{"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s854719131", "group_id": "codeNet:p00009", "input_text": "let for_range s e step f =\n let rec loop i =\n if i > e then ()\n else\n begin f i;loop (i + step) end\n in loop s;;\n\nlet a =\n let num = 1000000 in\n let p = Array.init (num+1) (fun x -> 1) in\n let rec loop i =\n if i*i < num then\n begin\n if p.(i) = 1 then\n for_range (i+i) num i (fun x -> p.(x) <- 0);\n loop (i+2)\n end\n in\n p.(0) <- 0; p.(1)<-(0);\n for_range 4 num 2 (fun x -> p.(x) <- 0);\n loop 3;\n for i = 1 to num-1 do\n p.(i) <- p.(i) + p.(i-1);\n done;\n let rec read () =\n try let n = read_int () in\n Printf.printf \"%d\\n\" p.(n);\n read ()\n with End_of_file -> ()\n in read ();;", "language": "OCaml", "metadata": {"date": 1468679840, "filename_ext": "ml", "original_language": "OCaml", "problem_description_relpath": "problem_descriptions/p00009.html", "problem_id": "p00009", "resource_group": "low_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/OCaml/s854719131.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s854719131", "user_id": "u935184340"}, "prompt_components": {"gold_output": "4\n2\n5\n", "input_to_evaluate": "let for_range s e step f =\n let rec loop i =\n if i > e then ()\n else\n begin f i;loop (i + step) end\n in loop s;;\n\nlet a =\n let num = 1000000 in\n let p = Array.init (num+1) (fun x -> 1) in\n let rec loop i =\n if i*i < num then\n begin\n if p.(i) = 1 then\n for_range (i+i) num i (fun x -> p.(x) <- 0);\n loop (i+2)\n end\n in\n p.(0) <- 0; p.(1)<-(0);\n for_range 4 num 2 (fun x -> p.(x) <- 0);\n loop 3;\n for i = 1 to num-1 do\n p.(i) <- p.(i) + p.(i-1);\n done;\n let rec read () =\n try let n = read_int () in\n Printf.printf \"%d\\n\" p.(n);\n read ()\n with End_of_file -> ()\n in read ();;", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 20, "memory_kb": 10196}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s053276923", "group_id": "codeNet:p00009", "input_text": "let m=1000000open Array;;let a,b=make m 1,make m 0;;a.(0)<-0;;let rec($)i j=if i*j()", "language": "OCaml", "metadata": {"date": 1474171934, "filename_ext": "ml", "original_language": "OCaml", "problem_description_relpath": "problem_descriptions/p00009.html", "problem_id": "p00009", "resource_group": "low_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/OCaml/s053276923.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s053276923", "user_id": "u809138450"}, "prompt_components": {"gold_output": "4\n2\n5\n", "input_to_evaluate": "let m=1000000open Array;;let a,b=make m 1,make m 0;;a.(0)<-0;;let rec($)i j=if i*j()", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 10, "memory_kb": 18172}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s098060884", "group_id": "codeNet:p00009", "input_text": "let for_range s e step f =\n let rec loop i =\n if i <= e then begin f i;loop (i + step) end\n in loop s;;\n \nlet sieve num =\n let p = Array.init num (fun x -> x mod 2) in\n let rec loop i =\n if i*i < num then\n begin\n if p.(i) = 1 then for_range (i*i) num (i*2) (fun x -> p.(x) <- 0);\n loop (i+2)\n end\n in\n p.(0) <- 0; p.(1)<-(0);p.(2)<-1;loop 3;\n for i = 3 to num-1 do\n p.(i) <- p.(i) + p.(i-1);\n done;\n p\n;;\n \nlet _ =\n let p = sieve 1000000 in\n let rec read () =\n try let n = read_int () in\n Printf.printf \"%d\\n\" p.(n);\n read ()\n with End_of_file -> ()\n in read ()\n;;", "language": "OCaml", "metadata": {"date": 1474312908, "filename_ext": "ml", "original_language": "OCaml", "problem_description_relpath": "problem_descriptions/p00009.html", "problem_id": "p00009", "resource_group": "low_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/OCaml/s098060884.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s098060884", "user_id": "u935184340"}, "prompt_components": {"gold_output": "4\n2\n5\n", "input_to_evaluate": "let for_range s e step f =\n let rec loop i =\n if i <= e then begin f i;loop (i + step) end\n in loop s;;\n \nlet sieve num =\n let p = Array.init num (fun x -> x mod 2) in\n let rec loop i =\n if i*i < num then\n begin\n if p.(i) = 1 then for_range (i*i) num (i*2) (fun x -> p.(x) <- 0);\n loop (i+2)\n end\n in\n p.(0) <- 0; p.(1)<-(0);p.(2)<-1;loop 3;\n for i = 3 to num-1 do\n p.(i) <- p.(i) + p.(i-1);\n done;\n p\n;;\n \nlet _ =\n let p = sieve 1000000 in\n let rec read () =\n try let n = read_int () in\n Printf.printf \"%d\\n\" p.(n);\n read ()\n with End_of_file -> ()\n in read ()\n;;", "problem_context": "Prime Number\n\nWrite a program which reads an integer n and prints the number of prime numbers which are less than or equal to n. A prime number is a natural number which has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5 and 7.\n\nInput\n\nInput consists of several datasets. Each dataset has an integer n (1 ≤ n ≤ 999,999) in a line.\n\nThe number of datasets is less than or equal to 30.\n\nOutput\n\nFor each dataset, prints the number of prime numbers.\n\nSample Input\n\n10\n3\n11\n\nOutput for the Sample Input\n\n4\n2\n5", "sample_input": "10\n3\n11\n"}, "reference_outputs": ["4\n2\n5\n"], "source_document_id": "p00009", "source_text": "Prime Number\n\nWrite a program which reads an integer n and prints the number of prime numbers which are less than or equal to n. A prime number is a natural number which has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5 and 7.\n\nInput\n\nInput consists of several datasets. Each dataset has an integer n (1 ≤ n ≤ 999,999) in a line.\n\nThe number of datasets is less than or equal to 30.\n\nOutput\n\nFor each dataset, prints the number of prime numbers.\n\nSample Input\n\n10\n3\n11\n\nOutput for the Sample Input\n\n4\n2\n5", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 629, "cpu_time_ms": 10, "memory_kb": 10148}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s154615363", "group_id": "codeNet:p00202", "input_text": "open Scanf\n\nlet iota ?(init=0) ?(step=1) n =\n let rec iota i n acc =\n if i = 0 then List.rev acc\n else iota (i - 1) (n + step) (n :: acc) in\n iota n init []\n\nlet rec primes last =\n if last < 2 then []\n else if last = 2 then [2]\n else if last mod 2 = 0 then primes (last - 1)\n else\n let index n = (n - 3) / 2 in\n let value i = 2 * i + 3 in\n let last_index = index last in\n let sieve = Array.make (last_index + 1) true in\n let rec mark i step =\n if i < Array.length sieve then begin\n sieve.(i) <- false;\n mark (i + step) step\n end\n else () in\n let primes = ref [2] in\n for i = 0 to last_index do\n if sieve.(i) then begin\n primes := (value i) :: !primes;\n mark (2 * i * i + 6 * i + 3) (value i)\n end\n done;\n !primes\n\nlet rec matches budget prices =\n if budget = 0 then true\n else\n match prices with\n | [] -> false\n | price :: prices when price > budget -> matches budget prices\n | price :: prices' ->\n try\n List.rev_map\n (fun m -> budget - price * m)\n (iota ~init:1 (budget / price))\n |> List.exists (fun budget -> matches budget prices')\n with Not_found -> matches budget prices'\n\nlet read_lines n =\n let rec read_lines n acc =\n if n = 0 then List.rev acc\n else read_lines (pred n) ((read_line ())::acc) in\n read_lines n []\n\nlet rec solve () =\n sscanf\n (read_line ()) \"%d %d\"\n (fun n budget ->\n if n = 0 && budget = 0 then ()\n else\n let prices =\n List.map int_of_string (read_lines n)\n |> List.sort (fun (a : int) b -> compare b a) in\n let result =\n try\n List.find (fun prime -> matches prime prices) (primes budget)\n |> string_of_int\n with Not_found -> \"NA\" in\n print_endline result;\n solve ())\n\nlet () = solve ()", "language": "OCaml", "metadata": {"date": 1451549752, "filename_ext": "ml", "original_language": "OCaml", "problem_description_relpath": "problem_descriptions/p00202.html", "problem_id": "p00202", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p00202/input.txt", "sample_output_relpath": "derived/input_output/data/p00202/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00202/OCaml/s154615363.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s154615363", "user_id": "u093524693"}, "prompt_components": {"gold_output": "14983\nNA\n200909\n", "input_to_evaluate": "open Scanf\n\nlet iota ?(init=0) ?(step=1) n =\n let rec iota i n acc =\n if i = 0 then List.rev acc\n else iota (i - 1) (n + step) (n :: acc) in\n iota n init []\n\nlet rec primes last =\n if last < 2 then []\n else if last = 2 then [2]\n else if last mod 2 = 0 then primes (last - 1)\n else\n let index n = (n - 3) / 2 in\n let value i = 2 * i + 3 in\n let last_index = index last in\n let sieve = Array.make (last_index + 1) true in\n let rec mark i step =\n if i < Array.length sieve then begin\n sieve.(i) <- false;\n mark (i + step) step\n end\n else () in\n let primes = ref [2] in\n for i = 0 to last_index do\n if sieve.(i) then begin\n primes := (value i) :: !primes;\n mark (2 * i * i + 6 * i + 3) (value i)\n end\n done;\n !primes\n\nlet rec matches budget prices =\n if budget = 0 then true\n else\n match prices with\n | [] -> false\n | price :: prices when price > budget -> matches budget prices\n | price :: prices' ->\n try\n List.rev_map\n (fun m -> budget - price * m)\n (iota ~init:1 (budget / price))\n |> List.exists (fun budget -> matches budget prices')\n with Not_found -> matches budget prices'\n\nlet read_lines n =\n let rec read_lines n acc =\n if n = 0 then List.rev acc\n else read_lines (pred n) ((read_line ())::acc) in\n read_lines n []\n\nlet rec solve () =\n sscanf\n (read_line ()) \"%d %d\"\n (fun n budget ->\n if n = 0 && budget = 0 then ()\n else\n let prices =\n List.map int_of_string (read_lines n)\n |> List.sort (fun (a : int) b -> compare b a) in\n let result =\n try\n List.find (fun prime -> matches prime prices) (primes budget)\n |> string_of_int\n with Not_found -> \"NA\" in\n print_endline result;\n solve ())\n\nlet () = solve ()", "problem_context": "上司のおごり\n\n会津太郎さんの会社には、割り切れない事が大嫌いな上司がいます。太郎さんがその上司と食事に行くときは、割り勘で会計をしているのですが、支払金額が参加人数で割り切れないときは、いつも上司がおごってくれています。\n\nある日、太郎さんは食事会の幹事になりました。お金の少ない太郎さんは、その上司を誘ってなんとかおごってもらえるように出来ないか考えました。もう料理屋に注文をしなければならないのですが、まだ何人参加するかは分からないので、どんな人数が参加してもおごってもらえるような注文をしておきたいようです。太郎さんの同期で、同じく食事会に参加する予定のあなたは、太郎さんに協力して、予算額以下で最大のどんな人数でも割り切れない金額を算出することにしました。\n\n料理の種類、各料理の料金、予算額を入力とし、予算額以下で最大のどんな数字でも割り切れない合計金額(ただし、 1 と合計金額は除く)を出力するプログラムを作成してください。なお、各種類の料理は複数個注文できますが、全種類の料理を注文する必要はありません。ただし、このような合計金額がない場合は、 NA と出力してください。\n\nInput\n\n複数のデータセットの並びが入力として与えられます。 入力の終わりはゼロふたつの行で示されます。\n各データセットは以下の形式で与えられます。\n\nn x\nv1\nv2\n:\nvn\n\n1 行目に料理の種類 n (1 ≤ n ≤ 30) と予算額 x (1 ≤ x ≤ 1000000) が空白区切りで与えられます。続くn 行に i 種類目の料理の金額を表す整数 vi (1 ≤ vi ≤ 1000000) が与えられます。\n\nデータセットの数は 100 を超えません。\n\nOutput\n\n入力データセットごとに、予算額に最も近い合計金額、または NA を1行に出力します。\n\nSample Input\n\n4 15000\n305\n260\n129\n500\n3 400\n10\n20\n30\n3 200909\n5\n9\n12\n0 0\n\nOutput for the Sample Input\n\n14983\nNA\n200909", "sample_input": "4 15000\n305\n260\n129\n500\n3 400\n10\n20\n30\n3 200909\n5\n9\n12\n0 0\n"}, "reference_outputs": ["14983\nNA\n200909\n"], "source_document_id": "p00202", "source_text": "上司のおごり\n\n会津太郎さんの会社には、割り切れない事が大嫌いな上司がいます。太郎さんがその上司と食事に行くときは、割り勘で会計をしているのですが、支払金額が参加人数で割り切れないときは、いつも上司がおごってくれています。\n\nある日、太郎さんは食事会の幹事になりました。お金の少ない太郎さんは、その上司を誘ってなんとかおごってもらえるように出来ないか考えました。もう料理屋に注文をしなければならないのですが、まだ何人参加するかは分からないので、どんな人数が参加してもおごってもらえるような注文をしておきたいようです。太郎さんの同期で、同じく食事会に参加する予定のあなたは、太郎さんに協力して、予算額以下で最大のどんな人数でも割り切れない金額を算出することにしました。\n\n料理の種類、各料理の料金、予算額を入力とし、予算額以下で最大のどんな数字でも割り切れない合計金額(ただし、 1 と合計金額は除く)を出力するプログラムを作成してください。なお、各種類の料理は複数個注文できますが、全種類の料理を注文する必要はありません。ただし、このような合計金額がない場合は、 NA と出力してください。\n\nInput\n\n複数のデータセットの並びが入力として与えられます。 入力の終わりはゼロふたつの行で示されます。\n各データセットは以下の形式で与えられます。\n\nn x\nv1\nv2\n:\nvn\n\n1 行目に料理の種類 n (1 ≤ n ≤ 30) と予算額 x (1 ≤ x ≤ 1000000) が空白区切りで与えられます。続くn 行に i 種類目の料理の金額を表す整数 vi (1 ≤ vi ≤ 1000000) が与えられます。\n\nデータセットの数は 100 を超えません。\n\nOutput\n\n入力データセットごとに、予算額に最も近い合計金額、または NA を1行に出力します。\n\nSample Input\n\n4 15000\n305\n260\n129\n500\n3 400\n10\n20\n30\n3 200909\n5\n9\n12\n0 0\n\nOutput for the Sample Input\n\n14983\nNA\n200909", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1883, "cpu_time_ms": 970, "memory_kb": 66500}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s744620655", "group_id": "codeNet:p00257", "input_text": "open Printf\nopen Scanf\n\nlet id x = x\n\nlet solve m n sg =\n let am = Array.make_matrix (n + 2) (n + 2) false in\n let que = Queue.create () in\n let ars = Array.make (n + 2) false in\n let arg = Array.make (n + 2) false in\n for i = 0 to n do\n for j = 1 to m do\n let k = if i + j >= n + 1 then n + 1 else i + j + sg.(i + j) in\n am.(i).(min (max 0 k) (n + 1)) <- true\n done\n done;\n Queue.push 0 que;\n ars.(0) <- true;\n while (not (Queue.is_empty que)) do\n let i = Queue.pop que in\n for j = 0 to n + 1 do\n if am.(i).(j) then\n begin\n if ars.(j) then ()\n else begin\n ars.(j) <- true;\n Queue.push j que\n end\n end\n else ()\n done\n done;\n Queue.push (n + 1) que;\n arg.(n + 1) <- true;\n while (not (Queue.is_empty que)) do\n let i = Queue.pop que in\n for j = 0 to n + 1 do\n if am.(j).(i) then\n begin\n if arg.(j) then ()\n else begin\n arg.(j) <- true;\n Queue.push j que\n end\n end\n else ()\n done\n done;\n let rec iter i =\n if i = n + 2 then printf \"OK\\n\"\n else if ars.(i) && not arg.(i) then\n printf \"NG\\n\"\n else iter (i + 1) in\n iter 0\n \nlet () = \n let rec loop () = \n let m = scanf \"%d \" id in\n if m = 0 then ()\n else\n begin\n let n = scanf \"%d \" id in\n let sg = Array.make (n + 2) 0 in\n for i = 1 to n do\n let d = scanf \"%d \" id in\n sg.(i) <- d\n done;\n solve m n sg;\n loop ()\n end\n in loop ()\n\n", "language": "OCaml", "metadata": {"date": 1590910641, "filename_ext": "ml", "original_language": "OCaml", "problem_description_relpath": "problem_descriptions/p00257.html", "problem_id": "p00257", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p00257/input.txt", "sample_output_relpath": "derived/input_output/data/p00257/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00257/OCaml/s744620655.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s744620655", "user_id": "u049242937"}, "prompt_components": {"gold_output": "OK\nNG\nNG\n", "input_to_evaluate": "open Printf\nopen Scanf\n\nlet id x = x\n\nlet solve m n sg =\n let am = Array.make_matrix (n + 2) (n + 2) false in\n let que = Queue.create () in\n let ars = Array.make (n + 2) false in\n let arg = Array.make (n + 2) false in\n for i = 0 to n do\n for j = 1 to m do\n let k = if i + j >= n + 1 then n + 1 else i + j + sg.(i + j) in\n am.(i).(min (max 0 k) (n + 1)) <- true\n done\n done;\n Queue.push 0 que;\n ars.(0) <- true;\n while (not (Queue.is_empty que)) do\n let i = Queue.pop que in\n for j = 0 to n + 1 do\n if am.(i).(j) then\n begin\n if ars.(j) then ()\n else begin\n ars.(j) <- true;\n Queue.push j que\n end\n end\n else ()\n done\n done;\n Queue.push (n + 1) que;\n arg.(n + 1) <- true;\n while (not (Queue.is_empty que)) do\n let i = Queue.pop que in\n for j = 0 to n + 1 do\n if am.(j).(i) then\n begin\n if arg.(j) then ()\n else begin\n arg.(j) <- true;\n Queue.push j que\n end\n end\n else ()\n done\n done;\n let rec iter i =\n if i = n + 2 then printf \"OK\\n\"\n else if ars.(i) && not arg.(i) then\n printf \"NG\\n\"\n else iter (i + 1) in\n iter 0\n \nlet () = \n let rec loop () = \n let m = scanf \"%d \" id in\n if m = 0 then ()\n else\n begin\n let n = scanf \"%d \" id in\n let sg = Array.make (n + 2) 0 in\n for i = 1 to n do\n let d = scanf \"%d \" id in\n sg.(i) <- d\n done;\n solve m n sg;\n loop ()\n end\n in loop ()\n\n", "problem_context": "すごろくを作る\n\n太郎君は、子供会の催しでみんなで遊べるようにすごろくを作りました。ゲームをおもしろくするために、「ふりだし」と「あがり」以外のすごろくのマスのいくつかに「6つ進む」、「5つ戻る」のように指示を書き込んでいきました。ルーレットを回して出た数だけ進み、止まったマスに指示が書き込んであれば、その指示に従って移動します。ただし、指示に従って進んだ先のマスの指示には従いません。\n\nルーレットは1からある数までの間の数を等確率で出すことができるものとします。また、「あがり」に達するより大きな数が出たときや、指示に従うと「あがり」より先に進んでしまうときは「あがり」に移動します。指示に従って戻るときに「ふりだし」より前に戻ってしまうときは「ふりだし」に戻ることにします。\n\nところが、ルーレットとマスの指示によっては「あがり」にたどりつけない場合が出てきてしまいます。たとえば、図のようなすごろくを作ったとしましょう。1と2しか出ないルーレットを使うと、1,2の順に出れば「あがり」に行けますが、はじめに2が出たらその後は何が出ても永久に「あがり」にはたどり着けません。太郎君は、そうとは知らずに調子に乗ってあちこちのマスに指示を書き込んでしまいました。\n\nそこで、太郎君に代わって、ルーレットとマスの指示によっては、「あがり」にたどり着けない場合が生じるかどうか判定するプログラムを作成してください。\n\n入力\n\n入力は複数のデータセットからなる。入力の終わりはゼロ1つの行で示される。各データセットは以下の形式で与えられる。\n\nmax\nn\nd1\nd2\n.\n.\n.\ndn\n\n1行目にルーレットが出す数の最大値 max (2 ≤ max ≤ 250) が与えられ、2行目に「ふりだし」と「あがり」以外のマスの数 n (2 ≤ n ≤ 250) が与えられる。続く n 行に各マスの指示を表す数 di(-n ≤ di ≤ n) が与えられる。di がゼロのときは指示が書いていないことを、正の数のときは |di| 進む指示を、負の数のときは |di| 戻る指示を表す(ここで、|x| は x の絶対値を表す)。入力される値はすべて整数である。\n\nデータセットの数は 100 を超えない。\n\n出力\n\n各データセットごとに判定結果を1行に出力する。ルーレットとマスの指示によっては、「あがり」にたどり着けない場合が生じるときは「NG」、そうでなければ「OK」を出力する。\n\n入力例\n\n3\n3\n-2\n1\n0\n2\n4\n2\n0\n-1\n-2\n2\n2\n-2\n-2\n0\n\n出力例\n\nOK\nNG\nNG", "sample_input": "3\n3\n-2\n1\n0\n2\n4\n2\n0\n-1\n-2\n2\n2\n-2\n-2\n0\n"}, "reference_outputs": ["OK\nNG\nNG\n"], "source_document_id": "p00257", "source_text": "すごろくを作る\n\n太郎君は、子供会の催しでみんなで遊べるようにすごろくを作りました。ゲームをおもしろくするために、「ふりだし」と「あがり」以外のすごろくのマスのいくつかに「6つ進む」、「5つ戻る」のように指示を書き込んでいきました。ルーレットを回して出た数だけ進み、止まったマスに指示が書き込んであれば、その指示に従って移動します。ただし、指示に従って進んだ先のマスの指示には従いません。\n\nルーレットは1からある数までの間の数を等確率で出すことができるものとします。また、「あがり」に達するより大きな数が出たときや、指示に従うと「あがり」より先に進んでしまうときは「あがり」に移動します。指示に従って戻るときに「ふりだし」より前に戻ってしまうときは「ふりだし」に戻ることにします。\n\nところが、ルーレットとマスの指示によっては「あがり」にたどりつけない場合が出てきてしまいます。たとえば、図のようなすごろくを作ったとしましょう。1と2しか出ないルーレットを使うと、1,2の順に出れば「あがり」に行けますが、はじめに2が出たらその後は何が出ても永久に「あがり」にはたどり着けません。太郎君は、そうとは知らずに調子に乗ってあちこちのマスに指示を書き込んでしまいました。\n\nそこで、太郎君に代わって、ルーレットとマスの指示によっては、「あがり」にたどり着けない場合が生じるかどうか判定するプログラムを作成してください。\n\n入力\n\n入力は複数のデータセットからなる。入力の終わりはゼロ1つの行で示される。各データセットは以下の形式で与えられる。\n\nmax\nn\nd1\nd2\n.\n.\n.\ndn\n\n1行目にルーレットが出す数の最大値 max (2 ≤ max ≤ 250) が与えられ、2行目に「ふりだし」と「あがり」以外のマスの数 n (2 ≤ n ≤ 250) が与えられる。続く n 行に各マスの指示を表す数 di(-n ≤ di ≤ n) が与えられる。di がゼロのときは指示が書いていないことを、正の数のときは |di| 進む指示を、負の数のときは |di| 戻る指示を表す(ここで、|x| は x の絶対値を表す)。入力される値はすべて整数である。\n\nデータセットの数は 100 を超えない。\n\n出力\n\n各データセットごとに判定結果を1行に出力する。ルーレットとマスの指示によっては、「あがり」にたどり着けない場合が生じるときは「NG」、そうでなければ「OK」を出力する。\n\n入力例\n\n3\n3\n-2\n1\n0\n2\n4\n2\n0\n-1\n-2\n2\n2\n-2\n-2\n0\n\n出力例\n\nOK\nNG\nNG", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1582, "cpu_time_ms": 20, "memory_kb": 8428}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s594939651", "group_id": "codeNet:p00426", "input_text": "type trays = Tray of int list * int list * int list\n\ntype move_command = AB | BA | BC | CB\n\nlet finished = function\n | Tray (_, [], []) | Tray ([], [], _) -> true\n | _ -> false\n\nlet move (Tray (as_, bs, cs)) command =\n let move xs ys = match xs, ys with\n | x :: xs, [] -> (xs, [x])\n | x :: xs, y :: ys when x > y -> (xs, x :: y :: ys)\n | _ -> invalid_arg \"move\" in\n try\n Some\n begin\n match command with\n | AB -> let as_, bs = move as_ bs in Tray (as_, bs, cs)\n | BA -> let bs, as_ = move bs as_ in Tray (as_, bs, cs)\n | BC -> let bs, cs = move bs cs in Tray (as_, bs, cs)\n | CB -> let cs, bs = move cs bs in Tray (as_, bs, cs)\n end\n with Invalid_argument _ -> None\n\nlet next_states state =\n List.fold_left\n (fun acc ->\n function\n | None -> acc\n | Some s -> s :: acc)\n []\n @@ List.map (move state) [CB; BC; BA; AB]\n\nlet search initial_state max_swaps =\n let states = Queue.create () in\n Queue.push (initial_state, 0) states;\n let seen = Hashtbl.create 1024 in\n let rec search () =\n if Queue.length states = 0 then -1\n else\n let state, count = Queue.pop states in\n if finished state then count\n else if count > max_swaps then -1\n else if Hashtbl.mem seen state then search ()\n else\n begin\n Hashtbl.add seen state true;\n List.iter\n (fun next_state -> Queue.push (next_state, succ count) states)\n @@ List.filter\n (fun state -> not @@ Hashtbl.mem seen state)\n (next_states state);\n search ()\n end in\n search ()\n\nlet read_lines n =\n let rec read_lines n acc =\n if n = 0 then List.rev acc\n else read_lines (pred n) ((read_line ()) :: acc) in\n read_lines n []\n\nlet split str delim =\n let len = String.length str in\n let rec split offset acc =\n try\n let index = String.index_from str offset delim in\n split (index + 1) ((String.sub str offset (index - offset)) :: acc)\n with Not_found -> List.rev ((String.sub str offset (len - offset)) :: acc) in\n split 0 []\n\nlet rec solve () =\n let read_tray () =\n List.rev @@ List.tl @@ List.map int_of_string @@ split (read_line ()) ' ' in\n let line = read_line () in\n let n_cups, max_swaps = Scanf.sscanf line \"%d %d\" (fun n m -> (n, m)) in\n if (n_cups, max_swaps) = (0, 0) then ()\n else\n let tray_a = read_tray () in\n let tray_b = read_tray () in\n let tray_c = read_tray () in\n print_endline @@ string_of_int\n @@ search (Tray (tray_a, tray_b, tray_c)) max_swaps;\n solve ()\n\nlet () = solve ()", "language": "OCaml", "metadata": {"date": 1439706464, "filename_ext": "ml", "original_language": "OCaml", "problem_description_relpath": "problem_descriptions/p00426.html", "problem_id": "p00426", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p00426/input.txt", "sample_output_relpath": "derived/input_output/data/p00426/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p00426/OCaml/s594939651.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Memory Limit Exceeded", "submission_id": "s594939651", "user_id": "u093524693"}, "prompt_components": {"gold_output": "9\n3\n0\n-1\n", "input_to_evaluate": "type trays = Tray of int list * int list * int list\n\ntype move_command = AB | BA | BC | CB\n\nlet finished = function\n | Tray (_, [], []) | Tray ([], [], _) -> true\n | _ -> false\n\nlet move (Tray (as_, bs, cs)) command =\n let move xs ys = match xs, ys with\n | x :: xs, [] -> (xs, [x])\n | x :: xs, y :: ys when x > y -> (xs, x :: y :: ys)\n | _ -> invalid_arg \"move\" in\n try\n Some\n begin\n match command with\n | AB -> let as_, bs = move as_ bs in Tray (as_, bs, cs)\n | BA -> let bs, as_ = move bs as_ in Tray (as_, bs, cs)\n | BC -> let bs, cs = move bs cs in Tray (as_, bs, cs)\n | CB -> let cs, bs = move cs bs in Tray (as_, bs, cs)\n end\n with Invalid_argument _ -> None\n\nlet next_states state =\n List.fold_left\n (fun acc ->\n function\n | None -> acc\n | Some s -> s :: acc)\n []\n @@ List.map (move state) [CB; BC; BA; AB]\n\nlet search initial_state max_swaps =\n let states = Queue.create () in\n Queue.push (initial_state, 0) states;\n let seen = Hashtbl.create 1024 in\n let rec search () =\n if Queue.length states = 0 then -1\n else\n let state, count = Queue.pop states in\n if finished state then count\n else if count > max_swaps then -1\n else if Hashtbl.mem seen state then search ()\n else\n begin\n Hashtbl.add seen state true;\n List.iter\n (fun next_state -> Queue.push (next_state, succ count) states)\n @@ List.filter\n (fun state -> not @@ Hashtbl.mem seen state)\n (next_states state);\n search ()\n end in\n search ()\n\nlet read_lines n =\n let rec read_lines n acc =\n if n = 0 then List.rev acc\n else read_lines (pred n) ((read_line ()) :: acc) in\n read_lines n []\n\nlet split str delim =\n let len = String.length str in\n let rec split offset acc =\n try\n let index = String.index_from str offset delim in\n split (index + 1) ((String.sub str offset (index - offset)) :: acc)\n with Not_found -> List.rev ((String.sub str offset (len - offset)) :: acc) in\n split 0 []\n\nlet rec solve () =\n let read_tray () =\n List.rev @@ List.tl @@ List.map int_of_string @@ split (read_line ()) ' ' in\n let line = read_line () in\n let n_cups, max_swaps = Scanf.sscanf line \"%d %d\" (fun n m -> (n, m)) in\n if (n_cups, max_swaps) = (0, 0) then ()\n else\n let tray_a = read_tray () in\n let tray_b = read_tray () in\n let tray_c = read_tray () in\n print_endline @@ string_of_int\n @@ search (Tray (tray_a, tray_b, tray_c)) max_swaps;\n solve ()\n\nlet () = solve ()", "problem_context": "大きさが異なる n 個のコップと 3 つのトレイ(お盆)A,B,C があり,それらのコップは 3 つのトレイの上にそれぞれ何個かずつ一山に重ねて置かれている.ただし,どのトレイにおいても,そのトレイの中で一番小さいコップが一番下に, 2 番目に小さいコップがその上に, 3 番目に小さいコップがその上にと,小さい順に伏せて重ねてある.例えば,下図の右側は, n = 5 個のコップがトレイ A,B,C にそれぞれ 2 個,0 個,3 個重ねて置かれている状態を示している.\n\nこのように,コップの初期状態が与えられたとき,次の規則 1 〜 3 を守りながら,すべてのコップを A または C のどちらかのトレイに移動させるには何回移動を行えばよいかを求めたい.\n\n(規則 1) 1 回に 1 つのコップだけを移動させることができる.それは,そのトレイにあるコップの中で一番上のコップ(つまり,一番大きいコップ)である.\n\n(規則 2)大きいコップの上に小さいコップを重ねてはいけない.\n\n(規則 3)コップ 1 個の直接移動は,トレイ A から B,B から A,B から C,C から B のみが許され, A から C への直接移動や C から A への直接移動は許されない.\n\n n 個のコップの初期状態と整数 m が与えられたとき, m 回以内の移動で, A または C のどちらかのトレイにすべてのコップをまとめて重ねることができるかどうかを判定し,可能な場合には移動回数の最小値を,不可能な場合には -1 を出力するプログラムを作成しなさい.\n\n 入力ファイルの 1 行目には, n と m がこの順に空白を区切り文字として書いてある. 1 ≦ n ≦ 15 であり, 1 ≦ m ≦ 15000000 である. 2 行目,3 行目,4 行目には, 1 から n までの整数を何個かずつ 3 つのグループに分けて,それぞれのグループ内で小さい順(昇順)に並べたものが書いてある.ただし,各行の先頭(それらの整数の前)には,それらの個数が書いてある. 2 行目に書かれている整数(先頭の 1 つを除く)はトレイ A の上に重ねられている各コップの大きさを表す.同様に, 3 行目に書かれている整数(先頭の 1 つを除く)はトレイ B の上に重ねられている各コップの大きさを表し, 4 行目に書かれている整数(先頭の1つを除く)はトレイ C の上に重ねられている各コップの大きさを表す.\n\n入力例1\n\n入力例2\n\n入力例3\n\n入力例4\n\n3 10\n\n4 20\n\n2 5\n\n3 3\n\n0\n\n2 1 2\n\n2 1 2\n\n0\n\n1 1\n\n1 3\n\n0\n\n1 1\n\n2 2 3\n\n1 4\n\n0\n\n2 2 3\n\n \n\n出力例1\n\n出力例2\n\n出力例3\n\n出力例4\n\n9\n\n3\n\n0\n\n-1\n\n入力\n\n入力は複数のデータセットからなる.n, m がともに 0 のとき入力が終了する.データセットの数は 5 を超えない.\n\n出力\n\nデータセットごとに、移動回数または -1 を1行に出力する.\n\n入力例\n\n3 10\n0\n1 1\n2 2 3\n4 20\n2 1 2\n1 3\n1 4\n2 5\n2 1 2\n0\n0\n3 3\n0\n1 1\n2 2 3\n0 0\n\n出力例\n\n9\n3\n0\n-1\n\n各データセットの出力(移動回数または -1)の後に改行を入れること.\n\n上記問題文と自動審判に使われるデータは、情報オリンピック日本委員会が作成し公開している問題文と採点用テストデータです。", "sample_input": "3 10\n0\n1 1\n2 2 3\n4 20\n2 1 2\n1 3\n1 4\n2 5\n2 1 2\n0\n0\n3 3\n0\n1 1\n2 2 3\n0 0\n"}, "reference_outputs": ["9\n3\n0\n-1\n"], "source_document_id": "p00426", "source_text": "大きさが異なる n 個のコップと 3 つのトレイ(お盆)A,B,C があり,それらのコップは 3 つのトレイの上にそれぞれ何個かずつ一山に重ねて置かれている.ただし,どのトレイにおいても,そのトレイの中で一番小さいコップが一番下に, 2 番目に小さいコップがその上に, 3 番目に小さいコップがその上にと,小さい順に伏せて重ねてある.例えば,下図の右側は, n = 5 個のコップがトレイ A,B,C にそれぞれ 2 個,0 個,3 個重ねて置かれている状態を示している.\n\nこのように,コップの初期状態が与えられたとき,次の規則 1 〜 3 を守りながら,すべてのコップを A または C のどちらかのトレイに移動させるには何回移動を行えばよいかを求めたい.\n\n(規則 1) 1 回に 1 つのコップだけを移動させることができる.それは,そのトレイにあるコップの中で一番上のコップ(つまり,一番大きいコップ)である.\n\n(規則 2)大きいコップの上に小さいコップを重ねてはいけない.\n\n(規則 3)コップ 1 個の直接移動は,トレイ A から B,B から A,B から C,C から B のみが許され, A から C への直接移動や C から A への直接移動は許されない.\n\n n 個のコップの初期状態と整数 m が与えられたとき, m 回以内の移動で, A または C のどちらかのトレイにすべてのコップをまとめて重ねることができるかどうかを判定し,可能な場合には移動回数の最小値を,不可能な場合には -1 を出力するプログラムを作成しなさい.\n\n 入力ファイルの 1 行目には, n と m がこの順に空白を区切り文字として書いてある. 1 ≦ n ≦ 15 であり, 1 ≦ m ≦ 15000000 である. 2 行目,3 行目,4 行目には, 1 から n までの整数を何個かずつ 3 つのグループに分けて,それぞれのグループ内で小さい順(昇順)に並べたものが書いてある.ただし,各行の先頭(それらの整数の前)には,それらの個数が書いてある. 2 行目に書かれている整数(先頭の 1 つを除く)はトレイ A の上に重ねられている各コップの大きさを表す.同様に, 3 行目に書かれている整数(先頭の 1 つを除く)はトレイ B の上に重ねられている各コップの大きさを表し, 4 行目に書かれている整数(先頭の1つを除く)はトレイ C の上に重ねられている各コップの大きさを表す.\n\n入力例1\n\n入力例2\n\n入力例3\n\n入力例4\n\n3 10\n\n4 20\n\n2 5\n\n3 3\n\n0\n\n2 1 2\n\n2 1 2\n\n0\n\n1 1\n\n1 3\n\n0\n\n1 1\n\n2 2 3\n\n1 4\n\n0\n\n2 2 3\n\n \n\n出力例1\n\n出力例2\n\n出力例3\n\n出力例4\n\n9\n\n3\n\n0\n\n-1\n\n入力\n\n入力は複数のデータセットからなる.n, m がともに 0 のとき入力が終了する.データセットの数は 5 を超えない.\n\n出力\n\nデータセットごとに、移動回数または -1 を1行に出力する.\n\n入力例\n\n3 10\n0\n1 1\n2 2 3\n4 20\n2 1 2\n1 3\n1 4\n2 5\n2 1 2\n0\n0\n3 3\n0\n1 1\n2 2 3\n0 0\n\n出力例\n\n9\n3\n0\n-1\n\n各データセットの出力(移動回数または -1)の後に改行を入れること.\n\n上記問題文と自動審判に使われるデータは、情報オリンピック日本委員会が作成し公開している問題文と採点用テストデータです。", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2588, "cpu_time_ms": 10610, "memory_kb": 402528}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s576621483", "group_id": "codeNet:p02038", "input_text": "let init n f =\n let rec loop i l = if i < n then loop (i + 1) (f i :: l) else l in\n List.rev (loop 0 [])\n\nlet n = Scanf.scanf \"%d\\n\" (fun n -> n)\nlet ps = init n (fun _ -> Scanf.scanf \" %c\" (fun c -> c = 'T'))\nlet b = match ps with\n p :: ps -> List.fold_left (fun b p -> not b || p) p ps\n | _ -> raise (Failure \"\")\nlet () = if b then\n print_endline \"T\"\n else\n print_endline \"F\"\n\n", "language": "OCaml", "metadata": {"date": 1551847369, "filename_ext": "ml", "original_language": "OCaml", "problem_description_relpath": "problem_descriptions/p02038.html", "problem_id": "p02038", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02038/input.txt", "sample_output_relpath": "derived/input_output/data/p02038/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02038/OCaml/s576621483.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s576621483", "user_id": "u788273968"}, "prompt_components": {"gold_output": "T\n", "input_to_evaluate": "let init n f =\n let rec loop i l = if i < n then loop (i + 1) (f i :: l) else l in\n List.rev (loop 0 [])\n\nlet n = Scanf.scanf \"%d\\n\" (fun n -> n)\nlet ps = init n (fun _ -> Scanf.scanf \" %c\" (fun c -> c = 'T'))\nlet b = match ps with\n p :: ps -> List.fold_left (fun b p -> not b || p) p ps\n | _ -> raise (Failure \"\")\nlet () = if b then\n print_endline \"T\"\n else\n print_endline \"F\"\n\n", "problem_context": "B: たぬきつね\n\n問題\n\n謎の装置 $M$ があり,この装置に Tanuki と Fox を入れると, 装置から一匹の動物が出てくる(以下, Tanuki を $T$ ,Foxを $F$ とする).\n\n$M(x, y)$ は,装置 $M$ に $x, y$ の順で動物を入れて出てきた動物を表す.\n\n色々試した結果,以下のことがわかった.\n\n$M(T, T) = T$\n\n$M(T, F) = F$\n\n$M(F, T) = T$\n\n$M(F, F) = T$\n\nあなたは,一列に並んでいる動物たち $P_1, P_2, ... , P_N$ を以下のように装置に入れていった.\n\n$M(....M(M(P_1,P_2), P_3)...., P_N)$\n\n最後に出てくる動物を答えよ.\n\n制約\n\n$2 \\leq N \\leq 10^{5}$\n\n$P_i$ は $T$ か $F$ の一文字\n\n入力形式\n\n入力は以下の形式で与えられる.\n\n$N$\n\n$P_1\\ P_2\\ ...\\ P_N$\n\n出力\n\n最後に出てくる動物を表す文字 $T$ または $F$ を出力せよ.また,末尾に改行も出力せよ.\n\nサンプル\n\nサンプル入力 1\n\n3\nF T T\n\nサンプル出力 1\n\nT\n\nサンプル入力 2\n\n7\nF T T F T T F\n\nサンプル出力 2\n\nF", "sample_input": "3\nF T T\n"}, "reference_outputs": ["T\n"], "source_document_id": "p02038", "source_text": "B: たぬきつね\n\n問題\n\n謎の装置 $M$ があり,この装置に Tanuki と Fox を入れると, 装置から一匹の動物が出てくる(以下, Tanuki を $T$ ,Foxを $F$ とする).\n\n$M(x, y)$ は,装置 $M$ に $x, y$ の順で動物を入れて出てきた動物を表す.\n\n色々試した結果,以下のことがわかった.\n\n$M(T, T) = T$\n\n$M(T, F) = F$\n\n$M(F, T) = T$\n\n$M(F, F) = T$\n\nあなたは,一列に並んでいる動物たち $P_1, P_2, ... , P_N$ を以下のように装置に入れていった.\n\n$M(....M(M(P_1,P_2), P_3)...., P_N)$\n\n最後に出てくる動物を答えよ.\n\n制約\n\n$2 \\leq N \\leq 10^{5}$\n\n$P_i$ は $T$ か $F$ の一文字\n\n入力形式\n\n入力は以下の形式で与えられる.\n\n$N$\n\n$P_1\\ P_2\\ ...\\ P_N$\n\n出力\n\n最後に出てくる動物を表す文字 $T$ または $F$ を出力せよ.また,末尾に改行も出力せよ.\n\nサンプル\n\nサンプル入力 1\n\n3\nF T T\n\nサンプル出力 1\n\nT\n\nサンプル入力 2\n\n7\nF T T F T T F\n\nサンプル出力 2\n\nF", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 10, "memory_kb": 8536}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s494777794", "group_id": "codeNet:p02235", "input_text": "let lcs (x, y) =\n let m = String.length x in\n let n = String.length y in\n let dp = Array.make_matrix (m + 1) (n + 1) 0 in\n for i = 1 to m do\n for j = 1 to n do\n dp.(i).(j) <-\n if x.[i-1] = y.[j-1] then dp.(i-1).(j-1) + 1\n else if dp.(i-1).(j) > dp.(i).(j-1) then dp.(i-1).(j)\n else dp.(i).(j-1)\n done\n done;\n dp.(m).(n)\n\nlet () =\n let q = read_int () in\n for _ = 0 to q - 1 do\n Scanf.scanf \"%s\\n%s\\n\" (fun x y -> (x, y)) |> lcs |> Printf.printf \"%d\\n\"\n done", "language": "OCaml", "metadata": {"date": 1500197253, "filename_ext": "ml", "original_language": "OCaml", "problem_description_relpath": "problem_descriptions/p02235.html", "problem_id": "p02235", "resource_group": "low_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/OCaml/s494777794.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s494777794", "user_id": "u809138450"}, "prompt_components": {"gold_output": "4\n3\n2\n", "input_to_evaluate": "let lcs (x, y) =\n let m = String.length x in\n let n = String.length y in\n let dp = Array.make_matrix (m + 1) (n + 1) 0 in\n for i = 1 to m do\n for j = 1 to n do\n dp.(i).(j) <-\n if x.[i-1] = y.[j-1] then dp.(i-1).(j-1) + 1\n else if dp.(i-1).(j) > dp.(i).(j-1) then dp.(i-1).(j)\n else dp.(i).(j-1)\n done\n done;\n dp.(m).(n)\n\nlet () =\n let q = read_int () in\n for _ = 0 to q - 1 do\n Scanf.scanf \"%s\\n%s\\n\" (fun x y -> (x, y)) |> lcs |> Printf.printf \"%d\\n\"\n done", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 501, "cpu_time_ms": 180, "memory_kb": 18680}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s151527369", "group_id": "codeNet:p02240", "input_text": "let split_on_char sep s =\n let open String in\n let r = ref [] in\n let j = ref (length s) in\n for i = length s - 1 downto 0 do\n if get s i = sep then begin\n r := sub s (i + 1) (!j - i - 1) :: !r;\n j := i\n end\n done;\n sub s 0 !j :: !r\n\nlet read_ints () = read_line () |> split_on_char ' ' |> List.map int_of_string\n\nlet dfs vs n =\n let d = Array.make n (-1) in\n let rec doit i j =\n d.(i) <- j;\n List.iter (fun v -> if d.(v) = (-1) then doit v j) vs.(i) in\n Array.iteri (fun i e -> if e = (-1) then doit i i) d;\n d\n\nlet solve n m =\n let g = Array.make n [] in\n for _ = 0 to m - 1 do\n match read_ints () with\n | [s; t] ->\n g.(s) <- t :: g.(s);\n g.(t) <- s :: g.(t);\n | _ -> assert false\n done;\n let v = dfs g n in\n let q = read_int () in\n for _ = 0 to q - 1 do\n match read_ints () with\n | [s; t] -> print_endline (if v.(s) = v.(t) then \"yes\" else \"no\")\n | _ -> assert false\n done\n\nlet () =\n match read_ints () with\n | [n;m] -> solve n m\n | _ -> assert false", "language": "OCaml", "metadata": {"date": 1500266475, "filename_ext": "ml", "original_language": "OCaml", "problem_description_relpath": "problem_descriptions/p02240.html", "problem_id": "p02240", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02240/input.txt", "sample_output_relpath": "derived/input_output/data/p02240/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02240/OCaml/s151527369.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s151527369", "user_id": "u809138450"}, "prompt_components": {"gold_output": "yes\nyes\nno\n", "input_to_evaluate": "let split_on_char sep s =\n let open String in\n let r = ref [] in\n let j = ref (length s) in\n for i = length s - 1 downto 0 do\n if get s i = sep then begin\n r := sub s (i + 1) (!j - i - 1) :: !r;\n j := i\n end\n done;\n sub s 0 !j :: !r\n\nlet read_ints () = read_line () |> split_on_char ' ' |> List.map int_of_string\n\nlet dfs vs n =\n let d = Array.make n (-1) in\n let rec doit i j =\n d.(i) <- j;\n List.iter (fun v -> if d.(v) = (-1) then doit v j) vs.(i) in\n Array.iteri (fun i e -> if e = (-1) then doit i i) d;\n d\n\nlet solve n m =\n let g = Array.make n [] in\n for _ = 0 to m - 1 do\n match read_ints () with\n | [s; t] ->\n g.(s) <- t :: g.(s);\n g.(t) <- s :: g.(t);\n | _ -> assert false\n done;\n let v = dfs g n in\n let q = read_int () in\n for _ = 0 to q - 1 do\n match read_ints () with\n | [s; t] -> print_endline (if v.(s) = v.(t) then \"yes\" else \"no\")\n | _ -> assert false\n done\n\nlet () =\n match read_ints () with\n | [n;m] -> solve n m\n | _ -> assert false", "problem_context": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nConnected Components\n\nWrite a program which reads relations in a SNS (Social Network Service), and judges that given pairs of users are reachable each other through the network.\n\nInput\n\nIn the first line, two integer $n$ and $m$ are given. $n$ is the number of users in the SNS and $m$ is the number of relations in the SNS. The users in the SNS are identified by IDs $0, 1, ..., n-1$.\n\nIn the following $m$ lines, the relations are given. Each relation is given by two integers $s$ and $t$ that represents $s$ and $t$ are friends (and reachable each other).\n\nIn the next line, the number of queries $q$ is given. In the following $q$ lines, $q$ queries are given respectively. Each query consists of two integers $s$ and $t$ separated by a space character.\n\nOutput\n\nFor each query, print \"yes\" if $t$ is reachable from $s$ through the social network, \"no\" otherwise.\n\nConstraints\n\n$2 \\leq n \\leq 100,000$\n\n$0 \\leq m \\leq 100,000$\n\n$1 \\leq q \\leq 10,000$\n\nSample Input\n\n10 9\n0 1\n0 2\n3 4\n5 7\n5 6\n6 7\n6 8\n7 8\n8 9\n3\n0 1\n5 9\n1 3\n\nSample Output\n\nyes\nyes\nno", "sample_input": "10 9\n0 1\n0 2\n3 4\n5 7\n5 6\n6 7\n6 8\n7 8\n8 9\n3\n0 1\n5 9\n1 3\n"}, "reference_outputs": ["yes\nyes\nno\n"], "source_document_id": "p02240", "source_text": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nConnected Components\n\nWrite a program which reads relations in a SNS (Social Network Service), and judges that given pairs of users are reachable each other through the network.\n\nInput\n\nIn the first line, two integer $n$ and $m$ are given. $n$ is the number of users in the SNS and $m$ is the number of relations in the SNS. The users in the SNS are identified by IDs $0, 1, ..., n-1$.\n\nIn the following $m$ lines, the relations are given. Each relation is given by two integers $s$ and $t$ that represents $s$ and $t$ are friends (and reachable each other).\n\nIn the next line, the number of queries $q$ is given. In the following $q$ lines, $q$ queries are given respectively. Each query consists of two integers $s$ and $t$ separated by a space character.\n\nOutput\n\nFor each query, print \"yes\" if $t$ is reachable from $s$ through the social network, \"no\" otherwise.\n\nConstraints\n\n$2 \\leq n \\leq 100,000$\n\n$0 \\leq m \\leq 100,000$\n\n$1 \\leq q \\leq 10,000$\n\nSample Input\n\n10 9\n0 1\n0 2\n3 4\n5 7\n5 6\n6 7\n6 8\n7 8\n8 9\n3\n0 1\n5 9\n1 3\n\nSample Output\n\nyes\nyes\nno", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1024, "cpu_time_ms": 40, "memory_kb": 19016}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s044850401", "group_id": "codeNet:p02243", "input_text": "module MakeBinaryHeap (M : sig type t val compare : t -> t -> int end) = struct\n\n type t = { node : M.t array; mutable size : int }\n\n let make n (init : M.t) = { node = Array.make n init; size = 0 }\n\n let empty_p t = if t.size = 0 then true else false\n\n let pop t =\n if t.size <= 0 then failwith \"out of size\" else\n let rec max_heapify i =\n let l = 2*i in\n let r = 2*i + 1 in\n let m = if l <= t.size && M.compare t.node.(l) t.node.(i) > 0 then l else i in\n let m = if r <= t.size && M.compare t.node.(r) t.node.(m) > 0 then r else m in\n if m = i then ()\n else begin\n let tmp = t.node.(i) in\n t.node.(i) <- t.node.(m);\n t.node.(m) <- tmp;\n max_heapify m\n end in\n let ret = t.node.(1) in\n t.node.(1) <- t.node.(t.size);\n t.size <- t.size - 1;\n max_heapify 1;\n ret\n\n let push x t =\n let parent i = int_of_float (floor (float_of_int i) /. 2.) in\n let rec doit i =\n let p = parent i in\n if i <= 1 || M.compare t.node.(p) t.node.(i) >= 0 then ()\n else begin\n let tmp = t.node.(i) in\n t.node.(i) <- t.node.(p);\n t.node.(p) <- tmp;\n doit p\n end in\n t.size <- t.size + 1;\n t.node.(t.size) <- x;\n doit t.size\n\nend\n\nmodule H = MakeBinaryHeap(struct type t = (int * int) let compare (_, x) (_, y) = y - x end)\n\nlet dijkstra g n =\n let reached_p = Array.make n false in\n let min_costs = Array.make n max_int in\n min_costs.(0) <- 0;\n let h = H.make 500000 (0, 0) in\n H.push (0, 0) h;\n while not (H.empty_p h) do\n let (u, x) = H.pop h in\n reached_p.(u) <- true;\n if x > min_costs.(u) then ()\n else\n List.iter (fun (v, c) ->\n let x = min_costs.(u) + c in\n if not reached_p.(v) && x < min_costs.(v) then begin\n min_costs.(v) <- x;\n H.push (v, x) h;\n end) g.(u);\n done;\n min_costs\n\nlet rec make_pair acc = function\n | [] -> acc\n | v :: c :: tl -> make_pair ((v, c) :: acc) tl\n | _ -> assert false\n\nlet make_pair lst = make_pair [] lst\n\nlet split_on_char sep s =\n let open String in\n let r = ref [] in\n let j = ref (length s) in\n for i = length s - 1 downto 0 do\n if get s i = sep then begin\n r := sub s (i + 1) (!j - i - 1) :: !r;\n j := i\n end\n done;\n sub s 0 !j :: !r\n\nlet () =\n let n = read_int () in\n let g = Array.make n [] in\n for _ = 0 to n - 1 do\n match read_line () |> split_on_char ' ' |> List.map int_of_string with\n | u :: _ :: l -> g.(u) <- make_pair l\n | _ -> assert false\n done;\n dijkstra g n |> Array.iteri (fun i e -> Printf.printf \"%d %d\\n\" i e)", "language": "OCaml", "metadata": {"date": 1500426397, "filename_ext": "ml", "original_language": "OCaml", "problem_description_relpath": "problem_descriptions/p02243.html", "problem_id": "p02243", "resource_group": "low_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/OCaml/s044850401.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s044850401", "user_id": "u809138450"}, "prompt_components": {"gold_output": "0 0\n1 2\n2 2\n3 1\n4 3\n", "input_to_evaluate": "module MakeBinaryHeap (M : sig type t val compare : t -> t -> int end) = struct\n\n type t = { node : M.t array; mutable size : int }\n\n let make n (init : M.t) = { node = Array.make n init; size = 0 }\n\n let empty_p t = if t.size = 0 then true else false\n\n let pop t =\n if t.size <= 0 then failwith \"out of size\" else\n let rec max_heapify i =\n let l = 2*i in\n let r = 2*i + 1 in\n let m = if l <= t.size && M.compare t.node.(l) t.node.(i) > 0 then l else i in\n let m = if r <= t.size && M.compare t.node.(r) t.node.(m) > 0 then r else m in\n if m = i then ()\n else begin\n let tmp = t.node.(i) in\n t.node.(i) <- t.node.(m);\n t.node.(m) <- tmp;\n max_heapify m\n end in\n let ret = t.node.(1) in\n t.node.(1) <- t.node.(t.size);\n t.size <- t.size - 1;\n max_heapify 1;\n ret\n\n let push x t =\n let parent i = int_of_float (floor (float_of_int i) /. 2.) in\n let rec doit i =\n let p = parent i in\n if i <= 1 || M.compare t.node.(p) t.node.(i) >= 0 then ()\n else begin\n let tmp = t.node.(i) in\n t.node.(i) <- t.node.(p);\n t.node.(p) <- tmp;\n doit p\n end in\n t.size <- t.size + 1;\n t.node.(t.size) <- x;\n doit t.size\n\nend\n\nmodule H = MakeBinaryHeap(struct type t = (int * int) let compare (_, x) (_, y) = y - x end)\n\nlet dijkstra g n =\n let reached_p = Array.make n false in\n let min_costs = Array.make n max_int in\n min_costs.(0) <- 0;\n let h = H.make 500000 (0, 0) in\n H.push (0, 0) h;\n while not (H.empty_p h) do\n let (u, x) = H.pop h in\n reached_p.(u) <- true;\n if x > min_costs.(u) then ()\n else\n List.iter (fun (v, c) ->\n let x = min_costs.(u) + c in\n if not reached_p.(v) && x < min_costs.(v) then begin\n min_costs.(v) <- x;\n H.push (v, x) h;\n end) g.(u);\n done;\n min_costs\n\nlet rec make_pair acc = function\n | [] -> acc\n | v :: c :: tl -> make_pair ((v, c) :: acc) tl\n | _ -> assert false\n\nlet make_pair lst = make_pair [] lst\n\nlet split_on_char sep s =\n let open String in\n let r = ref [] in\n let j = ref (length s) in\n for i = length s - 1 downto 0 do\n if get s i = sep then begin\n r := sub s (i + 1) (!j - i - 1) :: !r;\n j := i\n end\n done;\n sub s 0 !j :: !r\n\nlet () =\n let n = read_int () in\n let g = Array.make n [] in\n for _ = 0 to n - 1 do\n match read_line () |> split_on_char ' ' |> List.map int_of_string with\n | u :: _ :: l -> g.(u) <- make_pair l\n | _ -> assert false\n done;\n dijkstra g n |> Array.iteri (fun i e -> Printf.printf \"%d %d\\n\" i e)", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2599, "cpu_time_ms": 80, "memory_kb": 33780}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s779907342", "group_id": "codeNet:p02243", "input_text": "module MakeBinaryHeap (M : sig type t val compare : t -> t -> int end) = struct\n\n type t = { node : M.t array; mutable size : int }\n\n let make n (init : M.t) = { node = Array.make n init; size = 0 }\n\n let empty_p t = if t.size = 0 then true else false\n\n let pop t =\n let rec max_heapify i =\n let l = 2*i in\n let r = 2*i + 1 in\n let m = if l <= t.size && M.compare t.node.(l) t.node.(i) > 0 then l else i in\n let m = if r <= t.size && M.compare t.node.(r) t.node.(m) > 0 then r else m in\n if m = i then ()\n else begin\n let tmp = t.node.(i) in\n t.node.(i) <- t.node.(m);\n t.node.(m) <- tmp;\n max_heapify m\n end in\n let ret = t.node.(1) in\n t.node.(1) <- t.node.(t.size);\n t.size <- t.size - 1;\n max_heapify 1;\n ret\n\n let push x t =\n let parent i = int_of_float (floor (float_of_int i) /. 2.) in\n let rec doit i =\n let p = parent i in\n if i <= 1 || M.compare t.node.(p) t.node.(i) >= 0 then ()\n else begin\n let tmp = t.node.(i) in\n t.node.(i) <- t.node.(p);\n t.node.(p) <- tmp;\n doit p\n end in\n t.size <- t.size + 1;\n t.node.(t.size) <- x;\n doit t.size\n\nend\n\nmodule H = MakeBinaryHeap(struct type t = (int * int) let compare (_, x) (_, y) = y - x end)\n\nlet dijkstra g n =\n let reached_p = Array.make n false in\n let d = Array.make n max_int in\n d.(0) <- 0;\n let h = H.make 30000 (0, 0) in\n H.push (0, 0) h;\n while not (H.empty_p h) do\n let (u, x) = H.pop h in\n reached_p.(u) <- true;\n if x > d.(u) then ()\n else\n List.iter (fun (v, c) ->\n let x = d.(u) + c in\n if not reached_p.(v) && x < d.(v) then begin\n d.(v) <- x;\n H.push (v, x) h;\n end) g.(u)\n done;\n d\n\nlet rec make_pair acc = function\n | [] -> acc\n | v :: c :: tl -> make_pair ((v, c) :: acc) tl\n | _ -> assert false\n\nlet make_pair lst = make_pair [] lst\n\nlet split_on_char sep s =\n let open String in\n let r = ref [] in\n let j = ref (length s) in\n for i = length s - 1 downto 0 do\n if get s i = sep then begin\n r := sub s (i + 1) (!j - i - 1) :: !r;\n j := i\n end\n done;\n sub s 0 !j :: !r\n\nlet () =\n let n = read_int () in\n let g = Array.make n [] in\n for _ = 0 to n - 1 do\n match read_line () |> split_on_char ' ' |> List.map int_of_string with\n | u :: _ :: l -> g.(u) <- make_pair l\n | _ -> assert false\n done;\n dijkstra g n |> Array.iteri (fun i e -> Printf.printf \"%d %d\\n\" i e)", "language": "OCaml", "metadata": {"date": 1500465648, "filename_ext": "ml", "original_language": "OCaml", "problem_description_relpath": "problem_descriptions/p02243.html", "problem_id": "p02243", "resource_group": "low_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/OCaml/s779907342.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s779907342", "user_id": "u809138450"}, "prompt_components": {"gold_output": "0 0\n1 2\n2 2\n3 1\n4 3\n", "input_to_evaluate": "module MakeBinaryHeap (M : sig type t val compare : t -> t -> int end) = struct\n\n type t = { node : M.t array; mutable size : int }\n\n let make n (init : M.t) = { node = Array.make n init; size = 0 }\n\n let empty_p t = if t.size = 0 then true else false\n\n let pop t =\n let rec max_heapify i =\n let l = 2*i in\n let r = 2*i + 1 in\n let m = if l <= t.size && M.compare t.node.(l) t.node.(i) > 0 then l else i in\n let m = if r <= t.size && M.compare t.node.(r) t.node.(m) > 0 then r else m in\n if m = i then ()\n else begin\n let tmp = t.node.(i) in\n t.node.(i) <- t.node.(m);\n t.node.(m) <- tmp;\n max_heapify m\n end in\n let ret = t.node.(1) in\n t.node.(1) <- t.node.(t.size);\n t.size <- t.size - 1;\n max_heapify 1;\n ret\n\n let push x t =\n let parent i = int_of_float (floor (float_of_int i) /. 2.) in\n let rec doit i =\n let p = parent i in\n if i <= 1 || M.compare t.node.(p) t.node.(i) >= 0 then ()\n else begin\n let tmp = t.node.(i) in\n t.node.(i) <- t.node.(p);\n t.node.(p) <- tmp;\n doit p\n end in\n t.size <- t.size + 1;\n t.node.(t.size) <- x;\n doit t.size\n\nend\n\nmodule H = MakeBinaryHeap(struct type t = (int * int) let compare (_, x) (_, y) = y - x end)\n\nlet dijkstra g n =\n let reached_p = Array.make n false in\n let d = Array.make n max_int in\n d.(0) <- 0;\n let h = H.make 30000 (0, 0) in\n H.push (0, 0) h;\n while not (H.empty_p h) do\n let (u, x) = H.pop h in\n reached_p.(u) <- true;\n if x > d.(u) then ()\n else\n List.iter (fun (v, c) ->\n let x = d.(u) + c in\n if not reached_p.(v) && x < d.(v) then begin\n d.(v) <- x;\n H.push (v, x) h;\n end) g.(u)\n done;\n d\n\nlet rec make_pair acc = function\n | [] -> acc\n | v :: c :: tl -> make_pair ((v, c) :: acc) tl\n | _ -> assert false\n\nlet make_pair lst = make_pair [] lst\n\nlet split_on_char sep s =\n let open String in\n let r = ref [] in\n let j = ref (length s) in\n for i = length s - 1 downto 0 do\n if get s i = sep then begin\n r := sub s (i + 1) (!j - i - 1) :: !r;\n j := i\n end\n done;\n sub s 0 !j :: !r\n\nlet () =\n let n = read_int () in\n let g = Array.make n [] in\n for _ = 0 to n - 1 do\n match read_line () |> split_on_char ' ' |> List.map int_of_string with\n | u :: _ :: l -> g.(u) <- make_pair l\n | _ -> assert false\n done;\n dijkstra g n |> Array.iteri (fun i e -> Printf.printf \"%d %d\\n\" i e)", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2489, "cpu_time_ms": 80, "memory_kb": 29892}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s526214553", "group_id": "codeNet:p02244", "input_text": "module ArrayL = ArrayLabels\nmodule ListL = ListLabels\n\nlet dbg = Printf.printf \"[debug]%s\"\n\nlet max_num = 100_000_000_000\n\nlet id = fun x -> x\nlet tuple2 x y = (x,y)\nlet tuple3 x y z = (x,y,z)\nlet succ x = x + 1\nlet pred x = x - 1\n\nlet (++) n m =\n let rec aux i =\n if i = m then [m]\n else i :: aux (i+1) in\n if n > m then [] else aux n\n\nlet (++^) n m = n ++ (m-1)\n\nlet scan fmt f = Scanf.sscanf (read_line ()) fmt f\n\nlet scan_list ~sep cnv =\n let line = read_line () in\n Str.split (Str.regexp_string sep) line\n |> List.map cnv\n\nlet scan_lines n fmt f =\n List.map (fun _ -> scan fmt f) (0++^n)\n\nlet scan_matrix n m e conv =\n let arr = Array.make_matrix n m e in\n Array.iteri (fun i line ->\n let s = Scanf.Scanning.from_string @@ read_line () in\n Array.iteri (fun j _ ->\n arr.(i).(j) <- Scanf.bscanf s \" %s\" conv;\n ) line) arr; arr\n\nlet rec powerset = function\n | [] -> [[]]\n | hd::tl ->\n let pws = powerset tl in\n pws @ ListL.map pws ~f:(fun pw -> hd::pw)\n\nlet permutations l =\n let rec interleave x = function\n | [] -> [[x]]\n | (hd::tl) as l ->\n (x::l) :: (interleave x tl |> ListL.map ~f:(fun l -> hd::l)) in\n let rec aux = function\n | [] -> [[]]\n | a::rest ->\n aux rest |> ListL.map ~f:(interleave a) |> List.concat in\n aux l\n\nlet between n x m = n <= x && x < m\n\nlet string_to_list s =\n List.map (String.get s) (0 ++^ String.length s)\n\nlet n = scan \"%d\" id\nlet ls = scan_lines n \"%d %d\" tuple2\n\nexception Found of int array array\nlet print_mat mat =\n ArrayL.iter mat ~f:(fun a ->\n ArrayL.iter a ~f:(fun v ->\n if v = 0 then Printf.printf \".\"\n else Printf.printf \"Q\"\n );\n Printf.printf \"\\n\"\n )\n\nlet () =\n let sets = permutations (0++^8) in\n (try ListL.iter sets ~f:(fun set ->\n let mat = Array.make_matrix 8 8 0 in\n ListL.iteri set ~f:(fun i n -> mat.(i).(n) <- 1;);\n if not @@ ListL.for_all ls ~f:(fun (i, j) -> mat.(i).(j) = 1) then ()\n else\n if ListL.map (0++^8) ~f:(fun i ->\n ListL.map (0++^8) ~f:(fun j ->\n if mat.(i).(j) = 1 then\n ListL.for_all (0++^8) ~f:(fun k -> k = i || mat.(k).(j) = 0)\n && ListL.for_all (1++^8) ~f:(fun k -> i-k < 0 || j-k < 0 || mat.(i-k).(j-k) = 0)\n && ListL.for_all (1++^8) ~f:(fun k -> i+k >= 8 || j+k >= 8 || mat.(i+k).(j+k) = 0)\n && ListL.for_all (1++^8) ~f:(fun k -> i-k < 0 || j+k >= 8 || mat.(i-k).(j+k) = 0)\n && ListL.for_all (1++^8) ~f:(fun k -> i+k >= 8 || j-k < 0 || mat.(i+k).(j-k) = 0)\n else true))\n |> List.concat |> List.for_all ((=) true) then raise @@ Found mat else ());\n Array.make_matrix 8 8 0\n with\n | Found x -> x)\n |> print_mat\n\n", "language": "OCaml", "metadata": {"date": 1591418645, "filename_ext": "ml", "original_language": "OCaml", "problem_description_relpath": "problem_descriptions/p02244.html", "problem_id": "p02244", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02244/input.txt", "sample_output_relpath": "derived/input_output/data/p02244/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02244/OCaml/s526214553.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s526214553", "user_id": "u827214117"}, "prompt_components": {"gold_output": "......Q.\nQ.......\n..Q.....\n.......Q\n.....Q..\n...Q....\n.Q......\n....Q...\n", "input_to_evaluate": "module ArrayL = ArrayLabels\nmodule ListL = ListLabels\n\nlet dbg = Printf.printf \"[debug]%s\"\n\nlet max_num = 100_000_000_000\n\nlet id = fun x -> x\nlet tuple2 x y = (x,y)\nlet tuple3 x y z = (x,y,z)\nlet succ x = x + 1\nlet pred x = x - 1\n\nlet (++) n m =\n let rec aux i =\n if i = m then [m]\n else i :: aux (i+1) in\n if n > m then [] else aux n\n\nlet (++^) n m = n ++ (m-1)\n\nlet scan fmt f = Scanf.sscanf (read_line ()) fmt f\n\nlet scan_list ~sep cnv =\n let line = read_line () in\n Str.split (Str.regexp_string sep) line\n |> List.map cnv\n\nlet scan_lines n fmt f =\n List.map (fun _ -> scan fmt f) (0++^n)\n\nlet scan_matrix n m e conv =\n let arr = Array.make_matrix n m e in\n Array.iteri (fun i line ->\n let s = Scanf.Scanning.from_string @@ read_line () in\n Array.iteri (fun j _ ->\n arr.(i).(j) <- Scanf.bscanf s \" %s\" conv;\n ) line) arr; arr\n\nlet rec powerset = function\n | [] -> [[]]\n | hd::tl ->\n let pws = powerset tl in\n pws @ ListL.map pws ~f:(fun pw -> hd::pw)\n\nlet permutations l =\n let rec interleave x = function\n | [] -> [[x]]\n | (hd::tl) as l ->\n (x::l) :: (interleave x tl |> ListL.map ~f:(fun l -> hd::l)) in\n let rec aux = function\n | [] -> [[]]\n | a::rest ->\n aux rest |> ListL.map ~f:(interleave a) |> List.concat in\n aux l\n\nlet between n x m = n <= x && x < m\n\nlet string_to_list s =\n List.map (String.get s) (0 ++^ String.length s)\n\nlet n = scan \"%d\" id\nlet ls = scan_lines n \"%d %d\" tuple2\n\nexception Found of int array array\nlet print_mat mat =\n ArrayL.iter mat ~f:(fun a ->\n ArrayL.iter a ~f:(fun v ->\n if v = 0 then Printf.printf \".\"\n else Printf.printf \"Q\"\n );\n Printf.printf \"\\n\"\n )\n\nlet () =\n let sets = permutations (0++^8) in\n (try ListL.iter sets ~f:(fun set ->\n let mat = Array.make_matrix 8 8 0 in\n ListL.iteri set ~f:(fun i n -> mat.(i).(n) <- 1;);\n if not @@ ListL.for_all ls ~f:(fun (i, j) -> mat.(i).(j) = 1) then ()\n else\n if ListL.map (0++^8) ~f:(fun i ->\n ListL.map (0++^8) ~f:(fun j ->\n if mat.(i).(j) = 1 then\n ListL.for_all (0++^8) ~f:(fun k -> k = i || mat.(k).(j) = 0)\n && ListL.for_all (1++^8) ~f:(fun k -> i-k < 0 || j-k < 0 || mat.(i-k).(j-k) = 0)\n && ListL.for_all (1++^8) ~f:(fun k -> i+k >= 8 || j+k >= 8 || mat.(i+k).(j+k) = 0)\n && ListL.for_all (1++^8) ~f:(fun k -> i-k < 0 || j+k >= 8 || mat.(i-k).(j+k) = 0)\n && ListL.for_all (1++^8) ~f:(fun k -> i+k >= 8 || j-k < 0 || mat.(i+k).(j-k) = 0)\n else true))\n |> List.concat |> List.for_all ((=) true) then raise @@ Found mat else ());\n Array.make_matrix 8 8 0\n with\n | Found x -> x)\n |> print_mat\n\n", "problem_context": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\n8 Queens Problem\n\nThe goal of 8 Queens Problem is to put eight queens on a chess-board such that none of them threatens any of others. A queen threatens the squares in the same row, in the same column, or on the same diagonals as shown in the following figure.\n\nFor a given chess board where $k$ queens are already placed, find the solution of the 8 queens problem.\n\nInput\n\nIn the first line, an integer $k$ is given. In the following $k$ lines, each square where a queen is already placed is given by two integers $r$ and $c$. $r$ and $c$ respectively denotes the row number and the column number. The row/column numbers start with 0.\n\nOutput\n\nPrint a $8 \\times 8$ chess board by strings where a square with a queen is represented by 'Q' and an empty square is represented by '.'.\n\nConstraints\n\nThere is exactly one solution\n\nSample Input 1\n\n2\n2 2\n5 3\n\nSample Output 1\n\n......Q.\nQ.......\n..Q.....\n.......Q\n.....Q..\n...Q....\n.Q......\n....Q...", "sample_input": "2\n2 2\n5 3\n"}, "reference_outputs": ["......Q.\nQ.......\n..Q.....\n.......Q\n.....Q..\n...Q....\n.Q......\n....Q...\n"], "source_document_id": "p02244", "source_text": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\n8 Queens Problem\n\nThe goal of 8 Queens Problem is to put eight queens on a chess-board such that none of them threatens any of others. A queen threatens the squares in the same row, in the same column, or on the same diagonals as shown in the following figure.\n\nFor a given chess board where $k$ queens are already placed, find the solution of the 8 queens problem.\n\nInput\n\nIn the first line, an integer $k$ is given. In the following $k$ lines, each square where a queen is already placed is given by two integers $r$ and $c$. $r$ and $c$ respectively denotes the row number and the column number. The row/column numbers start with 0.\n\nOutput\n\nPrint a $8 \\times 8$ chess board by strings where a square with a queen is represented by 'Q' and an empty square is represented by '.'.\n\nConstraints\n\nThere is exactly one solution\n\nSample Input 1\n\n2\n2 2\n5 3\n\nSample Output 1\n\n......Q.\nQ.......\n..Q.....\n.......Q\n.....Q..\n...Q....\n.Q......\n....Q...", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2767, "cpu_time_ms": 10, "memory_kb": 11364}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s029783664", "group_id": "codeNet:p02248", "input_text": "let pn = 1000000007\n\nlet pow x n =\n let rec doit i acc =\n if i = n then acc\n else doit (i + 1) (acc*x)\n in doit 0 1\n\nlet str_fold_left f init s =\n let n = String.length s in\n let rec doit i acc =\n if i = n then acc\n else doit (i + 1) (f acc s.[i])\n in doit 0 init\n\nlet () =\n let p = read_line () in\n let t = read_line () in\n let n = String.length p in\n let m = String.length t in\n let h = Array.make (n + 1) 0 in\n String.iteri (fun i c -> h.(i+1) <- h.(i)*pn + Char.code c) p;\n let ht = str_fold_left (fun acc c -> acc*pn + Char.code c) 0 t in\n let x = pow pn m in\n let rec doit i =\n if i <= n then begin\n if h.(i) - h.(i-m)*x = ht then Printf.printf \"%d\\n\" (i - m);\n doit (i + 1)\n end in\n doit m", "language": "OCaml", "metadata": {"date": 1475761750, "filename_ext": "ml", "original_language": "OCaml", "problem_description_relpath": "problem_descriptions/p02248.html", "problem_id": "p02248", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02248/input.txt", "sample_output_relpath": "derived/input_output/data/p02248/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02248/OCaml/s029783664.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s029783664", "user_id": "u809138450"}, "prompt_components": {"gold_output": "0\n3\n4\n", "input_to_evaluate": "let pn = 1000000007\n\nlet pow x n =\n let rec doit i acc =\n if i = n then acc\n else doit (i + 1) (acc*x)\n in doit 0 1\n\nlet str_fold_left f init s =\n let n = String.length s in\n let rec doit i acc =\n if i = n then acc\n else doit (i + 1) (f acc s.[i])\n in doit 0 init\n\nlet () =\n let p = read_line () in\n let t = read_line () in\n let n = String.length p in\n let m = String.length t in\n let h = Array.make (n + 1) 0 in\n String.iteri (fun i c -> h.(i+1) <- h.(i)*pn + Char.code c) p;\n let ht = str_fold_left (fun acc c -> acc*pn + Char.code c) 0 t in\n let x = pow pn m in\n let rec doit i =\n if i <= n then begin\n if h.(i) - h.(i-m)*x = ht then Printf.printf \"%d\\n\" (i - m);\n doit (i + 1)\n end in\n doit m", "problem_context": "String Search\n\nFind places where a string P is found within a text T.\nPrint all indices of T where P found. The indices of T start with 0.\n\nInput\n\nIn the first line, a text T is given. In the second line, a string P is given.\n\nOutput\n\nPrint an index of T where P found in a line. Print the indices in ascending order.\n\nConstraints\n\n1 ≤ length of T ≤ 1000000\n\n1 ≤ length of P ≤ 10000\n\nThe input consists of alphabetical characters and digits\n\nSample Input 1\n\naabaaa\naa\n\nSample Output 1\n\n0\n3\n4\n\nSample Input 2\n\nxyzz\nyz\n\nSample Output 2\n\n1\n\nSample Input 3\n\nabc\nxyz\n\nSample Output 3\n\nThe output should be empty.", "sample_input": "aabaaa\naa\n"}, "reference_outputs": ["0\n3\n4\n"], "source_document_id": "p02248", "source_text": "String Search\n\nFind places where a string P is found within a text T.\nPrint all indices of T where P found. The indices of T start with 0.\n\nInput\n\nIn the first line, a text T is given. In the second line, a string P is given.\n\nOutput\n\nPrint an index of T where P found in a line. Print the indices in ascending order.\n\nConstraints\n\n1 ≤ length of T ≤ 1000000\n\n1 ≤ length of P ≤ 10000\n\nThe input consists of alphabetical characters and digits\n\nSample Input 1\n\naabaaa\naa\n\nSample Output 1\n\n0\n3\n4\n\nSample Input 2\n\nxyzz\nyz\n\nSample Output 2\n\n1\n\nSample Input 3\n\nabc\nxyz\n\nSample Output 3\n\nThe output should be empty.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 739, "cpu_time_ms": 130, "memory_kb": 14392}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s130647446", "group_id": "codeNet:p02248", "input_text": "let pn = 1000000007\n\nlet pow x n =\n let rec doit x n acc =\n if n = 0 then acc\n else if n mod 2 = 0 then doit (x * x) (n / 2) acc\n else doit (x * x) (n / 2) (acc * x) in\n doit x n 1\n\nlet fold_left f init s n =\n let rec doit i acc =\n if i = n then acc\n else doit (i + 1) (f acc s.[i]) in\n doit 0 init\n\nlet () =\n let p = read_line () in\n let t = read_line () in\n let n = String.length p in\n let m = String.length t in\n let h = Array.make (n + 1) 0 in\n String.iteri (fun i c -> h.(i+1) <- h.(i)*pn + Char.code c) p;\n let ht = fold_left (fun acc c -> acc*pn + Char.code c) 0 t m in\n let x = pow pn m in\n for i = m to n do\n if h.(i) - h.(i-m)*x = ht then Printf.printf \"%d\\n\" (i - m);\n done", "language": "OCaml", "metadata": {"date": 1500792369, "filename_ext": "ml", "original_language": "OCaml", "problem_description_relpath": "problem_descriptions/p02248.html", "problem_id": "p02248", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02248/input.txt", "sample_output_relpath": "derived/input_output/data/p02248/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02248/OCaml/s130647446.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s130647446", "user_id": "u809138450"}, "prompt_components": {"gold_output": "0\n3\n4\n", "input_to_evaluate": "let pn = 1000000007\n\nlet pow x n =\n let rec doit x n acc =\n if n = 0 then acc\n else if n mod 2 = 0 then doit (x * x) (n / 2) acc\n else doit (x * x) (n / 2) (acc * x) in\n doit x n 1\n\nlet fold_left f init s n =\n let rec doit i acc =\n if i = n then acc\n else doit (i + 1) (f acc s.[i]) in\n doit 0 init\n\nlet () =\n let p = read_line () in\n let t = read_line () in\n let n = String.length p in\n let m = String.length t in\n let h = Array.make (n + 1) 0 in\n String.iteri (fun i c -> h.(i+1) <- h.(i)*pn + Char.code c) p;\n let ht = fold_left (fun acc c -> acc*pn + Char.code c) 0 t m in\n let x = pow pn m in\n for i = m to n do\n if h.(i) - h.(i-m)*x = ht then Printf.printf \"%d\\n\" (i - m);\n done", "problem_context": "String Search\n\nFind places where a string P is found within a text T.\nPrint all indices of T where P found. The indices of T start with 0.\n\nInput\n\nIn the first line, a text T is given. In the second line, a string P is given.\n\nOutput\n\nPrint an index of T where P found in a line. Print the indices in ascending order.\n\nConstraints\n\n1 ≤ length of T ≤ 1000000\n\n1 ≤ length of P ≤ 10000\n\nThe input consists of alphabetical characters and digits\n\nSample Input 1\n\naabaaa\naa\n\nSample Output 1\n\n0\n3\n4\n\nSample Input 2\n\nxyzz\nyz\n\nSample Output 2\n\n1\n\nSample Input 3\n\nabc\nxyz\n\nSample Output 3\n\nThe output should be empty.", "sample_input": "aabaaa\naa\n"}, "reference_outputs": ["0\n3\n4\n"], "source_document_id": "p02248", "source_text": "String Search\n\nFind places where a string P is found within a text T.\nPrint all indices of T where P found. The indices of T start with 0.\n\nInput\n\nIn the first line, a text T is given. In the second line, a string P is given.\n\nOutput\n\nPrint an index of T where P found in a line. Print the indices in ascending order.\n\nConstraints\n\n1 ≤ length of T ≤ 1000000\n\n1 ≤ length of P ≤ 10000\n\nThe input consists of alphabetical characters and digits\n\nSample Input 1\n\naabaaa\naa\n\nSample Output 1\n\n0\n3\n4\n\nSample Input 2\n\nxyzz\nyz\n\nSample Output 2\n\n1\n\nSample Input 3\n\nabc\nxyz\n\nSample Output 3\n\nThe output should be empty.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 716, "cpu_time_ms": 120, "memory_kb": 14308}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s174709723", "group_id": "codeNet:p02249", "input_text": "let (p1, p2, p3) = (257, 251, 1000000007)\n\nlet pow x n =\n let rec doit i acc =\n if i = n then acc\n else doit (i + 1) (acc*x mod p3) in\n doit 0 1\n\nlet solve a (h, w) b (r, c) =\n let make_hash v (y, x) =\n let h1 = Array.make_matrix y x 0 in\n let c1 = pow p1 c in\n let rec duduwa i =\n if i < y then begin\n let rec calc_z j acc =\n if j = c then acc\n else calc_z (j + 1) ((acc*p1 + Char.code v.(i).(j)) mod p3) in\n let rec aux j z =\n if j = x - c then h1.(i).(j) <- z\n else begin\n h1.(i).(j) <- z;\n let new_z = (z*p1 - (Char.code v.(i).(j))*c1 + Char.code v.(i).(j+c)) mod p3 in\n aux (j + 1) (if new_z < 0 then new_z + p3 else new_z)\n end in\n aux 0 (calc_z 0 0);\n duduwa (i + 1)\n end in\n duduwa 0;\n let h2 = Array.make_matrix y x 0 in\n let c2 = pow p2 r in\n let rec doit j =\n if j < x then begin\n let rec calc_z i acc =\n if i = r then acc\n else calc_z (i + 1) ((acc*p2 + h1.(i).(j)) mod p3) in\n let rec aux i z =\n if i = y - r then h2.(i).(j) <- z\n else begin\n h2.(i).(j) <- z;\n let new_z = (z*p2 - h1.(i).(j)*c2 + h1.(i+r).(j)) mod p3 in\n aux (i + 1) (if new_z < 0 then new_z + p3 else new_z)\n end in\n aux 0 (calc_z 0 0);\n doit (j + 1)\n end in\n doit 0;\n h2 in\n let s = make_hash a (h, w) in\n let t = make_hash b (r, c) in\n let rec doit = function\n | (i, _) when i > h - r -> ()\n | (i, j) when j > w - c -> doit (i + 1, 0)\n | (i, j) ->\n if s.(i).(j) = t.(0).(0) then Printf.printf \"%d %d\\n\" i j;\n doit (i, j + 1) in\n doit (0, 0)\n\nlet input_array y x =\n let a = Array.make_matrix y x '\\000' in\n let rec doit = function\n | (i, _) when i = y -> a\n | (i, j) when j = x -> doit (i + 1, 0)\n | (i, j) ->\n a.(i).(j) <- Scanf.scanf \"%c \" (fun c -> c);\n doit (i, j + 1) in\n doit (0, 0)\n\nlet () =\n let (h, w) = Scanf.scanf \"%d %d\\n\" (fun h w -> (h, w)) in\n let a = input_array h w in\n let (r, c) = Scanf.scanf \"%d %d\\n\" (fun r c -> (r, c)) in\n let b = input_array r c in\n solve a (h, w) b (r, c)", "language": "OCaml", "metadata": {"date": 1476128876, "filename_ext": "ml", "original_language": "OCaml", "problem_description_relpath": "problem_descriptions/p02249.html", "problem_id": "p02249", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02249/input.txt", "sample_output_relpath": "derived/input_output/data/p02249/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02249/OCaml/s174709723.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s174709723", "user_id": "u809138450"}, "prompt_components": {"gold_output": "0 3\n1 2\n", "input_to_evaluate": "let (p1, p2, p3) = (257, 251, 1000000007)\n\nlet pow x n =\n let rec doit i acc =\n if i = n then acc\n else doit (i + 1) (acc*x mod p3) in\n doit 0 1\n\nlet solve a (h, w) b (r, c) =\n let make_hash v (y, x) =\n let h1 = Array.make_matrix y x 0 in\n let c1 = pow p1 c in\n let rec duduwa i =\n if i < y then begin\n let rec calc_z j acc =\n if j = c then acc\n else calc_z (j + 1) ((acc*p1 + Char.code v.(i).(j)) mod p3) in\n let rec aux j z =\n if j = x - c then h1.(i).(j) <- z\n else begin\n h1.(i).(j) <- z;\n let new_z = (z*p1 - (Char.code v.(i).(j))*c1 + Char.code v.(i).(j+c)) mod p3 in\n aux (j + 1) (if new_z < 0 then new_z + p3 else new_z)\n end in\n aux 0 (calc_z 0 0);\n duduwa (i + 1)\n end in\n duduwa 0;\n let h2 = Array.make_matrix y x 0 in\n let c2 = pow p2 r in\n let rec doit j =\n if j < x then begin\n let rec calc_z i acc =\n if i = r then acc\n else calc_z (i + 1) ((acc*p2 + h1.(i).(j)) mod p3) in\n let rec aux i z =\n if i = y - r then h2.(i).(j) <- z\n else begin\n h2.(i).(j) <- z;\n let new_z = (z*p2 - h1.(i).(j)*c2 + h1.(i+r).(j)) mod p3 in\n aux (i + 1) (if new_z < 0 then new_z + p3 else new_z)\n end in\n aux 0 (calc_z 0 0);\n doit (j + 1)\n end in\n doit 0;\n h2 in\n let s = make_hash a (h, w) in\n let t = make_hash b (r, c) in\n let rec doit = function\n | (i, _) when i > h - r -> ()\n | (i, j) when j > w - c -> doit (i + 1, 0)\n | (i, j) ->\n if s.(i).(j) = t.(0).(0) then Printf.printf \"%d %d\\n\" i j;\n doit (i, j + 1) in\n doit (0, 0)\n\nlet input_array y x =\n let a = Array.make_matrix y x '\\000' in\n let rec doit = function\n | (i, _) when i = y -> a\n | (i, j) when j = x -> doit (i + 1, 0)\n | (i, j) ->\n a.(i).(j) <- Scanf.scanf \"%c \" (fun c -> c);\n doit (i, j + 1) in\n doit (0, 0)\n\nlet () =\n let (h, w) = Scanf.scanf \"%d %d\\n\" (fun h w -> (h, w)) in\n let a = input_array h w in\n let (r, c) = Scanf.scanf \"%d %d\\n\" (fun r c -> (r, c)) in\n let b = input_array r c in\n solve a (h, w) b (r, c)", "problem_context": "Pattern Search\n\nFind places where a R × C pattern is found within a H × W region. Print top-left coordinates (i, j) of sub-regions where the pattern found. The top-left and bottom-right coordinates of the region is (0, 0) and (H-1, W-1) respectively.\n\nInput\n\nIn the first line, two integers H and W are given. In the following H lines, i-th lines of the region are given.\n\nIn the next line, two integers R and C are given. In the following R lines, i-th lines of the pattern are given.\n\noutput\n\nFor each sub-region found, print a coordinate i and j separated by a space character in a line. Print the coordinates in ascending order of the row numbers (i), or the column numbers (j) in case of a tie.\n\nConstraints\n\n1 ≤ H, W ≤ 1000\n\n1 ≤ R, C ≤ 1000\n\nThe input consists of alphabetical characters and digits\n\nSample Input 1\n\n4 5\n00010\n00101\n00010\n00100\n3 2\n10\n01\n10\n\nSample Output 1\n\n0 3\n1 2", "sample_input": "4 5\n00010\n00101\n00010\n00100\n3 2\n10\n01\n10\n"}, "reference_outputs": ["0 3\n1 2\n"], "source_document_id": "p02249", "source_text": "Pattern Search\n\nFind places where a R × C pattern is found within a H × W region. Print top-left coordinates (i, j) of sub-regions where the pattern found. The top-left and bottom-right coordinates of the region is (0, 0) and (H-1, W-1) respectively.\n\nInput\n\nIn the first line, two integers H and W are given. In the following H lines, i-th lines of the region are given.\n\nIn the next line, two integers R and C are given. In the following R lines, i-th lines of the pattern are given.\n\noutput\n\nFor each sub-region found, print a coordinate i and j separated by a space character in a line. Print the coordinates in ascending order of the row numbers (i), or the column numbers (j) in case of a tie.\n\nConstraints\n\n1 ≤ H, W ≤ 1000\n\n1 ≤ R, C ≤ 1000\n\nThe input consists of alphabetical characters and digits\n\nSample Input 1\n\n4 5\n00010\n00101\n00010\n00100\n3 2\n10\n01\n10\n\nSample Output 1\n\n0 3\n1 2", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2197, "cpu_time_ms": 220, "memory_kb": 46236}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s681621161", "group_id": "codeNet:p02249", "input_text": "let (p1, p2, p3) = (257, 251, 1000000007)\n\nlet split_on_char sep s =\n let open String in\n let r = ref [] in\n let j = ref (length s) in\n for i = length s - 1 downto 0 do\n if get s i = sep then begin\n r := sub s (i + 1) (!j - i - 1) :: !r;\n j := i\n end\n done;\n sub s 0 !j :: !r\n\nlet pow x n =\n let rec doit x n acc =\n if n = 0 then acc\n else if n mod 2 = 0 then doit (x * x mod p3) (n / 2) acc\n else doit (x * x mod p3) (n / 2) (acc * x mod p3) in\n doit x n 1\n\nlet make_hash v (x, y) (r, c) =\n let h1 = Array.make_matrix x y 0 in\n let c1 = pow p1 c in\n for i = 0 to x - 1 do\n let rec aux j acc =\n if j = c then acc\n else aux (j + 1) ((acc*p1 + Char.code v.(i).(j)) mod p3) in\n let rec doit j z =\n if j = y - c then h1.(i).(j) <- z\n else begin\n h1.(i).(j) <- z;\n let z = (z*p1 - (Char.code v.(i).(j))*c1 + Char.code v.(i).(j+c)) mod p3 in\n doit (j + 1) (if z < 0 then z + p3 else z)\n end in\n aux 0 0 |> doit 0;\n done;\n let h2 = Array.make_matrix x y 0 in\n let c2 = pow p2 r in\n for j = 0 to y - 1 do\n let rec aux i acc =\n if i = r then acc\n else aux (i + 1) ((acc*p2 + h1.(i).(j)) mod p3) in\n let rec doit i z =\n if i = x - r then h2.(i).(j) <- z\n else begin\n h2.(i).(j) <- z;\n let z = (z*p2 - h1.(i).(j)*c2 + h1.(i+r).(j)) mod p3 in\n doit (i + 1) (if z < 0 then z + p3 else z)\n end in\n aux 0 0 |> doit 0;\n done;\n h2\n\nlet solve (h, w) (r, c) a b =\n let s = make_hash a (h, w) (r, c) in\n let t = make_hash b (r, c) (r, c) in\n for i = 0 to h - r do\n for j = 0 to w -c do\n if s.(i).(j) = t.(0).(0) then Printf.printf \"%d %d\\n\" i j;\n done\n done\n\nlet read_array x y =\n let a = Array.make_matrix x y '\\000' in\n for i = 0 to x - 1 do\n let l = read_line () in\n for j = 0 to y - 1 do\n a.(i).(j) <- l.[j];\n done\n done;\n a\n\nlet () =\n match read_line () |> split_on_char ' ' |> List.map int_of_string with\n | [h; w] ->\n begin\n let a = read_array h w in\n match read_line () |> split_on_char ' ' |> List.map int_of_string with\n | [r; c] ->\n if h < r || w < c then ()\n else read_array r c |> solve (h, w) (r, c) a\n | _ -> assert false\n end\n | _ -> assert false", "language": "OCaml", "metadata": {"date": 1500799313, "filename_ext": "ml", "original_language": "OCaml", "problem_description_relpath": "problem_descriptions/p02249.html", "problem_id": "p02249", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02249/input.txt", "sample_output_relpath": "derived/input_output/data/p02249/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02249/OCaml/s681621161.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s681621161", "user_id": "u809138450"}, "prompt_components": {"gold_output": "0 3\n1 2\n", "input_to_evaluate": "let (p1, p2, p3) = (257, 251, 1000000007)\n\nlet split_on_char sep s =\n let open String in\n let r = ref [] in\n let j = ref (length s) in\n for i = length s - 1 downto 0 do\n if get s i = sep then begin\n r := sub s (i + 1) (!j - i - 1) :: !r;\n j := i\n end\n done;\n sub s 0 !j :: !r\n\nlet pow x n =\n let rec doit x n acc =\n if n = 0 then acc\n else if n mod 2 = 0 then doit (x * x mod p3) (n / 2) acc\n else doit (x * x mod p3) (n / 2) (acc * x mod p3) in\n doit x n 1\n\nlet make_hash v (x, y) (r, c) =\n let h1 = Array.make_matrix x y 0 in\n let c1 = pow p1 c in\n for i = 0 to x - 1 do\n let rec aux j acc =\n if j = c then acc\n else aux (j + 1) ((acc*p1 + Char.code v.(i).(j)) mod p3) in\n let rec doit j z =\n if j = y - c then h1.(i).(j) <- z\n else begin\n h1.(i).(j) <- z;\n let z = (z*p1 - (Char.code v.(i).(j))*c1 + Char.code v.(i).(j+c)) mod p3 in\n doit (j + 1) (if z < 0 then z + p3 else z)\n end in\n aux 0 0 |> doit 0;\n done;\n let h2 = Array.make_matrix x y 0 in\n let c2 = pow p2 r in\n for j = 0 to y - 1 do\n let rec aux i acc =\n if i = r then acc\n else aux (i + 1) ((acc*p2 + h1.(i).(j)) mod p3) in\n let rec doit i z =\n if i = x - r then h2.(i).(j) <- z\n else begin\n h2.(i).(j) <- z;\n let z = (z*p2 - h1.(i).(j)*c2 + h1.(i+r).(j)) mod p3 in\n doit (i + 1) (if z < 0 then z + p3 else z)\n end in\n aux 0 0 |> doit 0;\n done;\n h2\n\nlet solve (h, w) (r, c) a b =\n let s = make_hash a (h, w) (r, c) in\n let t = make_hash b (r, c) (r, c) in\n for i = 0 to h - r do\n for j = 0 to w -c do\n if s.(i).(j) = t.(0).(0) then Printf.printf \"%d %d\\n\" i j;\n done\n done\n\nlet read_array x y =\n let a = Array.make_matrix x y '\\000' in\n for i = 0 to x - 1 do\n let l = read_line () in\n for j = 0 to y - 1 do\n a.(i).(j) <- l.[j];\n done\n done;\n a\n\nlet () =\n match read_line () |> split_on_char ' ' |> List.map int_of_string with\n | [h; w] ->\n begin\n let a = read_array h w in\n match read_line () |> split_on_char ' ' |> List.map int_of_string with\n | [r; c] ->\n if h < r || w < c then ()\n else read_array r c |> solve (h, w) (r, c) a\n | _ -> assert false\n end\n | _ -> assert false", "problem_context": "Pattern Search\n\nFind places where a R × C pattern is found within a H × W region. Print top-left coordinates (i, j) of sub-regions where the pattern found. The top-left and bottom-right coordinates of the region is (0, 0) and (H-1, W-1) respectively.\n\nInput\n\nIn the first line, two integers H and W are given. In the following H lines, i-th lines of the region are given.\n\nIn the next line, two integers R and C are given. In the following R lines, i-th lines of the pattern are given.\n\noutput\n\nFor each sub-region found, print a coordinate i and j separated by a space character in a line. Print the coordinates in ascending order of the row numbers (i), or the column numbers (j) in case of a tie.\n\nConstraints\n\n1 ≤ H, W ≤ 1000\n\n1 ≤ R, C ≤ 1000\n\nThe input consists of alphabetical characters and digits\n\nSample Input 1\n\n4 5\n00010\n00101\n00010\n00100\n3 2\n10\n01\n10\n\nSample Output 1\n\n0 3\n1 2", "sample_input": "4 5\n00010\n00101\n00010\n00100\n3 2\n10\n01\n10\n"}, "reference_outputs": ["0 3\n1 2\n"], "source_document_id": "p02249", "source_text": "Pattern Search\n\nFind places where a R × C pattern is found within a H × W region. Print top-left coordinates (i, j) of sub-regions where the pattern found. The top-left and bottom-right coordinates of the region is (0, 0) and (H-1, W-1) respectively.\n\nInput\n\nIn the first line, two integers H and W are given. In the following H lines, i-th lines of the region are given.\n\nIn the next line, two integers R and C are given. In the following R lines, i-th lines of the pattern are given.\n\noutput\n\nFor each sub-region found, print a coordinate i and j separated by a space character in a line. Print the coordinates in ascending order of the row numbers (i), or the column numbers (j) in case of a tie.\n\nConstraints\n\n1 ≤ H, W ≤ 1000\n\n1 ≤ R, C ≤ 1000\n\nThe input consists of alphabetical characters and digits\n\nSample Input 1\n\n4 5\n00010\n00101\n00010\n00100\n3 2\n10\n01\n10\n\nSample Output 1\n\n0 3\n1 2", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2270, "cpu_time_ms": 150, "memory_kb": 43012}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s684622104", "group_id": "codeNet:p02250", "input_text": "exception Not_equal of int\n\nlet cmp_sa rank a b n k =\n if rank.(a) <> rank.(b) then compare rank.(a) rank.(b)\n else\n compare\n (if a + k <= n then rank.(a+k) else (-1))\n (if b + k <= n then rank.(b+k) else (-1))\n\nlet construct_sa t n =\n let sa = Array.make (n + 1) 0 in\n let rank = Array.make (n + 1) 0 in\n let tmp = Array.make (n + 1) 0 in\n for i = 0 to n - 1 do\n sa.(i) <- i;\n rank.(i) <- Char.code t.[i];\n done;\n sa.(n) <- n;\n rank.(n) <- (-1);\n let rec doit k =\n if k > n then ()\n else begin\n Array.fast_sort (fun a b -> cmp_sa rank a b n k) sa;\n tmp.(sa.(0)) <- 0;\n for i = 1 to n do\n tmp.(sa.(i)) <-\n tmp.(sa.(i-1)) + (if cmp_sa rank sa.(i-1) sa.(i) n k = (-1) then 1 else 0);\n done;\n for i = 0 to n do rank.(i) <- tmp.(i) done;\n doit (2 * k)\n end in\n doit 1;\n sa\n\nlet range_cmp t n offset p k =\n let m = n - offset in\n let m = if m < k then m else k in\n try\n for i = 0 to m - 1 do\n if t.[i+offset] <> p.[i] then\n raise (Not_equal (compare t.[i+offset] p.[i]));\n done;\n if m = k then 0\n else (-1)\n with Not_equal i -> i\n\nlet () =\n let t = read_line () in\n let n = String.length t in\n let sa = construct_sa t n in\n let q = read_int () in\n for _ = 0 to q - 1 do\n let p = read_line () in\n let k = String.length p in\n let rec doit l r =\n if r - l <= 1 then l\n else\n let m = (l + r) / 2 in\n if range_cmp t n sa.(m) p k <= 0 then doit m r\n else doit l m in\n let l = doit 0 (n + 1) in\n Printf.printf \"%d\\n\" (if range_cmp t n sa.(l) p k = 0 then 1 else 0);\n done", "language": "OCaml", "metadata": {"date": 1500893228, "filename_ext": "ml", "original_language": "OCaml", "problem_description_relpath": "problem_descriptions/p02250.html", "problem_id": "p02250", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02250/input.txt", "sample_output_relpath": "derived/input_output/data/p02250/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02250/OCaml/s684622104.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s684622104", "user_id": "u809138450"}, "prompt_components": {"gold_output": "1\n1\n0\n0\n", "input_to_evaluate": "exception Not_equal of int\n\nlet cmp_sa rank a b n k =\n if rank.(a) <> rank.(b) then compare rank.(a) rank.(b)\n else\n compare\n (if a + k <= n then rank.(a+k) else (-1))\n (if b + k <= n then rank.(b+k) else (-1))\n\nlet construct_sa t n =\n let sa = Array.make (n + 1) 0 in\n let rank = Array.make (n + 1) 0 in\n let tmp = Array.make (n + 1) 0 in\n for i = 0 to n - 1 do\n sa.(i) <- i;\n rank.(i) <- Char.code t.[i];\n done;\n sa.(n) <- n;\n rank.(n) <- (-1);\n let rec doit k =\n if k > n then ()\n else begin\n Array.fast_sort (fun a b -> cmp_sa rank a b n k) sa;\n tmp.(sa.(0)) <- 0;\n for i = 1 to n do\n tmp.(sa.(i)) <-\n tmp.(sa.(i-1)) + (if cmp_sa rank sa.(i-1) sa.(i) n k = (-1) then 1 else 0);\n done;\n for i = 0 to n do rank.(i) <- tmp.(i) done;\n doit (2 * k)\n end in\n doit 1;\n sa\n\nlet range_cmp t n offset p k =\n let m = n - offset in\n let m = if m < k then m else k in\n try\n for i = 0 to m - 1 do\n if t.[i+offset] <> p.[i] then\n raise (Not_equal (compare t.[i+offset] p.[i]));\n done;\n if m = k then 0\n else (-1)\n with Not_equal i -> i\n\nlet () =\n let t = read_line () in\n let n = String.length t in\n let sa = construct_sa t n in\n let q = read_int () in\n for _ = 0 to q - 1 do\n let p = read_line () in\n let k = String.length p in\n let rec doit l r =\n if r - l <= 1 then l\n else\n let m = (l + r) / 2 in\n if range_cmp t n sa.(m) p k <= 0 then doit m r\n else doit l m in\n let l = doit 0 (n + 1) in\n Printf.printf \"%d\\n\" (if range_cmp t n sa.(l) p k = 0 then 1 else 0);\n done", "problem_context": "String Search\n\nDetermine whether a text T includes a pattern P. Your program should answer for given queries consisting of P_i.\n\nInput\n\nIn the first line, a text T is given. In the second line, an integer Q denoting the number of queries is given. In the following Q lines, the patterns P_i are given respectively.\n\nOutput\n\nFor each question, print 1 if the text includes P_i, or print 0 otherwise.\n\nConstraints\n\n1 ≤ length of T ≤ 1000000\n\n1 ≤ length of P_i ≤ 1000\n\n1 ≤ Q ≤ 10000\n\nThe input consists of alphabetical characters and digits\n\nSample Input 1\n\naabaaa\n4\naa\nba\nbb\nxyz\n\nSample Output 1\n\n1\n1\n0\n0", "sample_input": "aabaaa\n4\naa\nba\nbb\nxyz\n"}, "reference_outputs": ["1\n1\n0\n0\n"], "source_document_id": "p02250", "source_text": "String Search\n\nDetermine whether a text T includes a pattern P. Your program should answer for given queries consisting of P_i.\n\nInput\n\nIn the first line, a text T is given. In the second line, an integer Q denoting the number of queries is given. In the following Q lines, the patterns P_i are given respectively.\n\nOutput\n\nFor each question, print 1 if the text includes P_i, or print 0 otherwise.\n\nConstraints\n\n1 ≤ length of T ≤ 1000000\n\n1 ≤ length of P_i ≤ 1000\n\n1 ≤ Q ≤ 10000\n\nThe input consists of alphabetical characters and digits\n\nSample Input 1\n\naabaaa\n4\naa\nba\nbb\nxyz\n\nSample Output 1\n\n1\n1\n0\n0", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1625, "cpu_time_ms": 4200, "memory_kb": 75520}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s774943238", "group_id": "codeNet:p02250", "input_text": "let id x = x\n \nlet string_search s p =\n let sl = String.length s in\n let pl = String.length p in\n let sa = Array.init (sl+1) id in\n let rank = Array.init (sl+1) (fun i -> if i = sl then (-1) else Char.code s.[i]) in\n let cmp k i j =\n if rank.(i) = rank.(j) then\n let rik = if i + k <= sl then rank.(i+k) else (-1) in\n let rjk = if j + k <= sl then rank.(j+k) else (-1) in\n rik - rjk\n else rank.(i) - rank.(j) in\n let ra_rank k =\n let ta = Array.make (sl+1) 0 in\n let rec iter i =\n if i > sl then ()\n else begin\n ta.(sa.(i)) <- ta.(sa.(i-1)) + (if cmp k sa.(i) sa.(i-1) > 0 then 1 else 0);\n iter (i+1)\n end in\n let rec copy i =\n if i > sl then ()\n else begin\n rank.(i) <- ta.(i);\n copy (i+1)\n end in\n iter 1;\n copy 0 in\n let rec sort_sa k =\n if k > sl then ()\n else begin\n Array.sort (cmp k) sa;\n ra_rank k;\n sort_sa (2 * k)\n end in\n let rec search l r =\n if r - l <= 1 then\n try String.sub s sa.(r) pl = p with _ -> false\n else\n let m = (l + r) / 2 in\n match compare (String.sub s sa.(m) (min pl (sl - sa.(m)))) p with\n 0 -> true\n | x when x < 0 -> search m r\n | _ -> search l m\n in\n sort_sa 1;\n search 0 (sl+1)\n \nlet () =\n let t = read_line () in\n let q = read_int () in\n let rec loop x =\n if x = 0 then ()\n else let p = read_line () in\n (if string_search t p then \"1\" else \"0\") |> print_endline;\n loop (x-1)\n in loop q", "language": "OCaml", "metadata": {"date": 1502167153, "filename_ext": "ml", "original_language": "OCaml", "problem_description_relpath": "problem_descriptions/p02250.html", "problem_id": "p02250", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02250/input.txt", "sample_output_relpath": "derived/input_output/data/p02250/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02250/OCaml/s774943238.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s774943238", "user_id": "u049242937"}, "prompt_components": {"gold_output": "1\n1\n0\n0\n", "input_to_evaluate": "let id x = x\n \nlet string_search s p =\n let sl = String.length s in\n let pl = String.length p in\n let sa = Array.init (sl+1) id in\n let rank = Array.init (sl+1) (fun i -> if i = sl then (-1) else Char.code s.[i]) in\n let cmp k i j =\n if rank.(i) = rank.(j) then\n let rik = if i + k <= sl then rank.(i+k) else (-1) in\n let rjk = if j + k <= sl then rank.(j+k) else (-1) in\n rik - rjk\n else rank.(i) - rank.(j) in\n let ra_rank k =\n let ta = Array.make (sl+1) 0 in\n let rec iter i =\n if i > sl then ()\n else begin\n ta.(sa.(i)) <- ta.(sa.(i-1)) + (if cmp k sa.(i) sa.(i-1) > 0 then 1 else 0);\n iter (i+1)\n end in\n let rec copy i =\n if i > sl then ()\n else begin\n rank.(i) <- ta.(i);\n copy (i+1)\n end in\n iter 1;\n copy 0 in\n let rec sort_sa k =\n if k > sl then ()\n else begin\n Array.sort (cmp k) sa;\n ra_rank k;\n sort_sa (2 * k)\n end in\n let rec search l r =\n if r - l <= 1 then\n try String.sub s sa.(r) pl = p with _ -> false\n else\n let m = (l + r) / 2 in\n match compare (String.sub s sa.(m) (min pl (sl - sa.(m)))) p with\n 0 -> true\n | x when x < 0 -> search m r\n | _ -> search l m\n in\n sort_sa 1;\n search 0 (sl+1)\n \nlet () =\n let t = read_line () in\n let q = read_int () in\n let rec loop x =\n if x = 0 then ()\n else let p = read_line () in\n (if string_search t p then \"1\" else \"0\") |> print_endline;\n loop (x-1)\n in loop q", "problem_context": "String Search\n\nDetermine whether a text T includes a pattern P. Your program should answer for given queries consisting of P_i.\n\nInput\n\nIn the first line, a text T is given. In the second line, an integer Q denoting the number of queries is given. In the following Q lines, the patterns P_i are given respectively.\n\nOutput\n\nFor each question, print 1 if the text includes P_i, or print 0 otherwise.\n\nConstraints\n\n1 ≤ length of T ≤ 1000000\n\n1 ≤ length of P_i ≤ 1000\n\n1 ≤ Q ≤ 10000\n\nThe input consists of alphabetical characters and digits\n\nSample Input 1\n\naabaaa\n4\naa\nba\nbb\nxyz\n\nSample Output 1\n\n1\n1\n0\n0", "sample_input": "aabaaa\n4\naa\nba\nbb\nxyz\n"}, "reference_outputs": ["1\n1\n0\n0\n"], "source_document_id": "p02250", "source_text": "String Search\n\nDetermine whether a text T includes a pattern P. Your program should answer for given queries consisting of P_i.\n\nInput\n\nIn the first line, a text T is given. In the second line, an integer Q denoting the number of queries is given. In the following Q lines, the patterns P_i are given respectively.\n\nOutput\n\nFor each question, print 1 if the text includes P_i, or print 0 otherwise.\n\nConstraints\n\n1 ≤ length of T ≤ 1000000\n\n1 ≤ length of P_i ≤ 1000\n\n1 ≤ Q ≤ 10000\n\nThe input consists of alphabetical characters and digits\n\nSample Input 1\n\naabaaa\n4\naa\nba\nbb\nxyz\n\nSample Output 1\n\n1\n1\n0\n0", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1550, "cpu_time_ms": 20000, "memory_kb": 13216}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s271491390", "group_id": "codeNet:p02257", "input_text": "let prime_p = function\n | 2 -> true\n | n when n < 2 || n mod 2 = 0 -> false\n | n ->\n let rec doit i =\n if i*i > n then true\n else if n mod i = 0 then false\n else doit (i + 2)\n in\n doit 3\n\nlet () =\n let n = read_int () in\n let rec read i cnt =\n if i >= n then cnt\n else read (i + 1) (cnt + (if prime_p (read_int ()) then 1 else 0))\n in\n Printf.printf \"%d\\n\" (read 0 0)", "language": "OCaml", "metadata": {"date": 1473939119, "filename_ext": "ml", "original_language": "OCaml", "problem_description_relpath": "problem_descriptions/p02257.html", "problem_id": "p02257", "resource_group": "low_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/OCaml/s271491390.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s271491390", "user_id": "u809138450"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "let prime_p = function\n | 2 -> true\n | n when n < 2 || n mod 2 = 0 -> false\n | n ->\n let rec doit i =\n if i*i > n then true\n else if n mod i = 0 then false\n else doit (i + 2)\n in\n doit 3\n\nlet () =\n let n = read_int () in\n let rec read i cnt =\n if i >= n then cnt\n else read (i + 1) (cnt + (if prime_p (read_int ()) then 1 else 0))\n in\n Printf.printf \"%d\\n\" (read 0 0)", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 416, "cpu_time_ms": 20, "memory_kb": 3048}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s705916349", "group_id": "codeNet:p02257", "input_text": "type intseq = Cons of int * (int -> intseq) ;; (* 整数の無限列 *)\n\nlet rec is_divisible lst x = (* リストのいずれかの要素でxが割り切れるかどうかチェックする. *)\n let max = float_of_int x |> sqrt |> int_of_float in (* チェックする最大値 *)\n match lst with\n [] -> false \n | p::ps when p > max -> false\n | p::ps -> if x mod p = 0 then true\n else is_divisible ps x ;;\n\nlet rec prime_seq primes x = (* 素数の無限列. primesはアキュムレータであり, 素数のリスト *)\n if is_divisible primes (x+1) then prime_seq primes (x+1)\n else Cons(x+1, prime_seq (primes @ [x+1])) ;;\n\nlet is_prime x = (* xが素数かどうかチェックする *)\n let max = float_of_int x |> sqrt |> int_of_float in\n let rec is_p p_seq = (* xが素数の数列で割り切れるかチェックする *)\n let Cons(n, f) = p_seq in\n if n > max then true\n else if x mod n = 0 then false\n else is_p (f n)\n in\n is_p (prime_seq [] 1) ;;\n\nlet () =\n let open Scanf in\n let m = scanf \"%d\\n\" (fun x -> x) in\n let as_ = Array.init m (fun _ -> scanf \"%d\\n\" (fun x -> if is_prime x then 1 else 0)) in\n Array.fold_left (+) 0 as_\n |> Printf.printf \"%d\\n\" ;;\n", "language": "OCaml", "metadata": {"date": 1592038422, "filename_ext": "ml", "original_language": "OCaml", "problem_description_relpath": "problem_descriptions/p02257.html", "problem_id": "p02257", "resource_group": "low_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/OCaml/s705916349.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s705916349", "user_id": "u440841603"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "type intseq = Cons of int * (int -> intseq) ;; (* 整数の無限列 *)\n\nlet rec is_divisible lst x = (* リストのいずれかの要素でxが割り切れるかどうかチェックする. *)\n let max = float_of_int x |> sqrt |> int_of_float in (* チェックする最大値 *)\n match lst with\n [] -> false \n | p::ps when p > max -> false\n | p::ps -> if x mod p = 0 then true\n else is_divisible ps x ;;\n\nlet rec prime_seq primes x = (* 素数の無限列. primesはアキュムレータであり, 素数のリスト *)\n if is_divisible primes (x+1) then prime_seq primes (x+1)\n else Cons(x+1, prime_seq (primes @ [x+1])) ;;\n\nlet is_prime x = (* xが素数かどうかチェックする *)\n let max = float_of_int x |> sqrt |> int_of_float in\n let rec is_p p_seq = (* xが素数の数列で割り切れるかチェックする *)\n let Cons(n, f) = p_seq in\n if n > max then true\n else if x mod n = 0 then false\n else is_p (f n)\n in\n is_p (prime_seq [] 1) ;;\n\nlet () =\n let open Scanf in\n let m = scanf \"%d\\n\" (fun x -> x) in\n let as_ = Array.init m (fun _ -> scanf \"%d\\n\" (fun x -> if is_prime x then 1 else 0)) in\n Array.fold_left (+) 0 as_\n |> Printf.printf \"%d\\n\" ;;\n", "problem_context": "Prime Numbers\n\nA prime number is a natural number which has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5 and 7.\n\nWrite a program which reads a list of N integers and prints the number of prime numbers in the list.\n\nInput\n\nThe first line contains an integer N, the number of elements in the list.\n\nN numbers are given in the following lines.\n\nOutput\n\nPrint the number of prime numbers in the given list.\n\nConstraints\n\n1 ≤ N ≤ 10000\n\n2 ≤ an element of the list ≤ 108\n\nSample Input 1\n\n5\n2\n3\n4\n5\n6\n\nSample Output 1\n\n3\n\nSample Input 2\n\n11\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n\nSample Output 2\n\n4", "sample_input": "5\n2\n3\n4\n5\n6\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02257", "source_text": "Prime Numbers\n\nA prime number is a natural number which has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5 and 7.\n\nWrite a program which reads a list of N integers and prints the number of prime numbers in the list.\n\nInput\n\nThe first line contains an integer N, the number of elements in the list.\n\nN numbers are given in the following lines.\n\nOutput\n\nPrint the number of prime numbers in the given list.\n\nConstraints\n\n1 ≤ N ≤ 10000\n\n2 ≤ an element of the list ≤ 108\n\nSample Input 1\n\n5\n2\n3\n4\n5\n6\n\nSample Output 1\n\n3\n\nSample Input 2\n\n11\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n\nSample Output 2\n\n4", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1244, "cpu_time_ms": 1050, "memory_kb": 5036}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s255095391", "group_id": "codeNet:p02258", "input_text": "let () =\n let n = read_int () in\n let minv = ref (read_int ()) in\n let maxv = ref min_int in\n for i = 1 to n - 1 do\n let j = read_int () in\n maxv := max !maxv (j - !minv);\n minv := min !minv j\n done;\n print_int !maxv; print_newline ()", "language": "OCaml", "metadata": {"date": 1486075978, "filename_ext": "ml", "original_language": "OCaml", "problem_description_relpath": "problem_descriptions/p02258.html", "problem_id": "p02258", "resource_group": "low_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/OCaml/s255095391.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s255095391", "user_id": "u899293860"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "let () =\n let n = read_int () in\n let minv = ref (read_int ()) in\n let maxv = ref min_int in\n for i = 1 to n - 1 do\n let j = read_int () in\n maxv := max !maxv (j - !minv);\n minv := min !minv j\n done;\n print_int !maxv; print_newline ()", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 4332}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s166335603", "group_id": "codeNet:p02258", "input_text": "let () =\n let n = read_int () in\n let r1 = read_int () in\n let r2 = read_int () in\n let rec iter mp mr m =\n if m = 0 then mp\n else let r = read_int () in\n iter (max mp (r - mr)) (min mr r) (m-1) in\n iter (r2 - r1) (min r1 r2) (n-2) |> string_of_int |> print_endline", "language": "OCaml", "metadata": {"date": 1499140831, "filename_ext": "ml", "original_language": "OCaml", "problem_description_relpath": "problem_descriptions/p02258.html", "problem_id": "p02258", "resource_group": "low_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/OCaml/s166335603.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s166335603", "user_id": "u049242937"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "let () =\n let n = read_int () in\n let r1 = read_int () in\n let r2 = read_int () in\n let rec iter mp mr m =\n if m = 0 then mp\n else let r = read_int () in\n iter (max mp (r - mr)) (min mr r) (m-1) in\n iter (r2 - r1) (min r1 r2) (n-2) |> string_of_int |> print_endline", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 284, "cpu_time_ms": 10, "memory_kb": 4308}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s232247420", "group_id": "codeNet:p02264", "input_text": "let () =\n let nq = read_line () |> Str.split (Str.regexp \" \")\n |> List.map int_of_string |> Array.of_list in\n let (n,q) = (nq.(0), nq.(1)) and\n queue = Queue.create () in\n let rec read = function\n 0 -> ()\n | i ->\n let line = read_line () |> Str.split (Str.regexp \" \")\n |> Array.of_list in\n Queue.push (line.(0),int_of_string line.(1)) queue;\n read (i-1)\n in\n read n;\n let rec f time_total =\n if Queue.is_empty queue then ()\n else\n let (name, time) = Queue.pop queue in\n if time <= q then\n begin\n Printf.printf \"%s %d\\n\" name (time+time_total);\n f (time+time_total)\n end\n else\n begin\n Queue.push (name, (time-q)) queue;\n f (q+time_total)\n end\n in\n f 0;;", "language": "OCaml", "metadata": {"date": 1468665866, "filename_ext": "ml", "original_language": "OCaml", "problem_description_relpath": "problem_descriptions/p02264.html", "problem_id": "p02264", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02264/input.txt", "sample_output_relpath": "derived/input_output/data/p02264/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02264/OCaml/s232247420.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s232247420", "user_id": "u935184340"}, "prompt_components": {"gold_output": "p2 180\np5 400\np1 450\np3 550\np4 800\n", "input_to_evaluate": "let () =\n let nq = read_line () |> Str.split (Str.regexp \" \")\n |> List.map int_of_string |> Array.of_list in\n let (n,q) = (nq.(0), nq.(1)) and\n queue = Queue.create () in\n let rec read = function\n 0 -> ()\n | i ->\n let line = read_line () |> Str.split (Str.regexp \" \")\n |> Array.of_list in\n Queue.push (line.(0),int_of_string line.(1)) queue;\n read (i-1)\n in\n read n;\n let rec f time_total =\n if Queue.is_empty queue then ()\n else\n let (name, time) = Queue.pop queue in\n if time <= q then\n begin\n Printf.printf \"%s %d\\n\" name (time+time_total);\n f (time+time_total)\n end\n else\n begin\n Queue.push (name, (time-q)) queue;\n f (q+time_total)\n end\n in\n f 0;;", "problem_context": "There are n processes in a queue. Each process has namei and timei. The round-robin scheduling handles the processes in order. A round-robin scheduler gives each process a quantum (a time slot) and interrupts the process if it is not completed by then. The process is resumed and moved to the end of the queue, then the scheduler handles the next process in the queue.\n\nFor example, we have the following queue with the quantum of 100ms.\n\nA(150) - B(80) - C(200) - D(200)\n\nFirst, process A is handled for 100ms, then the process is moved to the end of the queue with the remaining time (50ms).\n\nB(80) - C(200) - D(200) - A(50)\n\nNext, process B is handled for 80ms. The process is completed with the time stamp of 180ms and removed from the queue.\n\nC(200) - D(200) - A(50)\n\nYour task is to write a program which simulates the round-robin scheduling.\n\nInput\n\nn q\n\nname1 time1\n\nname2 time2\n\n...\n\nnamen timen\n\nIn the first line the number of processes n and the quantum q are given separated by a single space.\n\nIn the following n lines, names and times for the n processes are given. namei and timei are separated by a single space.\n\nOutput\n\nFor each process, prints its name and the time the process finished in order.\n\nConstraints\n\n1 ≤ n ≤ 100000\n\n1 ≤ q ≤ 1000\n\n1 ≤ timei ≤ 50000\n\n1 ≤ length of namei ≤ 10\n\n1 ≤ Sum of timei ≤ 1000000\n\nSample Input 1\n\n5 100\np1 150\np2 80\np3 200\np4 350\np5 20\n\nSample Output 1\n\np2 180\np5 400\np1 450\np3 550\np4 800\n\nNotes\n\nTemplate in C", "sample_input": "5 100\np1 150\np2 80\np3 200\np4 350\np5 20\n"}, "reference_outputs": ["p2 180\np5 400\np1 450\np3 550\np4 800\n"], "source_document_id": "p02264", "source_text": "There are n processes in a queue. Each process has namei and timei. The round-robin scheduling handles the processes in order. A round-robin scheduler gives each process a quantum (a time slot) and interrupts the process if it is not completed by then. The process is resumed and moved to the end of the queue, then the scheduler handles the next process in the queue.\n\nFor example, we have the following queue with the quantum of 100ms.\n\nA(150) - B(80) - C(200) - D(200)\n\nFirst, process A is handled for 100ms, then the process is moved to the end of the queue with the remaining time (50ms).\n\nB(80) - C(200) - D(200) - A(50)\n\nNext, process B is handled for 80ms. The process is completed with the time stamp of 180ms and removed from the queue.\n\nC(200) - D(200) - A(50)\n\nYour task is to write a program which simulates the round-robin scheduling.\n\nInput\n\nn q\n\nname1 time1\n\nname2 time2\n\n...\n\nnamen timen\n\nIn the first line the number of processes n and the quantum q are given separated by a single space.\n\nIn the following n lines, names and times for the n processes are given. namei and timei are separated by a single space.\n\nOutput\n\nFor each process, prints its name and the time the process finished in order.\n\nConstraints\n\n1 ≤ n ≤ 100000\n\n1 ≤ q ≤ 1000\n\n1 ≤ timei ≤ 50000\n\n1 ≤ length of namei ≤ 10\n\n1 ≤ Sum of timei ≤ 1000000\n\nSample Input 1\n\n5 100\np1 150\np2 80\np3 200\np4 350\np5 20\n\nSample Output 1\n\np2 180\np5 400\np1 450\np3 550\np4 800\n\nNotes\n\nTemplate in C", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 801, "cpu_time_ms": 50, "memory_kb": 11696}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s058065507", "group_id": "codeNet:p02265", "input_text": "module DoublyLinkedList = struct\n type t = {\n mutable data : int;\n mutable next : t;\n mutable prev : t;\n }\n\n let make () =\n let rec head = { data = 0; next = head; prev = head } in\n head\n\n let insert data head =\n let x = { data = data; next = head.next; prev = head } in\n head.next.prev <- x;\n head.next <- x\n\n let delete x =\n x.next.prev <- x.prev;\n x.prev.next <- x.next\n\n let delete_first head = delete head.next\n\n let delete_last head = delete head.prev\n\n let delete_node data head =\n let rec doit ite =\n if ite == head then None\n else if ite.data = data then Some ite\n else doit ite.next\n in\n match doit head.next with\n | None -> ()\n | Some ite -> delete ite\n\n let iteri head ~f =\n let rec doit i ite =\n if ite != head then (f i ite.data; doit (i + 1) ite.next)\n in\n doit 0 head.next\nend\n\nmodule L = DoublyLinkedList\n\nlet split str delim =\n let rec doit s acc =\n match\n try Some (String.rindex s delim) with _ -> None\n with\n | None -> s :: acc\n | Some i ->\n let s1 = String.sub s 0 i in\n let s2 = String.sub s (i + 1) (String.length s - String.length s1 - 1) in\n doit s1 (s2 :: acc)\n in\n doit str []\n\nlet () =\n let n = read_int () in\n let head = L.make () in\n let rec read i =\n if i < n then begin\n match split (read_line ()) ' ' with\n | [\"insert\"; n] -> (L.insert (int_of_string n) head; read (i + 1))\n | [\"delete\"; n] -> (L.delete_node (int_of_string n) head; read (i + 1))\n | [\"deleteFirst\"] -> (L.delete_first head; read (i + 1))\n | [\"deleteLast\"] -> (L.delete_last head; read (i + 1))\n | _ -> exit 1\n end\n in\n read 0;\n L.iteri head ~f:(fun i n -> if i <> 0 then print_string \" \"; print_int n);\n print_newline ()", "language": "OCaml", "metadata": {"date": 1474427918, "filename_ext": "ml", "original_language": "OCaml", "problem_description_relpath": "problem_descriptions/p02265.html", "problem_id": "p02265", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02265/input.txt", "sample_output_relpath": "derived/input_output/data/p02265/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02265/OCaml/s058065507.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s058065507", "user_id": "u809138450"}, "prompt_components": {"gold_output": "6 1 2\n", "input_to_evaluate": "module DoublyLinkedList = struct\n type t = {\n mutable data : int;\n mutable next : t;\n mutable prev : t;\n }\n\n let make () =\n let rec head = { data = 0; next = head; prev = head } in\n head\n\n let insert data head =\n let x = { data = data; next = head.next; prev = head } in\n head.next.prev <- x;\n head.next <- x\n\n let delete x =\n x.next.prev <- x.prev;\n x.prev.next <- x.next\n\n let delete_first head = delete head.next\n\n let delete_last head = delete head.prev\n\n let delete_node data head =\n let rec doit ite =\n if ite == head then None\n else if ite.data = data then Some ite\n else doit ite.next\n in\n match doit head.next with\n | None -> ()\n | Some ite -> delete ite\n\n let iteri head ~f =\n let rec doit i ite =\n if ite != head then (f i ite.data; doit (i + 1) ite.next)\n in\n doit 0 head.next\nend\n\nmodule L = DoublyLinkedList\n\nlet split str delim =\n let rec doit s acc =\n match\n try Some (String.rindex s delim) with _ -> None\n with\n | None -> s :: acc\n | Some i ->\n let s1 = String.sub s 0 i in\n let s2 = String.sub s (i + 1) (String.length s - String.length s1 - 1) in\n doit s1 (s2 :: acc)\n in\n doit str []\n\nlet () =\n let n = read_int () in\n let head = L.make () in\n let rec read i =\n if i < n then begin\n match split (read_line ()) ' ' with\n | [\"insert\"; n] -> (L.insert (int_of_string n) head; read (i + 1))\n | [\"delete\"; n] -> (L.delete_node (int_of_string n) head; read (i + 1))\n | [\"deleteFirst\"] -> (L.delete_first head; read (i + 1))\n | [\"deleteLast\"] -> (L.delete_last head; read (i + 1))\n | _ -> exit 1\n end\n in\n read 0;\n L.iteri head ~f:(fun i n -> if i <> 0 then print_string \" \"; print_int n);\n print_newline ()", "problem_context": "Doubly Linked List\n\nYour task is to implement a double linked list.\n\nWrite a program which performs the following operations:\n\ninsert x: insert an element with key x into the front of the list.\n\ndelete x: delete the first element which has the key of x from the list. If there is not such element, you need not do anything.\n\ndeleteFirst: delete the first element from the list.\n\ndeleteLast: delete the last element from the list.\n\nInput\n\nThe input is given in the following format:\n\nn\n\ncommand1\n\ncommand2\n\n...\n\ncommandn\n\nIn the first line, the number of operations n is given. In the following n lines, the above mentioned operations are given in the following format:\n\ninsert x\n\ndelete x\n\ndeleteFirst\n\ndeleteLast\n\nOutput\n\nPrint all the element (key) in the list after the given operations. Two consequtive keys should be separated by a single space.\n\nConstraints\n\nThe number of operations ≤ 2,000,000\n\nThe number of delete operations ≤ 20\n\n0 ≤ value of a key ≤ 109\n\nThe number of elements in the list does not exceed 106\n\nFor a delete, deleteFirst or deleteLast operation, there is at least one element in the list.\n\nSample Input 1\n\n7\ninsert 5\ninsert 2\ninsert 3\ninsert 1\ndelete 3\ninsert 6\ndelete 5\n\nSample Output 1\n\n6 1 2\n\nSample Input 2\n\n9\ninsert 5\ninsert 2\ninsert 3\ninsert 1\ndelete 3\ninsert 6\ndelete 5\ndeleteFirst\ndeleteLast\n\nSample Output 2\n\n1", "sample_input": "7\ninsert 5\ninsert 2\ninsert 3\ninsert 1\ndelete 3\ninsert 6\ndelete 5\n"}, "reference_outputs": ["6 1 2\n"], "source_document_id": "p02265", "source_text": "Doubly Linked List\n\nYour task is to implement a double linked list.\n\nWrite a program which performs the following operations:\n\ninsert x: insert an element with key x into the front of the list.\n\ndelete x: delete the first element which has the key of x from the list. If there is not such element, you need not do anything.\n\ndeleteFirst: delete the first element from the list.\n\ndeleteLast: delete the last element from the list.\n\nInput\n\nThe input is given in the following format:\n\nn\n\ncommand1\n\ncommand2\n\n...\n\ncommandn\n\nIn the first line, the number of operations n is given. In the following n lines, the above mentioned operations are given in the following format:\n\ninsert x\n\ndelete x\n\ndeleteFirst\n\ndeleteLast\n\nOutput\n\nPrint all the element (key) in the list after the given operations. Two consequtive keys should be separated by a single space.\n\nConstraints\n\nThe number of operations ≤ 2,000,000\n\nThe number of delete operations ≤ 20\n\n0 ≤ value of a key ≤ 109\n\nThe number of elements in the list does not exceed 106\n\nFor a delete, deleteFirst or deleteLast operation, there is at least one element in the list.\n\nSample Input 1\n\n7\ninsert 5\ninsert 2\ninsert 3\ninsert 1\ndelete 3\ninsert 6\ndelete 5\n\nSample Output 1\n\n6 1 2\n\nSample Input 2\n\n9\ninsert 5\ninsert 2\ninsert 3\ninsert 1\ndelete 3\ninsert 6\ndelete 5\ndeleteFirst\ndeleteLast\n\nSample Output 2\n\n1", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1788, "cpu_time_ms": 260, "memory_kb": 39020}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s993636659", "group_id": "codeNet:p02265", "input_text": "open Str\n\ntype dllist = {value : int option; mutable prev : dllist ref; mutable next : dllist ref}\n \nlet read_list () =\n split (regexp \" +\") (read_line ())\n \nlet () =\n let n = read_int () in\n let rec tn = {value = None; prev = ref tn; next = ref tn} in\n let insert x =\n let nn = {value = Some x; prev = ref tn; next = ref tn} in\n let nnn = !(tn.next) in\n nn.next <- tn.next;\n nn.prev <- nnn.prev;\n tn.next <- ref nn;\n nnn.prev <- ref nn\n in\n let find x =\n let rec loop n =\n let nn = !(n.next) in\n match nn.value with\n None -> raise Not_found\n | Some y -> if x = y then nn else loop nn in\n loop tn\n in\n let delete x = try\n let n = find x in\n let pn = !(n.prev) in\n let nn = !(n.next) in\n pn.next <- n.next;\n nn.prev <- n.prev\n with\n _ -> ()\n in\n let delete_first () =\n let dn = !(tn.next) in\n let nn = !(dn.next) in\n tn.next <- dn.next;\n nn.prev <- dn.prev\n in\n let delete_last () =\n let dn = !(tn.prev) in\n let pn = !(dn.prev) in\n tn.prev <- dn.prev;\n pn.next <- dn.next\n in\n let print_dll () =\n let rec loop n ls =\n let nn = !(n.next) in\n match nn.value with\n None -> List.rev ls\n | Some x -> loop nn (x :: ls) in\n loop tn [] |> List.map string_of_int |> String.concat \" \" |> print_endline\n in\n let rec iter x =\n if x = 0 then print_dll ()\n else\n let s = read_list () in\n match s with\n \"deleteFirst\" :: _ -> delete_first (); iter (x-1)\n | \"deleteLast\" :: _ -> delete_last (); iter (x-1)\n | \"insert\" :: n :: _ -> insert (int_of_string n); iter (x-1)\n | \"delete\" :: n :: _ -> delete (int_of_string n); iter (x-1)\n | _ -> failwith \"ddl\"\n in iter n", "language": "OCaml", "metadata": {"date": 1499659234, "filename_ext": "ml", "original_language": "OCaml", "problem_description_relpath": "problem_descriptions/p02265.html", "problem_id": "p02265", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02265/input.txt", "sample_output_relpath": "derived/input_output/data/p02265/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02265/OCaml/s993636659.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s993636659", "user_id": "u049242937"}, "prompt_components": {"gold_output": "6 1 2\n", "input_to_evaluate": "open Str\n\ntype dllist = {value : int option; mutable prev : dllist ref; mutable next : dllist ref}\n \nlet read_list () =\n split (regexp \" +\") (read_line ())\n \nlet () =\n let n = read_int () in\n let rec tn = {value = None; prev = ref tn; next = ref tn} in\n let insert x =\n let nn = {value = Some x; prev = ref tn; next = ref tn} in\n let nnn = !(tn.next) in\n nn.next <- tn.next;\n nn.prev <- nnn.prev;\n tn.next <- ref nn;\n nnn.prev <- ref nn\n in\n let find x =\n let rec loop n =\n let nn = !(n.next) in\n match nn.value with\n None -> raise Not_found\n | Some y -> if x = y then nn else loop nn in\n loop tn\n in\n let delete x = try\n let n = find x in\n let pn = !(n.prev) in\n let nn = !(n.next) in\n pn.next <- n.next;\n nn.prev <- n.prev\n with\n _ -> ()\n in\n let delete_first () =\n let dn = !(tn.next) in\n let nn = !(dn.next) in\n tn.next <- dn.next;\n nn.prev <- dn.prev\n in\n let delete_last () =\n let dn = !(tn.prev) in\n let pn = !(dn.prev) in\n tn.prev <- dn.prev;\n pn.next <- dn.next\n in\n let print_dll () =\n let rec loop n ls =\n let nn = !(n.next) in\n match nn.value with\n None -> List.rev ls\n | Some x -> loop nn (x :: ls) in\n loop tn [] |> List.map string_of_int |> String.concat \" \" |> print_endline\n in\n let rec iter x =\n if x = 0 then print_dll ()\n else\n let s = read_list () in\n match s with\n \"deleteFirst\" :: _ -> delete_first (); iter (x-1)\n | \"deleteLast\" :: _ -> delete_last (); iter (x-1)\n | \"insert\" :: n :: _ -> insert (int_of_string n); iter (x-1)\n | \"delete\" :: n :: _ -> delete (int_of_string n); iter (x-1)\n | _ -> failwith \"ddl\"\n in iter n", "problem_context": "Doubly Linked List\n\nYour task is to implement a double linked list.\n\nWrite a program which performs the following operations:\n\ninsert x: insert an element with key x into the front of the list.\n\ndelete x: delete the first element which has the key of x from the list. If there is not such element, you need not do anything.\n\ndeleteFirst: delete the first element from the list.\n\ndeleteLast: delete the last element from the list.\n\nInput\n\nThe input is given in the following format:\n\nn\n\ncommand1\n\ncommand2\n\n...\n\ncommandn\n\nIn the first line, the number of operations n is given. In the following n lines, the above mentioned operations are given in the following format:\n\ninsert x\n\ndelete x\n\ndeleteFirst\n\ndeleteLast\n\nOutput\n\nPrint all the element (key) in the list after the given operations. Two consequtive keys should be separated by a single space.\n\nConstraints\n\nThe number of operations ≤ 2,000,000\n\nThe number of delete operations ≤ 20\n\n0 ≤ value of a key ≤ 109\n\nThe number of elements in the list does not exceed 106\n\nFor a delete, deleteFirst or deleteLast operation, there is at least one element in the list.\n\nSample Input 1\n\n7\ninsert 5\ninsert 2\ninsert 3\ninsert 1\ndelete 3\ninsert 6\ndelete 5\n\nSample Output 1\n\n6 1 2\n\nSample Input 2\n\n9\ninsert 5\ninsert 2\ninsert 3\ninsert 1\ndelete 3\ninsert 6\ndelete 5\ndeleteFirst\ndeleteLast\n\nSample Output 2\n\n1", "sample_input": "7\ninsert 5\ninsert 2\ninsert 3\ninsert 1\ndelete 3\ninsert 6\ndelete 5\n"}, "reference_outputs": ["6 1 2\n"], "source_document_id": "p02265", "source_text": "Doubly Linked List\n\nYour task is to implement a double linked list.\n\nWrite a program which performs the following operations:\n\ninsert x: insert an element with key x into the front of the list.\n\ndelete x: delete the first element which has the key of x from the list. If there is not such element, you need not do anything.\n\ndeleteFirst: delete the first element from the list.\n\ndeleteLast: delete the last element from the list.\n\nInput\n\nThe input is given in the following format:\n\nn\n\ncommand1\n\ncommand2\n\n...\n\ncommandn\n\nIn the first line, the number of operations n is given. In the following n lines, the above mentioned operations are given in the following format:\n\ninsert x\n\ndelete x\n\ndeleteFirst\n\ndeleteLast\n\nOutput\n\nPrint all the element (key) in the list after the given operations. Two consequtive keys should be separated by a single space.\n\nConstraints\n\nThe number of operations ≤ 2,000,000\n\nThe number of delete operations ≤ 20\n\n0 ≤ value of a key ≤ 109\n\nThe number of elements in the list does not exceed 106\n\nFor a delete, deleteFirst or deleteLast operation, there is at least one element in the list.\n\nSample Input 1\n\n7\ninsert 5\ninsert 2\ninsert 3\ninsert 1\ndelete 3\ninsert 6\ndelete 5\n\nSample Output 1\n\n6 1 2\n\nSample Input 2\n\n9\ninsert 5\ninsert 2\ninsert 3\ninsert 1\ndelete 3\ninsert 6\ndelete 5\ndeleteFirst\ndeleteLast\n\nSample Output 2\n\n1", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1791, "cpu_time_ms": 1540, "memory_kb": 123900}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s361162107", "group_id": "codeNet:p02266", "input_text": "let analysis (area:string) =\n let len = String.length area in\n let stack = Stack.create () in\n let rec loop acc = function\n i when i = len -> acc\n | i ->\n match area.[i] with\n | '\\\\' -> Stack.push i stack; loop acc (i+1)\n | '/' -> loop\n (match Stack.length stack with\n 0 -> acc\n | _ -> let j = Stack.pop stack in\n (((j,i),i-j)::acc))\n (i+1)\n | _ -> loop acc (i+1)\n in loop [] 0\n\nlet summarize lst =\n let rec loop acc = function\n [] -> acc\n | [x] -> x::acc\n | ((s1,e1),v1)::((s2,e2),v2)::r when s1 < s2 && e1 > e2 ->\n loop acc (((s1,e1), v1+v2)::r)\n | a::(b::r as rest) -> loop (a::acc) rest\n in loop [] lst\n\nlet () =\n let line = read_line () in\n let count = ref 0 in\n let buf = Buffer.create 128 in\n analysis line |> summarize\n |> List.fold_left\n (fun acc (_,v) ->\n incr count;\n Buffer.add_string buf (Printf.sprintf \" %d\" v);\n acc+v)\n 0\n |> (fun sum -> Printf.printf \"%d\\n%d%s\\n\" sum !count (Buffer.contents buf))", "language": "OCaml", "metadata": {"date": 1477895588, "filename_ext": "ml", "original_language": "OCaml", "problem_description_relpath": "problem_descriptions/p02266.html", "problem_id": "p02266", "resource_group": "low_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/OCaml/s361162107.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s361162107", "user_id": "u995793569"}, "prompt_components": {"gold_output": "4\n1 4\n", "input_to_evaluate": "let analysis (area:string) =\n let len = String.length area in\n let stack = Stack.create () in\n let rec loop acc = function\n i when i = len -> acc\n | i ->\n match area.[i] with\n | '\\\\' -> Stack.push i stack; loop acc (i+1)\n | '/' -> loop\n (match Stack.length stack with\n 0 -> acc\n | _ -> let j = Stack.pop stack in\n (((j,i),i-j)::acc))\n (i+1)\n | _ -> loop acc (i+1)\n in loop [] 0\n\nlet summarize lst =\n let rec loop acc = function\n [] -> acc\n | [x] -> x::acc\n | ((s1,e1),v1)::((s2,e2),v2)::r when s1 < s2 && e1 > e2 ->\n loop acc (((s1,e1), v1+v2)::r)\n | a::(b::r as rest) -> loop (a::acc) rest\n in loop [] lst\n\nlet () =\n let line = read_line () in\n let count = ref 0 in\n let buf = Buffer.create 128 in\n analysis line |> summarize\n |> List.fold_left\n (fun acc (_,v) ->\n incr count;\n Buffer.add_string buf (Printf.sprintf \" %d\" v);\n acc+v)\n 0\n |> (fun sum -> Printf.printf \"%d\\n%d%s\\n\" sum !count (Buffer.contents buf))", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1085, "cpu_time_ms": 40, "memory_kb": 3936}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s048261564", "group_id": "codeNet:p02268", "input_text": "let bin_search x ary =\n let rec doit l r =\n if l >= r then false\n else begin\n let m = (l + r) / 2 in\n if x = ary.(m) then true\n else if x < ary.(m) then doit l m\n else doit (m + 1) r\n end\n in\n doit 0 (Array.length ary)\n\nlet () =\n let _ = read_int () in\n let s = Array.of_list (List.map int_of_string (Str.split (Str.regexp_string \" \") (read_line ()))) in\n let _ = read_int () in\n let t = List.map int_of_string (Str.split (Str.regexp_string \" \") (read_line ())) in\n let c = List.fold_left (fun cnt e -> if bin_search e s then (cnt + 1) else cnt) 0 t in\n Printf.printf \"%d\\n\" c", "language": "OCaml", "metadata": {"date": 1473383931, "filename_ext": "ml", "original_language": "OCaml", "problem_description_relpath": "problem_descriptions/p02268.html", "problem_id": "p02268", "resource_group": "low_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/OCaml/s048261564.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s048261564", "user_id": "u809138450"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "let bin_search x ary =\n let rec doit l r =\n if l >= r then false\n else begin\n let m = (l + r) / 2 in\n if x = ary.(m) then true\n else if x < ary.(m) then doit l m\n else doit (m + 1) r\n end\n in\n doit 0 (Array.length ary)\n\nlet () =\n let _ = read_int () in\n let s = Array.of_list (List.map int_of_string (Str.split (Str.regexp_string \" \") (read_line ()))) in\n let _ = read_int () in\n let t = List.map int_of_string (Str.split (Str.regexp_string \" \") (read_line ())) in\n let c = List.fold_left (fun cnt e -> if bin_search e s then (cnt + 1) else cnt) 0 t in\n Printf.printf \"%d\\n\" c", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 614, "cpu_time_ms": 40, "memory_kb": 16248}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s145748444", "group_id": "codeNet:p02268", "input_text": "let words str = Str.split (Str.regexp \" \") str |> List.map int_of_string\n\nlet bs elem (a: int array) =\n let rec loop (i_min,i_max) =\n match i_min > i_max with\n true -> false\n | false ->\n let mid = (i_min+i_max)/2 in\n match a.(mid) = elem with\n true -> true\n | false ->\n loop (match a.(mid) < elem with true -> mid+1,i_max | false -> i_min,mid-1)\n in loop (0,(Array.length a) -1)\n\nlet () =\n let _ = read_int () in\n let s = read_line () |> words |> Array.of_list in\n let _ = read_int () in\n let t = read_line () |> words in\n List.fold_left (fun acc x -> match bs x s with true -> acc+1 | false -> acc)\n 0 t\n |> Printf.printf \"%d\\n\"", "language": "OCaml", "metadata": {"date": 1477909227, "filename_ext": "ml", "original_language": "OCaml", "problem_description_relpath": "problem_descriptions/p02268.html", "problem_id": "p02268", "resource_group": "low_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/OCaml/s145748444.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s145748444", "user_id": "u995793569"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "let words str = Str.split (Str.regexp \" \") str |> List.map int_of_string\n\nlet bs elem (a: int array) =\n let rec loop (i_min,i_max) =\n match i_min > i_max with\n true -> false\n | false ->\n let mid = (i_min+i_max)/2 in\n match a.(mid) = elem with\n true -> true\n | false ->\n loop (match a.(mid) < elem with true -> mid+1,i_max | false -> i_min,mid-1)\n in loop (0,(Array.length a) -1)\n\nlet () =\n let _ = read_int () in\n let s = read_line () |> words |> Array.of_list in\n let _ = read_int () in\n let t = read_line () |> words in\n List.fold_left (fun acc x -> match bs x s with true -> acc+1 | false -> acc)\n 0 t\n |> Printf.printf \"%d\\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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 680, "cpu_time_ms": 30, "memory_kb": 16236}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s306191963", "group_id": "codeNet:p02268", "input_text": "module ArrayL = ArrayLabels\nmodule ListL = ListLabels\n\nlet dbg = Printf.printf \"[debug]%s\"\n\nlet max_num = 100_000_000_000\n\nlet id = fun x -> x\nlet tuple2 x y = (x,y)\nlet tuple3 x y z = (x,y,z)\nlet succ x = x + 1\nlet pred x = x - 1\n\nlet (++) n m =\n let rec aux i =\n if i = m then [m]\n else i :: aux (i+1) in\n if n > m then [] else aux n\n\nlet (++^) n m = n ++ (m-1)\n\nlet scan fmt f = Scanf.sscanf (read_line ()) fmt f\n\nlet scan_list ~sep cnv =\n let line = read_line () in\n Str.split (Str.regexp_string sep) line\n |> List.map cnv\n\nlet scan_lines n fmt f =\n List.map (fun _ -> scan fmt f) (0++^n)\n\nlet scan_matrix n m e conv =\n let arr = Array.make_matrix n m e in\n Array.iteri (fun i line ->\n let s = Scanf.Scanning.from_string @@ read_line () in\n Array.iteri (fun j _ ->\n arr.(i).(j) <- Scanf.bscanf s \" %s\" conv;\n ) line) arr; arr\n\nlet rec powerset = function\n | [] -> [[]]\n | hd::tl ->\n let pws = powerset tl in\n pws @ ListL.map pws ~f:(fun pw -> hd::pw)\n\nlet permutations l =\n let rec interleave x = function\n | [] -> [[x]]\n | (hd::tl) as l ->\n (x::l) :: (interleave x tl |> ListL.map ~f:(fun l -> hd::l)) in\n let rec aux = function\n | [] -> [[]]\n | a::rest ->\n aux rest |> ListL.map ~f:(interleave a) |> List.concat in\n aux l\n\nlet between n x m = n <= x && x < m\n\nlet lower_bound n f =\n let rec aux l u =\n if u - l > 1 then\n let m = (l + u) / 2 in\n if f m then aux l m\n else aux m u\n else u in aux (-1) n\n\nlet string_to_list s =\n List.map (String.get s) (0 ++^ String.length s)\n\nlet n = scan \"%d\" id\nlet s = Array.of_list @@ scan_list ~sep:\" \" int_of_string\nlet q = scan \"%d\" id\nlet t = scan_list ~sep:\" \" int_of_string\n\nlet () =\n ListL.map t ~f:(fun v ->\n let i = lower_bound (Array.length s) (fun i -> v <= s.(i)) in\n if i < Array.length s && s.(i) = v then 1 else 0\n ) |> ListL.fold_left ~init:0 ~f:(+) |> Printf.printf \"%d\\n\"\n\n", "language": "OCaml", "metadata": {"date": 1591419031, "filename_ext": "ml", "original_language": "OCaml", "problem_description_relpath": "problem_descriptions/p02268.html", "problem_id": "p02268", "resource_group": "low_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/OCaml/s306191963.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s306191963", "user_id": "u827214117"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "module ArrayL = ArrayLabels\nmodule ListL = ListLabels\n\nlet dbg = Printf.printf \"[debug]%s\"\n\nlet max_num = 100_000_000_000\n\nlet id = fun x -> x\nlet tuple2 x y = (x,y)\nlet tuple3 x y z = (x,y,z)\nlet succ x = x + 1\nlet pred x = x - 1\n\nlet (++) n m =\n let rec aux i =\n if i = m then [m]\n else i :: aux (i+1) in\n if n > m then [] else aux n\n\nlet (++^) n m = n ++ (m-1)\n\nlet scan fmt f = Scanf.sscanf (read_line ()) fmt f\n\nlet scan_list ~sep cnv =\n let line = read_line () in\n Str.split (Str.regexp_string sep) line\n |> List.map cnv\n\nlet scan_lines n fmt f =\n List.map (fun _ -> scan fmt f) (0++^n)\n\nlet scan_matrix n m e conv =\n let arr = Array.make_matrix n m e in\n Array.iteri (fun i line ->\n let s = Scanf.Scanning.from_string @@ read_line () in\n Array.iteri (fun j _ ->\n arr.(i).(j) <- Scanf.bscanf s \" %s\" conv;\n ) line) arr; arr\n\nlet rec powerset = function\n | [] -> [[]]\n | hd::tl ->\n let pws = powerset tl in\n pws @ ListL.map pws ~f:(fun pw -> hd::pw)\n\nlet permutations l =\n let rec interleave x = function\n | [] -> [[x]]\n | (hd::tl) as l ->\n (x::l) :: (interleave x tl |> ListL.map ~f:(fun l -> hd::l)) in\n let rec aux = function\n | [] -> [[]]\n | a::rest ->\n aux rest |> ListL.map ~f:(interleave a) |> List.concat in\n aux l\n\nlet between n x m = n <= x && x < m\n\nlet lower_bound n f =\n let rec aux l u =\n if u - l > 1 then\n let m = (l + u) / 2 in\n if f m then aux l m\n else aux m u\n else u in aux (-1) n\n\nlet string_to_list s =\n List.map (String.get s) (0 ++^ String.length s)\n\nlet n = scan \"%d\" id\nlet s = Array.of_list @@ scan_list ~sep:\" \" int_of_string\nlet q = scan \"%d\" id\nlet t = scan_list ~sep:\" \" int_of_string\n\nlet () =\n ListL.map t ~f:(fun v ->\n let i = lower_bound (Array.length s) (fun i -> v <= s.(i)) in\n if i < Array.length s && s.(i) = v then 1 else 0\n ) |> ListL.fold_left ~init:0 ~f:(+) |> Printf.printf \"%d\\n\"\n\n", "problem_context": "Search II\n\nYou are given a sequence of n integers S and a sequence of different q integers T. Write a program which outputs C, the number of integers in T which are also in the set S.\n\nInput\n\nIn the first line n is given. In the second line, n integers are given. In the third line q is given. Then, in the fourth line, q integers are given.\n\nOutput\n\nPrint C in a line.\n\nConstraints\n\nElements in S is sorted in ascending order\n\nn ≤ 100000\n\nq ≤ 50000\n\n0 ≤ an element in S ≤ 109\n\n0 ≤ an element in T ≤ 109\n\nSample Input 1\n\n5\n1 2 3 4 5\n3\n3 4 1\n\nSample Output 1\n\n3\n\nSample Input 2\n\n3\n1 2 3\n1\n5\n\nSample Output 2\n\n0\n\nSample Input 3\n\n5\n1 1 2 2 3\n2\n1 2\n\nSample Output 3\n\n2\n\nNotes", "sample_input": "5\n1 2 3 4 5\n3\n3 4 1\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02268", "source_text": "Search II\n\nYou are given a sequence of n integers S and a sequence of different q integers T. Write a program which outputs C, the number of integers in T which are also in the set S.\n\nInput\n\nIn the first line n is given. In the second line, n integers are given. In the third line q is given. Then, in the fourth line, q integers are given.\n\nOutput\n\nPrint C in a line.\n\nConstraints\n\nElements in S is sorted in ascending order\n\nn ≤ 100000\n\nq ≤ 50000\n\n0 ≤ an element in S ≤ 109\n\n0 ≤ an element in T ≤ 109\n\nSample Input 1\n\n5\n1 2 3 4 5\n3\n3 4 1\n\nSample Output 1\n\n3\n\nSample Input 2\n\n3\n1 2 3\n1\n5\n\nSample Output 2\n\n0\n\nSample Input 3\n\n5\n1 1 2 2 3\n2\n1 2\n\nSample Output 3\n\n2\n\nNotes", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1945, "cpu_time_ms": 40, "memory_kb": 21356}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s981890756", "group_id": "codeNet:p02270", "input_text": "let () =\n let (n, k) = Scanf.scanf \"%d %d\\n\" (fun n k -> (n, k)) in\n let a = Array.make n 0 in\n let rec read i =\n if i >= n then ()\n else (Scanf.scanf \"%d\\n\" (fun w -> a.(i) <- w); read (i + 1))\n in\n read 0;\n let check p =\n let rec doit i j s =\n if i = n then n\n else if j >= k then i\n else\n let x = s + a.(i) in\n if x > p then doit i (j + 1) 0\n else doit (i + 1) j x\n in\n doit 0 0 0\n in\n let rec bin_search l r =\n if r < l then l\n else\n let m = (l + r) / 2 in\n let v = check m in\n if v >= n then bin_search l (m - 1)\n else bin_search (m + 1) r\n in\n Printf.printf \"%d\\n\" (bin_search 0 (100000 * 10000))", "language": "OCaml", "metadata": {"date": 1474062731, "filename_ext": "ml", "original_language": "OCaml", "problem_description_relpath": "problem_descriptions/p02270.html", "problem_id": "p02270", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02270/input.txt", "sample_output_relpath": "derived/input_output/data/p02270/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02270/OCaml/s981890756.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s981890756", "user_id": "u809138450"}, "prompt_components": {"gold_output": "10\n", "input_to_evaluate": "let () =\n let (n, k) = Scanf.scanf \"%d %d\\n\" (fun n k -> (n, k)) in\n let a = Array.make n 0 in\n let rec read i =\n if i >= n then ()\n else (Scanf.scanf \"%d\\n\" (fun w -> a.(i) <- w); read (i + 1))\n in\n read 0;\n let check p =\n let rec doit i j s =\n if i = n then n\n else if j >= k then i\n else\n let x = s + a.(i) in\n if x > p then doit i (j + 1) 0\n else doit (i + 1) j x\n in\n doit 0 0 0\n in\n let rec bin_search l r =\n if r < l then l\n else\n let m = (l + r) / 2 in\n let v = check m in\n if v >= n then bin_search l (m - 1)\n else bin_search (m + 1) r\n in\n Printf.printf \"%d\\n\" (bin_search 0 (100000 * 10000))", "problem_context": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nYou are given $n$ packages of $w_i$ kg from a belt conveyor in order ($i = 0, 1, ... n-1$). You should load all packages onto $k$ trucks which have the common maximum load $P$. Each truck can load consecutive packages (more than or equals to zero) from the belt conveyor unless the total weights of the packages in the sequence does not exceed the maximum load $P$.\n\nWrite a program which reads $n$, $k$ and $w_i$, and reports the minimum value of the maximum load $P$ to load all packages from the belt conveyor.\n\nInput\n\nIn the first line, two integers $n$ and $k$ are given separated by a space character. In the following $n$ lines, $w_i$ are given respectively.\n\nOutput\n\nPrint the minimum value of $P$ in a line.\n\nConstraints\n\n$1 \\leq n \\leq 100,000$\n\n$1 \\leq k \\leq 100,000$\n\n$1 \\leq w_i \\leq 10,000$\n\nSample Input 1\n\n5 3\n8\n1\n7\n3\n9\n\nSample Output 1\n\n10\n\nIf the first truck loads two packages of $\\{8, 1\\}$, the second truck loads two packages of $\\{7, 3\\}$ and the third truck loads a package of $\\{9\\}$, then the minimum value of the maximum load $P$ shall be 10.\n\nSample Input 2\n\n4 2\n1\n2\n2\n6\n\nSample Output 2\n\n6\n\nIf the first truck loads three packages of $\\{1, 2, 2\\}$ and the second truck loads a package of $\\{6\\}$, then the minimum value of the maximum load $P$ shall be 6.", "sample_input": "5 3\n8\n1\n7\n3\n9\n"}, "reference_outputs": ["10\n"], "source_document_id": "p02270", "source_text": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nYou are given $n$ packages of $w_i$ kg from a belt conveyor in order ($i = 0, 1, ... n-1$). You should load all packages onto $k$ trucks which have the common maximum load $P$. Each truck can load consecutive packages (more than or equals to zero) from the belt conveyor unless the total weights of the packages in the sequence does not exceed the maximum load $P$.\n\nWrite a program which reads $n$, $k$ and $w_i$, and reports the minimum value of the maximum load $P$ to load all packages from the belt conveyor.\n\nInput\n\nIn the first line, two integers $n$ and $k$ are given separated by a space character. In the following $n$ lines, $w_i$ are given respectively.\n\nOutput\n\nPrint the minimum value of $P$ in a line.\n\nConstraints\n\n$1 \\leq n \\leq 100,000$\n\n$1 \\leq k \\leq 100,000$\n\n$1 \\leq w_i \\leq 10,000$\n\nSample Input 1\n\n5 3\n8\n1\n7\n3\n9\n\nSample Output 1\n\n10\n\nIf the first truck loads two packages of $\\{8, 1\\}$, the second truck loads two packages of $\\{7, 3\\}$ and the third truck loads a package of $\\{9\\}$, then the minimum value of the maximum load $P$ shall be 10.\n\nSample Input 2\n\n4 2\n1\n2\n2\n6\n\nSample Output 2\n\n6\n\nIf the first truck loads three packages of $\\{1, 2, 2\\}$ and the second truck loads a package of $\\{6\\}$, then the minimum value of the maximum load $P$ shall be 6.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 689, "cpu_time_ms": 20, "memory_kb": 5324}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s028979082", "group_id": "codeNet:p02270", "input_text": "let () =\n let (n, k) = Scanf.scanf \"%d %d\\n\" (fun n k -> (n, k)) in\n let a = Array.init n (fun _ -> Scanf.scanf \"%d\\n\" (fun i -> i)) in\n let check p =\n let rec doit i j s =\n if i = n then n\n else if j >= k then i\n else\n let x = s + a.(i) in\n if x > p then doit i (j + 1) 0\n else doit (i + 1) j x\n in\n doit 0 0 0\n in\n let rec bin_search l r =\n if r < l then l\n else\n let m = (l + r) / 2 in\n if check m >= n then bin_search l (m - 1)\n else bin_search (m + 1) r\n in\n Printf.printf \"%d\\n\" (bin_search 0 (100000 * 10000))", "language": "OCaml", "metadata": {"date": 1474606359, "filename_ext": "ml", "original_language": "OCaml", "problem_description_relpath": "problem_descriptions/p02270.html", "problem_id": "p02270", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02270/input.txt", "sample_output_relpath": "derived/input_output/data/p02270/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02270/OCaml/s028979082.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s028979082", "user_id": "u809138450"}, "prompt_components": {"gold_output": "10\n", "input_to_evaluate": "let () =\n let (n, k) = Scanf.scanf \"%d %d\\n\" (fun n k -> (n, k)) in\n let a = Array.init n (fun _ -> Scanf.scanf \"%d\\n\" (fun i -> i)) in\n let check p =\n let rec doit i j s =\n if i = n then n\n else if j >= k then i\n else\n let x = s + a.(i) in\n if x > p then doit i (j + 1) 0\n else doit (i + 1) j x\n in\n doit 0 0 0\n in\n let rec bin_search l r =\n if r < l then l\n else\n let m = (l + r) / 2 in\n if check m >= n then bin_search l (m - 1)\n else bin_search (m + 1) r\n in\n Printf.printf \"%d\\n\" (bin_search 0 (100000 * 10000))", "problem_context": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nYou are given $n$ packages of $w_i$ kg from a belt conveyor in order ($i = 0, 1, ... n-1$). You should load all packages onto $k$ trucks which have the common maximum load $P$. Each truck can load consecutive packages (more than or equals to zero) from the belt conveyor unless the total weights of the packages in the sequence does not exceed the maximum load $P$.\n\nWrite a program which reads $n$, $k$ and $w_i$, and reports the minimum value of the maximum load $P$ to load all packages from the belt conveyor.\n\nInput\n\nIn the first line, two integers $n$ and $k$ are given separated by a space character. In the following $n$ lines, $w_i$ are given respectively.\n\nOutput\n\nPrint the minimum value of $P$ in a line.\n\nConstraints\n\n$1 \\leq n \\leq 100,000$\n\n$1 \\leq k \\leq 100,000$\n\n$1 \\leq w_i \\leq 10,000$\n\nSample Input 1\n\n5 3\n8\n1\n7\n3\n9\n\nSample Output 1\n\n10\n\nIf the first truck loads two packages of $\\{8, 1\\}$, the second truck loads two packages of $\\{7, 3\\}$ and the third truck loads a package of $\\{9\\}$, then the minimum value of the maximum load $P$ shall be 10.\n\nSample Input 2\n\n4 2\n1\n2\n2\n6\n\nSample Output 2\n\n6\n\nIf the first truck loads three packages of $\\{1, 2, 2\\}$ and the second truck loads a package of $\\{6\\}$, then the minimum value of the maximum load $P$ shall be 6.", "sample_input": "5 3\n8\n1\n7\n3\n9\n"}, "reference_outputs": ["10\n"], "source_document_id": "p02270", "source_text": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nYou are given $n$ packages of $w_i$ kg from a belt conveyor in order ($i = 0, 1, ... n-1$). You should load all packages onto $k$ trucks which have the common maximum load $P$. Each truck can load consecutive packages (more than or equals to zero) from the belt conveyor unless the total weights of the packages in the sequence does not exceed the maximum load $P$.\n\nWrite a program which reads $n$, $k$ and $w_i$, and reports the minimum value of the maximum load $P$ to load all packages from the belt conveyor.\n\nInput\n\nIn the first line, two integers $n$ and $k$ are given separated by a space character. In the following $n$ lines, $w_i$ are given respectively.\n\nOutput\n\nPrint the minimum value of $P$ in a line.\n\nConstraints\n\n$1 \\leq n \\leq 100,000$\n\n$1 \\leq k \\leq 100,000$\n\n$1 \\leq w_i \\leq 10,000$\n\nSample Input 1\n\n5 3\n8\n1\n7\n3\n9\n\nSample Output 1\n\n10\n\nIf the first truck loads two packages of $\\{8, 1\\}$, the second truck loads two packages of $\\{7, 3\\}$ and the third truck loads a package of $\\{9\\}$, then the minimum value of the maximum load $P$ shall be 10.\n\nSample Input 2\n\n4 2\n1\n2\n2\n6\n\nSample Output 2\n\n6\n\nIf the first truck loads three packages of $\\{1, 2, 2\\}$ and the second truck loads a package of $\\{6\\}$, then the minimum value of the maximum load $P$ shall be 6.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 589, "cpu_time_ms": 10, "memory_kb": 5332}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s483780597", "group_id": "codeNet:p02271", "input_text": "module ArrayL = ArrayLabels\nmodule ListL = ListLabels\n\nlet dbg = Printf.printf \"[debug]%s\"\n\nlet max_num = 100_000_000_000\n\nlet id = fun x -> x\nlet tuple2 x y = (x,y)\nlet tuple3 x y z = (x,y,z)\nlet succ x = x + 1\nlet pred x = x - 1\n\nlet (++) n m =\n let rec aux acc i =\n if i = m then m::acc\n else aux (i::acc) (i+1) in\n if n > m then [] else List.rev @@ aux [] n\n\nlet (++^) n m = n ++ (m-1)\n\nlet scan fmt f = Scanf.sscanf (read_line ()) fmt f\n\nlet scan_list ~sep cnv =\n let line = read_line () in\n Str.split (Str.regexp_string sep) line\n |> List.map cnv\n\nlet scan_lines n fmt f =\n List.map (fun _ -> scan fmt f) (0++^n)\n\nlet scan_matrix n m e conv =\n let arr = Array.make_matrix n m e in\n Array.iteri (fun i line ->\n let s = Scanf.Scanning.from_string @@ read_line () in\n Array.iteri (fun j _ ->\n arr.(i).(j) <- Scanf.bscanf s \" %s\" conv;\n ) line) arr; arr\n\nlet between n x m = n <= x && x < m\n\nlet string_to_list s =\n List.map (String.get s) (0 ++^ String.length s)\n\nlet rec powerset = function\n | [] -> [[]]\n | hd::tl ->\n let pws = powerset tl in\n pws @ ListL.map pws ~f:(fun pw -> hd::pw)\n\n(* let powerset l =\n * let rec append acc l1 l2 =\n * match l1, l2 with\n * | [], [] -> acc\n * | [], h :: t -> append (h :: acc) [] t\n * | h :: t, l -> append (h :: acc) t l in\n * let rec aux acc = function\n * | [] -> acc\n * | hd::tl ->\n * aux (append [] acc @@ ListL.map acc ~f:(fun ac -> hd::ac)) tl in\n * aux [[]] l *)\n\nlet permutations l =\n let rec interleave x = function\n | [] -> [[x]]\n | (hd::tl) as l ->\n (x::l) :: (interleave x tl |> ListL.map ~f:(fun l -> hd::l)) in\n let rec aux = function\n | [] -> [[]]\n | a::rest ->\n aux rest |> ListL.map ~f:(interleave a) |> List.concat in\n aux l\n\nlet n = scan \"%d\" id\nlet arr = Array.of_list @@ scan_list ~sep:\" \" int_of_string\nlet q = scan \"%d\" id\nlet ls = scan_list ~sep:\" \" int_of_string\n\nexception Found\n\nlet () =\n let pwss = powerset (0 ++^ n) in\n let ht = Hashtbl.create @@ List.length pwss in\n ListL.iter pwss ~f:(fun pws ->\n ListL.map pws ~f:(fun i -> arr.(i))\n |> ListL.fold_left ~init:0 ~f:(+)\n |> (fun v-> Hashtbl.add ht v true));\n ListL.iter ls ~f:(fun v ->\n if Hashtbl.mem ht v then Printf.printf \"yes\\n\"\n else Printf.printf \"no\\n\")\n\n", "language": "OCaml", "metadata": {"date": 1591198824, "filename_ext": "ml", "original_language": "OCaml", "problem_description_relpath": "problem_descriptions/p02271.html", "problem_id": "p02271", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02271/input.txt", "sample_output_relpath": "derived/input_output/data/p02271/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02271/OCaml/s483780597.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s483780597", "user_id": "u827214117"}, "prompt_components": {"gold_output": "no\nno\nyes\nyes\nyes\nyes\nno\nno\n", "input_to_evaluate": "module ArrayL = ArrayLabels\nmodule ListL = ListLabels\n\nlet dbg = Printf.printf \"[debug]%s\"\n\nlet max_num = 100_000_000_000\n\nlet id = fun x -> x\nlet tuple2 x y = (x,y)\nlet tuple3 x y z = (x,y,z)\nlet succ x = x + 1\nlet pred x = x - 1\n\nlet (++) n m =\n let rec aux acc i =\n if i = m then m::acc\n else aux (i::acc) (i+1) in\n if n > m then [] else List.rev @@ aux [] n\n\nlet (++^) n m = n ++ (m-1)\n\nlet scan fmt f = Scanf.sscanf (read_line ()) fmt f\n\nlet scan_list ~sep cnv =\n let line = read_line () in\n Str.split (Str.regexp_string sep) line\n |> List.map cnv\n\nlet scan_lines n fmt f =\n List.map (fun _ -> scan fmt f) (0++^n)\n\nlet scan_matrix n m e conv =\n let arr = Array.make_matrix n m e in\n Array.iteri (fun i line ->\n let s = Scanf.Scanning.from_string @@ read_line () in\n Array.iteri (fun j _ ->\n arr.(i).(j) <- Scanf.bscanf s \" %s\" conv;\n ) line) arr; arr\n\nlet between n x m = n <= x && x < m\n\nlet string_to_list s =\n List.map (String.get s) (0 ++^ String.length s)\n\nlet rec powerset = function\n | [] -> [[]]\n | hd::tl ->\n let pws = powerset tl in\n pws @ ListL.map pws ~f:(fun pw -> hd::pw)\n\n(* let powerset l =\n * let rec append acc l1 l2 =\n * match l1, l2 with\n * | [], [] -> acc\n * | [], h :: t -> append (h :: acc) [] t\n * | h :: t, l -> append (h :: acc) t l in\n * let rec aux acc = function\n * | [] -> acc\n * | hd::tl ->\n * aux (append [] acc @@ ListL.map acc ~f:(fun ac -> hd::ac)) tl in\n * aux [[]] l *)\n\nlet permutations l =\n let rec interleave x = function\n | [] -> [[x]]\n | (hd::tl) as l ->\n (x::l) :: (interleave x tl |> ListL.map ~f:(fun l -> hd::l)) in\n let rec aux = function\n | [] -> [[]]\n | a::rest ->\n aux rest |> ListL.map ~f:(interleave a) |> List.concat in\n aux l\n\nlet n = scan \"%d\" id\nlet arr = Array.of_list @@ scan_list ~sep:\" \" int_of_string\nlet q = scan \"%d\" id\nlet ls = scan_list ~sep:\" \" int_of_string\n\nexception Found\n\nlet () =\n let pwss = powerset (0 ++^ n) in\n let ht = Hashtbl.create @@ List.length pwss in\n ListL.iter pwss ~f:(fun pws ->\n ListL.map pws ~f:(fun i -> arr.(i))\n |> ListL.fold_left ~init:0 ~f:(+)\n |> (fun v-> Hashtbl.add ht v true));\n ListL.iter ls ~f:(fun v ->\n if Hashtbl.mem ht v then Printf.printf \"yes\\n\"\n else Printf.printf \"no\\n\")\n\n", "problem_context": "Exhaustive Search\n\nWrite a program which reads a sequence A of n elements and an integer M, and outputs \"yes\" if you can make M by adding elements in A, otherwise \"no\". You can use an element only once.\n\nYou are given the sequence A and q questions where each question contains Mi.\n\nInput\n\nIn the first line n is given. In the second line, n integers are given. In the third line q is given. Then, in the fourth line, q integers (Mi) are given.\n\nOutput\n\nFor each question Mi, print yes or no.\n\nConstraints\n\nn ≤ 20\n\nq ≤ 200\n\n1 ≤ elements in A ≤ 2000\n\n1 ≤ Mi ≤ 2000\n\nSample Input 1\n\n5\n1 5 7 10 21\n8\n2 4 17 8 22 21 100 35\n\nSample Output 1\n\nno\nno\nyes\nyes\nyes\nyes\nno\nno\n\nNotes\n\nYou can solve this problem by a Burte Force approach. Suppose solve(p, t) is a function which checkes whether you can make t by selecting elements after p-th element (inclusive). Then you can recursively call the following functions:\n\nsolve(0, M)\n\nsolve(1, M-{sum created from elements before 1st element})\n\nsolve(2, M-{sum created from elements before 2nd element})\n\n...\n\nThe recursive function has two choices: you selected p-th element and not. So, you can check solve(p+1, t-A[p]) and solve(p+1, t) in solve(p, t) to check the all combinations.\n\nFor example, the following figure shows that 8 can be made by A[0] + A[2].", "sample_input": "5\n1 5 7 10 21\n8\n2 4 17 8 22 21 100 35\n"}, "reference_outputs": ["no\nno\nyes\nyes\nyes\nyes\nno\nno\n"], "source_document_id": "p02271", "source_text": "Exhaustive Search\n\nWrite a program which reads a sequence A of n elements and an integer M, and outputs \"yes\" if you can make M by adding elements in A, otherwise \"no\". You can use an element only once.\n\nYou are given the sequence A and q questions where each question contains Mi.\n\nInput\n\nIn the first line n is given. In the second line, n integers are given. In the third line q is given. Then, in the fourth line, q integers (Mi) are given.\n\nOutput\n\nFor each question Mi, print yes or no.\n\nConstraints\n\nn ≤ 20\n\nq ≤ 200\n\n1 ≤ elements in A ≤ 2000\n\n1 ≤ Mi ≤ 2000\n\nSample Input 1\n\n5\n1 5 7 10 21\n8\n2 4 17 8 22 21 100 35\n\nSample Output 1\n\nno\nno\nyes\nyes\nyes\nyes\nno\nno\n\nNotes\n\nYou can solve this problem by a Burte Force approach. Suppose solve(p, t) is a function which checkes whether you can make t by selecting elements after p-th element (inclusive). Then you can recursively call the following functions:\n\nsolve(0, M)\n\nsolve(1, M-{sum created from elements before 1st element})\n\nsolve(2, M-{sum created from elements before 2nd element})\n\n...\n\nThe recursive function has two choices: you selected p-th element and not. So, you can check solve(p+1, t-A[p]) and solve(p+1, t) in solve(p, t) to check the all combinations.\n\nFor example, the following figure shows that 8 can be made by A[0] + A[2].", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2327, "cpu_time_ms": 410, "memory_kb": 128596}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s552159015", "group_id": "codeNet:p02272", "input_text": "let to_array s =\n Str.split (Str.regexp_string \" \") s\n |> List.map int_of_string\n |> Array.of_list;;\n\nlet print_array l =\n Array.map string_of_int l\n |> Array.to_list\n |> String.concat \" \"\n |> print_endline;;\n\nlet merge (a:int array) left mid right =\n let n1 = mid - left and\n n2 = right - mid in\n let l = Array.init (n1+1) (fun i -> if i < n1 then a.(left+i) else max_int) and\n r = Array.init (n2+1) (fun i -> if i < n2 then a.(mid+i) else max_int) and\n i = ref 0 and\n j = ref 0 and\n count = ref 0\n in\n for k = left to right-1 do\n if l.(!i) <= r.(!j) then\n begin\n a.(k) <- l.(!i); i := !i+1\n end\n else\n begin\n a.(k) <- r.(!j); j := !j+1\n end;\n count := !count+1\n done;\n !count\n\nlet rec merge_sort a left right count =\n if left + 1 < right then\n let mid = (left+right)/2 in\n let count1 = merge_sort a left mid count and\n count2 = merge_sort a mid right count in\n count1 + count2 + (merge a left mid right)\n else count\n;;\n\nlet () =\n let _ = read_int () and\n a = read_line () |> to_array in\n let count = merge_sort a 0 (Array.length a) 0 in\n print_array a;\n print_int count;\n print_newline ()\n;;", "language": "OCaml", "metadata": {"date": 1468334057, "filename_ext": "ml", "original_language": "OCaml", "problem_description_relpath": "problem_descriptions/p02272.html", "problem_id": "p02272", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02272/input.txt", "sample_output_relpath": "derived/input_output/data/p02272/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02272/OCaml/s552159015.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s552159015", "user_id": "u935184340"}, "prompt_components": {"gold_output": "1 2 3 4 5 6 7 8 9 10\n34\n", "input_to_evaluate": "let to_array s =\n Str.split (Str.regexp_string \" \") s\n |> List.map int_of_string\n |> Array.of_list;;\n\nlet print_array l =\n Array.map string_of_int l\n |> Array.to_list\n |> String.concat \" \"\n |> print_endline;;\n\nlet merge (a:int array) left mid right =\n let n1 = mid - left and\n n2 = right - mid in\n let l = Array.init (n1+1) (fun i -> if i < n1 then a.(left+i) else max_int) and\n r = Array.init (n2+1) (fun i -> if i < n2 then a.(mid+i) else max_int) and\n i = ref 0 and\n j = ref 0 and\n count = ref 0\n in\n for k = left to right-1 do\n if l.(!i) <= r.(!j) then\n begin\n a.(k) <- l.(!i); i := !i+1\n end\n else\n begin\n a.(k) <- r.(!j); j := !j+1\n end;\n count := !count+1\n done;\n !count\n\nlet rec merge_sort a left right count =\n if left + 1 < right then\n let mid = (left+right)/2 in\n let count1 = merge_sort a left mid count and\n count2 = merge_sort a mid right count in\n count1 + count2 + (merge a left mid right)\n else count\n;;\n\nlet () =\n let _ = read_int () and\n a = read_line () |> to_array in\n let count = merge_sort a 0 (Array.length a) 0 in\n print_array a;\n print_int count;\n print_newline ()\n;;", "problem_context": "Merge Sort\n\nWrite a program of a Merge Sort algorithm implemented by the following pseudocode. You should also report the number of comparisons in the Merge function.\n\nMerge(A, left, mid, right)\nn1 = mid - left;\nn2 = right - mid;\ncreate array L[0...n1], R[0...n2]\nfor i = 0 to n1-1\ndo L[i] = A[left + i]\nfor i = 0 to n2-1\ndo R[i] = A[mid + i]\nL[n1] = SENTINEL\nR[n2] = SENTINEL\ni = 0;\nj = 0;\nfor k = left to right-1\nif L[i] <= R[j]\nthen A[k] = L[i]\ni = i + 1\nelse A[k] = R[j]\nj = j + 1\n\nMerge-Sort(A, left, right){\nif left+1 < right\nthen mid = (left + right)/2;\ncall Merge-Sort(A, left, mid)\ncall Merge-Sort(A, mid, right)\ncall Merge(A, left, mid, right)\n\nInput\n\nIn the first line n is given. In the second line, n integers are given.\n\nOutput\n\nIn the first line, print the sequence S. Two consequtive elements should be separated by a space character.\n\nIn the second line, print the number of comparisons.\n\nConstraints\n\nn ≤ 500000\n\n0 ≤ an element in S ≤ 109\n\nSample Input 1\n\n10\n8 5 9 2 6 3 7 1 10 4\n\nSample Output 1\n\n1 2 3 4 5 6 7 8 9 10\n34\n\nNotes", "sample_input": "10\n8 5 9 2 6 3 7 1 10 4\n"}, "reference_outputs": ["1 2 3 4 5 6 7 8 9 10\n34\n"], "source_document_id": "p02272", "source_text": "Merge Sort\n\nWrite a program of a Merge Sort algorithm implemented by the following pseudocode. You should also report the number of comparisons in the Merge function.\n\nMerge(A, left, mid, right)\nn1 = mid - left;\nn2 = right - mid;\ncreate array L[0...n1], R[0...n2]\nfor i = 0 to n1-1\ndo L[i] = A[left + i]\nfor i = 0 to n2-1\ndo R[i] = A[mid + i]\nL[n1] = SENTINEL\nR[n2] = SENTINEL\ni = 0;\nj = 0;\nfor k = left to right-1\nif L[i] <= R[j]\nthen A[k] = L[i]\ni = i + 1\nelse A[k] = R[j]\nj = j + 1\n\nMerge-Sort(A, left, right){\nif left+1 < right\nthen mid = (left + right)/2;\ncall Merge-Sort(A, left, mid)\ncall Merge-Sort(A, mid, right)\ncall Merge(A, left, mid, right)\n\nInput\n\nIn the first line n is given. In the second line, n integers are given.\n\nOutput\n\nIn the first line, print the sequence S. Two consequtive elements should be separated by a space character.\n\nIn the second line, print the number of comparisons.\n\nConstraints\n\nn ≤ 500000\n\n0 ≤ an element in S ≤ 109\n\nSample Input 1\n\n10\n8 5 9 2 6 3 7 1 10 4\n\nSample Output 1\n\n1 2 3 4 5 6 7 8 9 10\n34\n\nNotes", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1202, "cpu_time_ms": 370, "memory_kb": 77828}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s843125490", "group_id": "codeNet:p02272", "input_text": "let cnt = ref 0\n\nlet merge a l m r =\n let init_ary n p =\n let ret = Array.make (n + 1) max_int in\n for i = 0 to n - 1 do\n ret.(i) <- a.(p + i)\n done;\n ret in\n let ai = init_ary (m - l) l in\n let aj = init_ary (r - m) m in\n let i = ref 0 in\n let j = ref 0 in\n for k = l to r - 1 do\n incr cnt;\n if ai.(!i) <= aj.(!j) then begin\n a.(k) <- ai.(!i);\n incr i;\n end else begin\n a.(k) <- aj.(!j);\n incr j;\n end\n done\n\nlet rec merge_sort a l r =\n if (l + 1) < r then begin\n let m = (l + r) / 2 in\n merge_sort a l m;\n merge_sort a m r;\n merge a l m r\n end\n\nlet () =\n let n = read_int () in\n let a = Array.init n (fun _ -> Scanf.scanf \"%d \" (fun i -> i)) in\n merge_sort a 0 n;\n print_int a.(0);\n for i = 1 to n - 1 do\n print_string \" \";\n print_int a.(i);\n done;\n print_newline ();\n print_int !cnt;\n print_newline ()", "language": "OCaml", "metadata": {"date": 1499844175, "filename_ext": "ml", "original_language": "OCaml", "problem_description_relpath": "problem_descriptions/p02272.html", "problem_id": "p02272", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02272/input.txt", "sample_output_relpath": "derived/input_output/data/p02272/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02272/OCaml/s843125490.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s843125490", "user_id": "u809138450"}, "prompt_components": {"gold_output": "1 2 3 4 5 6 7 8 9 10\n34\n", "input_to_evaluate": "let cnt = ref 0\n\nlet merge a l m r =\n let init_ary n p =\n let ret = Array.make (n + 1) max_int in\n for i = 0 to n - 1 do\n ret.(i) <- a.(p + i)\n done;\n ret in\n let ai = init_ary (m - l) l in\n let aj = init_ary (r - m) m in\n let i = ref 0 in\n let j = ref 0 in\n for k = l to r - 1 do\n incr cnt;\n if ai.(!i) <= aj.(!j) then begin\n a.(k) <- ai.(!i);\n incr i;\n end else begin\n a.(k) <- aj.(!j);\n incr j;\n end\n done\n\nlet rec merge_sort a l r =\n if (l + 1) < r then begin\n let m = (l + r) / 2 in\n merge_sort a l m;\n merge_sort a m r;\n merge a l m r\n end\n\nlet () =\n let n = read_int () in\n let a = Array.init n (fun _ -> Scanf.scanf \"%d \" (fun i -> i)) in\n merge_sort a 0 n;\n print_int a.(0);\n for i = 1 to n - 1 do\n print_string \" \";\n print_int a.(i);\n done;\n print_newline ();\n print_int !cnt;\n print_newline ()", "problem_context": "Merge Sort\n\nWrite a program of a Merge Sort algorithm implemented by the following pseudocode. You should also report the number of comparisons in the Merge function.\n\nMerge(A, left, mid, right)\nn1 = mid - left;\nn2 = right - mid;\ncreate array L[0...n1], R[0...n2]\nfor i = 0 to n1-1\ndo L[i] = A[left + i]\nfor i = 0 to n2-1\ndo R[i] = A[mid + i]\nL[n1] = SENTINEL\nR[n2] = SENTINEL\ni = 0;\nj = 0;\nfor k = left to right-1\nif L[i] <= R[j]\nthen A[k] = L[i]\ni = i + 1\nelse A[k] = R[j]\nj = j + 1\n\nMerge-Sort(A, left, right){\nif left+1 < right\nthen mid = (left + right)/2;\ncall Merge-Sort(A, left, mid)\ncall Merge-Sort(A, mid, right)\ncall Merge(A, left, mid, right)\n\nInput\n\nIn the first line n is given. In the second line, n integers are given.\n\nOutput\n\nIn the first line, print the sequence S. Two consequtive elements should be separated by a space character.\n\nIn the second line, print the number of comparisons.\n\nConstraints\n\nn ≤ 500000\n\n0 ≤ an element in S ≤ 109\n\nSample Input 1\n\n10\n8 5 9 2 6 3 7 1 10 4\n\nSample Output 1\n\n1 2 3 4 5 6 7 8 9 10\n34\n\nNotes", "sample_input": "10\n8 5 9 2 6 3 7 1 10 4\n"}, "reference_outputs": ["1 2 3 4 5 6 7 8 9 10\n34\n"], "source_document_id": "p02272", "source_text": "Merge Sort\n\nWrite a program of a Merge Sort algorithm implemented by the following pseudocode. You should also report the number of comparisons in the Merge function.\n\nMerge(A, left, mid, right)\nn1 = mid - left;\nn2 = right - mid;\ncreate array L[0...n1], R[0...n2]\nfor i = 0 to n1-1\ndo L[i] = A[left + i]\nfor i = 0 to n2-1\ndo R[i] = A[mid + i]\nL[n1] = SENTINEL\nR[n2] = SENTINEL\ni = 0;\nj = 0;\nfor k = left to right-1\nif L[i] <= R[j]\nthen A[k] = L[i]\ni = i + 1\nelse A[k] = R[j]\nj = j + 1\n\nMerge-Sort(A, left, right){\nif left+1 < right\nthen mid = (left + right)/2;\ncall Merge-Sort(A, left, mid)\ncall Merge-Sort(A, mid, right)\ncall Merge(A, left, mid, right)\n\nInput\n\nIn the first line n is given. In the second line, n integers are given.\n\nOutput\n\nIn the first line, print the sequence S. Two consequtive elements should be separated by a space character.\n\nIn the second line, print the number of comparisons.\n\nConstraints\n\nn ≤ 500000\n\n0 ≤ an element in S ≤ 109\n\nSample Input 1\n\n10\n8 5 9 2 6 3 7 1 10 4\n\nSample Output 1\n\n1 2 3 4 5 6 7 8 9 10\n34\n\nNotes", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 889, "cpu_time_ms": 230, "memory_kb": 21012}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s106607588", "group_id": "codeNet:p02275", "input_text": "let print_ary a =\n Array.iteri (fun i e -> Printf.printf (if i = 0 then \"%d\" else \" %d\") e) a;\n print_newline ()\n\nlet rev_iter f a =\n let rec doit i =\n if i < 0 then ()\n else (f (Array.get a i); doit (i - 1))\n in\n doit (Array.length a - 1)\n\nlet counting_sort a b k =\n let c = Array.make (k + 1) 0 in\n Array.iter (fun e -> c.(e) <- c.(e) + 1) a;\n Array.iteri (fun i _ -> if i = 0 then () else c.(i) <- c.(i) + c.(i - 1)) c;\n rev_iter (fun e -> b.(c.(e) - 1) <- e; c.(e) <- c.(e) - 1) a\n\nlet () =\n let n = read_int () in\n let a = Array.init n (fun _ -> Scanf.scanf \"%d \" (fun e -> e)) in\n let k = Array.fold_left max (-1) a in\n let b = Array.make n 0 in\n counting_sort a b k;\n print_ary b", "language": "OCaml", "metadata": {"date": 1473435135, "filename_ext": "ml", "original_language": "OCaml", "problem_description_relpath": "problem_descriptions/p02275.html", "problem_id": "p02275", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02275/input.txt", "sample_output_relpath": "derived/input_output/data/p02275/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02275/OCaml/s106607588.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s106607588", "user_id": "u809138450"}, "prompt_components": {"gold_output": "0 1 2 2 3 3 5\n", "input_to_evaluate": "let print_ary a =\n Array.iteri (fun i e -> Printf.printf (if i = 0 then \"%d\" else \" %d\") e) a;\n print_newline ()\n\nlet rev_iter f a =\n let rec doit i =\n if i < 0 then ()\n else (f (Array.get a i); doit (i - 1))\n in\n doit (Array.length a - 1)\n\nlet counting_sort a b k =\n let c = Array.make (k + 1) 0 in\n Array.iter (fun e -> c.(e) <- c.(e) + 1) a;\n Array.iteri (fun i _ -> if i = 0 then () else c.(i) <- c.(i) + c.(i - 1)) c;\n rev_iter (fun e -> b.(c.(e) - 1) <- e; c.(e) <- c.(e) - 1) a\n\nlet () =\n let n = read_int () in\n let a = Array.init n (fun _ -> Scanf.scanf \"%d \" (fun e -> e)) in\n let k = Array.fold_left max (-1) a in\n let b = Array.make n 0 in\n counting_sort a b k;\n print_ary b", "problem_context": "Counting Sort\n\nCounting sort can be used for sorting elements in an array which each of the n input elements is an integer in the range 0 to k. The idea of counting sort is to determine, for each input element x, the number of elements less than x as C[x]. This information can be used to place element x directly into its position in the output array B. This scheme must be modified to handle the situation in which several elements have the same value. Please see the following pseudocode for the detail:\n\nCounting-Sort(A, B, k)\n1 for i = 0 to k\n2 do C[i] = 0\n3 for j = 1 to length[A]\n4 do C[A[j]] = C[A[j]]+1\n5 /* C[i] now contains the number of elements equal to i */\n6 for i = 1 to k\n7 do C[i] = C[i] + C[i-1]\n8 /* C[i] now contains the number of elements less than or equal to i */\n9 for j = length[A] downto 1\n10 do B[C[A[j]]] = A[j]\n11 C[A[j]] = C[A[j]]-1\n\nWrite a program which sorts elements of given array ascending order based on the counting sort.\n\nInput\n\nThe first line of the input includes an integer n, the number of elements in the sequence.\n\nIn the second line, n elements of the sequence are given separated by spaces characters.\n\nOutput\n\nPrint the sorted sequence. Two contiguous elements of the sequence should be separated by a space character.\n\nConstraints\n\n1 ≤ n ≤ 2,000,000\n\n0 ≤ A[i] ≤ 10,000\n\nSample Input 1\n\n7\n2 5 1 3 2 3 0\n\nSample Output 1\n\n0 1 2 2 3 3 5", "sample_input": "7\n2 5 1 3 2 3 0\n"}, "reference_outputs": ["0 1 2 2 3 3 5\n"], "source_document_id": "p02275", "source_text": "Counting Sort\n\nCounting sort can be used for sorting elements in an array which each of the n input elements is an integer in the range 0 to k. The idea of counting sort is to determine, for each input element x, the number of elements less than x as C[x]. This information can be used to place element x directly into its position in the output array B. This scheme must be modified to handle the situation in which several elements have the same value. Please see the following pseudocode for the detail:\n\nCounting-Sort(A, B, k)\n1 for i = 0 to k\n2 do C[i] = 0\n3 for j = 1 to length[A]\n4 do C[A[j]] = C[A[j]]+1\n5 /* C[i] now contains the number of elements equal to i */\n6 for i = 1 to k\n7 do C[i] = C[i] + C[i-1]\n8 /* C[i] now contains the number of elements less than or equal to i */\n9 for j = length[A] downto 1\n10 do B[C[A[j]]] = A[j]\n11 C[A[j]] = C[A[j]]-1\n\nWrite a program which sorts elements of given array ascending order based on the counting sort.\n\nInput\n\nThe first line of the input includes an integer n, the number of elements in the sequence.\n\nIn the second line, n elements of the sequence are given separated by spaces characters.\n\nOutput\n\nPrint the sorted sequence. Two contiguous elements of the sequence should be separated by a space character.\n\nConstraints\n\n1 ≤ n ≤ 2,000,000\n\n0 ≤ A[i] ≤ 10,000\n\nSample Input 1\n\n7\n2 5 1 3 2 3 0\n\nSample Output 1\n\n0 1 2 2 3 3 5", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 707, "cpu_time_ms": 790, "memory_kb": 36180}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s429311545", "group_id": "codeNet:p02275", "input_text": "let () =\n let n = read_int () in\n let a = Array.init n (fun _ -> Scanf.scanf \"%d \" (fun e -> e)) in\n let b = Array.make n 0 in\n let c = Array.make (10000 + 1) 0 in\n Array.iter (fun e -> c.(e) <- c.(e) + 1) a;\n Array.iteri (fun i _ -> if i <> 0 then c.(i) <- c.(i) + c.(i-1)) c;\n for i = n - 1 downto 0 do\n b.(c.( a.(i) ) - 1) <- a.(i);\n c.( a.(i) ) <- c.( a.(i) ) - 1;\n done;\n print_int b.(0);\n for i = 1 to n - 1 do\n print_string \" \";\n print_int b.(i);\n done;\n print_newline ()", "language": "OCaml", "metadata": {"date": 1499350973, "filename_ext": "ml", "original_language": "OCaml", "problem_description_relpath": "problem_descriptions/p02275.html", "problem_id": "p02275", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02275/input.txt", "sample_output_relpath": "derived/input_output/data/p02275/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02275/OCaml/s429311545.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s429311545", "user_id": "u809138450"}, "prompt_components": {"gold_output": "0 1 2 2 3 3 5\n", "input_to_evaluate": "let () =\n let n = read_int () in\n let a = Array.init n (fun _ -> Scanf.scanf \"%d \" (fun e -> e)) in\n let b = Array.make n 0 in\n let c = Array.make (10000 + 1) 0 in\n Array.iter (fun e -> c.(e) <- c.(e) + 1) a;\n Array.iteri (fun i _ -> if i <> 0 then c.(i) <- c.(i) + c.(i-1)) c;\n for i = n - 1 downto 0 do\n b.(c.( a.(i) ) - 1) <- a.(i);\n c.( a.(i) ) <- c.( a.(i) ) - 1;\n done;\n print_int b.(0);\n for i = 1 to n - 1 do\n print_string \" \";\n print_int b.(i);\n done;\n print_newline ()", "problem_context": "Counting Sort\n\nCounting sort can be used for sorting elements in an array which each of the n input elements is an integer in the range 0 to k. The idea of counting sort is to determine, for each input element x, the number of elements less than x as C[x]. This information can be used to place element x directly into its position in the output array B. This scheme must be modified to handle the situation in which several elements have the same value. Please see the following pseudocode for the detail:\n\nCounting-Sort(A, B, k)\n1 for i = 0 to k\n2 do C[i] = 0\n3 for j = 1 to length[A]\n4 do C[A[j]] = C[A[j]]+1\n5 /* C[i] now contains the number of elements equal to i */\n6 for i = 1 to k\n7 do C[i] = C[i] + C[i-1]\n8 /* C[i] now contains the number of elements less than or equal to i */\n9 for j = length[A] downto 1\n10 do B[C[A[j]]] = A[j]\n11 C[A[j]] = C[A[j]]-1\n\nWrite a program which sorts elements of given array ascending order based on the counting sort.\n\nInput\n\nThe first line of the input includes an integer n, the number of elements in the sequence.\n\nIn the second line, n elements of the sequence are given separated by spaces characters.\n\nOutput\n\nPrint the sorted sequence. Two contiguous elements of the sequence should be separated by a space character.\n\nConstraints\n\n1 ≤ n ≤ 2,000,000\n\n0 ≤ A[i] ≤ 10,000\n\nSample Input 1\n\n7\n2 5 1 3 2 3 0\n\nSample Output 1\n\n0 1 2 2 3 3 5", "sample_input": "7\n2 5 1 3 2 3 0\n"}, "reference_outputs": ["0 1 2 2 3 3 5\n"], "source_document_id": "p02275", "source_text": "Counting Sort\n\nCounting sort can be used for sorting elements in an array which each of the n input elements is an integer in the range 0 to k. The idea of counting sort is to determine, for each input element x, the number of elements less than x as C[x]. This information can be used to place element x directly into its position in the output array B. This scheme must be modified to handle the situation in which several elements have the same value. Please see the following pseudocode for the detail:\n\nCounting-Sort(A, B, k)\n1 for i = 0 to k\n2 do C[i] = 0\n3 for j = 1 to length[A]\n4 do C[A[j]] = C[A[j]]+1\n5 /* C[i] now contains the number of elements equal to i */\n6 for i = 1 to k\n7 do C[i] = C[i] + C[i-1]\n8 /* C[i] now contains the number of elements less than or equal to i */\n9 for j = length[A] downto 1\n10 do B[C[A[j]]] = A[j]\n11 C[A[j]] = C[A[j]]-1\n\nWrite a program which sorts elements of given array ascending order based on the counting sort.\n\nInput\n\nThe first line of the input includes an integer n, the number of elements in the sequence.\n\nIn the second line, n elements of the sequence are given separated by spaces characters.\n\nOutput\n\nPrint the sorted sequence. Two contiguous elements of the sequence should be separated by a space character.\n\nConstraints\n\n1 ≤ n ≤ 2,000,000\n\n0 ≤ A[i] ≤ 10,000\n\nSample Input 1\n\n7\n2 5 1 3 2 3 0\n\nSample Output 1\n\n0 1 2 2 3 3 5", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 502, "cpu_time_ms": 520, "memory_kb": 36148}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s744008665", "group_id": "codeNet:p02275", "input_text": "let counting_sort a b k n =\n let c = Array.make (k + 1) 0 in\n Array.iter (fun e -> c.(e) <- c.(e) + 1) a;\n for i = 1 to k do\n c.(i) <- c.(i) + c.(i-1)\n done;\n for i = n - 1 downto 0 do\n b.(c.( a.(i) ) - 1) <- a.(i);\n c.( a.(i) ) <- c.( a.(i) ) - 1;\n done\n\nlet () =\n let n = read_int () in\n let a = Array.init n (fun _ -> Scanf.scanf \"%d \" (fun e -> e)) in\n let b = Array.make n 0 in\n counting_sort a b 10000 n;\n print_int b.(0);\n for i = 1 to n - 1 do\n print_string \" \"; print_int b.(i);\n done;\n print_newline ()", "language": "OCaml", "metadata": {"date": 1499848464, "filename_ext": "ml", "original_language": "OCaml", "problem_description_relpath": "problem_descriptions/p02275.html", "problem_id": "p02275", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02275/input.txt", "sample_output_relpath": "derived/input_output/data/p02275/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02275/OCaml/s744008665.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s744008665", "user_id": "u809138450"}, "prompt_components": {"gold_output": "0 1 2 2 3 3 5\n", "input_to_evaluate": "let counting_sort a b k n =\n let c = Array.make (k + 1) 0 in\n Array.iter (fun e -> c.(e) <- c.(e) + 1) a;\n for i = 1 to k do\n c.(i) <- c.(i) + c.(i-1)\n done;\n for i = n - 1 downto 0 do\n b.(c.( a.(i) ) - 1) <- a.(i);\n c.( a.(i) ) <- c.( a.(i) ) - 1;\n done\n\nlet () =\n let n = read_int () in\n let a = Array.init n (fun _ -> Scanf.scanf \"%d \" (fun e -> e)) in\n let b = Array.make n 0 in\n counting_sort a b 10000 n;\n print_int b.(0);\n for i = 1 to n - 1 do\n print_string \" \"; print_int b.(i);\n done;\n print_newline ()", "problem_context": "Counting Sort\n\nCounting sort can be used for sorting elements in an array which each of the n input elements is an integer in the range 0 to k. The idea of counting sort is to determine, for each input element x, the number of elements less than x as C[x]. This information can be used to place element x directly into its position in the output array B. This scheme must be modified to handle the situation in which several elements have the same value. Please see the following pseudocode for the detail:\n\nCounting-Sort(A, B, k)\n1 for i = 0 to k\n2 do C[i] = 0\n3 for j = 1 to length[A]\n4 do C[A[j]] = C[A[j]]+1\n5 /* C[i] now contains the number of elements equal to i */\n6 for i = 1 to k\n7 do C[i] = C[i] + C[i-1]\n8 /* C[i] now contains the number of elements less than or equal to i */\n9 for j = length[A] downto 1\n10 do B[C[A[j]]] = A[j]\n11 C[A[j]] = C[A[j]]-1\n\nWrite a program which sorts elements of given array ascending order based on the counting sort.\n\nInput\n\nThe first line of the input includes an integer n, the number of elements in the sequence.\n\nIn the second line, n elements of the sequence are given separated by spaces characters.\n\nOutput\n\nPrint the sorted sequence. Two contiguous elements of the sequence should be separated by a space character.\n\nConstraints\n\n1 ≤ n ≤ 2,000,000\n\n0 ≤ A[i] ≤ 10,000\n\nSample Input 1\n\n7\n2 5 1 3 2 3 0\n\nSample Output 1\n\n0 1 2 2 3 3 5", "sample_input": "7\n2 5 1 3 2 3 0\n"}, "reference_outputs": ["0 1 2 2 3 3 5\n"], "source_document_id": "p02275", "source_text": "Counting Sort\n\nCounting sort can be used for sorting elements in an array which each of the n input elements is an integer in the range 0 to k. The idea of counting sort is to determine, for each input element x, the number of elements less than x as C[x]. This information can be used to place element x directly into its position in the output array B. This scheme must be modified to handle the situation in which several elements have the same value. Please see the following pseudocode for the detail:\n\nCounting-Sort(A, B, k)\n1 for i = 0 to k\n2 do C[i] = 0\n3 for j = 1 to length[A]\n4 do C[A[j]] = C[A[j]]+1\n5 /* C[i] now contains the number of elements equal to i */\n6 for i = 1 to k\n7 do C[i] = C[i] + C[i-1]\n8 /* C[i] now contains the number of elements less than or equal to i */\n9 for j = length[A] downto 1\n10 do B[C[A[j]]] = A[j]\n11 C[A[j]] = C[A[j]]-1\n\nWrite a program which sorts elements of given array ascending order based on the counting sort.\n\nInput\n\nThe first line of the input includes an integer n, the number of elements in the sequence.\n\nIn the second line, n elements of the sequence are given separated by spaces characters.\n\nOutput\n\nPrint the sorted sequence. Two contiguous elements of the sequence should be separated by a space character.\n\nConstraints\n\n1 ≤ n ≤ 2,000,000\n\n0 ≤ A[i] ≤ 10,000\n\nSample Input 1\n\n7\n2 5 1 3 2 3 0\n\nSample Output 1\n\n0 1 2 2 3 3 5", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 510, "memory_kb": 36156}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s781872211", "group_id": "codeNet:p02276", "input_text": "let partition (a : int array) p r =\n let x = a.(r) in\n let swap i j = let t = a.(i) in a.(i) <- a.(j); a.(j) <- t\n in\n let rec doit i j =\n if j >= r then i\n else begin\n if a.(j) <= x then (swap (i + 1) j; doit (i + 1) (j + 1))\n else doit i (j + 1)\n end\n in\n let i = doit (p - 1) p in\n swap (i + 1) r;\n i + 1\n\nlet () =\n let n = read_int () in\n let a = Array.init n (fun _ -> Scanf.scanf \"%d \" (fun i -> i)) in\n let k = partition a 0 (n - 1) in\n Array.iteri (fun i e ->\n Printf.printf (if i = 0 then \"%d\" else if i = k then \" [%d]\" else \" %d\") e) a;\n print_newline ()", "language": "OCaml", "metadata": {"date": 1474610955, "filename_ext": "ml", "original_language": "OCaml", "problem_description_relpath": "problem_descriptions/p02276.html", "problem_id": "p02276", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02276/input.txt", "sample_output_relpath": "derived/input_output/data/p02276/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02276/OCaml/s781872211.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s781872211", "user_id": "u809138450"}, "prompt_components": {"gold_output": "9 5 8 7 4 2 6 [11] 21 13 19 12\n", "input_to_evaluate": "let partition (a : int array) p r =\n let x = a.(r) in\n let swap i j = let t = a.(i) in a.(i) <- a.(j); a.(j) <- t\n in\n let rec doit i j =\n if j >= r then i\n else begin\n if a.(j) <= x then (swap (i + 1) j; doit (i + 1) (j + 1))\n else doit i (j + 1)\n end\n in\n let i = doit (p - 1) p in\n swap (i + 1) r;\n i + 1\n\nlet () =\n let n = read_int () in\n let a = Array.init n (fun _ -> Scanf.scanf \"%d \" (fun i -> i)) in\n let k = partition a 0 (n - 1) in\n Array.iteri (fun i e ->\n Printf.printf (if i = 0 then \"%d\" else if i = k then \" [%d]\" else \" %d\") e) a;\n print_newline ()", "problem_context": "Partition\n\nQuick sort is based on the Divide-and-conquer approach. In QuickSort(A, p, r), first, a procedure Partition(A, p, r) divides an array A[p..r] into two subarrays A[p..q-1] and A[q+1..r] such that each element of A[p..q-1] is less than or equal to A[q], which is, inturn, less than or equal to each element of A[q+1..r]. It also computes the index q.\n\nIn the conquer processes, the two subarrays A[p..q-1] and A[q+1..r] are sorted by recursive calls of QuickSort(A, p, q-1) and QuickSort(A, q+1, r).\n\nYour task is to read a sequence A and perform the Partition based on the following pseudocode:\n\nPartition(A, p, r)\n1 x = A[r]\n2 i = p-1\n3 for j = p to r-1\n4 do if A[j] <= x\n5 then i = i+1\n6 exchange A[i] and A[j]\n7 exchange A[i+1] and A[r]\n8 return i+1\n\nNote that, in this algorithm, Partition always selects an element A[r] as a pivot element around which to partition the array A[p..r].\n\nInput\n\nThe first line of the input includes an integer n, the number of elements in the sequence A.\n\nIn the second line, Ai (i = 1,2,...,n), elements of the sequence are given separated by space characters.\n\nOutput\n\nPrint the sorted sequence. Two contiguous elements of the sequence should be separated by a space character. The element which is selected as the pivot of the partition should be indicated by [  ].\n\nConstraints\n\n1 ≤ n ≤ 100,000\n\n0 ≤ Ai ≤ 100,000\n\nSample Input 1\n\n12\n13 19 9 5 12 8 7 4 21 2 6 11\n\nSample Output 1\n\n9 5 8 7 4 2 6 [11] 21 13 19 12", "sample_input": "12\n13 19 9 5 12 8 7 4 21 2 6 11\n"}, "reference_outputs": ["9 5 8 7 4 2 6 [11] 21 13 19 12\n"], "source_document_id": "p02276", "source_text": "Partition\n\nQuick sort is based on the Divide-and-conquer approach. In QuickSort(A, p, r), first, a procedure Partition(A, p, r) divides an array A[p..r] into two subarrays A[p..q-1] and A[q+1..r] such that each element of A[p..q-1] is less than or equal to A[q], which is, inturn, less than or equal to each element of A[q+1..r]. It also computes the index q.\n\nIn the conquer processes, the two subarrays A[p..q-1] and A[q+1..r] are sorted by recursive calls of QuickSort(A, p, q-1) and QuickSort(A, q+1, r).\n\nYour task is to read a sequence A and perform the Partition based on the following pseudocode:\n\nPartition(A, p, r)\n1 x = A[r]\n2 i = p-1\n3 for j = p to r-1\n4 do if A[j] <= x\n5 then i = i+1\n6 exchange A[i] and A[j]\n7 exchange A[i+1] and A[r]\n8 return i+1\n\nNote that, in this algorithm, Partition always selects an element A[r] as a pivot element around which to partition the array A[p..r].\n\nInput\n\nThe first line of the input includes an integer n, the number of elements in the sequence A.\n\nIn the second line, Ai (i = 1,2,...,n), elements of the sequence are given separated by space characters.\n\nOutput\n\nPrint the sorted sequence. Two contiguous elements of the sequence should be separated by a space character. The element which is selected as the pivot of the partition should be indicated by [  ].\n\nConstraints\n\n1 ≤ n ≤ 100,000\n\n0 ≤ Ai ≤ 100,000\n\nSample Input 1\n\n12\n13 19 9 5 12 8 7 4 21 2 6 11\n\nSample Output 1\n\n9 5 8 7 4 2 6 [11] 21 13 19 12", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 600, "cpu_time_ms": 30, "memory_kb": 5440}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s753135629", "group_id": "codeNet:p02277", "input_text": "open Printf\nopen Scanf\n\ntype card = {suit : string; value : int}\n \nlet id x = x\n\nlet partition cmp a p r =\n let swap i j =\n let t = a.(i) in\n a.(i) <- a.(j);\n a.(j) <- t in\n let x = a.(r) in\n let rec iter i j =\n if j = r then begin swap (i+1) r; i+1 end\n else if cmp a.(j) x <= 0 then\n let ii = i+1 in\n swap ii j;\n iter ii (j+1)\n else iter i (j+1) in\n iter (p-1) p\n\nlet rec quick_sort cmp a p r =\n if p >= r then ()\n else let q = partition cmp a p r in\n quick_sort cmp a p (q-1);\n quick_sort cmp a (q+1) r\n \nlet () =\n let n = scanf \"%d\\n\" id in\n let ar = Array.init n (fun _ -> scanf \"%s %d\\n\" (fun x y -> {suit = x; value = y})) in\n let ar2 = Array.copy ar in\n quick_sort (fun x y -> compare x.value y.value) ar 0 (n-1);\n Array.stable_sort (fun x y -> compare x.value y.value) ar2;\n printf \"%s\\n\" (if ar = ar2 then \"Stable\" else \"Not stable\");\n Array.iter (fun x -> printf \"%s %d\\n\" x.suit x.value) ar", "language": "OCaml", "metadata": {"date": 1500004348, "filename_ext": "ml", "original_language": "OCaml", "problem_description_relpath": "problem_descriptions/p02277.html", "problem_id": "p02277", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02277/input.txt", "sample_output_relpath": "derived/input_output/data/p02277/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02277/OCaml/s753135629.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s753135629", "user_id": "u049242937"}, "prompt_components": {"gold_output": "Not stable\nD 1\nC 1\nD 2\nH 2\nD 3\nS 3\n", "input_to_evaluate": "open Printf\nopen Scanf\n\ntype card = {suit : string; value : int}\n \nlet id x = x\n\nlet partition cmp a p r =\n let swap i j =\n let t = a.(i) in\n a.(i) <- a.(j);\n a.(j) <- t in\n let x = a.(r) in\n let rec iter i j =\n if j = r then begin swap (i+1) r; i+1 end\n else if cmp a.(j) x <= 0 then\n let ii = i+1 in\n swap ii j;\n iter ii (j+1)\n else iter i (j+1) in\n iter (p-1) p\n\nlet rec quick_sort cmp a p r =\n if p >= r then ()\n else let q = partition cmp a p r in\n quick_sort cmp a p (q-1);\n quick_sort cmp a (q+1) r\n \nlet () =\n let n = scanf \"%d\\n\" id in\n let ar = Array.init n (fun _ -> scanf \"%s %d\\n\" (fun x y -> {suit = x; value = y})) in\n let ar2 = Array.copy ar in\n quick_sort (fun x y -> compare x.value y.value) ar 0 (n-1);\n Array.stable_sort (fun x y -> compare x.value y.value) ar2;\n printf \"%s\\n\" (if ar = ar2 then \"Stable\" else \"Not stable\");\n Array.iter (fun x -> printf \"%s %d\\n\" x.suit x.value) ar", "problem_context": "Quick Sort\n\nLet's arrange a deck of cards. Your task is to sort totally n cards. A card consists of a part of a suit (S, H, C or D) and an number. Write a program which sorts such cards based on the following pseudocode:\n\nPartition(A, p, r)\n1 x = A[r]\n2 i = p-1\n3 for j = p to r-1\n4 do if A[j] <= x\n5 then i = i+1\n6 exchange A[i] and A[j]\n7 exchange A[i+1] and A[r]\n8 return i+1\n\nQuicksort(A, p, r)\n1 if p < r\n2 then q = Partition(A, p, r)\n3 run Quicksort(A, p, q-1)\n4 run Quicksort(A, q+1, r)\n\nHere, A is an array which represents a deck of cards and comparison operations are performed based on the numbers.\n\nYour program should also report the stability of the output for the given input (instance). Here, 'stability of the output' means that: cards with the same value appear in the output in the same order as they do in the input (instance).\n\nInput\n\nThe first line contains an integer n, the number of cards.\n\nn cards are given in the following lines. Each card is given in a line and represented by a pair of a character and an integer separated by a single space.\n\nOutput\n\nIn the first line, print the stability (\"Stable\" or \"Not stable\") of this output.\n\nIn the following lines, print the arranged cards in the same manner of that of the input.\n\nConstraints\n\n1 ≤ n ≤ 100,000\n\n1 ≤ the number of a card ≤ 109\n\nThere are no identical card in the input\n\nSample Input 1\n\n6\nD 3\nH 2\nD 1\nS 3\nD 2\nC 1\n\nSample Output 1\n\nNot stable\nD 1\nC 1\nD 2\nH 2\nD 3\nS 3\n\nSample Input 2\n\n2\nS 1\nH 1\n\nSample Output 2\n\nStable\nS 1\nH 1", "sample_input": "6\nD 3\nH 2\nD 1\nS 3\nD 2\nC 1\n"}, "reference_outputs": ["Not stable\nD 1\nC 1\nD 2\nH 2\nD 3\nS 3\n"], "source_document_id": "p02277", "source_text": "Quick Sort\n\nLet's arrange a deck of cards. Your task is to sort totally n cards. A card consists of a part of a suit (S, H, C or D) and an number. Write a program which sorts such cards based on the following pseudocode:\n\nPartition(A, p, r)\n1 x = A[r]\n2 i = p-1\n3 for j = p to r-1\n4 do if A[j] <= x\n5 then i = i+1\n6 exchange A[i] and A[j]\n7 exchange A[i+1] and A[r]\n8 return i+1\n\nQuicksort(A, p, r)\n1 if p < r\n2 then q = Partition(A, p, r)\n3 run Quicksort(A, p, q-1)\n4 run Quicksort(A, q+1, r)\n\nHere, A is an array which represents a deck of cards and comparison operations are performed based on the numbers.\n\nYour program should also report the stability of the output for the given input (instance). Here, 'stability of the output' means that: cards with the same value appear in the output in the same order as they do in the input (instance).\n\nInput\n\nThe first line contains an integer n, the number of cards.\n\nn cards are given in the following lines. Each card is given in a line and represented by a pair of a character and an integer separated by a single space.\n\nOutput\n\nIn the first line, print the stability (\"Stable\" or \"Not stable\") of this output.\n\nIn the following lines, print the arranged cards in the same manner of that of the input.\n\nConstraints\n\n1 ≤ n ≤ 100,000\n\n1 ≤ the number of a card ≤ 109\n\nThere are no identical card in the input\n\nSample Input 1\n\n6\nD 3\nH 2\nD 1\nS 3\nD 2\nC 1\n\nSample Output 1\n\nNot stable\nD 1\nC 1\nD 2\nH 2\nD 3\nS 3\n\nSample Input 2\n\n2\nS 1\nH 1\n\nSample Output 2\n\nStable\nS 1\nH 1", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 990, "cpu_time_ms": 100, "memory_kb": 11084}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s795682693", "group_id": "codeNet:p02279", "input_text": "let nil = -1\n\ntype tree = { mutable parent : int; mutable child : int; mutable bro : int; mutable depth : int }\n\nlet make () = { parent = nil; child = nil; bro = nil; depth = nil }\n\nlet set_depth t n =\n let rec root i =\n if i = n then nil\n else if t.(i).parent = nil then i\n else root (i + 1) in\n let rec doit i d =\n t.(i).depth <- d;\n if t.(i).bro <> nil then doit t.(i).bro d;\n if t.(i).child <> nil then doit t.(i).child (d + 1) in\n doit (root 0) 0\n\nlet print_tree t =\n t |> Array.iteri (fun i _ ->\n print_string \"node \"; print_int i;\n print_string \": parent = \"; print_int t.(i).parent;\n print_string \", depth = \"; print_int t.(i).depth;\n print_string (if t.(i).parent = nil then \", root, [\" else if t.(i).child = nil then \", leaf, [\" else \", internal node, [\");\n let rec print_children c =\n if c <> nil then begin\n if c <> t.(i).child then print_string \", \";\n print_int c;\n print_children t.(c).bro\n end in\n print_children t.(i).child;\n print_string \"]\\n\")\n\nlet () =\n let n = Scanf.scanf \"%d \" (fun i -> i) in\n let t = Array.init n (fun _ -> make ()) in\n for _ = 0 to n - 1 do\n let (id, k) = Scanf.scanf \"%d %d \" (fun id k -> (id, k)) in\n let left_child = ref 0 in\n for i = 0 to k - 1 do\n let c = Scanf.scanf \"%d \" (fun i -> i) in\n t.(c).parent <- id;\n if i = 0 then t.(id).child <- c else t.(!left_child).bro <- c;\n left_child := c;\n done;\n done;\n set_depth t n;\n print_tree t", "language": "OCaml", "metadata": {"date": 1499917985, "filename_ext": "ml", "original_language": "OCaml", "problem_description_relpath": "problem_descriptions/p02279.html", "problem_id": "p02279", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02279/input.txt", "sample_output_relpath": "derived/input_output/data/p02279/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02279/OCaml/s795682693.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s795682693", "user_id": "u809138450"}, "prompt_components": {"gold_output": "node 0: parent = -1, depth = 0, root, [1, 4, 10]\nnode 1: parent = 0, depth = 1, internal node, [2, 3]\nnode 2: parent = 1, depth = 2, leaf, []\nnode 3: parent = 1, depth = 2, leaf, []\nnode 4: parent = 0, depth = 1, internal node, [5, 6, 7]\nnode 5: parent = 4, depth = 2, leaf, []\nnode 6: parent = 4, depth = 2, leaf, []\nnode 7: parent = 4, depth = 2, internal node, [8, 9]\nnode 8: parent = 7, depth = 3, leaf, []\nnode 9: parent = 7, depth = 3, leaf, []\nnode 10: parent = 0, depth = 1, internal node, [11, 12]\nnode 11: parent = 10, depth = 2, leaf, []\nnode 12: parent = 10, depth = 2, leaf, []\n", "input_to_evaluate": "let nil = -1\n\ntype tree = { mutable parent : int; mutable child : int; mutable bro : int; mutable depth : int }\n\nlet make () = { parent = nil; child = nil; bro = nil; depth = nil }\n\nlet set_depth t n =\n let rec root i =\n if i = n then nil\n else if t.(i).parent = nil then i\n else root (i + 1) in\n let rec doit i d =\n t.(i).depth <- d;\n if t.(i).bro <> nil then doit t.(i).bro d;\n if t.(i).child <> nil then doit t.(i).child (d + 1) in\n doit (root 0) 0\n\nlet print_tree t =\n t |> Array.iteri (fun i _ ->\n print_string \"node \"; print_int i;\n print_string \": parent = \"; print_int t.(i).parent;\n print_string \", depth = \"; print_int t.(i).depth;\n print_string (if t.(i).parent = nil then \", root, [\" else if t.(i).child = nil then \", leaf, [\" else \", internal node, [\");\n let rec print_children c =\n if c <> nil then begin\n if c <> t.(i).child then print_string \", \";\n print_int c;\n print_children t.(c).bro\n end in\n print_children t.(i).child;\n print_string \"]\\n\")\n\nlet () =\n let n = Scanf.scanf \"%d \" (fun i -> i) in\n let t = Array.init n (fun _ -> make ()) in\n for _ = 0 to n - 1 do\n let (id, k) = Scanf.scanf \"%d %d \" (fun id k -> (id, k)) in\n let left_child = ref 0 in\n for i = 0 to k - 1 do\n let c = Scanf.scanf \"%d \" (fun i -> i) in\n t.(c).parent <- id;\n if i = 0 then t.(id).child <- c else t.(!left_child).bro <- c;\n left_child := c;\n done;\n done;\n set_depth t n;\n print_tree t", "problem_context": "Rooted Trees\n\nA graph G = (V, E) is a data structure where V is a finite set of vertices and E is a binary relation on V represented by a set of edges. Fig. 1 illustrates an example of a graph (or graphs).\n\nFig. 1\n\nA free tree is a connnected, acyclic, undirected graph. A rooted tree is a free tree in which one of the vertices is distinguished from the others. A vertex of a rooted tree is called \"node.\"\n\nYour task is to write a program which reports the following information for each node u of a given rooted tree T:\n\nnode ID of u\n\nparent of u\n\ndepth of u\n\nnode type (root, internal node or leaf)\n\na list of chidlren of u\n\nIf the last edge on the path from the root r of a tree T to a node x is (p, x), then p is the parent of x, and x is a child of p. The root is the only node in T with no parent.\n\nA node with no children is an external node or leaf. A nonleaf node is an internal node\n\nThe number of children of a node x in a rooted tree T is called the degree of x.\n\nThe length of the path from the root r to a node x is the depth of x in T.\n\nHere, the given tree consists of n nodes and evey node has a unique ID from 0 to n-1.\n\nFig. 2 shows an example of rooted trees where ID of each node is indicated by a number in a circle (node). The example corresponds to the first sample input.\n\nFig. 2\n\nInput\n\nThe first line of the input includes an integer n, the number of nodes of the tree.\n\nIn the next n lines, the information of each node u is given in the following format:\n\nid k c1 c2 ... ck\n\nwhere id is the node ID of u, k is the degree of u, c1 ... ck are node IDs of 1st, ... kth child of u. If the node does not have a child, the k is 0.\n\nOutput\n\nPrint the information of each node in the following format ordered by IDs:\n\nnode id: parent = p, depth = d, type, [c1...ck]\n\np is ID of its parent. If the node does not have a parent, print -1.\n\nd is depth of the node.\n\ntype is a type of nodes represented by a string (root, internal node or leaf). If the root can be considered as a leaf or an internal node, print root.\n\nc1...ck is the list of children as a ordered tree.\n\nPlease follow the format presented in a sample output below.\n\nConstraints\n\n1 ≤ n ≤ 100000\n\nSample Input 1\n\n13\n0 3 1 4 10\n1 2 2 3\n2 0\n3 0\n4 3 5 6 7\n5 0\n6 0\n7 2 8 9\n8 0\n9 0\n10 2 11 12\n11 0\n12 0\n\nSample Output 1\n\nnode 0: parent = -1, depth = 0, root, [1, 4, 10]\nnode 1: parent = 0, depth = 1, internal node, [2, 3]\nnode 2: parent = 1, depth = 2, leaf, []\nnode 3: parent = 1, depth = 2, leaf, []\nnode 4: parent = 0, depth = 1, internal node, [5, 6, 7]\nnode 5: parent = 4, depth = 2, leaf, []\nnode 6: parent = 4, depth = 2, leaf, []\nnode 7: parent = 4, depth = 2, internal node, [8, 9]\nnode 8: parent = 7, depth = 3, leaf, []\nnode 9: parent = 7, depth = 3, leaf, []\nnode 10: parent = 0, depth = 1, internal node, [11, 12]\nnode 11: parent = 10, depth = 2, leaf, []\nnode 12: parent = 10, depth = 2, leaf, []\n\nSample Input 2\n\n4\n1 3 3 2 0\n0 0\n3 0\n2 0\n\nSample Output 2\n\nnode 0: parent = 1, depth = 1, leaf, []\nnode 1: parent = -1, depth = 0, root, [3, 2, 0]\nnode 2: parent = 1, depth = 1, leaf, []\nnode 3: parent = 1, depth = 1, leaf, []\n\nNote\n\nYou can use a left-child, right-sibling representation to implement a tree which has the following data:\n\nthe parent of u\n\nthe leftmost child of u\n\nthe immediate right sibling of u\n\nReference\n\nIntroduction to Algorithms, Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Clifford Stein. The MIT Press.", "sample_input": "13\n0 3 1 4 10\n1 2 2 3\n2 0\n3 0\n4 3 5 6 7\n5 0\n6 0\n7 2 8 9\n8 0\n9 0\n10 2 11 12\n11 0\n12 0\n"}, "reference_outputs": ["node 0: parent = -1, depth = 0, root, [1, 4, 10]\nnode 1: parent = 0, depth = 1, internal node, [2, 3]\nnode 2: parent = 1, depth = 2, leaf, []\nnode 3: parent = 1, depth = 2, leaf, []\nnode 4: parent = 0, depth = 1, internal node, [5, 6, 7]\nnode 5: parent = 4, depth = 2, leaf, []\nnode 6: parent = 4, depth = 2, leaf, []\nnode 7: parent = 4, depth = 2, internal node, [8, 9]\nnode 8: parent = 7, depth = 3, leaf, []\nnode 9: parent = 7, depth = 3, leaf, []\nnode 10: parent = 0, depth = 1, internal node, [11, 12]\nnode 11: parent = 10, depth = 2, leaf, []\nnode 12: parent = 10, depth = 2, leaf, []\n"], "source_document_id": "p02279", "source_text": "Rooted Trees\n\nA graph G = (V, E) is a data structure where V is a finite set of vertices and E is a binary relation on V represented by a set of edges. Fig. 1 illustrates an example of a graph (or graphs).\n\nFig. 1\n\nA free tree is a connnected, acyclic, undirected graph. A rooted tree is a free tree in which one of the vertices is distinguished from the others. A vertex of a rooted tree is called \"node.\"\n\nYour task is to write a program which reports the following information for each node u of a given rooted tree T:\n\nnode ID of u\n\nparent of u\n\ndepth of u\n\nnode type (root, internal node or leaf)\n\na list of chidlren of u\n\nIf the last edge on the path from the root r of a tree T to a node x is (p, x), then p is the parent of x, and x is a child of p. The root is the only node in T with no parent.\n\nA node with no children is an external node or leaf. A nonleaf node is an internal node\n\nThe number of children of a node x in a rooted tree T is called the degree of x.\n\nThe length of the path from the root r to a node x is the depth of x in T.\n\nHere, the given tree consists of n nodes and evey node has a unique ID from 0 to n-1.\n\nFig. 2 shows an example of rooted trees where ID of each node is indicated by a number in a circle (node). The example corresponds to the first sample input.\n\nFig. 2\n\nInput\n\nThe first line of the input includes an integer n, the number of nodes of the tree.\n\nIn the next n lines, the information of each node u is given in the following format:\n\nid k c1 c2 ... ck\n\nwhere id is the node ID of u, k is the degree of u, c1 ... ck are node IDs of 1st, ... kth child of u. If the node does not have a child, the k is 0.\n\nOutput\n\nPrint the information of each node in the following format ordered by IDs:\n\nnode id: parent = p, depth = d, type, [c1...ck]\n\np is ID of its parent. If the node does not have a parent, print -1.\n\nd is depth of the node.\n\ntype is a type of nodes represented by a string (root, internal node or leaf). If the root can be considered as a leaf or an internal node, print root.\n\nc1...ck is the list of children as a ordered tree.\n\nPlease follow the format presented in a sample output below.\n\nConstraints\n\n1 ≤ n ≤ 100000\n\nSample Input 1\n\n13\n0 3 1 4 10\n1 2 2 3\n2 0\n3 0\n4 3 5 6 7\n5 0\n6 0\n7 2 8 9\n8 0\n9 0\n10 2 11 12\n11 0\n12 0\n\nSample Output 1\n\nnode 0: parent = -1, depth = 0, root, [1, 4, 10]\nnode 1: parent = 0, depth = 1, internal node, [2, 3]\nnode 2: parent = 1, depth = 2, leaf, []\nnode 3: parent = 1, depth = 2, leaf, []\nnode 4: parent = 0, depth = 1, internal node, [5, 6, 7]\nnode 5: parent = 4, depth = 2, leaf, []\nnode 6: parent = 4, depth = 2, leaf, []\nnode 7: parent = 4, depth = 2, internal node, [8, 9]\nnode 8: parent = 7, depth = 3, leaf, []\nnode 9: parent = 7, depth = 3, leaf, []\nnode 10: parent = 0, depth = 1, internal node, [11, 12]\nnode 11: parent = 10, depth = 2, leaf, []\nnode 12: parent = 10, depth = 2, leaf, []\n\nSample Input 2\n\n4\n1 3 3 2 0\n0 0\n3 0\n2 0\n\nSample Output 2\n\nnode 0: parent = 1, depth = 1, leaf, []\nnode 1: parent = -1, depth = 0, root, [3, 2, 0]\nnode 2: parent = 1, depth = 1, leaf, []\nnode 3: parent = 1, depth = 1, leaf, []\n\nNote\n\nYou can use a left-child, right-sibling representation to implement a tree which has the following data:\n\nthe parent of u\n\nthe leftmost child of u\n\nthe immediate right sibling of u\n\nReference\n\nIntroduction to Algorithms, Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Clifford Stein. The MIT Press.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1494, "cpu_time_ms": 80, "memory_kb": 13212}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s420919457", "group_id": "codeNet:p02279", "input_text": "let nil = -1\n\ntype tree = { mutable parent : int; mutable child : int; mutable bro : int; mutable depth : int }\n\nlet make () = { parent = nil; child = nil; bro = nil; depth = nil }\n\nlet set_depth t n =\n let rec root i =\n if i = n then nil\n else if t.(i).parent = nil then i\n else root (i + 1) in\n let rec doit i d =\n t.(i).depth <- d;\n if t.(i).bro <> nil then doit t.(i).bro d;\n if t.(i).child <> nil then doit t.(i).child (d + 1) in\n doit (root 0) 0\n\nlet print_tree t =\n let rec string_of_children i c acc =\n if c = nil then acc\n else string_of_children i t.(c).bro (acc ^ (if c <> t.(i).child then \", \" else \"\") ^ string_of_int c) in\n let string_of_children i c = string_of_children i c \"\" in\n t |> Array.iteri (fun i _ ->\n \"node \" ^ string_of_int i ^ \": parent = \" ^ string_of_int t.(i).parent\n ^ \", depth = \" ^ string_of_int t.(i).depth\n ^ (if t.(i).parent = nil then \", root, [\"\n else if t.(i).child = nil then \", leaf, [\"\n else \", internal node, [\")\n ^ string_of_children i t.(i).child\n ^ \"]\\n\"\n |> print_string)\n\nlet () =\n let n = Scanf.scanf \"%d \" (fun i -> i) in\n let t = Array.init n (fun _ -> make ()) in\n for _ = 0 to n - 1 do\n let (id, k) = Scanf.scanf \"%d %d \" (fun id k -> (id, k)) in\n let left_child = ref 0 in\n for i = 0 to k - 1 do\n let c = Scanf.scanf \"%d \" (fun i -> i) in\n t.(c).parent <- id;\n if i = 0 then t.(id).child <- c\n else t.(!left_child).bro <- c;\n left_child := c;\n done;\n done;\n set_depth t n;\n print_tree t", "language": "OCaml", "metadata": {"date": 1499928964, "filename_ext": "ml", "original_language": "OCaml", "problem_description_relpath": "problem_descriptions/p02279.html", "problem_id": "p02279", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02279/input.txt", "sample_output_relpath": "derived/input_output/data/p02279/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02279/OCaml/s420919457.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s420919457", "user_id": "u809138450"}, "prompt_components": {"gold_output": "node 0: parent = -1, depth = 0, root, [1, 4, 10]\nnode 1: parent = 0, depth = 1, internal node, [2, 3]\nnode 2: parent = 1, depth = 2, leaf, []\nnode 3: parent = 1, depth = 2, leaf, []\nnode 4: parent = 0, depth = 1, internal node, [5, 6, 7]\nnode 5: parent = 4, depth = 2, leaf, []\nnode 6: parent = 4, depth = 2, leaf, []\nnode 7: parent = 4, depth = 2, internal node, [8, 9]\nnode 8: parent = 7, depth = 3, leaf, []\nnode 9: parent = 7, depth = 3, leaf, []\nnode 10: parent = 0, depth = 1, internal node, [11, 12]\nnode 11: parent = 10, depth = 2, leaf, []\nnode 12: parent = 10, depth = 2, leaf, []\n", "input_to_evaluate": "let nil = -1\n\ntype tree = { mutable parent : int; mutable child : int; mutable bro : int; mutable depth : int }\n\nlet make () = { parent = nil; child = nil; bro = nil; depth = nil }\n\nlet set_depth t n =\n let rec root i =\n if i = n then nil\n else if t.(i).parent = nil then i\n else root (i + 1) in\n let rec doit i d =\n t.(i).depth <- d;\n if t.(i).bro <> nil then doit t.(i).bro d;\n if t.(i).child <> nil then doit t.(i).child (d + 1) in\n doit (root 0) 0\n\nlet print_tree t =\n let rec string_of_children i c acc =\n if c = nil then acc\n else string_of_children i t.(c).bro (acc ^ (if c <> t.(i).child then \", \" else \"\") ^ string_of_int c) in\n let string_of_children i c = string_of_children i c \"\" in\n t |> Array.iteri (fun i _ ->\n \"node \" ^ string_of_int i ^ \": parent = \" ^ string_of_int t.(i).parent\n ^ \", depth = \" ^ string_of_int t.(i).depth\n ^ (if t.(i).parent = nil then \", root, [\"\n else if t.(i).child = nil then \", leaf, [\"\n else \", internal node, [\")\n ^ string_of_children i t.(i).child\n ^ \"]\\n\"\n |> print_string)\n\nlet () =\n let n = Scanf.scanf \"%d \" (fun i -> i) in\n let t = Array.init n (fun _ -> make ()) in\n for _ = 0 to n - 1 do\n let (id, k) = Scanf.scanf \"%d %d \" (fun id k -> (id, k)) in\n let left_child = ref 0 in\n for i = 0 to k - 1 do\n let c = Scanf.scanf \"%d \" (fun i -> i) in\n t.(c).parent <- id;\n if i = 0 then t.(id).child <- c\n else t.(!left_child).bro <- c;\n left_child := c;\n done;\n done;\n set_depth t n;\n print_tree t", "problem_context": "Rooted Trees\n\nA graph G = (V, E) is a data structure where V is a finite set of vertices and E is a binary relation on V represented by a set of edges. Fig. 1 illustrates an example of a graph (or graphs).\n\nFig. 1\n\nA free tree is a connnected, acyclic, undirected graph. A rooted tree is a free tree in which one of the vertices is distinguished from the others. A vertex of a rooted tree is called \"node.\"\n\nYour task is to write a program which reports the following information for each node u of a given rooted tree T:\n\nnode ID of u\n\nparent of u\n\ndepth of u\n\nnode type (root, internal node or leaf)\n\na list of chidlren of u\n\nIf the last edge on the path from the root r of a tree T to a node x is (p, x), then p is the parent of x, and x is a child of p. The root is the only node in T with no parent.\n\nA node with no children is an external node or leaf. A nonleaf node is an internal node\n\nThe number of children of a node x in a rooted tree T is called the degree of x.\n\nThe length of the path from the root r to a node x is the depth of x in T.\n\nHere, the given tree consists of n nodes and evey node has a unique ID from 0 to n-1.\n\nFig. 2 shows an example of rooted trees where ID of each node is indicated by a number in a circle (node). The example corresponds to the first sample input.\n\nFig. 2\n\nInput\n\nThe first line of the input includes an integer n, the number of nodes of the tree.\n\nIn the next n lines, the information of each node u is given in the following format:\n\nid k c1 c2 ... ck\n\nwhere id is the node ID of u, k is the degree of u, c1 ... ck are node IDs of 1st, ... kth child of u. If the node does not have a child, the k is 0.\n\nOutput\n\nPrint the information of each node in the following format ordered by IDs:\n\nnode id: parent = p, depth = d, type, [c1...ck]\n\np is ID of its parent. If the node does not have a parent, print -1.\n\nd is depth of the node.\n\ntype is a type of nodes represented by a string (root, internal node or leaf). If the root can be considered as a leaf or an internal node, print root.\n\nc1...ck is the list of children as a ordered tree.\n\nPlease follow the format presented in a sample output below.\n\nConstraints\n\n1 ≤ n ≤ 100000\n\nSample Input 1\n\n13\n0 3 1 4 10\n1 2 2 3\n2 0\n3 0\n4 3 5 6 7\n5 0\n6 0\n7 2 8 9\n8 0\n9 0\n10 2 11 12\n11 0\n12 0\n\nSample Output 1\n\nnode 0: parent = -1, depth = 0, root, [1, 4, 10]\nnode 1: parent = 0, depth = 1, internal node, [2, 3]\nnode 2: parent = 1, depth = 2, leaf, []\nnode 3: parent = 1, depth = 2, leaf, []\nnode 4: parent = 0, depth = 1, internal node, [5, 6, 7]\nnode 5: parent = 4, depth = 2, leaf, []\nnode 6: parent = 4, depth = 2, leaf, []\nnode 7: parent = 4, depth = 2, internal node, [8, 9]\nnode 8: parent = 7, depth = 3, leaf, []\nnode 9: parent = 7, depth = 3, leaf, []\nnode 10: parent = 0, depth = 1, internal node, [11, 12]\nnode 11: parent = 10, depth = 2, leaf, []\nnode 12: parent = 10, depth = 2, leaf, []\n\nSample Input 2\n\n4\n1 3 3 2 0\n0 0\n3 0\n2 0\n\nSample Output 2\n\nnode 0: parent = 1, depth = 1, leaf, []\nnode 1: parent = -1, depth = 0, root, [3, 2, 0]\nnode 2: parent = 1, depth = 1, leaf, []\nnode 3: parent = 1, depth = 1, leaf, []\n\nNote\n\nYou can use a left-child, right-sibling representation to implement a tree which has the following data:\n\nthe parent of u\n\nthe leftmost child of u\n\nthe immediate right sibling of u\n\nReference\n\nIntroduction to Algorithms, Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Clifford Stein. The MIT Press.", "sample_input": "13\n0 3 1 4 10\n1 2 2 3\n2 0\n3 0\n4 3 5 6 7\n5 0\n6 0\n7 2 8 9\n8 0\n9 0\n10 2 11 12\n11 0\n12 0\n"}, "reference_outputs": ["node 0: parent = -1, depth = 0, root, [1, 4, 10]\nnode 1: parent = 0, depth = 1, internal node, [2, 3]\nnode 2: parent = 1, depth = 2, leaf, []\nnode 3: parent = 1, depth = 2, leaf, []\nnode 4: parent = 0, depth = 1, internal node, [5, 6, 7]\nnode 5: parent = 4, depth = 2, leaf, []\nnode 6: parent = 4, depth = 2, leaf, []\nnode 7: parent = 4, depth = 2, internal node, [8, 9]\nnode 8: parent = 7, depth = 3, leaf, []\nnode 9: parent = 7, depth = 3, leaf, []\nnode 10: parent = 0, depth = 1, internal node, [11, 12]\nnode 11: parent = 10, depth = 2, leaf, []\nnode 12: parent = 10, depth = 2, leaf, []\n"], "source_document_id": "p02279", "source_text": "Rooted Trees\n\nA graph G = (V, E) is a data structure where V is a finite set of vertices and E is a binary relation on V represented by a set of edges. Fig. 1 illustrates an example of a graph (or graphs).\n\nFig. 1\n\nA free tree is a connnected, acyclic, undirected graph. A rooted tree is a free tree in which one of the vertices is distinguished from the others. A vertex of a rooted tree is called \"node.\"\n\nYour task is to write a program which reports the following information for each node u of a given rooted tree T:\n\nnode ID of u\n\nparent of u\n\ndepth of u\n\nnode type (root, internal node or leaf)\n\na list of chidlren of u\n\nIf the last edge on the path from the root r of a tree T to a node x is (p, x), then p is the parent of x, and x is a child of p. The root is the only node in T with no parent.\n\nA node with no children is an external node or leaf. A nonleaf node is an internal node\n\nThe number of children of a node x in a rooted tree T is called the degree of x.\n\nThe length of the path from the root r to a node x is the depth of x in T.\n\nHere, the given tree consists of n nodes and evey node has a unique ID from 0 to n-1.\n\nFig. 2 shows an example of rooted trees where ID of each node is indicated by a number in a circle (node). The example corresponds to the first sample input.\n\nFig. 2\n\nInput\n\nThe first line of the input includes an integer n, the number of nodes of the tree.\n\nIn the next n lines, the information of each node u is given in the following format:\n\nid k c1 c2 ... ck\n\nwhere id is the node ID of u, k is the degree of u, c1 ... ck are node IDs of 1st, ... kth child of u. If the node does not have a child, the k is 0.\n\nOutput\n\nPrint the information of each node in the following format ordered by IDs:\n\nnode id: parent = p, depth = d, type, [c1...ck]\n\np is ID of its parent. If the node does not have a parent, print -1.\n\nd is depth of the node.\n\ntype is a type of nodes represented by a string (root, internal node or leaf). If the root can be considered as a leaf or an internal node, print root.\n\nc1...ck is the list of children as a ordered tree.\n\nPlease follow the format presented in a sample output below.\n\nConstraints\n\n1 ≤ n ≤ 100000\n\nSample Input 1\n\n13\n0 3 1 4 10\n1 2 2 3\n2 0\n3 0\n4 3 5 6 7\n5 0\n6 0\n7 2 8 9\n8 0\n9 0\n10 2 11 12\n11 0\n12 0\n\nSample Output 1\n\nnode 0: parent = -1, depth = 0, root, [1, 4, 10]\nnode 1: parent = 0, depth = 1, internal node, [2, 3]\nnode 2: parent = 1, depth = 2, leaf, []\nnode 3: parent = 1, depth = 2, leaf, []\nnode 4: parent = 0, depth = 1, internal node, [5, 6, 7]\nnode 5: parent = 4, depth = 2, leaf, []\nnode 6: parent = 4, depth = 2, leaf, []\nnode 7: parent = 4, depth = 2, internal node, [8, 9]\nnode 8: parent = 7, depth = 3, leaf, []\nnode 9: parent = 7, depth = 3, leaf, []\nnode 10: parent = 0, depth = 1, internal node, [11, 12]\nnode 11: parent = 10, depth = 2, leaf, []\nnode 12: parent = 10, depth = 2, leaf, []\n\nSample Input 2\n\n4\n1 3 3 2 0\n0 0\n3 0\n2 0\n\nSample Output 2\n\nnode 0: parent = 1, depth = 1, leaf, []\nnode 1: parent = -1, depth = 0, root, [3, 2, 0]\nnode 2: parent = 1, depth = 1, leaf, []\nnode 3: parent = 1, depth = 1, leaf, []\n\nNote\n\nYou can use a left-child, right-sibling representation to implement a tree which has the following data:\n\nthe parent of u\n\nthe leftmost child of u\n\nthe immediate right sibling of u\n\nReference\n\nIntroduction to Algorithms, Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Clifford Stein. The MIT Press.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1562, "cpu_time_ms": 20000, "memory_kb": 29600}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s699056867", "group_id": "codeNet:p02279", "input_text": "let nil = -1\n\ntype tree = { mutable parent : int; mutable child : int; mutable bro : int; mutable depth : int }\n\nlet make () = { parent = nil; child = nil; bro = nil; depth = nil }\n\nlet set_depth t n =\n let rec root i =\n if i = n then nil\n else if t.(i).parent = nil then i\n else root (i + 1) in\n let rec doit i d =\n t.(i).depth <- d;\n if t.(i).bro <> nil then doit t.(i).bro d;\n if t.(i).child <> nil then doit t.(i).child (d + 1) in\n doit (root 0) 0\n\nlet print_tree t =\n let rec string_of_children i c acc =\n if c = nil then acc\n else string_of_children i t.(c).bro (acc ^ (if c <> t.(i).child then \", \" else \"\") ^ string_of_int c) in\n let string_of_children i c = string_of_children i c \"\" in\n t |> Array.iteri (fun i _ ->\n \"node \" ^ string_of_int i ^ \": parent = \" ^ string_of_int t.(i).parent\n ^ \", depth = \" ^ string_of_int t.(i).depth\n ^ (if t.(i).parent = nil then \", root, [\"\n else if t.(i).child = nil then \", leaf, [\"\n else \", internal node, [\")\n ^ string_of_children i t.(i).child\n ^ \"]\"\n |> Printf.printf \"%s\\n\")\n\nlet () =\n let n = Scanf.scanf \"%d \" (fun i -> i) in\n let t = Array.init n (fun _ -> make ()) in\n for _ = 0 to n - 1 do\n let (id, k) = Scanf.scanf \"%d %d \" (fun id k -> (id, k)) in\n let left_child = ref 0 in\n for i = 0 to k - 1 do\n let c = Scanf.scanf \"%d \" (fun i -> i) in\n t.(c).parent <- id;\n if i = 0 then t.(id).child <- c\n else t.(!left_child).bro <- c;\n left_child := c;\n done;\n done;\n set_depth t n;\n print_tree t", "language": "OCaml", "metadata": {"date": 1499929012, "filename_ext": "ml", "original_language": "OCaml", "problem_description_relpath": "problem_descriptions/p02279.html", "problem_id": "p02279", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02279/input.txt", "sample_output_relpath": "derived/input_output/data/p02279/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02279/OCaml/s699056867.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s699056867", "user_id": "u809138450"}, "prompt_components": {"gold_output": "node 0: parent = -1, depth = 0, root, [1, 4, 10]\nnode 1: parent = 0, depth = 1, internal node, [2, 3]\nnode 2: parent = 1, depth = 2, leaf, []\nnode 3: parent = 1, depth = 2, leaf, []\nnode 4: parent = 0, depth = 1, internal node, [5, 6, 7]\nnode 5: parent = 4, depth = 2, leaf, []\nnode 6: parent = 4, depth = 2, leaf, []\nnode 7: parent = 4, depth = 2, internal node, [8, 9]\nnode 8: parent = 7, depth = 3, leaf, []\nnode 9: parent = 7, depth = 3, leaf, []\nnode 10: parent = 0, depth = 1, internal node, [11, 12]\nnode 11: parent = 10, depth = 2, leaf, []\nnode 12: parent = 10, depth = 2, leaf, []\n", "input_to_evaluate": "let nil = -1\n\ntype tree = { mutable parent : int; mutable child : int; mutable bro : int; mutable depth : int }\n\nlet make () = { parent = nil; child = nil; bro = nil; depth = nil }\n\nlet set_depth t n =\n let rec root i =\n if i = n then nil\n else if t.(i).parent = nil then i\n else root (i + 1) in\n let rec doit i d =\n t.(i).depth <- d;\n if t.(i).bro <> nil then doit t.(i).bro d;\n if t.(i).child <> nil then doit t.(i).child (d + 1) in\n doit (root 0) 0\n\nlet print_tree t =\n let rec string_of_children i c acc =\n if c = nil then acc\n else string_of_children i t.(c).bro (acc ^ (if c <> t.(i).child then \", \" else \"\") ^ string_of_int c) in\n let string_of_children i c = string_of_children i c \"\" in\n t |> Array.iteri (fun i _ ->\n \"node \" ^ string_of_int i ^ \": parent = \" ^ string_of_int t.(i).parent\n ^ \", depth = \" ^ string_of_int t.(i).depth\n ^ (if t.(i).parent = nil then \", root, [\"\n else if t.(i).child = nil then \", leaf, [\"\n else \", internal node, [\")\n ^ string_of_children i t.(i).child\n ^ \"]\"\n |> Printf.printf \"%s\\n\")\n\nlet () =\n let n = Scanf.scanf \"%d \" (fun i -> i) in\n let t = Array.init n (fun _ -> make ()) in\n for _ = 0 to n - 1 do\n let (id, k) = Scanf.scanf \"%d %d \" (fun id k -> (id, k)) in\n let left_child = ref 0 in\n for i = 0 to k - 1 do\n let c = Scanf.scanf \"%d \" (fun i -> i) in\n t.(c).parent <- id;\n if i = 0 then t.(id).child <- c\n else t.(!left_child).bro <- c;\n left_child := c;\n done;\n done;\n set_depth t n;\n print_tree t", "problem_context": "Rooted Trees\n\nA graph G = (V, E) is a data structure where V is a finite set of vertices and E is a binary relation on V represented by a set of edges. Fig. 1 illustrates an example of a graph (or graphs).\n\nFig. 1\n\nA free tree is a connnected, acyclic, undirected graph. A rooted tree is a free tree in which one of the vertices is distinguished from the others. A vertex of a rooted tree is called \"node.\"\n\nYour task is to write a program which reports the following information for each node u of a given rooted tree T:\n\nnode ID of u\n\nparent of u\n\ndepth of u\n\nnode type (root, internal node or leaf)\n\na list of chidlren of u\n\nIf the last edge on the path from the root r of a tree T to a node x is (p, x), then p is the parent of x, and x is a child of p. The root is the only node in T with no parent.\n\nA node with no children is an external node or leaf. A nonleaf node is an internal node\n\nThe number of children of a node x in a rooted tree T is called the degree of x.\n\nThe length of the path from the root r to a node x is the depth of x in T.\n\nHere, the given tree consists of n nodes and evey node has a unique ID from 0 to n-1.\n\nFig. 2 shows an example of rooted trees where ID of each node is indicated by a number in a circle (node). The example corresponds to the first sample input.\n\nFig. 2\n\nInput\n\nThe first line of the input includes an integer n, the number of nodes of the tree.\n\nIn the next n lines, the information of each node u is given in the following format:\n\nid k c1 c2 ... ck\n\nwhere id is the node ID of u, k is the degree of u, c1 ... ck are node IDs of 1st, ... kth child of u. If the node does not have a child, the k is 0.\n\nOutput\n\nPrint the information of each node in the following format ordered by IDs:\n\nnode id: parent = p, depth = d, type, [c1...ck]\n\np is ID of its parent. If the node does not have a parent, print -1.\n\nd is depth of the node.\n\ntype is a type of nodes represented by a string (root, internal node or leaf). If the root can be considered as a leaf or an internal node, print root.\n\nc1...ck is the list of children as a ordered tree.\n\nPlease follow the format presented in a sample output below.\n\nConstraints\n\n1 ≤ n ≤ 100000\n\nSample Input 1\n\n13\n0 3 1 4 10\n1 2 2 3\n2 0\n3 0\n4 3 5 6 7\n5 0\n6 0\n7 2 8 9\n8 0\n9 0\n10 2 11 12\n11 0\n12 0\n\nSample Output 1\n\nnode 0: parent = -1, depth = 0, root, [1, 4, 10]\nnode 1: parent = 0, depth = 1, internal node, [2, 3]\nnode 2: parent = 1, depth = 2, leaf, []\nnode 3: parent = 1, depth = 2, leaf, []\nnode 4: parent = 0, depth = 1, internal node, [5, 6, 7]\nnode 5: parent = 4, depth = 2, leaf, []\nnode 6: parent = 4, depth = 2, leaf, []\nnode 7: parent = 4, depth = 2, internal node, [8, 9]\nnode 8: parent = 7, depth = 3, leaf, []\nnode 9: parent = 7, depth = 3, leaf, []\nnode 10: parent = 0, depth = 1, internal node, [11, 12]\nnode 11: parent = 10, depth = 2, leaf, []\nnode 12: parent = 10, depth = 2, leaf, []\n\nSample Input 2\n\n4\n1 3 3 2 0\n0 0\n3 0\n2 0\n\nSample Output 2\n\nnode 0: parent = 1, depth = 1, leaf, []\nnode 1: parent = -1, depth = 0, root, [3, 2, 0]\nnode 2: parent = 1, depth = 1, leaf, []\nnode 3: parent = 1, depth = 1, leaf, []\n\nNote\n\nYou can use a left-child, right-sibling representation to implement a tree which has the following data:\n\nthe parent of u\n\nthe leftmost child of u\n\nthe immediate right sibling of u\n\nReference\n\nIntroduction to Algorithms, Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Clifford Stein. The MIT Press.", "sample_input": "13\n0 3 1 4 10\n1 2 2 3\n2 0\n3 0\n4 3 5 6 7\n5 0\n6 0\n7 2 8 9\n8 0\n9 0\n10 2 11 12\n11 0\n12 0\n"}, "reference_outputs": ["node 0: parent = -1, depth = 0, root, [1, 4, 10]\nnode 1: parent = 0, depth = 1, internal node, [2, 3]\nnode 2: parent = 1, depth = 2, leaf, []\nnode 3: parent = 1, depth = 2, leaf, []\nnode 4: parent = 0, depth = 1, internal node, [5, 6, 7]\nnode 5: parent = 4, depth = 2, leaf, []\nnode 6: parent = 4, depth = 2, leaf, []\nnode 7: parent = 4, depth = 2, internal node, [8, 9]\nnode 8: parent = 7, depth = 3, leaf, []\nnode 9: parent = 7, depth = 3, leaf, []\nnode 10: parent = 0, depth = 1, internal node, [11, 12]\nnode 11: parent = 10, depth = 2, leaf, []\nnode 12: parent = 10, depth = 2, leaf, []\n"], "source_document_id": "p02279", "source_text": "Rooted Trees\n\nA graph G = (V, E) is a data structure where V is a finite set of vertices and E is a binary relation on V represented by a set of edges. Fig. 1 illustrates an example of a graph (or graphs).\n\nFig. 1\n\nA free tree is a connnected, acyclic, undirected graph. A rooted tree is a free tree in which one of the vertices is distinguished from the others. A vertex of a rooted tree is called \"node.\"\n\nYour task is to write a program which reports the following information for each node u of a given rooted tree T:\n\nnode ID of u\n\nparent of u\n\ndepth of u\n\nnode type (root, internal node or leaf)\n\na list of chidlren of u\n\nIf the last edge on the path from the root r of a tree T to a node x is (p, x), then p is the parent of x, and x is a child of p. The root is the only node in T with no parent.\n\nA node with no children is an external node or leaf. A nonleaf node is an internal node\n\nThe number of children of a node x in a rooted tree T is called the degree of x.\n\nThe length of the path from the root r to a node x is the depth of x in T.\n\nHere, the given tree consists of n nodes and evey node has a unique ID from 0 to n-1.\n\nFig. 2 shows an example of rooted trees where ID of each node is indicated by a number in a circle (node). The example corresponds to the first sample input.\n\nFig. 2\n\nInput\n\nThe first line of the input includes an integer n, the number of nodes of the tree.\n\nIn the next n lines, the information of each node u is given in the following format:\n\nid k c1 c2 ... ck\n\nwhere id is the node ID of u, k is the degree of u, c1 ... ck are node IDs of 1st, ... kth child of u. If the node does not have a child, the k is 0.\n\nOutput\n\nPrint the information of each node in the following format ordered by IDs:\n\nnode id: parent = p, depth = d, type, [c1...ck]\n\np is ID of its parent. If the node does not have a parent, print -1.\n\nd is depth of the node.\n\ntype is a type of nodes represented by a string (root, internal node or leaf). If the root can be considered as a leaf or an internal node, print root.\n\nc1...ck is the list of children as a ordered tree.\n\nPlease follow the format presented in a sample output below.\n\nConstraints\n\n1 ≤ n ≤ 100000\n\nSample Input 1\n\n13\n0 3 1 4 10\n1 2 2 3\n2 0\n3 0\n4 3 5 6 7\n5 0\n6 0\n7 2 8 9\n8 0\n9 0\n10 2 11 12\n11 0\n12 0\n\nSample Output 1\n\nnode 0: parent = -1, depth = 0, root, [1, 4, 10]\nnode 1: parent = 0, depth = 1, internal node, [2, 3]\nnode 2: parent = 1, depth = 2, leaf, []\nnode 3: parent = 1, depth = 2, leaf, []\nnode 4: parent = 0, depth = 1, internal node, [5, 6, 7]\nnode 5: parent = 4, depth = 2, leaf, []\nnode 6: parent = 4, depth = 2, leaf, []\nnode 7: parent = 4, depth = 2, internal node, [8, 9]\nnode 8: parent = 7, depth = 3, leaf, []\nnode 9: parent = 7, depth = 3, leaf, []\nnode 10: parent = 0, depth = 1, internal node, [11, 12]\nnode 11: parent = 10, depth = 2, leaf, []\nnode 12: parent = 10, depth = 2, leaf, []\n\nSample Input 2\n\n4\n1 3 3 2 0\n0 0\n3 0\n2 0\n\nSample Output 2\n\nnode 0: parent = 1, depth = 1, leaf, []\nnode 1: parent = -1, depth = 0, root, [3, 2, 0]\nnode 2: parent = 1, depth = 1, leaf, []\nnode 3: parent = 1, depth = 1, leaf, []\n\nNote\n\nYou can use a left-child, right-sibling representation to implement a tree which has the following data:\n\nthe parent of u\n\nthe leftmost child of u\n\nthe immediate right sibling of u\n\nReference\n\nIntroduction to Algorithms, Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Clifford Stein. The MIT Press.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1568, "cpu_time_ms": 20000, "memory_kb": 29608}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s402149821", "group_id": "codeNet:p02283", "input_text": "type bs_tree = Nil | Node of node and\n node = {\n key:int;\n mutable left:bs_tree;\n mutable right:bs_tree\n };;\n\nlet new_node key = {key=key;left=Nil;right=Nil};;\n\nlet insert t z =\n let rec loop y = function\n Nil -> y\n | Node x ->\n if z.key < x.key then\n loop (Node x) (x.left)\n else\n loop (Node x) (x.right)\n in\n let y = loop t t in\n match y with\n Nil -> (Node z)\n | Node y ->\n if z.key < y.key then\n y.left <- (Node z)\n else\n y.right <- (Node z)\n ;t\n;;\n\nlet rec print_in = function\n Nil -> ()\n | Node x ->\n print_in (x.left);\n Printf.printf \" %d\" x.key;\n print_in (x.right)\n;;\n\nlet rec print_pre = function\n Nil -> ()\n | Node x ->\n Printf.printf \" %d\" x.key;\n print_pre (x.left);print_pre (x.right)\n;;\n\nlet () =\n let n = read_int () in\n let rec read t = function\n 0 -> ()\n | i ->\n let com = Scanf.scanf \"%s\" (fun x -> x) in\n if com = \"insert\" then begin\n let arg = Scanf.scanf \" %d\\n\" (fun x -> x) in\n let z = new_node arg in\n read (insert t z) (i-1)\n end\n else if com = \"print\" then begin\n let _ = Scanf.scanf \"%s\\n\" (fun x -> x) in\n print_in t;print_newline ();\n print_pre t;print_newline ();\n read t (i-1)\n end\n else ()\n in read Nil n\n;;", "language": "OCaml", "metadata": {"date": 1471093935, "filename_ext": "ml", "original_language": "OCaml", "problem_description_relpath": "problem_descriptions/p02283.html", "problem_id": "p02283", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02283/input.txt", "sample_output_relpath": "derived/input_output/data/p02283/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02283/OCaml/s402149821.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s402149821", "user_id": "u935184340"}, "prompt_components": {"gold_output": " 1 12 17 20 25 30 88\n 30 12 1 20 17 25 88\n", "input_to_evaluate": "type bs_tree = Nil | Node of node and\n node = {\n key:int;\n mutable left:bs_tree;\n mutable right:bs_tree\n };;\n\nlet new_node key = {key=key;left=Nil;right=Nil};;\n\nlet insert t z =\n let rec loop y = function\n Nil -> y\n | Node x ->\n if z.key < x.key then\n loop (Node x) (x.left)\n else\n loop (Node x) (x.right)\n in\n let y = loop t t in\n match y with\n Nil -> (Node z)\n | Node y ->\n if z.key < y.key then\n y.left <- (Node z)\n else\n y.right <- (Node z)\n ;t\n;;\n\nlet rec print_in = function\n Nil -> ()\n | Node x ->\n print_in (x.left);\n Printf.printf \" %d\" x.key;\n print_in (x.right)\n;;\n\nlet rec print_pre = function\n Nil -> ()\n | Node x ->\n Printf.printf \" %d\" x.key;\n print_pre (x.left);print_pre (x.right)\n;;\n\nlet () =\n let n = read_int () in\n let rec read t = function\n 0 -> ()\n | i ->\n let com = Scanf.scanf \"%s\" (fun x -> x) in\n if com = \"insert\" then begin\n let arg = Scanf.scanf \" %d\\n\" (fun x -> x) in\n let z = new_node arg in\n read (insert t z) (i-1)\n end\n else if com = \"print\" then begin\n let _ = Scanf.scanf \"%s\\n\" (fun x -> x) in\n print_in t;print_newline ();\n print_pre t;print_newline ();\n read t (i-1)\n end\n else ()\n in read Nil n\n;;", "problem_context": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nBinary Search Tree I\n\nSearch trees are data structures that support dynamic set operations including insert, search, delete and so on. Thus a search tree can be used both as a dictionary and as a priority queue.\n\nBinary search tree is one of fundamental search trees. The keys in a binary search tree are always stored in such a way as to satisfy the following binary search tree property:\n\nLet $x$ be a node in a binary search tree. If $y$ is a node in the left subtree of $x$, then $y.key \\leq x.key$. If $y$ is a node in the right subtree of $x$, then $x.key \\leq y.key$.\n\nThe following figure shows an example of the binary search tree.\n\nFor example, keys of nodes which belong to the left sub-tree of the node containing 80 are less than or equal to 80, and keys of nodes which belong to the right sub-tree are more than or equal to 80. The binary search tree property allows us to print out all the keys in the tree in sorted order by an inorder tree walk.\n\nA binary search tree should be implemented in such a way that the binary search tree property continues to hold after modifications by insertions and deletions. A binary search tree can be represented by a linked data structure in which each node is an object. In addition to a key field and satellite data, each node contains fields left, right, and p that point to the nodes corresponding to its left child, its right child, and its parent, respectively.\n\nTo insert a new value $v$ into a binary search tree $T$, we can use the procedure insert as shown in the following pseudo code. The insert procedure is passed a node $z$ for which $z.key = v$, $z.left = NIL$, and $z.right = NIL$. The procedure modifies $T$ and some of the fields of $z$ in such a way that $z$ is inserted into an appropriate position in the tree.\n\n1 insert(T, z)\n2 y = NIL // parent of x\n3 x = 'the root of T'\n4 while x ≠ NIL\n5 y = x // set the parent\n6 if z.key < x.key\n7 x = x.left // move to the left child\n8 else\n9 x = x.right // move to the right child\n10 z.p = y\n11\n12 if y == NIL // T is empty\n13 'the root of T' = z\n14 else if z.key < y.key\n15 y.left = z // z is the left child of y\n16 else\n17 y.right = z // z is the right child of y\n\nWrite a program which performs the following operations to a binary search tree $T$.\n\ninsert $k$: Insert a node containing $k$ as key into $T$.\n\nprint: Print the keys of the binary search tree by inorder tree walk and preorder tree walk respectively.\n\nYou should use the above pseudo code to implement the insert operation. $T$ is empty at the initial state.\n\nInput\n\nIn the first line, the number of operations $m$ is given. In the following $m$ lines, operations represented by insert $k$ or print are given.\n\nOutput\n\nFor each print operation, print a list of keys obtained by inorder tree walk and preorder tree walk in a line respectively. Put a space character before each key.\n\nConstraints\n\nThe number of operations $\\leq 500,000$\n\nThe number of print operations $\\leq 10$.\n\n$-2,000,000,000 \\leq key \\leq 2,000,000,000$\n\nThe height of the binary tree does not exceed 100 if you employ the above pseudo code.\n\nThe keys in the binary search tree are all different.\n\nSample Input 1\n\n8\ninsert 30\ninsert 88\ninsert 12\ninsert 1\ninsert 20\ninsert 17\ninsert 25\nprint\n\nSample Output 1\n\n1 12 17 20 25 30 88\n30 12 1 20 17 25 88\n\nReference\n\nIntroduction to Algorithms, Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Clifford Stein. The MIT Press.", "sample_input": "8\ninsert 30\ninsert 88\ninsert 12\ninsert 1\ninsert 20\ninsert 17\ninsert 25\nprint\n"}, "reference_outputs": [" 1 12 17 20 25 30 88\n 30 12 1 20 17 25 88\n"], "source_document_id": "p02283", "source_text": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nBinary Search Tree I\n\nSearch trees are data structures that support dynamic set operations including insert, search, delete and so on. Thus a search tree can be used both as a dictionary and as a priority queue.\n\nBinary search tree is one of fundamental search trees. The keys in a binary search tree are always stored in such a way as to satisfy the following binary search tree property:\n\nLet $x$ be a node in a binary search tree. If $y$ is a node in the left subtree of $x$, then $y.key \\leq x.key$. If $y$ is a node in the right subtree of $x$, then $x.key \\leq y.key$.\n\nThe following figure shows an example of the binary search tree.\n\nFor example, keys of nodes which belong to the left sub-tree of the node containing 80 are less than or equal to 80, and keys of nodes which belong to the right sub-tree are more than or equal to 80. The binary search tree property allows us to print out all the keys in the tree in sorted order by an inorder tree walk.\n\nA binary search tree should be implemented in such a way that the binary search tree property continues to hold after modifications by insertions and deletions. A binary search tree can be represented by a linked data structure in which each node is an object. In addition to a key field and satellite data, each node contains fields left, right, and p that point to the nodes corresponding to its left child, its right child, and its parent, respectively.\n\nTo insert a new value $v$ into a binary search tree $T$, we can use the procedure insert as shown in the following pseudo code. The insert procedure is passed a node $z$ for which $z.key = v$, $z.left = NIL$, and $z.right = NIL$. The procedure modifies $T$ and some of the fields of $z$ in such a way that $z$ is inserted into an appropriate position in the tree.\n\n1 insert(T, z)\n2 y = NIL // parent of x\n3 x = 'the root of T'\n4 while x ≠ NIL\n5 y = x // set the parent\n6 if z.key < x.key\n7 x = x.left // move to the left child\n8 else\n9 x = x.right // move to the right child\n10 z.p = y\n11\n12 if y == NIL // T is empty\n13 'the root of T' = z\n14 else if z.key < y.key\n15 y.left = z // z is the left child of y\n16 else\n17 y.right = z // z is the right child of y\n\nWrite a program which performs the following operations to a binary search tree $T$.\n\ninsert $k$: Insert a node containing $k$ as key into $T$.\n\nprint: Print the keys of the binary search tree by inorder tree walk and preorder tree walk respectively.\n\nYou should use the above pseudo code to implement the insert operation. $T$ is empty at the initial state.\n\nInput\n\nIn the first line, the number of operations $m$ is given. In the following $m$ lines, operations represented by insert $k$ or print are given.\n\nOutput\n\nFor each print operation, print a list of keys obtained by inorder tree walk and preorder tree walk in a line respectively. Put a space character before each key.\n\nConstraints\n\nThe number of operations $\\leq 500,000$\n\nThe number of print operations $\\leq 10$.\n\n$-2,000,000,000 \\leq key \\leq 2,000,000,000$\n\nThe height of the binary tree does not exceed 100 if you employ the above pseudo code.\n\nThe keys in the binary search tree are all different.\n\nSample Input 1\n\n8\ninsert 30\ninsert 88\ninsert 12\ninsert 1\ninsert 20\ninsert 17\ninsert 25\nprint\n\nSample Output 1\n\n1 12 17 20 25 30 88\n30 12 1 20 17 25 88\n\nReference\n\nIntroduction to Algorithms, Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Clifford Stein. The MIT Press.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1389, "cpu_time_ms": 720, "memory_kb": 28304}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s609055725", "group_id": "codeNet:p02283", "input_text": "type bs_tree = Nil | Node of node and\n node = {\n key:int;\n mutable left:bs_tree;\n mutable right:bs_tree\n };;\n\nlet new_node key = {key=key;left=Nil;right=Nil};;\n\nlet insert t z =\n let rec loop y = function\n Nil -> y\n | Node x ->\n if z.key < x.key then\n loop (Node x) (x.left)\n else\n loop (Node x) (x.right)\n in\n let y = loop t t in\n match y with\n Nil -> (Node z)\n | Node y ->\n if z.key < y.key then\n y.left <- (Node z)\n else\n y.right <- (Node z)\n ;t\n;;\n\nlet rec print_in = function\n Nil -> ()\n | Node x ->\n print_in (x.left);\n Printf.printf \" %d\" x.key;\n print_in (x.right)\n;;\n\nlet rec print_pre = function\n Nil -> ()\n | Node x ->\n Printf.printf \" %d\" x.key;\n print_pre (x.left);print_pre (x.right)\n;;\n\nlet () =\n let n = read_int () in\n let rec read t = function\n 0 -> ()\n | i ->\n let com = Scanf.scanf \"%s\" (fun x -> x) in\n if com = \"insert\" then begin\n let arg = Scanf.scanf \" %d\\n\" (fun x -> x) in\n let z = new_node arg in\n read (insert t z) (i-1)\n end\n else if com = \"print\" then begin\n let _ = Scanf.scanf \"%s\\n\" (fun x -> x) in\n print_in t;print_newline ();\n print_pre t;print_newline ();\n read t (i-1)\n end\n else ()\n in read Nil n\n;;", "language": "OCaml", "metadata": {"date": 1471093946, "filename_ext": "ml", "original_language": "OCaml", "problem_description_relpath": "problem_descriptions/p02283.html", "problem_id": "p02283", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02283/input.txt", "sample_output_relpath": "derived/input_output/data/p02283/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02283/OCaml/s609055725.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s609055725", "user_id": "u935184340"}, "prompt_components": {"gold_output": " 1 12 17 20 25 30 88\n 30 12 1 20 17 25 88\n", "input_to_evaluate": "type bs_tree = Nil | Node of node and\n node = {\n key:int;\n mutable left:bs_tree;\n mutable right:bs_tree\n };;\n\nlet new_node key = {key=key;left=Nil;right=Nil};;\n\nlet insert t z =\n let rec loop y = function\n Nil -> y\n | Node x ->\n if z.key < x.key then\n loop (Node x) (x.left)\n else\n loop (Node x) (x.right)\n in\n let y = loop t t in\n match y with\n Nil -> (Node z)\n | Node y ->\n if z.key < y.key then\n y.left <- (Node z)\n else\n y.right <- (Node z)\n ;t\n;;\n\nlet rec print_in = function\n Nil -> ()\n | Node x ->\n print_in (x.left);\n Printf.printf \" %d\" x.key;\n print_in (x.right)\n;;\n\nlet rec print_pre = function\n Nil -> ()\n | Node x ->\n Printf.printf \" %d\" x.key;\n print_pre (x.left);print_pre (x.right)\n;;\n\nlet () =\n let n = read_int () in\n let rec read t = function\n 0 -> ()\n | i ->\n let com = Scanf.scanf \"%s\" (fun x -> x) in\n if com = \"insert\" then begin\n let arg = Scanf.scanf \" %d\\n\" (fun x -> x) in\n let z = new_node arg in\n read (insert t z) (i-1)\n end\n else if com = \"print\" then begin\n let _ = Scanf.scanf \"%s\\n\" (fun x -> x) in\n print_in t;print_newline ();\n print_pre t;print_newline ();\n read t (i-1)\n end\n else ()\n in read Nil n\n;;", "problem_context": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nBinary Search Tree I\n\nSearch trees are data structures that support dynamic set operations including insert, search, delete and so on. Thus a search tree can be used both as a dictionary and as a priority queue.\n\nBinary search tree is one of fundamental search trees. The keys in a binary search tree are always stored in such a way as to satisfy the following binary search tree property:\n\nLet $x$ be a node in a binary search tree. If $y$ is a node in the left subtree of $x$, then $y.key \\leq x.key$. If $y$ is a node in the right subtree of $x$, then $x.key \\leq y.key$.\n\nThe following figure shows an example of the binary search tree.\n\nFor example, keys of nodes which belong to the left sub-tree of the node containing 80 are less than or equal to 80, and keys of nodes which belong to the right sub-tree are more than or equal to 80. The binary search tree property allows us to print out all the keys in the tree in sorted order by an inorder tree walk.\n\nA binary search tree should be implemented in such a way that the binary search tree property continues to hold after modifications by insertions and deletions. A binary search tree can be represented by a linked data structure in which each node is an object. In addition to a key field and satellite data, each node contains fields left, right, and p that point to the nodes corresponding to its left child, its right child, and its parent, respectively.\n\nTo insert a new value $v$ into a binary search tree $T$, we can use the procedure insert as shown in the following pseudo code. The insert procedure is passed a node $z$ for which $z.key = v$, $z.left = NIL$, and $z.right = NIL$. The procedure modifies $T$ and some of the fields of $z$ in such a way that $z$ is inserted into an appropriate position in the tree.\n\n1 insert(T, z)\n2 y = NIL // parent of x\n3 x = 'the root of T'\n4 while x ≠ NIL\n5 y = x // set the parent\n6 if z.key < x.key\n7 x = x.left // move to the left child\n8 else\n9 x = x.right // move to the right child\n10 z.p = y\n11\n12 if y == NIL // T is empty\n13 'the root of T' = z\n14 else if z.key < y.key\n15 y.left = z // z is the left child of y\n16 else\n17 y.right = z // z is the right child of y\n\nWrite a program which performs the following operations to a binary search tree $T$.\n\ninsert $k$: Insert a node containing $k$ as key into $T$.\n\nprint: Print the keys of the binary search tree by inorder tree walk and preorder tree walk respectively.\n\nYou should use the above pseudo code to implement the insert operation. $T$ is empty at the initial state.\n\nInput\n\nIn the first line, the number of operations $m$ is given. In the following $m$ lines, operations represented by insert $k$ or print are given.\n\nOutput\n\nFor each print operation, print a list of keys obtained by inorder tree walk and preorder tree walk in a line respectively. Put a space character before each key.\n\nConstraints\n\nThe number of operations $\\leq 500,000$\n\nThe number of print operations $\\leq 10$.\n\n$-2,000,000,000 \\leq key \\leq 2,000,000,000$\n\nThe height of the binary tree does not exceed 100 if you employ the above pseudo code.\n\nThe keys in the binary search tree are all different.\n\nSample Input 1\n\n8\ninsert 30\ninsert 88\ninsert 12\ninsert 1\ninsert 20\ninsert 17\ninsert 25\nprint\n\nSample Output 1\n\n1 12 17 20 25 30 88\n30 12 1 20 17 25 88\n\nReference\n\nIntroduction to Algorithms, Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Clifford Stein. The MIT Press.", "sample_input": "8\ninsert 30\ninsert 88\ninsert 12\ninsert 1\ninsert 20\ninsert 17\ninsert 25\nprint\n"}, "reference_outputs": [" 1 12 17 20 25 30 88\n 30 12 1 20 17 25 88\n"], "source_document_id": "p02283", "source_text": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nBinary Search Tree I\n\nSearch trees are data structures that support dynamic set operations including insert, search, delete and so on. Thus a search tree can be used both as a dictionary and as a priority queue.\n\nBinary search tree is one of fundamental search trees. The keys in a binary search tree are always stored in such a way as to satisfy the following binary search tree property:\n\nLet $x$ be a node in a binary search tree. If $y$ is a node in the left subtree of $x$, then $y.key \\leq x.key$. If $y$ is a node in the right subtree of $x$, then $x.key \\leq y.key$.\n\nThe following figure shows an example of the binary search tree.\n\nFor example, keys of nodes which belong to the left sub-tree of the node containing 80 are less than or equal to 80, and keys of nodes which belong to the right sub-tree are more than or equal to 80. The binary search tree property allows us to print out all the keys in the tree in sorted order by an inorder tree walk.\n\nA binary search tree should be implemented in such a way that the binary search tree property continues to hold after modifications by insertions and deletions. A binary search tree can be represented by a linked data structure in which each node is an object. In addition to a key field and satellite data, each node contains fields left, right, and p that point to the nodes corresponding to its left child, its right child, and its parent, respectively.\n\nTo insert a new value $v$ into a binary search tree $T$, we can use the procedure insert as shown in the following pseudo code. The insert procedure is passed a node $z$ for which $z.key = v$, $z.left = NIL$, and $z.right = NIL$. The procedure modifies $T$ and some of the fields of $z$ in such a way that $z$ is inserted into an appropriate position in the tree.\n\n1 insert(T, z)\n2 y = NIL // parent of x\n3 x = 'the root of T'\n4 while x ≠ NIL\n5 y = x // set the parent\n6 if z.key < x.key\n7 x = x.left // move to the left child\n8 else\n9 x = x.right // move to the right child\n10 z.p = y\n11\n12 if y == NIL // T is empty\n13 'the root of T' = z\n14 else if z.key < y.key\n15 y.left = z // z is the left child of y\n16 else\n17 y.right = z // z is the right child of y\n\nWrite a program which performs the following operations to a binary search tree $T$.\n\ninsert $k$: Insert a node containing $k$ as key into $T$.\n\nprint: Print the keys of the binary search tree by inorder tree walk and preorder tree walk respectively.\n\nYou should use the above pseudo code to implement the insert operation. $T$ is empty at the initial state.\n\nInput\n\nIn the first line, the number of operations $m$ is given. In the following $m$ lines, operations represented by insert $k$ or print are given.\n\nOutput\n\nFor each print operation, print a list of keys obtained by inorder tree walk and preorder tree walk in a line respectively. Put a space character before each key.\n\nConstraints\n\nThe number of operations $\\leq 500,000$\n\nThe number of print operations $\\leq 10$.\n\n$-2,000,000,000 \\leq key \\leq 2,000,000,000$\n\nThe height of the binary tree does not exceed 100 if you employ the above pseudo code.\n\nThe keys in the binary search tree are all different.\n\nSample Input 1\n\n8\ninsert 30\ninsert 88\ninsert 12\ninsert 1\ninsert 20\ninsert 17\ninsert 25\nprint\n\nSample Output 1\n\n1 12 17 20 25 30 88\n30 12 1 20 17 25 88\n\nReference\n\nIntroduction to Algorithms, Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Clifford Stein. The MIT Press.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1389, "cpu_time_ms": 650, "memory_kb": 28328}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s012154266", "group_id": "codeNet:p02283", "input_text": "module T = struct\n type tree = Nil | Node of int * tree * tree\n\n let create () = Nil\n\n let insert x t =\n let rec doit = function\n | Nil -> Node (x, Nil, Nil)\n | (Node (y, _, _)) as d when x = y -> d\n | Node (y, l, r) when x < y -> Node (y, doit l, r)\n | Node (y, l, r) -> Node (y, l, doit r)\n in\n doit t\n\n let preorder f t =\n let rec doit = function\n | Nil -> ()\n | Node (x, l, r) -> (f x; doit l; doit r)\n in\n doit t\n\n let inorder f t =\n let rec doit = function\n | Nil -> ()\n | Node (x, l, r) -> (doit l; f x; doit r)\n in\n doit t\nend\n\nlet print t =\n let f e = print_string \" \"; print_int e in\n T.inorder f t;\n print_newline ();\n T.preorder f t;\n print_newline ()\n\nlet split str delim =\n let rec doit s acc =\n match\n try Some (String.rindex s delim) with _ -> None\n with\n | None -> s :: acc\n | Some i ->\n let s1 = String.sub s 0 i in\n let s2 = String.sub s (i + 1) (String.length s - String.length s1 - 1) in\n doit s1 (s2 :: acc)\n in\n doit str []\n\nlet () =\n let m = read_int () in\n let rec read i t =\n if i < m then begin\n match split (read_line ()) ' ' with\n | [\"insert\"; n] -> read (i + 1) (T.insert (int_of_string n) t)\n | _ -> (print t; read (i + 1) t)\n end\n in\n read 0 (T.create ())", "language": "OCaml", "metadata": {"date": 1474730863, "filename_ext": "ml", "original_language": "OCaml", "problem_description_relpath": "problem_descriptions/p02283.html", "problem_id": "p02283", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02283/input.txt", "sample_output_relpath": "derived/input_output/data/p02283/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02283/OCaml/s012154266.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s012154266", "user_id": "u809138450"}, "prompt_components": {"gold_output": " 1 12 17 20 25 30 88\n 30 12 1 20 17 25 88\n", "input_to_evaluate": "module T = struct\n type tree = Nil | Node of int * tree * tree\n\n let create () = Nil\n\n let insert x t =\n let rec doit = function\n | Nil -> Node (x, Nil, Nil)\n | (Node (y, _, _)) as d when x = y -> d\n | Node (y, l, r) when x < y -> Node (y, doit l, r)\n | Node (y, l, r) -> Node (y, l, doit r)\n in\n doit t\n\n let preorder f t =\n let rec doit = function\n | Nil -> ()\n | Node (x, l, r) -> (f x; doit l; doit r)\n in\n doit t\n\n let inorder f t =\n let rec doit = function\n | Nil -> ()\n | Node (x, l, r) -> (doit l; f x; doit r)\n in\n doit t\nend\n\nlet print t =\n let f e = print_string \" \"; print_int e in\n T.inorder f t;\n print_newline ();\n T.preorder f t;\n print_newline ()\n\nlet split str delim =\n let rec doit s acc =\n match\n try Some (String.rindex s delim) with _ -> None\n with\n | None -> s :: acc\n | Some i ->\n let s1 = String.sub s 0 i in\n let s2 = String.sub s (i + 1) (String.length s - String.length s1 - 1) in\n doit s1 (s2 :: acc)\n in\n doit str []\n\nlet () =\n let m = read_int () in\n let rec read i t =\n if i < m then begin\n match split (read_line ()) ' ' with\n | [\"insert\"; n] -> read (i + 1) (T.insert (int_of_string n) t)\n | _ -> (print t; read (i + 1) t)\n end\n in\n read 0 (T.create ())", "problem_context": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nBinary Search Tree I\n\nSearch trees are data structures that support dynamic set operations including insert, search, delete and so on. Thus a search tree can be used both as a dictionary and as a priority queue.\n\nBinary search tree is one of fundamental search trees. The keys in a binary search tree are always stored in such a way as to satisfy the following binary search tree property:\n\nLet $x$ be a node in a binary search tree. If $y$ is a node in the left subtree of $x$, then $y.key \\leq x.key$. If $y$ is a node in the right subtree of $x$, then $x.key \\leq y.key$.\n\nThe following figure shows an example of the binary search tree.\n\nFor example, keys of nodes which belong to the left sub-tree of the node containing 80 are less than or equal to 80, and keys of nodes which belong to the right sub-tree are more than or equal to 80. The binary search tree property allows us to print out all the keys in the tree in sorted order by an inorder tree walk.\n\nA binary search tree should be implemented in such a way that the binary search tree property continues to hold after modifications by insertions and deletions. A binary search tree can be represented by a linked data structure in which each node is an object. In addition to a key field and satellite data, each node contains fields left, right, and p that point to the nodes corresponding to its left child, its right child, and its parent, respectively.\n\nTo insert a new value $v$ into a binary search tree $T$, we can use the procedure insert as shown in the following pseudo code. The insert procedure is passed a node $z$ for which $z.key = v$, $z.left = NIL$, and $z.right = NIL$. The procedure modifies $T$ and some of the fields of $z$ in such a way that $z$ is inserted into an appropriate position in the tree.\n\n1 insert(T, z)\n2 y = NIL // parent of x\n3 x = 'the root of T'\n4 while x ≠ NIL\n5 y = x // set the parent\n6 if z.key < x.key\n7 x = x.left // move to the left child\n8 else\n9 x = x.right // move to the right child\n10 z.p = y\n11\n12 if y == NIL // T is empty\n13 'the root of T' = z\n14 else if z.key < y.key\n15 y.left = z // z is the left child of y\n16 else\n17 y.right = z // z is the right child of y\n\nWrite a program which performs the following operations to a binary search tree $T$.\n\ninsert $k$: Insert a node containing $k$ as key into $T$.\n\nprint: Print the keys of the binary search tree by inorder tree walk and preorder tree walk respectively.\n\nYou should use the above pseudo code to implement the insert operation. $T$ is empty at the initial state.\n\nInput\n\nIn the first line, the number of operations $m$ is given. In the following $m$ lines, operations represented by insert $k$ or print are given.\n\nOutput\n\nFor each print operation, print a list of keys obtained by inorder tree walk and preorder tree walk in a line respectively. Put a space character before each key.\n\nConstraints\n\nThe number of operations $\\leq 500,000$\n\nThe number of print operations $\\leq 10$.\n\n$-2,000,000,000 \\leq key \\leq 2,000,000,000$\n\nThe height of the binary tree does not exceed 100 if you employ the above pseudo code.\n\nThe keys in the binary search tree are all different.\n\nSample Input 1\n\n8\ninsert 30\ninsert 88\ninsert 12\ninsert 1\ninsert 20\ninsert 17\ninsert 25\nprint\n\nSample Output 1\n\n1 12 17 20 25 30 88\n30 12 1 20 17 25 88\n\nReference\n\nIntroduction to Algorithms, Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Clifford Stein. The MIT Press.", "sample_input": "8\ninsert 30\ninsert 88\ninsert 12\ninsert 1\ninsert 20\ninsert 17\ninsert 25\nprint\n"}, "reference_outputs": [" 1 12 17 20 25 30 88\n 30 12 1 20 17 25 88\n"], "source_document_id": "p02283", "source_text": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nBinary Search Tree I\n\nSearch trees are data structures that support dynamic set operations including insert, search, delete and so on. Thus a search tree can be used both as a dictionary and as a priority queue.\n\nBinary search tree is one of fundamental search trees. The keys in a binary search tree are always stored in such a way as to satisfy the following binary search tree property:\n\nLet $x$ be a node in a binary search tree. If $y$ is a node in the left subtree of $x$, then $y.key \\leq x.key$. If $y$ is a node in the right subtree of $x$, then $x.key \\leq y.key$.\n\nThe following figure shows an example of the binary search tree.\n\nFor example, keys of nodes which belong to the left sub-tree of the node containing 80 are less than or equal to 80, and keys of nodes which belong to the right sub-tree are more than or equal to 80. The binary search tree property allows us to print out all the keys in the tree in sorted order by an inorder tree walk.\n\nA binary search tree should be implemented in such a way that the binary search tree property continues to hold after modifications by insertions and deletions. A binary search tree can be represented by a linked data structure in which each node is an object. In addition to a key field and satellite data, each node contains fields left, right, and p that point to the nodes corresponding to its left child, its right child, and its parent, respectively.\n\nTo insert a new value $v$ into a binary search tree $T$, we can use the procedure insert as shown in the following pseudo code. The insert procedure is passed a node $z$ for which $z.key = v$, $z.left = NIL$, and $z.right = NIL$. The procedure modifies $T$ and some of the fields of $z$ in such a way that $z$ is inserted into an appropriate position in the tree.\n\n1 insert(T, z)\n2 y = NIL // parent of x\n3 x = 'the root of T'\n4 while x ≠ NIL\n5 y = x // set the parent\n6 if z.key < x.key\n7 x = x.left // move to the left child\n8 else\n9 x = x.right // move to the right child\n10 z.p = y\n11\n12 if y == NIL // T is empty\n13 'the root of T' = z\n14 else if z.key < y.key\n15 y.left = z // z is the left child of y\n16 else\n17 y.right = z // z is the right child of y\n\nWrite a program which performs the following operations to a binary search tree $T$.\n\ninsert $k$: Insert a node containing $k$ as key into $T$.\n\nprint: Print the keys of the binary search tree by inorder tree walk and preorder tree walk respectively.\n\nYou should use the above pseudo code to implement the insert operation. $T$ is empty at the initial state.\n\nInput\n\nIn the first line, the number of operations $m$ is given. In the following $m$ lines, operations represented by insert $k$ or print are given.\n\nOutput\n\nFor each print operation, print a list of keys obtained by inorder tree walk and preorder tree walk in a line respectively. Put a space character before each key.\n\nConstraints\n\nThe number of operations $\\leq 500,000$\n\nThe number of print operations $\\leq 10$.\n\n$-2,000,000,000 \\leq key \\leq 2,000,000,000$\n\nThe height of the binary tree does not exceed 100 if you employ the above pseudo code.\n\nThe keys in the binary search tree are all different.\n\nSample Input 1\n\n8\ninsert 30\ninsert 88\ninsert 12\ninsert 1\ninsert 20\ninsert 17\ninsert 25\nprint\n\nSample Output 1\n\n1 12 17 20 25 30 88\n30 12 1 20 17 25 88\n\nReference\n\nIntroduction to Algorithms, Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Clifford Stein. The MIT Press.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1330, "cpu_time_ms": 780, "memory_kb": 31720}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s541331560", "group_id": "codeNet:p02283", "input_text": "type tree = Nil | Node of int * tree * tree\n\nlet create () = Nil\n\nlet insert x t =\n let rec doit = function\n | Nil -> Node (x, Nil, Nil)\n | Node (y, l, r) when x < y -> Node (y, doit l, r)\n | Node (y, l, r) -> Node (y, l, doit r)\n in doit t\n\nlet preorder f t =\n let rec doit = function\n | Nil -> ()\n | Node (x, l, r) -> (f x; doit l; doit r)\n in doit t\n\nlet inorder f t =\n let rec doit = function\n | Nil -> ()\n | Node (x, l, r) -> (doit l; f x; doit r)\n in doit t\n\nlet print t =\n let f e = print_string \" \"; print_int e in\n inorder f t;\n print_newline ();\n preorder f t;\n print_newline ()\n\nlet split str delim =\n let rec doit s acc =\n match\n try Some (String.rindex s delim) with _ -> None\n with\n | None -> s :: acc\n | Some i ->\n let s1 = String.sub s 0 i in\n doit s1 (String.sub s (i + 1) (String.length s - String.length s1 - 1) :: acc)\n in doit str []\n\nlet () =\n let m = read_int () in\n let rec read i t =\n if i < m then begin\n match split (read_line ()) ' ' with\n | [\"insert\"; n] -> read (i + 1) (insert (int_of_string n) t)\n | _ -> (print t; read (i + 1) t)\n end in\n read 0 (create ())", "language": "OCaml", "metadata": {"date": 1475482633, "filename_ext": "ml", "original_language": "OCaml", "problem_description_relpath": "problem_descriptions/p02283.html", "problem_id": "p02283", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02283/input.txt", "sample_output_relpath": "derived/input_output/data/p02283/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02283/OCaml/s541331560.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s541331560", "user_id": "u809138450"}, "prompt_components": {"gold_output": " 1 12 17 20 25 30 88\n 30 12 1 20 17 25 88\n", "input_to_evaluate": "type tree = Nil | Node of int * tree * tree\n\nlet create () = Nil\n\nlet insert x t =\n let rec doit = function\n | Nil -> Node (x, Nil, Nil)\n | Node (y, l, r) when x < y -> Node (y, doit l, r)\n | Node (y, l, r) -> Node (y, l, doit r)\n in doit t\n\nlet preorder f t =\n let rec doit = function\n | Nil -> ()\n | Node (x, l, r) -> (f x; doit l; doit r)\n in doit t\n\nlet inorder f t =\n let rec doit = function\n | Nil -> ()\n | Node (x, l, r) -> (doit l; f x; doit r)\n in doit t\n\nlet print t =\n let f e = print_string \" \"; print_int e in\n inorder f t;\n print_newline ();\n preorder f t;\n print_newline ()\n\nlet split str delim =\n let rec doit s acc =\n match\n try Some (String.rindex s delim) with _ -> None\n with\n | None -> s :: acc\n | Some i ->\n let s1 = String.sub s 0 i in\n doit s1 (String.sub s (i + 1) (String.length s - String.length s1 - 1) :: acc)\n in doit str []\n\nlet () =\n let m = read_int () in\n let rec read i t =\n if i < m then begin\n match split (read_line ()) ' ' with\n | [\"insert\"; n] -> read (i + 1) (insert (int_of_string n) t)\n | _ -> (print t; read (i + 1) t)\n end in\n read 0 (create ())", "problem_context": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nBinary Search Tree I\n\nSearch trees are data structures that support dynamic set operations including insert, search, delete and so on. Thus a search tree can be used both as a dictionary and as a priority queue.\n\nBinary search tree is one of fundamental search trees. The keys in a binary search tree are always stored in such a way as to satisfy the following binary search tree property:\n\nLet $x$ be a node in a binary search tree. If $y$ is a node in the left subtree of $x$, then $y.key \\leq x.key$. If $y$ is a node in the right subtree of $x$, then $x.key \\leq y.key$.\n\nThe following figure shows an example of the binary search tree.\n\nFor example, keys of nodes which belong to the left sub-tree of the node containing 80 are less than or equal to 80, and keys of nodes which belong to the right sub-tree are more than or equal to 80. The binary search tree property allows us to print out all the keys in the tree in sorted order by an inorder tree walk.\n\nA binary search tree should be implemented in such a way that the binary search tree property continues to hold after modifications by insertions and deletions. A binary search tree can be represented by a linked data structure in which each node is an object. In addition to a key field and satellite data, each node contains fields left, right, and p that point to the nodes corresponding to its left child, its right child, and its parent, respectively.\n\nTo insert a new value $v$ into a binary search tree $T$, we can use the procedure insert as shown in the following pseudo code. The insert procedure is passed a node $z$ for which $z.key = v$, $z.left = NIL$, and $z.right = NIL$. The procedure modifies $T$ and some of the fields of $z$ in such a way that $z$ is inserted into an appropriate position in the tree.\n\n1 insert(T, z)\n2 y = NIL // parent of x\n3 x = 'the root of T'\n4 while x ≠ NIL\n5 y = x // set the parent\n6 if z.key < x.key\n7 x = x.left // move to the left child\n8 else\n9 x = x.right // move to the right child\n10 z.p = y\n11\n12 if y == NIL // T is empty\n13 'the root of T' = z\n14 else if z.key < y.key\n15 y.left = z // z is the left child of y\n16 else\n17 y.right = z // z is the right child of y\n\nWrite a program which performs the following operations to a binary search tree $T$.\n\ninsert $k$: Insert a node containing $k$ as key into $T$.\n\nprint: Print the keys of the binary search tree by inorder tree walk and preorder tree walk respectively.\n\nYou should use the above pseudo code to implement the insert operation. $T$ is empty at the initial state.\n\nInput\n\nIn the first line, the number of operations $m$ is given. In the following $m$ lines, operations represented by insert $k$ or print are given.\n\nOutput\n\nFor each print operation, print a list of keys obtained by inorder tree walk and preorder tree walk in a line respectively. Put a space character before each key.\n\nConstraints\n\nThe number of operations $\\leq 500,000$\n\nThe number of print operations $\\leq 10$.\n\n$-2,000,000,000 \\leq key \\leq 2,000,000,000$\n\nThe height of the binary tree does not exceed 100 if you employ the above pseudo code.\n\nThe keys in the binary search tree are all different.\n\nSample Input 1\n\n8\ninsert 30\ninsert 88\ninsert 12\ninsert 1\ninsert 20\ninsert 17\ninsert 25\nprint\n\nSample Output 1\n\n1 12 17 20 25 30 88\n30 12 1 20 17 25 88\n\nReference\n\nIntroduction to Algorithms, Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Clifford Stein. The MIT Press.", "sample_input": "8\ninsert 30\ninsert 88\ninsert 12\ninsert 1\ninsert 20\ninsert 17\ninsert 25\nprint\n"}, "reference_outputs": [" 1 12 17 20 25 30 88\n 30 12 1 20 17 25 88\n"], "source_document_id": "p02283", "source_text": "MathJax.Hub.Config({ tex2jax: { inlineMath: [[\"$\",\"$\"], [\"\\\\(\",\"\\\\)\"]], processEscapes: true }});\n\nBinary Search Tree I\n\nSearch trees are data structures that support dynamic set operations including insert, search, delete and so on. Thus a search tree can be used both as a dictionary and as a priority queue.\n\nBinary search tree is one of fundamental search trees. The keys in a binary search tree are always stored in such a way as to satisfy the following binary search tree property:\n\nLet $x$ be a node in a binary search tree. If $y$ is a node in the left subtree of $x$, then $y.key \\leq x.key$. If $y$ is a node in the right subtree of $x$, then $x.key \\leq y.key$.\n\nThe following figure shows an example of the binary search tree.\n\nFor example, keys of nodes which belong to the left sub-tree of the node containing 80 are less than or equal to 80, and keys of nodes which belong to the right sub-tree are more than or equal to 80. The binary search tree property allows us to print out all the keys in the tree in sorted order by an inorder tree walk.\n\nA binary search tree should be implemented in such a way that the binary search tree property continues to hold after modifications by insertions and deletions. A binary search tree can be represented by a linked data structure in which each node is an object. In addition to a key field and satellite data, each node contains fields left, right, and p that point to the nodes corresponding to its left child, its right child, and its parent, respectively.\n\nTo insert a new value $v$ into a binary search tree $T$, we can use the procedure insert as shown in the following pseudo code. The insert procedure is passed a node $z$ for which $z.key = v$, $z.left = NIL$, and $z.right = NIL$. The procedure modifies $T$ and some of the fields of $z$ in such a way that $z$ is inserted into an appropriate position in the tree.\n\n1 insert(T, z)\n2 y = NIL // parent of x\n3 x = 'the root of T'\n4 while x ≠ NIL\n5 y = x // set the parent\n6 if z.key < x.key\n7 x = x.left // move to the left child\n8 else\n9 x = x.right // move to the right child\n10 z.p = y\n11\n12 if y == NIL // T is empty\n13 'the root of T' = z\n14 else if z.key < y.key\n15 y.left = z // z is the left child of y\n16 else\n17 y.right = z // z is the right child of y\n\nWrite a program which performs the following operations to a binary search tree $T$.\n\ninsert $k$: Insert a node containing $k$ as key into $T$.\n\nprint: Print the keys of the binary search tree by inorder tree walk and preorder tree walk respectively.\n\nYou should use the above pseudo code to implement the insert operation. $T$ is empty at the initial state.\n\nInput\n\nIn the first line, the number of operations $m$ is given. In the following $m$ lines, operations represented by insert $k$ or print are given.\n\nOutput\n\nFor each print operation, print a list of keys obtained by inorder tree walk and preorder tree walk in a line respectively. Put a space character before each key.\n\nConstraints\n\nThe number of operations $\\leq 500,000$\n\nThe number of print operations $\\leq 10$.\n\n$-2,000,000,000 \\leq key \\leq 2,000,000,000$\n\nThe height of the binary tree does not exceed 100 if you employ the above pseudo code.\n\nThe keys in the binary search tree are all different.\n\nSample Input 1\n\n8\ninsert 30\ninsert 88\ninsert 12\ninsert 1\ninsert 20\ninsert 17\ninsert 25\nprint\n\nSample Output 1\n\n1 12 17 20 25 30 88\n30 12 1 20 17 25 88\n\nReference\n\nIntroduction to Algorithms, Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Clifford Stein. The MIT Press.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1179, "cpu_time_ms": 930, "memory_kb": 31856}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s884647327", "group_id": "codeNet:p02284", "input_text": "type tree = Nil | Node of int * tree * tree\n\nlet create () = Nil\n\nlet insert x t =\n let rec doit = function\n | Nil -> Node (x, Nil, Nil)\n | Node (y, l, r) when x < y -> Node (y, doit l, r)\n | Node (y, l, r) -> Node (y, l, doit r)\n in doit t\n\nlet preorder f t =\n let rec doit = function\n | Nil -> ()\n | Node (x, l, r) -> (f x; doit l; doit r)\n in doit t\n\nlet inorder f t =\n let rec doit = function\n | Nil -> ()\n | Node (x, l, r) -> (doit l; f x; doit r)\n in doit t\n\nlet print t =\n let f e = print_string \" \"; print_int e in\n inorder f t;\n print_newline ();\n preorder f t;\n print_newline ()\n\nlet find x t =\n let rec doit = function\n | Nil -> false\n | Node (y, _, _) when x = y -> true\n | Node (y, l, _) when x < y -> doit l\n | Node (_, _, r) -> doit r\n in doit t\n\nlet split str delim =\n let open String in\n let rec doit s acc =\n match\n try Some (rindex s delim) with _ -> None\n with\n | None -> s :: acc\n | Some i ->\n let s1 = sub s 0 i in\n doit s1 (sub s (i + 1) (length s - length s1 - 1) :: acc)\n in doit str []\n\nlet () =\n let m = read_int () in\n let rec read i t =\n if i < m then begin\n match split (read_line ()) ' ' with\n | [\"insert\"; n] -> read (i + 1) (insert (int_of_string n) t)\n | [\"find\"; n] -> (print_endline (if find (int_of_string n) t then \"yes\" else \"no\"); read (i + 1) t)\n | _ -> (print t; read (i + 1) t)\n end in\n read 0 (create ())", "language": "OCaml", "metadata": {"date": 1475484472, "filename_ext": "ml", "original_language": "OCaml", "problem_description_relpath": "problem_descriptions/p02284.html", "problem_id": "p02284", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02284/input.txt", "sample_output_relpath": "derived/input_output/data/p02284/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02284/OCaml/s884647327.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s884647327", "user_id": "u809138450"}, "prompt_components": {"gold_output": "yes\nno\n 1 12 17 20 25 30 88\n 30 12 1 20 17 25 88\n", "input_to_evaluate": "type tree = Nil | Node of int * tree * tree\n\nlet create () = Nil\n\nlet insert x t =\n let rec doit = function\n | Nil -> Node (x, Nil, Nil)\n | Node (y, l, r) when x < y -> Node (y, doit l, r)\n | Node (y, l, r) -> Node (y, l, doit r)\n in doit t\n\nlet preorder f t =\n let rec doit = function\n | Nil -> ()\n | Node (x, l, r) -> (f x; doit l; doit r)\n in doit t\n\nlet inorder f t =\n let rec doit = function\n | Nil -> ()\n | Node (x, l, r) -> (doit l; f x; doit r)\n in doit t\n\nlet print t =\n let f e = print_string \" \"; print_int e in\n inorder f t;\n print_newline ();\n preorder f t;\n print_newline ()\n\nlet find x t =\n let rec doit = function\n | Nil -> false\n | Node (y, _, _) when x = y -> true\n | Node (y, l, _) when x < y -> doit l\n | Node (_, _, r) -> doit r\n in doit t\n\nlet split str delim =\n let open String in\n let rec doit s acc =\n match\n try Some (rindex s delim) with _ -> None\n with\n | None -> s :: acc\n | Some i ->\n let s1 = sub s 0 i in\n doit s1 (sub s (i + 1) (length s - length s1 - 1) :: acc)\n in doit str []\n\nlet () =\n let m = read_int () in\n let rec read i t =\n if i < m then begin\n match split (read_line ()) ' ' with\n | [\"insert\"; n] -> read (i + 1) (insert (int_of_string n) t)\n | [\"find\"; n] -> (print_endline (if find (int_of_string n) t then \"yes\" else \"no\"); read (i + 1) t)\n | _ -> (print t; read (i + 1) t)\n end in\n read 0 (create ())", "problem_context": "Binary Search Tree II\n\nWrite a program which performs the following operations to a binary search tree $T$ by adding the find operation to A: Binary Search Tree I.\n\ninsert $k$: Insert a node containing $k$ as key into $T$.\n\nfind $k$: Report whether $T$ has a node containing $k$.\n\nprint: Print the keys of the binary search tree by inorder tree walk and preorder tree walk respectively.\n\nInput\n\nIn the first line, the number of operations $m$ is given. In the following $m$ lines, operations represented by insert $k$, find $k$ or print are given.\n\nOutput\n\nFor each find $k$ operation, print \"yes\" if $T$ has a node containing $k$, \"no\" if not.\n\nIn addition, for each print operation, print a list of keys obtained by inorder tree walk and preorder tree walk in a line respectively. Put a space character before each key.\n\nConstraints\n\nThe number of operations $\\leq 500,000$\n\nThe number of print operations $\\leq 10$.\n\n$-2,000,000,000 \\leq key \\leq 2,000,000,000$\n\nThe height of the binary tree does not exceed 100 if you employ the above pseudo code.\n\nThe keys in the binary search tree are all different.\n\nSample Input 1\n\n10\ninsert 30\ninsert 88\ninsert 12\ninsert 1\ninsert 20\nfind 12\ninsert 17\ninsert 25\nfind 16\nprint\n\nSample Output 1\n\nyes\nno\n1 12 17 20 25 30 88\n30 12 1 20 17 25 88\n\nReference\n\nIntroduction to Algorithms, Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Clifford Stein. The MIT Press.", "sample_input": "10\ninsert 30\ninsert 88\ninsert 12\ninsert 1\ninsert 20\nfind 12\ninsert 17\ninsert 25\nfind 16\nprint\n"}, "reference_outputs": ["yes\nno\n 1 12 17 20 25 30 88\n 30 12 1 20 17 25 88\n"], "source_document_id": "p02284", "source_text": "Binary Search Tree II\n\nWrite a program which performs the following operations to a binary search tree $T$ by adding the find operation to A: Binary Search Tree I.\n\ninsert $k$: Insert a node containing $k$ as key into $T$.\n\nfind $k$: Report whether $T$ has a node containing $k$.\n\nprint: Print the keys of the binary search tree by inorder tree walk and preorder tree walk respectively.\n\nInput\n\nIn the first line, the number of operations $m$ is given. In the following $m$ lines, operations represented by insert $k$, find $k$ or print are given.\n\nOutput\n\nFor each find $k$ operation, print \"yes\" if $T$ has a node containing $k$, \"no\" if not.\n\nIn addition, for each print operation, print a list of keys obtained by inorder tree walk and preorder tree walk in a line respectively. Put a space character before each key.\n\nConstraints\n\nThe number of operations $\\leq 500,000$\n\nThe number of print operations $\\leq 10$.\n\n$-2,000,000,000 \\leq key \\leq 2,000,000,000$\n\nThe height of the binary tree does not exceed 100 if you employ the above pseudo code.\n\nThe keys in the binary search tree are all different.\n\nSample Input 1\n\n10\ninsert 30\ninsert 88\ninsert 12\ninsert 1\ninsert 20\nfind 12\ninsert 17\ninsert 25\nfind 16\nprint\n\nSample Output 1\n\nyes\nno\n1 12 17 20 25 30 88\n30 12 1 20 17 25 88\n\nReference\n\nIntroduction to Algorithms, Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Clifford Stein. The MIT Press.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1457, "cpu_time_ms": 710, "memory_kb": 25060}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s756086354", "group_id": "codeNet:p02284", "input_text": "open Str\n\ntype btree = Node of node | Nil and\n node = {k : int; l : btree; r : btree}\n\nlet preorder f tr =\n let rec iter = function\n Nil -> ()\n | Node n -> f n.k; iter n.l; iter n.r\n in iter tr; print_newline ()\n \nlet inorder f tr =\n let rec iter = function\n Nil -> ()\n | Node n -> iter n.l; f n.k; iter n.r\n in iter tr; print_newline ()\n\nlet insert k tr =\n let rec iter = function\n Nil -> Node {k = k; l = Nil; r = Nil}\n | Node n -> if n.k = k then Node n\n else if n.k < k then Node {n with r = iter n.r}\n else Node {n with l = iter n.l}\n in iter tr\n\nlet find k tr =\n let rec iter = function\n Nil -> \"no\"\n | Node n -> if n.k = k then \"yes\"\n else if n.k < k then iter n.r\n else iter n.l\n in iter tr\n\nlet read_list () =\n split (regexp \" +\") (read_line ())\n\nlet () =\n let n = read_int () in\n let rec read tr x =\n if x = 0 then ()\n else match read_list () with\n \"print\" :: _ -> begin\n inorder (fun i -> print_string @@ \" \" ^ (string_of_int i)) tr;\n preorder (fun i -> print_string @@ \" \" ^ (string_of_int i)) tr;\n read tr (x-1)\n end\n | \"insert\" :: ns :: _ -> read (insert (int_of_string ns) tr) (x-1)\n | \"find\" :: ns :: _ -> begin\n find (int_of_string ns) tr |> print_endline;\n read tr (x-1)\n end\n | _ -> failwith \"read\"\n in\n read Nil n", "language": "OCaml", "metadata": {"date": 1500288777, "filename_ext": "ml", "original_language": "OCaml", "problem_description_relpath": "problem_descriptions/p02284.html", "problem_id": "p02284", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02284/input.txt", "sample_output_relpath": "derived/input_output/data/p02284/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02284/OCaml/s756086354.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s756086354", "user_id": "u049242937"}, "prompt_components": {"gold_output": "yes\nno\n 1 12 17 20 25 30 88\n 30 12 1 20 17 25 88\n", "input_to_evaluate": "open Str\n\ntype btree = Node of node | Nil and\n node = {k : int; l : btree; r : btree}\n\nlet preorder f tr =\n let rec iter = function\n Nil -> ()\n | Node n -> f n.k; iter n.l; iter n.r\n in iter tr; print_newline ()\n \nlet inorder f tr =\n let rec iter = function\n Nil -> ()\n | Node n -> iter n.l; f n.k; iter n.r\n in iter tr; print_newline ()\n\nlet insert k tr =\n let rec iter = function\n Nil -> Node {k = k; l = Nil; r = Nil}\n | Node n -> if n.k = k then Node n\n else if n.k < k then Node {n with r = iter n.r}\n else Node {n with l = iter n.l}\n in iter tr\n\nlet find k tr =\n let rec iter = function\n Nil -> \"no\"\n | Node n -> if n.k = k then \"yes\"\n else if n.k < k then iter n.r\n else iter n.l\n in iter tr\n\nlet read_list () =\n split (regexp \" +\") (read_line ())\n\nlet () =\n let n = read_int () in\n let rec read tr x =\n if x = 0 then ()\n else match read_list () with\n \"print\" :: _ -> begin\n inorder (fun i -> print_string @@ \" \" ^ (string_of_int i)) tr;\n preorder (fun i -> print_string @@ \" \" ^ (string_of_int i)) tr;\n read tr (x-1)\n end\n | \"insert\" :: ns :: _ -> read (insert (int_of_string ns) tr) (x-1)\n | \"find\" :: ns :: _ -> begin\n find (int_of_string ns) tr |> print_endline;\n read tr (x-1)\n end\n | _ -> failwith \"read\"\n in\n read Nil n", "problem_context": "Binary Search Tree II\n\nWrite a program which performs the following operations to a binary search tree $T$ by adding the find operation to A: Binary Search Tree I.\n\ninsert $k$: Insert a node containing $k$ as key into $T$.\n\nfind $k$: Report whether $T$ has a node containing $k$.\n\nprint: Print the keys of the binary search tree by inorder tree walk and preorder tree walk respectively.\n\nInput\n\nIn the first line, the number of operations $m$ is given. In the following $m$ lines, operations represented by insert $k$, find $k$ or print are given.\n\nOutput\n\nFor each find $k$ operation, print \"yes\" if $T$ has a node containing $k$, \"no\" if not.\n\nIn addition, for each print operation, print a list of keys obtained by inorder tree walk and preorder tree walk in a line respectively. Put a space character before each key.\n\nConstraints\n\nThe number of operations $\\leq 500,000$\n\nThe number of print operations $\\leq 10$.\n\n$-2,000,000,000 \\leq key \\leq 2,000,000,000$\n\nThe height of the binary tree does not exceed 100 if you employ the above pseudo code.\n\nThe keys in the binary search tree are all different.\n\nSample Input 1\n\n10\ninsert 30\ninsert 88\ninsert 12\ninsert 1\ninsert 20\nfind 12\ninsert 17\ninsert 25\nfind 16\nprint\n\nSample Output 1\n\nyes\nno\n1 12 17 20 25 30 88\n30 12 1 20 17 25 88\n\nReference\n\nIntroduction to Algorithms, Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Clifford Stein. The MIT Press.", "sample_input": "10\ninsert 30\ninsert 88\ninsert 12\ninsert 1\ninsert 20\nfind 12\ninsert 17\ninsert 25\nfind 16\nprint\n"}, "reference_outputs": ["yes\nno\n 1 12 17 20 25 30 88\n 30 12 1 20 17 25 88\n"], "source_document_id": "p02284", "source_text": "Binary Search Tree II\n\nWrite a program which performs the following operations to a binary search tree $T$ by adding the find operation to A: Binary Search Tree I.\n\ninsert $k$: Insert a node containing $k$ as key into $T$.\n\nfind $k$: Report whether $T$ has a node containing $k$.\n\nprint: Print the keys of the binary search tree by inorder tree walk and preorder tree walk respectively.\n\nInput\n\nIn the first line, the number of operations $m$ is given. In the following $m$ lines, operations represented by insert $k$, find $k$ or print are given.\n\nOutput\n\nFor each find $k$ operation, print \"yes\" if $T$ has a node containing $k$, \"no\" if not.\n\nIn addition, for each print operation, print a list of keys obtained by inorder tree walk and preorder tree walk in a line respectively. Put a space character before each key.\n\nConstraints\n\nThe number of operations $\\leq 500,000$\n\nThe number of print operations $\\leq 10$.\n\n$-2,000,000,000 \\leq key \\leq 2,000,000,000$\n\nThe height of the binary tree does not exceed 100 if you employ the above pseudo code.\n\nThe keys in the binary search tree are all different.\n\nSample Input 1\n\n10\ninsert 30\ninsert 88\ninsert 12\ninsert 1\ninsert 20\nfind 12\ninsert 17\ninsert 25\nfind 16\nprint\n\nSample Output 1\n\nyes\nno\n1 12 17 20 25 30 88\n30 12 1 20 17 25 88\n\nReference\n\nIntroduction to Algorithms, Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Clifford Stein. The MIT Press.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1610, "memory_kb": 37336}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s398867413", "group_id": "codeNet:p02285", "input_text": "type tree = Nil | Node of int * tree * tree\n\nlet create () = Nil\n\nlet insert x t =\n let rec doit = function\n | Nil -> Node (x, Nil, Nil)\n | Node (y, l, r) when x < y -> Node (y, doit l, r)\n | Node (y, l, r) -> Node (y, l, doit r)\n in doit t\n\nlet preorder f t =\n let rec doit = function\n | Nil -> ()\n | Node (x, l, r) -> (f x; doit l; doit r)\n in doit t\n\nlet inorder f t =\n let rec doit = function\n | Nil -> ()\n | Node (x, l, r) -> (doit l; f x; doit r)\n in doit t\n\nlet print t =\n let f e = print_string \" \"; print_int e in\n inorder f t;\n print_newline ();\n preorder f t;\n print_newline ()\n\nlet find x t =\n let rec doit = function\n | Nil -> false\n | Node (y, _, _) when x = y -> true\n | Node (y, l, _) when x < y -> doit l\n | Node (_, _, r) -> doit r\n in doit t\n\nlet delete x t =\n let rec dudu = function\n | Nil -> exit 1\n | Node (x, Nil, _) -> x\n | Node (_, l, _) -> dudu l\n and wa = function\n | Nil -> exit 1\n | Node (_, Nil, r) -> r\n | Node (x, l, r) -> Node (x, wa l, r)\n and doit = function\n | Nil -> exit 1\n | Node (y, l, r) when x = y ->\n if l = Nil then r\n else if r = Nil then l\n else Node (dudu r, l, wa r)\n | Node (y, l, r) when x < y -> Node (y, doit l, r)\n | Node (y, l, r) -> Node (y, l, doit r)\n in doit t\n\nlet split str delim =\n let open String in\n let rec doit s acc =\n match\n try Some (rindex s delim) with _ -> None\n with\n | None -> s :: acc\n | Some i ->\n let s1 = sub s 0 i in\n doit s1 (sub s (i + 1) (length s - length s1 - 1) :: acc)\n in doit str []\n\nlet () =\n let m = read_int () in\n let rec read i t =\n if i < m then begin\n match split (read_line ()) ' ' with\n | [\"insert\"; n] -> read (i + 1) (insert (int_of_string n) t)\n | [\"find\"; n] -> (print_endline (if find (int_of_string n) t then \"yes\" else \"no\"); read (i + 1) t)\n | [\"delete\"; n] -> read (i + 1) (delete (int_of_string n) t)\n | _ -> (print t; read (i + 1) t)\n end in\n read 0 (create ())", "language": "OCaml", "metadata": {"date": 1475484724, "filename_ext": "ml", "original_language": "OCaml", "problem_description_relpath": "problem_descriptions/p02285.html", "problem_id": "p02285", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02285/input.txt", "sample_output_relpath": "derived/input_output/data/p02285/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02285/OCaml/s398867413.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s398867413", "user_id": "u809138450"}, "prompt_components": {"gold_output": "yes\nyes\nyes\nno\nno\nno\nyes\nyes\n 1 2 3 7 8 22\n 8 2 1 3 7 22\n 1 2 8 22\n 8 2 1 22\n", "input_to_evaluate": "type tree = Nil | Node of int * tree * tree\n\nlet create () = Nil\n\nlet insert x t =\n let rec doit = function\n | Nil -> Node (x, Nil, Nil)\n | Node (y, l, r) when x < y -> Node (y, doit l, r)\n | Node (y, l, r) -> Node (y, l, doit r)\n in doit t\n\nlet preorder f t =\n let rec doit = function\n | Nil -> ()\n | Node (x, l, r) -> (f x; doit l; doit r)\n in doit t\n\nlet inorder f t =\n let rec doit = function\n | Nil -> ()\n | Node (x, l, r) -> (doit l; f x; doit r)\n in doit t\n\nlet print t =\n let f e = print_string \" \"; print_int e in\n inorder f t;\n print_newline ();\n preorder f t;\n print_newline ()\n\nlet find x t =\n let rec doit = function\n | Nil -> false\n | Node (y, _, _) when x = y -> true\n | Node (y, l, _) when x < y -> doit l\n | Node (_, _, r) -> doit r\n in doit t\n\nlet delete x t =\n let rec dudu = function\n | Nil -> exit 1\n | Node (x, Nil, _) -> x\n | Node (_, l, _) -> dudu l\n and wa = function\n | Nil -> exit 1\n | Node (_, Nil, r) -> r\n | Node (x, l, r) -> Node (x, wa l, r)\n and doit = function\n | Nil -> exit 1\n | Node (y, l, r) when x = y ->\n if l = Nil then r\n else if r = Nil then l\n else Node (dudu r, l, wa r)\n | Node (y, l, r) when x < y -> Node (y, doit l, r)\n | Node (y, l, r) -> Node (y, l, doit r)\n in doit t\n\nlet split str delim =\n let open String in\n let rec doit s acc =\n match\n try Some (rindex s delim) with _ -> None\n with\n | None -> s :: acc\n | Some i ->\n let s1 = sub s 0 i in\n doit s1 (sub s (i + 1) (length s - length s1 - 1) :: acc)\n in doit str []\n\nlet () =\n let m = read_int () in\n let rec read i t =\n if i < m then begin\n match split (read_line ()) ' ' with\n | [\"insert\"; n] -> read (i + 1) (insert (int_of_string n) t)\n | [\"find\"; n] -> (print_endline (if find (int_of_string n) t then \"yes\" else \"no\"); read (i + 1) t)\n | [\"delete\"; n] -> read (i + 1) (delete (int_of_string n) t)\n | _ -> (print t; read (i + 1) t)\n end in\n read 0 (create ())", "problem_context": "Binary Search Tree III\n\nWrite a program which performs the following operations to a binary search tree $T$ by adding delete operation to B: Binary Search Tree II.\n\ninsert $k$: Insert a node containing $k$ as key into $T$.\n\nfind $k$: Report whether $T$ has a node containing $k$.\n\ndelete $k$: Delete a node containing $k$.\n\nprint: Print the keys of the binary search tree by inorder tree walk and preorder tree walk respectively.\n\nThe operation delete $k$ for deleting a given node $z$ containing key $k$ from $T$ can be implemented by an algorithm which considers the following cases:\n\nIf $z$ has no children, we modify its parent $z.p$ to replace $z$ with NIL as its child (delete $z$).\n\nIf $z$ has only a single child, we \"splice out\" $z$ by making a new link between its child and its parent.\n\nIf $z$ has two children, we splice out $z$'s successor $y$ and replace $z$'s key with $y$'s key.\n\nInput\n\nIn the first line, the number of operations $m$ is given. In the following $m$ lines, operations represented by insert $k$, find $k$, delete $k$ or print are given.\n\nOutput\n\nFor each find $k$ operation, print \"yes\" if $T$ has a node containing $k$, \"no\" if not.\n\nIn addition, for each print operation, print a list of keys obtained by inorder tree walk and preorder tree walk in a line respectively. Put a space character before each key\n\nConstraints\n\nThe number of operations $\\leq 500,000$\n\nThe number of print operations $\\leq 10$.\n\n$-2,000,000,000 \\leq key \\leq 2,000,000,000$\n\nThe height of the binary tree does not exceed 100 if you employ the above pseudo code.\n\nThe keys in the binary search tree are all different.\n\nSample Input 1\n\n18\ninsert 8\ninsert 2\ninsert 3\ninsert 7\ninsert 22\ninsert 1\nfind 1\nfind 2\nfind 3\nfind 4\nfind 5\nfind 6\nfind 7\nfind 8\nprint\ndelete 3\ndelete 7\nprint\n\nSample Output 1\n\nyes\nyes\nyes\nno\nno\nno\nyes\nyes\n1 2 3 7 8 22\n8 2 1 3 7 22\n1 2 8 22\n8 2 1 22\n\nReference\n\nIntroduction to Algorithms, Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Clifford Stein. The MIT Press.", "sample_input": "18\ninsert 8\ninsert 2\ninsert 3\ninsert 7\ninsert 22\ninsert 1\nfind 1\nfind 2\nfind 3\nfind 4\nfind 5\nfind 6\nfind 7\nfind 8\nprint\ndelete 3\ndelete 7\nprint\n"}, "reference_outputs": ["yes\nyes\nyes\nno\nno\nno\nyes\nyes\n 1 2 3 7 8 22\n 8 2 1 3 7 22\n 1 2 8 22\n 8 2 1 22\n"], "source_document_id": "p02285", "source_text": "Binary Search Tree III\n\nWrite a program which performs the following operations to a binary search tree $T$ by adding delete operation to B: Binary Search Tree II.\n\ninsert $k$: Insert a node containing $k$ as key into $T$.\n\nfind $k$: Report whether $T$ has a node containing $k$.\n\ndelete $k$: Delete a node containing $k$.\n\nprint: Print the keys of the binary search tree by inorder tree walk and preorder tree walk respectively.\n\nThe operation delete $k$ for deleting a given node $z$ containing key $k$ from $T$ can be implemented by an algorithm which considers the following cases:\n\nIf $z$ has no children, we modify its parent $z.p$ to replace $z$ with NIL as its child (delete $z$).\n\nIf $z$ has only a single child, we \"splice out\" $z$ by making a new link between its child and its parent.\n\nIf $z$ has two children, we splice out $z$'s successor $y$ and replace $z$'s key with $y$'s key.\n\nInput\n\nIn the first line, the number of operations $m$ is given. In the following $m$ lines, operations represented by insert $k$, find $k$, delete $k$ or print are given.\n\nOutput\n\nFor each find $k$ operation, print \"yes\" if $T$ has a node containing $k$, \"no\" if not.\n\nIn addition, for each print operation, print a list of keys obtained by inorder tree walk and preorder tree walk in a line respectively. Put a space character before each key\n\nConstraints\n\nThe number of operations $\\leq 500,000$\n\nThe number of print operations $\\leq 10$.\n\n$-2,000,000,000 \\leq key \\leq 2,000,000,000$\n\nThe height of the binary tree does not exceed 100 if you employ the above pseudo code.\n\nThe keys in the binary search tree are all different.\n\nSample Input 1\n\n18\ninsert 8\ninsert 2\ninsert 3\ninsert 7\ninsert 22\ninsert 1\nfind 1\nfind 2\nfind 3\nfind 4\nfind 5\nfind 6\nfind 7\nfind 8\nprint\ndelete 3\ndelete 7\nprint\n\nSample Output 1\n\nyes\nyes\nyes\nno\nno\nno\nyes\nyes\n1 2 3 7 8 22\n8 2 1 3 7 22\n1 2 8 22\n8 2 1 22\n\nReference\n\nIntroduction to Algorithms, Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Clifford Stein. The MIT Press.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2028, "cpu_time_ms": 740, "memory_kb": 25252}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s036839774", "group_id": "codeNet:p02289", "input_text": "let last_i = ref 0\n\nlet parent i = int_of_float (floor (float_of_int i) /. 2.)\n\nlet left i = 2*i\n\nlet right i = 2*i + 1\n\nlet extract (t : int array) =\n let rec max_heapify i =\n let l = left i in\n let r = right i in\n let m = if l <= !last_i && t.(l) > t.(i) then l else i in\n let m = if r <= !last_i && t.(r) > t.(m) then r else m in\n if i = m then ()\n else begin\n let tmp = t.(i) in\n t.(i) <- t.(m);\n t.(m) <- tmp;\n max_heapify m\n end in\n let ret = t.(1) in\n t.(1) <- t.(!last_i);\n decr last_i;\n max_heapify 1;\n ret\n\nlet insert x (t : int array) =\n let rec doit i =\n let p = parent i in\n if i <= 1 || t.(p) >= t.(i) then ()\n else begin\n let tmp = t.(i) in\n t.(i) <- t.(p);\n t.(p) <- tmp;\n doit p\n end in\n incr last_i;\n t.(!last_i) <- x;\n doit !last_i\n\nlet () =\n let t = Array.make 2000001 0 in\n let rec doit () =\n let op = Scanf.scanf \"%s \" (fun i -> i) in\n if op = \"end\" then ()\n else if op = \"extract\" then begin\n extract t |> Printf.printf \"%d\\n\";\n doit ()\n end else begin\n insert (Scanf.scanf \"%d \" (fun i -> i)) t;\n doit ()\n end in\n doit ()", "language": "OCaml", "metadata": {"date": 1500099285, "filename_ext": "ml", "original_language": "OCaml", "problem_description_relpath": "problem_descriptions/p02289.html", "problem_id": "p02289", "resource_group": "low_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/OCaml/s036839774.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s036839774", "user_id": "u809138450"}, "prompt_components": {"gold_output": "8\n10\n11\n2\n", "input_to_evaluate": "let last_i = ref 0\n\nlet parent i = int_of_float (floor (float_of_int i) /. 2.)\n\nlet left i = 2*i\n\nlet right i = 2*i + 1\n\nlet extract (t : int array) =\n let rec max_heapify i =\n let l = left i in\n let r = right i in\n let m = if l <= !last_i && t.(l) > t.(i) then l else i in\n let m = if r <= !last_i && t.(r) > t.(m) then r else m in\n if i = m then ()\n else begin\n let tmp = t.(i) in\n t.(i) <- t.(m);\n t.(m) <- tmp;\n max_heapify m\n end in\n let ret = t.(1) in\n t.(1) <- t.(!last_i);\n decr last_i;\n max_heapify 1;\n ret\n\nlet insert x (t : int array) =\n let rec doit i =\n let p = parent i in\n if i <= 1 || t.(p) >= t.(i) then ()\n else begin\n let tmp = t.(i) in\n t.(i) <- t.(p);\n t.(p) <- tmp;\n doit p\n end in\n incr last_i;\n t.(!last_i) <- x;\n doit !last_i\n\nlet () =\n let t = Array.make 2000001 0 in\n let rec doit () =\n let op = Scanf.scanf \"%s \" (fun i -> i) in\n if op = \"end\" then ()\n else if op = \"extract\" then begin\n extract t |> Printf.printf \"%d\\n\";\n doit ()\n end else begin\n insert (Scanf.scanf \"%d \" (fun i -> i)) t;\n doit ()\n end in\n doit ()", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1166, "cpu_time_ms": 700, "memory_kb": 20332}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s026718148", "group_id": "codeNet:p02314", "input_text": "let solve c n m =\n let dp = Array.make_matrix (m + 1) (n + 1) max_int in\n for i = 1 to m do dp.(i).(0) <- 0 done;\n for i = 1 to m do\n for j = 1 to n do\n dp.(i).(j) <-\n if j - c.(i-1) < 0 then dp.(i-1).(j)\n else min dp.(i-1).(j) (dp.(i).(j - c.(i-1)) + 1)\n done\n done;\n dp.(m).(n)\n\nlet () =\n let n, m = Scanf.scanf \"%d %d \" (fun n m -> n, m) in\n let c = Array.init m (fun _ -> Scanf.scanf \"%d \" (fun i -> i)) in\n solve c n m |> Printf.printf \"%d\\n\"", "language": "OCaml", "metadata": {"date": 1501557287, "filename_ext": "ml", "original_language": "OCaml", "problem_description_relpath": "problem_descriptions/p02314.html", "problem_id": "p02314", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02314/input.txt", "sample_output_relpath": "derived/input_output/data/p02314/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02314/OCaml/s026718148.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s026718148", "user_id": "u809138450"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "let solve c n m =\n let dp = Array.make_matrix (m + 1) (n + 1) max_int in\n for i = 1 to m do dp.(i).(0) <- 0 done;\n for i = 1 to m do\n for j = 1 to n do\n dp.(i).(j) <-\n if j - c.(i-1) < 0 then dp.(i-1).(j)\n else min dp.(i-1).(j) (dp.(i).(j - c.(i-1)) + 1)\n done\n done;\n dp.(m).(n)\n\nlet () =\n let n, m = Scanf.scanf \"%d %d \" (fun n m -> n, m) in\n let c = Array.init m (fun _ -> Scanf.scanf \"%d \" (fun i -> i)) in\n solve c n m |> Printf.printf \"%d\\n\"", "problem_context": "Coin Changing Problem\n\nFind the minimum number of coins to make change for n cents using coins of denominations d1, d2,.., dm. The coins can be used any number of times.\n\nInput\n\nn m\nd1 d2 ... dm\n\nTwo integers n and m are given in the first line. The available denominations are given in the second line.\n\nOutput\n\nPrint the minimum number of coins in a line.\n\nConstraints\n\n1 ≤ n ≤ 50000\n\n1 ≤ m ≤ 20\n\n1 ≤ denomination ≤ 10000\n\nThe denominations are all different and contain 1.\n\nSample Input 1\n\n55 4\n1 5 10 50\n\nSample Output 1\n\n2\n\nSample Input 2\n\n15 6\n1 2 7 8 12 50\n\nSample Output 2\n\n2\n\nSample Input 3\n\n65 6\n1 2 7 8 12 50\n\nSample Output 3\n\n3", "sample_input": "55 4\n1 5 10 50\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02314", "source_text": "Coin Changing Problem\n\nFind the minimum number of coins to make change for n cents using coins of denominations d1, d2,.., dm. The coins can be used any number of times.\n\nInput\n\nn m\nd1 d2 ... dm\n\nTwo integers n and m are given in the first line. The available denominations are given in the second line.\n\nOutput\n\nPrint the minimum number of coins in a line.\n\nConstraints\n\n1 ≤ n ≤ 50000\n\n1 ≤ m ≤ 20\n\n1 ≤ denomination ≤ 10000\n\nThe denominations are all different and contain 1.\n\nSample Input 1\n\n55 4\n1 5 10 50\n\nSample Output 1\n\n2\n\nSample Input 2\n\n15 6\n1 2 7 8 12 50\n\nSample Output 2\n\n2\n\nSample Input 3\n\n65 6\n1 2 7 8 12 50\n\nSample Output 3\n\n3", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 480, "cpu_time_ms": 10, "memory_kb": 10776}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s338163310", "group_id": "codeNet:p02317", "input_text": "let lower_bound (a : int array) first last v =\n let rec doit len first =\n if len = 0 then first\n else\n let half = len / 2 in\n let mid = first + half in\n if a.(mid) < v then doit (len - half - 1) (mid + 1)\n else doit half first in\n doit (last - first + 1) first\n\nlet () =\n let n = read_int () in\n let dp = Array.make (n + 1) max_int in\n let l = ref 0 in\n for _ = 0 to n - 1 do\n let a = read_int () in\n let x = lower_bound dp 0 n a in\n dp.(x) <- a;\n if x + 1 > !l then l := x + 1;\n done;\n Printf.printf \"%d\\n\" !l", "language": "OCaml", "metadata": {"date": 1501744464, "filename_ext": "ml", "original_language": "OCaml", "problem_description_relpath": "problem_descriptions/p02317.html", "problem_id": "p02317", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02317/input.txt", "sample_output_relpath": "derived/input_output/data/p02317/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02317/OCaml/s338163310.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s338163310", "user_id": "u809138450"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "let lower_bound (a : int array) first last v =\n let rec doit len first =\n if len = 0 then first\n else\n let half = len / 2 in\n let mid = first + half in\n if a.(mid) < v then doit (len - half - 1) (mid + 1)\n else doit half first in\n doit (last - first + 1) first\n\nlet () =\n let n = read_int () in\n let dp = Array.make (n + 1) max_int in\n let l = ref 0 in\n for _ = 0 to n - 1 do\n let a = read_int () in\n let x = lower_bound dp 0 n a in\n dp.(x) <- a;\n if x + 1 > !l then l := x + 1;\n done;\n Printf.printf \"%d\\n\" !l", "problem_context": "Longest Increasing Subsequence\n\nFor a given sequence A = {a0, a1, ... , an-1}, find the length of the longest increasing subsequnece (LIS) in A.\n\nAn increasing subsequence of A is defined by a subsequence {ai0, ai1, ... , aik} where 0 ≤ i0 < i1 < ... < ik < n and ai0 < ai1 < ... < aik.\n\nInput\n\nn\na0\na1\n:\nan-1\n\nIn the first line, an integer n is given. In the next n lines, elements of A are given.\n\nOutput\n\nThe length of the longest increasing subsequence of A.\n\nConstraints\n\n1 ≤ n ≤ 100000\n\n0 ≤ ai ≤ 109\n\nSample Input 1\n\n5\n5\n1\n3\n2\n4\n\nSample Output 1\n\n3\n\nSample Input 2\n\n3\n1\n1\n1\n\nSample Output 2\n\n1", "sample_input": "5\n5\n1\n3\n2\n4\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02317", "source_text": "Longest Increasing Subsequence\n\nFor a given sequence A = {a0, a1, ... , an-1}, find the length of the longest increasing subsequnece (LIS) in A.\n\nAn increasing subsequence of A is defined by a subsequence {ai0, ai1, ... , aik} where 0 ≤ i0 < i1 < ... < ik < n and ai0 < ai1 < ... < aik.\n\nInput\n\nn\na0\na1\n:\nan-1\n\nIn the first line, an integer n is given. In the next n lines, elements of A are given.\n\nOutput\n\nThe length of the longest increasing subsequence of A.\n\nConstraints\n\n1 ≤ n ≤ 100000\n\n0 ≤ ai ≤ 109\n\nSample Input 1\n\n5\n5\n1\n3\n2\n4\n\nSample Output 1\n\n3\n\nSample Input 2\n\n3\n1\n1\n1\n\nSample Output 2\n\n1", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 556, "cpu_time_ms": 10, "memory_kb": 5280}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s536557182", "group_id": "codeNet:p02319", "input_text": "type t = { v : int; w : int }\n\nlet solve n w a =\n let s = Array.make (w + 1) 0 in\n let t = Array.copy s in\n for i = 0 to n - 1 do\n for j = a.(i).w to w do\n if s.(j - a.(i).w) + a.(i).v > s.(j) then\n t.(j) <- s.(j - a.(i).w) + a.(i).v;\n done;\n Array.iteri (fun i e -> s.(i) <- e) t;\n done;\n t.(w)\n\nlet () =\n let (n, w) = Scanf.scanf \"%d %d \" (fun n w -> n, w) in\n Array.init n (fun _ -> Scanf.scanf \"%d %d \" (fun v w -> { v; w }))\n |> solve n w |> Printf.printf \"%d\\n\"", "language": "OCaml", "metadata": {"date": 1501894185, "filename_ext": "ml", "original_language": "OCaml", "problem_description_relpath": "problem_descriptions/p02319.html", "problem_id": "p02319", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02319/input.txt", "sample_output_relpath": "derived/input_output/data/p02319/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02319/OCaml/s536557182.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s536557182", "user_id": "u809138450"}, "prompt_components": {"gold_output": "13\n", "input_to_evaluate": "type t = { v : int; w : int }\n\nlet solve n w a =\n let s = Array.make (w + 1) 0 in\n let t = Array.copy s in\n for i = 0 to n - 1 do\n for j = a.(i).w to w do\n if s.(j - a.(i).w) + a.(i).v > s.(j) then\n t.(j) <- s.(j - a.(i).w) + a.(i).v;\n done;\n Array.iteri (fun i e -> s.(i) <- e) t;\n done;\n t.(w)\n\nlet () =\n let (n, w) = Scanf.scanf \"%d %d \" (fun n w -> n, w) in\n Array.init n (fun _ -> Scanf.scanf \"%d %d \" (fun v w -> { v; w }))\n |> solve n w |> Printf.printf \"%d\\n\"", "problem_context": "0-1 Knapsack Problem II\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 N 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 ≤ 100\n\n1 ≤ wi ≤ 10,000,000\n\n1 ≤ W ≤ 1,000,000,000\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": "p02319", "source_text": "0-1 Knapsack Problem II\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 N 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 ≤ 100\n\n1 ≤ wi ≤ 10,000,000\n\n1 ≤ W ≤ 1,000,000,000\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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 40, "memory_kb": 3872}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s382515839", "group_id": "codeNet:p02326", "input_text": "let solve h w c =\n let v0 = Array.make w 0 in\n let v1 = Array.make w 0 in\n let r = ref 0 in\n for i = 0 to h - 1 do if c.(i).(0) = 0 then r := 1 done;\n for j = 0 to w - 1 do if c.(0).(j) = 0 then begin v0.(j) <- 1; r := 1 end done;\n for i = 1 to h - 1 do\n if c.(i).(0) = 0 then v1.(0) <- 1;\n for j = 1 to w - 1 do\n if c.(i).(j) = 1 then v1.(j) <- 0\n else begin\n let t = if v0.(j) < v1.(j-1) then v0.(j) else v1.(j-1) in\n v1.(j) <- if v0.(j-1) < t then v0.(j-1) + 1 else t + 1;\n r := if v1.(j) > !r then v1.(j) else !r;\n end\n done;\n Array.iteri (fun i e -> v0.(i) <- e) v1\n done;\n !r * !r\n\nlet split_on_char sep s =\n let open String in\n let r = ref [] in\n let j = ref (length s) in\n for i = length s - 1 downto 0 do\n if get s i = sep then begin\n r := sub s (i + 1) (!j - i - 1) :: !r;\n j := i\n end\n done;\n sub s 0 !j :: !r\n\nlet read () = List.map int_of_string (split_on_char ' ' (read_line ()))\n\nlet () =\n match read () with\n | [h; w] ->\n let c = Array.make_matrix h w 0 in\n for i = 0 to h - 1 do\n let rec doit j = function\n | [] -> ()\n | x::xs ->\n c.(i).(j) <- x;\n doit (j + 1) xs in\n doit 0 (read ())\n done;\n Printf.printf \"%d\\n\" (solve h w c)\n | _ -> ()", "language": "OCaml", "metadata": {"date": 1480093511, "filename_ext": "ml", "original_language": "OCaml", "problem_description_relpath": "problem_descriptions/p02326.html", "problem_id": "p02326", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02326/input.txt", "sample_output_relpath": "derived/input_output/data/p02326/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02326/OCaml/s382515839.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s382515839", "user_id": "u809138450"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "let solve h w c =\n let v0 = Array.make w 0 in\n let v1 = Array.make w 0 in\n let r = ref 0 in\n for i = 0 to h - 1 do if c.(i).(0) = 0 then r := 1 done;\n for j = 0 to w - 1 do if c.(0).(j) = 0 then begin v0.(j) <- 1; r := 1 end done;\n for i = 1 to h - 1 do\n if c.(i).(0) = 0 then v1.(0) <- 1;\n for j = 1 to w - 1 do\n if c.(i).(j) = 1 then v1.(j) <- 0\n else begin\n let t = if v0.(j) < v1.(j-1) then v0.(j) else v1.(j-1) in\n v1.(j) <- if v0.(j-1) < t then v0.(j-1) + 1 else t + 1;\n r := if v1.(j) > !r then v1.(j) else !r;\n end\n done;\n Array.iteri (fun i e -> v0.(i) <- e) v1\n done;\n !r * !r\n\nlet split_on_char sep s =\n let open String in\n let r = ref [] in\n let j = ref (length s) in\n for i = length s - 1 downto 0 do\n if get s i = sep then begin\n r := sub s (i + 1) (!j - i - 1) :: !r;\n j := i\n end\n done;\n sub s 0 !j :: !r\n\nlet read () = List.map int_of_string (split_on_char ' ' (read_line ()))\n\nlet () =\n match read () with\n | [h; w] ->\n let c = Array.make_matrix h w 0 in\n for i = 0 to h - 1 do\n let rec doit j = function\n | [] -> ()\n | x::xs ->\n c.(i).(j) <- x;\n doit (j + 1) xs in\n doit 0 (read ())\n done;\n Printf.printf \"%d\\n\" (solve h w c)\n | _ -> ()", "problem_context": "Largest Square\n\nGiven a matrix (H × W) which contains only 1 and 0, find the area of the largest square matrix which only contains 0s.\n\nInput\n\nH W\nc1,1 c1,2 ... c1,W\nc2,1 c2,2 ... c2,W\n:\ncH,1 cH,2 ... cH,W\n\nIn the first line, two integers H and W separated by a space character are given. In the following H lines, ci,j, elements of the H × W matrix, are given.\n\nOutput\n\nPrint the area (the number of 0s) of the largest square.\n\nConstraints\n\n1 ≤ H, W ≤ 1,400\n\nSample Input\n\n4 5\n0 0 1 0 0\n1 0 0 0 0\n0 0 0 1 0\n0 0 0 1 0\n\nSample Output\n\n4", "sample_input": "4 5\n0 0 1 0 0\n1 0 0 0 0\n0 0 0 1 0\n0 0 0 1 0\n"}, "reference_outputs": ["4\n"], "source_document_id": "p02326", "source_text": "Largest Square\n\nGiven a matrix (H × W) which contains only 1 and 0, find the area of the largest square matrix which only contains 0s.\n\nInput\n\nH W\nc1,1 c1,2 ... c1,W\nc2,1 c2,2 ... c2,W\n:\ncH,1 cH,2 ... cH,W\n\nIn the first line, two integers H and W separated by a space character are given. In the following H lines, ci,j, elements of the H × W matrix, are given.\n\nOutput\n\nPrint the area (the number of 0s) of the largest square.\n\nConstraints\n\n1 ≤ H, W ≤ 1,400\n\nSample Input\n\n4 5\n0 0 1 0 0\n1 0 0 0 0\n0 0 0 1 0\n0 0 0 1 0\n\nSample Output\n\n4", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1290, "cpu_time_ms": 70, "memory_kb": 25312}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s912386780", "group_id": "codeNet:p02327", "input_text": "let solve ans w v =\n let rec duduwa ans j k = function\n | [] -> doit ans (j + 1, [(v.(j), k)])\n | (ch, cj) :: y' when ch >= v.(j) -> duduwa (if ch * (j - cj) > ans then ch * (j - cj) else ans) j cj y'\n | ys -> doit ans (j + 1, (v.(j), k) :: ys)\n and doit ans = function\n | (j, xs) when j = w -> List.fold_left (fun acc (ch, cj) -> if ch * (w - cj) > acc then ch * (w - cj) else acc) ans xs\n | (j, []) -> doit ans (j + 1, [(v.(j), j)])\n | (j, ((ch, _) :: _ as xs)) when ch = v.(j) -> doit ans (j + 1, xs)\n | (j, ((ch, _) :: _ as xs)) when ch < v.(j) -> doit ans (j + 1, (v.(j), j) :: xs)\n | (j, xs) -> duduwa ans j j xs in\n doit ans (0, [])\n\nlet split_on_char sep s =\n let open String in\n let r = ref [] in\n let j = ref (length s) in\n for i = length s - 1 downto 0 do\n if get s i = sep then begin\n r := sub s (i + 1) (!j - i - 1) :: !r;\n j := i\n end\n done;\n sub s 0 !j :: !r\n\nlet read () = List.map int_of_string (split_on_char ' ' (read_line ()))\n\nlet () =\n match read () with\n | [h; w] ->\n let v0 = Array.make w 0 in\n let v1 = Array.make w 0 in\n let rec doit i ans =\n if i = h then ans\n else\n let rec duduwa j = function\n | [] -> Array.iteri (fun i e -> v0.(i) <- e) v1; doit (i + 1) (solve ans w v1)\n | x::xs ->\n v1.(j) <- 1 - x;\n if i <> 0 then v1.(j) <- if v1.(j) = 0 then 0 else v0.(j) + 1;\n duduwa (j + 1) xs in\n duduwa 0 (read ()) in\n Printf.printf \"%d\\n\" (doit 0 0)\n | _ -> ()", "language": "OCaml", "metadata": {"date": 1480348421, "filename_ext": "ml", "original_language": "OCaml", "problem_description_relpath": "problem_descriptions/p02327.html", "problem_id": "p02327", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02327/input.txt", "sample_output_relpath": "derived/input_output/data/p02327/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02327/OCaml/s912386780.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s912386780", "user_id": "u809138450"}, "prompt_components": {"gold_output": "6\n", "input_to_evaluate": "let solve ans w v =\n let rec duduwa ans j k = function\n | [] -> doit ans (j + 1, [(v.(j), k)])\n | (ch, cj) :: y' when ch >= v.(j) -> duduwa (if ch * (j - cj) > ans then ch * (j - cj) else ans) j cj y'\n | ys -> doit ans (j + 1, (v.(j), k) :: ys)\n and doit ans = function\n | (j, xs) when j = w -> List.fold_left (fun acc (ch, cj) -> if ch * (w - cj) > acc then ch * (w - cj) else acc) ans xs\n | (j, []) -> doit ans (j + 1, [(v.(j), j)])\n | (j, ((ch, _) :: _ as xs)) when ch = v.(j) -> doit ans (j + 1, xs)\n | (j, ((ch, _) :: _ as xs)) when ch < v.(j) -> doit ans (j + 1, (v.(j), j) :: xs)\n | (j, xs) -> duduwa ans j j xs in\n doit ans (0, [])\n\nlet split_on_char sep s =\n let open String in\n let r = ref [] in\n let j = ref (length s) in\n for i = length s - 1 downto 0 do\n if get s i = sep then begin\n r := sub s (i + 1) (!j - i - 1) :: !r;\n j := i\n end\n done;\n sub s 0 !j :: !r\n\nlet read () = List.map int_of_string (split_on_char ' ' (read_line ()))\n\nlet () =\n match read () with\n | [h; w] ->\n let v0 = Array.make w 0 in\n let v1 = Array.make w 0 in\n let rec doit i ans =\n if i = h then ans\n else\n let rec duduwa j = function\n | [] -> Array.iteri (fun i e -> v0.(i) <- e) v1; doit (i + 1) (solve ans w v1)\n | x::xs ->\n v1.(j) <- 1 - x;\n if i <> 0 then v1.(j) <- if v1.(j) = 0 then 0 else v0.(j) + 1;\n duduwa (j + 1) xs in\n duduwa 0 (read ()) in\n Printf.printf \"%d\\n\" (doit 0 0)\n | _ -> ()", "problem_context": "Largest Rectangle\n\nGiven a matrix (H × W) which contains only 1 and 0, find the area of the largest rectangle which only contains 0s.\n\nInput\n\nH W\nc1,1 c1,2 ... c1,W\nc2,1 c2,2 ... c2,W\n:\ncH,1 cH,2 ... cH,W\n\nIn the first line, two integers H and W separated by a space character are given. In the following H lines, ci,j, elements of the H × W matrix, are given.\n\nOutput\n\nPrint the area (the number of 0s) of the largest rectangle.\n\nConstraints\n\n1 ≤ H, W ≤ 1,400\n\nSample Input\n\n4 5\n0 0 1 0 0\n1 0 0 0 0\n0 0 0 1 0\n0 0 0 1 0\n\nSample Output\n\n6", "sample_input": "4 5\n0 0 1 0 0\n1 0 0 0 0\n0 0 0 1 0\n0 0 0 1 0\n"}, "reference_outputs": ["6\n"], "source_document_id": "p02327", "source_text": "Largest Rectangle\n\nGiven a matrix (H × W) which contains only 1 and 0, find the area of the largest rectangle which only contains 0s.\n\nInput\n\nH W\nc1,1 c1,2 ... c1,W\nc2,1 c2,2 ... c2,W\n:\ncH,1 cH,2 ... cH,W\n\nIn the first line, two integers H and W separated by a space character are given. In the following H lines, ci,j, elements of the H × W matrix, are given.\n\nOutput\n\nPrint the area (the number of 0s) of the largest rectangle.\n\nConstraints\n\n1 ≤ H, W ≤ 1,400\n\nSample Input\n\n4 5\n0 0 1 0 0\n1 0 0 0 0\n0 0 0 1 0\n0 0 0 1 0\n\nSample Output\n\n6", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1523, "cpu_time_ms": 70, "memory_kb": 5092}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s267531678", "group_id": "codeNet:p02327", "input_text": "module IO = struct\n\n (* @since 4.04.0 *)\n let split_on_char sep s =\n let open String in\n let r = ref [] in\n let j = ref (length s) in\n for i = length s - 1 downto 0 do\n if get s i = sep then begin\n r := sub s (i + 1) (!j - i - 1) :: !r;\n j := i\n end\n done;\n sub s 0 !j :: !r\n\n let read_ns () = read_line () |> split_on_char ' ' |> List.map int_of_string\n\nend\n\nlet solve ans w v =\n let (ans, _, xs) = Array.fold_left (fun (ans, j, xs) c -> match xs with\n | [] -> (ans, j + 1, [(c, j)])\n | (ch, _) :: _ ->\n if ch = c then (ans, j + 1, xs)\n else if ch < c then (ans, j + 1, (c, j) :: xs)\n else\n let rec f ans k = function\n | [] -> (ans, j + 1, [(c, k)])\n | (ch, cj) :: tl as ys ->\n if ch >= c then f (if ch * (j - cj) > ans then ch * (j - cj) else ans) cj tl\n else (ans, j + 1, (c, k) :: ys) in\n f ans j xs)\n (ans, 0, [])\n v in\n List.fold_left (fun acc (ch, cj) -> if ch * (w - cj) > acc then ch * (w - cj) else acc) ans xs\n\nlet () =\n match IO.read_ns () with\n | [h; w] ->\n let s = Array.make w 0 in\n let t = Array.make w 0 in\n let rec doit i ans =\n if i = h then ans\n else begin\n IO.read_ns () |> List.iteri (fun j e -> t.(j) <- if e = 1 then 0 else s.(j) + 1);\n Array.iteri (fun i e -> s.(i) <- e) t;\n solve ans w t |> doit (i + 1)\n end in\n doit 0 0 |> Printf.printf \"%d\\n\"\n | _ -> assert false", "language": "OCaml", "metadata": {"date": 1501911347, "filename_ext": "ml", "original_language": "OCaml", "problem_description_relpath": "problem_descriptions/p02327.html", "problem_id": "p02327", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02327/input.txt", "sample_output_relpath": "derived/input_output/data/p02327/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02327/OCaml/s267531678.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s267531678", "user_id": "u809138450"}, "prompt_components": {"gold_output": "6\n", "input_to_evaluate": "module IO = struct\n\n (* @since 4.04.0 *)\n let split_on_char sep s =\n let open String in\n let r = ref [] in\n let j = ref (length s) in\n for i = length s - 1 downto 0 do\n if get s i = sep then begin\n r := sub s (i + 1) (!j - i - 1) :: !r;\n j := i\n end\n done;\n sub s 0 !j :: !r\n\n let read_ns () = read_line () |> split_on_char ' ' |> List.map int_of_string\n\nend\n\nlet solve ans w v =\n let (ans, _, xs) = Array.fold_left (fun (ans, j, xs) c -> match xs with\n | [] -> (ans, j + 1, [(c, j)])\n | (ch, _) :: _ ->\n if ch = c then (ans, j + 1, xs)\n else if ch < c then (ans, j + 1, (c, j) :: xs)\n else\n let rec f ans k = function\n | [] -> (ans, j + 1, [(c, k)])\n | (ch, cj) :: tl as ys ->\n if ch >= c then f (if ch * (j - cj) > ans then ch * (j - cj) else ans) cj tl\n else (ans, j + 1, (c, k) :: ys) in\n f ans j xs)\n (ans, 0, [])\n v in\n List.fold_left (fun acc (ch, cj) -> if ch * (w - cj) > acc then ch * (w - cj) else acc) ans xs\n\nlet () =\n match IO.read_ns () with\n | [h; w] ->\n let s = Array.make w 0 in\n let t = Array.make w 0 in\n let rec doit i ans =\n if i = h then ans\n else begin\n IO.read_ns () |> List.iteri (fun j e -> t.(j) <- if e = 1 then 0 else s.(j) + 1);\n Array.iteri (fun i e -> s.(i) <- e) t;\n solve ans w t |> doit (i + 1)\n end in\n doit 0 0 |> Printf.printf \"%d\\n\"\n | _ -> assert false", "problem_context": "Largest Rectangle\n\nGiven a matrix (H × W) which contains only 1 and 0, find the area of the largest rectangle which only contains 0s.\n\nInput\n\nH W\nc1,1 c1,2 ... c1,W\nc2,1 c2,2 ... c2,W\n:\ncH,1 cH,2 ... cH,W\n\nIn the first line, two integers H and W separated by a space character are given. In the following H lines, ci,j, elements of the H × W matrix, are given.\n\nOutput\n\nPrint the area (the number of 0s) of the largest rectangle.\n\nConstraints\n\n1 ≤ H, W ≤ 1,400\n\nSample Input\n\n4 5\n0 0 1 0 0\n1 0 0 0 0\n0 0 0 1 0\n0 0 0 1 0\n\nSample Output\n\n6", "sample_input": "4 5\n0 0 1 0 0\n1 0 0 0 0\n0 0 0 1 0\n0 0 0 1 0\n"}, "reference_outputs": ["6\n"], "source_document_id": "p02327", "source_text": "Largest Rectangle\n\nGiven a matrix (H × W) which contains only 1 and 0, find the area of the largest rectangle which only contains 0s.\n\nInput\n\nH W\nc1,1 c1,2 ... c1,W\nc2,1 c2,2 ... c2,W\n:\ncH,1 cH,2 ... cH,W\n\nIn the first line, two integers H and W separated by a space character are given. In the following H lines, ci,j, elements of the H × W matrix, are given.\n\nOutput\n\nPrint the area (the number of 0s) of the largest rectangle.\n\nConstraints\n\n1 ≤ H, W ≤ 1,400\n\nSample Input\n\n4 5\n0 0 1 0 0\n1 0 0 0 0\n0 0 0 1 0\n0 0 0 1 0\n\nSample Output\n\n6", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1472, "cpu_time_ms": 70, "memory_kb": 5044}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s926617368", "group_id": "codeNet:p02343", "input_text": "let read_lines () =\n let rec iter xs =\n try read_line() :: xs |> iter\n with End_of_file -> xs\n in iter [] |> List.rev\n\nlet split_nums str =\n Str.split (Str.regexp \" \") str\n |> List.map int_of_string\n\nlet read_ints () =\n read_line () |> split_nums |> Array.of_list\n\n\nlet init n = Array.init n (fun x -> x)\n\nlet rec find i a =\n if a.(i) = i then i\n else compress a.(i) a\nand compress i a =\n a.(i) <- find i a;\n a.(i)\n\nlet same x y a =\n find x a = find y a\n\nlet void _ = ()\n\nlet unite x y a =\n let i = find x a\n and j = find y a in\n if i = j then ()\n else a.(i) <- j\n\nlet () =\n let first_line = read_ints () in\n let tree = init first_line.(0) in\n let answer com x y =\n match com with\n | 0 -> unite x y tree;\n | 1 ->\n Printf.printf \"%d\\n\" (if same x y tree then 1 else 0);\n | _ -> raise Not_found in\n\n for i = 1 to first_line.(1) do\n let xs = read_ints () in\n answer xs.(0) xs.(1) xs.(2)\n done", "language": "OCaml", "metadata": {"date": 1466817803, "filename_ext": "ml", "original_language": "OCaml", "problem_description_relpath": "problem_descriptions/p02343.html", "problem_id": "p02343", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02343/input.txt", "sample_output_relpath": "derived/input_output/data/p02343/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02343/OCaml/s926617368.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s926617368", "user_id": "u088725606"}, "prompt_components": {"gold_output": "0\n0\n1\n1\n1\n0\n1\n1\n", "input_to_evaluate": "let read_lines () =\n let rec iter xs =\n try read_line() :: xs |> iter\n with End_of_file -> xs\n in iter [] |> List.rev\n\nlet split_nums str =\n Str.split (Str.regexp \" \") str\n |> List.map int_of_string\n\nlet read_ints () =\n read_line () |> split_nums |> Array.of_list\n\n\nlet init n = Array.init n (fun x -> x)\n\nlet rec find i a =\n if a.(i) = i then i\n else compress a.(i) a\nand compress i a =\n a.(i) <- find i a;\n a.(i)\n\nlet same x y a =\n find x a = find y a\n\nlet void _ = ()\n\nlet unite x y a =\n let i = find x a\n and j = find y a in\n if i = j then ()\n else a.(i) <- j\n\nlet () =\n let first_line = read_ints () in\n let tree = init first_line.(0) in\n let answer com x y =\n match com with\n | 0 -> unite x y tree;\n | 1 ->\n Printf.printf \"%d\\n\" (if same x y tree then 1 else 0);\n | _ -> raise Not_found in\n\n for i = 1 to first_line.(1) do\n let xs = read_ints () in\n answer xs.(0) xs.(1) xs.(2)\n done", "problem_context": "Disjoint Set\n\nWrite a program which manipulates a disjoint set S = {S1, S2, . . . , Sk}.\n\nFirst of all, the program should read an integer n, then make a disjoint set where each element consists of 0, 1, ... n−1 respectively.\n\nNext, the program should read an integer q and manipulate the set for q queries. There are two kinds of queries for different operations:\n\nunite(x, y): unites sets that contain x and y, say Sx and Sy, into a new set.\n\nsame(x, y): determine whether x and y are in the same set.\n\nInput\n\nn q\ncom1 x1 y1\ncom2 x2 y2\n...\ncomq xq yq\n\nIn the first line, n and q are given. Then, q queries are given where com represents the type of queries. '0' denotes unite and '1' denotes same operation.\n\nOutput\n\nFor each same operation, print 1 if x and y are in the same set, otherwise 0, in a line.\n\nConstraints\n\n1 ≤ n ≤ 10000\n\n1 ≤ q ≤ 100000\n\nx ≠ y\n\nSample Input\n\n5 12\n0 1 4\n0 2 3\n1 1 2\n1 3 4\n1 1 4\n1 3 2\n0 1 3\n1 2 4\n1 3 0\n0 0 4\n1 0 2\n1 3 0\n\nSample Output\n\n0\n0\n1\n1\n1\n0\n1\n1", "sample_input": "5 12\n0 1 4\n0 2 3\n1 1 2\n1 3 4\n1 1 4\n1 3 2\n0 1 3\n1 2 4\n1 3 0\n0 0 4\n1 0 2\n1 3 0\n"}, "reference_outputs": ["0\n0\n1\n1\n1\n0\n1\n1\n"], "source_document_id": "p02343", "source_text": "Disjoint Set\n\nWrite a program which manipulates a disjoint set S = {S1, S2, . . . , Sk}.\n\nFirst of all, the program should read an integer n, then make a disjoint set where each element consists of 0, 1, ... n−1 respectively.\n\nNext, the program should read an integer q and manipulate the set for q queries. There are two kinds of queries for different operations:\n\nunite(x, y): unites sets that contain x and y, say Sx and Sy, into a new set.\n\nsame(x, y): determine whether x and y are in the same set.\n\nInput\n\nn q\ncom1 x1 y1\ncom2 x2 y2\n...\ncomq xq yq\n\nIn the first line, n and q are given. Then, q queries are given where com represents the type of queries. '0' denotes unite and '1' denotes same operation.\n\nOutput\n\nFor each same operation, print 1 if x and y are in the same set, otherwise 0, in a line.\n\nConstraints\n\n1 ≤ n ≤ 10000\n\n1 ≤ q ≤ 100000\n\nx ≠ y\n\nSample Input\n\n5 12\n0 1 4\n0 2 3\n1 1 2\n1 3 4\n1 1 4\n1 3 2\n0 1 3\n1 2 4\n1 3 0\n0 0 4\n1 0 2\n1 3 0\n\nSample Output\n\n0\n0\n1\n1\n1\n0\n1\n1", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 938, "cpu_time_ms": 120, "memory_kb": 4840}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s390966336", "group_id": "codeNet:p02343", "input_text": "type t = { mutable parent : int; mutable rank : int }\n\nlet split_on_char sep s =\n let open String in\n let r = ref [] in\n let j = ref (length s) in\n for i = length s - 1 downto 0 do\n if get s i = sep then begin\n r := sub s (i + 1) (!j - i - 1) :: !r;\n j := i\n end\n done;\n sub s 0 !j :: !r\n\nlet readln () = read_line () |> split_on_char ' ' |> List.map int_of_string\n\nlet find s x =\n let rec doit x =\n let p = s.(x).parent in\n if x = p then x\n else begin\n s.(x).parent <- doit p;\n s.(x).parent\n end in\n doit x\n\nlet unite s x y =\n let px = find s x in\n let py = find s y in\n if s.(px).rank > s.(py).rank then s.(py).parent <- px\n else begin\n s.(px).parent <- py;\n if s.(px).rank = s.(py).rank then s.(py).rank <- s.(py).rank + 1\n end\n\nlet same_p s x y = find s x = find s y\n\nlet solve n q =\n let s = Array.init n (fun i -> { parent = i; rank = 0 }) in\n for i = 0 to q - 1 do\n match readln () with\n | n :: x :: y :: _ ->\n if n = 0 then unite s x y\n else print_endline (if same_p s x y then \"1\" else \"0\")\n | _ -> assert false\n done\n\nlet () =\n match readln () with\n | [n; q] -> solve n q\n | _ -> assert false", "language": "OCaml", "metadata": {"date": 1501049702, "filename_ext": "ml", "original_language": "OCaml", "problem_description_relpath": "problem_descriptions/p02343.html", "problem_id": "p02343", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02343/input.txt", "sample_output_relpath": "derived/input_output/data/p02343/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02343/OCaml/s390966336.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s390966336", "user_id": "u809138450"}, "prompt_components": {"gold_output": "0\n0\n1\n1\n1\n0\n1\n1\n", "input_to_evaluate": "type t = { mutable parent : int; mutable rank : int }\n\nlet split_on_char sep s =\n let open String in\n let r = ref [] in\n let j = ref (length s) in\n for i = length s - 1 downto 0 do\n if get s i = sep then begin\n r := sub s (i + 1) (!j - i - 1) :: !r;\n j := i\n end\n done;\n sub s 0 !j :: !r\n\nlet readln () = read_line () |> split_on_char ' ' |> List.map int_of_string\n\nlet find s x =\n let rec doit x =\n let p = s.(x).parent in\n if x = p then x\n else begin\n s.(x).parent <- doit p;\n s.(x).parent\n end in\n doit x\n\nlet unite s x y =\n let px = find s x in\n let py = find s y in\n if s.(px).rank > s.(py).rank then s.(py).parent <- px\n else begin\n s.(px).parent <- py;\n if s.(px).rank = s.(py).rank then s.(py).rank <- s.(py).rank + 1\n end\n\nlet same_p s x y = find s x = find s y\n\nlet solve n q =\n let s = Array.init n (fun i -> { parent = i; rank = 0 }) in\n for i = 0 to q - 1 do\n match readln () with\n | n :: x :: y :: _ ->\n if n = 0 then unite s x y\n else print_endline (if same_p s x y then \"1\" else \"0\")\n | _ -> assert false\n done\n\nlet () =\n match readln () with\n | [n; q] -> solve n q\n | _ -> assert false", "problem_context": "Disjoint Set\n\nWrite a program which manipulates a disjoint set S = {S1, S2, . . . , Sk}.\n\nFirst of all, the program should read an integer n, then make a disjoint set where each element consists of 0, 1, ... n−1 respectively.\n\nNext, the program should read an integer q and manipulate the set for q queries. There are two kinds of queries for different operations:\n\nunite(x, y): unites sets that contain x and y, say Sx and Sy, into a new set.\n\nsame(x, y): determine whether x and y are in the same set.\n\nInput\n\nn q\ncom1 x1 y1\ncom2 x2 y2\n...\ncomq xq yq\n\nIn the first line, n and q are given. Then, q queries are given where com represents the type of queries. '0' denotes unite and '1' denotes same operation.\n\nOutput\n\nFor each same operation, print 1 if x and y are in the same set, otherwise 0, in a line.\n\nConstraints\n\n1 ≤ n ≤ 10000\n\n1 ≤ q ≤ 100000\n\nx ≠ y\n\nSample Input\n\n5 12\n0 1 4\n0 2 3\n1 1 2\n1 3 4\n1 1 4\n1 3 2\n0 1 3\n1 2 4\n1 3 0\n0 0 4\n1 0 2\n1 3 0\n\nSample Output\n\n0\n0\n1\n1\n1\n0\n1\n1", "sample_input": "5 12\n0 1 4\n0 2 3\n1 1 2\n1 3 4\n1 1 4\n1 3 2\n0 1 3\n1 2 4\n1 3 0\n0 0 4\n1 0 2\n1 3 0\n"}, "reference_outputs": ["0\n0\n1\n1\n1\n0\n1\n1\n"], "source_document_id": "p02343", "source_text": "Disjoint Set\n\nWrite a program which manipulates a disjoint set S = {S1, S2, . . . , Sk}.\n\nFirst of all, the program should read an integer n, then make a disjoint set where each element consists of 0, 1, ... n−1 respectively.\n\nNext, the program should read an integer q and manipulate the set for q queries. There are two kinds of queries for different operations:\n\nunite(x, y): unites sets that contain x and y, say Sx and Sy, into a new set.\n\nsame(x, y): determine whether x and y are in the same set.\n\nInput\n\nn q\ncom1 x1 y1\ncom2 x2 y2\n...\ncomq xq yq\n\nIn the first line, n and q are given. Then, q queries are given where com represents the type of queries. '0' denotes unite and '1' denotes same operation.\n\nOutput\n\nFor each same operation, print 1 if x and y are in the same set, otherwise 0, in a line.\n\nConstraints\n\n1 ≤ n ≤ 10000\n\n1 ≤ q ≤ 100000\n\nx ≠ y\n\nSample Input\n\n5 12\n0 1 4\n0 2 3\n1 1 2\n1 3 4\n1 1 4\n1 3 2\n0 1 3\n1 2 4\n1 3 0\n0 0 4\n1 0 2\n1 3 0\n\nSample Output\n\n0\n0\n1\n1\n1\n0\n1\n1", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1184, "cpu_time_ms": 60, "memory_kb": 4652}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s086053032", "group_id": "codeNet:p02343", "input_text": "open Printf\nopen Scanf\n\nmodule Uftree =\n struct\n type t = int array\n let create n : t = Array.make n (-1)\n let rec find (uft : t) x =\n let p = uft.(x) in\n if p < 0 then x\n else\n let rt = find uft p in\n uft.(x) <- rt; rt\n let unite (uft : t) x y =\n let rx = find uft x in\n let ry = find uft y in\n if rx = ry then ()\n else\n if uft.(rx) < uft.(ry) then\n begin\n uft.(rx) <- uft.(rx) + uft.(ry);\n uft.(ry) <- rx\n end\n else\n begin\n uft.(ry) <- uft.(rx) + uft.(ry);\n uft.(rx) <- ry\n end\n let same (uft : t) x y =\n let rx = find uft x in\n let ry = find uft y in\n rx = ry\n let size (uft : t) x =\n let rx = find uft x in -uft.(rx)\n end\n\nlet tuple x y = (x, y)\n \nlet () =\n let n, q = scanf \"%d %d \" tuple in\n let uft = Uftree.create n in\n let rec loop x =\n if x = 0 then ()\n else\n let com, a, b = scanf \"%d %d %d \" (fun i j k -> (i, j, k)) in\n if com = 0 then\n Uftree.unite uft a b\n else\n (if Uftree.same uft a b then 1 else 0) |> printf \"%d\\n\";\n loop (x-1)\n in loop q", "language": "OCaml", "metadata": {"date": 1502197610, "filename_ext": "ml", "original_language": "OCaml", "problem_description_relpath": "problem_descriptions/p02343.html", "problem_id": "p02343", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02343/input.txt", "sample_output_relpath": "derived/input_output/data/p02343/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02343/OCaml/s086053032.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s086053032", "user_id": "u049242937"}, "prompt_components": {"gold_output": "0\n0\n1\n1\n1\n0\n1\n1\n", "input_to_evaluate": "open Printf\nopen Scanf\n\nmodule Uftree =\n struct\n type t = int array\n let create n : t = Array.make n (-1)\n let rec find (uft : t) x =\n let p = uft.(x) in\n if p < 0 then x\n else\n let rt = find uft p in\n uft.(x) <- rt; rt\n let unite (uft : t) x y =\n let rx = find uft x in\n let ry = find uft y in\n if rx = ry then ()\n else\n if uft.(rx) < uft.(ry) then\n begin\n uft.(rx) <- uft.(rx) + uft.(ry);\n uft.(ry) <- rx\n end\n else\n begin\n uft.(ry) <- uft.(rx) + uft.(ry);\n uft.(rx) <- ry\n end\n let same (uft : t) x y =\n let rx = find uft x in\n let ry = find uft y in\n rx = ry\n let size (uft : t) x =\n let rx = find uft x in -uft.(rx)\n end\n\nlet tuple x y = (x, y)\n \nlet () =\n let n, q = scanf \"%d %d \" tuple in\n let uft = Uftree.create n in\n let rec loop x =\n if x = 0 then ()\n else\n let com, a, b = scanf \"%d %d %d \" (fun i j k -> (i, j, k)) in\n if com = 0 then\n Uftree.unite uft a b\n else\n (if Uftree.same uft a b then 1 else 0) |> printf \"%d\\n\";\n loop (x-1)\n in loop q", "problem_context": "Disjoint Set\n\nWrite a program which manipulates a disjoint set S = {S1, S2, . . . , Sk}.\n\nFirst of all, the program should read an integer n, then make a disjoint set where each element consists of 0, 1, ... n−1 respectively.\n\nNext, the program should read an integer q and manipulate the set for q queries. There are two kinds of queries for different operations:\n\nunite(x, y): unites sets that contain x and y, say Sx and Sy, into a new set.\n\nsame(x, y): determine whether x and y are in the same set.\n\nInput\n\nn q\ncom1 x1 y1\ncom2 x2 y2\n...\ncomq xq yq\n\nIn the first line, n and q are given. Then, q queries are given where com represents the type of queries. '0' denotes unite and '1' denotes same operation.\n\nOutput\n\nFor each same operation, print 1 if x and y are in the same set, otherwise 0, in a line.\n\nConstraints\n\n1 ≤ n ≤ 10000\n\n1 ≤ q ≤ 100000\n\nx ≠ y\n\nSample Input\n\n5 12\n0 1 4\n0 2 3\n1 1 2\n1 3 4\n1 1 4\n1 3 2\n0 1 3\n1 2 4\n1 3 0\n0 0 4\n1 0 2\n1 3 0\n\nSample Output\n\n0\n0\n1\n1\n1\n0\n1\n1", "sample_input": "5 12\n0 1 4\n0 2 3\n1 1 2\n1 3 4\n1 1 4\n1 3 2\n0 1 3\n1 2 4\n1 3 0\n0 0 4\n1 0 2\n1 3 0\n"}, "reference_outputs": ["0\n0\n1\n1\n1\n0\n1\n1\n"], "source_document_id": "p02343", "source_text": "Disjoint Set\n\nWrite a program which manipulates a disjoint set S = {S1, S2, . . . , Sk}.\n\nFirst of all, the program should read an integer n, then make a disjoint set where each element consists of 0, 1, ... n−1 respectively.\n\nNext, the program should read an integer q and manipulate the set for q queries. There are two kinds of queries for different operations:\n\nunite(x, y): unites sets that contain x and y, say Sx and Sy, into a new set.\n\nsame(x, y): determine whether x and y are in the same set.\n\nInput\n\nn q\ncom1 x1 y1\ncom2 x2 y2\n...\ncomq xq yq\n\nIn the first line, n and q are given. Then, q queries are given where com represents the type of queries. '0' denotes unite and '1' denotes same operation.\n\nOutput\n\nFor each same operation, print 1 if x and y are in the same set, otherwise 0, in a line.\n\nConstraints\n\n1 ≤ n ≤ 10000\n\n1 ≤ q ≤ 100000\n\nx ≠ y\n\nSample Input\n\n5 12\n0 1 4\n0 2 3\n1 1 2\n1 3 4\n1 1 4\n1 3 2\n0 1 3\n1 2 4\n1 3 0\n0 0 4\n1 0 2\n1 3 0\n\nSample Output\n\n0\n0\n1\n1\n1\n0\n1\n1", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1201, "cpu_time_ms": 30, "memory_kb": 4688}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s704639811", "group_id": "codeNet:p02345", "input_text": "open Printf open Scanf\nmodule Lib = struct\n\tlet i32,i64,ist = Int64.(to_int,of_int,to_string)\n\tlet (+$) = (+) let (-$) = (-) let (/$) = (/) let ( *$) = ( * ) let (%$) = (mod)\n\tlet labs = Int64.abs\n\tlet (+),(-),( * ),(/),(mod),(%) = Int64.(add,sub,mul,div,rem,rem)\n\tlet (+=) r v = r := !r + v\n\tlet (-=) r v = r := !r - v\n\tlet ( *= ) r v = r := !r * v\n\tlet (/=) r v = r := !r / v\n\tlet (%=) r v = r := !r % v\n\tlet max_i64,min_i64 = Int64.(max_int,min_int)\n\t(* math *)\n\tlet ceildiv p q = (p+q-1L) / q\n\tlet rec gcd m n = match m,n with | m,0L -> m | m,n -> gcd n (m mod n)\n\tlet lcm m n = m / gcd m n * n \n\tmodule I64_infix = struct\n\t\tlet (land),(lor),(lxor),lnot,(lsl),(lsr),(asr) =\n\t\t\tlet open Int64 in\n\t\t\t(logand),(logor),(logxor),lognot,\n\t\t\t(fun u v -> shift_left u (i32 v)),\n\t\t\t(fun u v -> shift_right u (i32 v)),\n\t\t\t(fun u v -> shift_right_logical u (i32 v))\n\tend\n\t(* input *)\n\tlet input_i64_array n = Array.init (i32 n) (fun _ -> Scanf.scanf \" %Ld\" (fun v -> v))\n\tlet get_i64 _ = Scanf.scanf \" %Ld\" (fun v -> v)\n\tlet get_2_i64 _ = Scanf.scanf \" %Ld %Ld\" (fun u v -> u,v)\n\tlet get_3_i64 _ = Scanf.scanf \" %Ld %Ld %Ld\" (fun u v w -> u,v,w)\n\tlet get_4_i64 _ = Scanf.scanf \" %Ld %Ld %Ld %Ld\" (fun u v w x -> u,v,w,x)\n\tlet get_5_i64 _ = Scanf.scanf \" %Ld %Ld %Ld %Ld %Ld\" (fun u v w x y -> u,v,w,x,y)\n\tlet i32_get_int _ = Scanf.scanf \" %d\" (fun v -> v) let i32_get_2_ints _ = Scanf.scanf \" %d %d\" (fun u v -> u,v) let i32_get_3_ints _ = Scanf.scanf \" %d %d %d\" (fun u v w -> u,v,w) let i32_get_4_ints _ = Scanf.scanf \" %d %d %d %d\" (fun u v w x -> u,v,w,x) let i32_get_5_ints _ = Scanf.scanf \" %d %d %d %d %d\" (fun u v w x y -> u,v,w,x,y)\n\t(* utils *)\n\texternal id : 'a -> 'a = \"%identity\"\n\tlet ( *< ) f g x = f (g x)\n\tlet ( *> ) f g x = g (f x)\n\tlet rv f p q = f q p (* ex. 24 |> rv (/) 6 *)\n\tlet alen a = i64 @@ Array.length a\n\tlet llen l = i64 @@ List.length l\n\tlet string_of_list ?(separator=\" \") f ls = ls |> List.map f |> String.concat separator\n\tlet string_of_array ?(separator=\" \") f a = a |> Array.to_list |> string_of_list ~separator f\n\tlet char_list_of_string str = let rec f0 i a = if i<0 then a else f0 (i-$1) (str.[i]::a) in f0 (String.length str -$ 1) []\n\tlet string_of_char_list ls = List.fold_left (fun u v -> u ^ (String.make 1 v)) \"\" ls\n\tlet fail _ = failwith \"fail\"\n\tlet dx,dy = [|1;0;-1;0|],[|0;1;0;-1|]\n\tlet range l r = let ls = ref [] in for i=i32 l to i32 r do ls := i :: !ls done;!ls |> List.rev\n\tlet cartesian_product u v = u |> List.map (fun p -> List.map (fun q -> p,q) v) |> List.flatten\n\tlet shuffle a = Array.sort (fun _ _ -> (Random.int 3) -$ 1) a\n\tlet binary_search ng ok f = let d = if ng < ok then 1L else -1L in\n\t\tlet rec f0 ng ok =\n\t\t\tif labs (ok - ng) <= 1L then ok\n\t\t\telse let mid = ng + (ok - ng) / 2L in if f mid then f0 ng mid else f0 mid ok\n\t\tin f0 (ng-1L*d) (ok+1L*d)\n\tlet lower_bound a v = binary_search 0L (alen a - 1L) (fun i -> a.(i32 i) >= v)\n\tlet upper_bound a v = binary_search 0L (alen a - 1L) (fun i -> a.(i32 i) > v)\n\tlet equal_range a v = lower_bound a v, upper_bound a v (* #=snd-fst *)\n\tlet rec fix f x = f (fix f) x\n\tlet fix_memo ?(size=10000) f x =\n\t\tlet tb = Hashtbl.create ~random:true size in\n\t\tlet rec f0 x =\n\t\t\ttry Hashtbl.find tb x with\n\t\t\t| Not_found -> (let v = f f0 x in Hashtbl.add tb x v; v)\n\t\tin f0 x\n\t(* imperative *)\n\tlet rep f t ?(stride=1L) fbod = let i = ref f in while !i <= t do fbod !i; i := !i + stride done\n\tlet repb f t ?(stride=1L) fbod = let i,c = ref f,ref true in while !i <= t && !c do\n\t\tmatch fbod !i with | `Break -> c := false | `Ok -> i := !i + stride done\n\tlet repm f t ?(stride=1L) m0 fbod =\n\t\tlet i,c,m = ref f,ref true,ref m0 in\n\t\twhile !i<=t && !c do match fbod !m !i with\n\t\t| `Break -> c := false | `Break_m m' -> (c := false; m := m') | `Ok m' -> m := m'; i := !i + stride done; !m\n\tlet repi f t ?(stride=1) fbod = let i = ref f in while !i <= t do fbod !i; i := !i +$ stride done\n\tlet repib f t ?(stride=1) fbod = let i,c = ref f,ref true in while !i <= t && !c do\n\t\tmatch fbod !i with | `Break -> c := false | `Ok -> i := !i +$ stride done\n\tlet repim f t ?(stride=1) m0 fbod =\n\t\tlet i,c,m = ref f,ref true,ref m0 in\n\t\twhile !i<=t && !c do match fbod !m !i with\n\t\t| `Break -> c := false | `Break_m m' -> (c := false; m := m') | `Ok m' -> m := m'; i := !i +$ stride done; !m\n\tlet rep_rev f t ?(stride=1L) fbod = rep t f ~stride @@ fun v -> fbod @@ f + t - v\n\tlet repb_rev f t ?(stride=1L) fbod = repb t f ~stride @@ fun v -> fbod @@ f + t - v\n\tlet repm_rev f t ?(stride=1L) m0 fbod = repm f t ~stride m0 @@ fun u v -> fbod u @@ f + t - v\n\tlet repi_rev f t ?(stride=1) fbod = repi t f ~stride @@ fun v -> fbod @@ f +$ t -$ v\n\tlet repib_rev f t ?(stride=1) fbod = repib t f ~stride @@ fun v -> fbod @@ f +$ t -$ v\n\tlet repim_rev f t ?(stride=1) m0 fbod = repim f t ~stride m0 @@ fun u v -> fbod u @@ f +$ t -$ v\n\t(* output *)\n\tlet print_list_mle f ls = string_of_list f ls |> print_endline\n\tlet print_array_mle f a = string_of_array f a |> print_endline\n\tlet print_list f ls = ls |> List.iter (fun v -> printf \"%s \" @@ f v); print_newline ()\n\tlet print_array f a = a |> Array.iter (fun v -> printf \"%s \" @@ f v); print_newline ()\n\t(* debug *)\n\tlet dump_2darr f a = a |> Array.iter (fun b -> print_array f b)\n\tlet dump_i64_list ls = print_list ist ls\n\tlet dump_i64_array a = print_array ist a\nend open Lib open Array\n\nmodule SegTree = struct\n\tmodule type S = sig\n\t\ttype t\n\t\tval op: t -> t -> t\n\t\tval def: t\n\tend\n\tmodule RMQ = struct type t = int64 let op = min let def = max_i64 end\n\tlet par i = (i-$1)/$2\n\tlet chl i = 2*$i+$1\n\tlet chr i = 2*$i+$2\n\tmodule Make (X:S) = struct\n\t\ttype t = SegTree of (X.t array * int)\n\t\tlet raw (SegTree (a,_)) = a\n\t\tlet make raw =\n\t\t\tlet ln = Array.length raw in\n\t\t\tlet n =\n\t\t\t\tlet n = ref 1 in\n\t\t\t\twhile !n0 do\n\t\t\t\ti := par !i;\n\t\t\t\ta.(!i) <- X.op a.(chl !i) a.(chr !i) done\n\t\tlet get_half_open (SegTree(a,n)) l r = (* [l,r) *)\n\t\t\tlet rec f0 i p q =\n\t\t\t\tif q<=l || r<=p then X.def\n\t\t\t\telse if l<=p && q<=r then a.(i)\n\t\t\t\telse\n\t\t\t\t\tlet vl = f0 (2*$i+$1) p ((p+$q)/$2) in\n\t\t\t\t\tlet vr = f0 (2*$i+$2) ((p+$q)/$2) q in\n\t\t\t\t\tX.op vl vr\n\t\t\tin f0 0 0 n\n\t\tlet get_closed seg l r = get_half_open seg l (r+$1) (* [l,r] *)\n\tend\nend\n\nmodule RMQ = SegTree.Make(SegTree.RMQ)\nlet () =\n\tlet n,q = get_2_i64 0 in\n\tlet a = RMQ.make (make (i32 n) (i64 (2 lsl 30) - 1L)) in\n\trep 1L q (fun _ ->\n\t\tlet com,x,y = get_3_i64 0 in\n\t\tif com = 0L then (\n\t\t\tRMQ.update_destructive a (i32 x) y\n\t\t) else (\n\t\t\tprintf \"%Ld\\n\" @@ RMQ.get_closed a (i32 x) (i32 y)\n\t\t)\n\t)\n\n\n\n\n\n\n\n\n\n", "language": "OCaml", "metadata": {"date": 1541631141, "filename_ext": "ml", "original_language": "OCaml", "problem_description_relpath": "problem_descriptions/p02345.html", "problem_id": "p02345", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02345/input.txt", "sample_output_relpath": "derived/input_output/data/p02345/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02345/OCaml/s704639811.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s704639811", "user_id": "u296890922"}, "prompt_components": {"gold_output": "1\n2\n", "input_to_evaluate": "open Printf open Scanf\nmodule Lib = struct\n\tlet i32,i64,ist = Int64.(to_int,of_int,to_string)\n\tlet (+$) = (+) let (-$) = (-) let (/$) = (/) let ( *$) = ( * ) let (%$) = (mod)\n\tlet labs = Int64.abs\n\tlet (+),(-),( * ),(/),(mod),(%) = Int64.(add,sub,mul,div,rem,rem)\n\tlet (+=) r v = r := !r + v\n\tlet (-=) r v = r := !r - v\n\tlet ( *= ) r v = r := !r * v\n\tlet (/=) r v = r := !r / v\n\tlet (%=) r v = r := !r % v\n\tlet max_i64,min_i64 = Int64.(max_int,min_int)\n\t(* math *)\n\tlet ceildiv p q = (p+q-1L) / q\n\tlet rec gcd m n = match m,n with | m,0L -> m | m,n -> gcd n (m mod n)\n\tlet lcm m n = m / gcd m n * n \n\tmodule I64_infix = struct\n\t\tlet (land),(lor),(lxor),lnot,(lsl),(lsr),(asr) =\n\t\t\tlet open Int64 in\n\t\t\t(logand),(logor),(logxor),lognot,\n\t\t\t(fun u v -> shift_left u (i32 v)),\n\t\t\t(fun u v -> shift_right u (i32 v)),\n\t\t\t(fun u v -> shift_right_logical u (i32 v))\n\tend\n\t(* input *)\n\tlet input_i64_array n = Array.init (i32 n) (fun _ -> Scanf.scanf \" %Ld\" (fun v -> v))\n\tlet get_i64 _ = Scanf.scanf \" %Ld\" (fun v -> v)\n\tlet get_2_i64 _ = Scanf.scanf \" %Ld %Ld\" (fun u v -> u,v)\n\tlet get_3_i64 _ = Scanf.scanf \" %Ld %Ld %Ld\" (fun u v w -> u,v,w)\n\tlet get_4_i64 _ = Scanf.scanf \" %Ld %Ld %Ld %Ld\" (fun u v w x -> u,v,w,x)\n\tlet get_5_i64 _ = Scanf.scanf \" %Ld %Ld %Ld %Ld %Ld\" (fun u v w x y -> u,v,w,x,y)\n\tlet i32_get_int _ = Scanf.scanf \" %d\" (fun v -> v) let i32_get_2_ints _ = Scanf.scanf \" %d %d\" (fun u v -> u,v) let i32_get_3_ints _ = Scanf.scanf \" %d %d %d\" (fun u v w -> u,v,w) let i32_get_4_ints _ = Scanf.scanf \" %d %d %d %d\" (fun u v w x -> u,v,w,x) let i32_get_5_ints _ = Scanf.scanf \" %d %d %d %d %d\" (fun u v w x y -> u,v,w,x,y)\n\t(* utils *)\n\texternal id : 'a -> 'a = \"%identity\"\n\tlet ( *< ) f g x = f (g x)\n\tlet ( *> ) f g x = g (f x)\n\tlet rv f p q = f q p (* ex. 24 |> rv (/) 6 *)\n\tlet alen a = i64 @@ Array.length a\n\tlet llen l = i64 @@ List.length l\n\tlet string_of_list ?(separator=\" \") f ls = ls |> List.map f |> String.concat separator\n\tlet string_of_array ?(separator=\" \") f a = a |> Array.to_list |> string_of_list ~separator f\n\tlet char_list_of_string str = let rec f0 i a = if i<0 then a else f0 (i-$1) (str.[i]::a) in f0 (String.length str -$ 1) []\n\tlet string_of_char_list ls = List.fold_left (fun u v -> u ^ (String.make 1 v)) \"\" ls\n\tlet fail _ = failwith \"fail\"\n\tlet dx,dy = [|1;0;-1;0|],[|0;1;0;-1|]\n\tlet range l r = let ls = ref [] in for i=i32 l to i32 r do ls := i :: !ls done;!ls |> List.rev\n\tlet cartesian_product u v = u |> List.map (fun p -> List.map (fun q -> p,q) v) |> List.flatten\n\tlet shuffle a = Array.sort (fun _ _ -> (Random.int 3) -$ 1) a\n\tlet binary_search ng ok f = let d = if ng < ok then 1L else -1L in\n\t\tlet rec f0 ng ok =\n\t\t\tif labs (ok - ng) <= 1L then ok\n\t\t\telse let mid = ng + (ok - ng) / 2L in if f mid then f0 ng mid else f0 mid ok\n\t\tin f0 (ng-1L*d) (ok+1L*d)\n\tlet lower_bound a v = binary_search 0L (alen a - 1L) (fun i -> a.(i32 i) >= v)\n\tlet upper_bound a v = binary_search 0L (alen a - 1L) (fun i -> a.(i32 i) > v)\n\tlet equal_range a v = lower_bound a v, upper_bound a v (* #=snd-fst *)\n\tlet rec fix f x = f (fix f) x\n\tlet fix_memo ?(size=10000) f x =\n\t\tlet tb = Hashtbl.create ~random:true size in\n\t\tlet rec f0 x =\n\t\t\ttry Hashtbl.find tb x with\n\t\t\t| Not_found -> (let v = f f0 x in Hashtbl.add tb x v; v)\n\t\tin f0 x\n\t(* imperative *)\n\tlet rep f t ?(stride=1L) fbod = let i = ref f in while !i <= t do fbod !i; i := !i + stride done\n\tlet repb f t ?(stride=1L) fbod = let i,c = ref f,ref true in while !i <= t && !c do\n\t\tmatch fbod !i with | `Break -> c := false | `Ok -> i := !i + stride done\n\tlet repm f t ?(stride=1L) m0 fbod =\n\t\tlet i,c,m = ref f,ref true,ref m0 in\n\t\twhile !i<=t && !c do match fbod !m !i with\n\t\t| `Break -> c := false | `Break_m m' -> (c := false; m := m') | `Ok m' -> m := m'; i := !i + stride done; !m\n\tlet repi f t ?(stride=1) fbod = let i = ref f in while !i <= t do fbod !i; i := !i +$ stride done\n\tlet repib f t ?(stride=1) fbod = let i,c = ref f,ref true in while !i <= t && !c do\n\t\tmatch fbod !i with | `Break -> c := false | `Ok -> i := !i +$ stride done\n\tlet repim f t ?(stride=1) m0 fbod =\n\t\tlet i,c,m = ref f,ref true,ref m0 in\n\t\twhile !i<=t && !c do match fbod !m !i with\n\t\t| `Break -> c := false | `Break_m m' -> (c := false; m := m') | `Ok m' -> m := m'; i := !i +$ stride done; !m\n\tlet rep_rev f t ?(stride=1L) fbod = rep t f ~stride @@ fun v -> fbod @@ f + t - v\n\tlet repb_rev f t ?(stride=1L) fbod = repb t f ~stride @@ fun v -> fbod @@ f + t - v\n\tlet repm_rev f t ?(stride=1L) m0 fbod = repm f t ~stride m0 @@ fun u v -> fbod u @@ f + t - v\n\tlet repi_rev f t ?(stride=1) fbod = repi t f ~stride @@ fun v -> fbod @@ f +$ t -$ v\n\tlet repib_rev f t ?(stride=1) fbod = repib t f ~stride @@ fun v -> fbod @@ f +$ t -$ v\n\tlet repim_rev f t ?(stride=1) m0 fbod = repim f t ~stride m0 @@ fun u v -> fbod u @@ f +$ t -$ v\n\t(* output *)\n\tlet print_list_mle f ls = string_of_list f ls |> print_endline\n\tlet print_array_mle f a = string_of_array f a |> print_endline\n\tlet print_list f ls = ls |> List.iter (fun v -> printf \"%s \" @@ f v); print_newline ()\n\tlet print_array f a = a |> Array.iter (fun v -> printf \"%s \" @@ f v); print_newline ()\n\t(* debug *)\n\tlet dump_2darr f a = a |> Array.iter (fun b -> print_array f b)\n\tlet dump_i64_list ls = print_list ist ls\n\tlet dump_i64_array a = print_array ist a\nend open Lib open Array\n\nmodule SegTree = struct\n\tmodule type S = sig\n\t\ttype t\n\t\tval op: t -> t -> t\n\t\tval def: t\n\tend\n\tmodule RMQ = struct type t = int64 let op = min let def = max_i64 end\n\tlet par i = (i-$1)/$2\n\tlet chl i = 2*$i+$1\n\tlet chr i = 2*$i+$2\n\tmodule Make (X:S) = struct\n\t\ttype t = SegTree of (X.t array * int)\n\t\tlet raw (SegTree (a,_)) = a\n\t\tlet make raw =\n\t\t\tlet ln = Array.length raw in\n\t\t\tlet n =\n\t\t\t\tlet n = ref 1 in\n\t\t\t\twhile !n0 do\n\t\t\t\ti := par !i;\n\t\t\t\ta.(!i) <- X.op a.(chl !i) a.(chr !i) done\n\t\tlet get_half_open (SegTree(a,n)) l r = (* [l,r) *)\n\t\t\tlet rec f0 i p q =\n\t\t\t\tif q<=l || r<=p then X.def\n\t\t\t\telse if l<=p && q<=r then a.(i)\n\t\t\t\telse\n\t\t\t\t\tlet vl = f0 (2*$i+$1) p ((p+$q)/$2) in\n\t\t\t\t\tlet vr = f0 (2*$i+$2) ((p+$q)/$2) q in\n\t\t\t\t\tX.op vl vr\n\t\t\tin f0 0 0 n\n\t\tlet get_closed seg l r = get_half_open seg l (r+$1) (* [l,r] *)\n\tend\nend\n\nmodule RMQ = SegTree.Make(SegTree.RMQ)\nlet () =\n\tlet n,q = get_2_i64 0 in\n\tlet a = RMQ.make (make (i32 n) (i64 (2 lsl 30) - 1L)) in\n\trep 1L q (fun _ ->\n\t\tlet com,x,y = get_3_i64 0 in\n\t\tif com = 0L then (\n\t\t\tRMQ.update_destructive a (i32 x) y\n\t\t) else (\n\t\t\tprintf \"%Ld\\n\" @@ RMQ.get_closed a (i32 x) (i32 y)\n\t\t)\n\t)\n\n\n\n\n\n\n\n\n\n", "problem_context": "Range Minimum Query (RMQ)\n\nWrite a program which manipulates a sequence A = {a0, a1, . . . , an-1} with the following operations:\n\nfind(s, t): report the minimum element in as, as+1, . . . ,at.\n\nupdate(i, x): change ai to x.\n\nNote that the initial values of ai (i = 0, 1, . . . , n−1) are 231-1.\n\nInput\n\nn q\ncom0 x0 y0\ncom1 x1 y1\n...\ncomq−1 xq−1 yq−1\n\nIn the first line, n (the number of elements in A) and q (the number of queries) are given. Then, q queries are given where com represents the type of queries. '0' denotes update(xi, yi) and '1' denotes find(xi, yi).\n\nOutput\n\nFor each find operation, print the minimum element.\n\nConstraints\n\n1 ≤ n ≤ 100000\n\n1 ≤ q ≤ 100000\n\nIf comi is 0, then 0 ≤ xi < n, 0 ≤ yi < 231-1.\n\nIf comi is 1, then 0 ≤ xi < n, 0 ≤ yi < n.\n\nSample Input 1\n\n3 5\n0 0 1\n0 1 2\n0 2 3\n1 0 2\n1 1 2\n\nSample Output 1\n\n1\n2\n\nSample Input 2\n\n1 3\n1 0 0\n0 0 5\n1 0 0\n\nSample Output 2\n\n2147483647\n5", "sample_input": "3 5\n0 0 1\n0 1 2\n0 2 3\n1 0 2\n1 1 2\n"}, "reference_outputs": ["1\n2\n"], "source_document_id": "p02345", "source_text": "Range Minimum Query (RMQ)\n\nWrite a program which manipulates a sequence A = {a0, a1, . . . , an-1} with the following operations:\n\nfind(s, t): report the minimum element in as, as+1, . . . ,at.\n\nupdate(i, x): change ai to x.\n\nNote that the initial values of ai (i = 0, 1, . . . , n−1) are 231-1.\n\nInput\n\nn q\ncom0 x0 y0\ncom1 x1 y1\n...\ncomq−1 xq−1 yq−1\n\nIn the first line, n (the number of elements in A) and q (the number of queries) are given. Then, q queries are given where com represents the type of queries. '0' denotes update(xi, yi) and '1' denotes find(xi, yi).\n\nOutput\n\nFor each find operation, print the minimum element.\n\nConstraints\n\n1 ≤ n ≤ 100000\n\n1 ≤ q ≤ 100000\n\nIf comi is 0, then 0 ≤ xi < n, 0 ≤ yi < 231-1.\n\nIf comi is 1, then 0 ≤ xi < n, 0 ≤ yi < n.\n\nSample Input 1\n\n3 5\n0 0 1\n0 1 2\n0 2 3\n1 0 2\n1 1 2\n\nSample Output 1\n\n1\n2\n\nSample Input 2\n\n1 3\n1 0 0\n0 0 5\n1 0 0\n\nSample Output 2\n\n2147483647\n5", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 6787, "cpu_time_ms": 120, "memory_kb": 8948}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s784855223", "group_id": "codeNet:p02346", "input_text": "let split_on_char sep s =\n let open String in\n let r = ref [] in\n let j = ref (length s) in\n for i = length s - 1 downto 0 do\n if get s i = sep then begin\n r := sub s (i + 1) (!j - i - 1) :: !r;\n j := i\n end\n done;\n sub s 0 !j :: !r\n\nlet parent i = int_of_float ((float_of_int (i - 1)) /. 2.)\n\nlet left i = 2*i + 1\n\nlet right i = 2*i + 2\n\nlet to_pow_of_2 n =\n let rec doit i =\n if i > n then i\n else doit (i * 2) in\n doit 1\n\nlet add s n i x =\n let j = n + i - 1 in\n s.(j) <- x + s.(j);\n let rec doit j =\n if j > 0 then begin\n let j = parent j in\n s.(j) <- s.(left j) + s.(right j);\n doit j\n end in\n doit j\n\nlet sum s n a b =\n let rec doit a b k l r =\n if r < a || b < l then 0\n else if a <= l && r <= b then s.(k)\n else doit a b (left k) l ((l + r) / 2) + doit a b (right k) ((l + r) / 2 + 1) r in\n doit a b 0 0 (n - 1)\n\nlet solve n q =\n let n = to_pow_of_2 n in\n let s = Array.make (2*n) 0 in\n let rec doit i =\n if i < q then begin\n begin match List.map int_of_string (split_on_char ' ' (read_line ())) with\n | 0 :: x :: y :: _ -> add s n x y\n | 1 :: x :: y :: _ -> Printf.printf \"%d\\n\" (sum s n x y)\n | _ -> ()\n end;\n doit (i + 1)\n end in\n doit 0\n\nlet () =\n match List.map int_of_string (split_on_char ' ' (read_line ())) with\n | [n; q] -> solve n q\n | _ -> ()", "language": "OCaml", "metadata": {"date": 1479574560, "filename_ext": "ml", "original_language": "OCaml", "problem_description_relpath": "problem_descriptions/p02346.html", "problem_id": "p02346", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02346/input.txt", "sample_output_relpath": "derived/input_output/data/p02346/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02346/OCaml/s784855223.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s784855223", "user_id": "u809138450"}, "prompt_components": {"gold_output": "3\n2\n", "input_to_evaluate": "let split_on_char sep s =\n let open String in\n let r = ref [] in\n let j = ref (length s) in\n for i = length s - 1 downto 0 do\n if get s i = sep then begin\n r := sub s (i + 1) (!j - i - 1) :: !r;\n j := i\n end\n done;\n sub s 0 !j :: !r\n\nlet parent i = int_of_float ((float_of_int (i - 1)) /. 2.)\n\nlet left i = 2*i + 1\n\nlet right i = 2*i + 2\n\nlet to_pow_of_2 n =\n let rec doit i =\n if i > n then i\n else doit (i * 2) in\n doit 1\n\nlet add s n i x =\n let j = n + i - 1 in\n s.(j) <- x + s.(j);\n let rec doit j =\n if j > 0 then begin\n let j = parent j in\n s.(j) <- s.(left j) + s.(right j);\n doit j\n end in\n doit j\n\nlet sum s n a b =\n let rec doit a b k l r =\n if r < a || b < l then 0\n else if a <= l && r <= b then s.(k)\n else doit a b (left k) l ((l + r) / 2) + doit a b (right k) ((l + r) / 2 + 1) r in\n doit a b 0 0 (n - 1)\n\nlet solve n q =\n let n = to_pow_of_2 n in\n let s = Array.make (2*n) 0 in\n let rec doit i =\n if i < q then begin\n begin match List.map int_of_string (split_on_char ' ' (read_line ())) with\n | 0 :: x :: y :: _ -> add s n x y\n | 1 :: x :: y :: _ -> Printf.printf \"%d\\n\" (sum s n x y)\n | _ -> ()\n end;\n doit (i + 1)\n end in\n doit 0\n\nlet () =\n match List.map int_of_string (split_on_char ' ' (read_line ())) with\n | [n; q] -> solve n q\n | _ -> ()", "problem_context": "Range Sum Query\n\nWrite a program which manipulates a sequence A = {a1, a2, . . . , an} with the following operations:\n\nadd(i, x): add x to ai.\n\ngetSum(s, t): print the sum of as, as+1,...,at.\n\nNote that the initial values of ai (i = 1, 2, . . . , n) are 0.\n\nInput\n\nn q\ncom1 x1 y1\ncom2 x2 y2\n...\ncomq xq yq\n\nIn the first line, n (the number of elements in A) and q (the number of queries) are given. Then, q queries are given where com represents the type of queries. '0' denotes add(xi, yi) and '1' denotes getSum(xi, yi).\n\nOutput\n\nFor each getSum operation, print the sum in a line.\n\nConstraints\n\n1 ≤ n ≤ 100000\n\n1 ≤ q ≤ 100000\n\nIf comi is 0, then 1 ≤ xi ≤ n, 0 ≤ yi ≤ 1000.\n\nIf comi is 1, then 1 ≤ xi ≤ n, 1 ≤ yi ≤ n.\n\nSample Input 1\n\n3 5\n0 1 1\n0 2 2\n0 3 3\n1 1 2\n1 2 2\n\nSample Output 1\n\n3\n2", "sample_input": "3 5\n0 1 1\n0 2 2\n0 3 3\n1 1 2\n1 2 2\n"}, "reference_outputs": ["3\n2\n"], "source_document_id": "p02346", "source_text": "Range Sum Query\n\nWrite a program which manipulates a sequence A = {a1, a2, . . . , an} with the following operations:\n\nadd(i, x): add x to ai.\n\ngetSum(s, t): print the sum of as, as+1,...,at.\n\nNote that the initial values of ai (i = 1, 2, . . . , n) are 0.\n\nInput\n\nn q\ncom1 x1 y1\ncom2 x2 y2\n...\ncomq xq yq\n\nIn the first line, n (the number of elements in A) and q (the number of queries) are given. Then, q queries are given where com represents the type of queries. '0' denotes add(xi, yi) and '1' denotes getSum(xi, yi).\n\nOutput\n\nFor each getSum operation, print the sum in a line.\n\nConstraints\n\n1 ≤ n ≤ 100000\n\n1 ≤ q ≤ 100000\n\nIf comi is 0, then 1 ≤ xi ≤ n, 0 ≤ yi ≤ 1000.\n\nIf comi is 1, then 1 ≤ xi ≤ n, 1 ≤ yi ≤ n.\n\nSample Input 1\n\n3 5\n0 1 1\n0 2 2\n0 3 3\n1 1 2\n1 2 2\n\nSample Output 1\n\n3\n2", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1371, "cpu_time_ms": 80, "memory_kb": 6532}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s193448629", "group_id": "codeNet:p02347", "input_text": "let nil = -1\n\ntype node = {\n value : int;\n left : int;\n right : int;\n}\n\nlet make_node () = { value = nil; left = nil; right = nil }\n\nlet split str delim =\n let open String in\n let rec doit s acc =\n match\n try Some (rindex s delim) with _ -> None\n with\n | None -> s :: acc\n | Some i -> doit (sub s 0 i) (sub s (i + 1) (length s - i - 1) :: acc) in\n doit str []\n\nlet sort_range (a : (int * int * int) array) first last cmp =\n let swap i j = let tmp = a.(i) in a.(i) <- a.(j); a.(j) <- tmp in\n let partition p r =\n let rec exchange = function\n | (i, j) when j = r -> swap i r; i\n | (i, j) when cmp a.(j) a.(r) <= 0 -> swap i j; exchange (i + 1, j + 1)\n | (i, j) -> exchange (i, j + 1) in\n exchange (p, p) in\n let rec doit p r =\n if p < r then begin\n let q = partition p r in\n doit p (q - 1);\n doit q r\n end in\n doit first (last - 1)\n\nlet make_kd_tree p t n =\n let num = ref 0 in\n let rec doit l r d =\n if l >= r then nil\n else begin\n if d mod 2 = 0 then sort_range p l r (fun (_, ax, _) (_, bx, _) -> ax - bx)\n else sort_range p l r (fun (_, _, ay) (_, _, by) -> ay - by);\n let m = (l + r) / 2 in\n let i = !num in\n incr num;\n let il = doit l m (d + 1) in\n let ir = doit (m + 1) r (d + 1) in\n t.(i) <- { value = m; left = il; right = ir };\n i\n end in\n let _ = doit 0 n 0 in\n (p, t)\n\nlet find (p : (int * int * int) array) t (sx, sy) (tx, ty) =\n let acc = ref [] in\n let rec doit i d =\n let (id, x, y) = p.(t.(i).value) in\n if sx <= x && x <= tx && sy <= y && y <= ty then acc := id :: !acc;\n if d mod 2 = 0 then begin\n if t.(i).left != nil && sx <= x then doit t.(i).left (d + 1);\n if t.(i).right != nil && x <= tx then doit t.(i).right (d + 1);\n end else begin\n if t.(i).left != nil && sy <= y then doit t.(i).left (d + 1);\n if t.(i).right != nil && y <= ty then doit t.(i).right (d + 1);\n end in\n doit 0 0;\n acc\n\nlet () =\n let n = read_int () in\n let p = Array.init n (fun i ->\n match List.map int_of_string (split (read_line ()) ' ') with\n | [x; y] -> (i, x, y)\n | _ -> exit 1) in\n let t = Array.make n (make_node ()) in\n let (p, t) = make_kd_tree p t n in\n let q = read_int () in\n let rec doit i =\n if i < q then\n begin match List.map int_of_string (split (read_line ()) ' ') with\n | [sx; tx; sy; ty] ->\n let z = find p t (sx, sy) (tx, ty) in\n List.iter (fun e -> Printf.printf \"%d\\n\" e) (List.sort (-) !z);\n print_newline ();\n doit (i + 1)\n | _ -> exit 1\n end in\n doit 0", "language": "OCaml", "metadata": {"date": 1476444365, "filename_ext": "ml", "original_language": "OCaml", "problem_description_relpath": "problem_descriptions/p02347.html", "problem_id": "p02347", "resource_group": "low_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/OCaml/s193448629.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s193448629", "user_id": "u809138450"}, "prompt_components": {"gold_output": "0\n1\n2\n4\n\n2\n3\n5\n", "input_to_evaluate": "let nil = -1\n\ntype node = {\n value : int;\n left : int;\n right : int;\n}\n\nlet make_node () = { value = nil; left = nil; right = nil }\n\nlet split str delim =\n let open String in\n let rec doit s acc =\n match\n try Some (rindex s delim) with _ -> None\n with\n | None -> s :: acc\n | Some i -> doit (sub s 0 i) (sub s (i + 1) (length s - i - 1) :: acc) in\n doit str []\n\nlet sort_range (a : (int * int * int) array) first last cmp =\n let swap i j = let tmp = a.(i) in a.(i) <- a.(j); a.(j) <- tmp in\n let partition p r =\n let rec exchange = function\n | (i, j) when j = r -> swap i r; i\n | (i, j) when cmp a.(j) a.(r) <= 0 -> swap i j; exchange (i + 1, j + 1)\n | (i, j) -> exchange (i, j + 1) in\n exchange (p, p) in\n let rec doit p r =\n if p < r then begin\n let q = partition p r in\n doit p (q - 1);\n doit q r\n end in\n doit first (last - 1)\n\nlet make_kd_tree p t n =\n let num = ref 0 in\n let rec doit l r d =\n if l >= r then nil\n else begin\n if d mod 2 = 0 then sort_range p l r (fun (_, ax, _) (_, bx, _) -> ax - bx)\n else sort_range p l r (fun (_, _, ay) (_, _, by) -> ay - by);\n let m = (l + r) / 2 in\n let i = !num in\n incr num;\n let il = doit l m (d + 1) in\n let ir = doit (m + 1) r (d + 1) in\n t.(i) <- { value = m; left = il; right = ir };\n i\n end in\n let _ = doit 0 n 0 in\n (p, t)\n\nlet find (p : (int * int * int) array) t (sx, sy) (tx, ty) =\n let acc = ref [] in\n let rec doit i d =\n let (id, x, y) = p.(t.(i).value) in\n if sx <= x && x <= tx && sy <= y && y <= ty then acc := id :: !acc;\n if d mod 2 = 0 then begin\n if t.(i).left != nil && sx <= x then doit t.(i).left (d + 1);\n if t.(i).right != nil && x <= tx then doit t.(i).right (d + 1);\n end else begin\n if t.(i).left != nil && sy <= y then doit t.(i).left (d + 1);\n if t.(i).right != nil && y <= ty then doit t.(i).right (d + 1);\n end in\n doit 0 0;\n acc\n\nlet () =\n let n = read_int () in\n let p = Array.init n (fun i ->\n match List.map int_of_string (split (read_line ()) ' ') with\n | [x; y] -> (i, x, y)\n | _ -> exit 1) in\n let t = Array.make n (make_node ()) in\n let (p, t) = make_kd_tree p t n in\n let q = read_int () in\n let rec doit i =\n if i < q then\n begin match List.map int_of_string (split (read_line ()) ' ') with\n | [sx; tx; sy; ty] ->\n let z = find p t (sx, sy) (tx, ty) in\n List.iter (fun e -> Printf.printf \"%d\\n\" e) (List.sort (-) !z);\n print_newline ();\n doit (i + 1)\n | _ -> exit 1\n end in\n doit 0", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2604, "cpu_time_ms": 20000, "memory_kb": 38244}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s844950120", "group_id": "codeNet:p02347", "input_text": "let nil = -1\n\ntype node = { value : int; left : int; right : int }\n\nlet make_node () = { value = nil; left = nil; right = nil }\n\nlet split_on_char sep s =\n let open String in\n let r = ref [] in\n let j = ref (length s) in\n for i = length s - 1 downto 0 do\n if get s i = sep then begin\n r := sub s (i + 1) (!j - i - 1) :: !r;\n j := i\n end\n done;\n sub s 0 !j :: !r\n\nlet sort_range (a : (int * int * int) array) first last cmp =\n let swap i j = let tmp = a.(i) in a.(i) <- a.(j); a.(j) <- tmp in\n let partition p r =\n let i = ref p in\n for j = p to r - 1 do\n if cmp a.(j) a.(r) <= 0 then (swap !i j; incr i)\n done;\n swap !i r;\n !i in\n let rec doit p r =\n if p >= r then () else\n let q = partition p r in\n doit p (q - 1);\n doit (q + 1) r in\n doit first (last - 1)\n\nlet make_kd_tree p t n =\n let rec doit l r d =\n if l >= r then nil\n else begin\n if d mod 2 = 0 then sort_range p l r (fun (_, ax, _) (_, bx, _) -> ax - bx)\n else sort_range p l r (fun (_, _, ay) (_, _, by) -> ay - by);\n let m = (l + r) / 2 in\n t.(m) <- {value = m; left = doit l m (d + 1); right = doit (m + 1) r (d + 1)};\n m\n end in\n let root = doit 0 n 0 in\n (root, p, t)\n\nlet ans = ref []\n\nlet find (p : (int * int * int) array) t root sx tx sy ty =\n let rec doit i d =\n let (id, x, y) = p.(t.(i).value) in\n if sx <= x && x <= tx && sy <= y && y <= ty then ans := id :: !ans;\n if d mod 2 = 0 then begin\n if t.(i).left != nil && sx <= x then doit t.(i).left (d + 1);\n if t.(i).right != nil && x <= tx then doit t.(i).right (d + 1);\n end else begin\n if t.(i).left != nil && sy <= y then doit t.(i).left (d + 1);\n if t.(i).right != nil && y <= ty then doit t.(i).right (d + 1);\n end in\n doit root 0\n\nlet () =\n let n = read_int () in\n let p =\n Array.init n (fun i ->\n match read_line () |> split_on_char ' ' |> List.map int_of_string with\n | [x; y] -> (i, x, y)\n | _ -> assert false) in\n let t = Array.make n (make_node ()) in\n let (root, p, t) = make_kd_tree p t n in\n let q = read_int () in\n for _ = 0 to q - 1 do\n match read_line () |> split_on_char ' ' |> List.map int_of_string with\n | [sx; tx; sy; ty] ->\n find p t root sx tx sy ty;\n List.iter (fun e -> print_int e; print_newline ()) (List.sort (-) !ans);\n print_newline ();\n ans := []\n | _ -> assert false\n done", "language": "OCaml", "metadata": {"date": 1500208208, "filename_ext": "ml", "original_language": "OCaml", "problem_description_relpath": "problem_descriptions/p02347.html", "problem_id": "p02347", "resource_group": "low_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/OCaml/s844950120.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s844950120", "user_id": "u809138450"}, "prompt_components": {"gold_output": "0\n1\n2\n4\n\n2\n3\n5\n", "input_to_evaluate": "let nil = -1\n\ntype node = { value : int; left : int; right : int }\n\nlet make_node () = { value = nil; left = nil; right = nil }\n\nlet split_on_char sep s =\n let open String in\n let r = ref [] in\n let j = ref (length s) in\n for i = length s - 1 downto 0 do\n if get s i = sep then begin\n r := sub s (i + 1) (!j - i - 1) :: !r;\n j := i\n end\n done;\n sub s 0 !j :: !r\n\nlet sort_range (a : (int * int * int) array) first last cmp =\n let swap i j = let tmp = a.(i) in a.(i) <- a.(j); a.(j) <- tmp in\n let partition p r =\n let i = ref p in\n for j = p to r - 1 do\n if cmp a.(j) a.(r) <= 0 then (swap !i j; incr i)\n done;\n swap !i r;\n !i in\n let rec doit p r =\n if p >= r then () else\n let q = partition p r in\n doit p (q - 1);\n doit (q + 1) r in\n doit first (last - 1)\n\nlet make_kd_tree p t n =\n let rec doit l r d =\n if l >= r then nil\n else begin\n if d mod 2 = 0 then sort_range p l r (fun (_, ax, _) (_, bx, _) -> ax - bx)\n else sort_range p l r (fun (_, _, ay) (_, _, by) -> ay - by);\n let m = (l + r) / 2 in\n t.(m) <- {value = m; left = doit l m (d + 1); right = doit (m + 1) r (d + 1)};\n m\n end in\n let root = doit 0 n 0 in\n (root, p, t)\n\nlet ans = ref []\n\nlet find (p : (int * int * int) array) t root sx tx sy ty =\n let rec doit i d =\n let (id, x, y) = p.(t.(i).value) in\n if sx <= x && x <= tx && sy <= y && y <= ty then ans := id :: !ans;\n if d mod 2 = 0 then begin\n if t.(i).left != nil && sx <= x then doit t.(i).left (d + 1);\n if t.(i).right != nil && x <= tx then doit t.(i).right (d + 1);\n end else begin\n if t.(i).left != nil && sy <= y then doit t.(i).left (d + 1);\n if t.(i).right != nil && y <= ty then doit t.(i).right (d + 1);\n end in\n doit root 0\n\nlet () =\n let n = read_int () in\n let p =\n Array.init n (fun i ->\n match read_line () |> split_on_char ' ' |> List.map int_of_string with\n | [x; y] -> (i, x, y)\n | _ -> assert false) in\n let t = Array.make n (make_node ()) in\n let (root, p, t) = make_kd_tree p t n in\n let q = read_int () in\n for _ = 0 to q - 1 do\n match read_line () |> split_on_char ' ' |> List.map int_of_string with\n | [sx; tx; sy; ty] ->\n find p t root sx tx sy ty;\n List.iter (fun e -> print_int e; print_newline ()) (List.sort (-) !ans);\n print_newline ();\n ans := []\n | _ -> assert false\n done", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2414, "cpu_time_ms": 20000, "memory_kb": 38092}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s985167390", "group_id": "codeNet:p02349", "input_text": "open Printf\nopen Scanf\n\nlet () =\n let n, q = scanf \"%d %d \" (fun x y -> (x, y)) in\n let st = Array.make (4*n) 0 in\n let add s t x =\n let rec iter k l r =\n if t <= l || r <= s then ()\n else if s <= l && r <= t then\n st.(k) <- st.(k) + x\n else\n let m = (l + r) / 2 in\n iter (2*k) l m;\n iter (2*k+1) m r in\n iter 1 0 n in\n let get i =\n let rec iter k l r s =\n if i = l && i+1 = r then s + st.(k)\n else\n let m = (l + r) / 2 in\n if i < m then iter (2*k) l m (s + st.(k))\n else iter (2*k+1) m r (s + st.(k))\n in\n iter 1 0 n 0 in\n let rec loop c =\n if c = 0 then ()\n else\n begin\n begin\n let com = scanf \"%d \" (fun a -> a) in\n if com = 0 then\n let s, t, x = scanf \"%d %d %d \" (fun a b c -> (a-1, b, c)) in\n add s t x\n else\n let i = scanf \"%d \" (fun a -> a-1) in\n get i |> printf \"%d\\n\"\n end;\n loop (c-1)\n end\n in loop q", "language": "OCaml", "metadata": {"date": 1503469355, "filename_ext": "ml", "original_language": "OCaml", "problem_description_relpath": "problem_descriptions/p02349.html", "problem_id": "p02349", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02349/input.txt", "sample_output_relpath": "derived/input_output/data/p02349/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02349/OCaml/s985167390.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s985167390", "user_id": "u049242937"}, "prompt_components": {"gold_output": "3\n5\n", "input_to_evaluate": "open Printf\nopen Scanf\n\nlet () =\n let n, q = scanf \"%d %d \" (fun x y -> (x, y)) in\n let st = Array.make (4*n) 0 in\n let add s t x =\n let rec iter k l r =\n if t <= l || r <= s then ()\n else if s <= l && r <= t then\n st.(k) <- st.(k) + x\n else\n let m = (l + r) / 2 in\n iter (2*k) l m;\n iter (2*k+1) m r in\n iter 1 0 n in\n let get i =\n let rec iter k l r s =\n if i = l && i+1 = r then s + st.(k)\n else\n let m = (l + r) / 2 in\n if i < m then iter (2*k) l m (s + st.(k))\n else iter (2*k+1) m r (s + st.(k))\n in\n iter 1 0 n 0 in\n let rec loop c =\n if c = 0 then ()\n else\n begin\n begin\n let com = scanf \"%d \" (fun a -> a) in\n if com = 0 then\n let s, t, x = scanf \"%d %d %d \" (fun a b c -> (a-1, b, c)) in\n add s t x\n else\n let i = scanf \"%d \" (fun a -> a-1) in\n get i |> printf \"%d\\n\"\n end;\n loop (c-1)\n end\n in loop q", "problem_context": "Range Add Query (RAQ)\n\nWrite a program which manipulates a sequence A = {a1, a2, . . . , an} with the following operations:\n\nadd(s, t, x): add x to as, as+1, ..., at.\n\nget(i): output the value of ai.\n\nNote that the initial values of ai (i = 1, 2, . . . , n) are 0.\n\nInput\n\nn q\nquery1\nquery2\n:\nqueryq\n\nIn the first line, n (the number of elements in A) and q (the number of queries) are given. Then, ith query queryi is given in the following format:\n\n0 s t x\n\nor\n\n1 t\n\nThe first digit represents the type of the query. '0' denotes add(s, t, x) and '1' denotes get(i).\n\nOutput\n\nFor each get operation, print the value.\n\nConstraints\n\n1 ≤ n ≤ 100000\n\n1 ≤ q ≤ 100000\n\n1 ≤ s ≤ t ≤ n\n\n1 ≤ i ≤ n\n\n0 ≤ x ≤ 1000\n\nSample Input 1\n\n3 5\n0 1 2 1\n0 2 3 2\n0 3 3 3\n1 2\n1 3\n\nSample Output 1\n\n3\n5\n\nSample Input 2\n\n4 3\n1 2\n0 1 4 1\n1 2\n\nSample Output 2\n\n0\n1", "sample_input": "3 5\n0 1 2 1\n0 2 3 2\n0 3 3 3\n1 2\n1 3\n"}, "reference_outputs": ["3\n5\n"], "source_document_id": "p02349", "source_text": "Range Add Query (RAQ)\n\nWrite a program which manipulates a sequence A = {a1, a2, . . . , an} with the following operations:\n\nadd(s, t, x): add x to as, as+1, ..., at.\n\nget(i): output the value of ai.\n\nNote that the initial values of ai (i = 1, 2, . . . , n) are 0.\n\nInput\n\nn q\nquery1\nquery2\n:\nqueryq\n\nIn the first line, n (the number of elements in A) and q (the number of queries) are given. Then, ith query queryi is given in the following format:\n\n0 s t x\n\nor\n\n1 t\n\nThe first digit represents the type of the query. '0' denotes add(s, t, x) and '1' denotes get(i).\n\nOutput\n\nFor each get operation, print the value.\n\nConstraints\n\n1 ≤ n ≤ 100000\n\n1 ≤ q ≤ 100000\n\n1 ≤ s ≤ t ≤ n\n\n1 ≤ i ≤ n\n\n0 ≤ x ≤ 1000\n\nSample Input 1\n\n3 5\n0 1 2 1\n0 2 3 2\n0 3 3 3\n1 2\n1 3\n\nSample Output 1\n\n3\n5\n\nSample Input 2\n\n4 3\n1 2\n0 1 4 1\n1 2\n\nSample Output 2\n\n0\n1", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1014, "cpu_time_ms": 50, "memory_kb": 7768}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s112854691", "group_id": "codeNet:p02350", "input_text": "open Printf\nopen Scanf\n\nlet () =\n let n, q = scanf \"%d %d \" (fun a b -> (a, b)) in\n let b = 300 in\n let iv = 2147483647 in\n let ar = Array.make n iv in\n let ubk = Array.make ((n + b - 1) / b) None in\n let mbk = Array.make ((n + b - 1) / b) iv in\n let wb i = match ubk.(i) with\n None -> ()\n | Some v -> let rec iter j =\n if j = b then ubk.(i) <- None\n else begin\n ar.(i*b+j) <- v;\n iter (j+1)\n end in\n iter 0;\n mbk.(i) <- v\n in\n let update s t x =\n let rec iter i =\n if i >= t then ()\n else\n if i mod b = 0 && i + b <= t then\n begin\n ubk.(i / b) <- Some x;\n mbk.(i / b) <- x;\n iter (i + b)\n end\n else\n begin\n (match ubk.(i / b) with\n None -> ()\n | Some _ -> wb (i / b));\n ar.(i) <- x;\n mbk.(i / b) <- min mbk.(i / b) x;\n iter (i + 1)\n end\n in iter s\n in\n let find s t =\n let rec iter i m =\n if i >= t then m\n else\n if i mod b = 0 && i + b <= t then\n iter (i + b) (min m mbk.(i / b))\n else\n iter (i + 1) (min m ar.(i))\n in\n iter s iv\n in\n let rec loop c =\n if c = 0 then ()\n else\n begin\n (let com = scanf \"%d \" (fun u -> u) in\n if com = 0 then\n let s, t, x = scanf \"%d %d %d \" (fun u v w -> (u, v+1, w)) in\n update s t x\n else\n let s, t = scanf \"%d %d \" (fun u v -> (u, v+1)) in\n find s t |> printf \"%d\\n\");\n loop (c - 1)\n end\n in\n loop q", "language": "OCaml", "metadata": {"date": 1503497881, "filename_ext": "ml", "original_language": "OCaml", "problem_description_relpath": "problem_descriptions/p02350.html", "problem_id": "p02350", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02350/input.txt", "sample_output_relpath": "derived/input_output/data/p02350/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02350/OCaml/s112854691.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s112854691", "user_id": "u049242937"}, "prompt_components": {"gold_output": "1\n2\n", "input_to_evaluate": "open Printf\nopen Scanf\n\nlet () =\n let n, q = scanf \"%d %d \" (fun a b -> (a, b)) in\n let b = 300 in\n let iv = 2147483647 in\n let ar = Array.make n iv in\n let ubk = Array.make ((n + b - 1) / b) None in\n let mbk = Array.make ((n + b - 1) / b) iv in\n let wb i = match ubk.(i) with\n None -> ()\n | Some v -> let rec iter j =\n if j = b then ubk.(i) <- None\n else begin\n ar.(i*b+j) <- v;\n iter (j+1)\n end in\n iter 0;\n mbk.(i) <- v\n in\n let update s t x =\n let rec iter i =\n if i >= t then ()\n else\n if i mod b = 0 && i + b <= t then\n begin\n ubk.(i / b) <- Some x;\n mbk.(i / b) <- x;\n iter (i + b)\n end\n else\n begin\n (match ubk.(i / b) with\n None -> ()\n | Some _ -> wb (i / b));\n ar.(i) <- x;\n mbk.(i / b) <- min mbk.(i / b) x;\n iter (i + 1)\n end\n in iter s\n in\n let find s t =\n let rec iter i m =\n if i >= t then m\n else\n if i mod b = 0 && i + b <= t then\n iter (i + b) (min m mbk.(i / b))\n else\n iter (i + 1) (min m ar.(i))\n in\n iter s iv\n in\n let rec loop c =\n if c = 0 then ()\n else\n begin\n (let com = scanf \"%d \" (fun u -> u) in\n if com = 0 then\n let s, t, x = scanf \"%d %d %d \" (fun u v w -> (u, v+1, w)) in\n update s t x\n else\n let s, t = scanf \"%d %d \" (fun u v -> (u, v+1)) in\n find s t |> printf \"%d\\n\");\n loop (c - 1)\n end\n in\n loop q", "problem_context": "RMQ and RUQ\n\nWrite a program which manipulates a sequence A = {a0, a1, . . . , an−1} with the following operations:\n\nupdate(s, t, x): change as, as+1, ..., at to x.\n\nfind(s, t): report the minimum element in as, as+1, ..., at.\n\nNote that the initial values of ai (i = 0, 1, . . . , n−1) are 231-1.\n\nInput\n\nn q\nquery1\nquery2\n:\nqueryq\n\nIn the first line, n (the number of elements in A) and q (the number of queries) are given. Then, ith query queryi is given in the following format:\n\n0 s t x\n\nor\n\n1 s t\n\nThe first digit represents the type of the query. '0' denotes update(s, t, x) and '1' denotes find(s, t).\n\nOutput\n\nFor each find operation, print the minimum value.\n\nConstraints\n\n1 ≤ n ≤ 100000\n\n1 ≤ q ≤ 100000\n\n0 ≤ s ≤ t < n\n\n0 ≤ x < 231−1\n\nSample Input 1\n\n3 5\n0 0 1 1\n0 1 2 3\n0 2 2 2\n1 0 2\n1 1 2\n\nSample Output 1\n\n1\n2\n\nSample Input 2\n\n1 3\n1 0 0\n0 0 0 5\n1 0 0\n\nSample Output 2\n\n2147483647\n5", "sample_input": "3 5\n0 0 1 1\n0 1 2 3\n0 2 2 2\n1 0 2\n1 1 2\n"}, "reference_outputs": ["1\n2\n"], "source_document_id": "p02350", "source_text": "RMQ and RUQ\n\nWrite a program which manipulates a sequence A = {a0, a1, . . . , an−1} with the following operations:\n\nupdate(s, t, x): change as, as+1, ..., at to x.\n\nfind(s, t): report the minimum element in as, as+1, ..., at.\n\nNote that the initial values of ai (i = 0, 1, . . . , n−1) are 231-1.\n\nInput\n\nn q\nquery1\nquery2\n:\nqueryq\n\nIn the first line, n (the number of elements in A) and q (the number of queries) are given. Then, ith query queryi is given in the following format:\n\n0 s t x\n\nor\n\n1 s t\n\nThe first digit represents the type of the query. '0' denotes update(s, t, x) and '1' denotes find(s, t).\n\nOutput\n\nFor each find operation, print the minimum value.\n\nConstraints\n\n1 ≤ n ≤ 100000\n\n1 ≤ q ≤ 100000\n\n0 ≤ s ≤ t < n\n\n0 ≤ x < 231−1\n\nSample Input 1\n\n3 5\n0 0 1 1\n0 1 2 3\n0 2 2 2\n1 0 2\n1 1 2\n\nSample Output 1\n\n1\n2\n\nSample Input 2\n\n1 3\n1 0 0\n0 0 0 5\n1 0 0\n\nSample Output 2\n\n2147483647\n5", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1684, "cpu_time_ms": 30, "memory_kb": 4560}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s170587947", "group_id": "codeNet:p02536", "input_text": "open Batteries\nclass union_find n = object (self)\n val mutable par = ( [| |] : int array)\n method init = \n par <- Array.init n (fun a -> a)\n method get_par = par\n\n method root s = \n let rec loop x =\n if par.(x) = x then x else (par.(x) <- loop par.(x); par.(x))\n in loop s\n\n method rank s =\n let rec loop x n =\n if par.(x) = x then n else loop par.(x) (n+1)\n in loop s 1\n\n method unite x y =\n let xrank = self#rank x in\n let yrank = self#rank x in\n let rx = self#root x in\n let ry = self#root y in\n if rx != ry then (if xrank < yrank then par.(rx) <- ry else par.(ry) <- rx)\n\n method same x y = self#root x = self#root y\n\n method members x = (* 要素xが属する木の全ての要素を返す *) \n let r = self#root x in Array.fold_left (fun a y -> if self#root y = r then y :: a else a) [] par\n\n method roots = (* 全ての根 *) Array.fold_left (fun x y -> if List.mem y x then x else y :: x) [] par\n\n method tree_count = (* 木の数 *) List.length @@ self#roots\nend\n\n\nlet n, m = Scanf.sscanf (read_line()) \"%d %d\" (fun n m -> n,m)\nlet tree = new union_find n\nlet _ = tree#init\nlet rec loop i =\n if i >= m then () else Scanf.sscanf (read_line()) \"%d %d\" (fun a b -> tree#unite a b; loop (i+1))\n\nlet () = loop 0\nlet rec get_next result =\n if result >= n then -1 else\n if tree#same 0 result then get_next (result+1) else result\nlet rec tree_loop result =\n let a, b = (0, get_next 0) in\n if b = -1 then result else\n (tree#unite a b; tree_loop (result+1))\nlet () = Printf.printf \"%d\\n\" @@ tree_loop 0\n", "language": "OCaml", "metadata": {"date": 1601169730, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p02536.html", "problem_id": "p02536", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02536/input.txt", "sample_output_relpath": "derived/input_output/data/p02536/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02536/OCaml/s170587947.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s170587947", "user_id": "u511870776"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "open Batteries\nclass union_find n = object (self)\n val mutable par = ( [| |] : int array)\n method init = \n par <- Array.init n (fun a -> a)\n method get_par = par\n\n method root s = \n let rec loop x =\n if par.(x) = x then x else (par.(x) <- loop par.(x); par.(x))\n in loop s\n\n method rank s =\n let rec loop x n =\n if par.(x) = x then n else loop par.(x) (n+1)\n in loop s 1\n\n method unite x y =\n let xrank = self#rank x in\n let yrank = self#rank x in\n let rx = self#root x in\n let ry = self#root y in\n if rx != ry then (if xrank < yrank then par.(rx) <- ry else par.(ry) <- rx)\n\n method same x y = self#root x = self#root y\n\n method members x = (* 要素xが属する木の全ての要素を返す *) \n let r = self#root x in Array.fold_left (fun a y -> if self#root y = r then y :: a else a) [] par\n\n method roots = (* 全ての根 *) Array.fold_left (fun x y -> if List.mem y x then x else y :: x) [] par\n\n method tree_count = (* 木の数 *) List.length @@ self#roots\nend\n\n\nlet n, m = Scanf.sscanf (read_line()) \"%d %d\" (fun n m -> n,m)\nlet tree = new union_find n\nlet _ = tree#init\nlet rec loop i =\n if i >= m then () else Scanf.sscanf (read_line()) \"%d %d\" (fun a b -> tree#unite a b; loop (i+1))\n\nlet () = loop 0\nlet rec get_next result =\n if result >= n then -1 else\n if tree#same 0 result then get_next (result+1) else result\nlet rec tree_loop result =\n let a, b = (0, get_next 0) in\n if b = -1 then result else\n (tree#unite a b; tree_loop (result+1))\nlet () = Printf.printf \"%d\\n\" @@ tree_loop 0\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere are N cities numbered 1 through N, and M bidirectional roads numbered 1 through M.\nRoad i connects City A_i and City B_i.\n\nSnuke can perform the following operation zero or more times:\n\nChoose two distinct cities that are not directly connected by a road, and build a new road between the two cities.\n\nAfter he finishes the operations, it must be possible to travel from any city to any other cities by following roads (possibly multiple times).\n\nWhat is the minimum number of roads he must build to achieve the goal?\n\nConstraints\n\n2 \\leq N \\leq 100,000\n\n1 \\leq M \\leq 100,000\n\n1 \\leq A_i < B_i \\leq N\n\nNo two roads connect the same pair of cities.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 B_1\n:\nA_M B_M\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n3 1\n1 2\n\nSample Output 1\n\n1\n\nInitially, there are three cities, and there is a road between City 1 and City 2.\n\nSnuke can achieve the goal by building one new road, for example, between City 1 and City 3.\nAfter that,\n\nWe can travel between 1 and 2 directly.\n\nWe can travel between 1 and 3 directly.\n\nWe can travel between 2 and 3 by following both roads (2 - 1 - 3).", "sample_input": "3 1\n1 2\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02536", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere are N cities numbered 1 through N, and M bidirectional roads numbered 1 through M.\nRoad i connects City A_i and City B_i.\n\nSnuke can perform the following operation zero or more times:\n\nChoose two distinct cities that are not directly connected by a road, and build a new road between the two cities.\n\nAfter he finishes the operations, it must be possible to travel from any city to any other cities by following roads (possibly multiple times).\n\nWhat is the minimum number of roads he must build to achieve the goal?\n\nConstraints\n\n2 \\leq N \\leq 100,000\n\n1 \\leq M \\leq 100,000\n\n1 \\leq A_i < B_i \\leq N\n\nNo two roads connect the same pair of cities.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 B_1\n:\nA_M B_M\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n3 1\n1 2\n\nSample Output 1\n\n1\n\nInitially, there are three cities, and there is a road between City 1 and City 2.\n\nSnuke can achieve the goal by building one new road, for example, between City 1 and City 3.\nAfter that,\n\nWe can travel between 1 and 2 directly.\n\nWe can travel between 1 and 3 directly.\n\nWe can travel between 2 and 3 by following both roads (2 - 1 - 3).", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1565, "cpu_time_ms": 2206, "memory_kb": 9132}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s533505412", "group_id": "codeNet:p02536", "input_text": "open Batteries\nclass union_find n = object (self)\n val mutable par = ( [| |] : int array)\n method init = \n par <- Array.init n (fun a -> a)\n method get_par = par\n\n method root s = \n let rec loop x =\n if par.(x) = x then x else (par.(x) <- loop par.(x); par.(x))\n in loop s\n\n method rank s =\n let rec loop x n =\n if par.(x) = x then n else loop par.(x) (n+1)\n in loop s 1\n\n method unite x y =\n let xrank = self#rank x in\n let yrank = self#rank x in\n let rx = self#root x in\n let ry = self#root y in\n if rx != ry then (if xrank < yrank then par.(rx) <- ry else par.(ry) <- rx)\n\n method same x y = self#root x = self#root y\n\n method members x = (* 要素xが属する木の全ての要素を返す *) \n let r = self#root x in Array.fold_left (fun a y -> if self#root y = r then y :: a else a) [] par\n\n method roots = (* 全ての根 *) Array.fold_left (fun x y -> if List.mem y x then x else y :: x) [] par\n\n method tree_count = (* 木の数 *) List.length @@ self#roots\nend\n\n\nlet n, m = Scanf.sscanf (read_line()) \"%d %d\" (fun n m -> n,m)\nlet tree = new union_find n\nlet _ = tree#init\nlet rec loop i =\n if i >= m then () else Scanf.sscanf (read_line()) \"%d %d\" (fun a b -> tree#unite a b; loop (i+1))\n\nlet () = loop 0\nlet rec tree_loop result =\n if tree#tree_count = 1 then result else (\n let a, b = (List.hd tree#roots, List.hd @@ List.tl tree#roots) in\n tree#unite a b; tree_loop (result+1)\n )\nlet () = Printf.printf \"%d\\n\" @@ tree_loop 0\n\n\n", "language": "OCaml", "metadata": {"date": 1601169333, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p02536.html", "problem_id": "p02536", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02536/input.txt", "sample_output_relpath": "derived/input_output/data/p02536/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02536/OCaml/s533505412.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s533505412", "user_id": "u511870776"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "open Batteries\nclass union_find n = object (self)\n val mutable par = ( [| |] : int array)\n method init = \n par <- Array.init n (fun a -> a)\n method get_par = par\n\n method root s = \n let rec loop x =\n if par.(x) = x then x else (par.(x) <- loop par.(x); par.(x))\n in loop s\n\n method rank s =\n let rec loop x n =\n if par.(x) = x then n else loop par.(x) (n+1)\n in loop s 1\n\n method unite x y =\n let xrank = self#rank x in\n let yrank = self#rank x in\n let rx = self#root x in\n let ry = self#root y in\n if rx != ry then (if xrank < yrank then par.(rx) <- ry else par.(ry) <- rx)\n\n method same x y = self#root x = self#root y\n\n method members x = (* 要素xが属する木の全ての要素を返す *) \n let r = self#root x in Array.fold_left (fun a y -> if self#root y = r then y :: a else a) [] par\n\n method roots = (* 全ての根 *) Array.fold_left (fun x y -> if List.mem y x then x else y :: x) [] par\n\n method tree_count = (* 木の数 *) List.length @@ self#roots\nend\n\n\nlet n, m = Scanf.sscanf (read_line()) \"%d %d\" (fun n m -> n,m)\nlet tree = new union_find n\nlet _ = tree#init\nlet rec loop i =\n if i >= m then () else Scanf.sscanf (read_line()) \"%d %d\" (fun a b -> tree#unite a b; loop (i+1))\n\nlet () = loop 0\nlet rec tree_loop result =\n if tree#tree_count = 1 then result else (\n let a, b = (List.hd tree#roots, List.hd @@ List.tl tree#roots) in\n tree#unite a b; tree_loop (result+1)\n )\nlet () = Printf.printf \"%d\\n\" @@ tree_loop 0\n\n\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere are N cities numbered 1 through N, and M bidirectional roads numbered 1 through M.\nRoad i connects City A_i and City B_i.\n\nSnuke can perform the following operation zero or more times:\n\nChoose two distinct cities that are not directly connected by a road, and build a new road between the two cities.\n\nAfter he finishes the operations, it must be possible to travel from any city to any other cities by following roads (possibly multiple times).\n\nWhat is the minimum number of roads he must build to achieve the goal?\n\nConstraints\n\n2 \\leq N \\leq 100,000\n\n1 \\leq M \\leq 100,000\n\n1 \\leq A_i < B_i \\leq N\n\nNo two roads connect the same pair of cities.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 B_1\n:\nA_M B_M\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n3 1\n1 2\n\nSample Output 1\n\n1\n\nInitially, there are three cities, and there is a road between City 1 and City 2.\n\nSnuke can achieve the goal by building one new road, for example, between City 1 and City 3.\nAfter that,\n\nWe can travel between 1 and 2 directly.\n\nWe can travel between 1 and 3 directly.\n\nWe can travel between 2 and 3 by following both roads (2 - 1 - 3).", "sample_input": "3 1\n1 2\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02536", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere are N cities numbered 1 through N, and M bidirectional roads numbered 1 through M.\nRoad i connects City A_i and City B_i.\n\nSnuke can perform the following operation zero or more times:\n\nChoose two distinct cities that are not directly connected by a road, and build a new road between the two cities.\n\nAfter he finishes the operations, it must be possible to travel from any city to any other cities by following roads (possibly multiple times).\n\nWhat is the minimum number of roads he must build to achieve the goal?\n\nConstraints\n\n2 \\leq N \\leq 100,000\n\n1 \\leq M \\leq 100,000\n\n1 \\leq A_i < B_i \\leq N\n\nNo two roads connect the same pair of cities.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 B_1\n:\nA_M B_M\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n3 1\n1 2\n\nSample Output 1\n\n1\n\nInitially, there are three cities, and there is a road between City 1 and City 2.\n\nSnuke can achieve the goal by building one new road, for example, between City 1 and City 3.\nAfter that,\n\nWe can travel between 1 and 2 directly.\n\nWe can travel between 1 and 3 directly.\n\nWe can travel between 2 and 3 by following both roads (2 - 1 - 3).", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1503, "cpu_time_ms": 2205, "memory_kb": 9168}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s432910324", "group_id": "codeNet:p02537", "input_text": "module type Segtree = sig\n type s\n type t\n\n val create : int -> t\n val of_array : s array -> t\n val set : t -> int -> s -> unit\n val get : t -> int -> s\n val prod : t -> int -> int -> s\n val all_prod : t -> s\nend\n\nmodule type SegtreeParam = sig\n type t\n\n val op : t -> t -> t\n val e : t\nend \n\nmodule Segtree = struct\n module Make(STP: SegtreeParam) : Segtree with type s = STP.t = struct\n type t = int * int * int * STP.t array\n type s = STP.t\n\n let ceil_pow2 n =\n let rec loop x =\n if 1 lsl x < n then loop (x + 1) else x\n in\n loop 0\n\n let update d k =\n d.(k) <- STP.op d.(2 * k) d.(2 * k + 1)\n\n let of_array v =\n let n = Array.length v in\n let log = ceil_pow2 n in\n let size = 1 lsl log in\n let d = Array.make (2 * size) STP.e in\n for i = 0 to n - 1 do d.(size + i) <- v.(i) done;\n for i = size - 1 downto 1 do update d i done;\n n, size, log, d\n\n let create n =\n of_array (Array.make n STP.e)\n\n let set (n, size, log, d) p x =\n let p = p + size in\n d.(p) <- x;\n for i = 1 to log do update d (p lsr i) done\n\n let get (_, size, _, d) p = d.(p + size)\n\n let prod (n, size, log, d) l r =\n let rec loop l r sml smr =\n if l >= r then STP.op sml smr else\n let sml, l = if l land 1 = 0 then sml, l else STP.op sml d.(l), l + 1 in\n let smr, r = if r land 1 = 0 then smr, r else STP.op d.(r - 1) smr, r - 1 in\n loop (l lsr 1) (r lsr 1) sml smr\n in\n loop (l + size) (r + size) STP.e STP.e\n\n let all_prod (_, _, _, d) = d.(1)\n end\nend;;\nScanf.scanf \"%d %d\" (fun n k ->\n let module ST = Segtree.Make (struct type t = int let op = max let e = 0 end) in\n\n let seg = ST.create 600001 in\n for i = 0 to n - 1 do\n Scanf.scanf \" %d\" (fun a ->\n let l = max 0 (a - k) in\n let r = min 600000 (a + k + 1) in\n let v = ST.prod seg l r in\n ST.set seg a (v + 1)\n )\n done;\n Printf.printf \"%d\\n\" @@ ST.all_prod seg\n)", "language": "OCaml", "metadata": {"date": 1601178218, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p02537.html", "problem_id": "p02537", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02537/input.txt", "sample_output_relpath": "derived/input_output/data/p02537/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02537/OCaml/s432910324.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s432910324", "user_id": "u342443598"}, "prompt_components": {"gold_output": "7\n", "input_to_evaluate": "module type Segtree = sig\n type s\n type t\n\n val create : int -> t\n val of_array : s array -> t\n val set : t -> int -> s -> unit\n val get : t -> int -> s\n val prod : t -> int -> int -> s\n val all_prod : t -> s\nend\n\nmodule type SegtreeParam = sig\n type t\n\n val op : t -> t -> t\n val e : t\nend \n\nmodule Segtree = struct\n module Make(STP: SegtreeParam) : Segtree with type s = STP.t = struct\n type t = int * int * int * STP.t array\n type s = STP.t\n\n let ceil_pow2 n =\n let rec loop x =\n if 1 lsl x < n then loop (x + 1) else x\n in\n loop 0\n\n let update d k =\n d.(k) <- STP.op d.(2 * k) d.(2 * k + 1)\n\n let of_array v =\n let n = Array.length v in\n let log = ceil_pow2 n in\n let size = 1 lsl log in\n let d = Array.make (2 * size) STP.e in\n for i = 0 to n - 1 do d.(size + i) <- v.(i) done;\n for i = size - 1 downto 1 do update d i done;\n n, size, log, d\n\n let create n =\n of_array (Array.make n STP.e)\n\n let set (n, size, log, d) p x =\n let p = p + size in\n d.(p) <- x;\n for i = 1 to log do update d (p lsr i) done\n\n let get (_, size, _, d) p = d.(p + size)\n\n let prod (n, size, log, d) l r =\n let rec loop l r sml smr =\n if l >= r then STP.op sml smr else\n let sml, l = if l land 1 = 0 then sml, l else STP.op sml d.(l), l + 1 in\n let smr, r = if r land 1 = 0 then smr, r else STP.op d.(r - 1) smr, r - 1 in\n loop (l lsr 1) (r lsr 1) sml smr\n in\n loop (l + size) (r + size) STP.e STP.e\n\n let all_prod (_, _, _, d) = d.(1)\n end\nend;;\nScanf.scanf \"%d %d\" (fun n k ->\n let module ST = Segtree.Make (struct type t = int let op = max let e = 0 end) in\n\n let seg = ST.create 600001 in\n for i = 0 to n - 1 do\n Scanf.scanf \" %d\" (fun a ->\n let l = max 0 (a - k) in\n let r = min 600000 (a + k + 1) in\n let v = ST.prod seg l r in\n ST.set seg a (v + 1)\n )\n done;\n Printf.printf \"%d\\n\" @@ ST.all_prod seg\n)", "problem_context": "Score : 400 points\n\nProblem Statement\n\nYou are given a sequence A_1, A_2, ..., A_N and an integer K.\n\nPrint the maximum possible length of a sequence B that satisfies the following conditions:\n\nB is a (not necessarily continuous) subsequence of A.\n\nFor each pair of adjacents elements of B, the absolute difference of the elements is at most K.\n\nConstraints\n\n1 \\leq N \\leq 300,000\n\n0 \\leq A_i \\leq 300,000\n\n0 \\leq K \\leq 300,000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nA_1\nA_2\n:\nA_N\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n10 3\n1\n5\n4\n3\n8\n6\n9\n7\n2\n4\n\nSample Output 1\n\n7\n\nFor example, B = (1, 4, 3, 6, 9, 7, 4) satisfies the conditions.\n\nIt is a subsequence of A = (1, 5, 4, 3, 8, 6, 9, 7, 2, 4).\n\nAll of the absolute differences between two adjacent elements (|1-4|, |4-3|, |3-6|, |6-9|, |9-7|, |7-4|) are at most K = 3.", "sample_input": "10 3\n1\n5\n4\n3\n8\n6\n9\n7\n2\n4\n"}, "reference_outputs": ["7\n"], "source_document_id": "p02537", "source_text": "Score : 400 points\n\nProblem Statement\n\nYou are given a sequence A_1, A_2, ..., A_N and an integer K.\n\nPrint the maximum possible length of a sequence B that satisfies the following conditions:\n\nB is a (not necessarily continuous) subsequence of A.\n\nFor each pair of adjacents elements of B, the absolute difference of the elements is at most K.\n\nConstraints\n\n1 \\leq N \\leq 300,000\n\n0 \\leq A_i \\leq 300,000\n\n0 \\leq K \\leq 300,000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nA_1\nA_2\n:\nA_N\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n10 3\n1\n5\n4\n3\n8\n6\n9\n7\n2\n4\n\nSample Output 1\n\n7\n\nFor example, B = (1, 4, 3, 6, 9, 7, 4) satisfies the conditions.\n\nIt is a subsequence of A = (1, 5, 4, 3, 8, 6, 9, 7, 2, 4).\n\nAll of the absolute differences between two adjacent elements (|1-4|, |4-3|, |3-6|, |6-9|, |9-7|, |7-4|) are at most K = 3.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2276, "cpu_time_ms": 364, "memory_kb": 27368}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s353253356", "group_id": "codeNet:p02546", "input_text": "Scanf.scanf \"%s\" (fun s ->\n let n = String.length s in\n print_endline @@ if s.[n - 1] = 's' then s ^ \"es\" else s ^ \"s\"\n)", "language": "OCaml", "metadata": {"date": 1600542066, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p02546.html", "problem_id": "p02546", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02546/input.txt", "sample_output_relpath": "derived/input_output/data/p02546/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02546/OCaml/s353253356.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s353253356", "user_id": "u342443598"}, "prompt_components": {"gold_output": "apples\n", "input_to_evaluate": "Scanf.scanf \"%s\" (fun s ->\n let n = String.length s in\n print_endline @@ if s.[n - 1] = 's' then s ^ \"es\" else s ^ \"s\"\n)", "problem_context": "Score : 100 points\n\nProblem Statement\n\nIn the Kingdom of AtCoder, people use a language called Taknese, which uses lowercase English letters.\n\nIn Taknese, the plural form of a noun is spelled based on the following rules:\n\nIf a noun's singular form does not end with s, append s to the end of the singular form.\n\nIf a noun's singular form ends with s, append es to the end of the singular form.\n\nYou are given the singular form S of a Taknese noun. Output its plural form.\n\nConstraints\n\nS is a string of length 1 between 1000, inclusive.\n\nS contains only lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the plural form of the given Taknese word.\n\nSample Input 1\n\napple\n\nSample Output 1\n\napples\n\napple ends with e, so its plural form is apples.\n\nSample Input 2\n\nbus\n\nSample Output 2\n\nbuses\n\nbus ends with s, so its plural form is buses.\n\nSample Input 3\n\nbox\n\nSample Output 3\n\nboxs", "sample_input": "apple\n"}, "reference_outputs": ["apples\n"], "source_document_id": "p02546", "source_text": "Score : 100 points\n\nProblem Statement\n\nIn the Kingdom of AtCoder, people use a language called Taknese, which uses lowercase English letters.\n\nIn Taknese, the plural form of a noun is spelled based on the following rules:\n\nIf a noun's singular form does not end with s, append s to the end of the singular form.\n\nIf a noun's singular form ends with s, append es to the end of the singular form.\n\nYou are given the singular form S of a Taknese noun. Output its plural form.\n\nConstraints\n\nS is a string of length 1 between 1000, inclusive.\n\nS contains only lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the plural form of the given Taknese word.\n\nSample Input 1\n\napple\n\nSample Output 1\n\napples\n\napple ends with e, so its plural form is apples.\n\nSample Input 2\n\nbus\n\nSample Output 2\n\nbuses\n\nbus ends with s, so its plural form is buses.\n\nSample Input 3\n\nbox\n\nSample Output 3\n\nboxs", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 8, "memory_kb": 3732}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s888431870", "group_id": "codeNet:p02548", "input_text": "Scanf.scanf \"%d\" (fun n ->\n let rec loop_a a acc =\n let rec loop_b b acc =\n if a * b >= n then loop_a (a + 1) acc else\n loop_b (b + 1) (acc + 1)\n in\n if a >= n then acc else loop_b 1 acc\n in\n loop_a 1 0 |> Printf.printf \"%d\\n\"\n)", "language": "OCaml", "metadata": {"date": 1600542569, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p02548.html", "problem_id": "p02548", "resource_group": "low_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/OCaml/s888431870.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s888431870", "user_id": "u342443598"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "Scanf.scanf \"%d\" (fun n ->\n let rec loop_a a acc =\n let rec loop_b b acc =\n if a * b >= n then loop_a (a + 1) acc else\n loop_b (b + 1) (acc + 1)\n in\n if a >= n then acc else loop_b 1 acc\n in\n loop_a 1 0 |> Printf.printf \"%d\\n\"\n)", "problem_context": "Score : 300 points\n\nProblem Statement\n\nGiven is a positive integer N.\nHow many tuples (A,B,C) of positive integers satisfy A \\times B + C = N?\n\nConstraints\n\n2 \\leq N \\leq 10^6\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n3\n\nSample Output 1\n\n3\n\nThere are 3 tuples of integers that satisfy A \\times B + C = 3: (A, B, C) = (1, 1, 2), (1, 2, 1), (2, 1, 1).\n\nSample Input 2\n\n100\n\nSample Output 2\n\n473\n\nSample Input 3\n\n1000000\n\nSample Output 3\n\n13969985", "sample_input": "3\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02548", "source_text": "Score : 300 points\n\nProblem Statement\n\nGiven is a positive integer N.\nHow many tuples (A,B,C) of positive integers satisfy A \\times B + C = N?\n\nConstraints\n\n2 \\leq N \\leq 10^6\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n3\n\nSample Output 1\n\n3\n\nThere are 3 tuples of integers that satisfy A \\times B + C = 3: (A, B, C) = (1, 1, 2), (1, 2, 1), (2, 1, 1).\n\nSample Input 2\n\n100\n\nSample Output 2\n\n473\n\nSample Input 3\n\n1000000\n\nSample Output 3\n\n13969985", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 284, "cpu_time_ms": 32, "memory_kb": 5896}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s677579474", "group_id": "codeNet:p02553", "input_text": "open Batteries\nopen Printf\n\nlet ($) g f x = g (f x)\n\nlet swap = Tuple2.swap\n\nlet s2i = int_of_string\nlet i2s = string_of_int\nlet s2f = float_of_string\nlet f2s = string_of_float\nlet f2i = int_of_float\nlet i2f = float_of_int \n\nlet c2a = int_of_char\nlet a2c = char_of_int\n\nlet c2i c = c2a c - 48\nlet i2c i = a2c (i + 48)\n\nlet c2s = String.of_char\nlet s2cl = String.to_list\nlet cl2s = String.of_list\n\nlet puts s = print_endline s\nlet putw ?yn:(yn=(\"Yes\", \"No\")) b = puts (if b then fst yn else snd yn)\nlet puti i = puts @@ i2s i\n\n\n\nmodule StaleList = struct\n include List\n\n let nmem x l = not @@ mem x l\n\n let len = length\n let size = length\n let nempty l = not @@ is_empty l\n\n let hdop l = if nempty l then Some (hd l) else None\n\n (* let taker = drop *)\n let takewh = take_while\n\n (* let dropr = take *)\n let dropwh = drop_while\n\n let split_by = span\n\n let chunk = ntake\n\n let foldl = fold_left\n let foldli = fold_lefti\n let foldr f z l = fold_right f l z\n let foldri f z l = fold_righti f l z\n\n let partition_to_map f l =\n foldr (fun x m -> Map.modify_opt (f x) (function\n | None -> Some [x] \n | Some [] -> Some [x] \n | Some vl -> Some (x::vl)) m) Map.empty l;;\n\n let scanl f z ls =\n let rec loop acl acc = function\n | [] -> rev acl\n | h::t ->\n let r = f acc h in\n loop (r::acl) r t\n in loop [] z ls\n\n let scanr f z ls =\n let rec loop acl acc = function\n | [] -> acl \n | h::t ->\n let r = f h acc in\n loop (r::acl) r t\n in loop [] z (rev ls)\n\n (* let scanli = scan_lefti *)\n (* let scanri = scan_righti *)\n \n let flatmap = concat_map\n\n let zipf = map2\n let zipfi = map2i\n\nend\n\nmodule L = StaleList\n\nmodule StaleArray = struct\n include Array \n\n let nmem x l = not @@ mem x l\n\n let len = length\n let size = length\n let is_empty r = len r = 0\n let nempty r = len r > 0\n\n let take n r = left r n\n let taker n r = right r n\n\n let takeb x r =\n let l = len r in\n let rec loop i =\n if i >= l then r\n else if r.(i) = x then take i r\n else loop (i + 1)\n in loop 0\n \n (* let takewh = take_while *)\n\n let drop n r = tail r n\n let dropr n r = take ((len r) - n) r\n (* let dropwh = drop_while *)\n\n let index_of x r =\n let l = len r in\n let rec loop i =\n if i >= l then None\n else if r.(i) = x then Some i\n else loop (i + 1)\n in loop 0\n\n (* let split_by = span *)\n\n (* let chunk = ntake *)\n\n let foldl = fold_left\n let foldli = fold_lefti\n let foldr f z l = fold_right f l z\n let foldri f z l = fold_righti f l z\n\n (* let partition_to_map f l = *)\n (* foldr (fun x m -> Map.modify_opt (f x) (function *)\n (* | None -> Some [x] *)\n (* | Some [] -> Some [x] *)\n (* | Some vl -> Some (x::vl)) m) Map.empty l;; *)\n\n (* let scanl = scan_left *)\n (* let scanli = scan_lefti *)\n (* let scanr = scan_right *)\n (* let scanri = scan_righti *)\n \n let concat2 = append\n \n let flatmap (f : 'a -> 'b array) a =\n map f a |> enum |> L.of_enum |> concat\n\n let zipf = map2\n (* let zipfi = map2i *)\n\nend\n\nmodule A = StaleArray\n\nmodule StaleString = struct\n include String\n\n let len = length\n\n let replace_chars = map\n let map = replace\n\n let maptol f s = L.map f (s2cl s)\n let maptoli f s = L.map f (s2cl s)\n\n let zipf f a b = L.zipf f (s2cl a) (s2cl b)\n let zipfi f a b = L.zipfi f (s2cl a) (s2cl b)\n\n let mkstr f sep ls =\n L.foldl (fun acc x -> acc ^ sep ^ (f x)) (f @@ L.hd ls) (List.tl ls)\n\nend\n\nmodule S = StaleString\n\nlet spsp s = S.split_on_char ' ' s\n\n\nmodule StaleSortedSet = struct\n include Set\n\n module Make (Ord : Set.OrderedType) = struct\n include Set.Make(Ord)\n\n let nempty st = not @@ is_empty st\n let sing = singleton\n let nmem x st = not @@ mem x st\n\n let foldl f s z = fold (fun x a -> f a x) z s\n\n let size = cardinal\n end\n\n let nempty st = not @@ is_empty st\n let sing = singleton\n let nmem x st = not @@ mem x st\n\n let foldl f s z = fold (fun x a -> f a x) z s\n\n let size = cardinal\nend\n\nmodule Ss = StaleSortedSet\n\nmodule StaleSortedMap = struct\n include Map\n\n module Make (Ord : Map.OrderedType) = struct\n include Map.Make(Ord)\n\n let nempty st = not @@ is_empty st\n let sing = singleton\n let nmem x st = not @@ mem x st\n\n let get = find\n let get_or x d m = find_default d x m\n\n let size = cardinal\n end\n\n let nempty st = not @@ is_empty st\n let sing = singleton\n let nmem x st = not @@ mem x st\n\n let get = find\n let get_or x d m = find_default d x m\n\n let size = cardinal\nend\n\nmodule Ms = StaleSortedMap\n\n\nmodule StaleRange = struct\n\n type t = Range of int * int\n\n let make lb ub = Range (lb, ub)\n\n let to_list r =\n let Range (lb, ub) = r in\n L.make (ub - lb) ((+) lb) \n\n let to_array r =\n let Range (lb, ub) = r in\n A.make (ub - lb) ((+) lb)\n\n let iter r f = \n let Range (lb, ub) = r in\n for i = lb to ub do f i done\n\n let iter2 r1 r2 f =\n let Range (lb1, ub1) = r1 and Range (lb2, ub2) = r2 in\n for i = lb1 to ub2 do\n for j = lb2 to ub2 do\n f i j\n done\n done\nend\n\nmodule R = StaleRange\n\nlet (---) lb ub = R.make lb ub\nlet (--^) lb ub = R.make lb (ub - 1)\n\nmodule StaleGenericAlgorithms = struct\n\n let set_power ls =\n let rec loop ls pls =\n match ls with\n | [] -> pls\n | hd::tl -> loop tl (L.flatmap (fun p -> [p; hd::p]) pls)\n in loop ls [[]]\n\n let rec bsearch_max_int f lb ub =\n if lb >= ub then (if f lb then lb else (lb - 1))\n else (\n let m = (lb + ub) / 2 in\n if f m then bsearch_max_int f (m + 1) ub\n else bsearch_max_int f lb m\n )\n\n let partial_sum n ls =\n let rec loop s k = function\n | [] -> s\n | h::t ->\n if k >= n then s\n else loop (s + h) (k + 1) t\n in\n loop 0 0 ls\n\nend\n\nmodule Gal = StaleGenericAlgorithms\n\nlet rds () = read_line ()\n\nlet rdi () = s2i @@ rds ()\n\nlet rdhs () = spsp @@ rds ()\nlet rdhi () = rdhs () |> L.map s2i\n\nlet rdhf () = rdhs () |> L.map s2f\n\nlet rdf2 () = match rdhf () with\n| a::b::_ -> (a, b)\n| _ -> (0., 0.)\n\nlet rdf3 () = match rdhf () with\n| a::b::c::_ -> (a, b, c)\n| _ -> (0., 0., 0.)\n\nlet rdf4 () = match rdhf () with\n| a::b::c::d::_ -> (a, b, c, d)\n| _ -> (0., 0., 0., 0.)\n\nlet rds2 () = match rdhs () with\n | a::b::_ -> (a, b)\n | _ -> (\"\", \"\")\n\nlet rdi2 () = match rdhi () with\n | a::b::_ -> (a, b)\n | _ -> (0, 0)\n\nlet rdi3 () = match rdhi () with\n| a::b::c::_ -> (a, b, c)\n| _ -> (0, 0, 0)\n\nlet rdi4 () = match rdhi () with\n| a::b::c::d::_ -> (a, b, c, d)\n| _ -> (0, 0, 0, 0)\n\nlet rdi5 () = match rdhi () with\n| a::b::c::d::e::_ -> (a, b, c, d, e)\n| _ -> (0, 0, 0, 0, 0)\n\nlet rdv n rf =\n let rec loop n =\n if n <= 0 then []\n else (\n let s = rf () in\n s::(loop (n - 1))\n )\n in loop n\n\nlet rdvi n = rdv n rdi\nlet rdvi2 n = rdv n rdi2\nlet rdvi3 n = rdv n rdi3\nlet rdvi4 n = rdv n rdi4\n\n\nlet print_list aa = \n printf \"[ \"; aa |> L.iter (fun a -> printf \"%d \" a); puts \"]\"\n\nlet print_array aa = \n printf \"[ \"; aa |> A.iter (fun a -> printf \"%d \" a); puts \"]\"\n\nlet print_carray aa = \n printf \"[ \"; aa |> A.iter (fun a -> printf \"%c \" a); puts \"]\"\n\nlet print_matrix mat =\n puts \"----\";\n mat |> A.iter (fun r -> print_carray r);\n puts \"----\"\n\n\nlet _ =\n let a,b,c,d = rdi4 () in\n puti (max (a*c) (max (a*d) (max (b*c) (b*d))));\n ()\n", "language": "OCaml", "metadata": {"date": 1600023885, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p02553.html", "problem_id": "p02553", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02553/input.txt", "sample_output_relpath": "derived/input_output/data/p02553/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02553/OCaml/s677579474.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s677579474", "user_id": "u970139668"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "open Batteries\nopen Printf\n\nlet ($) g f x = g (f x)\n\nlet swap = Tuple2.swap\n\nlet s2i = int_of_string\nlet i2s = string_of_int\nlet s2f = float_of_string\nlet f2s = string_of_float\nlet f2i = int_of_float\nlet i2f = float_of_int \n\nlet c2a = int_of_char\nlet a2c = char_of_int\n\nlet c2i c = c2a c - 48\nlet i2c i = a2c (i + 48)\n\nlet c2s = String.of_char\nlet s2cl = String.to_list\nlet cl2s = String.of_list\n\nlet puts s = print_endline s\nlet putw ?yn:(yn=(\"Yes\", \"No\")) b = puts (if b then fst yn else snd yn)\nlet puti i = puts @@ i2s i\n\n\n\nmodule StaleList = struct\n include List\n\n let nmem x l = not @@ mem x l\n\n let len = length\n let size = length\n let nempty l = not @@ is_empty l\n\n let hdop l = if nempty l then Some (hd l) else None\n\n (* let taker = drop *)\n let takewh = take_while\n\n (* let dropr = take *)\n let dropwh = drop_while\n\n let split_by = span\n\n let chunk = ntake\n\n let foldl = fold_left\n let foldli = fold_lefti\n let foldr f z l = fold_right f l z\n let foldri f z l = fold_righti f l z\n\n let partition_to_map f l =\n foldr (fun x m -> Map.modify_opt (f x) (function\n | None -> Some [x] \n | Some [] -> Some [x] \n | Some vl -> Some (x::vl)) m) Map.empty l;;\n\n let scanl f z ls =\n let rec loop acl acc = function\n | [] -> rev acl\n | h::t ->\n let r = f acc h in\n loop (r::acl) r t\n in loop [] z ls\n\n let scanr f z ls =\n let rec loop acl acc = function\n | [] -> acl \n | h::t ->\n let r = f h acc in\n loop (r::acl) r t\n in loop [] z (rev ls)\n\n (* let scanli = scan_lefti *)\n (* let scanri = scan_righti *)\n \n let flatmap = concat_map\n\n let zipf = map2\n let zipfi = map2i\n\nend\n\nmodule L = StaleList\n\nmodule StaleArray = struct\n include Array \n\n let nmem x l = not @@ mem x l\n\n let len = length\n let size = length\n let is_empty r = len r = 0\n let nempty r = len r > 0\n\n let take n r = left r n\n let taker n r = right r n\n\n let takeb x r =\n let l = len r in\n let rec loop i =\n if i >= l then r\n else if r.(i) = x then take i r\n else loop (i + 1)\n in loop 0\n \n (* let takewh = take_while *)\n\n let drop n r = tail r n\n let dropr n r = take ((len r) - n) r\n (* let dropwh = drop_while *)\n\n let index_of x r =\n let l = len r in\n let rec loop i =\n if i >= l then None\n else if r.(i) = x then Some i\n else loop (i + 1)\n in loop 0\n\n (* let split_by = span *)\n\n (* let chunk = ntake *)\n\n let foldl = fold_left\n let foldli = fold_lefti\n let foldr f z l = fold_right f l z\n let foldri f z l = fold_righti f l z\n\n (* let partition_to_map f l = *)\n (* foldr (fun x m -> Map.modify_opt (f x) (function *)\n (* | None -> Some [x] *)\n (* | Some [] -> Some [x] *)\n (* | Some vl -> Some (x::vl)) m) Map.empty l;; *)\n\n (* let scanl = scan_left *)\n (* let scanli = scan_lefti *)\n (* let scanr = scan_right *)\n (* let scanri = scan_righti *)\n \n let concat2 = append\n \n let flatmap (f : 'a -> 'b array) a =\n map f a |> enum |> L.of_enum |> concat\n\n let zipf = map2\n (* let zipfi = map2i *)\n\nend\n\nmodule A = StaleArray\n\nmodule StaleString = struct\n include String\n\n let len = length\n\n let replace_chars = map\n let map = replace\n\n let maptol f s = L.map f (s2cl s)\n let maptoli f s = L.map f (s2cl s)\n\n let zipf f a b = L.zipf f (s2cl a) (s2cl b)\n let zipfi f a b = L.zipfi f (s2cl a) (s2cl b)\n\n let mkstr f sep ls =\n L.foldl (fun acc x -> acc ^ sep ^ (f x)) (f @@ L.hd ls) (List.tl ls)\n\nend\n\nmodule S = StaleString\n\nlet spsp s = S.split_on_char ' ' s\n\n\nmodule StaleSortedSet = struct\n include Set\n\n module Make (Ord : Set.OrderedType) = struct\n include Set.Make(Ord)\n\n let nempty st = not @@ is_empty st\n let sing = singleton\n let nmem x st = not @@ mem x st\n\n let foldl f s z = fold (fun x a -> f a x) z s\n\n let size = cardinal\n end\n\n let nempty st = not @@ is_empty st\n let sing = singleton\n let nmem x st = not @@ mem x st\n\n let foldl f s z = fold (fun x a -> f a x) z s\n\n let size = cardinal\nend\n\nmodule Ss = StaleSortedSet\n\nmodule StaleSortedMap = struct\n include Map\n\n module Make (Ord : Map.OrderedType) = struct\n include Map.Make(Ord)\n\n let nempty st = not @@ is_empty st\n let sing = singleton\n let nmem x st = not @@ mem x st\n\n let get = find\n let get_or x d m = find_default d x m\n\n let size = cardinal\n end\n\n let nempty st = not @@ is_empty st\n let sing = singleton\n let nmem x st = not @@ mem x st\n\n let get = find\n let get_or x d m = find_default d x m\n\n let size = cardinal\nend\n\nmodule Ms = StaleSortedMap\n\n\nmodule StaleRange = struct\n\n type t = Range of int * int\n\n let make lb ub = Range (lb, ub)\n\n let to_list r =\n let Range (lb, ub) = r in\n L.make (ub - lb) ((+) lb) \n\n let to_array r =\n let Range (lb, ub) = r in\n A.make (ub - lb) ((+) lb)\n\n let iter r f = \n let Range (lb, ub) = r in\n for i = lb to ub do f i done\n\n let iter2 r1 r2 f =\n let Range (lb1, ub1) = r1 and Range (lb2, ub2) = r2 in\n for i = lb1 to ub2 do\n for j = lb2 to ub2 do\n f i j\n done\n done\nend\n\nmodule R = StaleRange\n\nlet (---) lb ub = R.make lb ub\nlet (--^) lb ub = R.make lb (ub - 1)\n\nmodule StaleGenericAlgorithms = struct\n\n let set_power ls =\n let rec loop ls pls =\n match ls with\n | [] -> pls\n | hd::tl -> loop tl (L.flatmap (fun p -> [p; hd::p]) pls)\n in loop ls [[]]\n\n let rec bsearch_max_int f lb ub =\n if lb >= ub then (if f lb then lb else (lb - 1))\n else (\n let m = (lb + ub) / 2 in\n if f m then bsearch_max_int f (m + 1) ub\n else bsearch_max_int f lb m\n )\n\n let partial_sum n ls =\n let rec loop s k = function\n | [] -> s\n | h::t ->\n if k >= n then s\n else loop (s + h) (k + 1) t\n in\n loop 0 0 ls\n\nend\n\nmodule Gal = StaleGenericAlgorithms\n\nlet rds () = read_line ()\n\nlet rdi () = s2i @@ rds ()\n\nlet rdhs () = spsp @@ rds ()\nlet rdhi () = rdhs () |> L.map s2i\n\nlet rdhf () = rdhs () |> L.map s2f\n\nlet rdf2 () = match rdhf () with\n| a::b::_ -> (a, b)\n| _ -> (0., 0.)\n\nlet rdf3 () = match rdhf () with\n| a::b::c::_ -> (a, b, c)\n| _ -> (0., 0., 0.)\n\nlet rdf4 () = match rdhf () with\n| a::b::c::d::_ -> (a, b, c, d)\n| _ -> (0., 0., 0., 0.)\n\nlet rds2 () = match rdhs () with\n | a::b::_ -> (a, b)\n | _ -> (\"\", \"\")\n\nlet rdi2 () = match rdhi () with\n | a::b::_ -> (a, b)\n | _ -> (0, 0)\n\nlet rdi3 () = match rdhi () with\n| a::b::c::_ -> (a, b, c)\n| _ -> (0, 0, 0)\n\nlet rdi4 () = match rdhi () with\n| a::b::c::d::_ -> (a, b, c, d)\n| _ -> (0, 0, 0, 0)\n\nlet rdi5 () = match rdhi () with\n| a::b::c::d::e::_ -> (a, b, c, d, e)\n| _ -> (0, 0, 0, 0, 0)\n\nlet rdv n rf =\n let rec loop n =\n if n <= 0 then []\n else (\n let s = rf () in\n s::(loop (n - 1))\n )\n in loop n\n\nlet rdvi n = rdv n rdi\nlet rdvi2 n = rdv n rdi2\nlet rdvi3 n = rdv n rdi3\nlet rdvi4 n = rdv n rdi4\n\n\nlet print_list aa = \n printf \"[ \"; aa |> L.iter (fun a -> printf \"%d \" a); puts \"]\"\n\nlet print_array aa = \n printf \"[ \"; aa |> A.iter (fun a -> printf \"%d \" a); puts \"]\"\n\nlet print_carray aa = \n printf \"[ \"; aa |> A.iter (fun a -> printf \"%c \" a); puts \"]\"\n\nlet print_matrix mat =\n puts \"----\";\n mat |> A.iter (fun r -> print_carray r);\n puts \"----\"\n\n\nlet _ =\n let a,b,c,d = rdi4 () in\n puti (max (a*c) (max (a*d) (max (b*c) (b*d))));\n ()\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nGiven are integers a,b,c and d.\nIf x and y are integers and a \\leq x \\leq b and c\\leq y \\leq d hold, what is the maximum possible value of x \\times y?\n\nConstraints\n\n-10^9 \\leq a \\leq b \\leq 10^9\n\n-10^9 \\leq c \\leq d \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\na b c d\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n1 2 1 1\n\nSample Output 1\n\n2\n\nIf x = 1 and y = 1 then x \\times y = 1.\nIf x = 2 and y = 1 then x \\times y = 2.\nTherefore, the answer is 2.\n\nSample Input 2\n\n3 5 -4 -2\n\nSample Output 2\n\n-6\n\nThe answer can be negative.\n\nSample Input 3\n\n-1000000000 0 -1000000000 0\n\nSample Output 3\n\n1000000000000000000", "sample_input": "1 2 1 1\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02553", "source_text": "Score : 200 points\n\nProblem Statement\n\nGiven are integers a,b,c and d.\nIf x and y are integers and a \\leq x \\leq b and c\\leq y \\leq d hold, what is the maximum possible value of x \\times y?\n\nConstraints\n\n-10^9 \\leq a \\leq b \\leq 10^9\n\n-10^9 \\leq c \\leq d \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\na b c d\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n1 2 1 1\n\nSample Output 1\n\n2\n\nIf x = 1 and y = 1 then x \\times y = 1.\nIf x = 2 and y = 1 then x \\times y = 2.\nTherefore, the answer is 2.\n\nSample Input 2\n\n3 5 -4 -2\n\nSample Output 2\n\n-6\n\nThe answer can be negative.\n\nSample Input 3\n\n-1000000000 0 -1000000000 0\n\nSample Output 3\n\n1000000000000000000", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 7311, "cpu_time_ms": 9, "memory_kb": 5516}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s222590318", "group_id": "codeNet:p02554", "input_text": "let () =\n Scanf.scanf \"%d\\n\" @@ fun n ->\n let rec powmod x y ans = \n \tif y = 0 then ans else powmod x (y-1) (ans * x mod 1000000007) in\n Printf.printf \"%d\\n\" ((powmod 10 n 1) - 2 * (powmod 9 n 1) + (powmod 8 n 1))", "language": "OCaml", "metadata": {"date": 1600438436, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p02554.html", "problem_id": "p02554", "resource_group": "low_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/OCaml/s222590318.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s222590318", "user_id": "u307426615"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "let () =\n Scanf.scanf \"%d\\n\" @@ fun n ->\n let rec powmod x y ans = \n \tif y = 0 then ans else powmod x (y-1) (ans * x mod 1000000007) in\n Printf.printf \"%d\\n\" ((powmod 10 n 1) - 2 * (powmod 9 n 1) + (powmod 8 n 1))", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 32, "memory_kb": 3848}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s628973781", "group_id": "codeNet:p02554", "input_text": "let rec power ( * ) e m n =\n if n <= 0 then e\n else power ( * ) (if n land 1 = 0 then e else m * e) (m * m) (n lsr 1)\n\nlet m = 1000000007\nlet ( +^ ) x y = (x + y) mod m\nlet ( -^ ) x y = x +^ (m - y)\nlet ( *^ ) x y = (x * y) mod m\nlet perm n k =\n Array.fold_left ( *^ ) 1 @@\n Array.init k @@ ( + ) (n - k + 1)\n\nlet () =\n let n = read_int () in\n Printf.printf \"%d\\n\" @@\n power ( *^ ) 1 10 n -^ 2 *^ power ( *^ ) 1 9 n +^ power ( *^ ) 1 8 n", "language": "OCaml", "metadata": {"date": 1600029687, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p02554.html", "problem_id": "p02554", "resource_group": "low_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/OCaml/s628973781.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s628973781", "user_id": "u504158101"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "let rec power ( * ) e m n =\n if n <= 0 then e\n else power ( * ) (if n land 1 = 0 then e else m * e) (m * m) (n lsr 1)\n\nlet m = 1000000007\nlet ( +^ ) x y = (x + y) mod m\nlet ( -^ ) x y = x +^ (m - y)\nlet ( *^ ) x y = (x * y) mod m\nlet perm n k =\n Array.fold_left ( *^ ) 1 @@\n Array.init k @@ ( + ) (n - k + 1)\n\nlet () =\n let n = read_int () in\n Printf.printf \"%d\\n\" @@\n power ( *^ ) 1 10 n -^ 2 *^ power ( *^ ) 1 9 n +^ power ( *^ ) 1 8 n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nHow many integer sequences A_1,A_2,\\ldots,A_N of length N satisfy all of the following conditions?\n\n0 \\leq A_i \\leq 9\n\nThere exists some i such that A_i=0 holds.\n\nThere exists some i such that A_i=9 holds.\n\nThe answer can be very large, so output it modulo 10^9 + 7.\n\nConstraints\n\n1 \\leq N \\leq 10^6\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the answer modulo 10^9 + 7.\n\nSample Input 1\n\n2\n\nSample Output 1\n\n2\n\nTwo sequences \\{0,9\\} and \\{9,0\\} satisfy all conditions.\n\nSample Input 2\n\n1\n\nSample Output 2\n\n0\n\nSample Input 3\n\n869121\n\nSample Output 3\n\n2511445", "sample_input": "2\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02554", "source_text": "Score : 300 points\n\nProblem Statement\n\nHow many integer sequences A_1,A_2,\\ldots,A_N of length N satisfy all of the following conditions?\n\n0 \\leq A_i \\leq 9\n\nThere exists some i such that A_i=0 holds.\n\nThere exists some i such that A_i=9 holds.\n\nThe answer can be very large, so output it modulo 10^9 + 7.\n\nConstraints\n\n1 \\leq N \\leq 10^6\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the answer modulo 10^9 + 7.\n\nSample Input 1\n\n2\n\nSample Output 1\n\n2\n\nTwo sequences \\{0,9\\} and \\{9,0\\} satisfy all conditions.\n\nSample Input 2\n\n1\n\nSample Output 2\n\n0\n\nSample Input 3\n\n869121\n\nSample Output 3\n\n2511445", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 444, "cpu_time_ms": 7, "memory_kb": 3644}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s404152361", "group_id": "codeNet:p02554", "input_text": "Scanf.scanf \"%d\" (fun n ->\n let z = 1_000_000_007 in\n let ( +@) a b = (a + b) mod z in\n let ( *@) a b = (a * b) mod z in\n\n let rec loop i d09 d0 d9 dn =\n if i = n then d09 else\n loop (i + 1) (d09 *@ 10 +@ d0 +@ d9) (d0 *@ 9 +@ dn) (d9 *@ 9 +@ dn) (dn *@ 8)\n in\n loop 0 0 0 0 1 |> Printf.printf \"%d\\n\"\n)", "language": "OCaml", "metadata": {"date": 1600024862, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p02554.html", "problem_id": "p02554", "resource_group": "low_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/OCaml/s404152361.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s404152361", "user_id": "u342443598"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "Scanf.scanf \"%d\" (fun n ->\n let z = 1_000_000_007 in\n let ( +@) a b = (a + b) mod z in\n let ( *@) a b = (a * b) mod z in\n\n let rec loop i d09 d0 d9 dn =\n if i = n then d09 else\n loop (i + 1) (d09 *@ 10 +@ d0 +@ d9) (d0 *@ 9 +@ dn) (d9 *@ 9 +@ dn) (dn *@ 8)\n in\n loop 0 0 0 0 1 |> Printf.printf \"%d\\n\"\n)", "problem_context": "Score : 300 points\n\nProblem Statement\n\nHow many integer sequences A_1,A_2,\\ldots,A_N of length N satisfy all of the following conditions?\n\n0 \\leq A_i \\leq 9\n\nThere exists some i such that A_i=0 holds.\n\nThere exists some i such that A_i=9 holds.\n\nThe answer can be very large, so output it modulo 10^9 + 7.\n\nConstraints\n\n1 \\leq N \\leq 10^6\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the answer modulo 10^9 + 7.\n\nSample Input 1\n\n2\n\nSample Output 1\n\n2\n\nTwo sequences \\{0,9\\} and \\{9,0\\} satisfy all conditions.\n\nSample Input 2\n\n1\n\nSample Output 2\n\n0\n\nSample Input 3\n\n869121\n\nSample Output 3\n\n2511445", "sample_input": "2\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02554", "source_text": "Score : 300 points\n\nProblem Statement\n\nHow many integer sequences A_1,A_2,\\ldots,A_N of length N satisfy all of the following conditions?\n\n0 \\leq A_i \\leq 9\n\nThere exists some i such that A_i=0 holds.\n\nThere exists some i such that A_i=9 holds.\n\nThe answer can be very large, so output it modulo 10^9 + 7.\n\nConstraints\n\n1 \\leq N \\leq 10^6\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the answer modulo 10^9 + 7.\n\nSample Input 1\n\n2\n\nSample Output 1\n\n2\n\nTwo sequences \\{0,9\\} and \\{9,0\\} satisfy all conditions.\n\nSample Input 2\n\n1\n\nSample Output 2\n\n0\n\nSample Input 3\n\n869121\n\nSample Output 3\n\n2511445", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 35, "memory_kb": 3788}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s820568662", "group_id": "codeNet:p02558", "input_text": "module Dsu : sig\n type t\n\n val make : int -> t\n val merge : t -> int -> int -> int\n val same : t -> int -> int -> bool\n val leader : t -> int -> int\n val size : t -> int -> int\nend = struct\n type t = int * int array\n\n let make n =\n n, Array.make n (-1)\n\n let rec leader ((n, parent_or_size) as dsu) a =\n if parent_or_size.(a) < 0 then a else\n let r = leader dsu parent_or_size.(a) in\n let () = parent_or_size.(a) <- r in\n r\n\n let merge ((n, parent_or_size) as dsu) a b =\n let x = leader dsu a in\n let y = leader dsu b in\n if x = y then x else (\n let x, y = if -parent_or_size.(x) < -parent_or_size.(y) then y, x else x, y in\n parent_or_size.(x) <- parent_or_size.(x) + parent_or_size.(y);\n parent_or_size.(y) <- x;\n x\n )\n\n let same dsu a b =\n leader dsu a = leader dsu b\n\n let size ((n, parent_or_size) as dsu) a =\n -parent_or_size.(leader dsu a)\nend;;\n\nScanf.scanf \"%d %d\" (fun n q ->\n let dsu = Dsu.make n in\n for i = 1 to q do\n Scanf.scanf \" %d %d %d\" (fun t u v ->\n if t = 0 then ignore (Dsu.merge dsu u v) else\n Printf.printf \"%d\\n\" @@ if Dsu.same dsu u v then 1 else 0\n )\n done\n)", "language": "OCaml", "metadata": {"date": 1600593255, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p02558.html", "problem_id": "p02558", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02558/input.txt", "sample_output_relpath": "derived/input_output/data/p02558/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02558/OCaml/s820568662.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s820568662", "user_id": "u342443598"}, "prompt_components": {"gold_output": "0\n1\n0\n1\n", "input_to_evaluate": "module Dsu : sig\n type t\n\n val make : int -> t\n val merge : t -> int -> int -> int\n val same : t -> int -> int -> bool\n val leader : t -> int -> int\n val size : t -> int -> int\nend = struct\n type t = int * int array\n\n let make n =\n n, Array.make n (-1)\n\n let rec leader ((n, parent_or_size) as dsu) a =\n if parent_or_size.(a) < 0 then a else\n let r = leader dsu parent_or_size.(a) in\n let () = parent_or_size.(a) <- r in\n r\n\n let merge ((n, parent_or_size) as dsu) a b =\n let x = leader dsu a in\n let y = leader dsu b in\n if x = y then x else (\n let x, y = if -parent_or_size.(x) < -parent_or_size.(y) then y, x else x, y in\n parent_or_size.(x) <- parent_or_size.(x) + parent_or_size.(y);\n parent_or_size.(y) <- x;\n x\n )\n\n let same dsu a b =\n leader dsu a = leader dsu b\n\n let size ((n, parent_or_size) as dsu) a =\n -parent_or_size.(leader dsu a)\nend;;\n\nScanf.scanf \"%d %d\" (fun n q ->\n let dsu = Dsu.make n in\n for i = 1 to q do\n Scanf.scanf \" %d %d %d\" (fun t u v ->\n if t = 0 then ignore (Dsu.merge dsu u v) else\n Printf.printf \"%d\\n\" @@ if Dsu.same dsu u v then 1 else 0\n )\n done\n)", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou are given an undirected graph with N vertices and 0 edges. Process Q queries of the following types.\n\n0 u v: Add an edge (u, v).\n\n1 u v: Print 1 if u and v are in the same connected component, 0 otherwise.\n\nConstraints\n\n1 \\leq N \\leq 200,000\n\n1 \\leq Q \\leq 200,000\n\n0 \\leq u_i, v_i \\lt N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN Q\nt_1 u_1 v_1\nt_2 u_2 v_2\n:\nt_Q u_Q v_Q\n\n出力\n\nFor each query of the latter type, print the answer.\n\nSample Input 1\n\n4 7\n1 0 1\n0 0 1\n0 2 3\n1 0 1\n1 1 2\n0 0 2\n1 1 3\n\nSample Output 1\n\n0\n1\n0\n1", "sample_input": "4 7\n1 0 1\n0 0 1\n0 2 3\n1 0 1\n1 1 2\n0 0 2\n1 1 3\n"}, "reference_outputs": ["0\n1\n0\n1\n"], "source_document_id": "p02558", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou are given an undirected graph with N vertices and 0 edges. Process Q queries of the following types.\n\n0 u v: Add an edge (u, v).\n\n1 u v: Print 1 if u and v are in the same connected component, 0 otherwise.\n\nConstraints\n\n1 \\leq N \\leq 200,000\n\n1 \\leq Q \\leq 200,000\n\n0 \\leq u_i, v_i \\lt N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN Q\nt_1 u_1 v_1\nt_2 u_2 v_2\n:\nt_Q u_Q v_Q\n\n出力\n\nFor each query of the latter type, print the answer.\n\nSample Input 1\n\n4 7\n1 0 1\n0 0 1\n0 2 3\n1 0 1\n1 1 2\n0 0 2\n1 1 3\n\nSample Output 1\n\n0\n1\n0\n1", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1310, "cpu_time_ms": 111, "memory_kb": 7472}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s761190096", "group_id": "codeNet:p02561", "input_text": "module type CapType = sig\n type t\n val zero : t\n val cap_max : t\n val add : t -> t -> t\n val sub : t -> t -> t\n val to_int : t -> int\nend ;;\n\nmodule CapInt : CapType with type t = int = struct\n type t = int\n let zero = 0\n let cap_max = max_int\n let add = (+)\n let sub = (-)\n let to_int a = a\nend\n\nmodule type S = sig\n type t\n type cap\n\n val create : int -> int -> t\n val add_edge : t -> int -> int -> cap -> t\n val edges : t -> (int * int * cap * cap) array\n val get_edge : t -> int -> int * int * cap * cap\n val flow : t -> int -> int -> cap\nend;;\n\nmodule Mf_graph = struct\n module Make(Cap: CapType) : S with type cap = Cap.t = struct\n type cap = Cap.t\n\n type edge = { to_: int; rev: int; mutable cap : cap }\n type t = int * int * int list array * edge array\n\n let create n m =\n n, 0, Array.make n [], Array.init (m * 2) (fun _ -> { to_ = 0; rev = 0; cap = Cap.zero } )\n\n let get_edge (n, idx, g, pos) i =\n let _e = pos.(i * 2) in\n let _re = pos.(_e.rev) in\n _re.to_, _e.to_, Cap.add _e.cap _re.cap, _re.cap\n\n let edges ((n, idx, g, pos) as mf) =\n Array.init (idx / 2) (fun i -> get_edge mf i)\n\n let add_edge (n, idx, g, pos) from to_ cap =\n pos.(idx) <- { to_ = to_; rev = idx + 1; cap = cap };\n pos.(idx + 1) <- { to_ = from; rev = idx; cap = Cap.zero };\n g.(from) <- idx :: g.(from);\n g.(to_) <- (idx + 1) :: g.(to_);\n n, idx + 2, g, pos\n\n let flow mf s t =\n let flow (n, idx, g, pos) s t flow_limit =\n let g = Array.map List.rev g in\n let rec bfs () =\n let level = Array.make n (-1) in\n level.(s) <- 0;\n\n let rec loop fq bq =\n match fq with\n | [] -> if bq = [] then level else loop (List.rev bq) []\n | v :: vs -> (\n let rec loop2 bq = function\n | [] -> loop vs bq\n | e :: es ->\n let e = pos.(e) in\n if e.cap = Cap.zero || level.(e.to_) >= 0 then loop2 bq es else (\n level.(e.to_) <- level.(v) + 1;\n if e.to_ = t then level else loop2 (e.to_ :: bq) es\n )\n in\n loop2 bq g.(v)\n )\n in\n loop [ s ] []\n in\n let rec dfs level iter v up =\n if v = s then up else\n let level_v = level.(v) in\n let rec loop res iis =\n iter.(v) <- iis;\n match iis with\n | [] -> res\n | i :: is ->\n let e = pos.(i) in\n if level_v <= level.(e.to_) || pos.(e.rev).cap = Cap.zero then loop res is else\n let d = dfs level iter e.to_ (min (Cap.sub up res) pos.(e.rev).cap) in\n if d <= Cap.zero then loop res is else (\n pos.(i).cap <- Cap.add pos.(i).cap d;\n pos.(e.rev).cap <- Cap.sub pos.(e.rev).cap d;\n let res = Cap.add res d in\n if res = up then res else loop res is\n )\n in\n loop Cap.zero iter.(v)\n in\n let rec flow_loop flow =\n if flow >= flow_limit then flow else\n let level = bfs () in\n if level.(t) = -1 then flow else\n let iter = Array.copy g in\n let rec loop flow =\n if flow < flow_limit then (\n let f = dfs level iter t (Cap.sub flow_limit flow) in\n if f = Cap.zero then flow else\n loop (Cap.add flow f)\n ) else flow\n in\n loop flow\n in\n flow_loop Cap.zero\n\n in\n flow mf s t Cap.cap_max\n end\nend;;\n\nScanf.scanf \"%d %d\" (fun n m ->\n let ss = Array.init n (fun _ -> Scanf.scanf \" %s\" (fun s -> s)) in\n\n let module MF = Mf_graph.Make (CapInt) in\n let mf = MF.create (n * m + 2) (n * m * 3) in\n let s = n * m in\n let t = n * m + 1 in\n let rec loop_y y mf =\n let rec loop_x x mf =\n if x = m then loop_y (y + 1) mf else\n let pivot = y * m + x in\n let mf = if ss.(y).[x] = '#' then mf else (\n if (x + y) mod 2 <> 0 then MF.add_edge mf pivot t 1 else (\n let mf = MF.add_edge mf s pivot 1 in\n let mf = if y > 0 && ss.(y - 1).[x] = '.' then MF.add_edge mf pivot ((y - 1) * m + x) 1 else mf in\n let mf = if y < n - 1 && ss.(y + 1).[x] = '.' then MF.add_edge mf pivot ((y + 1) * m + x) 1 else mf in\n let mf = if x > 0 && ss.(y).[x - 1] = '.' then MF.add_edge mf pivot (y * m + x - 1) 1 else mf in\n let mf = if x < m - 1 && ss.(y).[x + 1] = '.' then MF.add_edge mf pivot (y * m + x + 1) 1 else mf in\n mf\n )\n )\n in\n loop_x (x + 1) mf\n in\n if y = n then mf else loop_x 0 mf\n in\n let mf = loop_y 0 mf in\n let f = MF.flow mf s t in\n let ar = MF.edges mf in\n let map = Array.make_matrix n m ' ' in\n for y = 0 to n - 1 do\n for x = 0 to m - 1 do\n map.(y).(x) <- ss.(y).[x]\n done\n done;\n Array.iter (fun (from, to_, c1, c2) -> if c2 > 0 && from <> s && to_ <> t then (\n let prt p1 c1 p2 c2 =\n let prt2 p c =\n let y = p / m in\n let x = p mod m in\n map.(y).(x) <- c\n in\n prt2 p1 c1; prt2 p2 c2\n in\n if from + m = to_ then prt from 'v' to_ '^' else\n if to_ + m = from then prt from '^' to_ 'v' else\n if from + 1 = to_ then prt from '>' to_ '<' else\n if to_ + 1 = from then prt from '<' to_ '>'\n )) ar;\n Printf.printf \"%d\\n\" f;\n for y = 0 to n - 1 do\n for x = 0 to m - 1 do\n print_char map.(y).(x)\n done;\n print_newline ()\n done\n)", "language": "OCaml", "metadata": {"date": 1600730186, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p02561.html", "problem_id": "p02561", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02561/input.txt", "sample_output_relpath": "derived/input_output/data/p02561/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02561/OCaml/s761190096.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s761190096", "user_id": "u342443598"}, "prompt_components": {"gold_output": "3\n#><\nvv#\n^^.\n", "input_to_evaluate": "module type CapType = sig\n type t\n val zero : t\n val cap_max : t\n val add : t -> t -> t\n val sub : t -> t -> t\n val to_int : t -> int\nend ;;\n\nmodule CapInt : CapType with type t = int = struct\n type t = int\n let zero = 0\n let cap_max = max_int\n let add = (+)\n let sub = (-)\n let to_int a = a\nend\n\nmodule type S = sig\n type t\n type cap\n\n val create : int -> int -> t\n val add_edge : t -> int -> int -> cap -> t\n val edges : t -> (int * int * cap * cap) array\n val get_edge : t -> int -> int * int * cap * cap\n val flow : t -> int -> int -> cap\nend;;\n\nmodule Mf_graph = struct\n module Make(Cap: CapType) : S with type cap = Cap.t = struct\n type cap = Cap.t\n\n type edge = { to_: int; rev: int; mutable cap : cap }\n type t = int * int * int list array * edge array\n\n let create n m =\n n, 0, Array.make n [], Array.init (m * 2) (fun _ -> { to_ = 0; rev = 0; cap = Cap.zero } )\n\n let get_edge (n, idx, g, pos) i =\n let _e = pos.(i * 2) in\n let _re = pos.(_e.rev) in\n _re.to_, _e.to_, Cap.add _e.cap _re.cap, _re.cap\n\n let edges ((n, idx, g, pos) as mf) =\n Array.init (idx / 2) (fun i -> get_edge mf i)\n\n let add_edge (n, idx, g, pos) from to_ cap =\n pos.(idx) <- { to_ = to_; rev = idx + 1; cap = cap };\n pos.(idx + 1) <- { to_ = from; rev = idx; cap = Cap.zero };\n g.(from) <- idx :: g.(from);\n g.(to_) <- (idx + 1) :: g.(to_);\n n, idx + 2, g, pos\n\n let flow mf s t =\n let flow (n, idx, g, pos) s t flow_limit =\n let g = Array.map List.rev g in\n let rec bfs () =\n let level = Array.make n (-1) in\n level.(s) <- 0;\n\n let rec loop fq bq =\n match fq with\n | [] -> if bq = [] then level else loop (List.rev bq) []\n | v :: vs -> (\n let rec loop2 bq = function\n | [] -> loop vs bq\n | e :: es ->\n let e = pos.(e) in\n if e.cap = Cap.zero || level.(e.to_) >= 0 then loop2 bq es else (\n level.(e.to_) <- level.(v) + 1;\n if e.to_ = t then level else loop2 (e.to_ :: bq) es\n )\n in\n loop2 bq g.(v)\n )\n in\n loop [ s ] []\n in\n let rec dfs level iter v up =\n if v = s then up else\n let level_v = level.(v) in\n let rec loop res iis =\n iter.(v) <- iis;\n match iis with\n | [] -> res\n | i :: is ->\n let e = pos.(i) in\n if level_v <= level.(e.to_) || pos.(e.rev).cap = Cap.zero then loop res is else\n let d = dfs level iter e.to_ (min (Cap.sub up res) pos.(e.rev).cap) in\n if d <= Cap.zero then loop res is else (\n pos.(i).cap <- Cap.add pos.(i).cap d;\n pos.(e.rev).cap <- Cap.sub pos.(e.rev).cap d;\n let res = Cap.add res d in\n if res = up then res else loop res is\n )\n in\n loop Cap.zero iter.(v)\n in\n let rec flow_loop flow =\n if flow >= flow_limit then flow else\n let level = bfs () in\n if level.(t) = -1 then flow else\n let iter = Array.copy g in\n let rec loop flow =\n if flow < flow_limit then (\n let f = dfs level iter t (Cap.sub flow_limit flow) in\n if f = Cap.zero then flow else\n loop (Cap.add flow f)\n ) else flow\n in\n loop flow\n in\n flow_loop Cap.zero\n\n in\n flow mf s t Cap.cap_max\n end\nend;;\n\nScanf.scanf \"%d %d\" (fun n m ->\n let ss = Array.init n (fun _ -> Scanf.scanf \" %s\" (fun s -> s)) in\n\n let module MF = Mf_graph.Make (CapInt) in\n let mf = MF.create (n * m + 2) (n * m * 3) in\n let s = n * m in\n let t = n * m + 1 in\n let rec loop_y y mf =\n let rec loop_x x mf =\n if x = m then loop_y (y + 1) mf else\n let pivot = y * m + x in\n let mf = if ss.(y).[x] = '#' then mf else (\n if (x + y) mod 2 <> 0 then MF.add_edge mf pivot t 1 else (\n let mf = MF.add_edge mf s pivot 1 in\n let mf = if y > 0 && ss.(y - 1).[x] = '.' then MF.add_edge mf pivot ((y - 1) * m + x) 1 else mf in\n let mf = if y < n - 1 && ss.(y + 1).[x] = '.' then MF.add_edge mf pivot ((y + 1) * m + x) 1 else mf in\n let mf = if x > 0 && ss.(y).[x - 1] = '.' then MF.add_edge mf pivot (y * m + x - 1) 1 else mf in\n let mf = if x < m - 1 && ss.(y).[x + 1] = '.' then MF.add_edge mf pivot (y * m + x + 1) 1 else mf in\n mf\n )\n )\n in\n loop_x (x + 1) mf\n in\n if y = n then mf else loop_x 0 mf\n in\n let mf = loop_y 0 mf in\n let f = MF.flow mf s t in\n let ar = MF.edges mf in\n let map = Array.make_matrix n m ' ' in\n for y = 0 to n - 1 do\n for x = 0 to m - 1 do\n map.(y).(x) <- ss.(y).[x]\n done\n done;\n Array.iter (fun (from, to_, c1, c2) -> if c2 > 0 && from <> s && to_ <> t then (\n let prt p1 c1 p2 c2 =\n let prt2 p c =\n let y = p / m in\n let x = p mod m in\n map.(y).(x) <- c\n in\n prt2 p1 c1; prt2 p2 c2\n in\n if from + m = to_ then prt from 'v' to_ '^' else\n if to_ + m = from then prt from '^' to_ 'v' else\n if from + 1 = to_ then prt from '>' to_ '<' else\n if to_ + 1 = from then prt from '<' to_ '>'\n )) ar;\n Printf.printf \"%d\\n\" f;\n for y = 0 to n - 1 do\n for x = 0 to m - 1 do\n print_char map.(y).(x)\n done;\n print_newline ()\n done\n)", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou are given a grid of N rows and M columns. The square at the i-th row and j-th column will be denoted as (i,j).\nSome of the squares contain an object. All the remaining squares are empty.\nThe state of the grid is represented by strings S_1,S_2,\\cdots,S_N. The square (i,j) contains an object if S_{i,j}= # and is empty if S_{i,j}= ..\n\nConsider placing 1 \\times 2 tiles on the grid. Tiles can be placed vertically or horizontally to cover two adjacent empty squares.\nTiles must not stick out of the grid, and no two different tiles may intersect. Tiles cannot occupy the square with an object.\n\nCalculate the maximum number of tiles that can be placed and any configulation that acheives the maximum.\n\nConstraints\n\n1 \\leq N \\leq 100\n\n1 \\leq M \\leq 100\n\nS_i is a string with length M consists of # and ..\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nS_1\nS_2\n\\vdots\nS_N\n\nOutput\n\nOn the first line, print the maximum number of tiles that can be placed.\n\nOn the next N lines, print a configulation that achieves the maximum.\nPrecisely, output the strings t_1,t_2,\\cdots,t_N constructed by the following way.\n\nt_i is initialized to S_i.\n\nFor each (i,j), if there is a tile that occupies (i,j) and (i+1,j), change t_{i,j}:=v, t_{i+1,j}:=^.\n\nFor each (i,j), if there is a tile that occupies (i,j) and (i,j+1), change t_{i,j}:=>, t_{i,j+1}:=<.\n\nSee samples for further information.\n\nYou may print any configulation that maximizes the number of tiles.\n\nSample Input 1\n\n3 3\n#..\n..#\n...\n\nSample Output 1\n\n3\n#><\nvv#\n^^.\n\nThe following output is also treated as a correct answer.\n\n3\n#><\nv.#\n^><", "sample_input": "3 3\n#..\n..#\n...\n"}, "reference_outputs": ["3\n#><\nvv#\n^^.\n"], "source_document_id": "p02561", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou are given a grid of N rows and M columns. The square at the i-th row and j-th column will be denoted as (i,j).\nSome of the squares contain an object. All the remaining squares are empty.\nThe state of the grid is represented by strings S_1,S_2,\\cdots,S_N. The square (i,j) contains an object if S_{i,j}= # and is empty if S_{i,j}= ..\n\nConsider placing 1 \\times 2 tiles on the grid. Tiles can be placed vertically or horizontally to cover two adjacent empty squares.\nTiles must not stick out of the grid, and no two different tiles may intersect. Tiles cannot occupy the square with an object.\n\nCalculate the maximum number of tiles that can be placed and any configulation that acheives the maximum.\n\nConstraints\n\n1 \\leq N \\leq 100\n\n1 \\leq M \\leq 100\n\nS_i is a string with length M consists of # and ..\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nS_1\nS_2\n\\vdots\nS_N\n\nOutput\n\nOn the first line, print the maximum number of tiles that can be placed.\n\nOn the next N lines, print a configulation that achieves the maximum.\nPrecisely, output the strings t_1,t_2,\\cdots,t_N constructed by the following way.\n\nt_i is initialized to S_i.\n\nFor each (i,j), if there is a tile that occupies (i,j) and (i+1,j), change t_{i,j}:=v, t_{i+1,j}:=^.\n\nFor each (i,j), if there is a tile that occupies (i,j) and (i,j+1), change t_{i,j}:=>, t_{i,j+1}:=<.\n\nSee samples for further information.\n\nYou may print any configulation that maximizes the number of tiles.\n\nSample Input 1\n\n3 3\n#..\n..#\n...\n\nSample Output 1\n\n3\n#><\nvv#\n^^.\n\nThe following output is also treated as a correct answer.\n\n3\n#><\nv.#\n^><", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 6938, "cpu_time_ms": 37, "memory_kb": 14132}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s185224627", "group_id": "codeNet:p02570", "input_text": "open Core;;\n\nlet (d, t, s) = Scanf.scanf \"%d %d %d\" Tuple3.create in\nprintf \"%s\\n\" (if d <= t * s then \"Yes\" else \"No\")\n;;\n\n", "language": "OCaml", "metadata": {"date": 1599158367, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p02570.html", "problem_id": "p02570", "resource_group": "low_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/OCaml/s185224627.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s185224627", "user_id": "u411712623"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "open Core;;\n\nlet (d, t, s) = Scanf.scanf \"%d %d %d\" Tuple3.create in\nprintf \"%s\\n\" (if d <= t * s then \"Yes\" else \"No\")\n;;\n\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nTakahashi is meeting up with Aoki.\n\nThey have planned to meet at a place that is D meters away from Takahashi's house in T minutes from now.\n\nTakahashi will leave his house now and go straight to the place at a speed of S meters per minute.\n\nWill he arrive in time?\n\nConstraints\n\n1 \\leq D \\leq 10000\n\n1 \\leq T \\leq 10000\n\n1 \\leq S \\leq 10000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nD T S\n\nOutput\n\nIf Takahashi will reach the place in time, print Yes; otherwise, print No.\n\nSample Input 1\n\n1000 15 80\n\nSample Output 1\n\nYes\n\nIt takes 12.5 minutes to go 1000 meters to the place at a speed of 80 meters per minute. They have planned to meet in 15 minutes so he will arrive in time.\n\nSample Input 2\n\n2000 20 100\n\nSample Output 2\n\nYes\n\nIt takes 20 minutes to go 2000 meters to the place at a speed of 100 meters per minute. They have planned to meet in 20 minutes so he will arrive just on time.\n\nSample Input 3\n\n10000 1 1\n\nSample Output 3\n\nNo\n\nHe will be late.", "sample_input": "1000 15 80\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02570", "source_text": "Score : 100 points\n\nProblem Statement\n\nTakahashi is meeting up with Aoki.\n\nThey have planned to meet at a place that is D meters away from Takahashi's house in T minutes from now.\n\nTakahashi will leave his house now and go straight to the place at a speed of S meters per minute.\n\nWill he arrive in time?\n\nConstraints\n\n1 \\leq D \\leq 10000\n\n1 \\leq T \\leq 10000\n\n1 \\leq S \\leq 10000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nD T S\n\nOutput\n\nIf Takahashi will reach the place in time, print Yes; otherwise, print No.\n\nSample Input 1\n\n1000 15 80\n\nSample Output 1\n\nYes\n\nIt takes 12.5 minutes to go 1000 meters to the place at a speed of 80 meters per minute. They have planned to meet in 15 minutes so he will arrive in time.\n\nSample Input 2\n\n2000 20 100\n\nSample Output 2\n\nYes\n\nIt takes 20 minutes to go 2000 meters to the place at a speed of 100 meters per minute. They have planned to meet in 20 minutes so he will arrive just on time.\n\nSample Input 3\n\n10000 1 1\n\nSample Output 3\n\nNo\n\nHe will be late.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 17, "memory_kb": 13632}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s478418452", "group_id": "codeNet:p02570", "input_text": "let () =\n Scanf.scanf \"%d %d %d\\n\" @@ fun d t s ->\n Printf.printf \"%s\\n\" (if d <= t * s then \"Yes\" else \"No\")", "language": "OCaml", "metadata": {"date": 1598727725, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p02570.html", "problem_id": "p02570", "resource_group": "low_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/OCaml/s478418452.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s478418452", "user_id": "u307426615"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "let () =\n Scanf.scanf \"%d %d %d\\n\" @@ fun d t s ->\n Printf.printf \"%s\\n\" (if d <= t * s then \"Yes\" else \"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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 8, "memory_kb": 3716}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s818626181", "group_id": "codeNet:p02571", "input_text": "open Batteries\nopen Printf\n\nlet ($) g f x = g (f x)\n\nlet swap = Tuple2.swap\n\nlet s2i = int_of_string\nlet i2s = string_of_int\nlet s2f = float_of_string\nlet f2s = string_of_float\nlet f2i = int_of_float\nlet i2f = float_of_int \n\nlet c2a = int_of_char\nlet a2c = char_of_int\n\nlet c2i c = c2a c - 48\nlet i2c i = a2c (i + 48)\n\nlet c2s = String.of_char\nlet s2cl = String.to_list\nlet cl2s = String.of_list\n\nlet puts s = print_endline s\nlet putw ?yn:(yn=(\"Yes\", \"No\")) b = puts (if b then fst yn else snd yn)\nlet puti i = puts @@ i2s i\n\n\n\nmodule StaleList = struct\n include List\n\n let nmem x l = not @@ mem x l\n\n let len = length\n let size = length\n let nempty l = not @@ is_empty l\n\n let hdop l = if nempty l then Some (hd l) else None\n\n (* let taker = drop *)\n let takewh = take_while\n\n (* let dropr = take *)\n let dropwh = drop_while\n\n let split_by = span\n\n let chunk = ntake\n\n let foldl = fold_left\n let foldli = fold_lefti\n let foldr f z l = fold_right f l z\n let foldri f z l = fold_righti f l z\n\n let partition_to_map f l =\n foldr (fun x m -> Map.modify_opt (f x) (function\n | None -> Some [x] \n | Some [] -> Some [x] \n | Some vl -> Some (x::vl)) m) Map.empty l;;\n\n let scanl f z ls =\n let rec loop acl acc = function\n | [] -> rev acl\n | h::t ->\n let r = f acc h in\n loop (r::acl) r t\n in loop [] z ls\n\n let scanr f z ls =\n let rec loop acl acc = function\n | [] -> acl \n | h::t ->\n let r = f h acc in\n loop (r::acl) r t\n in loop [] z (rev ls)\n\n (* let scanli = scan_lefti *)\n (* let scanri = scan_righti *)\n \n let flatmap = concat_map\n\n let zipf = map2\n let zipfi = map2i\n\nend\n\nmodule L = StaleList\n\nmodule StaleArray = struct\n include Array \n\n let nmem x l = not @@ mem x l\n\n let len = length\n let size = length\n let is_empty r = len r = 0\n let nempty r = len r > 0\n\n let take n r = left r n\n let taker n r = right r n\n\n let takeb x r =\n let l = len r in\n let rec loop i =\n if i >= l then r\n else if r.(i) = x then take i r\n else loop (i + 1)\n in loop 0\n \n (* let takewh = take_while *)\n\n let drop n r = tail r n\n let dropr n r = take ((len r) - n) r\n (* let dropwh = drop_while *)\n\n let index_of x r =\n let l = len r in\n let rec loop i =\n if i >= l then None\n else if r.(i) = x then Some i\n else loop (i + 1)\n in loop 0\n\n (* let split_by = span *)\n\n (* let chunk = ntake *)\n\n let foldl = fold_left\n let foldli = fold_lefti\n let foldr f z l = fold_right f l z\n let foldri f z l = fold_righti f l z\n\n (* let partition_to_map f l = *)\n (* foldr (fun x m -> Map.modify_opt (f x) (function *)\n (* | None -> Some [x] *)\n (* | Some [] -> Some [x] *)\n (* | Some vl -> Some (x::vl)) m) Map.empty l;; *)\n\n (* let scanl = scan_left *)\n (* let scanli = scan_lefti *)\n (* let scanr = scan_right *)\n (* let scanri = scan_righti *)\n \n let concat2 = append\n \n let flatmap (f : 'a -> 'b array) a =\n map f a |> enum |> L.of_enum |> concat\n\n let zipf = map2\n (* let zipfi = map2i *)\n\nend\n\nmodule A = StaleArray\n\nmodule StaleString = struct\n include String\n\n let len = length\n\n let replace_chars = map\n let map = replace\n\n let maptol f s = L.map f (s2cl s)\n let maptoli f s = L.map f (s2cl s)\n\n let zipf f a b = L.zipf f (s2cl a) (s2cl b)\n let zipfi f a b = L.zipfi f (s2cl a) (s2cl b)\n\n let mkstr f sep ls =\n L.foldl (fun acc x -> acc ^ sep ^ (f x)) (f @@ L.hd ls) (List.tl ls)\n\nend\n\nmodule S = StaleString\n\nlet spsp s = S.split_on_char ' ' s\n\n\nmodule StaleSortedSet = struct\n include Set\n\n module Make (Ord : Set.OrderedType) = struct\n include Set.Make(Ord)\n\n let nmem x st = not @@ mem x st\n\n let foldl f s z = fold (fun x a -> f a x) z s\n\n let size = cardinal\n end\n\n let nmem x st = not @@ mem x st\n\n let foldl f s z = fold (fun x a -> f a x) z s\n\n let size = cardinal\nend\n\nmodule Ss = StaleSortedSet\n\nmodule StaleSortedMap = struct\n include Map\n\n module Make (Ord : Map.OrderedType) = struct\n include Map.Make(Ord)\n\n let nmem x st = not @@ mem x st\n\n let get = find\n let get_or x d m = find_default d x m\n\n let size = cardinal\n end\n\n let nmem x st = not @@ mem x st\n\n let get = find\n let get_or x d m = find_default d x m\n\n let size = cardinal\nend\n\nmodule Ms = StaleSortedMap\n\n\nmodule StaleRange = struct\n\n type t = Range of int * int\n\n let make lb ub = Range (lb, ub)\n\n let to_list r =\n let Range (lb, ub) = r in\n L.make (ub - lb) ((+) lb) \n\n let to_array r =\n let Range (lb, ub) = r in\n A.make (ub - lb) ((+) lb)\n\n let iter r f = \n let Range (lb, ub) = r in\n for i = lb to ub do f i done\n\n let iter2 r1 r2 f =\n let Range (lb1, ub1) = r1 and Range (lb2, ub2) = r2 in\n for i = lb1 to ub2 do\n for j = lb2 to ub2 do\n f i j\n done\n done\nend\n\nmodule R = StaleRange\n\nlet (---) lb ub = R.make lb ub\nlet (--^) lb ub = R.make lb (ub - 1)\n\nmodule StaleGenericAlgorithms = struct\n\n let set_power ls =\n let rec loop ls pls =\n match ls with\n | [] -> pls\n | hd::tl -> loop tl (L.flatmap (fun p -> [p; hd::p]) pls)\n in loop ls [[]]\n\n let rec bsearch_max_int f lb ub =\n if lb >= ub then (if f lb then lb else (lb - 1))\n else (\n let m = (lb + ub) / 2 in\n if f m then bsearch_max_int f (m + 1) ub\n else bsearch_max_int f lb m\n )\n\n let partial_sum n ls =\n let rec loop s k = function\n | [] -> s\n | h::t ->\n if k >= n then s\n else loop (s + h) (k + 1) t\n in\n loop 0 0 ls\n\nend\n\nmodule Gal = StaleGenericAlgorithms\n\nlet rds () = read_line ()\n\nlet rdi () = s2i @@ rds ()\n\nlet rdhs () = spsp @@ rds ()\nlet rdhi () = rdhs () |> L.map s2i\n\nlet rdhf () = rdhs () |> L.map s2f\n\nlet rdf2 () = match rdhf () with\n| a::b::_ -> (a, b)\n| _ -> (0., 0.)\n\nlet rdf3 () = match rdhf () with\n| a::b::c::_ -> (a, b, c)\n| _ -> (0., 0., 0.)\n\nlet rdf4 () = match rdhf () with\n| a::b::c::d::_ -> (a, b, c, d)\n| _ -> (0., 0., 0., 0.)\n\nlet rds2 () = match rdhs () with\n | a::b::_ -> (a, b)\n | _ -> (\"\", \"\")\n\nlet rdi2 () = match rdhi () with\n | a::b::_ -> (a, b)\n | _ -> (0, 0)\n\nlet rdi3 () = match rdhi () with\n| a::b::c::_ -> (a, b, c)\n| _ -> (0, 0, 0)\n\nlet rdi4 () = match rdhi () with\n| a::b::c::d::_ -> (a, b, c, d)\n| _ -> (0, 0, 0, 0)\n\nlet rdi5 () = match rdhi () with\n| a::b::c::d::e::_ -> (a, b, c, d, e)\n| _ -> (0, 0, 0, 0, 0)\n\nlet rdv n rf =\n let rec loop n =\n if n <= 0 then []\n else (\n let s = rf () in\n s::(loop (n - 1))\n )\n in loop n\n\nlet rdvi n = rdv n rdi\nlet rdvi2 n = rdv n rdi2\nlet rdvi3 n = rdv n rdi3\nlet rdvi4 n = rdv n rdi4\n\n\nlet print_list aa = \n printf \"[ \"; aa |> L.iter (fun a -> printf \"%d \" a); puts \"]\"\n\nlet print_array aa = \n printf \"[ \"; aa |> A.iter (fun a -> printf \"%d \" a); puts \"]\"\n\nlet print_carray aa = \n printf \"[ \"; aa |> A.iter (fun a -> printf \"%c \" a); puts \"]\"\n\nlet print_matrix mat =\n puts \"----\";\n mat |> A.iter (fun r -> print_carray r);\n puts \"----\"\n\n\nlet _ =\n let s = s2cl @@ rds () and t = s2cl @@ rds () in\n let len = L.len t in\n\n let rec diff s1 s2 = L.len @@ L.filter (fun x -> x) @@ L.zipf (<>) s1 s2 in\n\n let rec min_diff m sl =\n if L.len sl < len then m\n else\n let d = diff t (L.take len sl) in\n if d < m then min_diff d (L.tl sl) else min_diff m (L.tl sl)\n in\n\n puti @@ min_diff 10000 s\n", "language": "OCaml", "metadata": {"date": 1598729067, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p02571.html", "problem_id": "p02571", "resource_group": "low_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/OCaml/s818626181.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s818626181", "user_id": "u970139668"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "open Batteries\nopen Printf\n\nlet ($) g f x = g (f x)\n\nlet swap = Tuple2.swap\n\nlet s2i = int_of_string\nlet i2s = string_of_int\nlet s2f = float_of_string\nlet f2s = string_of_float\nlet f2i = int_of_float\nlet i2f = float_of_int \n\nlet c2a = int_of_char\nlet a2c = char_of_int\n\nlet c2i c = c2a c - 48\nlet i2c i = a2c (i + 48)\n\nlet c2s = String.of_char\nlet s2cl = String.to_list\nlet cl2s = String.of_list\n\nlet puts s = print_endline s\nlet putw ?yn:(yn=(\"Yes\", \"No\")) b = puts (if b then fst yn else snd yn)\nlet puti i = puts @@ i2s i\n\n\n\nmodule StaleList = struct\n include List\n\n let nmem x l = not @@ mem x l\n\n let len = length\n let size = length\n let nempty l = not @@ is_empty l\n\n let hdop l = if nempty l then Some (hd l) else None\n\n (* let taker = drop *)\n let takewh = take_while\n\n (* let dropr = take *)\n let dropwh = drop_while\n\n let split_by = span\n\n let chunk = ntake\n\n let foldl = fold_left\n let foldli = fold_lefti\n let foldr f z l = fold_right f l z\n let foldri f z l = fold_righti f l z\n\n let partition_to_map f l =\n foldr (fun x m -> Map.modify_opt (f x) (function\n | None -> Some [x] \n | Some [] -> Some [x] \n | Some vl -> Some (x::vl)) m) Map.empty l;;\n\n let scanl f z ls =\n let rec loop acl acc = function\n | [] -> rev acl\n | h::t ->\n let r = f acc h in\n loop (r::acl) r t\n in loop [] z ls\n\n let scanr f z ls =\n let rec loop acl acc = function\n | [] -> acl \n | h::t ->\n let r = f h acc in\n loop (r::acl) r t\n in loop [] z (rev ls)\n\n (* let scanli = scan_lefti *)\n (* let scanri = scan_righti *)\n \n let flatmap = concat_map\n\n let zipf = map2\n let zipfi = map2i\n\nend\n\nmodule L = StaleList\n\nmodule StaleArray = struct\n include Array \n\n let nmem x l = not @@ mem x l\n\n let len = length\n let size = length\n let is_empty r = len r = 0\n let nempty r = len r > 0\n\n let take n r = left r n\n let taker n r = right r n\n\n let takeb x r =\n let l = len r in\n let rec loop i =\n if i >= l then r\n else if r.(i) = x then take i r\n else loop (i + 1)\n in loop 0\n \n (* let takewh = take_while *)\n\n let drop n r = tail r n\n let dropr n r = take ((len r) - n) r\n (* let dropwh = drop_while *)\n\n let index_of x r =\n let l = len r in\n let rec loop i =\n if i >= l then None\n else if r.(i) = x then Some i\n else loop (i + 1)\n in loop 0\n\n (* let split_by = span *)\n\n (* let chunk = ntake *)\n\n let foldl = fold_left\n let foldli = fold_lefti\n let foldr f z l = fold_right f l z\n let foldri f z l = fold_righti f l z\n\n (* let partition_to_map f l = *)\n (* foldr (fun x m -> Map.modify_opt (f x) (function *)\n (* | None -> Some [x] *)\n (* | Some [] -> Some [x] *)\n (* | Some vl -> Some (x::vl)) m) Map.empty l;; *)\n\n (* let scanl = scan_left *)\n (* let scanli = scan_lefti *)\n (* let scanr = scan_right *)\n (* let scanri = scan_righti *)\n \n let concat2 = append\n \n let flatmap (f : 'a -> 'b array) a =\n map f a |> enum |> L.of_enum |> concat\n\n let zipf = map2\n (* let zipfi = map2i *)\n\nend\n\nmodule A = StaleArray\n\nmodule StaleString = struct\n include String\n\n let len = length\n\n let replace_chars = map\n let map = replace\n\n let maptol f s = L.map f (s2cl s)\n let maptoli f s = L.map f (s2cl s)\n\n let zipf f a b = L.zipf f (s2cl a) (s2cl b)\n let zipfi f a b = L.zipfi f (s2cl a) (s2cl b)\n\n let mkstr f sep ls =\n L.foldl (fun acc x -> acc ^ sep ^ (f x)) (f @@ L.hd ls) (List.tl ls)\n\nend\n\nmodule S = StaleString\n\nlet spsp s = S.split_on_char ' ' s\n\n\nmodule StaleSortedSet = struct\n include Set\n\n module Make (Ord : Set.OrderedType) = struct\n include Set.Make(Ord)\n\n let nmem x st = not @@ mem x st\n\n let foldl f s z = fold (fun x a -> f a x) z s\n\n let size = cardinal\n end\n\n let nmem x st = not @@ mem x st\n\n let foldl f s z = fold (fun x a -> f a x) z s\n\n let size = cardinal\nend\n\nmodule Ss = StaleSortedSet\n\nmodule StaleSortedMap = struct\n include Map\n\n module Make (Ord : Map.OrderedType) = struct\n include Map.Make(Ord)\n\n let nmem x st = not @@ mem x st\n\n let get = find\n let get_or x d m = find_default d x m\n\n let size = cardinal\n end\n\n let nmem x st = not @@ mem x st\n\n let get = find\n let get_or x d m = find_default d x m\n\n let size = cardinal\nend\n\nmodule Ms = StaleSortedMap\n\n\nmodule StaleRange = struct\n\n type t = Range of int * int\n\n let make lb ub = Range (lb, ub)\n\n let to_list r =\n let Range (lb, ub) = r in\n L.make (ub - lb) ((+) lb) \n\n let to_array r =\n let Range (lb, ub) = r in\n A.make (ub - lb) ((+) lb)\n\n let iter r f = \n let Range (lb, ub) = r in\n for i = lb to ub do f i done\n\n let iter2 r1 r2 f =\n let Range (lb1, ub1) = r1 and Range (lb2, ub2) = r2 in\n for i = lb1 to ub2 do\n for j = lb2 to ub2 do\n f i j\n done\n done\nend\n\nmodule R = StaleRange\n\nlet (---) lb ub = R.make lb ub\nlet (--^) lb ub = R.make lb (ub - 1)\n\nmodule StaleGenericAlgorithms = struct\n\n let set_power ls =\n let rec loop ls pls =\n match ls with\n | [] -> pls\n | hd::tl -> loop tl (L.flatmap (fun p -> [p; hd::p]) pls)\n in loop ls [[]]\n\n let rec bsearch_max_int f lb ub =\n if lb >= ub then (if f lb then lb else (lb - 1))\n else (\n let m = (lb + ub) / 2 in\n if f m then bsearch_max_int f (m + 1) ub\n else bsearch_max_int f lb m\n )\n\n let partial_sum n ls =\n let rec loop s k = function\n | [] -> s\n | h::t ->\n if k >= n then s\n else loop (s + h) (k + 1) t\n in\n loop 0 0 ls\n\nend\n\nmodule Gal = StaleGenericAlgorithms\n\nlet rds () = read_line ()\n\nlet rdi () = s2i @@ rds ()\n\nlet rdhs () = spsp @@ rds ()\nlet rdhi () = rdhs () |> L.map s2i\n\nlet rdhf () = rdhs () |> L.map s2f\n\nlet rdf2 () = match rdhf () with\n| a::b::_ -> (a, b)\n| _ -> (0., 0.)\n\nlet rdf3 () = match rdhf () with\n| a::b::c::_ -> (a, b, c)\n| _ -> (0., 0., 0.)\n\nlet rdf4 () = match rdhf () with\n| a::b::c::d::_ -> (a, b, c, d)\n| _ -> (0., 0., 0., 0.)\n\nlet rds2 () = match rdhs () with\n | a::b::_ -> (a, b)\n | _ -> (\"\", \"\")\n\nlet rdi2 () = match rdhi () with\n | a::b::_ -> (a, b)\n | _ -> (0, 0)\n\nlet rdi3 () = match rdhi () with\n| a::b::c::_ -> (a, b, c)\n| _ -> (0, 0, 0)\n\nlet rdi4 () = match rdhi () with\n| a::b::c::d::_ -> (a, b, c, d)\n| _ -> (0, 0, 0, 0)\n\nlet rdi5 () = match rdhi () with\n| a::b::c::d::e::_ -> (a, b, c, d, e)\n| _ -> (0, 0, 0, 0, 0)\n\nlet rdv n rf =\n let rec loop n =\n if n <= 0 then []\n else (\n let s = rf () in\n s::(loop (n - 1))\n )\n in loop n\n\nlet rdvi n = rdv n rdi\nlet rdvi2 n = rdv n rdi2\nlet rdvi3 n = rdv n rdi3\nlet rdvi4 n = rdv n rdi4\n\n\nlet print_list aa = \n printf \"[ \"; aa |> L.iter (fun a -> printf \"%d \" a); puts \"]\"\n\nlet print_array aa = \n printf \"[ \"; aa |> A.iter (fun a -> printf \"%d \" a); puts \"]\"\n\nlet print_carray aa = \n printf \"[ \"; aa |> A.iter (fun a -> printf \"%c \" a); puts \"]\"\n\nlet print_matrix mat =\n puts \"----\";\n mat |> A.iter (fun r -> print_carray r);\n puts \"----\"\n\n\nlet _ =\n let s = s2cl @@ rds () and t = s2cl @@ rds () in\n let len = L.len t in\n\n let rec diff s1 s2 = L.len @@ L.filter (fun x -> x) @@ L.zipf (<>) s1 s2 in\n\n let rec min_diff m sl =\n if L.len sl < len then m\n else\n let d = diff t (L.take len sl) in\n if d < m then min_diff d (L.tl sl) else min_diff m (L.tl sl)\n in\n\n puti @@ min_diff 10000 s\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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 7339, "cpu_time_ms": 21, "memory_kb": 7560}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s026137908", "group_id": "codeNet:p02571", "input_text": "let () =\n let rec charlist_of_string str n i =\n if i = n then [] else str.[i] :: charlist_of_string str n (i+1) in\n Scanf.scanf \"%s\\n%s\\n\" @@ fun s t ->\n let slst = charlist_of_string s (String.length s) 0 in\n let tlst = charlist_of_string t (String.length t) 0 in\n let ans = ref max_int in\n let rec check lst1 lst2 ans = match lst1, lst2 with\n | [], [] -> ans\n | _, [] -> raise Not_found\n | [], _ -> raise Not_found\n | h1 :: t1, h2 :: t2 -> if h1 = h2 then check t1 t2 ans else check t1 t2 (ans + 1) in\n for start = 0 to (String.length s) - (String.length t) - 1 do\n let buf = check (Array.to_list (Array.sub (Array.of_list slst) start (String.length t))) tlst 0 in\n if buf < !ans then ans := buf\n done;\n Printf.printf \"%d\\n\" !ans", "language": "OCaml", "metadata": {"date": 1598728720, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p02571.html", "problem_id": "p02571", "resource_group": "low_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/OCaml/s026137908.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s026137908", "user_id": "u307426615"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "let () =\n let rec charlist_of_string str n i =\n if i = n then [] else str.[i] :: charlist_of_string str n (i+1) in\n Scanf.scanf \"%s\\n%s\\n\" @@ fun s t ->\n let slst = charlist_of_string s (String.length s) 0 in\n let tlst = charlist_of_string t (String.length t) 0 in\n let ans = ref max_int in\n let rec check lst1 lst2 ans = match lst1, lst2 with\n | [], [] -> ans\n | _, [] -> raise Not_found\n | [], _ -> raise Not_found\n | h1 :: t1, h2 :: t2 -> if h1 = h2 then check t1 t2 ans else check t1 t2 (ans + 1) in\n for start = 0 to (String.length s) - (String.length t) - 1 do\n let buf = check (Array.to_list (Array.sub (Array.of_list slst) start (String.length t))) tlst 0 in\n if buf < !ans then ans := buf\n done;\n Printf.printf \"%d\\n\" !ans", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 763, "cpu_time_ms": 23, "memory_kb": 11036}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s621415873", "group_id": "codeNet:p02575", "input_text": "let () = Scanf.scanf \"%d %d\\n\" @@ fun h w ->\n let as_ = Array.make h 0 in\n let bs = Array.make h 0 in\n for i = 0 to h - 1 do\n Scanf.scanf \"%d %d\\n\" @@ fun a b ->\n as_.(i) <- a;\n bs.(i) <- b\n done;\n let dp = Array.make (h + 1) 1 in\n for i = 0 to h - 1 do\n dp.(i + 1) <- if dp.(i) < as_.(i) then dp.(i) else bs.(i) + 1\n done;\n let dp' = Array.make (h + 1) w in\n for i = h - 1 downto 0 do\n dp'.(i) <- if bs.(i) < dp.(i + 1) then dp.(i + 1) else as_.(i) - 1\n done;\n for i = 1 to h do\n Printf.printf \"%d\\n\" @@\n if w < dp.(i)\n then -1\n else i + min (dp.(i) - 1) (dp'.(i) - dp'.(0))\n done\n", "language": "OCaml", "metadata": {"date": 1598733720, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p02575.html", "problem_id": "p02575", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02575/input.txt", "sample_output_relpath": "derived/input_output/data/p02575/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02575/OCaml/s621415873.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s621415873", "user_id": "u504158101"}, "prompt_components": {"gold_output": "1\n3\n6\n-1\n", "input_to_evaluate": "let () = Scanf.scanf \"%d %d\\n\" @@ fun h w ->\n let as_ = Array.make h 0 in\n let bs = Array.make h 0 in\n for i = 0 to h - 1 do\n Scanf.scanf \"%d %d\\n\" @@ fun a b ->\n as_.(i) <- a;\n bs.(i) <- b\n done;\n let dp = Array.make (h + 1) 1 in\n for i = 0 to h - 1 do\n dp.(i + 1) <- if dp.(i) < as_.(i) then dp.(i) else bs.(i) + 1\n done;\n let dp' = Array.make (h + 1) w in\n for i = h - 1 downto 0 do\n dp'.(i) <- if bs.(i) < dp.(i + 1) then dp.(i + 1) else as_.(i) - 1\n done;\n for i = 1 to h do\n Printf.printf \"%d\\n\" @@\n if w < dp.(i)\n then -1\n else i + min (dp.(i) - 1) (dp'.(i) - dp'.(0))\n done\n", "problem_context": "Score : 600 points\n\nProblem Statement\n\nThere is a grid of squares with H+1 horizontal rows and W vertical columns.\n\nYou will start at one of the squares in the top row and repeat moving one square right or down. However, for each integer i from 1 through H, you cannot move down from the A_i-th, (A_i + 1)-th, \\ldots, B_i-th squares from the left in the i-th row from the top.\n\nFor each integer k from 1 through H, find the minimum number of moves needed to reach one of the squares in the (k+1)-th row from the top. (The starting square can be chosen individually for each case.) If, starting from any square in the top row, none of the squares in the (k+1)-th row can be reached, print -1 instead.\n\nConstraints\n\n1 \\leq H,W \\leq 2\\times 10^5\n\n1 \\leq A_i \\leq B_i \\leq W\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\nA_1 B_1\nA_2 B_2\n:\nA_H B_H\n\nOutput\n\nPrint H lines. The i-th line should contain the answer for the case k=i.\n\nSample Input 1\n\n4 4\n2 4\n1 1\n2 3\n2 4\n\nSample Output 1\n\n1\n3\n6\n-1\n\nLet (i,j) denote the square at the i-th row from the top and j-th column from the left.\n\nFor k=1, we need one move such as (1,1) → (2,1).\n\nFor k=2, we need three moves such as (1,1) → (2,1) → (2,2) → (3,2).\n\nFor k=3, we need six moves such as (1,1) → (2,1) → (2,2) → (3,2) → (3,3) → (3,4) → (4,4).\n\nFor k=4, it is impossible to reach any square in the fifth row from the top.", "sample_input": "4 4\n2 4\n1 1\n2 3\n2 4\n"}, "reference_outputs": ["1\n3\n6\n-1\n"], "source_document_id": "p02575", "source_text": "Score : 600 points\n\nProblem Statement\n\nThere is a grid of squares with H+1 horizontal rows and W vertical columns.\n\nYou will start at one of the squares in the top row and repeat moving one square right or down. However, for each integer i from 1 through H, you cannot move down from the A_i-th, (A_i + 1)-th, \\ldots, B_i-th squares from the left in the i-th row from the top.\n\nFor each integer k from 1 through H, find the minimum number of moves needed to reach one of the squares in the (k+1)-th row from the top. (The starting square can be chosen individually for each case.) If, starting from any square in the top row, none of the squares in the (k+1)-th row can be reached, print -1 instead.\n\nConstraints\n\n1 \\leq H,W \\leq 2\\times 10^5\n\n1 \\leq A_i \\leq B_i \\leq W\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\nA_1 B_1\nA_2 B_2\n:\nA_H B_H\n\nOutput\n\nPrint H lines. The i-th line should contain the answer for the case k=i.\n\nSample Input 1\n\n4 4\n2 4\n1 1\n2 3\n2 4\n\nSample Output 1\n\n1\n3\n6\n-1\n\nLet (i,j) denote the square at the i-th row from the top and j-th column from the left.\n\nFor k=1, we need one move such as (1,1) → (2,1).\n\nFor k=2, we need three moves such as (1,1) → (2,1) → (2,2) → (3,2).\n\nFor k=3, we need six moves such as (1,1) → (2,1) → (2,2) → (3,2) → (3,3) → (3,4) → (4,4).\n\nFor k=4, it is impossible to reach any square in the fifth row from the top.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 625, "cpu_time_ms": 113, "memory_kb": 12332}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s795620076", "group_id": "codeNet:p02576", "input_text": "let () =\n Scanf.scanf \"%d %d %d\\n\" @@ fun n x t ->\n Printf.printf \"%d\\n\" (if n mod x = 0 then t * (n / x) else t * (n / x + 1))", "language": "OCaml", "metadata": {"date": 1598123054, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p02576.html", "problem_id": "p02576", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02576/input.txt", "sample_output_relpath": "derived/input_output/data/p02576/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02576/OCaml/s795620076.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s795620076", "user_id": "u307426615"}, "prompt_components": {"gold_output": "12\n", "input_to_evaluate": "let () =\n Scanf.scanf \"%d %d %d\\n\" @@ fun n x t ->\n Printf.printf \"%d\\n\" (if n mod x = 0 then t * (n / x) else t * (n / x + 1))", "problem_context": "Score : 100 points\n\nProblem Statement\n\nTakahashi loves takoyaki - a ball-shaped snack.\n\nWith a takoyaki machine, he can make at most X pieces of takoyaki at a time, taking T minutes regardless of the number of pieces to make.\n\nHow long does it take to make N takoyaki?\n\nConstraints\n\n1 \\leq N,X,T \\leq 1000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN X T\n\nOutput\n\nPrint an integer representing the minimum number of minutes needed to make N pieces of takoyaki.\n\nSample Input 1\n\n20 12 6\n\nSample Output 1\n\n12\n\nHe can make 12 pieces of takoyaki in the first 6 minutes and 8 more in the next 6 minutes, so he can make 20 in a total of 12 minutes.\n\nNote that being able to make 12 in 6 minutes does not mean he can make 2 in 1 minute.\n\nSample Input 2\n\n1000 1 1000\n\nSample Output 2\n\n1000000\n\nIt seems to take a long time to make this kind of takoyaki.", "sample_input": "20 12 6\n"}, "reference_outputs": ["12\n"], "source_document_id": "p02576", "source_text": "Score : 100 points\n\nProblem Statement\n\nTakahashi loves takoyaki - a ball-shaped snack.\n\nWith a takoyaki machine, he can make at most X pieces of takoyaki at a time, taking T minutes regardless of the number of pieces to make.\n\nHow long does it take to make N takoyaki?\n\nConstraints\n\n1 \\leq N,X,T \\leq 1000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN X T\n\nOutput\n\nPrint an integer representing the minimum number of minutes needed to make N pieces of takoyaki.\n\nSample Input 1\n\n20 12 6\n\nSample Output 1\n\n12\n\nHe can make 12 pieces of takoyaki in the first 6 minutes and 8 more in the next 6 minutes, so he can make 20 in a total of 12 minutes.\n\nNote that being able to make 12 in 6 minutes does not mean he can make 2 in 1 minute.\n\nSample Input 2\n\n1000 1 1000\n\nSample Output 2\n\n1000000\n\nIt seems to take a long time to make this kind of takoyaki.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 3792}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s005334246", "group_id": "codeNet:p02577", "input_text": "let () =\n let rec solve n ans =\n if n / 10 = 0 then ans+n else solve (n / 10) (ans + (n mod 10)) in\n Scanf.scanf \"%d\\n\" @@ fun n ->\n Printf.printf \"%s\\n\" (if (solve n 0) mod 9 = 0 then \"Yes\" else \"No\")", "language": "OCaml", "metadata": {"date": 1598124083, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p02577.html", "problem_id": "p02577", "resource_group": "low_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/OCaml/s005334246.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s005334246", "user_id": "u307426615"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "let () =\n let rec solve n ans =\n if n / 10 = 0 then ans+n else solve (n / 10) (ans + (n mod 10)) in\n Scanf.scanf \"%d\\n\" @@ fun n ->\n Printf.printf \"%s\\n\" (if (solve n 0) mod 9 = 0 then \"Yes\" else \"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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 13, "memory_kb": 4532}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s906717818", "group_id": "codeNet:p02578", "input_text": "open Printf\nopen Scanf\n\nlet solve n =\n let aa = Array.init n @@ fun _ -> scanf \"%d \" @@ fun x -> x in\n let f (tc, mh) a = if mh <= a then (tc, a) else (tc + mh - a, mh) in\n fst @@ Array.fold_left f (0, 0) aa\n\nlet () =\n scanf \"%d \" solve |> printf \"%d\\n\"\n", "language": "OCaml", "metadata": {"date": 1598441742, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p02578.html", "problem_id": "p02578", "resource_group": "low_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/OCaml/s906717818.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s906717818", "user_id": "u388783188"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "open Printf\nopen Scanf\n\nlet solve n =\n let aa = Array.init n @@ fun _ -> scanf \"%d \" @@ fun x -> x in\n let f (tc, mh) a = if mh <= a then (tc, a) else (tc + mh - a, mh) in\n fst @@ Array.fold_left f (0, 0) aa\n\nlet () =\n scanf \"%d \" solve |> printf \"%d\\n\"\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nN persons are standing in a row. The height of the i-th person from the front is A_i.\n\nWe want to have each person stand on a stool of some heights - at least zero - so that the following condition is satisfied for every person:\n\nCondition: Nobody in front of the person is taller than the person. Here, the height of a person includes the stool.\n\nFind the minimum total height of the stools needed to meet this goal.\n\nConstraints\n\n1 \\leq N \\leq 2\\times 10^5\n\n1 \\leq A_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 \\ldots A_N\n\nOutput\n\nPrint the minimum total height of the stools needed to meet the goal.\n\nSample Input 1\n\n5\n2 1 5 4 3\n\nSample Output 1\n\n4\n\nIf the persons stand on stools of heights 0, 1, 0, 1, and 2, respectively, their heights will be 2, 2, 5, 5, and 5, satisfying the condition.\n\nWe cannot meet the goal with a smaller total height of the stools.\n\nSample Input 2\n\n5\n3 3 3 3 3\n\nSample Output 2\n\n0\n\nGiving a stool of height 0 to everyone will work.", "sample_input": "5\n2 1 5 4 3\n"}, "reference_outputs": ["4\n"], "source_document_id": "p02578", "source_text": "Score : 300 points\n\nProblem Statement\n\nN persons are standing in a row. The height of the i-th person from the front is A_i.\n\nWe want to have each person stand on a stool of some heights - at least zero - so that the following condition is satisfied for every person:\n\nCondition: Nobody in front of the person is taller than the person. Here, the height of a person includes the stool.\n\nFind the minimum total height of the stools needed to meet this goal.\n\nConstraints\n\n1 \\leq N \\leq 2\\times 10^5\n\n1 \\leq A_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 \\ldots A_N\n\nOutput\n\nPrint the minimum total height of the stools needed to meet the goal.\n\nSample Input 1\n\n5\n2 1 5 4 3\n\nSample Output 1\n\n4\n\nIf the persons stand on stools of heights 0, 1, 0, 1, and 2, respectively, their heights will be 2, 2, 5, 5, and 5, satisfying the condition.\n\nWe cannot meet the goal with a smaller total height of the stools.\n\nSample Input 2\n\n5\n3 3 3 3 3\n\nSample Output 2\n\n0\n\nGiving a stool of height 0 to everyone will work.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 57, "memory_kb": 7540}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s806125366", "group_id": "codeNet:p02578", "input_text": "let readNInt () =\n let temp = read_line () in\n let digits = String.split_on_char ' ' temp in\n List.map int_of_string digits\n\n\nlet rec findDifSum acc l =\n match l with\n [] -> acc\n | a :: [] -> acc\n | a :: b :: rest ->\n if a > b\n then (findDifSum (a - b + acc) rest)\n else (findDifSum acc rest)\n \nlet main () =\n let _ = read_int () in\n let l = readNInt () in\n let sum = findDifSum 0 (List.rev l) in\n (\n print_int sum;\n print_newline ()\n )\n\nlet _ = main ()\n", "language": "OCaml", "metadata": {"date": 1598128323, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p02578.html", "problem_id": "p02578", "resource_group": "low_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/OCaml/s806125366.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s806125366", "user_id": "u589100520"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "let readNInt () =\n let temp = read_line () in\n let digits = String.split_on_char ' ' temp in\n List.map int_of_string digits\n\n\nlet rec findDifSum acc l =\n match l with\n [] -> acc\n | a :: [] -> acc\n | a :: b :: rest ->\n if a > b\n then (findDifSum (a - b + acc) rest)\n else (findDifSum acc rest)\n \nlet main () =\n let _ = read_int () in\n let l = readNInt () in\n let sum = findDifSum 0 (List.rev l) in\n (\n print_int sum;\n print_newline ()\n )\n\nlet _ = main ()\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nN persons are standing in a row. The height of the i-th person from the front is A_i.\n\nWe want to have each person stand on a stool of some heights - at least zero - so that the following condition is satisfied for every person:\n\nCondition: Nobody in front of the person is taller than the person. Here, the height of a person includes the stool.\n\nFind the minimum total height of the stools needed to meet this goal.\n\nConstraints\n\n1 \\leq N \\leq 2\\times 10^5\n\n1 \\leq A_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 \\ldots A_N\n\nOutput\n\nPrint the minimum total height of the stools needed to meet the goal.\n\nSample Input 1\n\n5\n2 1 5 4 3\n\nSample Output 1\n\n4\n\nIf the persons stand on stools of heights 0, 1, 0, 1, and 2, respectively, their heights will be 2, 2, 5, 5, and 5, satisfying the condition.\n\nWe cannot meet the goal with a smaller total height of the stools.\n\nSample Input 2\n\n5\n3 3 3 3 3\n\nSample Output 2\n\n0\n\nGiving a stool of height 0 to everyone will work.", "sample_input": "5\n2 1 5 4 3\n"}, "reference_outputs": ["4\n"], "source_document_id": "p02578", "source_text": "Score : 300 points\n\nProblem Statement\n\nN persons are standing in a row. The height of the i-th person from the front is A_i.\n\nWe want to have each person stand on a stool of some heights - at least zero - so that the following condition is satisfied for every person:\n\nCondition: Nobody in front of the person is taller than the person. Here, the height of a person includes the stool.\n\nFind the minimum total height of the stools needed to meet this goal.\n\nConstraints\n\n1 \\leq N \\leq 2\\times 10^5\n\n1 \\leq A_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 \\ldots A_N\n\nOutput\n\nPrint the minimum total height of the stools needed to meet the goal.\n\nSample Input 1\n\n5\n2 1 5 4 3\n\nSample Output 1\n\n4\n\nIf the persons stand on stools of heights 0, 1, 0, 1, and 2, respectively, their heights will be 2, 2, 5, 5, and 5, satisfying the condition.\n\nWe cannot meet the goal with a smaller total height of the stools.\n\nSample Input 2\n\n5\n3 3 3 3 3\n\nSample Output 2\n\n0\n\nGiving a stool of height 0 to everyone will work.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 487, "cpu_time_ms": 65, "memory_kb": 28496}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s263513409", "group_id": "codeNet:p02578", "input_text": "Scanf.scanf \"%d\" (fun n ->\n let a = Array.init n (fun _ -> Scanf.scanf \" %d\" (fun a -> a)) in\n\n let rec loop i prev acc =\n if i = n then acc else\n if a.(i) >= prev then loop (i + 1) a.(i) acc else\n let d = prev - a.(i) in\n loop (i + 1) prev (acc + d)\n in\n loop 0 0 0 |> Printf.printf \"%d\\n\"\n)", "language": "OCaml", "metadata": {"date": 1598123185, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p02578.html", "problem_id": "p02578", "resource_group": "low_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/OCaml/s263513409.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s263513409", "user_id": "u342443598"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "Scanf.scanf \"%d\" (fun n ->\n let a = Array.init n (fun _ -> Scanf.scanf \" %d\" (fun a -> a)) in\n\n let rec loop i prev acc =\n if i = n then acc else\n if a.(i) >= prev then loop (i + 1) a.(i) acc else\n let d = prev - a.(i) in\n loop (i + 1) prev (acc + d)\n in\n loop 0 0 0 |> Printf.printf \"%d\\n\"\n)", "problem_context": "Score : 300 points\n\nProblem Statement\n\nN persons are standing in a row. The height of the i-th person from the front is A_i.\n\nWe want to have each person stand on a stool of some heights - at least zero - so that the following condition is satisfied for every person:\n\nCondition: Nobody in front of the person is taller than the person. Here, the height of a person includes the stool.\n\nFind the minimum total height of the stools needed to meet this goal.\n\nConstraints\n\n1 \\leq N \\leq 2\\times 10^5\n\n1 \\leq A_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 \\ldots A_N\n\nOutput\n\nPrint the minimum total height of the stools needed to meet the goal.\n\nSample Input 1\n\n5\n2 1 5 4 3\n\nSample Output 1\n\n4\n\nIf the persons stand on stools of heights 0, 1, 0, 1, and 2, respectively, their heights will be 2, 2, 5, 5, and 5, satisfying the condition.\n\nWe cannot meet the goal with a smaller total height of the stools.\n\nSample Input 2\n\n5\n3 3 3 3 3\n\nSample Output 2\n\n0\n\nGiving a stool of height 0 to everyone will work.", "sample_input": "5\n2 1 5 4 3\n"}, "reference_outputs": ["4\n"], "source_document_id": "p02578", "source_text": "Score : 300 points\n\nProblem Statement\n\nN persons are standing in a row. The height of the i-th person from the front is A_i.\n\nWe want to have each person stand on a stool of some heights - at least zero - so that the following condition is satisfied for every person:\n\nCondition: Nobody in front of the person is taller than the person. Here, the height of a person includes the stool.\n\nFind the minimum total height of the stools needed to meet this goal.\n\nConstraints\n\n1 \\leq N \\leq 2\\times 10^5\n\n1 \\leq A_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 \\ldots A_N\n\nOutput\n\nPrint the minimum total height of the stools needed to meet the goal.\n\nSample Input 1\n\n5\n2 1 5 4 3\n\nSample Output 1\n\n4\n\nIf the persons stand on stools of heights 0, 1, 0, 1, and 2, respectively, their heights will be 2, 2, 5, 5, and 5, satisfying the condition.\n\nWe cannot meet the goal with a smaller total height of the stools.\n\nSample Input 2\n\n5\n3 3 3 3 3\n\nSample Output 2\n\n0\n\nGiving a stool of height 0 to everyone will work.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 54, "memory_kb": 7552}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s707578646", "group_id": "codeNet:p02581", "input_text": "Scanf.scanf \"%d\" (fun n ->\n let n3 = 3 * n in\n let a = Array.init n3 (fun _ -> Scanf.scanf \" %d\" (fun a -> a - 1)) in\n let m = 100000 in\n let make_key a b = if a < b then a * m + b else b * m + a in\n let module M = Map.Make (struct type t = int let compare = compare end) in\n\n let add a b c d e v newmap =\n let key = make_key a b in\n let v = if c = d && d = e then v + 1 else v in\n M.add key (max v (try M.find key newmap with _ -> 0)) newmap\n in\n\n let rec loop i map =\n if i = n3 - 1 then map else\n let k3 = a.(i) in\n let k4 = a.(i + 1) in\n let k5 = a.(i + 2) in\n let newmap = M.fold (fun key v newmap ->\n let k1 = key / m in\n let k2 = key mod m in\n let newmap = add k1 k2 k3 k4 k5 v newmap in\n let newmap = add k1 k3 k2 k4 k5 v newmap in\n let newmap = add k1 k4 k2 k3 k5 v newmap in\n let newmap = add k1 k5 k2 k3 k4 v newmap in\n let newmap = add k2 k3 k1 k4 k5 v newmap in\n let newmap = add k2 k4 k1 k3 k5 v newmap in\n let newmap = add k2 k5 k1 k3 k4 v newmap in\n let newmap = add k3 k4 k1 k2 k5 v newmap in\n let newmap = add k3 k5 k1 k2 k4 v newmap in\n let newmap = add k4 k5 k1 k2 k5 v newmap in\n newmap\n ) map M.empty in\n loop (i + 3) newmap\n in\n let map = loop 2 (M.singleton (make_key a.(0) a.(1)) 0) in\n M.fold (fun key v acc ->\n let k1 = key / m in\n let k2 = key mod m in\n let v = if k1 = k2 && k2 = a.(n3 - 1) then v + 1 else v in\n max acc v\n ) map 0 |> Printf.printf \"%d\\n\"\n)", "language": "OCaml", "metadata": {"date": 1598132581, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p02581.html", "problem_id": "p02581", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02581/input.txt", "sample_output_relpath": "derived/input_output/data/p02581/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02581/OCaml/s707578646.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s707578646", "user_id": "u342443598"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "Scanf.scanf \"%d\" (fun n ->\n let n3 = 3 * n in\n let a = Array.init n3 (fun _ -> Scanf.scanf \" %d\" (fun a -> a - 1)) in\n let m = 100000 in\n let make_key a b = if a < b then a * m + b else b * m + a in\n let module M = Map.Make (struct type t = int let compare = compare end) in\n\n let add a b c d e v newmap =\n let key = make_key a b in\n let v = if c = d && d = e then v + 1 else v in\n M.add key (max v (try M.find key newmap with _ -> 0)) newmap\n in\n\n let rec loop i map =\n if i = n3 - 1 then map else\n let k3 = a.(i) in\n let k4 = a.(i + 1) in\n let k5 = a.(i + 2) in\n let newmap = M.fold (fun key v newmap ->\n let k1 = key / m in\n let k2 = key mod m in\n let newmap = add k1 k2 k3 k4 k5 v newmap in\n let newmap = add k1 k3 k2 k4 k5 v newmap in\n let newmap = add k1 k4 k2 k3 k5 v newmap in\n let newmap = add k1 k5 k2 k3 k4 v newmap in\n let newmap = add k2 k3 k1 k4 k5 v newmap in\n let newmap = add k2 k4 k1 k3 k5 v newmap in\n let newmap = add k2 k5 k1 k3 k4 v newmap in\n let newmap = add k3 k4 k1 k2 k5 v newmap in\n let newmap = add k3 k5 k1 k2 k4 v newmap in\n let newmap = add k4 k5 k1 k2 k5 v newmap in\n newmap\n ) map M.empty in\n loop (i + 3) newmap\n in\n let map = loop 2 (M.singleton (make_key a.(0) a.(1)) 0) in\n M.fold (fun key v acc ->\n let k1 = key / m in\n let k2 = key mod m in\n let v = if k1 = k2 && k2 = a.(n3 - 1) then v + 1 else v in\n max acc v\n ) map 0 |> Printf.printf \"%d\\n\"\n)", "problem_context": "Score : 600 points\n\nProblem Statement\n\nWe have 3N cards arranged in a row from left to right, where each card has an integer between 1 and N (inclusive) written on it. The integer written on the i-th card from the left is A_i.\n\nYou will do the following operation N-1 times:\n\nRearrange the five leftmost cards in any order you like, then remove the three leftmost cards. If the integers written on those three cards are all equal, you gain 1 point.\n\nAfter these N-1 operations, if the integers written on the remaining three cards are all equal, you will gain 1 additional point.\n\nFind the maximum number of points you can gain.\n\nConstraints\n\n1 \\leq N \\leq 2000\n\n1 \\leq A_i \\leq N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 \\cdots A_{3N}\n\nOutput\n\nPrint the maximum number of points you can gain.\n\nSample Input 1\n\n2\n1 2 1 2 2 1\n\nSample Output 1\n\n2\n\nLet us rearrange the five leftmost cards so that the integers written on the six cards will be 2\\ 2\\ 2\\ 1\\ 1\\ 1 from left to right.\n\nThen, remove the three leftmost cards, all of which have the same integer 2, gaining 1 point.\n\nNow, the integers written on the remaining cards are 1\\ 1\\ 1.\n\nSince these three cards have the same integer 1, we gain 1 more point.\n\nIn this way, we can gain 2 points - which is the maximum possible.\n\nSample Input 2\n\n3\n1 1 2 2 3 3 3 2 1\n\nSample Output 2\n\n1\n\nSample Input 3\n\n3\n1 1 2 2 2 3 3 3 1\n\nSample Output 3\n\n3", "sample_input": "2\n1 2 1 2 2 1\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02581", "source_text": "Score : 600 points\n\nProblem Statement\n\nWe have 3N cards arranged in a row from left to right, where each card has an integer between 1 and N (inclusive) written on it. The integer written on the i-th card from the left is A_i.\n\nYou will do the following operation N-1 times:\n\nRearrange the five leftmost cards in any order you like, then remove the three leftmost cards. If the integers written on those three cards are all equal, you gain 1 point.\n\nAfter these N-1 operations, if the integers written on the remaining three cards are all equal, you will gain 1 additional point.\n\nFind the maximum number of points you can gain.\n\nConstraints\n\n1 \\leq N \\leq 2000\n\n1 \\leq A_i \\leq N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 \\cdots A_{3N}\n\nOutput\n\nPrint the maximum number of points you can gain.\n\nSample Input 1\n\n2\n1 2 1 2 2 1\n\nSample Output 1\n\n2\n\nLet us rearrange the five leftmost cards so that the integers written on the six cards will be 2\\ 2\\ 2\\ 1\\ 1\\ 1 from left to right.\n\nThen, remove the three leftmost cards, all of which have the same integer 2, gaining 1 point.\n\nNow, the integers written on the remaining cards are 1\\ 1\\ 1.\n\nSince these three cards have the same integer 1, we gain 1 more point.\n\nIn this way, we can gain 2 points - which is the maximum possible.\n\nSample Input 2\n\n3\n1 1 2 2 3 3 3 2 1\n\nSample Output 2\n\n1\n\nSample Input 3\n\n3\n1 1 2 2 2 3 3 3 1\n\nSample Output 3\n\n3", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 2206, "memory_kb": 9524}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s212239193", "group_id": "codeNet:p02582", "input_text": "let () =\n Scanf.scanf \"%1s%1s%1s\\n\" @@ fun s1 s2 s3 ->\n Printf.printf \"%d\\n\"\n (if s1 = \"S\" && s2 = \"S\" && s3 = \"S\" then 0 \n else if s1 = \"R\" && s2 = \"R\" && s3 = \"R\" then 3\n else if (s1 = \"R\" && s2 = \"R\") || (s2 = \"R\" && s3 = \"R\") then 2 else 1)", "language": "OCaml", "metadata": {"date": 1597833196, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p02582.html", "problem_id": "p02582", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02582/input.txt", "sample_output_relpath": "derived/input_output/data/p02582/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02582/OCaml/s212239193.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s212239193", "user_id": "u307426615"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "let () =\n Scanf.scanf \"%1s%1s%1s\\n\" @@ fun s1 s2 s3 ->\n Printf.printf \"%d\\n\"\n (if s1 = \"S\" && s2 = \"S\" && s3 = \"S\" then 0 \n else if s1 = \"R\" && s2 = \"R\" && s3 = \"R\" then 3\n else if (s1 = \"R\" && s2 = \"R\") || (s2 = \"R\" && s3 = \"R\") then 2 else 1)", "problem_context": "Score : 100 points\n\nProblem Statement\n\nWe have weather records at AtCoder Town for some consecutive three days. A string of length 3, S, represents the records - if the i-th character is S, it means it was sunny on the i-th day; if that character is R, it means it was rainy on that day.\n\nFind the maximum number of consecutive rainy days in this period.\n\nConstraints\n\n|S| = 3\n\nEach character of S is S or R.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the maximum number of consecutive rainy days in the period.\n\nSample Input 1\n\nRRS\n\nSample Output 1\n\n2\n\nWe had rain on the 1-st and 2-nd days in the period. Here, the maximum number of consecutive rainy days is 2, so we should print 2.\n\nSample Input 2\n\nSSS\n\nSample Output 2\n\n0\n\nIt was sunny throughout the period. We had no rainy days, so we should print 0.\n\nSample Input 3\n\nRSR\n\nSample Output 3\n\n1\n\nWe had rain on the 1-st and 3-rd days - two \"streaks\" of one rainy day, so we should print 1.", "sample_input": "RRS\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02582", "source_text": "Score : 100 points\n\nProblem Statement\n\nWe have weather records at AtCoder Town for some consecutive three days. A string of length 3, S, represents the records - if the i-th character is S, it means it was sunny on the i-th day; if that character is R, it means it was rainy on that day.\n\nFind the maximum number of consecutive rainy days in this period.\n\nConstraints\n\n|S| = 3\n\nEach character of S is S or R.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the maximum number of consecutive rainy days in the period.\n\nSample Input 1\n\nRRS\n\nSample Output 1\n\n2\n\nWe had rain on the 1-st and 2-nd days in the period. Here, the maximum number of consecutive rainy days is 2, so we should print 2.\n\nSample Input 2\n\nSSS\n\nSample Output 2\n\n0\n\nIt was sunny throughout the period. We had no rainy days, so we should print 0.\n\nSample Input 3\n\nRSR\n\nSample Output 3\n\n1\n\nWe had rain on the 1-st and 3-rd days - two \"streaks\" of one rainy day, so we should print 1.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 11, "memory_kb": 3812}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s301688854", "group_id": "codeNet:p02582", "input_text": "(*\nocamlfind ocamlopt -package batteries -linkpkg main.ml -o a.out\n*)\nopen Batteries\n\nlet ans = \n Str.split (Str.regexp \"S\") (read_line ())\n |> List.map (fun str -> String.length str)\n |> List.max\n\nlet () = Printf.printf \"%d\" ans\n", "language": "OCaml", "metadata": {"date": 1597518723, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p02582.html", "problem_id": "p02582", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02582/input.txt", "sample_output_relpath": "derived/input_output/data/p02582/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02582/OCaml/s301688854.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s301688854", "user_id": "u280335093"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "(*\nocamlfind ocamlopt -package batteries -linkpkg main.ml -o a.out\n*)\nopen Batteries\n\nlet ans = \n Str.split (Str.regexp \"S\") (read_line ())\n |> List.map (fun str -> String.length str)\n |> List.max\n\nlet () = Printf.printf \"%d\" ans\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nWe have weather records at AtCoder Town for some consecutive three days. A string of length 3, S, represents the records - if the i-th character is S, it means it was sunny on the i-th day; if that character is R, it means it was rainy on that day.\n\nFind the maximum number of consecutive rainy days in this period.\n\nConstraints\n\n|S| = 3\n\nEach character of S is S or R.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the maximum number of consecutive rainy days in the period.\n\nSample Input 1\n\nRRS\n\nSample Output 1\n\n2\n\nWe had rain on the 1-st and 2-nd days in the period. Here, the maximum number of consecutive rainy days is 2, so we should print 2.\n\nSample Input 2\n\nSSS\n\nSample Output 2\n\n0\n\nIt was sunny throughout the period. We had no rainy days, so we should print 0.\n\nSample Input 3\n\nRSR\n\nSample Output 3\n\n1\n\nWe had rain on the 1-st and 3-rd days - two \"streaks\" of one rainy day, so we should print 1.", "sample_input": "RRS\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02582", "source_text": "Score : 100 points\n\nProblem Statement\n\nWe have weather records at AtCoder Town for some consecutive three days. A string of length 3, S, represents the records - if the i-th character is S, it means it was sunny on the i-th day; if that character is R, it means it was rainy on that day.\n\nFind the maximum number of consecutive rainy days in this period.\n\nConstraints\n\n|S| = 3\n\nEach character of S is S or R.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the maximum number of consecutive rainy days in the period.\n\nSample Input 1\n\nRRS\n\nSample Output 1\n\n2\n\nWe had rain on the 1-st and 2-nd days in the period. Here, the maximum number of consecutive rainy days is 2, so we should print 2.\n\nSample Input 2\n\nSSS\n\nSample Output 2\n\n0\n\nIt was sunny throughout the period. We had no rainy days, so we should print 0.\n\nSample Input 3\n\nRSR\n\nSample Output 3\n\n1\n\nWe had rain on the 1-st and 3-rd days - two \"streaks\" of one rainy day, so we should print 1.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 5252}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s365627249", "group_id": "codeNet:p02583", "input_text": "let () =\n Scanf.scanf \"%d\\n\" @@ fun n ->\n let arr = Array.init n @@ fun _ -> Scanf.scanf \"%d \" @@ fun d -> d in\n let _ = Array.fast_sort compare arr in\n let ans = ref 0 in\n for i = 0 to Array.length arr - 1 do\n for j = i + 1 to Array.length arr - 1 do\n for k = j + 1 to Array.length arr - 1 do\n if arr.(i) + arr.(j) > arr.(k) then ans := !ans + 1\n done;\n done;\n done;\n Printf.printf \"%d\\n\" !ans", "language": "OCaml", "metadata": {"date": 1597833841, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p02583.html", "problem_id": "p02583", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02583/input.txt", "sample_output_relpath": "derived/input_output/data/p02583/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02583/OCaml/s365627249.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s365627249", "user_id": "u307426615"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "let () =\n Scanf.scanf \"%d\\n\" @@ fun n ->\n let arr = Array.init n @@ fun _ -> Scanf.scanf \"%d \" @@ fun d -> d in\n let _ = Array.fast_sort compare arr in\n let ans = ref 0 in\n for i = 0 to Array.length arr - 1 do\n for j = i + 1 to Array.length arr - 1 do\n for k = j + 1 to Array.length arr - 1 do\n if arr.(i) + arr.(j) > arr.(k) then ans := !ans + 1\n done;\n done;\n done;\n Printf.printf \"%d\\n\" !ans", "problem_context": "Score : 200 points\n\nProblem Statement\n\nWe have sticks numbered 1, \\cdots, N. The length of Stick i (1 \\leq i \\leq N) is L_i.\n\nIn how many ways can we choose three of the sticks with different lengths that can form a triangle?\n\nThat is, find the number of triples of integers (i, j, k) (1 \\leq i < j < k \\leq N) that satisfy both of the following conditions:\n\nL_i, L_j, and L_k are all different.\n\nThere exists a triangle whose sides have lengths L_i, L_j, and L_k.\n\nConstraints\n\n1 \\leq N \\leq 100\n\n1 \\leq L_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nL_1 L_2 \\cdots L_N\n\nOutput\n\nPrint the number of ways to choose three of the sticks with different lengths that can form a triangle.\n\nSample Input 1\n\n5\n4 4 9 7 5\n\nSample Output 1\n\n5\n\nThe following five triples (i, j, k) satisfy the conditions: (1, 3, 4), (1, 4, 5), (2, 3, 4), (2, 4, 5), and (3, 4, 5).\n\nSample Input 2\n\n6\n4 5 4 3 3 5\n\nSample Output 2\n\n8\n\nWe have two sticks for each of the lengths 3, 4, and 5. To satisfy the first condition, we have to choose one from each length.\n\nThere is a triangle whose sides have lengths 3, 4, and 5, so we have 2 ^ 3 = 8 triples (i, j, k) that satisfy the conditions.\n\nSample Input 3\n\n10\n9 4 6 1 9 6 10 6 6 8\n\nSample Output 3\n\n39\n\nSample Input 4\n\n2\n1 1\n\nSample Output 4\n\n0\n\nNo triple (i, j, k) satisfies 1 \\leq i < j < k \\leq N, so we should print 0.", "sample_input": "5\n4 4 9 7 5\n"}, "reference_outputs": ["5\n"], "source_document_id": "p02583", "source_text": "Score : 200 points\n\nProblem Statement\n\nWe have sticks numbered 1, \\cdots, N. The length of Stick i (1 \\leq i \\leq N) is L_i.\n\nIn how many ways can we choose three of the sticks with different lengths that can form a triangle?\n\nThat is, find the number of triples of integers (i, j, k) (1 \\leq i < j < k \\leq N) that satisfy both of the following conditions:\n\nL_i, L_j, and L_k are all different.\n\nThere exists a triangle whose sides have lengths L_i, L_j, and L_k.\n\nConstraints\n\n1 \\leq N \\leq 100\n\n1 \\leq L_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nL_1 L_2 \\cdots L_N\n\nOutput\n\nPrint the number of ways to choose three of the sticks with different lengths that can form a triangle.\n\nSample Input 1\n\n5\n4 4 9 7 5\n\nSample Output 1\n\n5\n\nThe following five triples (i, j, k) satisfy the conditions: (1, 3, 4), (1, 4, 5), (2, 3, 4), (2, 4, 5), and (3, 4, 5).\n\nSample Input 2\n\n6\n4 5 4 3 3 5\n\nSample Output 2\n\n8\n\nWe have two sticks for each of the lengths 3, 4, and 5. To satisfy the first condition, we have to choose one from each length.\n\nThere is a triangle whose sides have lengths 3, 4, and 5, so we have 2 ^ 3 = 8 triples (i, j, k) that satisfy the conditions.\n\nSample Input 3\n\n10\n9 4 6 1 9 6 10 6 6 8\n\nSample Output 3\n\n39\n\nSample Input 4\n\n2\n1 1\n\nSample Output 4\n\n0\n\nNo triple (i, j, k) satisfies 1 \\leq i < j < k \\leq N, so we should print 0.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 5, "memory_kb": 3840}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s398323662", "group_id": "codeNet:p02584", "input_text": "open Batteries\nopen Printf\n\nlet ($) g f x = g (f x)\n\nlet swap = Tuple2.swap\n\nlet s2i = int_of_string\nlet i2s = string_of_int\nlet s2f = float_of_string\nlet f2s = string_of_float\nlet c2i = int_of_char\nlet i2c = char_of_int\nlet f2i = int_of_float\nlet i2f = float_of_int \n\nlet c2s = String.of_char\nlet s2cl = String.to_list\nlet cl2s = String.of_list\n\nlet puts s = print_endline s\nlet putw ?yn:(yn=(\"Yes\", \"No\")) b = puts (if b then fst yn else snd yn)\nlet puti i = puts @@ i2s i\n\n\n\nmodule StaleList = struct\n include List\n\n let nmem x l = not @@ mem x l\n\n let len = length\n let size = length\n let nempty l = not @@ is_empty l\n\n let hdop l = if nempty l then Some (hd l) else None\n\n (* let taker = drop *)\n let takewh = take_while\n\n (* let dropr = take *)\n let dropwh = drop_while\n\n let split_by = span\n\n let chunk = ntake\n\n let foldl = fold_left\n let foldli = fold_lefti\n let foldr f z l = fold_right f l z\n let foldri f z l = fold_righti f l z\n\n let partition_to_map f l =\n foldr (fun x m -> Map.modify_opt (f x) (function\n | None -> Some [x] \n | Some [] -> Some [x] \n | Some vl -> Some (x::vl)) m) Map.empty l;;\n\n let scanl f z ls =\n let rec loop acl acc = function\n | [] -> rev acl\n | h::t ->\n let r = f acc h in\n loop (r::acl) r t\n in loop [] z ls\n\n let scanr f z ls =\n let rec loop acl acc = function\n | [] -> acl \n | h::t ->\n let r = f h acc in\n loop (r::acl) r t\n in loop [] z (rev ls)\n\n (* let scanli = scan_lefti *)\n (* let scanri = scan_righti *)\n \n let flatmap = concat_map\n\n let zipf = map2\n let zipfi = map2i\n\nend\n\nmodule L = StaleList\n\nmodule StaleArray = struct\n include Array \n\n let nmem x l = not @@ mem x l\n\n let len = length\n let size = length\n let is_empty r = len r = 0\n let nempty r = len r > 0\n\n let take n r = left r n\n let taker n r = right r n\n\n let takeb x r =\n let l = len r in\n let rec loop i =\n if i >= l then r\n else if r.(i) = x then take i r\n else loop (i + 1)\n in loop 0\n \n (* let takewh = take_while *)\n\n let drop n r = tail r n\n let dropr n r = take ((len r) - n) r\n (* let dropwh = drop_while *)\n\n let index_of x r =\n let l = len r in\n let rec loop i =\n if i >= l then None\n else if r.(i) = x then Some i\n else loop (i + 1)\n in loop 0\n\n (* let split_by = span *)\n\n (* let chunk = ntake *)\n\n let foldl = fold_left\n let foldli = fold_lefti\n let foldr f z l = fold_right f l z\n let foldri f z l = fold_righti f l z\n\n (* let partition_to_map f l = *)\n (* foldr (fun x m -> Map.modify_opt (f x) (function *)\n (* | None -> Some [x] *)\n (* | Some [] -> Some [x] *)\n (* | Some vl -> Some (x::vl)) m) Map.empty l;; *)\n\n (* let scanl = scan_left *)\n (* let scanli = scan_lefti *)\n (* let scanr = scan_right *)\n (* let scanri = scan_righti *)\n \n let concat2 = append\n \n let flatmap (f : 'a -> 'b array) a =\n map f a |> enum |> L.of_enum |> concat\n\n let zipf = map2\n (* let zipfi = map2i *)\n\nend\n\nmodule A = StaleArray\n\nmodule StaleString = struct\n include String\n\n let len = length\n\n let replace_chars = map\n let map = replace\n\n let maptol f s = L.map f (s2cl s)\n let maptoli f s = L.map f (s2cl s)\n\n let zipf f a b = L.zipf f (s2cl a) (s2cl b)\n let zipfi f a b = L.zipfi f (s2cl a) (s2cl b)\n\n let mkstr f sep ls =\n L.foldl (fun acc x -> acc ^ sep ^ (f x)) (f @@ L.hd ls) (List.tl ls)\n\nend\n\nmodule S = StaleString\n\nlet spsp s = S.split_on_char ' ' s\n\n\nmodule StaleSortedSet = struct\n include Set\n\n module Make (Ord : Set.OrderedType) = struct\n include Set.Make(Ord)\n\n let nmem x st = not @@ mem x st\n\n let foldl f s z = fold (fun x a -> f a x) z s\n\n let size = cardinal\n end\n\n let nmem x st = not @@ mem x st\n\n let foldl f s z = fold (fun x a -> f a x) z s\n\n let size = cardinal\nend\n\nmodule Ss = StaleSortedSet\n\nmodule StaleSortedMap = struct\n include Map\n\n module Make (Ord : Map.OrderedType) = struct\n include Map.Make(Ord)\n\n let nmem x st = not @@ mem x st\n\n let get = find\n let get_or x d m = find_default d x m\n\n let size = cardinal\n end\n\n let nmem x st = not @@ mem x st\n\n let get = find\n let get_or x d m = find_default d x m\n\n let size = cardinal\nend\n\nmodule Ms = StaleSortedMap\n\n\nmodule StaleRange = struct\n\n type t = Range of int * int\n\n let make lb ub = Range (lb, ub)\n\n let to_list r =\n let Range (lb, ub) = r in\n L.make (ub - lb) ((+) lb) \n\n let to_array r =\n let Range (lb, ub) = r in\n A.make (ub - lb) ((+) lb)\n\n let iter r f = \n let Range (lb, ub) = r in\n for i = lb to ub do f i done\n\n let iter2 r1 r2 f =\n let Range (lb1, ub1) = r1 and Range (lb2, ub2) = r2 in\n for i = lb1 to ub2 do\n for j = lb2 to ub2 do\n f i j\n done\n done\nend\n\nmodule R = StaleRange\n\nlet (---) lb ub = R.make lb ub\nlet (--^) lb ub = R.make lb (ub - 1)\n\nmodule StaleGenericAlgorithms = struct\n\n let set_power ls =\n let rec loop ls pls =\n match ls with\n | [] -> pls\n | hd::tl -> loop tl (L.flatmap (fun p -> [p; hd::p]) pls)\n in loop ls [[]]\n\n let rec bsearch_max_int f lb ub =\n if lb >= ub then (if f lb then lb else (lb - 1))\n else (\n let m = (lb + ub) / 2 in\n if f m then bsearch_max_int f (m + 1) ub\n else bsearch_max_int f lb m\n )\n\n let partial_sum n ls =\n let rec loop s k = function\n | [] -> s\n | h::t ->\n if k >= n then s\n else loop (s + h) (k + 1) t\n in\n loop 0 0 ls\n\nend\n\nmodule Gal = StaleGenericAlgorithms\n\n\nmodule StaleIntArithmetic = struct\n\n let rec power x e =\n if e = 0 then x\n else \n let rec loop r x2 e' =\n if e' = 0 then r\n else if e' land 1 = 0 then loop r (x2 * x2) (e' lsr 1)\n else loop (r * x2) (x2 * x2) (e' lsr 1)\n in loop 1 x e\n \n\n let rec powers_le_1000 x =\n if x > 32 then [x]\n else\n L.init 9 (fun e -> power x (e + 1))\n |> L.filter (fun y -> y < 1000)\n\n let primes_le_1000 = [2;3;5;7;11;13;17;19;23;29;31;37;41;\n 43;47;53;59;61;67;71;73;79;83;89;97;101;\n 103;107;109;113;127;131;137;139;149;151;157;163;167;\n 173;179;181;191;193;197;199;211;223;227;229;233;239;\n 241;251;257;263;269;271;277;281;283;293;307;311;313;\n 317;331;337;347;349;353;359;367;373;379;383;389;397;\n 401;409;419;421;431;433;439;443;449;457;461;463;467;\n 479;487;491;499;503;509;521;523;541;547;557;563;569;\n 571;577;587;593;599;601;607;613;617;619;631;641;643;\n 647;653;659;661;673;677;683;691;701;709;719;727;733;\n 739;743;751;757;761;769;773;787;797;809;811;821;823;\n 827;829;839;853;857;859;863;877;881;883;887;907;911;\n 919;929;937;941;947;953;967;971;977;983;991;997]\n\n let primes_and_powers_le_1000 =\n [2;3;4;5;7;8;9;11;13;16;17;19;23;25;27;29;31;32;37;41;\n 43;47;49;53;59;61;64;67;71;73;79;81;83;89;97;\n 101;103;107;109;113;121;125;127;128;131;137;139;149;151;\n 157;163;167;169;173;179;181;191;193;197;199;211;223;227;\n 229;233;239;241;243;251;256;257;263;269;271;277;281;283;\n 289;293;307;311;313;317;331;337;343;347;349;353;359;361;\n 367;373;379;383;389;397;401;409;419;421;431;433;439;443;\n 449;457;461;463;467;479;487;491;499;503;509;512;521;523;\n 529;541;547;557;563;569;571;577;587;593;599;601;607;613;\n 617;619;625;631;641;643;647;653;659;661;673;677;683;691;\n 701;709;719;727;729;733;739;743;751;757;761;769;773;787;\n 797;809;811;821;823;827;829;839;841;853;857;859;863;877;\n 881;883;887;907;911;919;929;937;941;947;953;961;967;971;\n 977;983;991;997]\n\n let factorize_with ps n =\n let rec loop acc ps e n' =\n if n' <= 1 then ([], n') \n else\n match ps with\n | [] -> (acc, n')\n | p::t ->\n let r = n' mod p in\n if r = 0 then (\n if n' = p then ((p, e + 1) :: acc, 1)\n else loop acc ps (e + 1) (n' / p)\n ) else\n loop (if e = 0 then acc else (p, e) :: acc) t 0 n'\n in\n let (fs, r) = loop [] ps 0 n in\n (L.rev fs, r)\n\n let factorize_le_million n =\n factorize_with primes_le_1000 n\n\n let rec to_bits_le n =\n if n = 0 then []\n else (n mod 2) :: to_bits_le (n lsr 1)\n\n let rec gcd x y =\n match x mod y with\n | 0 -> y\n | z -> gcd y z\n\n let ext_euclid a b =\n let rec next (r0, s0, t0) (r1, s1, t1) =\n match r1 with\n | 0 -> (r0, s0, t0)\n | r2 ->\n let q = r0 / r1 in\n next (r1, s1, t1) (r0 - q * r1, s0 - q * s1, t0 - q * t1)\n in\n if a < b then\n let (g, y, x) = next (b, 1, 0) (a, 0, 1) in (g, x, y)\n else\n next (a, 1, 0) (b, 0, 1)\n\n let modinv x m =\n let (g, y, z) = ext_euclid x m in\n match g with\n | 1 -> y mod m\n | _ -> invalid_arg \"Not relatively prime\"\n \n\nend\n\nmodule N = StaleIntArithmetic\n\n\n\nlet rds () = read_line ()\n\nlet rdi () = s2i @@ rds ()\n\nlet rdhs () = spsp @@ rds ()\nlet rdhi () = rdhs () |> L.map s2i\n\nlet rdhf () = rdhs () |> L.map s2f\n\nlet rdf2 () = match rdhf () with\n| a::b::_ -> (a, b)\n| _ -> (0., 0.)\n\nlet rdf3 () = match rdhf () with\n| a::b::c::_ -> (a, b, c)\n| _ -> (0., 0., 0.)\n\nlet rdf4 () = match rdhf () with\n| a::b::c::d::_ -> (a, b, c, d)\n| _ -> (0., 0., 0., 0.)\n\nlet rds2 () = match rdhs () with\n | a::b::_ -> (a, b)\n | _ -> (\"\", \"\")\n\nlet rdi2 () = match rdhi () with\n | a::b::_ -> (a, b)\n | _ -> (0, 0)\n\nlet rdi3 () = match rdhi () with\n| a::b::c::_ -> (a, b, c)\n| _ -> (0, 0, 0)\n\nlet rdi4 () = match rdhi () with\n| a::b::c::d::_ -> (a, b, c, d)\n| _ -> (0, 0, 0, 0)\n\nlet rdi5 () = match rdhi () with\n| a::b::c::d::e::_ -> (a, b, c, d, e)\n| _ -> (0, 0, 0, 0, 0)\n\nlet rdv n rf =\n let rec loop n =\n if n <= 0 then []\n else (\n let s = rf () in\n s::(loop (n - 1))\n )\n in loop n\n\nlet rdvi n = rdv n rdi\nlet rdvi2 n = rdv n rdi2\nlet rdvi3 n = rdv n rdi3\nlet rdvi4 n = rdv n rdi4\n\n\nlet print_list aa = \n printf \"[ \"; aa |> L.iter (fun a -> printf \"%d \" a); puts \"]\"\n\nlet print_array aa = \n printf \"[ \"; aa |> A.iter (fun a -> printf \"%d \" a); puts \"]\"\n\nlet print_carray aa = \n printf \"[ \"; aa |> A.iter (fun a -> printf \"%c \" a); puts \"]\"\n\nlet print_matrix mat =\n puts \"----\";\n mat |> A.iter (fun r -> print_carray r);\n puts \"----\"\n\nlet _ =\n let (x, k, d) = rdi3 () in\n let xa = abs x in\n let k1 = xa / d and m1 = xa mod d and m2 = d - xa mod d in\n let m =\n if k < k1 then \n abs (if x >= 0 then abs x - k * d else abs x + k * d)\n else if (k - k1) mod 2 = 0 then m1\n else m2\n in\n puti @@ abs m\n \n", "language": "OCaml", "metadata": {"date": 1597522978, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p02584.html", "problem_id": "p02584", "resource_group": "low_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/OCaml/s398323662.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s398323662", "user_id": "u970139668"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "open Batteries\nopen Printf\n\nlet ($) g f x = g (f x)\n\nlet swap = Tuple2.swap\n\nlet s2i = int_of_string\nlet i2s = string_of_int\nlet s2f = float_of_string\nlet f2s = string_of_float\nlet c2i = int_of_char\nlet i2c = char_of_int\nlet f2i = int_of_float\nlet i2f = float_of_int \n\nlet c2s = String.of_char\nlet s2cl = String.to_list\nlet cl2s = String.of_list\n\nlet puts s = print_endline s\nlet putw ?yn:(yn=(\"Yes\", \"No\")) b = puts (if b then fst yn else snd yn)\nlet puti i = puts @@ i2s i\n\n\n\nmodule StaleList = struct\n include List\n\n let nmem x l = not @@ mem x l\n\n let len = length\n let size = length\n let nempty l = not @@ is_empty l\n\n let hdop l = if nempty l then Some (hd l) else None\n\n (* let taker = drop *)\n let takewh = take_while\n\n (* let dropr = take *)\n let dropwh = drop_while\n\n let split_by = span\n\n let chunk = ntake\n\n let foldl = fold_left\n let foldli = fold_lefti\n let foldr f z l = fold_right f l z\n let foldri f z l = fold_righti f l z\n\n let partition_to_map f l =\n foldr (fun x m -> Map.modify_opt (f x) (function\n | None -> Some [x] \n | Some [] -> Some [x] \n | Some vl -> Some (x::vl)) m) Map.empty l;;\n\n let scanl f z ls =\n let rec loop acl acc = function\n | [] -> rev acl\n | h::t ->\n let r = f acc h in\n loop (r::acl) r t\n in loop [] z ls\n\n let scanr f z ls =\n let rec loop acl acc = function\n | [] -> acl \n | h::t ->\n let r = f h acc in\n loop (r::acl) r t\n in loop [] z (rev ls)\n\n (* let scanli = scan_lefti *)\n (* let scanri = scan_righti *)\n \n let flatmap = concat_map\n\n let zipf = map2\n let zipfi = map2i\n\nend\n\nmodule L = StaleList\n\nmodule StaleArray = struct\n include Array \n\n let nmem x l = not @@ mem x l\n\n let len = length\n let size = length\n let is_empty r = len r = 0\n let nempty r = len r > 0\n\n let take n r = left r n\n let taker n r = right r n\n\n let takeb x r =\n let l = len r in\n let rec loop i =\n if i >= l then r\n else if r.(i) = x then take i r\n else loop (i + 1)\n in loop 0\n \n (* let takewh = take_while *)\n\n let drop n r = tail r n\n let dropr n r = take ((len r) - n) r\n (* let dropwh = drop_while *)\n\n let index_of x r =\n let l = len r in\n let rec loop i =\n if i >= l then None\n else if r.(i) = x then Some i\n else loop (i + 1)\n in loop 0\n\n (* let split_by = span *)\n\n (* let chunk = ntake *)\n\n let foldl = fold_left\n let foldli = fold_lefti\n let foldr f z l = fold_right f l z\n let foldri f z l = fold_righti f l z\n\n (* let partition_to_map f l = *)\n (* foldr (fun x m -> Map.modify_opt (f x) (function *)\n (* | None -> Some [x] *)\n (* | Some [] -> Some [x] *)\n (* | Some vl -> Some (x::vl)) m) Map.empty l;; *)\n\n (* let scanl = scan_left *)\n (* let scanli = scan_lefti *)\n (* let scanr = scan_right *)\n (* let scanri = scan_righti *)\n \n let concat2 = append\n \n let flatmap (f : 'a -> 'b array) a =\n map f a |> enum |> L.of_enum |> concat\n\n let zipf = map2\n (* let zipfi = map2i *)\n\nend\n\nmodule A = StaleArray\n\nmodule StaleString = struct\n include String\n\n let len = length\n\n let replace_chars = map\n let map = replace\n\n let maptol f s = L.map f (s2cl s)\n let maptoli f s = L.map f (s2cl s)\n\n let zipf f a b = L.zipf f (s2cl a) (s2cl b)\n let zipfi f a b = L.zipfi f (s2cl a) (s2cl b)\n\n let mkstr f sep ls =\n L.foldl (fun acc x -> acc ^ sep ^ (f x)) (f @@ L.hd ls) (List.tl ls)\n\nend\n\nmodule S = StaleString\n\nlet spsp s = S.split_on_char ' ' s\n\n\nmodule StaleSortedSet = struct\n include Set\n\n module Make (Ord : Set.OrderedType) = struct\n include Set.Make(Ord)\n\n let nmem x st = not @@ mem x st\n\n let foldl f s z = fold (fun x a -> f a x) z s\n\n let size = cardinal\n end\n\n let nmem x st = not @@ mem x st\n\n let foldl f s z = fold (fun x a -> f a x) z s\n\n let size = cardinal\nend\n\nmodule Ss = StaleSortedSet\n\nmodule StaleSortedMap = struct\n include Map\n\n module Make (Ord : Map.OrderedType) = struct\n include Map.Make(Ord)\n\n let nmem x st = not @@ mem x st\n\n let get = find\n let get_or x d m = find_default d x m\n\n let size = cardinal\n end\n\n let nmem x st = not @@ mem x st\n\n let get = find\n let get_or x d m = find_default d x m\n\n let size = cardinal\nend\n\nmodule Ms = StaleSortedMap\n\n\nmodule StaleRange = struct\n\n type t = Range of int * int\n\n let make lb ub = Range (lb, ub)\n\n let to_list r =\n let Range (lb, ub) = r in\n L.make (ub - lb) ((+) lb) \n\n let to_array r =\n let Range (lb, ub) = r in\n A.make (ub - lb) ((+) lb)\n\n let iter r f = \n let Range (lb, ub) = r in\n for i = lb to ub do f i done\n\n let iter2 r1 r2 f =\n let Range (lb1, ub1) = r1 and Range (lb2, ub2) = r2 in\n for i = lb1 to ub2 do\n for j = lb2 to ub2 do\n f i j\n done\n done\nend\n\nmodule R = StaleRange\n\nlet (---) lb ub = R.make lb ub\nlet (--^) lb ub = R.make lb (ub - 1)\n\nmodule StaleGenericAlgorithms = struct\n\n let set_power ls =\n let rec loop ls pls =\n match ls with\n | [] -> pls\n | hd::tl -> loop tl (L.flatmap (fun p -> [p; hd::p]) pls)\n in loop ls [[]]\n\n let rec bsearch_max_int f lb ub =\n if lb >= ub then (if f lb then lb else (lb - 1))\n else (\n let m = (lb + ub) / 2 in\n if f m then bsearch_max_int f (m + 1) ub\n else bsearch_max_int f lb m\n )\n\n let partial_sum n ls =\n let rec loop s k = function\n | [] -> s\n | h::t ->\n if k >= n then s\n else loop (s + h) (k + 1) t\n in\n loop 0 0 ls\n\nend\n\nmodule Gal = StaleGenericAlgorithms\n\n\nmodule StaleIntArithmetic = struct\n\n let rec power x e =\n if e = 0 then x\n else \n let rec loop r x2 e' =\n if e' = 0 then r\n else if e' land 1 = 0 then loop r (x2 * x2) (e' lsr 1)\n else loop (r * x2) (x2 * x2) (e' lsr 1)\n in loop 1 x e\n \n\n let rec powers_le_1000 x =\n if x > 32 then [x]\n else\n L.init 9 (fun e -> power x (e + 1))\n |> L.filter (fun y -> y < 1000)\n\n let primes_le_1000 = [2;3;5;7;11;13;17;19;23;29;31;37;41;\n 43;47;53;59;61;67;71;73;79;83;89;97;101;\n 103;107;109;113;127;131;137;139;149;151;157;163;167;\n 173;179;181;191;193;197;199;211;223;227;229;233;239;\n 241;251;257;263;269;271;277;281;283;293;307;311;313;\n 317;331;337;347;349;353;359;367;373;379;383;389;397;\n 401;409;419;421;431;433;439;443;449;457;461;463;467;\n 479;487;491;499;503;509;521;523;541;547;557;563;569;\n 571;577;587;593;599;601;607;613;617;619;631;641;643;\n 647;653;659;661;673;677;683;691;701;709;719;727;733;\n 739;743;751;757;761;769;773;787;797;809;811;821;823;\n 827;829;839;853;857;859;863;877;881;883;887;907;911;\n 919;929;937;941;947;953;967;971;977;983;991;997]\n\n let primes_and_powers_le_1000 =\n [2;3;4;5;7;8;9;11;13;16;17;19;23;25;27;29;31;32;37;41;\n 43;47;49;53;59;61;64;67;71;73;79;81;83;89;97;\n 101;103;107;109;113;121;125;127;128;131;137;139;149;151;\n 157;163;167;169;173;179;181;191;193;197;199;211;223;227;\n 229;233;239;241;243;251;256;257;263;269;271;277;281;283;\n 289;293;307;311;313;317;331;337;343;347;349;353;359;361;\n 367;373;379;383;389;397;401;409;419;421;431;433;439;443;\n 449;457;461;463;467;479;487;491;499;503;509;512;521;523;\n 529;541;547;557;563;569;571;577;587;593;599;601;607;613;\n 617;619;625;631;641;643;647;653;659;661;673;677;683;691;\n 701;709;719;727;729;733;739;743;751;757;761;769;773;787;\n 797;809;811;821;823;827;829;839;841;853;857;859;863;877;\n 881;883;887;907;911;919;929;937;941;947;953;961;967;971;\n 977;983;991;997]\n\n let factorize_with ps n =\n let rec loop acc ps e n' =\n if n' <= 1 then ([], n') \n else\n match ps with\n | [] -> (acc, n')\n | p::t ->\n let r = n' mod p in\n if r = 0 then (\n if n' = p then ((p, e + 1) :: acc, 1)\n else loop acc ps (e + 1) (n' / p)\n ) else\n loop (if e = 0 then acc else (p, e) :: acc) t 0 n'\n in\n let (fs, r) = loop [] ps 0 n in\n (L.rev fs, r)\n\n let factorize_le_million n =\n factorize_with primes_le_1000 n\n\n let rec to_bits_le n =\n if n = 0 then []\n else (n mod 2) :: to_bits_le (n lsr 1)\n\n let rec gcd x y =\n match x mod y with\n | 0 -> y\n | z -> gcd y z\n\n let ext_euclid a b =\n let rec next (r0, s0, t0) (r1, s1, t1) =\n match r1 with\n | 0 -> (r0, s0, t0)\n | r2 ->\n let q = r0 / r1 in\n next (r1, s1, t1) (r0 - q * r1, s0 - q * s1, t0 - q * t1)\n in\n if a < b then\n let (g, y, x) = next (b, 1, 0) (a, 0, 1) in (g, x, y)\n else\n next (a, 1, 0) (b, 0, 1)\n\n let modinv x m =\n let (g, y, z) = ext_euclid x m in\n match g with\n | 1 -> y mod m\n | _ -> invalid_arg \"Not relatively prime\"\n \n\nend\n\nmodule N = StaleIntArithmetic\n\n\n\nlet rds () = read_line ()\n\nlet rdi () = s2i @@ rds ()\n\nlet rdhs () = spsp @@ rds ()\nlet rdhi () = rdhs () |> L.map s2i\n\nlet rdhf () = rdhs () |> L.map s2f\n\nlet rdf2 () = match rdhf () with\n| a::b::_ -> (a, b)\n| _ -> (0., 0.)\n\nlet rdf3 () = match rdhf () with\n| a::b::c::_ -> (a, b, c)\n| _ -> (0., 0., 0.)\n\nlet rdf4 () = match rdhf () with\n| a::b::c::d::_ -> (a, b, c, d)\n| _ -> (0., 0., 0., 0.)\n\nlet rds2 () = match rdhs () with\n | a::b::_ -> (a, b)\n | _ -> (\"\", \"\")\n\nlet rdi2 () = match rdhi () with\n | a::b::_ -> (a, b)\n | _ -> (0, 0)\n\nlet rdi3 () = match rdhi () with\n| a::b::c::_ -> (a, b, c)\n| _ -> (0, 0, 0)\n\nlet rdi4 () = match rdhi () with\n| a::b::c::d::_ -> (a, b, c, d)\n| _ -> (0, 0, 0, 0)\n\nlet rdi5 () = match rdhi () with\n| a::b::c::d::e::_ -> (a, b, c, d, e)\n| _ -> (0, 0, 0, 0, 0)\n\nlet rdv n rf =\n let rec loop n =\n if n <= 0 then []\n else (\n let s = rf () in\n s::(loop (n - 1))\n )\n in loop n\n\nlet rdvi n = rdv n rdi\nlet rdvi2 n = rdv n rdi2\nlet rdvi3 n = rdv n rdi3\nlet rdvi4 n = rdv n rdi4\n\n\nlet print_list aa = \n printf \"[ \"; aa |> L.iter (fun a -> printf \"%d \" a); puts \"]\"\n\nlet print_array aa = \n printf \"[ \"; aa |> A.iter (fun a -> printf \"%d \" a); puts \"]\"\n\nlet print_carray aa = \n printf \"[ \"; aa |> A.iter (fun a -> printf \"%c \" a); puts \"]\"\n\nlet print_matrix mat =\n puts \"----\";\n mat |> A.iter (fun r -> print_carray r);\n puts \"----\"\n\nlet _ =\n let (x, k, d) = rdi3 () in\n let xa = abs x in\n let k1 = xa / d and m1 = xa mod d and m2 = d - xa mod d in\n let m =\n if k < k1 then \n abs (if x >= 0 then abs x - k * d else abs x + k * d)\n else if (k - k1) mod 2 = 0 then m1\n else m2\n in\n puti @@ abs m\n \n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nTakahashi, who lives on the number line, is now at coordinate X. He will make exactly K moves of distance D in the positive or negative direction.\n\nMore specifically, in one move, he can go from coordinate x to x + D or x - D.\n\nHe wants to make K moves so that the absolute value of the coordinate of the destination will be the smallest possible.\n\nFind the minimum possible absolute value of the coordinate of the destination.\n\nConstraints\n\n-10^{15} \\leq X \\leq 10^{15}\n\n1 \\leq K \\leq 10^{15}\n\n1 \\leq D \\leq 10^{15}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX K D\n\nOutput\n\nPrint the minimum possible absolute value of the coordinate of the destination.\n\nSample Input 1\n\n6 2 4\n\nSample Output 1\n\n2\n\nTakahashi is now at coordinate 6. It is optimal to make the following moves:\n\nMove from coordinate 6 to (6 - 4 =) 2.\n\nMove from coordinate 2 to (2 - 4 =) -2.\n\nHere, the absolute value of the coordinate of the destination is 2, and we cannot make it smaller.\n\nSample Input 2\n\n7 4 3\n\nSample Output 2\n\n1\n\nTakahashi is now at coordinate 7. It is optimal to make, for example, the following moves:\n\nMove from coordinate 7 to 4.\n\nMove from coordinate 4 to 7.\n\nMove from coordinate 7 to 4.\n\nMove from coordinate 4 to 1.\n\nHere, the absolute value of the coordinate of the destination is 1, and we cannot make it smaller.\n\nSample Input 3\n\n10 1 2\n\nSample Output 3\n\n8\n\nSample Input 4\n\n1000000000000000 1000000000000000 1000000000000000\n\nSample Output 4\n\n1000000000000000\n\nThe answer can be enormous.", "sample_input": "6 2 4\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02584", "source_text": "Score : 300 points\n\nProblem Statement\n\nTakahashi, who lives on the number line, is now at coordinate X. He will make exactly K moves of distance D in the positive or negative direction.\n\nMore specifically, in one move, he can go from coordinate x to x + D or x - D.\n\nHe wants to make K moves so that the absolute value of the coordinate of the destination will be the smallest possible.\n\nFind the minimum possible absolute value of the coordinate of the destination.\n\nConstraints\n\n-10^{15} \\leq X \\leq 10^{15}\n\n1 \\leq K \\leq 10^{15}\n\n1 \\leq D \\leq 10^{15}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX K D\n\nOutput\n\nPrint the minimum possible absolute value of the coordinate of the destination.\n\nSample Input 1\n\n6 2 4\n\nSample Output 1\n\n2\n\nTakahashi is now at coordinate 6. It is optimal to make the following moves:\n\nMove from coordinate 6 to (6 - 4 =) 2.\n\nMove from coordinate 2 to (2 - 4 =) -2.\n\nHere, the absolute value of the coordinate of the destination is 2, and we cannot make it smaller.\n\nSample Input 2\n\n7 4 3\n\nSample Output 2\n\n1\n\nTakahashi is now at coordinate 7. It is optimal to make, for example, the following moves:\n\nMove from coordinate 7 to 4.\n\nMove from coordinate 4 to 7.\n\nMove from coordinate 7 to 4.\n\nMove from coordinate 4 to 1.\n\nHere, the absolute value of the coordinate of the destination is 1, and we cannot make it smaller.\n\nSample Input 3\n\n10 1 2\n\nSample Output 3\n\n8\n\nSample Input 4\n\n1000000000000000 1000000000000000 1000000000000000\n\nSample Output 4\n\n1000000000000000\n\nThe answer can be enormous.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 10451, "cpu_time_ms": 14, "memory_kb": 5512}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s639160496", "group_id": "codeNet:p02586", "input_text": "Scanf.scanf \"%d %d %d\" (fun rr cc k ->\n let mat = Array.make_matrix rr cc 0 in\n for i = 1 to k do\n Scanf.scanf \" %d %d %d\" (fun rr cc v ->\n mat.(rr - 1).(cc - 1) <- v\n )\n done;\n\n let prev = Array.make cc 0 in\n for y = 0 to rr - 1 do\n let m = mat.(y) in\n let rec loop x work0 work1 work2 work3 =\n if x < cc then (\n let work0 = max work0 prev.(x) in\n let v = m.(x) in\n let work3 = max work3 (work2 + v) in\n let work2 = max work2 (work1 + v) in\n let work1 = max work1 (work0 + v) in\n prev.(x) <- max (max work3 work2) (max work1 work0);\n loop (x + 1) work0 work1 work2 work3\n )\n in\n loop 0 0 0 0 0\n done;\n Printf.printf \"%d\\n\" (prev.(cc - 1))\n)", "language": "OCaml", "metadata": {"date": 1597964563, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p02586.html", "problem_id": "p02586", "resource_group": "low_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/OCaml/s639160496.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s639160496", "user_id": "u342443598"}, "prompt_components": {"gold_output": "8\n", "input_to_evaluate": "Scanf.scanf \"%d %d %d\" (fun rr cc k ->\n let mat = Array.make_matrix rr cc 0 in\n for i = 1 to k do\n Scanf.scanf \" %d %d %d\" (fun rr cc v ->\n mat.(rr - 1).(cc - 1) <- v\n )\n done;\n\n let prev = Array.make cc 0 in\n for y = 0 to rr - 1 do\n let m = mat.(y) in\n let rec loop x work0 work1 work2 work3 =\n if x < cc then (\n let work0 = max work0 prev.(x) in\n let v = m.(x) in\n let work3 = max work3 (work2 + v) in\n let work2 = max work2 (work1 + v) in\n let work1 = max work1 (work0 + v) in\n prev.(x) <- max (max work3 work2) (max work1 work0);\n loop (x + 1) work0 work1 work2 work3\n )\n in\n loop 0 0 0 0 0\n done;\n Printf.printf \"%d\\n\" (prev.(cc - 1))\n)", "problem_context": "Score : 500 points\n\nProblem Statement\n\nThere are K items placed on a grid of squares with R rows and C columns. Let (i, j) denote the square at the i-th row (1 \\leq i \\leq R) and the j-th column (1 \\leq j \\leq C). The i-th item is at (r_i, c_i) and has the value v_i.\n\nTakahashi will begin at (1, 1), the start, and get to (R, C), the goal. When he is at (i, j), he can move to (i + 1, j) or (i, j + 1) (but cannot move to a non-existent square).\n\nHe can pick up items on the squares he visits, including the start and the goal, but at most three for each row. It is allowed to ignore the item on a square he visits.\n\nFind the maximum possible sum of the values of items he picks up.\n\nConstraints\n\n1 \\leq R, C \\leq 3000\n\n1 \\leq K \\leq \\min(2 \\times 10^5, R \\times C)\n\n1 \\leq r_i \\leq R\n\n1 \\leq c_i \\leq C\n\n(r_i, c_i) \\neq (r_j, c_j) (i \\neq j)\n\n1 \\leq v_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nR C K\nr_1 c_1 v_1\nr_2 c_2 v_2\n:\nr_K c_K v_K\n\nOutput\n\nPrint the maximum possible sum of the values of items Takahashi picks up.\n\nSample Input 1\n\n2 2 3\n1 1 3\n2 1 4\n1 2 5\n\nSample Output 1\n\n8\n\nHe has two ways to get to the goal:\n\nVisit (1, 1), (1, 2), and (2, 2), in this order. In this case, the total value of the items he can pick up is 3 + 5 = 8.\n\nVisit (1, 1), (2, 1), and (2, 2), in this order. In this case, the total value of the items he can pick up is 3 + 4 = 7.\n\nThus, the maximum possible sum of the values of items he picks up is 8.\n\nSample Input 2\n\n2 5 5\n1 1 3\n2 4 20\n1 2 1\n1 3 4\n1 4 2\n\nSample Output 2\n\n29\n\nWe have four items in the 1-st row. The optimal choices are as follows:\n\nVisit (1, 1) (1, 2), (1, 3), (1, 4), (2, 4), and (2, 5), in this order, and pick up all items except the one on (1, 2). Then, the total value of the items he picks up will be 3 + 4 + 2 + 20 = 29.\n\nSample Input 3\n\n4 5 10\n2 5 12\n1 5 12\n2 3 15\n1 2 20\n1 1 28\n2 4 26\n3 2 27\n4 5 21\n3 5 10\n1 3 10\n\nSample Output 3\n\n142", "sample_input": "2 2 3\n1 1 3\n2 1 4\n1 2 5\n"}, "reference_outputs": ["8\n"], "source_document_id": "p02586", "source_text": "Score : 500 points\n\nProblem Statement\n\nThere are K items placed on a grid of squares with R rows and C columns. Let (i, j) denote the square at the i-th row (1 \\leq i \\leq R) and the j-th column (1 \\leq j \\leq C). The i-th item is at (r_i, c_i) and has the value v_i.\n\nTakahashi will begin at (1, 1), the start, and get to (R, C), the goal. When he is at (i, j), he can move to (i + 1, j) or (i, j + 1) (but cannot move to a non-existent square).\n\nHe can pick up items on the squares he visits, including the start and the goal, but at most three for each row. It is allowed to ignore the item on a square he visits.\n\nFind the maximum possible sum of the values of items he picks up.\n\nConstraints\n\n1 \\leq R, C \\leq 3000\n\n1 \\leq K \\leq \\min(2 \\times 10^5, R \\times C)\n\n1 \\leq r_i \\leq R\n\n1 \\leq c_i \\leq C\n\n(r_i, c_i) \\neq (r_j, c_j) (i \\neq j)\n\n1 \\leq v_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nR C K\nr_1 c_1 v_1\nr_2 c_2 v_2\n:\nr_K c_K v_K\n\nOutput\n\nPrint the maximum possible sum of the values of items Takahashi picks up.\n\nSample Input 1\n\n2 2 3\n1 1 3\n2 1 4\n1 2 5\n\nSample Output 1\n\n8\n\nHe has two ways to get to the goal:\n\nVisit (1, 1), (1, 2), and (2, 2), in this order. In this case, the total value of the items he can pick up is 3 + 5 = 8.\n\nVisit (1, 1), (2, 1), and (2, 2), in this order. In this case, the total value of the items he can pick up is 3 + 4 = 7.\n\nThus, the maximum possible sum of the values of items he picks up is 8.\n\nSample Input 2\n\n2 5 5\n1 1 3\n2 4 20\n1 2 1\n1 3 4\n1 4 2\n\nSample Output 2\n\n29\n\nWe have four items in the 1-st row. The optimal choices are as follows:\n\nVisit (1, 1) (1, 2), (1, 3), (1, 4), (2, 4), and (2, 5), in this order, and pick up all items except the one on (1, 2). Then, the total value of the items he picks up will be 3 + 4 + 2 + 20 = 29.\n\nSample Input 3\n\n4 5 10\n2 5 12\n1 5 12\n2 3 15\n1 2 20\n1 1 28\n2 4 26\n3 2 27\n4 5 21\n3 5 10\n1 3 10\n\nSample Output 3\n\n142", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 842, "cpu_time_ms": 655, "memory_kb": 77096}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s114638832", "group_id": "codeNet:p02594", "input_text": "let () = Scanf.scanf \"%d\" @@ fun x ->\n print_endline @@ if 30 <= x then \"Yes\" else \"No\"", "language": "OCaml", "metadata": {"date": 1596423381, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p02594.html", "problem_id": "p02594", "resource_group": "low_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/OCaml/s114638832.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s114638832", "user_id": "u504158101"}, "prompt_components": {"gold_output": "No\n", "input_to_evaluate": "let () = Scanf.scanf \"%d\" @@ fun x ->\n print_endline @@ if 30 <= x then \"Yes\" else \"No\"", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 6, "memory_kb": 3708}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s796728416", "group_id": "codeNet:p02595", "input_text": "open Printf\nopen Scanf\n\nlet solve n d =\n let lxy = List.init n @@ fun _ -> scanf \"%d %d \" @@ fun x y -> (x, y) in\n let f ct (x, y) = if d * d >= x * x + y * y then ct + 1 else ct in\n List.fold_left f 0 lxy\n\nlet () =\n scanf \"%d %d \" solve |> printf \"%d\\n\"\n", "language": "OCaml", "metadata": {"date": 1596563851, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p02595.html", "problem_id": "p02595", "resource_group": "low_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/OCaml/s796728416.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s796728416", "user_id": "u388783188"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "open Printf\nopen Scanf\n\nlet solve n d =\n let lxy = List.init n @@ fun _ -> scanf \"%d %d \" @@ fun x y -> (x, y) in\n let f ct (x, y) = if d * d >= x * x + y * y then ct + 1 else ct in\n List.fold_left f 0 lxy\n\nlet () =\n scanf \"%d %d \" solve |> printf \"%d\\n\"\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nWe have N points in the two-dimensional plane. The coordinates of the i-th point are (X_i,Y_i).\n\nAmong them, we are looking for the points such that the distance from the origin is at most D. How many such points are there?\n\nWe remind you that the distance between the origin and the point (p, q) can be represented as \\sqrt{p^2+q^2}.\n\nConstraints\n\n1 \\leq N \\leq 2\\times 10^5\n\n0 \\leq D \\leq 2\\times 10^5\n\n|X_i|,|Y_i| \\leq 2\\times 10^5\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN D\nX_1 Y_1\n\\vdots\nX_N Y_N\n\nOutput\n\nPrint an integer representing the number of points such that the distance from the origin is at most D.\n\nSample Input 1\n\n4 5\n0 5\n-2 4\n3 4\n4 -4\n\nSample Output 1\n\n3\n\nThe distance between the origin and each of the given points is as follows:\n\n\\sqrt{0^2+5^2}=5\n\n\\sqrt{(-2)^2+4^2}=4.472\\ldots\n\n\\sqrt{3^2+4^2}=5\n\n\\sqrt{4^2+(-4)^2}=5.656\\ldots\n\nThus, we have three points such that the distance from the origin is at most 5.\n\nSample Input 2\n\n12 3\n1 1\n1 1\n1 1\n1 1\n1 2\n1 3\n2 1\n2 2\n2 3\n3 1\n3 2\n3 3\n\nSample Output 2\n\n7\n\nMultiple points may exist at the same coordinates.\n\nSample Input 3\n\n20 100000\n14309 -32939\n-56855 100340\n151364 25430\n103789 -113141\n147404 -136977\n-37006 -30929\n188810 -49557\n13419 70401\n-88280 165170\n-196399 137941\n-176527 -61904\n46659 115261\n-153551 114185\n98784 -6820\n94111 -86268\n-30401 61477\n-55056 7872\n5901 -163796\n138819 -185986\n-69848 -96669\n\nSample Output 3\n\n6", "sample_input": "4 5\n0 5\n-2 4\n3 4\n4 -4\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02595", "source_text": "Score : 200 points\n\nProblem Statement\n\nWe have N points in the two-dimensional plane. The coordinates of the i-th point are (X_i,Y_i).\n\nAmong them, we are looking for the points such that the distance from the origin is at most D. How many such points are there?\n\nWe remind you that the distance between the origin and the point (p, q) can be represented as \\sqrt{p^2+q^2}.\n\nConstraints\n\n1 \\leq N \\leq 2\\times 10^5\n\n0 \\leq D \\leq 2\\times 10^5\n\n|X_i|,|Y_i| \\leq 2\\times 10^5\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN D\nX_1 Y_1\n\\vdots\nX_N Y_N\n\nOutput\n\nPrint an integer representing the number of points such that the distance from the origin is at most D.\n\nSample Input 1\n\n4 5\n0 5\n-2 4\n3 4\n4 -4\n\nSample Output 1\n\n3\n\nThe distance between the origin and each of the given points is as follows:\n\n\\sqrt{0^2+5^2}=5\n\n\\sqrt{(-2)^2+4^2}=4.472\\ldots\n\n\\sqrt{3^2+4^2}=5\n\n\\sqrt{4^2+(-4)^2}=5.656\\ldots\n\nThus, we have three points such that the distance from the origin is at most 5.\n\nSample Input 2\n\n12 3\n1 1\n1 1\n1 1\n1 1\n1 2\n1 3\n2 1\n2 2\n2 3\n3 1\n3 2\n3 3\n\nSample Output 2\n\n7\n\nMultiple points may exist at the same coordinates.\n\nSample Input 3\n\n20 100000\n14309 -32939\n-56855 100340\n151364 25430\n103789 -113141\n147404 -136977\n-37006 -30929\n188810 -49557\n13419 70401\n-88280 165170\n-196399 137941\n-176527 -61904\n46659 115261\n-153551 114185\n98784 -6820\n94111 -86268\n-30401 61477\n-55056 7872\n5901 -163796\n138819 -185986\n-69848 -96669\n\nSample Output 3\n\n6", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 115, "memory_kb": 20584}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s014896904", "group_id": "codeNet:p02595", "input_text": "let f () = Scanf.scanf \"%d %d\\n\" (fun a b -> a, b)\n\nlet () =\n let n, d = f () in\n let d2 = d * d in\n let rec g i s =\n if i = n then\n print_int s\n else\n let x, y = f () in\n if x * x + y * y <= d2 then\n g (i + 1) (s + 1)\n else\n g (i + 1) s\n in g 0 0\n", "language": "OCaml", "metadata": {"date": 1596474351, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p02595.html", "problem_id": "p02595", "resource_group": "low_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/OCaml/s014896904.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s014896904", "user_id": "u752907799"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "let f () = Scanf.scanf \"%d %d\\n\" (fun a b -> a, b)\n\nlet () =\n let n, d = f () in\n let d2 = d * d in\n let rec g i s =\n if i = n then\n print_int s\n else\n let x, y = f () in\n if x * x + y * y <= d2 then\n g (i + 1) (s + 1)\n else\n g (i + 1) s\n in g 0 0\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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 74, "memory_kb": 5868}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s502650473", "group_id": "codeNet:p02595", "input_text": "open Batteries\nopen Printf\n\nlet ($) g f x = g (f x)\n\nlet swap = Tuple2.swap\n\nlet s2i = int_of_string\nlet i2s = string_of_int\nlet s2f = float_of_string\nlet f2s = string_of_float\nlet c2i = int_of_char\nlet i2c = char_of_int\nlet f2i = int_of_float\nlet i2f = float_of_int \n\nlet c2s = String.of_char\nlet s2cl = String.to_list\nlet cl2s = String.of_list\n\nlet puts s = print_endline s\nlet putw ?yn:(yn=(\"Yes\", \"No\")) b = puts (if b then fst yn else snd yn)\nlet puti i = puts @@ i2s i\n\n\n\nmodule StaleList = struct\n include List\n\n let nmem x l = not @@ mem x l\n\n let len = length\n let size = length\n let nempty l = not @@ is_empty l\n\n let hdop l = if nempty l then Some (hd l) else None\n\n (* let taker = drop *)\n let takewh = take_while\n\n (* let dropr = take *)\n let dropwh = drop_while\n\n let split_by = span\n\n let chunk = ntake\n\n let foldl = fold_left\n let foldli = fold_lefti\n let foldr f z l = fold_right f l z\n let foldri f z l = fold_righti f l z\n\n let partition_to_map f l =\n foldr (fun x m -> Map.modify_opt (f x) (function\n | None -> Some [x] \n | Some [] -> Some [x] \n | Some vl -> Some (x::vl)) m) Map.empty l;;\n\n let scanl f z ls =\n let rec loop acl acc = function\n | [] -> rev acl\n | h::t ->\n let r = f acc h in\n loop (r::acl) r t\n in loop [] z ls\n\n let scanr f z ls =\n let rec loop acl acc = function\n | [] -> acl \n | h::t ->\n let r = f h acc in\n loop (r::acl) r t\n in loop [] z (rev ls)\n\n (* let scanli = scan_lefti *)\n (* let scanri = scan_righti *)\n \n let flatmap = concat_map\n\n let zipf = map2\n let zipfi = map2i\n\nend\n\nmodule L = StaleList\n\nmodule StaleArray = struct\n include Array \n\n let nmem x l = not @@ mem x l\n\n let len = length\n let size = length\n let is_empty r = len r = 0\n let nempty r = len r > 0\n\n let take n r = left r n\n let taker n r = right r n\n\n let takeb x r =\n let l = len r in\n let rec loop i =\n if i >= l then r\n else if r.(i) = x then take i r\n else loop (i + 1)\n in loop 0\n \n (* let takewh = take_while *)\n\n let drop n r = tail r n\n let dropr n r = take ((len r) - n) r\n (* let dropwh = drop_while *)\n\n let index_of x r =\n let l = len r in\n let rec loop i =\n if i >= l then None\n else if r.(i) = x then Some i\n else loop (i + 1)\n in loop 0\n\n (* let split_by = span *)\n\n (* let chunk = ntake *)\n\n let foldl = fold_left\n let foldli = fold_lefti\n let foldr f z l = fold_right f l z\n let foldri f z l = fold_righti f l z\n\n (* let partition_to_map f l = *)\n (* foldr (fun x m -> Map.modify_opt (f x) (function *)\n (* | None -> Some [x] *)\n (* | Some [] -> Some [x] *)\n (* | Some vl -> Some (x::vl)) m) Map.empty l;; *)\n\n (* let scanl = scan_left *)\n (* let scanli = scan_lefti *)\n (* let scanr = scan_right *)\n (* let scanri = scan_righti *)\n \n let concat2 = append\n \n let flatmap (f : 'a -> 'b array) a =\n map f a |> enum |> L.of_enum |> concat\n\n let zipf = map2\n (* let zipfi = map2i *)\n\nend\n\nmodule A = StaleArray\n\nmodule StaleString = struct\n include String\n\n let len = length\n\n let replace_chars = map\n let map = replace\n\n let maptol f s = L.map f (s2cl s)\n let maptoli f s = L.map f (s2cl s)\n\n let zipf f a b = L.zipf f (s2cl a) (s2cl b)\n let zipfi f a b = L.zipfi f (s2cl a) (s2cl b)\n\n let mkstr f sep ls =\n L.foldl (fun acc x -> acc ^ sep ^ (f x)) (f @@ L.hd ls) (List.tl ls)\n\nend\n\nmodule S = StaleString\n\nlet spsp s = S.split_on_char ' ' s\n\n\nmodule StaleSortedSet = struct\n include Set\n\n module Make (Ord : Set.OrderedType) = struct\n include Set.Make(Ord)\n\n let nmem x st = not @@ mem x st\n\n let foldl f s z = fold (fun x a -> f a x) z s\n\n let size = cardinal\n end\n\n let nmem x st = not @@ mem x st\n\n let foldl f s z = fold (fun x a -> f a x) z s\n\n let size = cardinal\nend\n\nmodule Ss = StaleSortedSet\n\nmodule StaleSortedMap = struct\n include Map\n\n module Make (Ord : Map.OrderedType) = struct\n include Map.Make(Ord)\n\n let nmem x st = not @@ mem x st\n\n let get = find\n let get_or x d m = find_default d x m\n\n let size = cardinal\n end\n\n let nmem x st = not @@ mem x st\n\n let get = find\n let get_or x d m = find_default d x m\n\n let size = cardinal\nend\n\nmodule Ms = StaleSortedMap\n\n\nmodule StaleRange = struct\n\n type t = Range of int * int\n\n let make lb ub = Range (lb, ub)\n\n let to_list r =\n let Range (lb, ub) = r in\n L.make (ub - lb) ((+) lb) \n\n let to_array r =\n let Range (lb, ub) = r in\n A.make (ub - lb) ((+) lb)\n\n let iter r f = \n let Range (lb, ub) = r in\n for i = lb to ub do f i done\n\n let iter2 r1 r2 f =\n let Range (lb1, ub1) = r1 and Range (lb2, ub2) = r2 in\n for i = lb1 to ub2 do\n for j = lb2 to ub2 do\n f i j\n done\n done\nend\n\nmodule R = StaleRange\n\nlet (---) lb ub = R.make lb ub\nlet (--^) lb ub = R.make lb (ub - 1)\n\nmodule StaleGenericAlgorithms = struct\n\n let set_power ls =\n let rec loop ls pls =\n match ls with\n | [] -> pls\n | hd::tl -> loop tl (L.flatmap (fun p -> [p; hd::p]) pls)\n in loop ls [[]]\n\n let rec bsearch_max_int f lb ub =\n if lb >= ub then (if f lb then lb else (lb - 1))\n else (\n let m = (lb + ub) / 2 in\n if f m then bsearch_max_int f (m + 1) ub\n else bsearch_max_int f lb m\n )\n\n let partial_sum n ls =\n let rec loop s k = function\n | [] -> s\n | h::t ->\n if k >= n then s\n else loop (s + h) (k + 1) t\n in\n loop 0 0 ls\n\nend\n\nmodule Gal = StaleGenericAlgorithms\n\nlet rds () = read_line ()\n\nlet rdi () = s2i @@ rds ()\n\nlet rdhs () = spsp @@ rds ()\nlet rdhi () = rdhs () |> L.map s2i\n\nlet rdhf () = rdhs () |> L.map s2f\n\nlet rdf2 () = match rdhf () with\n| a::b::_ -> (a, b)\n| _ -> (0., 0.)\n\nlet rdf3 () = match rdhf () with\n| a::b::c::_ -> (a, b, c)\n| _ -> (0., 0., 0.)\n\nlet rdf4 () = match rdhf () with\n| a::b::c::d::_ -> (a, b, c, d)\n| _ -> (0., 0., 0., 0.)\n\nlet rds2 () = match rdhs () with\n | a::b::_ -> (a, b)\n | _ -> (\"\", \"\")\n\nlet rdi2 () = match rdhi () with\n | a::b::_ -> (a, b)\n | _ -> (0, 0)\n\nlet rdi3 () = match rdhi () with\n| a::b::c::_ -> (a, b, c)\n| _ -> (0, 0, 0)\n\nlet rdi4 () = match rdhi () with\n| a::b::c::d::_ -> (a, b, c, d)\n| _ -> (0, 0, 0, 0)\n\nlet rdi5 () = match rdhi () with\n| a::b::c::d::e::_ -> (a, b, c, d, e)\n| _ -> (0, 0, 0, 0, 0)\n\nlet rdv n rf =\n let rec loop n =\n if n <= 0 then []\n else (\n let s = rf () in\n s::(loop (n - 1))\n )\n in loop n\n\nlet rdvi n = rdv n rdi\nlet rdvi2 n = rdv n rdi2\nlet rdvi3 n = rdv n rdi3\nlet rdvi4 n = rdv n rdi4\n\n\nlet print_list aa = \n printf \"[ \"; aa |> L.iter (fun a -> printf \"%d \" a); puts \"]\"\n\nlet print_array aa = \n printf \"[ \"; aa |> A.iter (fun a -> printf \"%d \" a); puts \"]\"\n\nlet print_carray aa = \n printf \"[ \"; aa |> A.iter (fun a -> printf \"%c \" a); puts \"]\"\n\nlet print_matrix mat =\n puts \"----\";\n mat |> A.iter (fun r -> print_carray r);\n puts \"----\"\n\n\nlet _ =\n let (n, d) = rdi2 () in\n let xys = rdvi2 n in\n let flt = xys |> L.filter (fun (x,y) -> x*x + y*y <= d*d) in\n puti @@ L.len flt;\n ()\n", "language": "OCaml", "metadata": {"date": 1596416867, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p02595.html", "problem_id": "p02595", "resource_group": "low_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/OCaml/s502650473.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s502650473", "user_id": "u970139668"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "open Batteries\nopen Printf\n\nlet ($) g f x = g (f x)\n\nlet swap = Tuple2.swap\n\nlet s2i = int_of_string\nlet i2s = string_of_int\nlet s2f = float_of_string\nlet f2s = string_of_float\nlet c2i = int_of_char\nlet i2c = char_of_int\nlet f2i = int_of_float\nlet i2f = float_of_int \n\nlet c2s = String.of_char\nlet s2cl = String.to_list\nlet cl2s = String.of_list\n\nlet puts s = print_endline s\nlet putw ?yn:(yn=(\"Yes\", \"No\")) b = puts (if b then fst yn else snd yn)\nlet puti i = puts @@ i2s i\n\n\n\nmodule StaleList = struct\n include List\n\n let nmem x l = not @@ mem x l\n\n let len = length\n let size = length\n let nempty l = not @@ is_empty l\n\n let hdop l = if nempty l then Some (hd l) else None\n\n (* let taker = drop *)\n let takewh = take_while\n\n (* let dropr = take *)\n let dropwh = drop_while\n\n let split_by = span\n\n let chunk = ntake\n\n let foldl = fold_left\n let foldli = fold_lefti\n let foldr f z l = fold_right f l z\n let foldri f z l = fold_righti f l z\n\n let partition_to_map f l =\n foldr (fun x m -> Map.modify_opt (f x) (function\n | None -> Some [x] \n | Some [] -> Some [x] \n | Some vl -> Some (x::vl)) m) Map.empty l;;\n\n let scanl f z ls =\n let rec loop acl acc = function\n | [] -> rev acl\n | h::t ->\n let r = f acc h in\n loop (r::acl) r t\n in loop [] z ls\n\n let scanr f z ls =\n let rec loop acl acc = function\n | [] -> acl \n | h::t ->\n let r = f h acc in\n loop (r::acl) r t\n in loop [] z (rev ls)\n\n (* let scanli = scan_lefti *)\n (* let scanri = scan_righti *)\n \n let flatmap = concat_map\n\n let zipf = map2\n let zipfi = map2i\n\nend\n\nmodule L = StaleList\n\nmodule StaleArray = struct\n include Array \n\n let nmem x l = not @@ mem x l\n\n let len = length\n let size = length\n let is_empty r = len r = 0\n let nempty r = len r > 0\n\n let take n r = left r n\n let taker n r = right r n\n\n let takeb x r =\n let l = len r in\n let rec loop i =\n if i >= l then r\n else if r.(i) = x then take i r\n else loop (i + 1)\n in loop 0\n \n (* let takewh = take_while *)\n\n let drop n r = tail r n\n let dropr n r = take ((len r) - n) r\n (* let dropwh = drop_while *)\n\n let index_of x r =\n let l = len r in\n let rec loop i =\n if i >= l then None\n else if r.(i) = x then Some i\n else loop (i + 1)\n in loop 0\n\n (* let split_by = span *)\n\n (* let chunk = ntake *)\n\n let foldl = fold_left\n let foldli = fold_lefti\n let foldr f z l = fold_right f l z\n let foldri f z l = fold_righti f l z\n\n (* let partition_to_map f l = *)\n (* foldr (fun x m -> Map.modify_opt (f x) (function *)\n (* | None -> Some [x] *)\n (* | Some [] -> Some [x] *)\n (* | Some vl -> Some (x::vl)) m) Map.empty l;; *)\n\n (* let scanl = scan_left *)\n (* let scanli = scan_lefti *)\n (* let scanr = scan_right *)\n (* let scanri = scan_righti *)\n \n let concat2 = append\n \n let flatmap (f : 'a -> 'b array) a =\n map f a |> enum |> L.of_enum |> concat\n\n let zipf = map2\n (* let zipfi = map2i *)\n\nend\n\nmodule A = StaleArray\n\nmodule StaleString = struct\n include String\n\n let len = length\n\n let replace_chars = map\n let map = replace\n\n let maptol f s = L.map f (s2cl s)\n let maptoli f s = L.map f (s2cl s)\n\n let zipf f a b = L.zipf f (s2cl a) (s2cl b)\n let zipfi f a b = L.zipfi f (s2cl a) (s2cl b)\n\n let mkstr f sep ls =\n L.foldl (fun acc x -> acc ^ sep ^ (f x)) (f @@ L.hd ls) (List.tl ls)\n\nend\n\nmodule S = StaleString\n\nlet spsp s = S.split_on_char ' ' s\n\n\nmodule StaleSortedSet = struct\n include Set\n\n module Make (Ord : Set.OrderedType) = struct\n include Set.Make(Ord)\n\n let nmem x st = not @@ mem x st\n\n let foldl f s z = fold (fun x a -> f a x) z s\n\n let size = cardinal\n end\n\n let nmem x st = not @@ mem x st\n\n let foldl f s z = fold (fun x a -> f a x) z s\n\n let size = cardinal\nend\n\nmodule Ss = StaleSortedSet\n\nmodule StaleSortedMap = struct\n include Map\n\n module Make (Ord : Map.OrderedType) = struct\n include Map.Make(Ord)\n\n let nmem x st = not @@ mem x st\n\n let get = find\n let get_or x d m = find_default d x m\n\n let size = cardinal\n end\n\n let nmem x st = not @@ mem x st\n\n let get = find\n let get_or x d m = find_default d x m\n\n let size = cardinal\nend\n\nmodule Ms = StaleSortedMap\n\n\nmodule StaleRange = struct\n\n type t = Range of int * int\n\n let make lb ub = Range (lb, ub)\n\n let to_list r =\n let Range (lb, ub) = r in\n L.make (ub - lb) ((+) lb) \n\n let to_array r =\n let Range (lb, ub) = r in\n A.make (ub - lb) ((+) lb)\n\n let iter r f = \n let Range (lb, ub) = r in\n for i = lb to ub do f i done\n\n let iter2 r1 r2 f =\n let Range (lb1, ub1) = r1 and Range (lb2, ub2) = r2 in\n for i = lb1 to ub2 do\n for j = lb2 to ub2 do\n f i j\n done\n done\nend\n\nmodule R = StaleRange\n\nlet (---) lb ub = R.make lb ub\nlet (--^) lb ub = R.make lb (ub - 1)\n\nmodule StaleGenericAlgorithms = struct\n\n let set_power ls =\n let rec loop ls pls =\n match ls with\n | [] -> pls\n | hd::tl -> loop tl (L.flatmap (fun p -> [p; hd::p]) pls)\n in loop ls [[]]\n\n let rec bsearch_max_int f lb ub =\n if lb >= ub then (if f lb then lb else (lb - 1))\n else (\n let m = (lb + ub) / 2 in\n if f m then bsearch_max_int f (m + 1) ub\n else bsearch_max_int f lb m\n )\n\n let partial_sum n ls =\n let rec loop s k = function\n | [] -> s\n | h::t ->\n if k >= n then s\n else loop (s + h) (k + 1) t\n in\n loop 0 0 ls\n\nend\n\nmodule Gal = StaleGenericAlgorithms\n\nlet rds () = read_line ()\n\nlet rdi () = s2i @@ rds ()\n\nlet rdhs () = spsp @@ rds ()\nlet rdhi () = rdhs () |> L.map s2i\n\nlet rdhf () = rdhs () |> L.map s2f\n\nlet rdf2 () = match rdhf () with\n| a::b::_ -> (a, b)\n| _ -> (0., 0.)\n\nlet rdf3 () = match rdhf () with\n| a::b::c::_ -> (a, b, c)\n| _ -> (0., 0., 0.)\n\nlet rdf4 () = match rdhf () with\n| a::b::c::d::_ -> (a, b, c, d)\n| _ -> (0., 0., 0., 0.)\n\nlet rds2 () = match rdhs () with\n | a::b::_ -> (a, b)\n | _ -> (\"\", \"\")\n\nlet rdi2 () = match rdhi () with\n | a::b::_ -> (a, b)\n | _ -> (0, 0)\n\nlet rdi3 () = match rdhi () with\n| a::b::c::_ -> (a, b, c)\n| _ -> (0, 0, 0)\n\nlet rdi4 () = match rdhi () with\n| a::b::c::d::_ -> (a, b, c, d)\n| _ -> (0, 0, 0, 0)\n\nlet rdi5 () = match rdhi () with\n| a::b::c::d::e::_ -> (a, b, c, d, e)\n| _ -> (0, 0, 0, 0, 0)\n\nlet rdv n rf =\n let rec loop n =\n if n <= 0 then []\n else (\n let s = rf () in\n s::(loop (n - 1))\n )\n in loop n\n\nlet rdvi n = rdv n rdi\nlet rdvi2 n = rdv n rdi2\nlet rdvi3 n = rdv n rdi3\nlet rdvi4 n = rdv n rdi4\n\n\nlet print_list aa = \n printf \"[ \"; aa |> L.iter (fun a -> printf \"%d \" a); puts \"]\"\n\nlet print_array aa = \n printf \"[ \"; aa |> A.iter (fun a -> printf \"%d \" a); puts \"]\"\n\nlet print_carray aa = \n printf \"[ \"; aa |> A.iter (fun a -> printf \"%c \" a); puts \"]\"\n\nlet print_matrix mat =\n puts \"----\";\n mat |> A.iter (fun r -> print_carray r);\n puts \"----\"\n\n\nlet _ =\n let (n, d) = rdi2 () in\n let xys = rdvi2 n in\n let flt = xys |> L.filter (fun (x,y) -> x*x + y*y <= d*d) in\n puti @@ L.len flt;\n ()\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nWe have N points in the two-dimensional plane. The coordinates of the i-th point are (X_i,Y_i).\n\nAmong them, we are looking for the points such that the distance from the origin is at most D. How many such points are there?\n\nWe remind you that the distance between the origin and the point (p, q) can be represented as \\sqrt{p^2+q^2}.\n\nConstraints\n\n1 \\leq N \\leq 2\\times 10^5\n\n0 \\leq D \\leq 2\\times 10^5\n\n|X_i|,|Y_i| \\leq 2\\times 10^5\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN D\nX_1 Y_1\n\\vdots\nX_N Y_N\n\nOutput\n\nPrint an integer representing the number of points such that the distance from the origin is at most D.\n\nSample Input 1\n\n4 5\n0 5\n-2 4\n3 4\n4 -4\n\nSample Output 1\n\n3\n\nThe distance between the origin and each of the given points is as follows:\n\n\\sqrt{0^2+5^2}=5\n\n\\sqrt{(-2)^2+4^2}=4.472\\ldots\n\n\\sqrt{3^2+4^2}=5\n\n\\sqrt{4^2+(-4)^2}=5.656\\ldots\n\nThus, we have three points such that the distance from the origin is at most 5.\n\nSample Input 2\n\n12 3\n1 1\n1 1\n1 1\n1 1\n1 2\n1 3\n2 1\n2 2\n2 3\n3 1\n3 2\n3 3\n\nSample Output 2\n\n7\n\nMultiple points may exist at the same coordinates.\n\nSample Input 3\n\n20 100000\n14309 -32939\n-56855 100340\n151364 25430\n103789 -113141\n147404 -136977\n-37006 -30929\n188810 -49557\n13419 70401\n-88280 165170\n-196399 137941\n-176527 -61904\n46659 115261\n-153551 114185\n98784 -6820\n94111 -86268\n-30401 61477\n-55056 7872\n5901 -163796\n138819 -185986\n-69848 -96669\n\nSample Output 3\n\n6", "sample_input": "4 5\n0 5\n-2 4\n3 4\n4 -4\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02595", "source_text": "Score : 200 points\n\nProblem Statement\n\nWe have N points in the two-dimensional plane. The coordinates of the i-th point are (X_i,Y_i).\n\nAmong them, we are looking for the points such that the distance from the origin is at most D. How many such points are there?\n\nWe remind you that the distance between the origin and the point (p, q) can be represented as \\sqrt{p^2+q^2}.\n\nConstraints\n\n1 \\leq N \\leq 2\\times 10^5\n\n0 \\leq D \\leq 2\\times 10^5\n\n|X_i|,|Y_i| \\leq 2\\times 10^5\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN D\nX_1 Y_1\n\\vdots\nX_N Y_N\n\nOutput\n\nPrint an integer representing the number of points such that the distance from the origin is at most D.\n\nSample Input 1\n\n4 5\n0 5\n-2 4\n3 4\n4 -4\n\nSample Output 1\n\n3\n\nThe distance between the origin and each of the given points is as follows:\n\n\\sqrt{0^2+5^2}=5\n\n\\sqrt{(-2)^2+4^2}=4.472\\ldots\n\n\\sqrt{3^2+4^2}=5\n\n\\sqrt{4^2+(-4)^2}=5.656\\ldots\n\nThus, we have three points such that the distance from the origin is at most 5.\n\nSample Input 2\n\n12 3\n1 1\n1 1\n1 1\n1 1\n1 2\n1 3\n2 1\n2 2\n2 3\n3 1\n3 2\n3 3\n\nSample Output 2\n\n7\n\nMultiple points may exist at the same coordinates.\n\nSample Input 3\n\n20 100000\n14309 -32939\n-56855 100340\n151364 25430\n103789 -113141\n147404 -136977\n-37006 -30929\n188810 -49557\n13419 70401\n-88280 165170\n-196399 137941\n-176527 -61904\n46659 115261\n-153551 114185\n98784 -6820\n94111 -86268\n-30401 61477\n-55056 7872\n5901 -163796\n138819 -185986\n-69848 -96669\n\nSample Output 3\n\n6", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 7069, "cpu_time_ms": 134, "memory_kb": 27916}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s183088699", "group_id": "codeNet:p02596", "input_text": "let k = read_int() in\nlet rec f m i =\n if i = k then -1\n else\n let m = (10 * m + 7) mod k in\n if m = 0 then i + 1\n else f m (i + 1)\nin print_int (f 0 0)\n", "language": "OCaml", "metadata": {"date": 1597254950, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p02596.html", "problem_id": "p02596", "resource_group": "low_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/OCaml/s183088699.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s183088699", "user_id": "u752907799"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "let k = read_int() in\nlet rec f m i =\n if i = k then -1\n else\n let m = (10 * m + 7) mod k in\n if m = 0 then i + 1\n else f m (i + 1)\nin print_int (f 0 0)\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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 28, "memory_kb": 3708}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s240413313", "group_id": "codeNet:p02597", "input_text": "let n = read_int ()\nlet c = read_line()\n\nlet rec r i s =\n if i = n then s\n else if c.[i] = 'R' then\n r (i + 1) (s + 1)\n else\n r (i + 1) s\n\nlet rec f i w r =\n if w == r then r\n else if c.[i] = 'W' then\n f (i + 1) (w + 1) r\n else\n f (i + 1) w (r - 1)\n\nlet () =\n let ans = f 0 0 (r 0 0) in\n Printf.printf \"%d\\n\" ans\n", "language": "OCaml", "metadata": {"date": 1597283175, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p02597.html", "problem_id": "p02597", "resource_group": "low_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/OCaml/s240413313.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s240413313", "user_id": "u752907799"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "let n = read_int ()\nlet c = read_line()\n\nlet rec r i s =\n if i = n then s\n else if c.[i] = 'R' then\n r (i + 1) (s + 1)\n else\n r (i + 1) s\n\nlet rec f i w r =\n if w == r then r\n else if c.[i] = 'W' then\n f (i + 1) (w + 1) r\n else\n f (i + 1) w (r - 1)\n\nlet () =\n let ans = f 0 0 (r 0 0) in\n Printf.printf \"%d\\n\" ans\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nAn altar enshrines N stones arranged in a row from left to right. The color of the i-th stone from the left (1 \\leq i \\leq N) is given to you as a character c_i; R stands for red and W stands for white.\n\nYou can do the following two kinds of operations any number of times in any order:\n\nChoose two stones (not necessarily adjacent) and swap them.\n\nChoose one stone and change its color (from red to white and vice versa).\n\nAccording to a fortune-teller, a white stone placed to the immediate left of a red stone will bring a disaster. At least how many operations are needed to reach a situation without such a white stone?\n\nConstraints\n\n2 \\leq N \\leq 200000\n\nc_i is R or W.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nc_{1}c_{2}...c_{N}\n\nOutput\n\nPrint an integer representing the minimum number of operations needed.\n\nSample Input 1\n\n4\nWWRR\n\nSample Output 1\n\n2\n\nFor example, the two operations below will achieve the objective.\n\nSwap the 1-st and 3-rd stones from the left, resulting in RWWR.\n\nChange the color of the 4-th stone from the left, resulting in RWWW.\n\nSample Input 2\n\n2\nRR\n\nSample Output 2\n\n0\n\nIt can be the case that no operation is needed.\n\nSample Input 3\n\n8\nWRWWRWRR\n\nSample Output 3\n\n3", "sample_input": "4\nWWRR\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02597", "source_text": "Score : 400 points\n\nProblem Statement\n\nAn altar enshrines N stones arranged in a row from left to right. The color of the i-th stone from the left (1 \\leq i \\leq N) is given to you as a character c_i; R stands for red and W stands for white.\n\nYou can do the following two kinds of operations any number of times in any order:\n\nChoose two stones (not necessarily adjacent) and swap them.\n\nChoose one stone and change its color (from red to white and vice versa).\n\nAccording to a fortune-teller, a white stone placed to the immediate left of a red stone will bring a disaster. At least how many operations are needed to reach a situation without such a white stone?\n\nConstraints\n\n2 \\leq N \\leq 200000\n\nc_i is R or W.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nc_{1}c_{2}...c_{N}\n\nOutput\n\nPrint an integer representing the minimum number of operations needed.\n\nSample Input 1\n\n4\nWWRR\n\nSample Output 1\n\n2\n\nFor example, the two operations below will achieve the objective.\n\nSwap the 1-st and 3-rd stones from the left, resulting in RWWR.\n\nChange the color of the 4-th stone from the left, resulting in RWWW.\n\nSample Input 2\n\n2\nRR\n\nSample Output 2\n\n0\n\nIt can be the case that no operation is needed.\n\nSample Input 3\n\n8\nWRWWRWRR\n\nSample Output 3\n\n3", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 4080}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s074585272", "group_id": "codeNet:p02597", "input_text": "let () =\n let red = ref 0 in\n let rec charlist_of_string str n i =\n if i = n then []\n else if str.[i] = 'R' then (red := !red + 1; 'R' :: charlist_of_string str n (i+1))\n else 'W' :: charlist_of_string str n (i+1) in\n let rec count lst target n i =\n if i = n then 0\n else match lst with\n | [] -> 0\n | h :: t -> if h = target then 1 + count t target n (i+1) else count t target n (i+1) in\n Scanf.scanf \"%d\\n%s\\n\" @@ fun n s ->\n let lst = charlist_of_string s (String.length s) 0 in\n Printf.printf \"%d\\n\" (count lst 'W' (!red) 0)", "language": "OCaml", "metadata": {"date": 1596559998, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p02597.html", "problem_id": "p02597", "resource_group": "low_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/OCaml/s074585272.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s074585272", "user_id": "u307426615"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "let () =\n let red = ref 0 in\n let rec charlist_of_string str n i =\n if i = n then []\n else if str.[i] = 'R' then (red := !red + 1; 'R' :: charlist_of_string str n (i+1))\n else 'W' :: charlist_of_string str n (i+1) in\n let rec count lst target n i =\n if i = n then 0\n else match lst with\n | [] -> 0\n | h :: t -> if h = target then 1 + count t target n (i+1) else count t target n (i+1) in\n Scanf.scanf \"%d\\n%s\\n\" @@ fun n s ->\n let lst = charlist_of_string s (String.length s) 0 in\n Printf.printf \"%d\\n\" (count lst 'W' (!red) 0)", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 35, "memory_kb": 15372}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s004980413", "group_id": "codeNet:p02598", "input_text": "Scanf.scanf \"%d %d\" (fun n k ->\n let a = Array.init n (fun _ -> Scanf.scanf \" %d\" (fun a -> a)) in\n\n let count m =\n Array.fold_left (fun acc b -> acc + (b + m - 1) / m - 1) 0 a\n in\n\n let rec loop l r =\n if l = r then l else\n let m = (l + r) / 2 in\n if count m <= k then loop l m else loop (m + 1) r\n in\n loop 0 1000000001 |> Printf.printf \"%d\\n\"\n)", "language": "OCaml", "metadata": {"date": 1596418465, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p02598.html", "problem_id": "p02598", "resource_group": "low_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/OCaml/s004980413.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s004980413", "user_id": "u342443598"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "Scanf.scanf \"%d %d\" (fun n k ->\n let a = Array.init n (fun _ -> Scanf.scanf \" %d\" (fun a -> a)) in\n\n let count m =\n Array.fold_left (fun acc b -> acc + (b + m - 1) / m - 1) 0 a\n in\n\n let rec loop l r =\n if l = r then l else\n let m = (l + r) / 2 in\n if count m <= k then loop l m else loop (m + 1) r\n in\n loop 0 1000000001 |> Printf.printf \"%d\\n\"\n)", "problem_context": "Score : 500 points\n\nProblem Statement\n\nWe have N logs of lengths A_1,A_2,\\cdots A_N.\n\nWe can cut these logs at most K times in total. When a log of length L is cut at a point whose distance from an end of the log is t (0 t -> t\n val zero: t\n end\n module Make(E: Element) = struct\n let create n = Array.make (n + 1) E.zero\n\n let update bit index value =\n let n = Array.length bit - 1 in\n let rec loop ii =\n if ii <= n then (\n bit.(ii) <- E.proc bit.(ii) value;\n loop (ii + (ii land (-ii)))\n )\n in\n loop index\n\n let query bit index = \n let rec loop ii acc =\n if ii > 0 then (\n loop (ii - (ii land -ii)) (E.proc bit.(ii) acc)\n ) else acc\n in\n loop index E.zero\n end\nend;;\ntype q = { r:int; l:int; idx:int };;\nScanf.scanf \"%d %d\" (fun n q ->\n let solve arr n query q =\n let ans = Array.make q 0 in\n let module F = Fenwick.Make (struct type t = int let proc = (+) let zero = 0 end) in\n let bit = F.create n in\n let last_visit = Array.make 500001 (-1) in\n\n let rec loop i qi =\n if i < n then (\n if last_visit.(arr.(i)) <> -1 then\n F.update bit (last_visit.(arr.(i)) + 1) (-1);\n last_visit.(arr.(i)) <- i;\n\n F.update bit (i + 1) 1;\n\n let rec loop2 qi =\n if qi < q && query.(qi).r = i then (\n ans.(query.(qi).idx) <-\n F.query bit (query.(qi).r + 1) - F.query bit (query.(qi).l);\n loop2 (qi + 1)\n ) else qi\n in\n loop (i + 1) (loop2 qi)\n )\n in\n loop 0 0;\n Array.iter (Printf.printf \"%d\\n\") ans\n in\n let c = Array.init n (fun _ -> Scanf.scanf \" %d\" (fun a -> a)) in\n let query = Array.init q (fun i -> Scanf.scanf \" %d %d\" (fun l r -> { r = r - 1; l = l - 1; idx = i})) in\n Array.sort compare query;\n solve c n query q\n)", "language": "OCaml", "metadata": {"date": 1596433969, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p02599.html", "problem_id": "p02599", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02599/input.txt", "sample_output_relpath": "derived/input_output/data/p02599/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02599/OCaml/s034381706.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s034381706", "user_id": "u342443598"}, "prompt_components": {"gold_output": "2\n3\n1\n", "input_to_evaluate": "module Fenwick = struct\n module type Element =\n sig\n type t\n val proc: t -> t -> t\n val zero: t\n end\n module Make(E: Element) = struct\n let create n = Array.make (n + 1) E.zero\n\n let update bit index value =\n let n = Array.length bit - 1 in\n let rec loop ii =\n if ii <= n then (\n bit.(ii) <- E.proc bit.(ii) value;\n loop (ii + (ii land (-ii)))\n )\n in\n loop index\n\n let query bit index = \n let rec loop ii acc =\n if ii > 0 then (\n loop (ii - (ii land -ii)) (E.proc bit.(ii) acc)\n ) else acc\n in\n loop index E.zero\n end\nend;;\ntype q = { r:int; l:int; idx:int };;\nScanf.scanf \"%d %d\" (fun n q ->\n let solve arr n query q =\n let ans = Array.make q 0 in\n let module F = Fenwick.Make (struct type t = int let proc = (+) let zero = 0 end) in\n let bit = F.create n in\n let last_visit = Array.make 500001 (-1) in\n\n let rec loop i qi =\n if i < n then (\n if last_visit.(arr.(i)) <> -1 then\n F.update bit (last_visit.(arr.(i)) + 1) (-1);\n last_visit.(arr.(i)) <- i;\n\n F.update bit (i + 1) 1;\n\n let rec loop2 qi =\n if qi < q && query.(qi).r = i then (\n ans.(query.(qi).idx) <-\n F.query bit (query.(qi).r + 1) - F.query bit (query.(qi).l);\n loop2 (qi + 1)\n ) else qi\n in\n loop (i + 1) (loop2 qi)\n )\n in\n loop 0 0;\n Array.iter (Printf.printf \"%d\\n\") ans\n in\n let c = Array.init n (fun _ -> Scanf.scanf \" %d\" (fun a -> a)) in\n let query = Array.init q (fun i -> Scanf.scanf \" %d %d\" (fun l r -> { r = r - 1; l = l - 1; idx = i})) in\n Array.sort compare query;\n solve c n query q\n)", "problem_context": "Score : 600 points\n\nProblem Statement\n\nWe have N colored balls arranged in a row from left to right; the color of the i-th ball from the left is c_i.\n\nYou are given Q queries. The i-th query is as follows: how many different colors do the l_i-th through r_i-th balls from the left have?\n\nConstraints\n\n1\\leq N,Q \\leq 5 \\times 10^5\n\n1\\leq c_i \\leq N\n\n1\\leq l_i \\leq r_i \\leq N\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN Q\nc_1 c_2 \\cdots c_N\nl_1 r_1\nl_2 r_2\n:\nl_Q r_Q\n\nOutput\n\nPrint Q lines. The i-th line should contain the response to the i-th query.\n\nSample Input 1\n\n4 3\n1 2 1 3\n1 3\n2 4\n3 3\n\nSample Output 1\n\n2\n3\n1\n\nThe 1-st, 2-nd, and 3-rd balls from the left have the colors 1, 2, and 1 - two different colors.\n\nThe 2-st, 3-rd, and 4-th balls from the left have the colors 2, 1, and 3 - three different colors.\n\nThe 3-rd ball from the left has the color 1 - just one color.\n\nSample Input 2\n\n10 10\n2 5 6 5 2 1 7 9 7 2\n5 5\n2 4\n6 7\n2 2\n7 8\n7 9\n1 8\n6 9\n8 10\n6 8\n\nSample Output 2\n\n1\n2\n2\n1\n2\n2\n6\n3\n3\n3", "sample_input": "4 3\n1 2 1 3\n1 3\n2 4\n3 3\n"}, "reference_outputs": ["2\n3\n1\n"], "source_document_id": "p02599", "source_text": "Score : 600 points\n\nProblem Statement\n\nWe have N colored balls arranged in a row from left to right; the color of the i-th ball from the left is c_i.\n\nYou are given Q queries. The i-th query is as follows: how many different colors do the l_i-th through r_i-th balls from the left have?\n\nConstraints\n\n1\\leq N,Q \\leq 5 \\times 10^5\n\n1\\leq c_i \\leq N\n\n1\\leq l_i \\leq r_i \\leq N\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN Q\nc_1 c_2 \\cdots c_N\nl_1 r_1\nl_2 r_2\n:\nl_Q r_Q\n\nOutput\n\nPrint Q lines. The i-th line should contain the response to the i-th query.\n\nSample Input 1\n\n4 3\n1 2 1 3\n1 3\n2 4\n3 3\n\nSample Output 1\n\n2\n3\n1\n\nThe 1-st, 2-nd, and 3-rd balls from the left have the colors 1, 2, and 1 - two different colors.\n\nThe 2-st, 3-rd, and 4-th balls from the left have the colors 2, 1, and 3 - three different colors.\n\nThe 3-rd ball from the left has the color 1 - just one color.\n\nSample Input 2\n\n10 10\n2 5 6 5 2 1 7 9 7 2\n5 5\n2 4\n6 7\n2 2\n7 8\n7 9\n1 8\n6 9\n8 10\n6 8\n\nSample Output 2\n\n1\n2\n2\n1\n2\n2\n6\n3\n3\n3", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2052, "cpu_time_ms": 995, "memory_kb": 43460}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s910460927", "group_id": "codeNet:p02600", "input_text": "let x = read_int ()\nlet _ = (\n if x < 600 then \"8\" else\n if x < 800 then \"7\" else\n if x < 1000 then \"6\" else\n if x < 1200 then \"5\" else\n if x < 1400 then \"4\" else\n if x < 1600 then \"3\" else\n if x < 1800 then \"2\" else\n \"1\"\n) |> print_endline", "language": "OCaml", "metadata": {"date": 1595725353, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p02600.html", "problem_id": "p02600", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02600/input.txt", "sample_output_relpath": "derived/input_output/data/p02600/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02600/OCaml/s910460927.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s910460927", "user_id": "u511870776"}, "prompt_components": {"gold_output": "7\n", "input_to_evaluate": "let x = read_int ()\nlet _ = (\n if x < 600 then \"8\" else\n if x < 800 then \"7\" else\n if x < 1000 then \"6\" else\n if x < 1200 then \"5\" else\n if x < 1400 then \"4\" else\n if x < 1600 then \"3\" else\n if x < 1800 then \"2\" else\n \"1\"\n) |> print_endline", "problem_context": "Score: 100 points\n\nProblem Statement\n\nM-kun is a competitor in AtCoder, whose highest rating is X.\n\nIn this site, a competitor is given a kyu (class) according to his/her highest rating. For ratings from 400 through 1999, the following kyus are given:\n\nFrom 400 through 599: 8-kyu\n\nFrom 600 through 799: 7-kyu\n\nFrom 800 through 999: 6-kyu\n\nFrom 1000 through 1199: 5-kyu\n\nFrom 1200 through 1399: 4-kyu\n\nFrom 1400 through 1599: 3-kyu\n\nFrom 1600 through 1799: 2-kyu\n\nFrom 1800 through 1999: 1-kyu\n\nWhat kyu does M-kun have?\n\nConstraints\n\n400 \\leq X \\leq 1999\n\nX is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX\n\nOutput\n\nPrint the kyu M-kun has, as an integer.\nFor example, if he has 8-kyu, print 8.\n\nSample Input 1\n\n725\n\nSample Output 1\n\n7\n\nM-kun's highest rating is 725, which corresponds to 7-kyu.\n\nThus, 7 is the correct output.\n\nSample Input 2\n\n1600\n\nSample Output 2\n\n2\n\nM-kun's highest rating is 1600, which corresponds to 2-kyu.\n\nThus, 2 is the correct output.", "sample_input": "725\n"}, "reference_outputs": ["7\n"], "source_document_id": "p02600", "source_text": "Score: 100 points\n\nProblem Statement\n\nM-kun is a competitor in AtCoder, whose highest rating is X.\n\nIn this site, a competitor is given a kyu (class) according to his/her highest rating. For ratings from 400 through 1999, the following kyus are given:\n\nFrom 400 through 599: 8-kyu\n\nFrom 600 through 799: 7-kyu\n\nFrom 800 through 999: 6-kyu\n\nFrom 1000 through 1199: 5-kyu\n\nFrom 1200 through 1399: 4-kyu\n\nFrom 1400 through 1599: 3-kyu\n\nFrom 1600 through 1799: 2-kyu\n\nFrom 1800 through 1999: 1-kyu\n\nWhat kyu does M-kun have?\n\nConstraints\n\n400 \\leq X \\leq 1999\n\nX is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX\n\nOutput\n\nPrint the kyu M-kun has, as an integer.\nFor example, if he has 8-kyu, print 8.\n\nSample Input 1\n\n725\n\nSample Output 1\n\n7\n\nM-kun's highest rating is 725, which corresponds to 7-kyu.\n\nThus, 7 is the correct output.\n\nSample Input 2\n\n1600\n\nSample Output 2\n\n2\n\nM-kun's highest rating is 1600, which corresponds to 2-kyu.\n\nThus, 2 is the correct output.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 7, "memory_kb": 3612}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s437501220", "group_id": "codeNet:p02601", "input_text": "let a, b, c = Scanf.sscanf (read_line()) \"%d %d %d\" (fun a b c -> a,b,c)\nlet k = read_int ()\n\nlet rec loop red green blue i =\n if blue > green && green > red then \"Yes\" else \n if i >= k then \"No\" else (\n if red > green then loop red (green*2) blue (i+1) else\n loop red green (blue*2) (i+1)\n )\n\nlet () = print_endline @@ loop a b c 0\n", "language": "OCaml", "metadata": {"date": 1595725846, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p02601.html", "problem_id": "p02601", "resource_group": "low_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/OCaml/s437501220.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s437501220", "user_id": "u511870776"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "let a, b, c = Scanf.sscanf (read_line()) \"%d %d %d\" (fun a b c -> a,b,c)\nlet k = read_int ()\n\nlet rec loop red green blue i =\n if blue > green && green > red then \"Yes\" else \n if i >= k then \"No\" else (\n if red > green then loop red (green*2) blue (i+1) else\n loop red green (blue*2) (i+1)\n )\n\nlet () = print_endline @@ loop a b c 0\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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 342, "cpu_time_ms": 10, "memory_kb": 3748}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s744266008", "group_id": "codeNet:p02602", "input_text": "open Batteries\nlet n, k = Scanf.sscanf (read_line()) \"%d %d\" (fun n k -> n,k)\nlet a = Array.init n @@ fun _ -> Scanf.scanf \" %d\" @@ fun a -> a\n\nlet get_hyoutei start ed=\n let rec loop i result =\n if i > ed then result else (\n loop (i+1) result * a.(i)\n )\n in loop start 1\n\nlet rec hyoutei_loop i result =\n if i + k > n then List.rev result else (\n hyoutei_loop (i+1) (get_hyoutei i (i+k-1) :: result)\n )\n\nlet rec loop old lst =\n match lst with\n | [] -> ()\n | first :: rest ->\n if first > old then print_endline \"Yes\" else print_endline \"No\"; loop first rest\n\nlet r = hyoutei_loop 0 []\nlet () = loop (List.hd r) @@ List.tl r", "language": "OCaml", "metadata": {"date": 1595729111, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p02602.html", "problem_id": "p02602", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02602/input.txt", "sample_output_relpath": "derived/input_output/data/p02602/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02602/OCaml/s744266008.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s744266008", "user_id": "u511870776"}, "prompt_components": {"gold_output": "Yes\nNo\n", "input_to_evaluate": "open Batteries\nlet n, k = Scanf.sscanf (read_line()) \"%d %d\" (fun n k -> n,k)\nlet a = Array.init n @@ fun _ -> Scanf.scanf \" %d\" @@ fun a -> a\n\nlet get_hyoutei start ed=\n let rec loop i result =\n if i > ed then result else (\n loop (i+1) result * a.(i)\n )\n in loop start 1\n\nlet rec hyoutei_loop i result =\n if i + k > n then List.rev result else (\n hyoutei_loop (i+1) (get_hyoutei i (i+k-1) :: result)\n )\n\nlet rec loop old lst =\n match lst with\n | [] -> ()\n | first :: rest ->\n if first > old then print_endline \"Yes\" else print_endline \"No\"; loop first rest\n\nlet r = hyoutei_loop 0 []\nlet () = loop (List.hd r) @@ List.tl r", "problem_context": "Score: 300 points\n\nProblem Statement\n\nM-kun is a student in Aoki High School, where a year is divided into N terms.\n\nThere is an exam at the end of each term. According to the scores in those exams, a student is given a grade for each term, as follows:\n\nFor the first through (K-1)-th terms: not given.\n\nFor each of the K-th through N-th terms: the multiplication of the scores in the last K exams, including the exam in the graded term.\n\nM-kun scored A_i in the exam at the end of the i-th term.\n\nFor each i such that K+1 \\leq i \\leq N, determine whether his grade for the i-th term is strictly greater than the grade for the (i-1)-th term.\n\nConstraints\n\n2 \\leq N \\leq 200000\n\n1 \\leq K \\leq N-1\n\n1 \\leq A_i \\leq 10^{9}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nA_1 A_2 A_3 \\ldots A_N\n\nOutput\n\nPrint the answer in N-K lines.\n\nThe i-th line should contain Yes if the grade for the (K+i)-th term is greater than the grade for the (K+i-1)-th term, and No otherwise.\n\nSample Input 1\n\n5 3\n96 98 95 100 20\n\nSample Output 1\n\nYes\nNo\n\nHis grade for each term is computed as follows:\n\n3-rd term: (96 \\times 98 \\times 95) = 893760\n\n4-th term: (98 \\times 95 \\times 100) = 931000\n\n5-th term: (95 \\times 100 \\times 20) = 190000\n\nSample Input 2\n\n3 2\n1001 869120 1001\n\nSample Output 2\n\nNo\n\nNote that the output should be No if the grade for the 3-rd term is equal to the grade for the 2-nd term.\n\nSample Input 3\n\n15 7\n3 1 4 1 5 9 2 6 5 3 5 8 9 7 9\n\nSample Output 3\n\nYes\nYes\nNo\nYes\nYes\nNo\nYes\nYes", "sample_input": "5 3\n96 98 95 100 20\n"}, "reference_outputs": ["Yes\nNo\n"], "source_document_id": "p02602", "source_text": "Score: 300 points\n\nProblem Statement\n\nM-kun is a student in Aoki High School, where a year is divided into N terms.\n\nThere is an exam at the end of each term. According to the scores in those exams, a student is given a grade for each term, as follows:\n\nFor the first through (K-1)-th terms: not given.\n\nFor each of the K-th through N-th terms: the multiplication of the scores in the last K exams, including the exam in the graded term.\n\nM-kun scored A_i in the exam at the end of the i-th term.\n\nFor each i such that K+1 \\leq i \\leq N, determine whether his grade for the i-th term is strictly greater than the grade for the (i-1)-th term.\n\nConstraints\n\n2 \\leq N \\leq 200000\n\n1 \\leq K \\leq N-1\n\n1 \\leq A_i \\leq 10^{9}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nA_1 A_2 A_3 \\ldots A_N\n\nOutput\n\nPrint the answer in N-K lines.\n\nThe i-th line should contain Yes if the grade for the (K+i)-th term is greater than the grade for the (K+i-1)-th term, and No otherwise.\n\nSample Input 1\n\n5 3\n96 98 95 100 20\n\nSample Output 1\n\nYes\nNo\n\nHis grade for each term is computed as follows:\n\n3-rd term: (96 \\times 98 \\times 95) = 893760\n\n4-th term: (98 \\times 95 \\times 100) = 931000\n\n5-th term: (95 \\times 100 \\times 20) = 190000\n\nSample Input 2\n\n3 2\n1001 869120 1001\n\nSample Output 2\n\nNo\n\nNote that the output should be No if the grade for the 3-rd term is equal to the grade for the 2-nd term.\n\nSample Input 3\n\n15 7\n3 1 4 1 5 9 2 6 5 3 5 8 9 7 9\n\nSample Output 3\n\nYes\nYes\nNo\nYes\nYes\nNo\nYes\nYes", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 2206, "memory_kb": 16848}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s419301580", "group_id": "codeNet:p02603", "input_text": "let () =\n Scanf.scanf \"%d\\n\" @@ fun n ->\n let lst = Array.to_list (Array.init n @@ fun _ -> Scanf.scanf \"%d \" @@ fun d -> d) in\n let (bfr,(x,ans)) = List.fold_left\n (fun (bfr,(stock, money)) x ->\n if bfr < x then (x,(stock+(money/bfr), money - bfr*(money/bfr)))\n else (x, (0, money+bfr*stock))) (List.hd lst, (0, 1000)) (List.tl lst) in\n Printf.printf \"%d\\n\" (bfr*x+ans)", "language": "OCaml", "metadata": {"date": 1596672204, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p02603.html", "problem_id": "p02603", "resource_group": "low_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/OCaml/s419301580.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s419301580", "user_id": "u307426615"}, "prompt_components": {"gold_output": "1685\n", "input_to_evaluate": "let () =\n Scanf.scanf \"%d\\n\" @@ fun n ->\n let lst = Array.to_list (Array.init n @@ fun _ -> Scanf.scanf \"%d \" @@ fun d -> d) in\n let (bfr,(x,ans)) = List.fold_left\n (fun (bfr,(stock, money)) x ->\n if bfr < x then (x,(stock+(money/bfr), money - bfr*(money/bfr)))\n else (x, (0, money+bfr*stock))) (List.hd lst, (0, 1000)) (List.tl lst) in\n Printf.printf \"%d\\n\" (bfr*x+ans)", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 6, "memory_kb": 3812}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s232564005", "group_id": "codeNet:p02604", "input_text": "Scanf.scanf \"%d\" (fun n ->\n let xyp = Array.init n (fun _ -> Scanf.scanf \" %d %d %d\" (fun x y p -> x, y, p)) in\n\n let calc list =\n Array.fold_left (fun acc (x, y, p) ->\n let dist = \n List.fold_left (fun acc2 (flag, l) ->\n if flag then min acc2 (abs (x - l)) \n else min acc2 (abs (y - l))) max_int list\n in\n acc + dist * p) 0 xyp\n in\n let init = [ true, 0; false, 0 ] in\n let best = Array.make (n + 1) max_int in\n best.(0) <- calc init;\n\n let rec loop i c l =\n if i < n then (\n loop (i + 1) c l;\n let x, y, p = xyp.(i) in\n let l1 = ((true, x) :: l) in\n let l2 = ((false, y) :: l) in\n let q1 = calc l1 in\n let q2 = calc l2 in\n best.(c + 1) <- min best.(c + 1) (min q1 q2);\n loop (i + 1) (c + 1) l1;\n loop (i + 1) (c + 1) l2;\n )\n in\n loop 0 0 init;\n\n Array.iter (Printf.printf \"%d\\n\") best;\n)", "language": "OCaml", "metadata": {"date": 1595729568, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p02604.html", "problem_id": "p02604", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02604/input.txt", "sample_output_relpath": "derived/input_output/data/p02604/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02604/OCaml/s232564005.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s232564005", "user_id": "u342443598"}, "prompt_components": {"gold_output": "2900\n900\n0\n0\n", "input_to_evaluate": "Scanf.scanf \"%d\" (fun n ->\n let xyp = Array.init n (fun _ -> Scanf.scanf \" %d %d %d\" (fun x y p -> x, y, p)) in\n\n let calc list =\n Array.fold_left (fun acc (x, y, p) ->\n let dist = \n List.fold_left (fun acc2 (flag, l) ->\n if flag then min acc2 (abs (x - l)) \n else min acc2 (abs (y - l))) max_int list\n in\n acc + dist * p) 0 xyp\n in\n let init = [ true, 0; false, 0 ] in\n let best = Array.make (n + 1) max_int in\n best.(0) <- calc init;\n\n let rec loop i c l =\n if i < n then (\n loop (i + 1) c l;\n let x, y, p = xyp.(i) in\n let l1 = ((true, x) :: l) in\n let l2 = ((false, y) :: l) in\n let q1 = calc l1 in\n let q2 = calc l2 in\n best.(c + 1) <- min best.(c + 1) (min q1 q2);\n loop (i + 1) (c + 1) l1;\n loop (i + 1) (c + 1) l2;\n )\n in\n loop 0 0 init;\n\n Array.iter (Printf.printf \"%d\\n\") best;\n)", "problem_context": "Score: 500 points\n\nProblem Statement\n\nNew AtCoder City has an infinite grid of streets, as follows:\n\nAt the center of the city stands a clock tower. Let (0, 0) be the coordinates of this point.\n\nA straight street, which we will call East-West Main Street, runs east-west and passes the clock tower. It corresponds to the x-axis in the two-dimensional coordinate plane.\n\nThere are also other infinitely many streets parallel to East-West Main Street, with a distance of 1 between them. They correspond to the lines \\ldots, y = -2, y = -1, y = 1, y = 2, \\ldots in the two-dimensional coordinate plane.\n\nA straight street, which we will call North-South Main Street, runs north-south and passes the clock tower. It corresponds to the y-axis in the two-dimensional coordinate plane.\n\nThere are also other infinitely many streets parallel to North-South Main Street, with a distance of 1 between them. They correspond to the lines \\ldots, x = -2, x = -1, x = 1, x = 2, \\ldots in the two-dimensional coordinate plane.\n\nThere are N residential areas in New AtCoder City. The i-th area is located at the intersection with the coordinates (X_i, Y_i) and has a population of P_i. Each citizen in the city lives in one of these areas.\n\nThe city currently has only two railroads, stretching infinitely, one along East-West Main Street and the other along North-South Main Street.\n\nM-kun, the mayor, thinks that they are not enough for the commuters, so he decides to choose K streets and build a railroad stretching infinitely along each of those streets.\n\nLet the walking distance of each citizen be the distance from his/her residential area to the nearest railroad.\n\nM-kun wants to build railroads so that the sum of the walking distances of all citizens, S, is minimized.\n\nFor each K = 0, 1, 2, \\dots, N, what is the minimum possible value of S after building railroads?\n\nConstraints\n\n1 \\leq N \\leq 15\n\n-10 \\ 000 \\leq X_i \\leq 10 \\ 000\n\n-10 \\ 000 \\leq Y_i \\leq 10 \\ 000\n\n1 \\leq P_i \\leq 1 \\ 000 \\ 000\n\nThe locations of the N residential areas, (X_i, Y_i), are all distinct.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nX_1 Y_1 P_1\nX_2 Y_2 P_2\n: : :\nX_N Y_N P_N\n\nOutput\n\nPrint the answer in N+1 lines.\n\nThe i-th line (i = 1, \\ldots, N+1) should contain the minimum possible value of S after building railroads for the case K = i-1.\n\nSample Input 1\n\n3\n1 2 300\n3 3 600\n1 4 800\n\nSample Output 1\n\n2900\n900\n0\n0\n\nWhen K = 0, the residents of Area 1, 2, and 3 have to walk the distances of 1, 3, and 1, respectively, to reach a railroad.\n\nThus, the sum of the walking distances of all citizens, S, is 1 \\times 300 + 3 \\times 600 + 1 \\times 800 = 2900.\n\nWhen K = 1, if we build a railroad along the street corresponding to the line y = 4 in the coordinate plane, the walking distances of the citizens of Area 1, 2, and 3 become 1, 1, and 0, respectively.\n\nThen, S = 1 \\times 300 + 1 \\times 600 + 0 \\times 800 = 900.\n\nWe have many other options for where we build the railroad, but none of them makes S less than 900.\n\nWhen K = 2, if we build a railroad along the street corresponding to the lines x = 1 and x = 3 in the coordinate plane, all citizens can reach a railroad with the walking distance of 0, so S = 0. We can also have S = 0 when K = 3.\n\nThe figure below shows the optimal way to build railroads for the cases K = 0, 1, 2.\n\nThe street painted blue represents the roads along which we build railroads.\n\nSample Input 2\n\n5\n3 5 400\n5 3 700\n5 5 1000\n5 7 700\n7 5 400\n\nSample Output 2\n\n13800\n1600\n0\n0\n0\n0\n\nThe figure below shows the optimal way to build railroads for the cases K = 1, 2.\n\nSample Input 3\n\n6\n2 5 1000\n5 2 1100\n5 5 1700\n-2 -5 900\n-5 -2 600\n-5 -5 2200\n\nSample Output 3\n\n26700\n13900\n3200\n1200\n0\n0\n0\n\nThe figure below shows the optimal way to build railroads for the case K = 3.\n\nSample Input 4\n\n8\n2 2 286017\n3 1 262355\n2 -2 213815\n1 -3 224435\n-2 -2 136860\n-3 -1 239338\n-2 2 217647\n-1 3 141903\n\nSample Output 4\n\n2576709\n1569381\n868031\n605676\n366338\n141903\n0\n0\n0\n\nThe figure below shows the optimal way to build railroads for the case K = 4.", "sample_input": "3\n1 2 300\n3 3 600\n1 4 800\n"}, "reference_outputs": ["2900\n900\n0\n0\n"], "source_document_id": "p02604", "source_text": "Score: 500 points\n\nProblem Statement\n\nNew AtCoder City has an infinite grid of streets, as follows:\n\nAt the center of the city stands a clock tower. Let (0, 0) be the coordinates of this point.\n\nA straight street, which we will call East-West Main Street, runs east-west and passes the clock tower. It corresponds to the x-axis in the two-dimensional coordinate plane.\n\nThere are also other infinitely many streets parallel to East-West Main Street, with a distance of 1 between them. They correspond to the lines \\ldots, y = -2, y = -1, y = 1, y = 2, \\ldots in the two-dimensional coordinate plane.\n\nA straight street, which we will call North-South Main Street, runs north-south and passes the clock tower. It corresponds to the y-axis in the two-dimensional coordinate plane.\n\nThere are also other infinitely many streets parallel to North-South Main Street, with a distance of 1 between them. They correspond to the lines \\ldots, x = -2, x = -1, x = 1, x = 2, \\ldots in the two-dimensional coordinate plane.\n\nThere are N residential areas in New AtCoder City. The i-th area is located at the intersection with the coordinates (X_i, Y_i) and has a population of P_i. Each citizen in the city lives in one of these areas.\n\nThe city currently has only two railroads, stretching infinitely, one along East-West Main Street and the other along North-South Main Street.\n\nM-kun, the mayor, thinks that they are not enough for the commuters, so he decides to choose K streets and build a railroad stretching infinitely along each of those streets.\n\nLet the walking distance of each citizen be the distance from his/her residential area to the nearest railroad.\n\nM-kun wants to build railroads so that the sum of the walking distances of all citizens, S, is minimized.\n\nFor each K = 0, 1, 2, \\dots, N, what is the minimum possible value of S after building railroads?\n\nConstraints\n\n1 \\leq N \\leq 15\n\n-10 \\ 000 \\leq X_i \\leq 10 \\ 000\n\n-10 \\ 000 \\leq Y_i \\leq 10 \\ 000\n\n1 \\leq P_i \\leq 1 \\ 000 \\ 000\n\nThe locations of the N residential areas, (X_i, Y_i), are all distinct.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nX_1 Y_1 P_1\nX_2 Y_2 P_2\n: : :\nX_N Y_N P_N\n\nOutput\n\nPrint the answer in N+1 lines.\n\nThe i-th line (i = 1, \\ldots, N+1) should contain the minimum possible value of S after building railroads for the case K = i-1.\n\nSample Input 1\n\n3\n1 2 300\n3 3 600\n1 4 800\n\nSample Output 1\n\n2900\n900\n0\n0\n\nWhen K = 0, the residents of Area 1, 2, and 3 have to walk the distances of 1, 3, and 1, respectively, to reach a railroad.\n\nThus, the sum of the walking distances of all citizens, S, is 1 \\times 300 + 3 \\times 600 + 1 \\times 800 = 2900.\n\nWhen K = 1, if we build a railroad along the street corresponding to the line y = 4 in the coordinate plane, the walking distances of the citizens of Area 1, 2, and 3 become 1, 1, and 0, respectively.\n\nThen, S = 1 \\times 300 + 1 \\times 600 + 0 \\times 800 = 900.\n\nWe have many other options for where we build the railroad, but none of them makes S less than 900.\n\nWhen K = 2, if we build a railroad along the street corresponding to the lines x = 1 and x = 3 in the coordinate plane, all citizens can reach a railroad with the walking distance of 0, so S = 0. We can also have S = 0 when K = 3.\n\nThe figure below shows the optimal way to build railroads for the cases K = 0, 1, 2.\n\nThe street painted blue represents the roads along which we build railroads.\n\nSample Input 2\n\n5\n3 5 400\n5 3 700\n5 5 1000\n5 7 700\n7 5 400\n\nSample Output 2\n\n13800\n1600\n0\n0\n0\n0\n\nThe figure below shows the optimal way to build railroads for the cases K = 1, 2.\n\nSample Input 3\n\n6\n2 5 1000\n5 2 1100\n5 5 1700\n-2 -5 900\n-5 -2 600\n-5 -5 2200\n\nSample Output 3\n\n26700\n13900\n3200\n1200\n0\n0\n0\n\nThe figure below shows the optimal way to build railroads for the case K = 3.\n\nSample Input 4\n\n8\n2 2 286017\n3 1 262355\n2 -2 213815\n1 -3 224435\n-2 -2 136860\n-3 -1 239338\n-2 2 217647\n-1 3 141903\n\nSample Output 4\n\n2576709\n1569381\n868031\n605676\n366338\n141903\n0\n0\n0\n\nThe figure below shows the optimal way to build railroads for the case K = 4.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1034, "cpu_time_ms": 3308, "memory_kb": 5780}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s741651616", "group_id": "codeNet:p02607", "input_text": "open Printf\nopen Scanf\n\nlet id x = x\n\nlet n = scanf \"%d\"id\nlet ns = Array.init n (fun _ -> scanf \" %d\" id)\n\nlet run () =\n let result = ref 0 in\n for i = 0 to n - 1 do\n if (i + 1) mod 2 = 1 && ns.(i) mod 2 = 1 then incr result\n done;\n printf \"%d\\n\" !result\n\nlet () = run ()", "language": "OCaml", "metadata": {"date": 1594516169, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p02607.html", "problem_id": "p02607", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02607/input.txt", "sample_output_relpath": "derived/input_output/data/p02607/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02607/OCaml/s741651616.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s741651616", "user_id": "u809832909"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "open Printf\nopen Scanf\n\nlet id x = x\n\nlet n = scanf \"%d\"id\nlet ns = Array.init n (fun _ -> scanf \" %d\" id)\n\nlet run () =\n let result = ref 0 in\n for i = 0 to n - 1 do\n if (i + 1) mod 2 = 1 && ns.(i) mod 2 = 1 then incr result\n done;\n printf \"%d\\n\" !result\n\nlet () = run ()", "problem_context": "Score : 200 points\n\nProblem Statement\n\nWe have N squares assigned the numbers 1,2,3,\\ldots,N. Each square has an integer written on it, and the integer written on Square i is a_i.\n\nHow many squares i satisfy both of the following conditions?\n\nThe assigned number, i, is odd.\n\nThe written integer is odd.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N, a_i \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 \\cdots a_N\n\nOutput\n\nPrint the number of squares that satisfy both of the conditions.\n\nSample Input 1\n\n5\n1 3 4 5 7\n\nSample Output 1\n\n2\n\nTwo squares, Square 1 and 5, satisfy both of the conditions.\n\nFor Square 2 and 4, the assigned numbers are not odd.\n\nFor Square 3, the written integer is not odd.\n\nSample Input 2\n\n15\n13 76 46 15 50 98 93 77 31 43 84 90 6 24 14\n\nSample Output 2\n\n3", "sample_input": "5\n1 3 4 5 7\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02607", "source_text": "Score : 200 points\n\nProblem Statement\n\nWe have N squares assigned the numbers 1,2,3,\\ldots,N. Each square has an integer written on it, and the integer written on Square i is a_i.\n\nHow many squares i satisfy both of the following conditions?\n\nThe assigned number, i, is odd.\n\nThe written integer is odd.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N, a_i \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 \\cdots a_N\n\nOutput\n\nPrint the number of squares that satisfy both of the conditions.\n\nSample Input 1\n\n5\n1 3 4 5 7\n\nSample Output 1\n\n2\n\nTwo squares, Square 1 and 5, satisfy both of the conditions.\n\nFor Square 2 and 4, the assigned numbers are not odd.\n\nFor Square 3, the written integer is not odd.\n\nSample Input 2\n\n15\n13 76 46 15 50 98 93 77 31 43 84 90 6 24 14\n\nSample Output 2\n\n3", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 5, "memory_kb": 3828}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s950753129", "group_id": "codeNet:p02608", "input_text": "let create_int_array n = Array.init n (fun _ -> 0)\n\nlet calc x y z = x * x + y * y + z * z + x * y + y * z + z * x\n\nlet case x y z =\n if x = y then (if y = z then 1 else 3)\n else if y = z then 3\n else 6\n\nlet () =\n let n = read_int () in\n let a = create_int_array n in\n\n let rec f x =\n let k = 6 * x * x in\n if k <= n then\n let rec g y =\n let k = x * x + 3 * y * y + 2 * x * y in\n if n < k then f (x + 1)\n else\n let rec h z =\n let k = calc x y z in\n if n < k then g (y + 1)\n else\n let w = case x y z in\n a.(k - 1) <- a.(k - 1) + w;\n h (z + 1)\n in h y\n in g x\n in\n\n f 1;\n ignore (Array.map (fun i -> Printf.printf \"%d\\n\" i) a);\n ()\n", "language": "OCaml", "metadata": {"date": 1596422324, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p02608.html", "problem_id": "p02608", "resource_group": "low_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/OCaml/s950753129.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s950753129", "user_id": "u752907799"}, "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": "let create_int_array n = Array.init n (fun _ -> 0)\n\nlet calc x y z = x * x + y * y + z * z + x * y + y * z + z * x\n\nlet case x y z =\n if x = y then (if y = z then 1 else 3)\n else if y = z then 3\n else 6\n\nlet () =\n let n = read_int () in\n let a = create_int_array n in\n\n let rec f x =\n let k = 6 * x * x in\n if k <= n then\n let rec g y =\n let k = x * x + 3 * y * y + 2 * x * y in\n if n < k then f (x + 1)\n else\n let rec h z =\n let k = calc x y z in\n if n < k then g (y + 1)\n else\n let w = case x y z in\n a.(k - 1) <- a.(k - 1) + w;\n h (z + 1)\n in h y\n in g x\n in\n\n f 1;\n ignore (Array.map (fun i -> Printf.printf \"%d\\n\" i) a);\n ()\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nLet f(n) be the number of triples of integers (x,y,z) that satisfy both of the following conditions:\n\n1 \\leq x,y,z\n\nx^2 + y^2 + z^2 + xy + yz + zx = n\n\nGiven an integer N, find each of f(1),f(2),f(3),\\ldots,f(N).\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^4\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint N lines. The i-th line should contain the value f(i).\n\nSample Input 1\n\n20\n\nSample Output 1\n\n0\n0\n0\n0\n0\n1\n0\n0\n0\n0\n3\n0\n0\n0\n0\n0\n3\n3\n0\n0\n\nFor n=6, only (1,1,1) satisfies both of the conditions. Thus, f(6) = 1.\n\nFor n=11, three triples, (1,1,2), (1,2,1), and (2,1,1), satisfy both of the conditions. Thus, f(6) = 3.\n\nFor n=17, three triples, (1,2,2), (2,1,2), and (2,2,1), satisfy both of the conditions. Thus, f(17) = 3.\n\nFor n=18, three triples, (1,1,3), (1,3,1), and (3,1,1), satisfy both of the conditions. Thus, f(18) = 3.", "sample_input": "20\n"}, "reference_outputs": ["0\n0\n0\n0\n0\n1\n0\n0\n0\n0\n3\n0\n0\n0\n0\n0\n3\n3\n0\n0\n"], "source_document_id": "p02608", "source_text": "Score : 300 points\n\nProblem Statement\n\nLet f(n) be the number of triples of integers (x,y,z) that satisfy both of the following conditions:\n\n1 \\leq x,y,z\n\nx^2 + y^2 + z^2 + xy + yz + zx = n\n\nGiven an integer N, find each of f(1),f(2),f(3),\\ldots,f(N).\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^4\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint N lines. The i-th line should contain the value f(i).\n\nSample Input 1\n\n20\n\nSample Output 1\n\n0\n0\n0\n0\n0\n1\n0\n0\n0\n0\n3\n0\n0\n0\n0\n0\n3\n3\n0\n0\n\nFor n=6, only (1,1,1) satisfies both of the conditions. Thus, f(6) = 1.\n\nFor n=11, three triples, (1,1,2), (1,2,1), and (2,1,1), satisfy both of the conditions. Thus, f(6) = 3.\n\nFor n=17, three triples, (1,2,2), (2,1,2), and (2,2,1), satisfy both of the conditions. Thus, f(17) = 3.\n\nFor n=18, three triples, (1,1,3), (1,3,1), and (3,1,1), satisfy both of the conditions. Thus, f(18) = 3.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 767, "cpu_time_ms": 15, "memory_kb": 5616}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s030441260", "group_id": "codeNet:p02608", "input_text": "open Printf\nopen Scanf\n\nlet id x = x\nexception Break\n\nlet n = scanf \"%d\"id\n\nlet int_sqrt n = truncate (sqrt (float n))\n\nlet run () =\n let nn = Array.init (n + 1) (fun _ -> ref 0) in\n let max = int_sqrt n in\n begin\n try for x = 1 to max do\n try for y = 1 to max do\n try for z = 1 to max do\n let i = x * x + y * y + z * z + x * y + y * z + z * x in\n if i > n then begin\n raise Break\n end else incr (nn.(i))\n done with Break -> ()\n done with Break -> ()\n done with Break -> ()\n end;\n for i = 1 to n do\n printf \"%d\\n\" !(nn.(i))\n done\n \nlet () = run ()\n", "language": "OCaml", "metadata": {"date": 1594517843, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p02608.html", "problem_id": "p02608", "resource_group": "low_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/OCaml/s030441260.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s030441260", "user_id": "u809832909"}, "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": "open Printf\nopen Scanf\n\nlet id x = x\nexception Break\n\nlet n = scanf \"%d\"id\n\nlet int_sqrt n = truncate (sqrt (float n))\n\nlet run () =\n let nn = Array.init (n + 1) (fun _ -> ref 0) in\n let max = int_sqrt n in\n begin\n try for x = 1 to max do\n try for y = 1 to max do\n try for z = 1 to max do\n let i = x * x + y * y + z * z + x * y + y * z + z * x in\n if i > n then begin\n raise Break\n end else incr (nn.(i))\n done with Break -> ()\n done with Break -> ()\n done with Break -> ()\n end;\n for i = 1 to n do\n printf \"%d\\n\" !(nn.(i))\n done\n \nlet () = run ()\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nLet f(n) be the number of triples of integers (x,y,z) that satisfy both of the following conditions:\n\n1 \\leq x,y,z\n\nx^2 + y^2 + z^2 + xy + yz + zx = n\n\nGiven an integer N, find each of f(1),f(2),f(3),\\ldots,f(N).\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^4\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint N lines. The i-th line should contain the value f(i).\n\nSample Input 1\n\n20\n\nSample Output 1\n\n0\n0\n0\n0\n0\n1\n0\n0\n0\n0\n3\n0\n0\n0\n0\n0\n3\n3\n0\n0\n\nFor n=6, only (1,1,1) satisfies both of the conditions. Thus, f(6) = 1.\n\nFor n=11, three triples, (1,1,2), (1,2,1), and (2,1,1), satisfy both of the conditions. Thus, f(6) = 3.\n\nFor n=17, three triples, (1,2,2), (2,1,2), and (2,2,1), satisfy both of the conditions. Thus, f(17) = 3.\n\nFor n=18, three triples, (1,1,3), (1,3,1), and (3,1,1), satisfy both of the conditions. Thus, f(18) = 3.", "sample_input": "20\n"}, "reference_outputs": ["0\n0\n0\n0\n0\n1\n0\n0\n0\n0\n3\n0\n0\n0\n0\n0\n3\n3\n0\n0\n"], "source_document_id": "p02608", "source_text": "Score : 300 points\n\nProblem Statement\n\nLet f(n) be the number of triples of integers (x,y,z) that satisfy both of the following conditions:\n\n1 \\leq x,y,z\n\nx^2 + y^2 + z^2 + xy + yz + zx = n\n\nGiven an integer N, find each of f(1),f(2),f(3),\\ldots,f(N).\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^4\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint N lines. The i-th line should contain the value f(i).\n\nSample Input 1\n\n20\n\nSample Output 1\n\n0\n0\n0\n0\n0\n1\n0\n0\n0\n0\n3\n0\n0\n0\n0\n0\n3\n3\n0\n0\n\nFor n=6, only (1,1,1) satisfies both of the conditions. Thus, f(6) = 1.\n\nFor n=11, three triples, (1,1,2), (1,2,1), and (2,1,1), satisfy both of the conditions. Thus, f(6) = 3.\n\nFor n=17, three triples, (1,2,2), (2,1,2), and (2,2,1), satisfy both of the conditions. Thus, f(17) = 3.\n\nFor n=18, three triples, (1,1,3), (1,3,1), and (3,1,1), satisfy both of the conditions. Thus, f(18) = 3.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 722, "cpu_time_ms": 16, "memory_kb": 5856}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s055407877", "group_id": "codeNet:p02609", "input_text": "let popcnt x =\n let x = (x land 0x5555555555555555) + ((x lsr 1) land 0x5555555555555555) in\n let x = (x land 0x3333333333333333) + ((x lsr 2) land 0x3333333333333333) in\n let x = (x land 0x0f0f0f0f0f0f0f0f) + ((x lsr 4) land 0x0f0f0f0f0f0f0f0f) in\n let x = (x land 0x00ff00ff00ff00ff) + ((x lsr 8) land 0x00ff00ff00ff00ff) in\n let x = (x land 0x0000ffff0000ffff) + ((x lsr 16) land 0x0000ffff0000ffff) in\n (x land 0x00000000ffffffff) + ((x lsr 32) land 0x00000000ffffffff)\n\nlet rec power ( * ) e m n =\n if n <= 0 then e\n else power ( * ) (if n land 1 = 0 then e else m * e) (m * m) (n lsr 1)\n\nlet () = Scanf.scanf \"%d\\n%s\" @@ fun n x ->\n let x = Array.init n @@ String.get x in\n let dp = Array.make (n + 2) 0 in\n for i = 1 to n + 1 do\n dp.(i) <- 1 + dp.(i mod popcnt i)\n done;\n let pop = Array.fold_right (function '0' -> Fun.id | '1' -> succ) x 0 in\n let m0 = Array.fold_left (fun acc c -> (2 * acc + if c = '0' then 0 else 1) mod (pop + 1)) 0 x in\n let m1 = Array.fold_left (fun acc c -> (2 * acc + if c = '0' then 0 else 1) mod (pop - 1)) 0 x in\n Fun.flip Array.iteri x @@ fun i c ->\n let i = n - i - 1 in\n Printf.printf \"%d\\n\" @@\n succ @@\n Array.get dp @@\n if c = '0'\n then (m0 + power (fun x y -> (x * y) mod (pop + 1)) 1 2 i) mod (pop + 1)\n else (m1 + pop - 1 - power (fun x y -> (x * y) mod (pop - 1)) 1 2 i) mod (pop - 1)", "language": "OCaml", "metadata": {"date": 1594518022, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p02609.html", "problem_id": "p02609", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02609/input.txt", "sample_output_relpath": "derived/input_output/data/p02609/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02609/OCaml/s055407877.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s055407877", "user_id": "u504158101"}, "prompt_components": {"gold_output": "2\n1\n1\n", "input_to_evaluate": "let popcnt x =\n let x = (x land 0x5555555555555555) + ((x lsr 1) land 0x5555555555555555) in\n let x = (x land 0x3333333333333333) + ((x lsr 2) land 0x3333333333333333) in\n let x = (x land 0x0f0f0f0f0f0f0f0f) + ((x lsr 4) land 0x0f0f0f0f0f0f0f0f) in\n let x = (x land 0x00ff00ff00ff00ff) + ((x lsr 8) land 0x00ff00ff00ff00ff) in\n let x = (x land 0x0000ffff0000ffff) + ((x lsr 16) land 0x0000ffff0000ffff) in\n (x land 0x00000000ffffffff) + ((x lsr 32) land 0x00000000ffffffff)\n\nlet rec power ( * ) e m n =\n if n <= 0 then e\n else power ( * ) (if n land 1 = 0 then e else m * e) (m * m) (n lsr 1)\n\nlet () = Scanf.scanf \"%d\\n%s\" @@ fun n x ->\n let x = Array.init n @@ String.get x in\n let dp = Array.make (n + 2) 0 in\n for i = 1 to n + 1 do\n dp.(i) <- 1 + dp.(i mod popcnt i)\n done;\n let pop = Array.fold_right (function '0' -> Fun.id | '1' -> succ) x 0 in\n let m0 = Array.fold_left (fun acc c -> (2 * acc + if c = '0' then 0 else 1) mod (pop + 1)) 0 x in\n let m1 = Array.fold_left (fun acc c -> (2 * acc + if c = '0' then 0 else 1) mod (pop - 1)) 0 x in\n Fun.flip Array.iteri x @@ fun i c ->\n let i = n - i - 1 in\n Printf.printf \"%d\\n\" @@\n succ @@\n Array.get dp @@\n if c = '0'\n then (m0 + power (fun x y -> (x * y) mod (pop + 1)) 1 2 i) mod (pop + 1)\n else (m1 + pop - 1 - power (fun x y -> (x * y) mod (pop - 1)) 1 2 i) mod (pop - 1)", "problem_context": "Score : 400 points\n\nProblem Statement\n\nLet \\mathrm{popcount}(n) be the number of 1s in the binary representation of n.\nFor example, \\mathrm{popcount}(3) = 2, \\mathrm{popcount}(7) = 3, and \\mathrm{popcount}(0) = 0.\n\nLet f(n) be the number of times the following operation will be done when we repeat it until n becomes 0: \"replace n with the remainder when n is divided by \\mathrm{popcount}(n).\" (It can be proved that, under the constraints of this problem, n always becomes 0 after a finite number of operations.)\n\nFor example, when n=7, it becomes 0 after two operations, as follows:\n\n\\mathrm{popcount}(7)=3, so we divide 7 by 3 and replace it with the remainder, 1.\n\n\\mathrm{popcount}(1)=1, so we divide 1 by 1 and replace it with the remainder, 0.\n\nYou are given an integer X with N digits in binary.\nFor each integer i such that 1 \\leq i \\leq N, let X_i be what X becomes when the i-th bit from the top is inverted.\nFind f(X_1), f(X_2), \\ldots, f(X_N).\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\nX is an integer with N digits in binary, possibly with leading zeros.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nX\n\nOutput\n\nPrint N lines. The i-th line should contain the value f(X_i).\n\nSample Input 1\n\n3\n011\n\nSample Output 1\n\n2\n1\n1\n\nX_1 = 7, which will change as follows: 7 \\rightarrow 1 \\rightarrow 0. Thus, f(7) = 2.\n\nX_2 = 1, which will change as follows: 1 \\rightarrow 0. Thus, f(1) = 1.\n\nX_3 = 2, which will change as follows: 2 \\rightarrow 0. Thus, f(2) = 1.\n\nSample Input 2\n\n23\n00110111001011011001110\n\nSample Output 2\n\n2\n1\n2\n2\n1\n2\n2\n2\n2\n2\n2\n2\n2\n2\n2\n2\n2\n2\n2\n2\n2\n1\n3", "sample_input": "3\n011\n"}, "reference_outputs": ["2\n1\n1\n"], "source_document_id": "p02609", "source_text": "Score : 400 points\n\nProblem Statement\n\nLet \\mathrm{popcount}(n) be the number of 1s in the binary representation of n.\nFor example, \\mathrm{popcount}(3) = 2, \\mathrm{popcount}(7) = 3, and \\mathrm{popcount}(0) = 0.\n\nLet f(n) be the number of times the following operation will be done when we repeat it until n becomes 0: \"replace n with the remainder when n is divided by \\mathrm{popcount}(n).\" (It can be proved that, under the constraints of this problem, n always becomes 0 after a finite number of operations.)\n\nFor example, when n=7, it becomes 0 after two operations, as follows:\n\n\\mathrm{popcount}(7)=3, so we divide 7 by 3 and replace it with the remainder, 1.\n\n\\mathrm{popcount}(1)=1, so we divide 1 by 1 and replace it with the remainder, 0.\n\nYou are given an integer X with N digits in binary.\nFor each integer i such that 1 \\leq i \\leq N, let X_i be what X becomes when the i-th bit from the top is inverted.\nFind f(X_1), f(X_2), \\ldots, f(X_N).\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\nX is an integer with N digits in binary, possibly with leading zeros.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nX\n\nOutput\n\nPrint N lines. The i-th line should contain the value f(X_i).\n\nSample Input 1\n\n3\n011\n\nSample Output 1\n\n2\n1\n1\n\nX_1 = 7, which will change as follows: 7 \\rightarrow 1 \\rightarrow 0. Thus, f(7) = 2.\n\nX_2 = 1, which will change as follows: 1 \\rightarrow 0. Thus, f(1) = 1.\n\nX_3 = 2, which will change as follows: 2 \\rightarrow 0. Thus, f(2) = 1.\n\nSample Input 2\n\n23\n00110111001011011001110\n\nSample Output 2\n\n2\n1\n2\n2\n1\n2\n2\n2\n2\n2\n2\n2\n2\n2\n2\n2\n2\n2\n2\n2\n2\n1\n3", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1370, "cpu_time_ms": 146, "memory_kb": 9912}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s552333429", "group_id": "codeNet:p02613", "input_text": "open Printf\nopen Scanf\n\nlet id x = x\n\nlet print_ans (a, b, c, d) =\n printf \"AC x %d\\n\" a;\n printf \"WA x %d\\n\" b;\n printf \"TLE x %d\\n\" c;\n printf \"RE x %d\\n\" d\n\nlet solve n =\n let ss = List.init n (fun _ -> scanf \"%s \" id) in\n let ht = Hashtbl.create n in\n Hashtbl.replace ht \"AC\" 0;\n Hashtbl.replace ht \"WA\" 0;\n Hashtbl.replace ht \"TLE\" 0;\n Hashtbl.replace ht \"RE\" 0;\n List.iter (fun s -> let v = Hashtbl.find ht s in Hashtbl.replace ht s (v + 1)) ss;\n (Hashtbl.find ht \"AC\", Hashtbl.find ht \"WA\", Hashtbl.find ht \"TLE\", Hashtbl.find ht \"RE\")\n \n\nlet () =\n scanf \"%d \" solve |> print_ans\n", "language": "OCaml", "metadata": {"date": 1594153120, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p02613.html", "problem_id": "p02613", "resource_group": "low_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/OCaml/s552333429.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s552333429", "user_id": "u388783188"}, "prompt_components": {"gold_output": "AC x 3\nWA x 1\nTLE x 2\nRE x 0\n", "input_to_evaluate": "open Printf\nopen Scanf\n\nlet id x = x\n\nlet print_ans (a, b, c, d) =\n printf \"AC x %d\\n\" a;\n printf \"WA x %d\\n\" b;\n printf \"TLE x %d\\n\" c;\n printf \"RE x %d\\n\" d\n\nlet solve n =\n let ss = List.init n (fun _ -> scanf \"%s \" id) in\n let ht = Hashtbl.create n in\n Hashtbl.replace ht \"AC\" 0;\n Hashtbl.replace ht \"WA\" 0;\n Hashtbl.replace ht \"TLE\" 0;\n Hashtbl.replace ht \"RE\" 0;\n List.iter (fun s -> let v = Hashtbl.find ht s in Hashtbl.replace ht s (v + 1)) ss;\n (Hashtbl.find ht \"AC\", Hashtbl.find ht \"WA\", Hashtbl.find ht \"TLE\", Hashtbl.find ht \"RE\")\n \n\nlet () =\n scanf \"%d \" solve |> print_ans\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nTakahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A.\n\nThe problem has N test cases.\n\nFor each test case i (1\\leq i \\leq N), you are given a string S_i representing the verdict for that test case. Find the numbers of test cases for which the verdict is AC, WA, TLE, and RE, respectively.\n\nSee the Output section for the output format.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\nS_i is AC, WA, TLE, or RE.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS_1\n\\vdots\nS_N\n\nOutput\n\nLet C_0, C_1, C_2, and C_3 be the numbers of test cases for which the verdict is AC, WA, TLE, and RE, respectively. Print the following:\n\nAC x C_0\nWA x C_1\nTLE x C_2\nRE x C_3\n\nSample Input 1\n\n6\nAC\nTLE\nAC\nAC\nWA\nTLE\n\nSample Output 1\n\nAC x 3\nWA x 1\nTLE x 2\nRE x 0\n\nWe have 3, 1, 2, and 0 test case(s) for which the verdict is AC, WA, TLE, and RE, respectively.\n\nSample Input 2\n\n10\nAC\nAC\nAC\nAC\nAC\nAC\nAC\nAC\nAC\nAC\n\nSample Output 2\n\nAC x 10\nWA x 0\nTLE x 0\nRE x 0", "sample_input": "6\nAC\nTLE\nAC\nAC\nWA\nTLE\n"}, "reference_outputs": ["AC x 3\nWA x 1\nTLE x 2\nRE x 0\n"], "source_document_id": "p02613", "source_text": "Score : 200 points\n\nProblem Statement\n\nTakahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A.\n\nThe problem has N test cases.\n\nFor each test case i (1\\leq i \\leq N), you are given a string S_i representing the verdict for that test case. Find the numbers of test cases for which the verdict is AC, WA, TLE, and RE, respectively.\n\nSee the Output section for the output format.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\nS_i is AC, WA, TLE, or RE.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS_1\n\\vdots\nS_N\n\nOutput\n\nLet C_0, C_1, C_2, and C_3 be the numbers of test cases for which the verdict is AC, WA, TLE, and RE, respectively. Print the following:\n\nAC x C_0\nWA x C_1\nTLE x C_2\nRE x C_3\n\nSample Input 1\n\n6\nAC\nTLE\nAC\nAC\nWA\nTLE\n\nSample Output 1\n\nAC x 3\nWA x 1\nTLE x 2\nRE x 0\n\nWe have 3, 1, 2, and 0 test case(s) for which the verdict is AC, WA, TLE, and RE, respectively.\n\nSample Input 2\n\n10\nAC\nAC\nAC\nAC\nAC\nAC\nAC\nAC\nAC\nAC\n\nSample Output 2\n\nAC x 10\nWA x 0\nTLE x 0\nRE x 0", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 601, "cpu_time_ms": 48, "memory_kb": 12256}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s722637566", "group_id": "codeNet:p02615", "input_text": "let () = Scanf.scanf \"%d\\n\" @@ fun n ->\n let as_ = Array.init n @@ fun _ -> Scanf.scanf \"%d \" @@ fun a -> a in\n Array.sort (Fun.flip compare) as_;\n Printf.printf \"%d\\n\" @@\n Array.fold_left ( + ) as_.(1) @@\n Array.sub as_ 0 (n - 2)", "language": "OCaml", "metadata": {"date": 1594003340, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p02615.html", "problem_id": "p02615", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02615/input.txt", "sample_output_relpath": "derived/input_output/data/p02615/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02615/OCaml/s722637566.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s722637566", "user_id": "u504158101"}, "prompt_components": {"gold_output": "7\n", "input_to_evaluate": "let () = Scanf.scanf \"%d\\n\" @@ fun n ->\n let as_ = Array.init n @@ fun _ -> Scanf.scanf \"%d \" @@ fun a -> a in\n Array.sort (Fun.flip compare) as_;\n Printf.printf \"%d\\n\" @@\n Array.fold_left ( + ) as_.(1) @@\n Array.sub as_ 0 (n - 2)", "problem_context": "Score: 400 points\n\nProblem Statement\n\nQuickly after finishing the tutorial of the online game ATChat, you have decided to visit a particular place with N-1 players who happen to be there. These N players, including you, are numbered 1 through N, and the friendliness of Player i is A_i.\n\nThe N players will arrive at the place one by one in some order. To make sure nobody gets lost, you have set the following rule: players who have already arrived there should form a circle, and a player who has just arrived there should cut into the circle somewhere.\n\nWhen each player, except the first one to arrive, arrives at the place, the player gets comfort equal to the smaller of the friendliness of the clockwise adjacent player and that of the counter-clockwise adjacent player. The first player to arrive there gets the comfort of 0.\n\nWhat is the maximum total comfort the N players can get by optimally choosing the order of arrivals and the positions in the circle to cut into?\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq A_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 \\dots A_N\n\nOutput\n\nPrint the maximum total comfort the N players can get.\n\nSample Input 1\n\n4\n2 2 1 3\n\nSample Output 1\n\n7\n\nBy arriving at the place in the order Player 4, 2, 1, 3, and cutting into the circle as shown in the figure, they can get the total comfort of 7.\n\nThey cannot get the total comfort greater than 7, so the answer is 7.\n\nSample Input 2\n\n7\n1 1 1 1 1 1 1\n\nSample Output 2\n\n6", "sample_input": "4\n2 2 1 3\n"}, "reference_outputs": ["7\n"], "source_document_id": "p02615", "source_text": "Score: 400 points\n\nProblem Statement\n\nQuickly after finishing the tutorial of the online game ATChat, you have decided to visit a particular place with N-1 players who happen to be there. These N players, including you, are numbered 1 through N, and the friendliness of Player i is A_i.\n\nThe N players will arrive at the place one by one in some order. To make sure nobody gets lost, you have set the following rule: players who have already arrived there should form a circle, and a player who has just arrived there should cut into the circle somewhere.\n\nWhen each player, except the first one to arrive, arrives at the place, the player gets comfort equal to the smaller of the friendliness of the clockwise adjacent player and that of the counter-clockwise adjacent player. The first player to arrive there gets the comfort of 0.\n\nWhat is the maximum total comfort the N players can get by optimally choosing the order of arrivals and the positions in the circle to cut into?\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq A_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 \\dots A_N\n\nOutput\n\nPrint the maximum total comfort the N players can get.\n\nSample Input 1\n\n4\n2 2 1 3\n\nSample Output 1\n\n7\n\nBy arriving at the place in the order Player 4, 2, 1, 3, and cutting into the circle as shown in the figure, they can get the total comfort of 7.\n\nThey cannot get the total comfort greater than 7, so the answer is 7.\n\nSample Input 2\n\n7\n1 1 1 1 1 1 1\n\nSample Output 2\n\n6", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 117, "memory_kb": 9196}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s414617566", "group_id": "codeNet:p02616", "input_text": "Scanf.scanf \"%d %d\" (fun n k ->\n let a = Array.init n (fun _ -> Scanf.scanf \" %d\" (fun a -> a)) in\n Array.sort (fun a b -> compare (abs a) (abs b)) a;\n\n let z = 1_000_000_007 in\n\n let ( *@) a b = (((a * b) mod z) + z) mod z in\n\n let rec loop rest i m z p minm minp =\n if rest = 0 then m, z, p, minm, minp else\n let m = if a.(i) < 0 then m + 1 else m in\n let z = if a.(i) = 0 then z + 1 else z in\n let p = if a.(i) > 0 then p + 1 else p in\n loop (rest - 1) (i - 1) m z p (if a.(i) < 0 then i else minm) (if a.(i) > 0 then i else minp)\n in\n let m, z, p, minm, minp = loop k (n - 1) 0 0 0 n n in\n let prod f t =\n let rec loop i acc =\n if i > t then acc else loop (i + 1) (acc *@ a.(i))\n in\n loop f 1\n in\n let prod2 f t skip alter =\n let rec loop i acc =\n if i > t then acc else\n let acc = if i = skip then acc else acc *@ a.(i) in\n loop (i + 1) acc\n in\n loop f a.(alter)\n in\n Printf.printf \"%d\\n\" @@ if z > 0 then 0 else ( (* z = 0 *)\n if k = n then prod 0 (n - 1) else\n if m mod 2 = 0 then prod (n - k) (n - 1) else ( (* z = 0 && m % 2 = 1 *)\n let rec loop i maxm maxp zero =\n if i = n - k then maxm, maxp, zero else\n if a.(i) > 0 then loop (i + 1) maxm i zero else\n if a.(i) < 0 then loop (i + 1) i maxp zero else\n loop (i + 1) maxm maxp true\n in\n let maxm, maxp, zero = loop 0 (-1) (-1) false in\n (* case:\n * p > 0 && m % 2 = 1:\n * maxm >= 0 && maxp >= 0 -> compare prod / a.(minm) * a.(maxp)\n prod / a.(minp) * a.(maxm)\n * maxm >= 0 && maxp < 0 -> prod / a.(minp) * a.(maxm)\n * maxm < 0 && maxp >= 0 -> prod / a.(minm) * a.(maxp)\n * else -> 0\n * p = 0 && m % 2 = 1 && zero -> 0\n * p = 0 && m % 2 = 1 && !zero -> phase2\n *)\n if p > 0 then (\n if maxm >= 0 && maxp >= 0 then (\n if a.(maxp) * a.(minp) > a.(maxm) * a.(minm) then prod2 (n - k) (n - 1) minm maxp\n else prod2 (n - k) (n - 1) minp maxm\n ) else\n if maxm >= 0 && maxp < 0 then prod2 (n - k) (n - 1) minp maxm else\n if maxm < 0 && maxp >= 0 then prod2 (n - k) (n - 1) minm maxp else 0\n ) else if zero then 0 else prod 0 (k - 1)\n )\n )\n)", "language": "OCaml", "metadata": {"date": 1593981004, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p02616.html", "problem_id": "p02616", "resource_group": "low_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/OCaml/s414617566.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s414617566", "user_id": "u342443598"}, "prompt_components": {"gold_output": "12\n", "input_to_evaluate": "Scanf.scanf \"%d %d\" (fun n k ->\n let a = Array.init n (fun _ -> Scanf.scanf \" %d\" (fun a -> a)) in\n Array.sort (fun a b -> compare (abs a) (abs b)) a;\n\n let z = 1_000_000_007 in\n\n let ( *@) a b = (((a * b) mod z) + z) mod z in\n\n let rec loop rest i m z p minm minp =\n if rest = 0 then m, z, p, minm, minp else\n let m = if a.(i) < 0 then m + 1 else m in\n let z = if a.(i) = 0 then z + 1 else z in\n let p = if a.(i) > 0 then p + 1 else p in\n loop (rest - 1) (i - 1) m z p (if a.(i) < 0 then i else minm) (if a.(i) > 0 then i else minp)\n in\n let m, z, p, minm, minp = loop k (n - 1) 0 0 0 n n in\n let prod f t =\n let rec loop i acc =\n if i > t then acc else loop (i + 1) (acc *@ a.(i))\n in\n loop f 1\n in\n let prod2 f t skip alter =\n let rec loop i acc =\n if i > t then acc else\n let acc = if i = skip then acc else acc *@ a.(i) in\n loop (i + 1) acc\n in\n loop f a.(alter)\n in\n Printf.printf \"%d\\n\" @@ if z > 0 then 0 else ( (* z = 0 *)\n if k = n then prod 0 (n - 1) else\n if m mod 2 = 0 then prod (n - k) (n - 1) else ( (* z = 0 && m % 2 = 1 *)\n let rec loop i maxm maxp zero =\n if i = n - k then maxm, maxp, zero else\n if a.(i) > 0 then loop (i + 1) maxm i zero else\n if a.(i) < 0 then loop (i + 1) i maxp zero else\n loop (i + 1) maxm maxp true\n in\n let maxm, maxp, zero = loop 0 (-1) (-1) false in\n (* case:\n * p > 0 && m % 2 = 1:\n * maxm >= 0 && maxp >= 0 -> compare prod / a.(minm) * a.(maxp)\n prod / a.(minp) * a.(maxm)\n * maxm >= 0 && maxp < 0 -> prod / a.(minp) * a.(maxm)\n * maxm < 0 && maxp >= 0 -> prod / a.(minm) * a.(maxp)\n * else -> 0\n * p = 0 && m % 2 = 1 && zero -> 0\n * p = 0 && m % 2 = 1 && !zero -> phase2\n *)\n if p > 0 then (\n if maxm >= 0 && maxp >= 0 then (\n if a.(maxp) * a.(minp) > a.(maxm) * a.(minm) then prod2 (n - k) (n - 1) minm maxp\n else prod2 (n - k) (n - 1) minp maxm\n ) else\n if maxm >= 0 && maxp < 0 then prod2 (n - k) (n - 1) minp maxm else\n if maxm < 0 && maxp >= 0 then prod2 (n - k) (n - 1) minm maxp else 0\n ) else if zero then 0 else prod 0 (k - 1)\n )\n )\n)", "problem_context": "Score : 500 points\n\nProblem Statement\n\nGiven are N integers A_1,\\ldots,A_N.\n\nWe will choose exactly K of these elements. Find the maximum possible product of the chosen elements.\n\nThen, print the maximum product modulo (10^9+7), using an integer between 0 and 10^9+6 (inclusive).\n\nConstraints\n\n1 \\leq K \\leq N \\leq 2\\times 10^5\n\n|A_i| \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nA_1 \\ldots A_N\n\nOutput\n\nPrint the maximum product modulo (10^9+7), using an integer between 0 and 10^9+6 (inclusive).\n\nSample Input 1\n\n4 2\n1 2 -3 -4\n\nSample Output 1\n\n12\n\nThe possible products of the two chosen elements are 2, -3, -4, -6, -8, and 12, so the maximum product is 12.\n\nSample Input 2\n\n4 3\n-1 -2 -3 -4\n\nSample Output 2\n\n1000000001\n\nThe possible products of the three chosen elements are -24, -12, -8, and -6, so the maximum product is -6.\n\nWe print this value modulo (10^9+7), that is, 1000000001.\n\nSample Input 3\n\n2 1\n-1 1000000000\n\nSample Output 3\n\n1000000000\n\nThe possible products of the one chosen element are -1 and 1000000000, so the maximum product is 1000000000.\n\nSample Input 4\n\n10 10\n1000000000 100000000 10000000 1000000 100000 10000 1000 100 10 1\n\nSample Output 4\n\n999983200\n\nBe sure to print the product modulo (10^9+7).", "sample_input": "4 2\n1 2 -3 -4\n"}, "reference_outputs": ["12\n"], "source_document_id": "p02616", "source_text": "Score : 500 points\n\nProblem Statement\n\nGiven are N integers A_1,\\ldots,A_N.\n\nWe will choose exactly K of these elements. Find the maximum possible product of the chosen elements.\n\nThen, print the maximum product modulo (10^9+7), using an integer between 0 and 10^9+6 (inclusive).\n\nConstraints\n\n1 \\leq K \\leq N \\leq 2\\times 10^5\n\n|A_i| \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nA_1 \\ldots A_N\n\nOutput\n\nPrint the maximum product modulo (10^9+7), using an integer between 0 and 10^9+6 (inclusive).\n\nSample Input 1\n\n4 2\n1 2 -3 -4\n\nSample Output 1\n\n12\n\nThe possible products of the two chosen elements are 2, -3, -4, -6, -8, and 12, so the maximum product is 12.\n\nSample Input 2\n\n4 3\n-1 -2 -3 -4\n\nSample Output 2\n\n1000000001\n\nThe possible products of the three chosen elements are -24, -12, -8, and -6, so the maximum product is -6.\n\nWe print this value modulo (10^9+7), that is, 1000000001.\n\nSample Input 3\n\n2 1\n-1 1000000000\n\nSample Output 3\n\n1000000000\n\nThe possible products of the one chosen element are -1 and 1000000000, so the maximum product is 1000000000.\n\nSample Input 4\n\n10 10\n1000000000 100000000 10000000 1000000 100000 10000 1000 100 10 1\n\nSample Output 4\n\n999983200\n\nBe sure to print the product modulo (10^9+7).", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2688, "cpu_time_ms": 146, "memory_kb": 7504}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s604899184", "group_id": "codeNet:p02621", "input_text": "let a = Scanf.sscanf (read_line ()) \"%d\" @@ fun a -> a\n\nlet () = Printf.printf \"%d\" @@ a + a * a + a * a * a", "language": "OCaml", "metadata": {"date": 1594579088, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p02621.html", "problem_id": "p02621", "resource_group": "low_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/OCaml/s604899184.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s604899184", "user_id": "u811309788"}, "prompt_components": {"gold_output": "14\n", "input_to_evaluate": "let a = Scanf.sscanf (read_line ()) \"%d\" @@ fun a -> a\n\nlet () = Printf.printf \"%d\" @@ a + a * a + a * a * a", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 13, "memory_kb": 3788}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s707491416", "group_id": "codeNet:p02621", "input_text": "let () =\n Scanf.scanf \"%d\" @@ fun n ->\n Printf.printf \"%d\" (n + n * n + n * n * n)", "language": "OCaml", "metadata": {"date": 1593821271, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p02621.html", "problem_id": "p02621", "resource_group": "low_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/OCaml/s707491416.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s707491416", "user_id": "u326834569"}, "prompt_components": {"gold_output": "14\n", "input_to_evaluate": "let () =\n Scanf.scanf \"%d\" @@ fun n ->\n Printf.printf \"%d\" (n + n * n + n * n * n)", "problem_context": "Score : 100 points\n\nProblem Statement\n\nGiven an integer a as input, print the value a + a^2 + a^3.\n\nConstraints\n\n1 \\leq a \\leq 10\n\na is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\na\n\nOutput\n\nPrint the value a + a^2 + a^3 as an integer.\n\nSample Input 1\n\n2\n\nSample Output 1\n\n14\n\nWhen a = 2, we have a + a^2 + a^3 = 2 + 2^2 + 2^3 = 2 + 4 + 8 = 14.\n\nPrint the answer as an input. Outputs such as 14.0 will be judged as incorrect.\n\nSample Input 2\n\n10\n\nSample Output 2\n\n1110", "sample_input": "2\n"}, "reference_outputs": ["14\n"], "source_document_id": "p02621", "source_text": "Score : 100 points\n\nProblem Statement\n\nGiven an integer a as input, print the value a + a^2 + a^3.\n\nConstraints\n\n1 \\leq a \\leq 10\n\na is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\na\n\nOutput\n\nPrint the value a + a^2 + a^3 as an integer.\n\nSample Input 1\n\n2\n\nSample Output 1\n\n14\n\nWhen a = 2, we have a + a^2 + a^3 = 2 + 2^2 + 2^3 = 2 + 4 + 8 = 14.\n\nPrint the answer as an input. Outputs such as 14.0 will be judged as incorrect.\n\nSample Input 2\n\n10\n\nSample Output 2\n\n1110", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 6, "memory_kb": 3740}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s074384906", "group_id": "codeNet:p02627", "input_text": "(* unihernandez22\n * https://atcoder.jp/contests/abc171/tasks/abc171_a\n * implementation\n * *)\n\nlet is_uppercase = function\n 'A' .. 'Z' -> true\n | _ -> false;;\n\nPrintf.printf \"%c\\n\" @@\nScanf.scanf \"%c\" @@ fun a ->\n if is_uppercase a then 'A'\n else 'a';;\n", "language": "OCaml", "metadata": {"date": 1593662134, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p02627.html", "problem_id": "p02627", "resource_group": "low_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/OCaml/s074384906.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s074384906", "user_id": "u878654696"}, "prompt_components": {"gold_output": "A\n", "input_to_evaluate": "(* unihernandez22\n * https://atcoder.jp/contests/abc171/tasks/abc171_a\n * implementation\n * *)\n\nlet is_uppercase = function\n 'A' .. 'Z' -> true\n | _ -> false;;\n\nPrintf.printf \"%c\\n\" @@\nScanf.scanf \"%c\" @@ fun a ->\n if is_uppercase a then 'A'\n else 'a';;\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nAn uppercase or lowercase English letter \\alpha will be given as input.\nIf \\alpha is uppercase, print A; if it is lowercase, print a.\n\nConstraints\n\n\\alpha is an uppercase (A - Z) or lowercase (a - z) English letter.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nα\n\nOutput\n\nIf \\alpha is uppercase, print A; if it is lowercase, print a.\n\nSample Input 1\n\nB\n\nSample Output 1\n\nA\n\nB is uppercase, so we should print A.\n\nSample Input 2\n\na\n\nSample Output 2\n\na\n\na is lowercase, so we should print a.", "sample_input": "B\n"}, "reference_outputs": ["A\n"], "source_document_id": "p02627", "source_text": "Score : 100 points\n\nProblem Statement\n\nAn uppercase or lowercase English letter \\alpha will be given as input.\nIf \\alpha is uppercase, print A; if it is lowercase, print a.\n\nConstraints\n\n\\alpha is an uppercase (A - Z) or lowercase (a - z) English letter.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nα\n\nOutput\n\nIf \\alpha is uppercase, print A; if it is lowercase, print a.\n\nSample Input 1\n\nB\n\nSample Output 1\n\nA\n\nB is uppercase, so we should print A.\n\nSample Input 2\n\na\n\nSample Output 2\n\na\n\na is lowercase, so we should print a.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 266, "cpu_time_ms": 7, "memory_kb": 3744}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s362089165", "group_id": "codeNet:p02628", "input_text": "let () =\n Scanf.scanf \"%d %d\\n\" @@ fun n k ->\n let prr = Array.init n @@ fun _ -> Scanf.scanf \" %d\" @@ fun d -> d in\n let () = Array.fast_sort compare prr in\n let plst = Array.to_list prr in\n let rec sumk lst k = if k = 0 then 0 else (List.hd lst) + sumk (List.tl lst) (k-1) in\n Printf.printf \"%d\\n\" (sumk plst k)", "language": "OCaml", "metadata": {"date": 1593718947, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p02628.html", "problem_id": "p02628", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02628/input.txt", "sample_output_relpath": "derived/input_output/data/p02628/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02628/OCaml/s362089165.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s362089165", "user_id": "u307426615"}, "prompt_components": {"gold_output": "210\n", "input_to_evaluate": "let () =\n Scanf.scanf \"%d %d\\n\" @@ fun n k ->\n let prr = Array.init n @@ fun _ -> Scanf.scanf \" %d\" @@ fun d -> d in\n let () = Array.fast_sort compare prr in\n let plst = Array.to_list prr in\n let rec sumk lst k = if k = 0 then 0 else (List.hd lst) + sumk (List.tl lst) (k-1) in\n Printf.printf \"%d\\n\" (sumk plst k)", "problem_context": "Score : 200 points\n\nProblem Statement\n\nA shop sells N kinds of fruits, Fruit 1, \\ldots, N, at prices of p_1, \\ldots, p_N yen per item, respectively. (Yen is the currency of Japan.)\n\nHere, we will choose K kinds of fruits and buy one of each chosen kind. Find the minimum possible total price of those fruits.\n\nConstraints\n\n1 \\leq K \\leq N \\leq 1000\n\n1 \\leq p_i \\leq 1000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\np_1 p_2 \\ldots p_N\n\nOutput\n\nPrint an integer representing the minimum possible total price of fruits.\n\nSample Input 1\n\n5 3\n50 100 80 120 80\n\nSample Output 1\n\n210\n\nThis shop sells Fruit 1, 2, 3, 4, and 5 for 50 yen, 100 yen, 80 yen, 120 yen, and 80 yen, respectively.\n\nThe minimum total price for three kinds of fruits is 50 + 80 + 80 = 210 yen when choosing Fruit 1, 3, and 5.\n\nSample Input 2\n\n1 1\n1000\n\nSample Output 2\n\n1000", "sample_input": "5 3\n50 100 80 120 80\n"}, "reference_outputs": ["210\n"], "source_document_id": "p02628", "source_text": "Score : 200 points\n\nProblem Statement\n\nA shop sells N kinds of fruits, Fruit 1, \\ldots, N, at prices of p_1, \\ldots, p_N yen per item, respectively. (Yen is the currency of Japan.)\n\nHere, we will choose K kinds of fruits and buy one of each chosen kind. Find the minimum possible total price of those fruits.\n\nConstraints\n\n1 \\leq K \\leq N \\leq 1000\n\n1 \\leq p_i \\leq 1000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\np_1 p_2 \\ldots p_N\n\nOutput\n\nPrint an integer representing the minimum possible total price of fruits.\n\nSample Input 1\n\n5 3\n50 100 80 120 80\n\nSample Output 1\n\n210\n\nThis shop sells Fruit 1, 2, 3, 4, and 5 for 50 yen, 100 yen, 80 yen, 120 yen, and 80 yen, respectively.\n\nThe minimum total price for three kinds of fruits is 50 + 80 + 80 = 210 yen when choosing Fruit 1, 3, and 5.\n\nSample Input 2\n\n1 1\n1000\n\nSample Output 2\n\n1000", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 6, "memory_kb": 4168}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s004766358", "group_id": "codeNet:p02628", "input_text": "open Printf\nopen Scanf\n\nmodule L =\n struct\n include List\n \n let rec take n = function\n [] -> []\n | h :: t when n > 0 -> h :: take (n - 1) t\n | _ -> []\n\n let sum = fold_left (+) 0\n end\n\nlet id x = x\n\nlet solve n k =\n let ps = L.init n @@ fun _ -> scanf \"%d \" id in\n L.sum @@ L.take k @@ List.sort compare ps\n \nlet () =\n scanf \"%d %d \" solve |> printf \"%d\\n\"\n", "language": "OCaml", "metadata": {"date": 1592929644, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p02628.html", "problem_id": "p02628", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02628/input.txt", "sample_output_relpath": "derived/input_output/data/p02628/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02628/OCaml/s004766358.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s004766358", "user_id": "u388783188"}, "prompt_components": {"gold_output": "210\n", "input_to_evaluate": "open Printf\nopen Scanf\n\nmodule L =\n struct\n include List\n \n let rec take n = function\n [] -> []\n | h :: t when n > 0 -> h :: take (n - 1) t\n | _ -> []\n\n let sum = fold_left (+) 0\n end\n\nlet id x = x\n\nlet solve n k =\n let ps = L.init n @@ fun _ -> scanf \"%d \" id in\n L.sum @@ L.take k @@ List.sort compare ps\n \nlet () =\n scanf \"%d %d \" solve |> printf \"%d\\n\"\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nA shop sells N kinds of fruits, Fruit 1, \\ldots, N, at prices of p_1, \\ldots, p_N yen per item, respectively. (Yen is the currency of Japan.)\n\nHere, we will choose K kinds of fruits and buy one of each chosen kind. Find the minimum possible total price of those fruits.\n\nConstraints\n\n1 \\leq K \\leq N \\leq 1000\n\n1 \\leq p_i \\leq 1000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\np_1 p_2 \\ldots p_N\n\nOutput\n\nPrint an integer representing the minimum possible total price of fruits.\n\nSample Input 1\n\n5 3\n50 100 80 120 80\n\nSample Output 1\n\n210\n\nThis shop sells Fruit 1, 2, 3, 4, and 5 for 50 yen, 100 yen, 80 yen, 120 yen, and 80 yen, respectively.\n\nThe minimum total price for three kinds of fruits is 50 + 80 + 80 = 210 yen when choosing Fruit 1, 3, and 5.\n\nSample Input 2\n\n1 1\n1000\n\nSample Output 2\n\n1000", "sample_input": "5 3\n50 100 80 120 80\n"}, "reference_outputs": ["210\n"], "source_document_id": "p02628", "source_text": "Score : 200 points\n\nProblem Statement\n\nA shop sells N kinds of fruits, Fruit 1, \\ldots, N, at prices of p_1, \\ldots, p_N yen per item, respectively. (Yen is the currency of Japan.)\n\nHere, we will choose K kinds of fruits and buy one of each chosen kind. Find the minimum possible total price of those fruits.\n\nConstraints\n\n1 \\leq K \\leq N \\leq 1000\n\n1 \\leq p_i \\leq 1000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\np_1 p_2 \\ldots p_N\n\nOutput\n\nPrint an integer representing the minimum possible total price of fruits.\n\nSample Input 1\n\n5 3\n50 100 80 120 80\n\nSample Output 1\n\n210\n\nThis shop sells Fruit 1, 2, 3, 4, and 5 for 50 yen, 100 yen, 80 yen, 120 yen, and 80 yen, respectively.\n\nThe minimum total price for three kinds of fruits is 50 + 80 + 80 = 210 yen when choosing Fruit 1, 3, and 5.\n\nSample Input 2\n\n1 1\n1000\n\nSample Output 2\n\n1000", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 7, "memory_kb": 4372}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s459247614", "group_id": "codeNet:p02629", "input_text": "let () = Scanf.scanf \"%d\" @@ fun n ->\n let pow = Array.make 12 0 in\n pow.(0) <- 1;\n for i = 0 to 10 do\n pow.(i + 1) <- 26 * pow.(i)\n done;\n let rec aux n d (p :: ps) k =\n if n < p\n then k n d\n else aux (n - p) (d + 1) ps k in\n let rec solve acc n = function\n | 0 -> acc\n | d -> solve (Char.chr (Char.code 'a' + n mod 26) :: acc) (n / 26) (d - 1) in\n List.iter print_char @@ aux n 0 (Array.to_list pow) @@ solve ['\\n']\n\n", "language": "OCaml", "metadata": {"date": 1592796885, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p02629.html", "problem_id": "p02629", "resource_group": "low_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/OCaml/s459247614.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s459247614", "user_id": "u504158101"}, "prompt_components": {"gold_output": "b\n", "input_to_evaluate": "let () = Scanf.scanf \"%d\" @@ fun n ->\n let pow = Array.make 12 0 in\n pow.(0) <- 1;\n for i = 0 to 10 do\n pow.(i + 1) <- 26 * pow.(i)\n done;\n let rec aux n d (p :: ps) k =\n if n < p\n then k n d\n else aux (n - p) (d + 1) ps k in\n let rec solve acc n = function\n | 0 -> acc\n | d -> solve (Char.chr (Char.code 'a' + n mod 26) :: acc) (n / 26) (d - 1) in\n List.iter print_char @@ aux n 0 (Array.to_list pow) @@ solve ['\\n']\n\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\n1000000000000001 dogs suddenly appeared under the roof of Roger's house, all of which he decided to keep. The dogs had been numbered 1 through 1000000000000001, but he gave them new names, as follows:\n\nthe dogs numbered 1,2,\\cdots,26 were respectively given the names a, b, ..., z;\n\nthe dogs numbered 27,28,29,\\cdots,701,702 were respectively given the names aa, ab, ac, ..., zy, zz;\n\nthe dogs numbered 703,704,705,\\cdots,18277,18278 were respectively given the names aaa, aab, aac, ..., zzy, zzz;\n\nthe dogs numbered 18279,18280,18281,\\cdots,475253,475254 were respectively given the names aaaa, aaab, aaac, ..., zzzy, zzzz;\n\nthe dogs numbered 475255,475256,\\cdots were respectively given the names aaaaa, aaaab, ...;\n\nand so on.\n\nTo sum it up, the dogs numbered 1, 2, \\cdots were respectively given the following names:\n\na, b, ..., z, aa, ab, ..., az, ba, bb, ..., bz, ..., za, zb, ..., zz, aaa, aab, ..., aaz, aba, abb, ..., abz, ..., zzz, aaaa, ...\n\nNow, Roger asks you:\n\n\"What is the name for the dog numbered N?\"\n\nConstraints\n\nN is an integer.\n\n1 \\leq N \\leq 1000000000000001\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the answer to Roger's question as a string consisting of lowercase English letters.\n\nSample Input 1\n\n2\n\nSample Output 1\n\nb\n\nSample Input 2\n\n27\n\nSample Output 2\n\naa\n\nSample Input 3\n\n123456789\n\nSample Output 3\n\njjddja", "sample_input": "2\n"}, "reference_outputs": ["b\n"], "source_document_id": "p02629", "source_text": "Score : 300 points\n\nProblem Statement\n\n1000000000000001 dogs suddenly appeared under the roof of Roger's house, all of which he decided to keep. The dogs had been numbered 1 through 1000000000000001, but he gave them new names, as follows:\n\nthe dogs numbered 1,2,\\cdots,26 were respectively given the names a, b, ..., z;\n\nthe dogs numbered 27,28,29,\\cdots,701,702 were respectively given the names aa, ab, ac, ..., zy, zz;\n\nthe dogs numbered 703,704,705,\\cdots,18277,18278 were respectively given the names aaa, aab, aac, ..., zzy, zzz;\n\nthe dogs numbered 18279,18280,18281,\\cdots,475253,475254 were respectively given the names aaaa, aaab, aaac, ..., zzzy, zzzz;\n\nthe dogs numbered 475255,475256,\\cdots were respectively given the names aaaaa, aaaab, ...;\n\nand so on.\n\nTo sum it up, the dogs numbered 1, 2, \\cdots were respectively given the following names:\n\na, b, ..., z, aa, ab, ..., az, ba, bb, ..., bz, ..., za, zb, ..., zz, aaa, aab, ..., aaz, aba, abb, ..., abz, ..., zzz, aaaa, ...\n\nNow, Roger asks you:\n\n\"What is the name for the dog numbered N?\"\n\nConstraints\n\nN is an integer.\n\n1 \\leq N \\leq 1000000000000001\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the answer to Roger's question as a string consisting of lowercase English letters.\n\nSample Input 1\n\n2\n\nSample Output 1\n\nb\n\nSample Input 2\n\n27\n\nSample Output 2\n\naa\n\nSample Input 3\n\n123456789\n\nSample Output 3\n\njjddja", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 444, "cpu_time_ms": 7, "memory_kb": 3764}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s155291753", "group_id": "codeNet:p02629", "input_text": "let rec solve acc = function\n | 0 -> acc\n | n -> solve (Char.chr (Char.code 'a' + n mod 26) :: acc) (n / 26)\n\nlet () = Scanf.scanf \"%d\" @@ fun n ->\n let pow = Array.make 12 0 in\n pow.(0) <- 1;\n for i = 0 to 10 do\n pow.(i + 1) <- 26 * pow.(i)\n done;\n let rec aux d n (p :: ps) =\n if n < p\n then (d, n)\n else aux (d + 1) (n - p) ps in\n let rec solve acc n = function\n | 0 -> acc\n | d -> solve (Char.chr (Char.code 'a' + n mod 26) :: acc) (n / 26) (d - 1) in\n let (d, n) = aux 0 n @@ Array.to_list pow in\n List.iter print_char @@ solve ['\\n'] n d\n\n", "language": "OCaml", "metadata": {"date": 1592794563, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p02629.html", "problem_id": "p02629", "resource_group": "low_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/OCaml/s155291753.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s155291753", "user_id": "u504158101"}, "prompt_components": {"gold_output": "b\n", "input_to_evaluate": "let rec solve acc = function\n | 0 -> acc\n | n -> solve (Char.chr (Char.code 'a' + n mod 26) :: acc) (n / 26)\n\nlet () = Scanf.scanf \"%d\" @@ fun n ->\n let pow = Array.make 12 0 in\n pow.(0) <- 1;\n for i = 0 to 10 do\n pow.(i + 1) <- 26 * pow.(i)\n done;\n let rec aux d n (p :: ps) =\n if n < p\n then (d, n)\n else aux (d + 1) (n - p) ps in\n let rec solve acc n = function\n | 0 -> acc\n | d -> solve (Char.chr (Char.code 'a' + n mod 26) :: acc) (n / 26) (d - 1) in\n let (d, n) = aux 0 n @@ Array.to_list pow in\n List.iter print_char @@ solve ['\\n'] n d\n\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\n1000000000000001 dogs suddenly appeared under the roof of Roger's house, all of which he decided to keep. The dogs had been numbered 1 through 1000000000000001, but he gave them new names, as follows:\n\nthe dogs numbered 1,2,\\cdots,26 were respectively given the names a, b, ..., z;\n\nthe dogs numbered 27,28,29,\\cdots,701,702 were respectively given the names aa, ab, ac, ..., zy, zz;\n\nthe dogs numbered 703,704,705,\\cdots,18277,18278 were respectively given the names aaa, aab, aac, ..., zzy, zzz;\n\nthe dogs numbered 18279,18280,18281,\\cdots,475253,475254 were respectively given the names aaaa, aaab, aaac, ..., zzzy, zzzz;\n\nthe dogs numbered 475255,475256,\\cdots were respectively given the names aaaaa, aaaab, ...;\n\nand so on.\n\nTo sum it up, the dogs numbered 1, 2, \\cdots were respectively given the following names:\n\na, b, ..., z, aa, ab, ..., az, ba, bb, ..., bz, ..., za, zb, ..., zz, aaa, aab, ..., aaz, aba, abb, ..., abz, ..., zzz, aaaa, ...\n\nNow, Roger asks you:\n\n\"What is the name for the dog numbered N?\"\n\nConstraints\n\nN is an integer.\n\n1 \\leq N \\leq 1000000000000001\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the answer to Roger's question as a string consisting of lowercase English letters.\n\nSample Input 1\n\n2\n\nSample Output 1\n\nb\n\nSample Input 2\n\n27\n\nSample Output 2\n\naa\n\nSample Input 3\n\n123456789\n\nSample Output 3\n\njjddja", "sample_input": "2\n"}, "reference_outputs": ["b\n"], "source_document_id": "p02629", "source_text": "Score : 300 points\n\nProblem Statement\n\n1000000000000001 dogs suddenly appeared under the roof of Roger's house, all of which he decided to keep. The dogs had been numbered 1 through 1000000000000001, but he gave them new names, as follows:\n\nthe dogs numbered 1,2,\\cdots,26 were respectively given the names a, b, ..., z;\n\nthe dogs numbered 27,28,29,\\cdots,701,702 were respectively given the names aa, ab, ac, ..., zy, zz;\n\nthe dogs numbered 703,704,705,\\cdots,18277,18278 were respectively given the names aaa, aab, aac, ..., zzy, zzz;\n\nthe dogs numbered 18279,18280,18281,\\cdots,475253,475254 were respectively given the names aaaa, aaab, aaac, ..., zzzy, zzzz;\n\nthe dogs numbered 475255,475256,\\cdots were respectively given the names aaaaa, aaaab, ...;\n\nand so on.\n\nTo sum it up, the dogs numbered 1, 2, \\cdots were respectively given the following names:\n\na, b, ..., z, aa, ab, ..., az, ba, bb, ..., bz, ..., za, zb, ..., zz, aaa, aab, ..., aaz, aba, abb, ..., abz, ..., zzz, aaaa, ...\n\nNow, Roger asks you:\n\n\"What is the name for the dog numbered N?\"\n\nConstraints\n\nN is an integer.\n\n1 \\leq N \\leq 1000000000000001\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the answer to Roger's question as a string consisting of lowercase English letters.\n\nSample Input 1\n\n2\n\nSample Output 1\n\nb\n\nSample Input 2\n\n27\n\nSample Output 2\n\naa\n\nSample Input 3\n\n123456789\n\nSample Output 3\n\njjddja", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 573, "cpu_time_ms": 5, "memory_kb": 3740}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s568056768", "group_id": "codeNet:p02629", "input_text": "let n = Scanf.sscanf (read_line ()) \"%d\" @@ fun n -> n\n\nlet code_a = int_of_char 'a'\n\nlet char_of_code code = char_of_int (code_a + code)\n\nlet rec alp_of_int acc n =\n let acc = (n mod 26) :: acc in\n if n > 25 then alp_of_int acc (n / 26 - 1)\n else acc\n\nlet () = \n (n - 1) |> alp_of_int [] |> List.map char_of_code |> List.map Char.escaped |> String.concat \"\" |> print_endline", "language": "OCaml", "metadata": {"date": 1592792861, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p02629.html", "problem_id": "p02629", "resource_group": "low_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/OCaml/s568056768.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s568056768", "user_id": "u811309788"}, "prompt_components": {"gold_output": "b\n", "input_to_evaluate": "let n = Scanf.sscanf (read_line ()) \"%d\" @@ fun n -> n\n\nlet code_a = int_of_char 'a'\n\nlet char_of_code code = char_of_int (code_a + code)\n\nlet rec alp_of_int acc n =\n let acc = (n mod 26) :: acc in\n if n > 25 then alp_of_int acc (n / 26 - 1)\n else acc\n\nlet () = \n (n - 1) |> alp_of_int [] |> List.map char_of_code |> List.map Char.escaped |> String.concat \"\" |> print_endline", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 8, "memory_kb": 3732}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s357051972", "group_id": "codeNet:p02629", "input_text": "Scanf.scanf \"%d\" (fun n ->\n let n = n - 1 in\n let calc r digits =\n let rec loop r i acc =\n if i = 0 then acc else\n loop (r / 26) (i - 1) (Printf.sprintf \"%c%s\" (char_of_int ((r mod 26) + 97)) acc)\n in\n loop r digits \"\"\n in\n let rec loop p digits d k =\n if n < k then calc (n - p) digits else\n loop k (digits + 1) (d * 26) (k + d)\n in\n loop 0 1 (26 * 26) 26 |> print_endline\n)", "language": "OCaml", "metadata": {"date": 1592788153, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p02629.html", "problem_id": "p02629", "resource_group": "low_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/OCaml/s357051972.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s357051972", "user_id": "u342443598"}, "prompt_components": {"gold_output": "b\n", "input_to_evaluate": "Scanf.scanf \"%d\" (fun n ->\n let n = n - 1 in\n let calc r digits =\n let rec loop r i acc =\n if i = 0 then acc else\n loop (r / 26) (i - 1) (Printf.sprintf \"%c%s\" (char_of_int ((r mod 26) + 97)) acc)\n in\n loop r digits \"\"\n in\n let rec loop p digits d k =\n if n < k then calc (n - p) digits else\n loop k (digits + 1) (d * 26) (k + d)\n in\n loop 0 1 (26 * 26) 26 |> print_endline\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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 7, "memory_kb": 3744}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s201889219", "group_id": "codeNet:p02630", "input_text": "let () = Scanf.scanf \"%d\\n\" @@ fun n ->\n let sum = ref 0 in\n let cnt = Array.make 100001 0 in\n for i = 0 to n - 1 do\n Scanf.scanf \"%d \" @@ fun a ->\n sum := !sum + a;\n cnt.(a) <- cnt.(a) + 1\n done;\n Scanf.scanf \"%d\\n\" @@ fun q ->\n for i = 0 to q - 1 do\n Scanf.scanf \"%d %d\\n\" @@ fun b c ->\n sum := !sum + (c - b) * cnt.(b);\n cnt.(c) <- cnt.(c) + cnt.(b);\n cnt.(b) <- 0;\n Printf.printf \"%d\\n\" !sum\n done;", "language": "OCaml", "metadata": {"date": 1593316111, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p02630.html", "problem_id": "p02630", "resource_group": "low_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/OCaml/s201889219.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s201889219", "user_id": "u052332717"}, "prompt_components": {"gold_output": "11\n12\n16\n", "input_to_evaluate": "let () = Scanf.scanf \"%d\\n\" @@ fun n ->\n let sum = ref 0 in\n let cnt = Array.make 100001 0 in\n for i = 0 to n - 1 do\n Scanf.scanf \"%d \" @@ fun a ->\n sum := !sum + a;\n cnt.(a) <- cnt.(a) + 1\n done;\n Scanf.scanf \"%d\\n\" @@ fun q ->\n for i = 0 to q - 1 do\n Scanf.scanf \"%d %d\\n\" @@ fun b c ->\n sum := !sum + (c - b) * cnt.(b);\n cnt.(c) <- cnt.(c) + cnt.(b);\n cnt.(b) <- 0;\n Printf.printf \"%d\\n\" !sum\n done;", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 76, "memory_kb": 6780}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s055786936", "group_id": "codeNet:p02630", "input_text": "open Batteries\nlet n = read_int ()\nlet a = read_line () |> String.split_on_char ' ' |> List.map int_of_string\nlet q = read_int ()\n\nlet dp = Array.init 100010 @@ fun _ -> 0\nlet rec dp_loop lst result =\n match lst with\n | [] -> result\n | first :: rest -> dp.(first) <- dp.(first)+1; dp_loop rest (result+first)\nlet all = dp_loop a 0\n\nlet rec q_loop i now_all =\n if i >= q then () else (\n Scanf.sscanf (read_line()) \"%d %d\" (fun b c -> \n let new_all = (now_all - (dp.(b)*b) - (dp.(c)*c) + ((dp.(b)+dp.(c))*c)) in\n Printf.printf \"%d\\n\" new_all;\n (* Printf.printf \"dp(b)*b: %d, dp(b): %d\\n\" (dp.(b)*b) (dp.(b));\n Printf.printf \"dp(c)*c: %d, dp(c): %d\\n\" (dp.(c)*c) dp.(c); *)\n dp.(c) <- dp.(c) + dp.(b);\n dp.(b) <- 0;\n q_loop (i+1) new_all\n )\n )\n\nlet _ = q_loop 0 all", "language": "OCaml", "metadata": {"date": 1592790680, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p02630.html", "problem_id": "p02630", "resource_group": "low_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/OCaml/s055786936.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s055786936", "user_id": "u511870776"}, "prompt_components": {"gold_output": "11\n12\n16\n", "input_to_evaluate": "open Batteries\nlet n = read_int ()\nlet a = read_line () |> String.split_on_char ' ' |> List.map int_of_string\nlet q = read_int ()\n\nlet dp = Array.init 100010 @@ fun _ -> 0\nlet rec dp_loop lst result =\n match lst with\n | [] -> result\n | first :: rest -> dp.(first) <- dp.(first)+1; dp_loop rest (result+first)\nlet all = dp_loop a 0\n\nlet rec q_loop i now_all =\n if i >= q then () else (\n Scanf.sscanf (read_line()) \"%d %d\" (fun b c -> \n let new_all = (now_all - (dp.(b)*b) - (dp.(c)*c) + ((dp.(b)+dp.(c))*c)) in\n Printf.printf \"%d\\n\" new_all;\n (* Printf.printf \"dp(b)*b: %d, dp(b): %d\\n\" (dp.(b)*b) (dp.(b));\n Printf.printf \"dp(c)*c: %d, dp(c): %d\\n\" (dp.(c)*c) dp.(c); *)\n dp.(c) <- dp.(c) + dp.(b);\n dp.(b) <- 0;\n q_loop (i+1) new_all\n )\n )\n\nlet _ = q_loop 0 all", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 304, "memory_kb": 17400}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s382049413", "group_id": "codeNet:p02631", "input_text": "let () = Scanf.scanf \"%d\\n\" @@ fun n ->\n let as_ = Array.init n @@ fun _ -> Scanf.scanf \"%d \" @@ fun a -> a in\n let xor = Array.fold_left ( lxor ) 0 as_ in\n Array.iter (fun a -> Printf.printf \"%d \" @@ a lxor xor) as_;\n print_newline ()\n", "language": "OCaml", "metadata": {"date": 1592794595, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p02631.html", "problem_id": "p02631", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02631/input.txt", "sample_output_relpath": "derived/input_output/data/p02631/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02631/OCaml/s382049413.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s382049413", "user_id": "u504158101"}, "prompt_components": {"gold_output": "26 5 7 22\n", "input_to_evaluate": "let () = Scanf.scanf \"%d\\n\" @@ fun n ->\n let as_ = Array.init n @@ fun _ -> Scanf.scanf \"%d \" @@ fun a -> a in\n let xor = Array.fold_left ( lxor ) 0 as_ in\n Array.iter (fun a -> Printf.printf \"%d \" @@ a lxor xor) as_;\n print_newline ()\n", "problem_context": "Score : 500 points\n\nProblem Statement\n\nThere are N Snuke Cats numbered 1, 2, \\ldots, N, where N is even.\n\nEach Snuke Cat wears a red scarf, on which his favorite non-negative integer is written.\n\nRecently, they learned the operation called xor (exclusive OR).\n\nWhat is xor?\n\nFor n non-negative integers x_1, x_2, \\ldots, x_n, their xor, x_1~\\textrm{xor}~x_2~\\textrm{xor}~\\ldots~\\textrm{xor}~x_n is defined as follows:\n\nWhen x_1~\\textrm{xor}~x_2~\\textrm{xor}~\\ldots~\\textrm{xor}~x_n is written in base two, the digit in the 2^k's place (k \\geq 0) is 1 if the number of integers among x_1, x_2, \\ldots, x_n whose binary representations have 1 in the 2^k's place is odd, and 0 if that count is even.\n\nFor example, 3~\\textrm{xor}~5 = 6.\n\nThey wanted to use this operation quickly, so each of them calculated the xor of the integers written on their scarfs except his scarf.\n\nWe know that the xor calculated by Snuke Cat i, that is, the xor of the integers written on the scarfs except the scarf of Snuke Cat i is a_i.\nUsing this information, restore the integer written on the scarf of each Snuke Cat.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 200000\n\nN is even.\n\n0 \\leq a_i \\leq 10^9\n\nThere exists a combination of integers on the scarfs that is consistent with the given information.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 \\ldots a_N\n\nOutput\n\nPrint a line containing N integers separated with space.\n\nThe i-th of the integers from the left should represent the integer written on the scarf of Snuke Cat i.\n\nIf there are multiple possible solutions, you may print any of them.\n\nSample Input 1\n\n4\n20 11 9 24\n\nSample Output 1\n\n26 5 7 22\n\n5~\\textrm{xor}~7~\\textrm{xor}~22 = 20\n\n26~\\textrm{xor}~7~\\textrm{xor}~22 = 11\n\n26~\\textrm{xor}~5~\\textrm{xor}~22 = 9\n\n26~\\textrm{xor}~5~\\textrm{xor}~7 = 24\n\nThus, this output is consistent with the given information.", "sample_input": "4\n20 11 9 24\n"}, "reference_outputs": ["26 5 7 22\n"], "source_document_id": "p02631", "source_text": "Score : 500 points\n\nProblem Statement\n\nThere are N Snuke Cats numbered 1, 2, \\ldots, N, where N is even.\n\nEach Snuke Cat wears a red scarf, on which his favorite non-negative integer is written.\n\nRecently, they learned the operation called xor (exclusive OR).\n\nWhat is xor?\n\nFor n non-negative integers x_1, x_2, \\ldots, x_n, their xor, x_1~\\textrm{xor}~x_2~\\textrm{xor}~\\ldots~\\textrm{xor}~x_n is defined as follows:\n\nWhen x_1~\\textrm{xor}~x_2~\\textrm{xor}~\\ldots~\\textrm{xor}~x_n is written in base two, the digit in the 2^k's place (k \\geq 0) is 1 if the number of integers among x_1, x_2, \\ldots, x_n whose binary representations have 1 in the 2^k's place is odd, and 0 if that count is even.\n\nFor example, 3~\\textrm{xor}~5 = 6.\n\nThey wanted to use this operation quickly, so each of them calculated the xor of the integers written on their scarfs except his scarf.\n\nWe know that the xor calculated by Snuke Cat i, that is, the xor of the integers written on the scarfs except the scarf of Snuke Cat i is a_i.\nUsing this information, restore the integer written on the scarf of each Snuke Cat.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 200000\n\nN is even.\n\n0 \\leq a_i \\leq 10^9\n\nThere exists a combination of integers on the scarfs that is consistent with the given information.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 \\ldots a_N\n\nOutput\n\nPrint a line containing N integers separated with space.\n\nThe i-th of the integers from the left should represent the integer written on the scarf of Snuke Cat i.\n\nIf there are multiple possible solutions, you may print any of them.\n\nSample Input 1\n\n4\n20 11 9 24\n\nSample Output 1\n\n26 5 7 22\n\n5~\\textrm{xor}~7~\\textrm{xor}~22 = 20\n\n26~\\textrm{xor}~7~\\textrm{xor}~22 = 11\n\n26~\\textrm{xor}~5~\\textrm{xor}~22 = 9\n\n26~\\textrm{xor}~5~\\textrm{xor}~7 = 24\n\nThus, this output is consistent with the given information.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 240, "cpu_time_ms": 89, "memory_kb": 7620}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s282178066", "group_id": "codeNet:p02632", "input_text": "let rec power ( * ) e m n =\n if n <= 0 then e\n else power ( * ) (if n land 1 = 0 then e else m * e) (m * m) (n lsr 1)\n\nlet m = 1000000007\nlet ( +^ ) x y = (x + y) mod m\nlet ( -^ ) x y = x +^ (m - y)\nlet ( *^ ) x y = (x * y) mod m\nlet ( /^ ) x y = power ( *^ ) x y (m - 2)\n\nlet () = Scanf.scanf \"%d %s\" @@ fun k s ->\n (* comb.(i) = (|S| - 1 + i)C(|S| - 1) *)\n let comb = Array.make (k + 1) 0 in\n comb.(0) <- 1;\n for i = 1 to k do\n comb.(i) <- (String.length s - 1 + i) *^ comb.(i - 1) /^ i\n done;\n Printf.printf \"%d\\n\" @@\n Array.fold_left ( +^ ) (power ( *^ ) 1 26 k) @@\n Array.init k @@ fun i ->\n power ( *^ ) (power ( *^ ) comb.(k - i) 25 (k - i)) 26 i\n", "language": "OCaml", "metadata": {"date": 1592796297, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p02632.html", "problem_id": "p02632", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02632/input.txt", "sample_output_relpath": "derived/input_output/data/p02632/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02632/OCaml/s282178066.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s282178066", "user_id": "u504158101"}, "prompt_components": {"gold_output": "575111451\n", "input_to_evaluate": "let rec power ( * ) e m n =\n if n <= 0 then e\n else power ( * ) (if n land 1 = 0 then e else m * e) (m * m) (n lsr 1)\n\nlet m = 1000000007\nlet ( +^ ) x y = (x + y) mod m\nlet ( -^ ) x y = x +^ (m - y)\nlet ( *^ ) x y = (x * y) mod m\nlet ( /^ ) x y = power ( *^ ) x y (m - 2)\n\nlet () = Scanf.scanf \"%d %s\" @@ fun k s ->\n (* comb.(i) = (|S| - 1 + i)C(|S| - 1) *)\n let comb = Array.make (k + 1) 0 in\n comb.(0) <- 1;\n for i = 1 to k do\n comb.(i) <- (String.length s - 1 + i) *^ comb.(i - 1) /^ i\n done;\n Printf.printf \"%d\\n\" @@\n Array.fold_left ( +^ ) (power ( *^ ) 1 26 k) @@\n Array.init k @@ fun i ->\n power ( *^ ) (power ( *^ ) comb.(k - i) 25 (k - i)) 26 i\n", "problem_context": "Score: 600 points\n\nProblem Statement\n\nHow many strings can be obtained by applying the following operation on a string S exactly K times: \"choose one lowercase English letter and insert it somewhere\"?\n\nThe answer can be enormous, so print it modulo (10^9+7).\n\nConstraints\n\nK is an integer between 1 and 10^6 (inclusive).\n\nS is a string of length between 1 and 10^6 (inclusive) consisting of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK\nS\n\nOutput\n\nPrint the number of strings satisfying the condition, modulo (10^9+7).\n\nSample Input 1\n\n5\noof\n\nSample Output 1\n\n575111451\n\nFor example, we can obtain proofend, moonwolf, and onionpuf, while we cannot obtain oofsix, oofelevennn, voxafolt, or fooooooo.\n\nSample Input 2\n\n37564\nwhydidyoudesertme\n\nSample Output 2\n\n318008117", "sample_input": "5\noof\n"}, "reference_outputs": ["575111451\n"], "source_document_id": "p02632", "source_text": "Score: 600 points\n\nProblem Statement\n\nHow many strings can be obtained by applying the following operation on a string S exactly K times: \"choose one lowercase English letter and insert it somewhere\"?\n\nThe answer can be enormous, so print it modulo (10^9+7).\n\nConstraints\n\nK is an integer between 1 and 10^6 (inclusive).\n\nS is a string of length between 1 and 10^6 (inclusive) consisting of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK\nS\n\nOutput\n\nPrint the number of strings satisfying the condition, modulo (10^9+7).\n\nSample Input 1\n\n5\noof\n\nSample Output 1\n\n575111451\n\nFor example, we can obtain proofend, moonwolf, and onionpuf, while we cannot obtain oofsix, oofelevennn, voxafolt, or fooooooo.\n\nSample Input 2\n\n37564\nwhydidyoudesertme\n\nSample Output 2\n\n318008117", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 670, "cpu_time_ms": 587, "memory_kb": 22840}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s106431214", "group_id": "codeNet:p02633", "input_text": "Scanf.scanf \"%d\" (fun x ->\n let rec gcd a b = if b = 0 then a else gcd b (a mod b) in\n let lcm a b = a / gcd a b * b in\n\n let q = lcm x 360 in\n Printf.printf \"%d\\n\" @@ q / x\n)", "language": "OCaml", "metadata": {"date": 1593909118, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p02633.html", "problem_id": "p02633", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02633/input.txt", "sample_output_relpath": "derived/input_output/data/p02633/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02633/OCaml/s106431214.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s106431214", "user_id": "u342443598"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "Scanf.scanf \"%d\" (fun x ->\n let rec gcd a b = if b = 0 then a else gcd b (a mod b) in\n let lcm a b = a / gcd a b * b in\n\n let q = lcm x 360 in\n Printf.printf \"%d\\n\" @@ q / x\n)", "problem_context": "Score : 200 points\n\nProblem Statement\n\nTakahashi is standing on a two-dimensional plane, facing north. Find the minimum positive integer K such that Takahashi will be at the starting position again after he does the following action K times:\n\nGo one meter in the direction he is facing. Then, turn X degrees counter-clockwise.\n\nConstraints\n\n1 \\leq X \\leq 179\n\nX is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX\n\nOutput\n\nPrint the number of times Takahashi will do the action before he is at the starting position again.\n\nSample Input 1\n\n90\n\nSample Output 1\n\n4\n\nTakahashi's path is a square.\n\nSample Input 2\n\n1\n\nSample Output 2\n\n360", "sample_input": "90\n"}, "reference_outputs": ["4\n"], "source_document_id": "p02633", "source_text": "Score : 200 points\n\nProblem Statement\n\nTakahashi is standing on a two-dimensional plane, facing north. Find the minimum positive integer K such that Takahashi will be at the starting position again after he does the following action K times:\n\nGo one meter in the direction he is facing. Then, turn X degrees counter-clockwise.\n\nConstraints\n\n1 \\leq X \\leq 179\n\nX is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX\n\nOutput\n\nPrint the number of times Takahashi will do the action before he is at the starting position again.\n\nSample Input 1\n\n90\n\nSample Output 1\n\n4\n\nTakahashi's path is a square.\n\nSample Input 2\n\n1\n\nSample Output 2\n\n360", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 9, "memory_kb": 3796}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s237086567", "group_id": "codeNet:p02633", "input_text": "let rec gcd n m =\n if m = 0 then n else gcd m (n mod m)\n\nlet () = Scanf.scanf \"%d\\n\" @@ fun x ->\n Printf.printf \"%d\\n\" @@ 360 / gcd 360 x\n\n", "language": "OCaml", "metadata": {"date": 1592786891, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p02633.html", "problem_id": "p02633", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02633/input.txt", "sample_output_relpath": "derived/input_output/data/p02633/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02633/OCaml/s237086567.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s237086567", "user_id": "u504158101"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "let rec gcd n m =\n if m = 0 then n else gcd m (n mod m)\n\nlet () = Scanf.scanf \"%d\\n\" @@ fun x ->\n Printf.printf \"%d\\n\" @@ 360 / gcd 360 x\n\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nTakahashi is standing on a two-dimensional plane, facing north. Find the minimum positive integer K such that Takahashi will be at the starting position again after he does the following action K times:\n\nGo one meter in the direction he is facing. Then, turn X degrees counter-clockwise.\n\nConstraints\n\n1 \\leq X \\leq 179\n\nX is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX\n\nOutput\n\nPrint the number of times Takahashi will do the action before he is at the starting position again.\n\nSample Input 1\n\n90\n\nSample Output 1\n\n4\n\nTakahashi's path is a square.\n\nSample Input 2\n\n1\n\nSample Output 2\n\n360", "sample_input": "90\n"}, "reference_outputs": ["4\n"], "source_document_id": "p02633", "source_text": "Score : 200 points\n\nProblem Statement\n\nTakahashi is standing on a two-dimensional plane, facing north. Find the minimum positive integer K such that Takahashi will be at the starting position again after he does the following action K times:\n\nGo one meter in the direction he is facing. Then, turn X degrees counter-clockwise.\n\nConstraints\n\n1 \\leq X \\leq 179\n\nX is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX\n\nOutput\n\nPrint the number of times Takahashi will do the action before he is at the starting position again.\n\nSample Input 1\n\n90\n\nSample Output 1\n\n4\n\nTakahashi's path is a square.\n\nSample Input 2\n\n1\n\nSample Output 2\n\n360", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 3848}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s301431614", "group_id": "codeNet:p02639", "input_text": "open Batteries\nmodule EnumL = Enum.Labels\nmodule ListL = List.Labels\nmodule ArrayL = Array.Labels\n\nlet dbg0 x = Printf.eprintf \"[debug]%s\\n\" @@ dump x\nlet dbg1 x = dbg0 x; x\n\nlet id = identity\n\nlet (++) n m = if n <= m then List.range n `To m else []\nlet (++-) n m = if n >= m then List.range n `Downto m else []\nlet (++^) n m = if n < m then List.range n `To (pred m) else []\n\nlet scan fmt = Scanf.sscanf (read_line ()) fmt\n\nlet scan_lines n fmt f =\n if n = 0 then []\n else List.map (fun _ -> scan fmt f) (0 ++^ n)\n\nlet scan_list ?sep cnv =\n let line = read_line () in\n (match sep with\n | None -> List.map String.of_char @@ String.to_list line\n | Some sep -> String.split_on_char sep line)\n |> List.map cnv\nlet scan_array ?sep cnv = Array.of_list @@ scan_list ?sep cnv\nlet scan_matrix n m e ?sep conv =\n let arr = Array.make_matrix n m e in\n ListL.iter (0 ++^ n)\n ~f:(fun i -> arr.(i) <- Array.of_list @@ scan_list ?sep conv);\n arr\n\nlet atoi c = Char.code c - Char.code '0'\nlet itoa n = Char.chr (n + Char.code '0')\n\nlet between n x m = n <= x && x < m\n\n\n(* ===== MAIN ===== *)\n\nlet xs = scan_list ~sep:' ' int_of_string\n\nlet () =\n List.fold_lefti (fun state i x ->\n if (state >= 1) then state\n else if (x = 0) then (i+1)\n else (-1)) (-1) xs\n |> Printf.printf \"%d\\n\"\n\n", "language": "OCaml", "metadata": {"date": 1593902546, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p02639.html", "problem_id": "p02639", "resource_group": "low_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/OCaml/s301431614.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s301431614", "user_id": "u106804623"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "open Batteries\nmodule EnumL = Enum.Labels\nmodule ListL = List.Labels\nmodule ArrayL = Array.Labels\n\nlet dbg0 x = Printf.eprintf \"[debug]%s\\n\" @@ dump x\nlet dbg1 x = dbg0 x; x\n\nlet id = identity\n\nlet (++) n m = if n <= m then List.range n `To m else []\nlet (++-) n m = if n >= m then List.range n `Downto m else []\nlet (++^) n m = if n < m then List.range n `To (pred m) else []\n\nlet scan fmt = Scanf.sscanf (read_line ()) fmt\n\nlet scan_lines n fmt f =\n if n = 0 then []\n else List.map (fun _ -> scan fmt f) (0 ++^ n)\n\nlet scan_list ?sep cnv =\n let line = read_line () in\n (match sep with\n | None -> List.map String.of_char @@ String.to_list line\n | Some sep -> String.split_on_char sep line)\n |> List.map cnv\nlet scan_array ?sep cnv = Array.of_list @@ scan_list ?sep cnv\nlet scan_matrix n m e ?sep conv =\n let arr = Array.make_matrix n m e in\n ListL.iter (0 ++^ n)\n ~f:(fun i -> arr.(i) <- Array.of_list @@ scan_list ?sep conv);\n arr\n\nlet atoi c = Char.code c - Char.code '0'\nlet itoa n = Char.chr (n + Char.code '0')\n\nlet between n x m = n <= x && x < m\n\n\n(* ===== MAIN ===== *)\n\nlet xs = scan_list ~sep:' ' int_of_string\n\nlet () =\n List.fold_lefti (fun state i x ->\n if (state >= 1) then state\n else if (x = 0) then (i+1)\n else (-1)) (-1) xs\n |> Printf.printf \"%d\\n\"\n\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nWe have five variables x_1, x_2, x_3, x_4, and x_5.\n\nThe variable x_i was initially assigned a value of i.\n\nSnuke chose one of these variables and assigned it 0.\n\nYou are given the values of the five variables after this assignment.\n\nFind out which variable Snuke assigned 0.\n\nConstraints\n\nThe values of x_1, x_2, x_3, x_4, and x_5 given as input are a possible outcome of the assignment by Snuke.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nx_1 x_2 x_3 x_4 x_5\n\nOutput\n\nIf the variable Snuke assigned 0 was x_i, print the integer i.\n\nSample Input 1\n\n0 2 3 4 5\n\nSample Output 1\n\n1\n\nIn this case, Snuke assigned 0 to x_1, so we should print 1.\n\nSample Input 2\n\n1 2 0 4 5\n\nSample Output 2\n\n3", "sample_input": "0 2 3 4 5\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02639", "source_text": "Score : 100 points\n\nProblem Statement\n\nWe have five variables x_1, x_2, x_3, x_4, and x_5.\n\nThe variable x_i was initially assigned a value of i.\n\nSnuke chose one of these variables and assigned it 0.\n\nYou are given the values of the five variables after this assignment.\n\nFind out which variable Snuke assigned 0.\n\nConstraints\n\nThe values of x_1, x_2, x_3, x_4, and x_5 given as input are a possible outcome of the assignment by Snuke.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nx_1 x_2 x_3 x_4 x_5\n\nOutput\n\nIf the variable Snuke assigned 0 was x_i, print the integer i.\n\nSample Input 1\n\n0 2 3 4 5\n\nSample Output 1\n\n1\n\nIn this case, Snuke assigned 0 to x_1, so we should print 1.\n\nSample Input 2\n\n1 2 0 4 5\n\nSample Output 2\n\n3", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1302, "cpu_time_ms": 11, "memory_kb": 5324}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s299540186", "group_id": "codeNet:p02639", "input_text": "let x1,x2,x3,x4,x5 = Scanf.sscanf (read_line()) \"%d %d %d %d %d\" (fun q w e r t -> q,w,e,r,t)\nlet _ = (\n if x1 = 0 then \"1\" else\n if x2 = 0 then \"2\" else\n if x3 = 0 then \"3\" else\n if x4 = 0 then \"4\" else\n\"5\") |> print_endline", "language": "OCaml", "metadata": {"date": 1592182898, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p02639.html", "problem_id": "p02639", "resource_group": "low_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/OCaml/s299540186.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s299540186", "user_id": "u511870776"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "let x1,x2,x3,x4,x5 = Scanf.sscanf (read_line()) \"%d %d %d %d %d\" (fun q w e r t -> q,w,e,r,t)\nlet _ = (\n if x1 = 0 then \"1\" else\n if x2 = 0 then \"2\" else\n if x3 = 0 then \"3\" else\n if x4 = 0 then \"4\" else\n\"5\") |> print_endline", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 10, "memory_kb": 3716}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s954763359", "group_id": "codeNet:p02640", "input_text": "(*\nocamlfind ocamlopt -package batteries -linkpkg main.ml -o a.out\n*)\nopen Batteries\n\nlet x, y = Scanf.sscanf (read_line ()) \"%f %f\" ( fun x y -> x, y)\n\nlet kame = (y -. (2.0 *. x)) /. 2.0 \nlet tsuru = x -. kame\nlet () =\n (\n if kame = (ceil kame) && tsuru = (ceil tsuru) && kame >= 0.0 && tsuru >= 0.0 then\n \"Yes\"\n else\n \"No\"\n ) |> Printf.printf \"%s\\n\"\n", "language": "OCaml", "metadata": {"date": 1592183644, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p02640.html", "problem_id": "p02640", "resource_group": "low_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/OCaml/s954763359.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s954763359", "user_id": "u280335093"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "(*\nocamlfind ocamlopt -package batteries -linkpkg main.ml -o a.out\n*)\nopen Batteries\n\nlet x, y = Scanf.sscanf (read_line ()) \"%f %f\" ( fun x y -> x, y)\n\nlet kame = (y -. (2.0 *. x)) /. 2.0 \nlet tsuru = x -. kame\nlet () =\n (\n if kame = (ceil kame) && tsuru = (ceil tsuru) && kame >= 0.0 && tsuru >= 0.0 then\n \"Yes\"\n else\n \"No\"\n ) |> Printf.printf \"%s\\n\"\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nThere are some animals in a garden. Each of them is a crane with two legs or a turtle with four legs.\n\nTakahashi says: \"there are X animals in total in the garden, and they have Y legs in total.\" Determine whether there is a combination of numbers of cranes and turtles in which this statement is correct.\n\nConstraints\n\n1 \\leq X \\leq 100\n\n1 \\leq Y \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX Y\n\nOutput\n\nIf there is a combination of numbers of cranes and turtles in which the statement is correct, print Yes; otherwise, print No.\n\nSample Input 1\n\n3 8\n\nSample Output 1\n\nYes\n\nThe statement \"there are 3 animals in total in the garden, and they have 8 legs in total\" is correct if there are two cranes and one turtle. Thus, there is a combination of numbers of cranes and turtles in which the statement is correct.\n\nSample Input 2\n\n2 100\n\nSample Output 2\n\nNo\n\nThere is no combination of numbers of cranes and turtles in which this statement is correct.\n\nSample Input 3\n\n1 2\n\nSample Output 3\n\nYes\n\nWe also consider the case in which there are only cranes or only turtles.", "sample_input": "3 8\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02640", "source_text": "Score : 200 points\n\nProblem Statement\n\nThere are some animals in a garden. Each of them is a crane with two legs or a turtle with four legs.\n\nTakahashi says: \"there are X animals in total in the garden, and they have Y legs in total.\" Determine whether there is a combination of numbers of cranes and turtles in which this statement is correct.\n\nConstraints\n\n1 \\leq X \\leq 100\n\n1 \\leq Y \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX Y\n\nOutput\n\nIf there is a combination of numbers of cranes and turtles in which the statement is correct, print Yes; otherwise, print No.\n\nSample Input 1\n\n3 8\n\nSample Output 1\n\nYes\n\nThe statement \"there are 3 animals in total in the garden, and they have 8 legs in total\" is correct if there are two cranes and one turtle. Thus, there is a combination of numbers of cranes and turtles in which the statement is correct.\n\nSample Input 2\n\n2 100\n\nSample Output 2\n\nNo\n\nThere is no combination of numbers of cranes and turtles in which this statement is correct.\n\nSample Input 3\n\n1 2\n\nSample Output 3\n\nYes\n\nWe also consider the case in which there are only cranes or only turtles.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 8, "memory_kb": 5536}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s304548208", "group_id": "codeNet:p02644", "input_text": "\nlet () = Scanf.scanf \"%d %d %d\\n%d %d %d %d\\n\" @@ fun h w k x1 y1 x2 y2 ->\n let x1 = x1 - 1 in\n let x2 = x2 - 1 in\n let y1 = y1 - 1 in\n let y2 = y2 - 1 in\n let css = Array.init h @@ fun _ -> Scanf.scanf \"%s\\n\" Fun.id in\n let d =\n Array.init h @@ fun _ ->\n Array.init w @@ fun _ ->\n Array.init 5 @@ fun _ -> (max_int, max_int) in\n let es (i, j, s, dir) = \n List.filter_map (fun (i, j, dir') ->\n if i < 0 || h <= i || j < 0 || w <= j || css.(i).[j] = '@'\n then None\n else if dir = dir' && s < k\n then Some ((i, j, s + 1, dir'), false)\n else Some ((i, j, 1, dir'), true))\n [(i - 1, j, 1); (i + 1, j, 2); (i, j - 1, 3); (i, j + 1, 4)] in\n let rec bfs p = function\n | [] -> ()\n | vs -> bfs (p + 1) @@ List.fold_left (dfs p) [] vs\n and dfs p vs ((i, j, s, dir) as v) =\n if d.(i).(j).(dir) <= (p, s)\n then vs\n else begin\n d.(i).(j).(dir) <- (p, s);\n List.fold_left (fun vs (v, b) ->\n if b\n then v :: vs\n else dfs p vs v) vs (es v)\n end in\n bfs 0 [(x1, y1, 0, 0)];\n Printf.printf \"%d\\n\" @@\n (fun x -> if max_int <= x then -1 else x) @@\n fst @@ Array.fold_left min (max_int, max_int) d.(x2).(y2)\n\n", "language": "OCaml", "metadata": {"date": 1592190497, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p02644.html", "problem_id": "p02644", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02644/input.txt", "sample_output_relpath": "derived/input_output/data/p02644/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02644/OCaml/s304548208.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s304548208", "user_id": "u504158101"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "\nlet () = Scanf.scanf \"%d %d %d\\n%d %d %d %d\\n\" @@ fun h w k x1 y1 x2 y2 ->\n let x1 = x1 - 1 in\n let x2 = x2 - 1 in\n let y1 = y1 - 1 in\n let y2 = y2 - 1 in\n let css = Array.init h @@ fun _ -> Scanf.scanf \"%s\\n\" Fun.id in\n let d =\n Array.init h @@ fun _ ->\n Array.init w @@ fun _ ->\n Array.init 5 @@ fun _ -> (max_int, max_int) in\n let es (i, j, s, dir) = \n List.filter_map (fun (i, j, dir') ->\n if i < 0 || h <= i || j < 0 || w <= j || css.(i).[j] = '@'\n then None\n else if dir = dir' && s < k\n then Some ((i, j, s + 1, dir'), false)\n else Some ((i, j, 1, dir'), true))\n [(i - 1, j, 1); (i + 1, j, 2); (i, j - 1, 3); (i, j + 1, 4)] in\n let rec bfs p = function\n | [] -> ()\n | vs -> bfs (p + 1) @@ List.fold_left (dfs p) [] vs\n and dfs p vs ((i, j, s, dir) as v) =\n if d.(i).(j).(dir) <= (p, s)\n then vs\n else begin\n d.(i).(j).(dir) <- (p, s);\n List.fold_left (fun vs (v, b) ->\n if b\n then v :: vs\n else dfs p vs v) vs (es v)\n end in\n bfs 0 [(x1, y1, 0, 0)];\n Printf.printf \"%d\\n\" @@\n (fun x -> if max_int <= x then -1 else x) @@\n fst @@ Array.fold_left min (max_int, max_int) d.(x2).(y2)\n\n", "problem_context": "Score : 600 points\n\nProblem Statement\n\nSnuke, a water strider, lives in a rectangular pond that can be seen as a grid with H east-west rows and W north-south columns. Let (i,j) be the square at the i-th row from the north and j-th column from the west.\n\nSome of the squares have a lotus leaf on it and cannot be entered.\nThe square (i,j) has a lotus leaf on it if c_{ij} is @, and it does not if c_{ij} is ..\n\nIn one stroke, Snuke can move between 1 and K squares (inclusive) toward one of the four directions: north, east, south, and west.\nThe move may not pass through a square with a lotus leaf. Moving to such a square or out of the pond is also forbidden.\n\nFind the minimum number of strokes Snuke takes to travel from the square (x_1,y_1) to (x_2,y_2).\nIf the travel from (x_1,y_1) to (x_2,y_2) is impossible, point out that fact.\n\nConstraints\n\n1 \\leq H,W,K \\leq 10^6\n\nH \\times W \\leq 10^6\n\n1 \\leq x_1,x_2 \\leq H\n\n1 \\leq y_1,y_2 \\leq W\n\nx_1 \\neq x_2 or y_1 \\neq y_2.\n\nc_{i,j} is . or @.\n\nc_{x_1,y_1} = .\n\nc_{x_2,y_2} = .\n\nAll numbers in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W K\nx_1 y_1 x_2 y_2\nc_{1,1}c_{1,2} .. c_{1,W}\nc_{2,1}c_{2,2} .. c_{2,W}\n:\nc_{H,1}c_{H,2} .. c_{H,W}\n\nOutput\n\nPrint the minimum number of strokes Snuke takes to travel from the square (x_1,y_1) to (x_2,y_2), or print -1 if the travel is impossible.\n\nSample Input 1\n\n3 5 2\n3 2 3 4\n.....\n.@..@\n..@..\n\nSample Output 1\n\n5\n\nInitially, Snuke is at the square (3,2).\nHe can reach the square (3, 4) by making five strokes as follows:\n\nFrom (3, 2), go west one square to (3, 1).\n\nFrom (3, 1), go north two squares to (1, 1).\n\nFrom (1, 1), go east two squares to (1, 3).\n\nFrom (1, 3), go east one square to (1, 4).\n\nFrom (1, 4), go south two squares to (3, 4).\n\nSample Input 2\n\n1 6 4\n1 1 1 6\n......\n\nSample Output 2\n\n2\n\nSample Input 3\n\n3 3 1\n2 1 2 3\n.@.\n.@.\n.@.\n\nSample Output 3\n\n-1", "sample_input": "3 5 2\n3 2 3 4\n.....\n.@..@\n..@..\n"}, "reference_outputs": ["5\n"], "source_document_id": "p02644", "source_text": "Score : 600 points\n\nProblem Statement\n\nSnuke, a water strider, lives in a rectangular pond that can be seen as a grid with H east-west rows and W north-south columns. Let (i,j) be the square at the i-th row from the north and j-th column from the west.\n\nSome of the squares have a lotus leaf on it and cannot be entered.\nThe square (i,j) has a lotus leaf on it if c_{ij} is @, and it does not if c_{ij} is ..\n\nIn one stroke, Snuke can move between 1 and K squares (inclusive) toward one of the four directions: north, east, south, and west.\nThe move may not pass through a square with a lotus leaf. Moving to such a square or out of the pond is also forbidden.\n\nFind the minimum number of strokes Snuke takes to travel from the square (x_1,y_1) to (x_2,y_2).\nIf the travel from (x_1,y_1) to (x_2,y_2) is impossible, point out that fact.\n\nConstraints\n\n1 \\leq H,W,K \\leq 10^6\n\nH \\times W \\leq 10^6\n\n1 \\leq x_1,x_2 \\leq H\n\n1 \\leq y_1,y_2 \\leq W\n\nx_1 \\neq x_2 or y_1 \\neq y_2.\n\nc_{i,j} is . or @.\n\nc_{x_1,y_1} = .\n\nc_{x_2,y_2} = .\n\nAll numbers in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W K\nx_1 y_1 x_2 y_2\nc_{1,1}c_{1,2} .. c_{1,W}\nc_{2,1}c_{2,2} .. c_{2,W}\n:\nc_{H,1}c_{H,2} .. c_{H,W}\n\nOutput\n\nPrint the minimum number of strokes Snuke takes to travel from the square (x_1,y_1) to (x_2,y_2), or print -1 if the travel is impossible.\n\nSample Input 1\n\n3 5 2\n3 2 3 4\n.....\n.@..@\n..@..\n\nSample Output 1\n\n5\n\nInitially, Snuke is at the square (3,2).\nHe can reach the square (3, 4) by making five strokes as follows:\n\nFrom (3, 2), go west one square to (3, 1).\n\nFrom (3, 1), go north two squares to (1, 1).\n\nFrom (1, 1), go east two squares to (1, 3).\n\nFrom (1, 3), go east one square to (1, 4).\n\nFrom (1, 4), go south two squares to (3, 4).\n\nSample Input 2\n\n1 6 4\n1 1 1 6\n......\n\nSample Output 2\n\n2\n\nSample Input 3\n\n3 3 1\n2 1 2 3\n.@.\n.@.\n.@.\n\nSample Output 3\n\n-1", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1197, "cpu_time_ms": 3330, "memory_kb": 760216}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s789504209", "group_id": "codeNet:p02646", "input_text": "let () =\n Scanf.scanf \"%d %d\\n%d %d\\n%d\\n\" @@ fun a v b w t ->\n Printf.printf \"%s\\n\" (if v <= w || abs(a-b)/(v-w) >= t then \"NO\" else \"YES\")", "language": "OCaml", "metadata": {"date": 1598890207, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p02646.html", "problem_id": "p02646", "resource_group": "low_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/OCaml/s789504209.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s789504209", "user_id": "u307426615"}, "prompt_components": {"gold_output": "YES\n", "input_to_evaluate": "let () =\n Scanf.scanf \"%d %d\\n%d %d\\n%d\\n\" @@ fun a v b w t ->\n Printf.printf \"%s\\n\" (if v <= w || abs(a-b)/(v-w) >= t then \"NO\" else \"YES\")", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 9, "memory_kb": 3684}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s987843477", "group_id": "codeNet:p02648", "input_text": "let rec floor_sqrt acc acc_x_2_x_r sq_acc_minus_z r sq_r =\n if r = 0 then acc\n else\n let sq_acc_minus_z' = sq_acc_minus_z + acc_x_2_x_r + sq_r in\n ( if sq_acc_minus_z' <= 0 then\n floor_sqrt (acc + r) ((acc_x_2_x_r lsr 1) + sq_r) sq_acc_minus_z'\n else\n floor_sqrt acc (acc_x_2_x_r lsr 1) sq_acc_minus_z) (r lsr 1) (sq_r lsr 2)\nlet floor_sqrt z = floor_sqrt 0 0 (~-z) (1 lsl 30) (1 lsl 60)\n\nlet () = Scanf.scanf \"%d\\n\" @@ fun n ->\n let vs = Array.make n 0 in\n let ws = Array.make n 0 in\n for i = 0 to n - 1 do\n Scanf.scanf \"%d %d\\n\" @@ fun v w ->\n vs.(i) <- v;\n ws.(i) <- w\n done;\n Scanf.scanf \"%d\\n\" @@ fun q ->\n let vls = Array.init q @@ fun _ -> Scanf.scanf \"%d %d\\n\" @@ fun v l -> v, l in\n let maxl = Array.fold_right (fun (_, l) -> max l) vls min_int in\n let n' = floor_sqrt n in\n let dp = Bigarray.Array2.create Bigarray.int Bigarray.c_layout (n' + 1) (maxl + 1) in\n Bigarray.Array2.fill (Bigarray.Array2.sub_left dp 0 1) 0;\n for i = 1 to n' do\n let v = Array.unsafe_get vs (i - 1) in\n let w = Array.unsafe_get ws (i - 1) in\n Bigarray.Array2.blit\n (Bigarray.Array2.sub_left dp (i lsr 1) 1)\n (Bigarray.Array2.sub_left dp i 1);\n for j = w to maxl do\n let d = Bigarray.Array2.unsafe_get dp (i lsr 1) j in\n let d' = v + Bigarray.Array2.unsafe_get dp (i lsr 1) (j - w) in\n if d < d' then Bigarray.Array2.unsafe_set dp i j d'\n done\n done;\n let rec solve l i s m =\n if l < 0\n then m\n else if i <= n'\n then max m (s + Bigarray.Array2.unsafe_get dp i l)\n else solve l (i lsr 1) s @@ solve (l - Array.unsafe_get ws (i - 1)) (i lsr 1) (s + Array.unsafe_get vs (i - 1)) m in\n Array.iter (fun (v, l) -> Printf.printf \"%d\\n\" @@ solve l v 0 min_int) vls\n\n", "language": "OCaml", "metadata": {"date": 1592160370, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p02648.html", "problem_id": "p02648", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02648/input.txt", "sample_output_relpath": "derived/input_output/data/p02648/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02648/OCaml/s987843477.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s987843477", "user_id": "u504158101"}, "prompt_components": {"gold_output": "0\n3\n3\n", "input_to_evaluate": "let rec floor_sqrt acc acc_x_2_x_r sq_acc_minus_z r sq_r =\n if r = 0 then acc\n else\n let sq_acc_minus_z' = sq_acc_minus_z + acc_x_2_x_r + sq_r in\n ( if sq_acc_minus_z' <= 0 then\n floor_sqrt (acc + r) ((acc_x_2_x_r lsr 1) + sq_r) sq_acc_minus_z'\n else\n floor_sqrt acc (acc_x_2_x_r lsr 1) sq_acc_minus_z) (r lsr 1) (sq_r lsr 2)\nlet floor_sqrt z = floor_sqrt 0 0 (~-z) (1 lsl 30) (1 lsl 60)\n\nlet () = Scanf.scanf \"%d\\n\" @@ fun n ->\n let vs = Array.make n 0 in\n let ws = Array.make n 0 in\n for i = 0 to n - 1 do\n Scanf.scanf \"%d %d\\n\" @@ fun v w ->\n vs.(i) <- v;\n ws.(i) <- w\n done;\n Scanf.scanf \"%d\\n\" @@ fun q ->\n let vls = Array.init q @@ fun _ -> Scanf.scanf \"%d %d\\n\" @@ fun v l -> v, l in\n let maxl = Array.fold_right (fun (_, l) -> max l) vls min_int in\n let n' = floor_sqrt n in\n let dp = Bigarray.Array2.create Bigarray.int Bigarray.c_layout (n' + 1) (maxl + 1) in\n Bigarray.Array2.fill (Bigarray.Array2.sub_left dp 0 1) 0;\n for i = 1 to n' do\n let v = Array.unsafe_get vs (i - 1) in\n let w = Array.unsafe_get ws (i - 1) in\n Bigarray.Array2.blit\n (Bigarray.Array2.sub_left dp (i lsr 1) 1)\n (Bigarray.Array2.sub_left dp i 1);\n for j = w to maxl do\n let d = Bigarray.Array2.unsafe_get dp (i lsr 1) j in\n let d' = v + Bigarray.Array2.unsafe_get dp (i lsr 1) (j - w) in\n if d < d' then Bigarray.Array2.unsafe_set dp i j d'\n done\n done;\n let rec solve l i s m =\n if l < 0\n then m\n else if i <= n'\n then max m (s + Bigarray.Array2.unsafe_get dp i l)\n else solve l (i lsr 1) s @@ solve (l - Array.unsafe_get ws (i - 1)) (i lsr 1) (s + Array.unsafe_get vs (i - 1)) m in\n Array.iter (fun (v, l) -> Printf.printf \"%d\\n\" @@ solve l v 0 min_int) vls\n\n", "problem_context": "Score : 700 points\n\nProblem Statement\n\nWe have a rooted binary tree with N vertices, where the vertices are numbered 1 to N.\nVertex 1 is the root, and the parent of Vertex i (i \\geq 2) is Vertex \\left[ \\frac{i}{2} \\right].\n\nEach vertex has one item in it. The item in Vertex i has a value of V_i and a weight of W_i.\nNow, process the following query Q times:\n\nGiven are a vertex v of the tree and a positive integer L.\nLet us choose some (possibly none) of the items in v and the ancestors of v so that their total weight is at most L.\nFind the maximum possible total value of the chosen items.\n\nHere, Vertex u is said to be an ancestor of Vertex v when u is an indirect parent of v, that is, there exists a sequence of vertices w_1,w_2,\\ldots,w_k (k\\geq 2) where w_1=v, w_k=u, and w_{i+1} is the parent of w_i for each i.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N < 2^{18}\n\n1 \\leq Q \\leq 10^5\n\n1 \\leq V_i \\leq 10^5\n\n1 \\leq W_i \\leq 10^5\n\nFor the values v and L given in each query, 1 \\leq v \\leq N and 1 \\leq L \\leq 10^5.\n\nInput\n\nLet v_i and L_i be the values v and L given in the i-th query.\nThen, Input is given from Standard Input in the following format:\n\nN\nV_1 W_1\n:\nV_N W_N\nQ\nv_1 L_1\n:\nv_Q L_Q\n\nOutput\n\nFor each integer i from 1 through Q,\nthe i-th line should contain the response to the i-th query.\n\nSample Input 1\n\n3\n1 2\n2 3\n3 4\n3\n1 1\n2 5\n3 5\n\nSample Output 1\n\n0\n3\n3\n\nIn the first query, we are given only one choice: the item with (V, W)=(1,2). Since L = 1, we cannot actually choose it, so our response should be 0.\n\nIn the second query, we are given two choices: the items with (V, W)=(1,2) and (V, W)=(2,3). Since L = 5, we can choose both of them, so our response should be 3.\n\nSample Input 2\n\n15\n123 119\n129 120\n132 112\n126 109\n118 103\n115 109\n102 100\n130 120\n105 105\n132 115\n104 102\n107 107\n127 116\n121 104\n121 115\n8\n8 234\n9 244\n10 226\n11 227\n12 240\n13 237\n14 206\n15 227\n\nSample Output 2\n\n256\n255\n250\n247\n255\n259\n223\n253", "sample_input": "3\n1 2\n2 3\n3 4\n3\n1 1\n2 5\n3 5\n"}, "reference_outputs": ["0\n3\n3\n"], "source_document_id": "p02648", "source_text": "Score : 700 points\n\nProblem Statement\n\nWe have a rooted binary tree with N vertices, where the vertices are numbered 1 to N.\nVertex 1 is the root, and the parent of Vertex i (i \\geq 2) is Vertex \\left[ \\frac{i}{2} \\right].\n\nEach vertex has one item in it. The item in Vertex i has a value of V_i and a weight of W_i.\nNow, process the following query Q times:\n\nGiven are a vertex v of the tree and a positive integer L.\nLet us choose some (possibly none) of the items in v and the ancestors of v so that their total weight is at most L.\nFind the maximum possible total value of the chosen items.\n\nHere, Vertex u is said to be an ancestor of Vertex v when u is an indirect parent of v, that is, there exists a sequence of vertices w_1,w_2,\\ldots,w_k (k\\geq 2) where w_1=v, w_k=u, and w_{i+1} is the parent of w_i for each i.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N < 2^{18}\n\n1 \\leq Q \\leq 10^5\n\n1 \\leq V_i \\leq 10^5\n\n1 \\leq W_i \\leq 10^5\n\nFor the values v and L given in each query, 1 \\leq v \\leq N and 1 \\leq L \\leq 10^5.\n\nInput\n\nLet v_i and L_i be the values v and L given in the i-th query.\nThen, Input is given from Standard Input in the following format:\n\nN\nV_1 W_1\n:\nV_N W_N\nQ\nv_1 L_1\n:\nv_Q L_Q\n\nOutput\n\nFor each integer i from 1 through Q,\nthe i-th line should contain the response to the i-th query.\n\nSample Input 1\n\n3\n1 2\n2 3\n3 4\n3\n1 1\n2 5\n3 5\n\nSample Output 1\n\n0\n3\n3\n\nIn the first query, we are given only one choice: the item with (V, W)=(1,2). Since L = 1, we cannot actually choose it, so our response should be 0.\n\nIn the second query, we are given two choices: the items with (V, W)=(1,2) and (V, W)=(2,3). Since L = 5, we can choose both of them, so our response should be 3.\n\nSample Input 2\n\n15\n123 119\n129 120\n132 112\n126 109\n118 103\n115 109\n102 100\n130 120\n105 105\n132 115\n104 102\n107 107\n127 116\n121 104\n121 115\n8\n8 234\n9 244\n10 226\n11 227\n12 240\n13 237\n14 206\n15 227\n\nSample Output 2\n\n256\n255\n250\n247\n255\n259\n223\n253", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1801, "cpu_time_ms": 3320, "memory_kb": 414012}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s068562536", "group_id": "codeNet:p02657", "input_text": "Scanf.scanf \"%d %d\" (fun a b -> print_int (a * b))\n", "language": "OCaml", "metadata": {"date": 1592099553, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p02657.html", "problem_id": "p02657", "resource_group": "low_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/OCaml/s068562536.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s068562536", "user_id": "u752907799"}, "prompt_components": {"gold_output": "10\n", "input_to_evaluate": "Scanf.scanf \"%d %d\" (fun a b -> print_int (a * b))\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nCompute A \\times B.\n\nConstraints\n\n1 \\leq A \\leq 100\n\n1 \\leq B \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the value A \\times B as an integer.\n\nSample Input 1\n\n2 5\n\nSample Output 1\n\n10\n\nWe have 2 \\times 5 = 10.\n\nSample Input 2\n\n100 100\n\nSample Output 2\n\n10000", "sample_input": "2 5\n"}, "reference_outputs": ["10\n"], "source_document_id": "p02657", "source_text": "Score : 100 points\n\nProblem Statement\n\nCompute A \\times B.\n\nConstraints\n\n1 \\leq A \\leq 100\n\n1 \\leq B \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the value A \\times B as an integer.\n\nSample Input 1\n\n2 5\n\nSample Output 1\n\n10\n\nWe have 2 \\times 5 = 10.\n\nSample Input 2\n\n100 100\n\nSample Output 2\n\n10000", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 51, "cpu_time_ms": 9, "memory_kb": 3832}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s512161809", "group_id": "codeNet:p02661", "input_text": "let comp x y = \n if x > y then 1 else if x < y then -1 else 0\n\nlet () = Scanf.scanf \"%d\\n\" @@ fun n ->\n let as_ = Array.make n 0 in\n let bs_ = Array.make n 0 in\n let substitute i = \n Scanf.scanf \"%d %d\\n\" @@ fun a b ->\n Array.set as_ i a;\n Array.set bs_ i b;\n in\n ignore @@ Array.map substitute @@ (Array.init n @@ fun i -> i);\n ignore @@ Array.sort comp as_;\n ignore @@ Array.sort comp bs_;\n let res = \n if n mod 2 == 0\n then\n (Array.get bs_ @@ n / 2) + (Array.get bs_ @@ n / 2 - 1)\n - (Array.get as_ @@ n / 2) - (Array.get as_ @@ n / 2 - 1) + 1\n else\n (Array.get bs_ @@ n / 2) - (Array.get as_ @@ n / 2) + 1\n in\n ignore @@ Printf.printf \"%d\\n\" @@ res\n", "language": "OCaml", "metadata": {"date": 1595713311, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p02661.html", "problem_id": "p02661", "resource_group": "low_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/OCaml/s512161809.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s512161809", "user_id": "u592290074"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "let comp x y = \n if x > y then 1 else if x < y then -1 else 0\n\nlet () = Scanf.scanf \"%d\\n\" @@ fun n ->\n let as_ = Array.make n 0 in\n let bs_ = Array.make n 0 in\n let substitute i = \n Scanf.scanf \"%d %d\\n\" @@ fun a b ->\n Array.set as_ i a;\n Array.set bs_ i b;\n in\n ignore @@ Array.map substitute @@ (Array.init n @@ fun i -> i);\n ignore @@ Array.sort comp as_;\n ignore @@ Array.sort comp bs_;\n let res = \n if n mod 2 == 0\n then\n (Array.get bs_ @@ n / 2) + (Array.get bs_ @@ n / 2 - 1)\n - (Array.get as_ @@ n / 2) - (Array.get as_ @@ n / 2 - 1) + 1\n else\n (Array.get bs_ @@ n / 2) - (Array.get as_ @@ n / 2) + 1\n in\n ignore @@ Printf.printf \"%d\\n\" @@ res\n", "problem_context": "Score : 500 points\n\nProblem Statement\n\nThere are N integers X_1, X_2, \\cdots, X_N, and we know that A_i \\leq X_i \\leq B_i.\nFind the number of different values that the median of X_1, X_2, \\cdots, X_N can take.\n\nNotes\n\nThe median of X_1, X_2, \\cdots, X_N is defined as follows. Let x_1, x_2, \\cdots, x_N be the result of sorting X_1, X_2, \\cdots, X_N in ascending order.\n\nIf N is odd, the median is x_{(N+1)/2};\n\nif N is even, the median is (x_{N/2} + x_{N/2+1}) / 2.\n\nConstraints\n\n2 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq A_i \\leq B_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 B_1\nA_2 B_2\n:\nA_N B_N\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n2\n1 2\n2 3\n\nSample Output 1\n\n3\n\nIf X_1 = 1 and X_2 = 2, the median is \\frac{3}{2};\n\nif X_1 = 1 and X_2 = 3, the median is 2;\n\nif X_1 = 2 and X_2 = 2, the median is 2;\n\nif X_1 = 2 and X_2 = 3, the median is \\frac{5}{2}.\n\nThus, the median can take three values: \\frac{3}{2}, 2, and \\frac{5}{2}.\n\nSample Input 2\n\n3\n100 100\n10 10000\n1 1000000000\n\nSample Output 2\n\n9991", "sample_input": "2\n1 2\n2 3\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02661", "source_text": "Score : 500 points\n\nProblem Statement\n\nThere are N integers X_1, X_2, \\cdots, X_N, and we know that A_i \\leq X_i \\leq B_i.\nFind the number of different values that the median of X_1, X_2, \\cdots, X_N can take.\n\nNotes\n\nThe median of X_1, X_2, \\cdots, X_N is defined as follows. Let x_1, x_2, \\cdots, x_N be the result of sorting X_1, X_2, \\cdots, X_N in ascending order.\n\nIf N is odd, the median is x_{(N+1)/2};\n\nif N is even, the median is (x_{N/2} + x_{N/2+1}) / 2.\n\nConstraints\n\n2 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq A_i \\leq B_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 B_1\nA_2 B_2\n:\nA_N B_N\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n2\n1 2\n2 3\n\nSample Output 1\n\n3\n\nIf X_1 = 1 and X_2 = 2, the median is \\frac{3}{2};\n\nif X_1 = 1 and X_2 = 3, the median is 2;\n\nif X_1 = 2 and X_2 = 2, the median is 2;\n\nif X_1 = 2 and X_2 = 3, the median is \\frac{5}{2}.\n\nThus, the median can take three values: \\frac{3}{2}, 2, and \\frac{5}{2}.\n\nSample Input 2\n\n3\n100 100\n10 10000\n1 1000000000\n\nSample Output 2\n\n9991", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 769, "cpu_time_ms": 270, "memory_kb": 12340}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s872009691", "group_id": "codeNet:p02662", "input_text": "Scanf.scanf \"%d %d\" (fun n s ->\n let a = Array.init n (fun _ -> Scanf.scanf \" %d\" (fun a -> a)) in\n\n let m = 998244353 in\n let ( +@) a b = (a + b) mod m in\n let ( *@) a b = (a * b) mod m in\n\n let module M = Map.Make (struct type t = int let compare = compare end) in\n let dp = Array.make (n + 1) M.empty in\n let () = dp.(0) <- M.add 0 1 M.empty in\n\n for i = 0 to n - 1 do\n let c = a.(i) in\n for j = i downto 0 do\n dp.(j + 1) <-\n M.fold (fun k v acc ->\n if c + k > s then acc else\n M.add (c + k) (v +@ try M.find (c + k) acc with _ -> 0) acc) dp.(j) dp.(j + 1)\n done\n done;\n let powmod a b =\n let rec loop r i acc =\n if i = 0 then acc else\n loop (r *@ r) (i lsr 1) (if i land 1 = 1 then acc *@ r else acc)\n in\n loop a b 1\n in\n let rec loop k acc =\n if k > n then acc else\n let acc =\n if M.mem s dp.(k) then acc +@ M.find s dp.(k) *@ powmod 2 (n - k) else acc\n in\n loop (k + 1) acc\n in\n loop 1 0 |> Printf.printf \"%d\\n\"\n)", "language": "OCaml", "metadata": {"date": 1590978252, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p02662.html", "problem_id": "p02662", "resource_group": "low_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/OCaml/s872009691.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s872009691", "user_id": "u342443598"}, "prompt_components": {"gold_output": "6\n", "input_to_evaluate": "Scanf.scanf \"%d %d\" (fun n s ->\n let a = Array.init n (fun _ -> Scanf.scanf \" %d\" (fun a -> a)) in\n\n let m = 998244353 in\n let ( +@) a b = (a + b) mod m in\n let ( *@) a b = (a * b) mod m in\n\n let module M = Map.Make (struct type t = int let compare = compare end) in\n let dp = Array.make (n + 1) M.empty in\n let () = dp.(0) <- M.add 0 1 M.empty in\n\n for i = 0 to n - 1 do\n let c = a.(i) in\n for j = i downto 0 do\n dp.(j + 1) <-\n M.fold (fun k v acc ->\n if c + k > s then acc else\n M.add (c + k) (v +@ try M.find (c + k) acc with _ -> 0) acc) dp.(j) dp.(j + 1)\n done\n done;\n let powmod a b =\n let rec loop r i acc =\n if i = 0 then acc else\n loop (r *@ r) (i lsr 1) (if i land 1 = 1 then acc *@ r else acc)\n in\n loop a b 1\n in\n let rec loop k acc =\n if k > n then acc else\n let acc =\n if M.mem s dp.(k) then acc +@ M.find s dp.(k) *@ powmod 2 (n - k) else acc\n in\n loop (k + 1) acc\n in\n loop 1 0 |> Printf.printf \"%d\\n\"\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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 2206, "memory_kb": 12588}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s318323702", "group_id": "codeNet:p02663", "input_text": "open Batteries\nopen Printf\n\nlet ($) g f x = g (f x)\n\nmodule MyList = struct\n include List\n let foldl = fold_left\n let foldli = fold_lefti\n let foldr = fold_right\n let foldri = fold_righti\n \n let flatmap = concat_map\n\n let zipf = map2\n let zipfi = map2i\nend\n\nmodule L = MyList\n\nlet swap = Tuple2.swap\n\nlet atoi = int_of_string\nlet itoa = string_of_int\nlet atof = float_of_string\nlet ftoa = string_of_float\nlet ctoi = int_of_char\nlet itoc = char_of_int\n\nlet stocl = String.to_list\nlet cltos = String.of_list\nlet spsp s = String.split_on_char ' ' s\n\nmodule MyString = struct\n include String\n\n let map' f s = L.map f (stocl s)\n let mapi' f s = L.map f (stocl s)\n\n let zipf f a b = L.zipf f (stocl a) (stocl b)\n let zipfi f a b = L.zipfi f (stocl a) (stocl b)\n\n let mkstr f sep ls =\n L.foldl (fun acc x -> acc ^ sep ^ (f x)) (f @@ L.hd ls) (List.tl ls)\nend\n\nmodule S = MyString\n\nmodule MySet = struct\n include Set\n\n let fold' f s z = fold f z s\nend\n\nmodule St = MySet\n\nmodule MyMap = struct\n include Map\n\n let apply = find\n let apply_or = find_default\nend\n\nmodule Mp = MyMap\n\n\nlet rds () = read_line ()\n\nlet rdi () = atoi @@ rds ()\n\nlet rdhs () = spsp @@ rds ()\nlet rdhi () = rdhs () |> L.map atoi\n\nlet rdi2 () = match rdhi () with\n | a::b::_ -> (a, b)\n | _ -> (0, 0)\n\nlet rdi3 () = match rdhi () with\n| a::b::c::_ -> (a, b, c)\n| _ -> (0, 0, 0)\n\nlet rdi4 () = match rdhi () with\n| a::b::c::d::_ -> (a, b, c, d)\n| _ -> (0, 0, 0, 0)\n\nlet rdi5 () = match rdhi () with\n| a::b::c::d::e::_ -> (a, b, c, d, e)\n| _ -> (0, 0, 0, 0, 0)\n\nlet rdv n rdf =\n let rec rdv' n =\n if n <= 0 then []\n else (\n let s = rdf () in\n s::(rdv' (n - 1))\n )\n in rdv' n\n\nlet rdvi n = rdv n rdi\nlet rdvi2 n = rdv n rdi2\nlet rdvi3 n = rdv n rdi3\nlet rdvi4 n = rdv n rdi4\n\nlet puts s = print_endline s\nlet putyn b = puts (if b then \"Yes\" else \"No\")\nlet puti i = puts @@ itoa i\n\nlet set_power ls =\n let rec set_power' ls pls =\n match ls with\n | [] -> pls\n | hd::tl -> set_power' tl (L.flatmap (fun p -> [p; hd::p]) pls)\n in set_power' ls [[]]\n\n\nlet rdhf () = rdhs () |> L.map atof\nlet rdf4 () = match rdhf () with\n| a::b::c::d::_ -> (a, b, c, d)\n| _ -> (0., 0., 0., 0.)\n\n\nmodule Graph = struct\n\n type 'a t = { nb : (int, int St.t) Mp.t; vdt : (int, 'a) Mp.t }\n\n let nothing = { nb = Mp.empty; vdt = Mp.empty }\n\n let add_edge (e : int * int) g =\n let (v1, v2) = e in\n let nbvs = g.nb |> Mp.apply_or St.empty v1 in\n let nb1 = g.nb |> Mp.add v1 (nbvs |> St.add v2) in\n { g with nb = nb1 }\n\n let add_uedge e g =\n add_edge e (add_edge (swap e) g)\n\n let from_edges es =\n es |> L.foldl (fun g e -> add_edge e g) nothing\n\n let from_uedges es =\n es |> L.foldl (fun g e -> add_uedge e g) nothing\n\n\nend\n\nmodule G = Graph\n\n\nlet _ =\n let (h1, m1, h2, m2, k) = rdi5 () in\n let dif = (h2 * 60 + m2) - (h1 * 60 + m1) in\n puti @@ max 0 (dif - k)\n;;\n", "language": "OCaml", "metadata": {"date": 1590887212, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p02663.html", "problem_id": "p02663", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02663/input.txt", "sample_output_relpath": "derived/input_output/data/p02663/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02663/OCaml/s318323702.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s318323702", "user_id": "u970139668"}, "prompt_components": {"gold_output": "270\n", "input_to_evaluate": "open Batteries\nopen Printf\n\nlet ($) g f x = g (f x)\n\nmodule MyList = struct\n include List\n let foldl = fold_left\n let foldli = fold_lefti\n let foldr = fold_right\n let foldri = fold_righti\n \n let flatmap = concat_map\n\n let zipf = map2\n let zipfi = map2i\nend\n\nmodule L = MyList\n\nlet swap = Tuple2.swap\n\nlet atoi = int_of_string\nlet itoa = string_of_int\nlet atof = float_of_string\nlet ftoa = string_of_float\nlet ctoi = int_of_char\nlet itoc = char_of_int\n\nlet stocl = String.to_list\nlet cltos = String.of_list\nlet spsp s = String.split_on_char ' ' s\n\nmodule MyString = struct\n include String\n\n let map' f s = L.map f (stocl s)\n let mapi' f s = L.map f (stocl s)\n\n let zipf f a b = L.zipf f (stocl a) (stocl b)\n let zipfi f a b = L.zipfi f (stocl a) (stocl b)\n\n let mkstr f sep ls =\n L.foldl (fun acc x -> acc ^ sep ^ (f x)) (f @@ L.hd ls) (List.tl ls)\nend\n\nmodule S = MyString\n\nmodule MySet = struct\n include Set\n\n let fold' f s z = fold f z s\nend\n\nmodule St = MySet\n\nmodule MyMap = struct\n include Map\n\n let apply = find\n let apply_or = find_default\nend\n\nmodule Mp = MyMap\n\n\nlet rds () = read_line ()\n\nlet rdi () = atoi @@ rds ()\n\nlet rdhs () = spsp @@ rds ()\nlet rdhi () = rdhs () |> L.map atoi\n\nlet rdi2 () = match rdhi () with\n | a::b::_ -> (a, b)\n | _ -> (0, 0)\n\nlet rdi3 () = match rdhi () with\n| a::b::c::_ -> (a, b, c)\n| _ -> (0, 0, 0)\n\nlet rdi4 () = match rdhi () with\n| a::b::c::d::_ -> (a, b, c, d)\n| _ -> (0, 0, 0, 0)\n\nlet rdi5 () = match rdhi () with\n| a::b::c::d::e::_ -> (a, b, c, d, e)\n| _ -> (0, 0, 0, 0, 0)\n\nlet rdv n rdf =\n let rec rdv' n =\n if n <= 0 then []\n else (\n let s = rdf () in\n s::(rdv' (n - 1))\n )\n in rdv' n\n\nlet rdvi n = rdv n rdi\nlet rdvi2 n = rdv n rdi2\nlet rdvi3 n = rdv n rdi3\nlet rdvi4 n = rdv n rdi4\n\nlet puts s = print_endline s\nlet putyn b = puts (if b then \"Yes\" else \"No\")\nlet puti i = puts @@ itoa i\n\nlet set_power ls =\n let rec set_power' ls pls =\n match ls with\n | [] -> pls\n | hd::tl -> set_power' tl (L.flatmap (fun p -> [p; hd::p]) pls)\n in set_power' ls [[]]\n\n\nlet rdhf () = rdhs () |> L.map atof\nlet rdf4 () = match rdhf () with\n| a::b::c::d::_ -> (a, b, c, d)\n| _ -> (0., 0., 0., 0.)\n\n\nmodule Graph = struct\n\n type 'a t = { nb : (int, int St.t) Mp.t; vdt : (int, 'a) Mp.t }\n\n let nothing = { nb = Mp.empty; vdt = Mp.empty }\n\n let add_edge (e : int * int) g =\n let (v1, v2) = e in\n let nbvs = g.nb |> Mp.apply_or St.empty v1 in\n let nb1 = g.nb |> Mp.add v1 (nbvs |> St.add v2) in\n { g with nb = nb1 }\n\n let add_uedge e g =\n add_edge e (add_edge (swap e) g)\n\n let from_edges es =\n es |> L.foldl (fun g e -> add_edge e g) nothing\n\n let from_uedges es =\n es |> L.foldl (fun g e -> add_uedge e g) nothing\n\n\nend\n\nmodule G = Graph\n\n\nlet _ =\n let (h1, m1, h2, m2, k) = rdi5 () in\n let dif = (h2 * 60 + m2) - (h1 * 60 + m1) in\n puti @@ max 0 (dif - k)\n;;\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nIn this problem, we use the 24-hour clock.\n\nTakahashi gets up exactly at the time H_1 : M_1 and goes to bed exactly at the time H_2 : M_2. (See Sample Inputs below for clarity.)\nHe has decided to study for K consecutive minutes while he is up.\nWhat is the length of the period in which he can start studying?\n\nConstraints\n\n0 \\le H_1, H_2 \\le 23\n\n0 \\le M_1, M_2 \\le 59\n\nThe time H_1 : M_1 comes before the time H_2 : M_2.\n\nK \\ge 1\n\nTakahashi is up for at least K minutes.\n\nAll values in input are integers (without leading zeros).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH_1 M_1 H_2 M_2 K\n\nOutput\n\nPrint the length of the period in which he can start studying, as an integer.\n\nSample Input 1\n\n10 0 15 0 30\n\nSample Output 1\n\n270\n\nTakahashi gets up at exactly ten in the morning and goes to bed at exactly three in the afternoon.\nIt takes 30 minutes to do the study, so he can start it in the period between ten o'clock and half-past two. The length of this period is 270 minutes, so we should print 270.\n\nSample Input 2\n\n10 0 12 0 120\n\nSample Output 2\n\n0\n\nTakahashi gets up at exactly ten in the morning and goes to bed at exactly noon. It takes 120 minutes to do the study, so he has to start it at exactly ten o'clock. Thus, we should print 0.", "sample_input": "10 0 15 0 30\n"}, "reference_outputs": ["270\n"], "source_document_id": "p02663", "source_text": "Score : 100 points\n\nProblem Statement\n\nIn this problem, we use the 24-hour clock.\n\nTakahashi gets up exactly at the time H_1 : M_1 and goes to bed exactly at the time H_2 : M_2. (See Sample Inputs below for clarity.)\nHe has decided to study for K consecutive minutes while he is up.\nWhat is the length of the period in which he can start studying?\n\nConstraints\n\n0 \\le H_1, H_2 \\le 23\n\n0 \\le M_1, M_2 \\le 59\n\nThe time H_1 : M_1 comes before the time H_2 : M_2.\n\nK \\ge 1\n\nTakahashi is up for at least K minutes.\n\nAll values in input are integers (without leading zeros).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH_1 M_1 H_2 M_2 K\n\nOutput\n\nPrint the length of the period in which he can start studying, as an integer.\n\nSample Input 1\n\n10 0 15 0 30\n\nSample Output 1\n\n270\n\nTakahashi gets up at exactly ten in the morning and goes to bed at exactly three in the afternoon.\nIt takes 30 minutes to do the study, so he can start it in the period between ten o'clock and half-past two. The length of this period is 270 minutes, so we should print 270.\n\nSample Input 2\n\n10 0 12 0 120\n\nSample Output 2\n\n0\n\nTakahashi gets up at exactly ten in the morning and goes to bed at exactly noon. It takes 120 minutes to do the study, so he has to start it at exactly ten o'clock. Thus, we should print 0.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2880, "cpu_time_ms": 9, "memory_kb": 5452}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s178689191", "group_id": "codeNet:p02664", "input_text": "let () =\n let str = Bytes.of_string @@ read_line () in\n for i = (Bytes.length str) - 1 downto 0 do\n if Bytes.get str i = '?' then Bytes.set str i 'D'\n done;\n print_endline (Bytes.to_string str)", "language": "OCaml", "metadata": {"date": 1591124193, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p02664.html", "problem_id": "p02664", "resource_group": "low_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/OCaml/s178689191.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s178689191", "user_id": "u307426615"}, "prompt_components": {"gold_output": "PDPDPDP\n", "input_to_evaluate": "let () =\n let str = Bytes.of_string @@ read_line () in\n for i = (Bytes.length str) - 1 downto 0 do\n if Bytes.get str i = '?' then Bytes.set str i 'D'\n done;\n print_endline (Bytes.to_string str)", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 10, "memory_kb": 4460}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s146350217", "group_id": "codeNet:p02665", "input_text": "let () = Scanf.scanf \"%d\\n\" @@ fun n ->\n let as_ = Array.init (n + 1) @@ fun _ -> Scanf.scanf \"%d \" @@ fun a -> a in\n let maximum = Array.make (n + 1) 0 in\n maximum.(0) <- max 0 (1 - as_.(0));\n for i = 0 to n - 1 do\n maximum.(i + 1) <- max 0 @@ 2 * maximum.(i) - as_.(i + 1)\n done;\n try\n let nodes = ref 0 in\n let leafs = ref as_.(n) in\n for i = n - 1 downto 0 do\n let leafs' = min !leafs maximum.(i) in\n if !leafs < leafs' || 2 * leafs' < !leafs then raise Not_found;\n nodes := !nodes + leafs';\n leafs := leafs'\n done;\n Printf.printf \"%d\\n\" @@ !nodes + Array.fold_left ( + ) 0 as_\n with Not_found -> print_endline \"-1\"\n", "language": "OCaml", "metadata": {"date": 1590893463, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p02665.html", "problem_id": "p02665", "resource_group": "low_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/OCaml/s146350217.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s146350217", "user_id": "u504158101"}, "prompt_components": {"gold_output": "7\n", "input_to_evaluate": "let () = Scanf.scanf \"%d\\n\" @@ fun n ->\n let as_ = Array.init (n + 1) @@ fun _ -> Scanf.scanf \"%d \" @@ fun a -> a in\n let maximum = Array.make (n + 1) 0 in\n maximum.(0) <- max 0 (1 - as_.(0));\n for i = 0 to n - 1 do\n maximum.(i + 1) <- max 0 @@ 2 * maximum.(i) - as_.(i + 1)\n done;\n try\n let nodes = ref 0 in\n let leafs = ref as_.(n) in\n for i = n - 1 downto 0 do\n let leafs' = min !leafs maximum.(i) in\n if !leafs < leafs' || 2 * leafs' < !leafs then raise Not_found;\n nodes := !nodes + leafs';\n leafs := leafs'\n done;\n Printf.printf \"%d\\n\" @@ !nodes + Array.fold_left ( + ) 0 as_\n with Not_found -> print_endline \"-1\"\n", "problem_context": "Score : 600 points\n\nProblem Statement\n\nGiven is an integer sequence of length N+1: A_0, A_1, A_2, \\ldots, A_N. Is there a binary tree of depth N such that, for each d = 0, 1, \\ldots, N, there are exactly A_d leaves at depth d? If such a tree exists, print the maximum possible number of vertices in such a tree; otherwise, print -1.\n\nNotes\n\nA binary tree is a rooted tree such that each vertex has at most two direct children.\n\nA leaf in a binary tree is a vertex with zero children.\n\nThe depth of a vertex v in a binary tree is the distance from the tree's root to v. (The root has the depth of 0.)\n\nThe depth of a binary tree is the maximum depth of a vertex in the tree.\n\nConstraints\n\n0 \\leq N \\leq 10^5\n\n0 \\leq A_i \\leq 10^{8} (0 \\leq i \\leq N)\n\nA_N \\geq 1\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_0 A_1 A_2 \\cdots A_N\n\nOutput\n\nPrint the answer as an integer.\n\nSample Input 1\n\n3\n0 1 1 2\n\nSample Output 1\n\n7\n\nBelow is the tree with the maximum possible number of vertices. It has seven vertices, so we should print 7.\n\nSample Input 2\n\n4\n0 0 1 0 2\n\nSample Output 2\n\n10\n\nSample Input 3\n\n2\n0 3 1\n\nSample Output 3\n\n-1\n\nSample Input 4\n\n1\n1 1\n\nSample Output 4\n\n-1\n\nSample Input 5\n\n10\n0 0 1 1 2 3 5 8 13 21 34\n\nSample Output 5\n\n264", "sample_input": "3\n0 1 1 2\n"}, "reference_outputs": ["7\n"], "source_document_id": "p02665", "source_text": "Score : 600 points\n\nProblem Statement\n\nGiven is an integer sequence of length N+1: A_0, A_1, A_2, \\ldots, A_N. Is there a binary tree of depth N such that, for each d = 0, 1, \\ldots, N, there are exactly A_d leaves at depth d? If such a tree exists, print the maximum possible number of vertices in such a tree; otherwise, print -1.\n\nNotes\n\nA binary tree is a rooted tree such that each vertex has at most two direct children.\n\nA leaf in a binary tree is a vertex with zero children.\n\nThe depth of a vertex v in a binary tree is the distance from the tree's root to v. (The root has the depth of 0.)\n\nThe depth of a binary tree is the maximum depth of a vertex in the tree.\n\nConstraints\n\n0 \\leq N \\leq 10^5\n\n0 \\leq A_i \\leq 10^{8} (0 \\leq i \\leq N)\n\nA_N \\geq 1\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_0 A_1 A_2 \\cdots A_N\n\nOutput\n\nPrint the answer as an integer.\n\nSample Input 1\n\n3\n0 1 1 2\n\nSample Output 1\n\n7\n\nBelow is the tree with the maximum possible number of vertices. It has seven vertices, so we should print 7.\n\nSample Input 2\n\n4\n0 0 1 0 2\n\nSample Output 2\n\n10\n\nSample Input 3\n\n2\n0 3 1\n\nSample Output 3\n\n-1\n\nSample Input 4\n\n1\n1 1\n\nSample Output 4\n\n-1\n\nSample Input 5\n\n10\n0 0 1 1 2 3 5 8 13 21 34\n\nSample Output 5\n\n264", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 665, "cpu_time_ms": 30, "memory_kb": 7452}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s578890866", "group_id": "codeNet:p02669", "input_text": "open Num;;\n\nScanf.scanf \"%d\" (fun t ->\n let module M = Map.Make (struct type t = int let compare = compare end) in\n for i = 1 to t do\n Scanf.scanf \" %d %d %d %d %d\" (fun n a b c d ->\n let rec calc =\n let map = ref (M.add 0 (Int 0) (M.singleton 1 (Int d))) in\n fun k ->\n if M.mem k !map then M.find k !map else (\n let ans = Int k */ Int d in\n let ans = List.fold_left (fun acc i ->\n if (k + i) mod 2 <> 0 then acc else\n min_num acc (calc ((k + i) / 2) +/ Int a +/ Int d */ Int (abs i))\n ) ans [ -1; 0; 1 ]\n in\n let ans = List.fold_left (fun acc i ->\n if (k + i) mod 3 <> 0 then acc else\n min_num acc (calc ((k + i) / 3) +/ Int b +/ Int d */ Int (abs i))\n ) ans [ -1; 0; 1 ]\n in\n let ans = List.fold_left (fun acc i ->\n if (k + i) mod 5 <> 0 then acc else\n min_num acc (calc ((k + i) / 5) +/ Int c +/ Int d */ Int ( abs i))\n ) ans [ -2; -1; 0; 1; 2 ]\n in\n map := M.add k ans !map;\n ans\n )\n in\n Printf.printf \"%s\\n\" @@ string_of_num (calc n)\n )\n done\n)", "language": "OCaml", "metadata": {"date": 1594089490, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p02669.html", "problem_id": "p02669", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02669/input.txt", "sample_output_relpath": "derived/input_output/data/p02669/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02669/OCaml/s578890866.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s578890866", "user_id": "u342443598"}, "prompt_components": {"gold_output": "20\n19\n26\n3821859835\n23441258666\n", "input_to_evaluate": "open Num;;\n\nScanf.scanf \"%d\" (fun t ->\n let module M = Map.Make (struct type t = int let compare = compare end) in\n for i = 1 to t do\n Scanf.scanf \" %d %d %d %d %d\" (fun n a b c d ->\n let rec calc =\n let map = ref (M.add 0 (Int 0) (M.singleton 1 (Int d))) in\n fun k ->\n if M.mem k !map then M.find k !map else (\n let ans = Int k */ Int d in\n let ans = List.fold_left (fun acc i ->\n if (k + i) mod 2 <> 0 then acc else\n min_num acc (calc ((k + i) / 2) +/ Int a +/ Int d */ Int (abs i))\n ) ans [ -1; 0; 1 ]\n in\n let ans = List.fold_left (fun acc i ->\n if (k + i) mod 3 <> 0 then acc else\n min_num acc (calc ((k + i) / 3) +/ Int b +/ Int d */ Int (abs i))\n ) ans [ -1; 0; 1 ]\n in\n let ans = List.fold_left (fun acc i ->\n if (k + i) mod 5 <> 0 then acc else\n min_num acc (calc ((k + i) / 5) +/ Int c +/ Int d */ Int ( abs i))\n ) ans [ -2; -1; 0; 1; 2 ]\n in\n map := M.add k ans !map;\n ans\n )\n in\n Printf.printf \"%s\\n\" @@ string_of_num (calc n)\n )\n done\n)", "problem_context": "Score : 400 points\n\nProblem Statement\n\nYou start with the number 0 and you want to reach the number N.\n\nYou can change the number, paying a certain amount of coins, with the following operations:\n\nMultiply the number by 2, paying A coins.\n\nMultiply the number by 3, paying B coins.\n\nMultiply the number by 5, paying C coins.\n\nIncrease or decrease the number by 1, paying D coins.\n\nYou can perform these operations in arbitrary order and an arbitrary number of times.\n\nWhat is the minimum number of coins you need to reach N?\n\nYou have to solve T testcases.\n\nConstraints\n\n1 \\le T \\le 10\n\n1 \\le N \\le 10^{18}\n\n1 \\le A, B, C, D \\le 10^9\n\nAll numbers N, A, B, C, D are integers.\n\nInput\n\nThe input is given from Standard Input. The first line of the input is\n\nT\n\nThen, T lines follow describing the T testcases.\nEach of the T lines has the format\n\nN A B C D\n\nOutput\n\nFor each testcase, print the answer on Standard Output followed by a newline.\n\nSample Input 1\n\n5\n11 1 2 4 8\n11 1 2 2 8\n32 10 8 5 4\n29384293847243 454353412 332423423 934923490 1\n900000000000000000 332423423 454353412 934923490 987654321\n\nSample Output 1\n\n20\n19\n26\n3821859835\n23441258666\n\nFor the first testcase, a sequence of moves that achieves the minimum cost of 20 is:\n\nInitially x = 0.\n\nPay 8 to increase by 1 (x = 1).\n\nPay 1 to multiply by 2 (x = 2).\n\nPay 1 to multiply by 2 (x = 4).\n\nPay 2 to multiply by 3 (x = 12).\n\nPay 8 to decrease by 1 (x = 11).\n\nFor the second testcase, a sequence of moves that achieves the minimum cost of 19 is:\n\nInitially x = 0.\n\nPay 8 to increase by 1 (x = 1).\n\nPay 1 to multiply by 2 (x = 2).\n\nPay 2 to multiply by 5 (x = 10).\n\nPay 8 to increase by 1 (x = 11).", "sample_input": "5\n11 1 2 4 8\n11 1 2 2 8\n32 10 8 5 4\n29384293847243 454353412 332423423 934923490 1\n900000000000000000 332423423 454353412 934923490 987654321\n"}, "reference_outputs": ["20\n19\n26\n3821859835\n23441258666\n"], "source_document_id": "p02669", "source_text": "Score : 400 points\n\nProblem Statement\n\nYou start with the number 0 and you want to reach the number N.\n\nYou can change the number, paying a certain amount of coins, with the following operations:\n\nMultiply the number by 2, paying A coins.\n\nMultiply the number by 3, paying B coins.\n\nMultiply the number by 5, paying C coins.\n\nIncrease or decrease the number by 1, paying D coins.\n\nYou can perform these operations in arbitrary order and an arbitrary number of times.\n\nWhat is the minimum number of coins you need to reach N?\n\nYou have to solve T testcases.\n\nConstraints\n\n1 \\le T \\le 10\n\n1 \\le N \\le 10^{18}\n\n1 \\le A, B, C, D \\le 10^9\n\nAll numbers N, A, B, C, D are integers.\n\nInput\n\nThe input is given from Standard Input. The first line of the input is\n\nT\n\nThen, T lines follow describing the T testcases.\nEach of the T lines has the format\n\nN A B C D\n\nOutput\n\nFor each testcase, print the answer on Standard Output followed by a newline.\n\nSample Input 1\n\n5\n11 1 2 4 8\n11 1 2 2 8\n32 10 8 5 4\n29384293847243 454353412 332423423 934923490 1\n900000000000000000 332423423 454353412 934923490 987654321\n\nSample Output 1\n\n20\n19\n26\n3821859835\n23441258666\n\nFor the first testcase, a sequence of moves that achieves the minimum cost of 20 is:\n\nInitially x = 0.\n\nPay 8 to increase by 1 (x = 1).\n\nPay 1 to multiply by 2 (x = 2).\n\nPay 1 to multiply by 2 (x = 4).\n\nPay 2 to multiply by 3 (x = 12).\n\nPay 8 to decrease by 1 (x = 11).\n\nFor the second testcase, a sequence of moves that achieves the minimum cost of 19 is:\n\nInitially x = 0.\n\nPay 8 to increase by 1 (x = 1).\n\nPay 1 to multiply by 2 (x = 2).\n\nPay 2 to multiply by 5 (x = 10).\n\nPay 8 to increase by 1 (x = 11).", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1469, "cpu_time_ms": 232, "memory_kb": 8280}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s916447111", "group_id": "codeNet:p02669", "input_text": "Scanf.scanf \"%d\" (fun t ->\n let module M = Map.Make (struct type t = int let compare = compare end) in\n for i = 1 to t do\n Scanf.scanf \" %d %d %d %d %d\" (fun n a b c d ->\n let rec calc =\n let map = ref (M.add 0 0 (M.singleton 1 d)) in\n fun k ->\n if M.mem k !map then M.find k !map else (\n let ans = if k < max_int / d then k * d else max_int in\n let ans = List.fold_left (fun acc i ->\n if (k + i) mod 2 <> 0 then acc else\n min acc (calc ((k + i) / 2) + a + d * abs i)\n ) ans [ -1; 0 ]\n in\n let ans = List.fold_left (fun acc i ->\n if (k + i) mod 3 <> 0 then acc else\n min acc (calc ((k + i) / 3) + b + d * abs i)\n ) ans [ -1; 0; 1 ]\n in\n let ans = List.fold_left (fun acc i ->\n if (k + i) mod 5 <> 0 then acc else\n min acc (calc ((k + i) / 5) + c + d * abs i)\n ) ans [ -2; -1; 0; 1; 2 ]\n in\n map := M.add k ans !map;\n ans\n )\n in\n Printf.printf \"%d\\n\" @@ calc n\n )\n done\n)", "language": "OCaml", "metadata": {"date": 1594088621, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p02669.html", "problem_id": "p02669", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02669/input.txt", "sample_output_relpath": "derived/input_output/data/p02669/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02669/OCaml/s916447111.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s916447111", "user_id": "u342443598"}, "prompt_components": {"gold_output": "20\n19\n26\n3821859835\n23441258666\n", "input_to_evaluate": "Scanf.scanf \"%d\" (fun t ->\n let module M = Map.Make (struct type t = int let compare = compare end) in\n for i = 1 to t do\n Scanf.scanf \" %d %d %d %d %d\" (fun n a b c d ->\n let rec calc =\n let map = ref (M.add 0 0 (M.singleton 1 d)) in\n fun k ->\n if M.mem k !map then M.find k !map else (\n let ans = if k < max_int / d then k * d else max_int in\n let ans = List.fold_left (fun acc i ->\n if (k + i) mod 2 <> 0 then acc else\n min acc (calc ((k + i) / 2) + a + d * abs i)\n ) ans [ -1; 0 ]\n in\n let ans = List.fold_left (fun acc i ->\n if (k + i) mod 3 <> 0 then acc else\n min acc (calc ((k + i) / 3) + b + d * abs i)\n ) ans [ -1; 0; 1 ]\n in\n let ans = List.fold_left (fun acc i ->\n if (k + i) mod 5 <> 0 then acc else\n min acc (calc ((k + i) / 5) + c + d * abs i)\n ) ans [ -2; -1; 0; 1; 2 ]\n in\n map := M.add k ans !map;\n ans\n )\n in\n Printf.printf \"%d\\n\" @@ calc n\n )\n done\n)", "problem_context": "Score : 400 points\n\nProblem Statement\n\nYou start with the number 0 and you want to reach the number N.\n\nYou can change the number, paying a certain amount of coins, with the following operations:\n\nMultiply the number by 2, paying A coins.\n\nMultiply the number by 3, paying B coins.\n\nMultiply the number by 5, paying C coins.\n\nIncrease or decrease the number by 1, paying D coins.\n\nYou can perform these operations in arbitrary order and an arbitrary number of times.\n\nWhat is the minimum number of coins you need to reach N?\n\nYou have to solve T testcases.\n\nConstraints\n\n1 \\le T \\le 10\n\n1 \\le N \\le 10^{18}\n\n1 \\le A, B, C, D \\le 10^9\n\nAll numbers N, A, B, C, D are integers.\n\nInput\n\nThe input is given from Standard Input. The first line of the input is\n\nT\n\nThen, T lines follow describing the T testcases.\nEach of the T lines has the format\n\nN A B C D\n\nOutput\n\nFor each testcase, print the answer on Standard Output followed by a newline.\n\nSample Input 1\n\n5\n11 1 2 4 8\n11 1 2 2 8\n32 10 8 5 4\n29384293847243 454353412 332423423 934923490 1\n900000000000000000 332423423 454353412 934923490 987654321\n\nSample Output 1\n\n20\n19\n26\n3821859835\n23441258666\n\nFor the first testcase, a sequence of moves that achieves the minimum cost of 20 is:\n\nInitially x = 0.\n\nPay 8 to increase by 1 (x = 1).\n\nPay 1 to multiply by 2 (x = 2).\n\nPay 1 to multiply by 2 (x = 4).\n\nPay 2 to multiply by 3 (x = 12).\n\nPay 8 to decrease by 1 (x = 11).\n\nFor the second testcase, a sequence of moves that achieves the minimum cost of 19 is:\n\nInitially x = 0.\n\nPay 8 to increase by 1 (x = 1).\n\nPay 1 to multiply by 2 (x = 2).\n\nPay 2 to multiply by 5 (x = 10).\n\nPay 8 to increase by 1 (x = 11).", "sample_input": "5\n11 1 2 4 8\n11 1 2 2 8\n32 10 8 5 4\n29384293847243 454353412 332423423 934923490 1\n900000000000000000 332423423 454353412 934923490 987654321\n"}, "reference_outputs": ["20\n19\n26\n3821859835\n23441258666\n"], "source_document_id": "p02669", "source_text": "Score : 400 points\n\nProblem Statement\n\nYou start with the number 0 and you want to reach the number N.\n\nYou can change the number, paying a certain amount of coins, with the following operations:\n\nMultiply the number by 2, paying A coins.\n\nMultiply the number by 3, paying B coins.\n\nMultiply the number by 5, paying C coins.\n\nIncrease or decrease the number by 1, paying D coins.\n\nYou can perform these operations in arbitrary order and an arbitrary number of times.\n\nWhat is the minimum number of coins you need to reach N?\n\nYou have to solve T testcases.\n\nConstraints\n\n1 \\le T \\le 10\n\n1 \\le N \\le 10^{18}\n\n1 \\le A, B, C, D \\le 10^9\n\nAll numbers N, A, B, C, D are integers.\n\nInput\n\nThe input is given from Standard Input. The first line of the input is\n\nT\n\nThen, T lines follow describing the T testcases.\nEach of the T lines has the format\n\nN A B C D\n\nOutput\n\nFor each testcase, print the answer on Standard Output followed by a newline.\n\nSample Input 1\n\n5\n11 1 2 4 8\n11 1 2 2 8\n32 10 8 5 4\n29384293847243 454353412 332423423 934923490 1\n900000000000000000 332423423 454353412 934923490 987654321\n\nSample Output 1\n\n20\n19\n26\n3821859835\n23441258666\n\nFor the first testcase, a sequence of moves that achieves the minimum cost of 20 is:\n\nInitially x = 0.\n\nPay 8 to increase by 1 (x = 1).\n\nPay 1 to multiply by 2 (x = 2).\n\nPay 1 to multiply by 2 (x = 4).\n\nPay 2 to multiply by 3 (x = 12).\n\nPay 8 to decrease by 1 (x = 11).\n\nFor the second testcase, a sequence of moves that achieves the minimum cost of 19 is:\n\nInitially x = 0.\n\nPay 8 to increase by 1 (x = 1).\n\nPay 1 to multiply by 2 (x = 2).\n\nPay 2 to multiply by 5 (x = 10).\n\nPay 8 to increase by 1 (x = 11).", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1390, "cpu_time_ms": 129, "memory_kb": 7436}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s742802371", "group_id": "codeNet:p02675", "input_text": "let therefore n =\n let n_mod_10 = n mod 10 in\n if n_mod_10 = 2 then \"hon\"\n else if n_mod_10 = 4 then \"hon\"\n else if n_mod_10 = 5 then \"hon\"\n else if n_mod_10 = 7 then \"hon\"\n else if n_mod_10 = 9 then \"hon\"\n else if n_mod_10 = 0 then \"pon\"\n else if n_mod_10 = 1 then \"pon\"\n else if n_mod_10 = 6 then \"pon\"\n else if n_mod_10 = 8 then \"pon\"\n else \"bon\"\n\nlet () = Printf.printf \"%s\\n\" (therefore (read_int ()))", "language": "OCaml", "metadata": {"date": 1595603518, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p02675.html", "problem_id": "p02675", "resource_group": "low_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/OCaml/s742802371.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s742802371", "user_id": "u272377260"}, "prompt_components": {"gold_output": "pon\n", "input_to_evaluate": "let therefore n =\n let n_mod_10 = n mod 10 in\n if n_mod_10 = 2 then \"hon\"\n else if n_mod_10 = 4 then \"hon\"\n else if n_mod_10 = 5 then \"hon\"\n else if n_mod_10 = 7 then \"hon\"\n else if n_mod_10 = 9 then \"hon\"\n else if n_mod_10 = 0 then \"pon\"\n else if n_mod_10 = 1 then \"pon\"\n else if n_mod_10 = 6 then \"pon\"\n else if n_mod_10 = 8 then \"pon\"\n else \"bon\"\n\nlet () = Printf.printf \"%s\\n\" (therefore (read_int ()))", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 417, "cpu_time_ms": 10, "memory_kb": 3580}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s645745731", "group_id": "codeNet:p02676", "input_text": "open Scanf\nopen Printf\n\nlet triple_dots k s =\n if String.length s <= k then s\n else String.sub s 0 k ^ \"...\"\n\nlet k,s = scanf \"%d %s\" (fun k s -> (k,s))\nlet () = printf \"%s\\n\" (triple_dots k s)", "language": "OCaml", "metadata": {"date": 1596639148, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p02676.html", "problem_id": "p02676", "resource_group": "low_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/OCaml/s645745731.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s645745731", "user_id": "u272377260"}, "prompt_components": {"gold_output": "nikoand...\n", "input_to_evaluate": "open Scanf\nopen Printf\n\nlet triple_dots k s =\n if String.length s <= k then s\n else String.sub s 0 k ^ \"...\"\n\nlet k,s = scanf \"%d %s\" (fun k s -> (k,s))\nlet () = printf \"%s\\n\" (triple_dots k s)", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 7, "memory_kb": 3716}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s122904981", "group_id": "codeNet:p02676", "input_text": "let k = Scanf.sscanf (read_line ()) \"%d\" @@ fun k -> k\nlet s = read_line ()\n\nlet () = print_endline @@\n if (String.length s > k) then (String.sub s 0 k) ^ \"...\"\n else s", "language": "OCaml", "metadata": {"date": 1589850478, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p02676.html", "problem_id": "p02676", "resource_group": "low_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/OCaml/s122904981.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s122904981", "user_id": "u811309788"}, "prompt_components": {"gold_output": "nikoand...\n", "input_to_evaluate": "let k = Scanf.sscanf (read_line ()) \"%d\" @@ fun k -> k\nlet s = read_line ()\n\nlet () = print_endline @@\n if (String.length s > k) then (String.sub s 0 k) ^ \"...\"\n else s", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 5, "memory_kb": 3708}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s763644010", "group_id": "codeNet:p02677", "input_text": "open Batteries\nmodule EnumL = Enum.Labels\nmodule ListL = List.Labels\nmodule ArrayL = Array.Labels\n\nlet dbg0 x = Printf.eprintf \"[debug]%s\\n\" @@ dump x\nlet dbg1 x = dbg0 x; x\n\nlet id = identity\n\nlet (++) n m = List.range n `To m\nlet (++-) n m = if n >= m then List.range n `Downto m else []\nlet (++^) n m = if n < m then List.range n `To (pred m) else []\n\nlet scan fmt = Scanf.sscanf (read_line ()) fmt\n\nlet scan_lines n fmt f =\n if n = 0 then []\n else List.map (fun _ -> scan fmt f) (1 ++ n)\n\nlet scan_list ?sep cnv =\n let line = read_line () in\n (match sep with\n | None -> List.map String.of_char @@ String.to_list line\n | Some sep -> String.split_on_char sep line)\n |> List.map cnv\n\nlet scan_array ?sep cnv = Array.of_list @@ scan_list ?sep cnv\n\nlet scan_matrix n m e ?sep conv =\n let arr = Array.make_matrix n m e in\n ListL.iter (0 ++^ n)\n ~f:(fun i -> arr.(i) <- Array.of_list @@ scan_list ?sep conv);\n arr\n\nlet atoi c = Char.code c - Char.code '0'\n\nlet rec powerset = function\n | [] -> [[]]\n | hd::tl ->\n let pws = powerset tl in\n pws @ ListL.map pws ~f:(fun pw -> hd::pw)\n\nlet permutations l =\n let rec interleave x = function\n | [] -> [[x]]\n | (hd::tl) as l ->\n (x::l) :: (interleave x tl |> ListL.map ~f:(fun l -> hd::l)) in\n let rec aux = function\n | [] -> [[]]\n | a::rest ->\n aux rest |> ListL.map ~f:(interleave a) |> List.concat in\n aux l\n\nlet intersection l =\n EnumL.filter ~f:(fun x -> EnumL.exists ~f:((=) x) @@ Enum.clone l)\n\nlet zip l m =\n let n = min (List.length l) (List.length m) in\n List.combine (List.take n l) (List.take n m)\n\nlet lower_bound n f =\n let rec aux l u =\n if u - l > 1 then\n let m = (l + u) / 2 in\n if f m then aux l m\n else aux m u\n else u in aux (-1) n\n\nlet between n x m = n <= x && x < m\n\nlet (a,b,h,m) = scan \"%f %f %f %f\" Tuple4.make\n\nlet () =\n let theta = Float.abs 2.0*.Float.pi *. ((h +. m /. 60.0) /. 12.0 -. m /. 60.0) in\n Printf.printf \"%.10f\\n\" @@ Float.sqrt @@ a*.a +. b*.b -. 2.0*.a*.b*.cos theta\n", "language": "OCaml", "metadata": {"date": 1591846063, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p02677.html", "problem_id": "p02677", "resource_group": "low_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/OCaml/s763644010.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s763644010", "user_id": "u802614675"}, "prompt_components": {"gold_output": "5.00000000000000000000\n", "input_to_evaluate": "open Batteries\nmodule EnumL = Enum.Labels\nmodule ListL = List.Labels\nmodule ArrayL = Array.Labels\n\nlet dbg0 x = Printf.eprintf \"[debug]%s\\n\" @@ dump x\nlet dbg1 x = dbg0 x; x\n\nlet id = identity\n\nlet (++) n m = List.range n `To m\nlet (++-) n m = if n >= m then List.range n `Downto m else []\nlet (++^) n m = if n < m then List.range n `To (pred m) else []\n\nlet scan fmt = Scanf.sscanf (read_line ()) fmt\n\nlet scan_lines n fmt f =\n if n = 0 then []\n else List.map (fun _ -> scan fmt f) (1 ++ n)\n\nlet scan_list ?sep cnv =\n let line = read_line () in\n (match sep with\n | None -> List.map String.of_char @@ String.to_list line\n | Some sep -> String.split_on_char sep line)\n |> List.map cnv\n\nlet scan_array ?sep cnv = Array.of_list @@ scan_list ?sep cnv\n\nlet scan_matrix n m e ?sep conv =\n let arr = Array.make_matrix n m e in\n ListL.iter (0 ++^ n)\n ~f:(fun i -> arr.(i) <- Array.of_list @@ scan_list ?sep conv);\n arr\n\nlet atoi c = Char.code c - Char.code '0'\n\nlet rec powerset = function\n | [] -> [[]]\n | hd::tl ->\n let pws = powerset tl in\n pws @ ListL.map pws ~f:(fun pw -> hd::pw)\n\nlet permutations l =\n let rec interleave x = function\n | [] -> [[x]]\n | (hd::tl) as l ->\n (x::l) :: (interleave x tl |> ListL.map ~f:(fun l -> hd::l)) in\n let rec aux = function\n | [] -> [[]]\n | a::rest ->\n aux rest |> ListL.map ~f:(interleave a) |> List.concat in\n aux l\n\nlet intersection l =\n EnumL.filter ~f:(fun x -> EnumL.exists ~f:((=) x) @@ Enum.clone l)\n\nlet zip l m =\n let n = min (List.length l) (List.length m) in\n List.combine (List.take n l) (List.take n m)\n\nlet lower_bound n f =\n let rec aux l u =\n if u - l > 1 then\n let m = (l + u) / 2 in\n if f m then aux l m\n else aux m u\n else u in aux (-1) n\n\nlet between n x m = n <= x && x < m\n\nlet (a,b,h,m) = scan \"%f %f %f %f\" Tuple4.make\n\nlet () =\n let theta = Float.abs 2.0*.Float.pi *. ((h +. m /. 60.0) /. 12.0 -. m /. 60.0) in\n Printf.printf \"%.10f\\n\" @@ Float.sqrt @@ a*.a +. b*.b -. 2.0*.a*.b*.cos theta\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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2026, "cpu_time_ms": 10, "memory_kb": 5788}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s771649482", "group_id": "codeNet:p02677", "input_text": "let pi = atan(1.) *. 4.\nlet () =\n Scanf.scanf \"%f %f %f %f\\n\" @@ fun a b h m ->\n let d = let d' = abs_float (h *. 30. -. m *. 5.5) in\n if d' <= 180. then d' else 360. -. d' in\n let ans = sqrt (a**2. +. b**2. -. 2.*.a*.b*.cos(d *. pi /. 180.)) in\n Printf.printf \"%.10f\\n\" ans", "language": "OCaml", "metadata": {"date": 1591408714, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p02677.html", "problem_id": "p02677", "resource_group": "low_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/OCaml/s771649482.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s771649482", "user_id": "u307426615"}, "prompt_components": {"gold_output": "5.00000000000000000000\n", "input_to_evaluate": "let pi = atan(1.) *. 4.\nlet () =\n Scanf.scanf \"%f %f %f %f\\n\" @@ fun a b h m ->\n let d = let d' = abs_float (h *. 30. -. m *. 5.5) in\n if d' <= 180. then d' else 360. -. d' in\n let ans = sqrt (a**2. +. b**2. -. 2.*.a*.b*.cos(d *. pi /. 180.)) in\n Printf.printf \"%.10f\\n\" ans", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 281, "cpu_time_ms": 7, "memory_kb": 4404}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s350250489", "group_id": "codeNet:p02677", "input_text": "open Batteries\nlet a,b,h,m = Scanf.sscanf (read_line()) \"%d %d %d %d\" (fun a b h m -> a,b,h,m)\nlet get_hour_kakudo hour = (15 * (hour+3))\nlet get_minute_kakudo minutes = (6 * (minutes+15))\nlet pi = 4.0 *. atan 1.0\nlet f_a = float_of_int a\nlet f_b = float_of_int b\nlet _ = (\n if get_hour_kakudo h = get_minute_kakudo m then (float_of_int @@ abs (a-b)) else (\n let hour_x = f_a *. (cos @@ (((float_of_int @@ get_hour_kakudo h) /. 180.) *. pi)) in\n let hour_y = f_a *. (sin @@ (((float_of_int @@ get_hour_kakudo h) /. 180.) *. pi)) in\n let min_x = f_b *. (cos @@ (((float_of_int @@ get_minute_kakudo m) /. 180.) *. pi)) in\n let min_y = f_b *. (sin @@ (((float_of_int @@ get_minute_kakudo m) /. 180.) *. pi)) in\n (* Printf.printf \"%.1f %.8f %.8f %.8f hour %d minutes %d\\n\" hour_x hour_y min_x min_y (get_hour_kakudo h) (get_minute_kakudo m); *)\n (((min_x -. hour_x) ** 2.) +. ((min_y -. hour_y) ** 2.)) |> sqrt\n )\n) |> Printf.printf \"%f\\n\"\n\n", "language": "OCaml", "metadata": {"date": 1589769581, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p02677.html", "problem_id": "p02677", "resource_group": "low_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/OCaml/s350250489.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s350250489", "user_id": "u511870776"}, "prompt_components": {"gold_output": "5.00000000000000000000\n", "input_to_evaluate": "open Batteries\nlet a,b,h,m = Scanf.sscanf (read_line()) \"%d %d %d %d\" (fun a b h m -> a,b,h,m)\nlet get_hour_kakudo hour = (15 * (hour+3))\nlet get_minute_kakudo minutes = (6 * (minutes+15))\nlet pi = 4.0 *. atan 1.0\nlet f_a = float_of_int a\nlet f_b = float_of_int b\nlet _ = (\n if get_hour_kakudo h = get_minute_kakudo m then (float_of_int @@ abs (a-b)) else (\n let hour_x = f_a *. (cos @@ (((float_of_int @@ get_hour_kakudo h) /. 180.) *. pi)) in\n let hour_y = f_a *. (sin @@ (((float_of_int @@ get_hour_kakudo h) /. 180.) *. pi)) in\n let min_x = f_b *. (cos @@ (((float_of_int @@ get_minute_kakudo m) /. 180.) *. pi)) in\n let min_y = f_b *. (sin @@ (((float_of_int @@ get_minute_kakudo m) /. 180.) *. pi)) in\n (* Printf.printf \"%.1f %.8f %.8f %.8f hour %d minutes %d\\n\" hour_x hour_y min_x min_y (get_hour_kakudo h) (get_minute_kakudo m); *)\n (((min_x -. hour_x) ** 2.) +. ((min_y -. hour_y) ** 2.)) |> sqrt\n )\n) |> Printf.printf \"%f\\n\"\n\n", "problem_context": "Score: 300 points\n\nProblem Statement\n\nConsider an analog clock whose hour and minute hands are A and B centimeters long, respectively.\n\nAn endpoint of the hour hand and an endpoint of the minute hand are fixed at the same point, around which each hand rotates clockwise at constant angular velocity. It takes the hour and minute hands 12 hours and 1 hour to make one full rotation, respectively.\n\nAt 0 o'clock, the two hands overlap each other. H hours and M minutes later, what is the distance in centimeters between the unfixed endpoints of the hands?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq A, B \\leq 1000\n\n0 \\leq H \\leq 11\n\n0 \\leq M \\leq 59\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B H M\n\nOutput\n\nPrint the answer without units. Your output will be accepted when its absolute or relative error from the correct value is at most 10^{-9}.\n\nSample Input 1\n\n3 4 9 0\n\nSample Output 1\n\n5.00000000000000000000\n\nThe two hands will be in the positions shown in the figure below, so the answer is 5 centimeters.\n\nSample Input 2\n\n3 4 10 40\n\nSample Output 2\n\n4.56425719433005567605\n\nThe two hands will be in the positions shown in the figure below. Note that each hand always rotates at constant angular velocity.", "sample_input": "3 4 9 0\n"}, "reference_outputs": ["5.00000000000000000000\n"], "source_document_id": "p02677", "source_text": "Score: 300 points\n\nProblem Statement\n\nConsider an analog clock whose hour and minute hands are A and B centimeters long, respectively.\n\nAn endpoint of the hour hand and an endpoint of the minute hand are fixed at the same point, around which each hand rotates clockwise at constant angular velocity. It takes the hour and minute hands 12 hours and 1 hour to make one full rotation, respectively.\n\nAt 0 o'clock, the two hands overlap each other. H hours and M minutes later, what is the distance in centimeters between the unfixed endpoints of the hands?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq A, B \\leq 1000\n\n0 \\leq H \\leq 11\n\n0 \\leq M \\leq 59\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B H M\n\nOutput\n\nPrint the answer without units. Your output will be accepted when its absolute or relative error from the correct value is at most 10^{-9}.\n\nSample Input 1\n\n3 4 9 0\n\nSample Output 1\n\n5.00000000000000000000\n\nThe two hands will be in the positions shown in the figure below, so the answer is 5 centimeters.\n\nSample Input 2\n\n3 4 10 40\n\nSample Output 2\n\n4.56425719433005567605\n\nThe two hands will be in the positions shown in the figure below. Note that each hand always rotates at constant angular velocity.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 958, "cpu_time_ms": 8, "memory_kb": 5808}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s070493867", "group_id": "codeNet:p02678", "input_text": "module DirectedGraph\n: sig\n (* 配列を用いたBFSの実装 *)\n module ByArray : sig\n module Make :\n functor\n (* 道の表現 *)\n (Path : sig\n type t\n (* 辺の名前 *)\n type edge\n (* 長さ0の道 *)\n val nil : t\n (* 道の後ろに辺を付け足した道 *)\n val snoc : t -> edge -> t\n end) ->\n sig\n type 'a church_list = { fold : 'b. ('a -> 'b -> 'b) -> 'b -> 'b }\n\n (* BFSにより,重みのないグラフの最短経路を求める *)\n val bfs :\n (* 頂点数n *)\n int ->\n (* 辺の名前が付いた隣接リスト *)\n (int -> (int * Path.edge) church_list) ->\n (* 始点 *)\n int ->\n (* 始点からの最短経路を返す関数\n この関数を覚えておけば,呼び出しごとの途中までの計算結果がシェアされる *)\n (int -> Path.t option)\n end\n end\n\n (* ハッシュテーブルを用いたBFSの実装 *)\n module ByHashtbl : sig\n module Make :\n functor\n (* 頂点をキーとしたハッシュテーブルの実装 *)\n (VHash : Hashtbl.S)\n (* 道の表現 *)\n (Path : sig\n type t\n (* 辺の名前 *)\n type edge\n (* 長さ0の道 *)\n val nil : t\n (* 道の後ろに辺を付け足した道 *)\n val snoc : t -> edge -> t\n end) ->\n sig\n type 'a church_list = { fold : 'b. ('a -> 'b -> 'b) -> 'b -> 'b }\n\n (* BFSにより,重みのないグラフの最短経路を求める *)\n val bfs :\n (* 頂点数(ハッシュテーブルを用いるので目安程度) *)\n int ->\n (* 辺の名前が付いた隣接リスト *)\n (VHash.key -> (VHash.key * Path.edge) church_list) ->\n (* 始点 *)\n VHash.key ->\n (* 最短経路を返す関数 辿り着けなければNoneを返す) *)\n (VHash.key -> Path.t option)\n end\n end\n\n (* Mapを用いたBFSの実装 *)\n module ByMap : sig\n module Make :\n functor\n (* 頂点をキーとしたMapの実装 *)\n (VMap : Map.S)\n (* 道の表現 *)\n (Path : sig\n type t\n (* 辺の名前 *)\n type edge\n (* 長さ0の道 *)\n val nil : t\n (* 道の後ろに辺を付け足した道 *)\n val snoc : t -> edge -> t\n end) ->\n sig\n type 'a church_list = { fold : 'b. ('a -> 'b -> 'b) -> 'b -> 'b }\n\n (* BFSにより,重みのないグラフの最短経路を求める *)\n val bfs :\n (* 辺の名前が付いた隣接リスト *)\n (VMap.key -> (VMap.key * Path.edge) church_list) ->\n (* 始点 *)\n VMap.key ->\n (* 最短経路を返す関数 辿り着けなければNoneを返す) *)\n (VMap.key -> Path.t option)\n end\n end\nend\n= struct\n module type Path = sig\n type t\n (* 辺の名前 *)\n type edge\n (* 長さ0の道 *)\n val nil : t\n (* 道の後ろに辺を付け足した道 *)\n val snoc : t -> edge -> t\n end\n\n (* 最短経路を格納するデータ構造を抽象化したBFSの実装 *)\n module Core\n (P : Path)\n (* グラフの頂点を添字としたハッシュ *)\n (VHash : sig\n type t\n type vertex (* グラフの頂点 *)\n val find_opt : t -> vertex -> P.t option\n val update : t -> vertex -> (P.t option -> P.t option) -> unit\n end)\n = struct\n type 'a church_list = { fold : 'b. ('a -> 'b -> 'b) -> 'b -> 'b }\n\n let bfs d es s =\n VHash.update d s (Fun.const (Some P.nil));\n let q = ref [(s, P.nil)] in\n let rec bfs_aux t =\n match VHash.find_opt d t, !q with\n (* もう既に全ての頂点までの経路が分かっている *)\n | None, [] -> None\n (* 既に終点までの経路が分かっているので返す *)\n | Some _ as ans, _ -> ans\n (* 終点までの経路が分かっていないので,BFSを続行 *)\n | None, ups ->\n q := [];\n List.iter (fun (u, p) ->\n Fun.flip (es u).fold () @@ fun (v, e) () ->\n VHash.update d u @@ function\n | (Some _) as op -> op\n | None ->\n let p' = P.snoc p e in\n q := (v, p') :: !q; Some p') ups;\n bfs_aux t in\n bfs_aux\n end\n\n module ByArray = struct\n module Make (P : Path) = struct\n module C = Core (P) (struct\n type t = P.t option array\n type vertex = int\n let find_opt = Array.get\n let update d v f = d.(v) <- f d.(v)\n end)\n include C\n\n let bfs n e s = C.bfs (Array.make n None) e s\n end\n end\n\n module ByHashtbl = struct\n module Make (VHash : Hashtbl.S) (P : Path) = struct\n module C = Core (P) (struct\n type t = P.t VHash.t\n type vertex = VHash.key\n let find_opt = VHash.find_opt\n let update d v f =\n let opt = VHash.find_opt d v in\n match opt, f opt with\n | None, None -> ()\n | None, Some p -> VHash.add d v p\n | Some _, None -> VHash.remove d v\n | Some p, Some p' -> if p != p' then VHash.replace d v p'\n end)\n include C\n\n let bfs n e s = C.bfs (VHash.create n) e s\n end\n end\n\n module ByMap = struct\n module Make (VMap : Map.S) (P : Path) = struct\n module C = Core (P) (struct\n type t = P.t VMap.t ref\n type vertex = VMap.key\n let find_opt d v = VMap.find_opt v !d\n let update d v f = d := VMap.update v f !d\n end)\n include C\n\n let bfs e s = C.bfs (ref VMap.empty) e s\n end\n end\nend\n\nmodule G = DirectedGraph.ByArray.Make\n (struct\n type t = int\n type edge = int\n let nil = 0\n let snoc _ e = e\n end)\n\nlet () = Scanf.scanf \"%d %d\\n\" @@ fun n m ->\n let es = Array.make n [] in\n for i = 0 to m - 1 do\n Scanf.scanf \"%d %d\\n\" @@ fun a b ->\n es.(a - 1) <- (b - 1, a) :: es.(a - 1);\n es.(b - 1) <- (a - 1, b) :: es.(b - 1);\n done;\n let d = G.bfs n (fun v -> { G.fold = fun f -> List.fold_right f es.(v) }) 0 in\n if List.exists Option.is_none @@ List.init n d\n then print_endline \"No\"\n else begin\n print_endline \"Yes\";\n for i = 1 to n - 1 do\n Printf.printf \"%d\\n\" @@ Option.get @@ d i\n done\n end\n", "language": "OCaml", "metadata": {"date": 1589832894, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p02678.html", "problem_id": "p02678", "resource_group": "low_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/OCaml/s070493867.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s070493867", "user_id": "u504158101"}, "prompt_components": {"gold_output": "Yes\n1\n2\n2\n", "input_to_evaluate": "module DirectedGraph\n: sig\n (* 配列を用いたBFSの実装 *)\n module ByArray : sig\n module Make :\n functor\n (* 道の表現 *)\n (Path : sig\n type t\n (* 辺の名前 *)\n type edge\n (* 長さ0の道 *)\n val nil : t\n (* 道の後ろに辺を付け足した道 *)\n val snoc : t -> edge -> t\n end) ->\n sig\n type 'a church_list = { fold : 'b. ('a -> 'b -> 'b) -> 'b -> 'b }\n\n (* BFSにより,重みのないグラフの最短経路を求める *)\n val bfs :\n (* 頂点数n *)\n int ->\n (* 辺の名前が付いた隣接リスト *)\n (int -> (int * Path.edge) church_list) ->\n (* 始点 *)\n int ->\n (* 始点からの最短経路を返す関数\n この関数を覚えておけば,呼び出しごとの途中までの計算結果がシェアされる *)\n (int -> Path.t option)\n end\n end\n\n (* ハッシュテーブルを用いたBFSの実装 *)\n module ByHashtbl : sig\n module Make :\n functor\n (* 頂点をキーとしたハッシュテーブルの実装 *)\n (VHash : Hashtbl.S)\n (* 道の表現 *)\n (Path : sig\n type t\n (* 辺の名前 *)\n type edge\n (* 長さ0の道 *)\n val nil : t\n (* 道の後ろに辺を付け足した道 *)\n val snoc : t -> edge -> t\n end) ->\n sig\n type 'a church_list = { fold : 'b. ('a -> 'b -> 'b) -> 'b -> 'b }\n\n (* BFSにより,重みのないグラフの最短経路を求める *)\n val bfs :\n (* 頂点数(ハッシュテーブルを用いるので目安程度) *)\n int ->\n (* 辺の名前が付いた隣接リスト *)\n (VHash.key -> (VHash.key * Path.edge) church_list) ->\n (* 始点 *)\n VHash.key ->\n (* 最短経路を返す関数 辿り着けなければNoneを返す) *)\n (VHash.key -> Path.t option)\n end\n end\n\n (* Mapを用いたBFSの実装 *)\n module ByMap : sig\n module Make :\n functor\n (* 頂点をキーとしたMapの実装 *)\n (VMap : Map.S)\n (* 道の表現 *)\n (Path : sig\n type t\n (* 辺の名前 *)\n type edge\n (* 長さ0の道 *)\n val nil : t\n (* 道の後ろに辺を付け足した道 *)\n val snoc : t -> edge -> t\n end) ->\n sig\n type 'a church_list = { fold : 'b. ('a -> 'b -> 'b) -> 'b -> 'b }\n\n (* BFSにより,重みのないグラフの最短経路を求める *)\n val bfs :\n (* 辺の名前が付いた隣接リスト *)\n (VMap.key -> (VMap.key * Path.edge) church_list) ->\n (* 始点 *)\n VMap.key ->\n (* 最短経路を返す関数 辿り着けなければNoneを返す) *)\n (VMap.key -> Path.t option)\n end\n end\nend\n= struct\n module type Path = sig\n type t\n (* 辺の名前 *)\n type edge\n (* 長さ0の道 *)\n val nil : t\n (* 道の後ろに辺を付け足した道 *)\n val snoc : t -> edge -> t\n end\n\n (* 最短経路を格納するデータ構造を抽象化したBFSの実装 *)\n module Core\n (P : Path)\n (* グラフの頂点を添字としたハッシュ *)\n (VHash : sig\n type t\n type vertex (* グラフの頂点 *)\n val find_opt : t -> vertex -> P.t option\n val update : t -> vertex -> (P.t option -> P.t option) -> unit\n end)\n = struct\n type 'a church_list = { fold : 'b. ('a -> 'b -> 'b) -> 'b -> 'b }\n\n let bfs d es s =\n VHash.update d s (Fun.const (Some P.nil));\n let q = ref [(s, P.nil)] in\n let rec bfs_aux t =\n match VHash.find_opt d t, !q with\n (* もう既に全ての頂点までの経路が分かっている *)\n | None, [] -> None\n (* 既に終点までの経路が分かっているので返す *)\n | Some _ as ans, _ -> ans\n (* 終点までの経路が分かっていないので,BFSを続行 *)\n | None, ups ->\n q := [];\n List.iter (fun (u, p) ->\n Fun.flip (es u).fold () @@ fun (v, e) () ->\n VHash.update d u @@ function\n | (Some _) as op -> op\n | None ->\n let p' = P.snoc p e in\n q := (v, p') :: !q; Some p') ups;\n bfs_aux t in\n bfs_aux\n end\n\n module ByArray = struct\n module Make (P : Path) = struct\n module C = Core (P) (struct\n type t = P.t option array\n type vertex = int\n let find_opt = Array.get\n let update d v f = d.(v) <- f d.(v)\n end)\n include C\n\n let bfs n e s = C.bfs (Array.make n None) e s\n end\n end\n\n module ByHashtbl = struct\n module Make (VHash : Hashtbl.S) (P : Path) = struct\n module C = Core (P) (struct\n type t = P.t VHash.t\n type vertex = VHash.key\n let find_opt = VHash.find_opt\n let update d v f =\n let opt = VHash.find_opt d v in\n match opt, f opt with\n | None, None -> ()\n | None, Some p -> VHash.add d v p\n | Some _, None -> VHash.remove d v\n | Some p, Some p' -> if p != p' then VHash.replace d v p'\n end)\n include C\n\n let bfs n e s = C.bfs (VHash.create n) e s\n end\n end\n\n module ByMap = struct\n module Make (VMap : Map.S) (P : Path) = struct\n module C = Core (P) (struct\n type t = P.t VMap.t ref\n type vertex = VMap.key\n let find_opt d v = VMap.find_opt v !d\n let update d v f = d := VMap.update v f !d\n end)\n include C\n\n let bfs e s = C.bfs (ref VMap.empty) e s\n end\n end\nend\n\nmodule G = DirectedGraph.ByArray.Make\n (struct\n type t = int\n type edge = int\n let nil = 0\n let snoc _ e = e\n end)\n\nlet () = Scanf.scanf \"%d %d\\n\" @@ fun n m ->\n let es = Array.make n [] in\n for i = 0 to m - 1 do\n Scanf.scanf \"%d %d\\n\" @@ fun a b ->\n es.(a - 1) <- (b - 1, a) :: es.(a - 1);\n es.(b - 1) <- (a - 1, b) :: es.(b - 1);\n done;\n let d = G.bfs n (fun v -> { G.fold = fun f -> List.fold_right f es.(v) }) 0 in\n if List.exists Option.is_none @@ List.init n d\n then print_endline \"No\"\n else begin\n print_endline \"Yes\";\n for i = 1 to n - 1 do\n Printf.printf \"%d\\n\" @@ Option.get @@ d i\n done\n end\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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 6545, "cpu_time_ms": 193, "memory_kb": 32872}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s137077099", "group_id": "codeNet:p02679", "input_text": "open Batteries\nmodule EnumL = Enum.Labels\nmodule ListL = List.Labels\nmodule ArrayL = Array.Labels\n\nlet dbg0 x = Printf.eprintf \"[debug]%s\\n\" @@ dump x\nlet dbg1 x = dbg0 x; x\n\nlet id = identity\n\nlet (++) n m = List.range n `To m\nlet (++-) n m = if n >= m then List.range n `Downto m else []\nlet (++^) n m = if n < m then List.range n `To (pred m) else []\n\nlet scan fmt = Scanf.sscanf (read_line ()) fmt\n\nlet scan_lines n fmt f =\n if n = 0 then []\n else List.map (fun _ -> scan fmt f) (1 ++ n)\n\nlet scan_list ?sep cnv =\n let line = read_line () in\n (match sep with\n | None -> List.map String.of_char @@ String.to_list line\n | Some sep -> String.split_on_char sep line)\n |> List.map cnv\n\nlet scan_array ?sep cnv = Array.of_list @@ scan_list ?sep cnv\n\nlet scan_matrix n m e ?sep conv =\n let arr = Array.make_matrix n m e in\n ListL.iter (0 ++^ n)\n ~f:(fun i -> arr.(i) <- Array.of_list @@ scan_list ?sep conv);\n arr\n\nlet atoi c = Char.code c - Char.code '0'\n\nlet rec powerset = function\n | [] -> [[]]\n | hd::tl ->\n let pws = powerset tl in\n pws @ ListL.map pws ~f:(fun pw -> hd::pw)\n\nlet permutations l =\n let rec interleave x = function\n | [] -> [[x]]\n | (hd::tl) as l ->\n (x::l) :: (interleave x tl |> ListL.map ~f:(fun l -> hd::l)) in\n let rec aux = function\n | [] -> [[]]\n | a::rest ->\n aux rest |> ListL.map ~f:(interleave a) |> List.concat in\n aux l\n\nlet intersection l =\n EnumL.filter ~f:(fun x -> EnumL.exists ~f:((=) x) @@ Enum.clone l)\n\nlet zip l m =\n let n = min (List.length l) (List.length m) in\n List.combine (List.take n l) (List.take n m)\n\nlet lower_bound n f =\n let rec aux l u =\n if u - l > 1 then\n let m = (l + u) / 2 in\n if f m then aux l m\n else aux m u\n else u in aux (-1) n\n\nlet between n x m = n <= x && x < m\n\nmodule ModOp = struct\n let prime = 1_000_000_007\n let (-) a b = (a + prime - b) mod prime\n let (+) a b = (a + b) mod prime\n let ( * ) a b = (a * b) mod prime\n\n let rec pow x n =\n if n = 0 then 1\n else if n mod 2 = 0 then pow (x*x) (n/2)\n else x * pow (x*x) (n/2)\nend\n\nlet n = scan \"%d\" id\nlet ls = scan_lines n \"%d %d\" Tuple2.make\n\nlet rec gcd a b =\n if b = 0 then a\n else gcd b (a mod b)\n\nlet () =\n let open ModOp in\n let (ks, ms) = ListL.partition ls ~f:(fun (a,b) -> a = 0 && b = 0) in\n let ms = ListL.map ms ~f:(fun (a, b) ->\n if a = 0 then (0,1)\n else\n let m = gcd (abs a) (abs b) in\n if a < 0 then (-a/m, -b/m)\n else (a/m, b/m)) in\n let h = Hashtbl.create n in\n ListL.iter ms ~f:(fun (a,b) -> Hashtbl.modify_def 0 (a,b) succ h);\n Hashtbl.map (fun (a,b) n ->\n let x = if b >= 0 then\n (let v = Hashtbl.find_default h (b,-a) 0 in\n Hashtbl.remove_all h (b,-a); v)\n else\n (let v = Hashtbl.find_default h (-b,a) 0 in\n Hashtbl.remove_all h (-b,a); v) in\n pow 2 n + pow 2 x - 1) h\n |> Hashtbl.to_list |> List.map Tuple2.second\n |> ListL.fold_left ~init:1 ~f:( * )\n |> ((+) (List.length ks - 1))\n |> Printf.printf \"%d\\n\"\n", "language": "OCaml", "metadata": {"date": 1592076973, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p02679.html", "problem_id": "p02679", "resource_group": "low_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/OCaml/s137077099.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s137077099", "user_id": "u802614675"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "open Batteries\nmodule EnumL = Enum.Labels\nmodule ListL = List.Labels\nmodule ArrayL = Array.Labels\n\nlet dbg0 x = Printf.eprintf \"[debug]%s\\n\" @@ dump x\nlet dbg1 x = dbg0 x; x\n\nlet id = identity\n\nlet (++) n m = List.range n `To m\nlet (++-) n m = if n >= m then List.range n `Downto m else []\nlet (++^) n m = if n < m then List.range n `To (pred m) else []\n\nlet scan fmt = Scanf.sscanf (read_line ()) fmt\n\nlet scan_lines n fmt f =\n if n = 0 then []\n else List.map (fun _ -> scan fmt f) (1 ++ n)\n\nlet scan_list ?sep cnv =\n let line = read_line () in\n (match sep with\n | None -> List.map String.of_char @@ String.to_list line\n | Some sep -> String.split_on_char sep line)\n |> List.map cnv\n\nlet scan_array ?sep cnv = Array.of_list @@ scan_list ?sep cnv\n\nlet scan_matrix n m e ?sep conv =\n let arr = Array.make_matrix n m e in\n ListL.iter (0 ++^ n)\n ~f:(fun i -> arr.(i) <- Array.of_list @@ scan_list ?sep conv);\n arr\n\nlet atoi c = Char.code c - Char.code '0'\n\nlet rec powerset = function\n | [] -> [[]]\n | hd::tl ->\n let pws = powerset tl in\n pws @ ListL.map pws ~f:(fun pw -> hd::pw)\n\nlet permutations l =\n let rec interleave x = function\n | [] -> [[x]]\n | (hd::tl) as l ->\n (x::l) :: (interleave x tl |> ListL.map ~f:(fun l -> hd::l)) in\n let rec aux = function\n | [] -> [[]]\n | a::rest ->\n aux rest |> ListL.map ~f:(interleave a) |> List.concat in\n aux l\n\nlet intersection l =\n EnumL.filter ~f:(fun x -> EnumL.exists ~f:((=) x) @@ Enum.clone l)\n\nlet zip l m =\n let n = min (List.length l) (List.length m) in\n List.combine (List.take n l) (List.take n m)\n\nlet lower_bound n f =\n let rec aux l u =\n if u - l > 1 then\n let m = (l + u) / 2 in\n if f m then aux l m\n else aux m u\n else u in aux (-1) n\n\nlet between n x m = n <= x && x < m\n\nmodule ModOp = struct\n let prime = 1_000_000_007\n let (-) a b = (a + prime - b) mod prime\n let (+) a b = (a + b) mod prime\n let ( * ) a b = (a * b) mod prime\n\n let rec pow x n =\n if n = 0 then 1\n else if n mod 2 = 0 then pow (x*x) (n/2)\n else x * pow (x*x) (n/2)\nend\n\nlet n = scan \"%d\" id\nlet ls = scan_lines n \"%d %d\" Tuple2.make\n\nlet rec gcd a b =\n if b = 0 then a\n else gcd b (a mod b)\n\nlet () =\n let open ModOp in\n let (ks, ms) = ListL.partition ls ~f:(fun (a,b) -> a = 0 && b = 0) in\n let ms = ListL.map ms ~f:(fun (a, b) ->\n if a = 0 then (0,1)\n else\n let m = gcd (abs a) (abs b) in\n if a < 0 then (-a/m, -b/m)\n else (a/m, b/m)) in\n let h = Hashtbl.create n in\n ListL.iter ms ~f:(fun (a,b) -> Hashtbl.modify_def 0 (a,b) succ h);\n Hashtbl.map (fun (a,b) n ->\n let x = if b >= 0 then\n (let v = Hashtbl.find_default h (b,-a) 0 in\n Hashtbl.remove_all h (b,-a); v)\n else\n (let v = Hashtbl.find_default h (-b,a) 0 in\n Hashtbl.remove_all h (-b,a); v) in\n pow 2 n + pow 2 x - 1) h\n |> Hashtbl.to_list |> List.map Tuple2.second\n |> ListL.fold_left ~init:1 ~f:( * )\n |> ((+) (List.length ks - 1))\n |> Printf.printf \"%d\\n\"\n", "problem_context": "Score: 500 points\n\nProblem Statement\n\nWe have caught N sardines. The deliciousness and fragrantness of the i-th sardine is A_i and B_i, respectively.\n\nWe will choose one or more of these sardines and put them into a cooler. However, two sardines on bad terms cannot be chosen at the same time.\n\nThe i-th and j-th sardines (i \\neq j) are on bad terms if and only if A_i \\cdot A_j + B_i \\cdot B_j = 0.\n\nIn how many ways can we choose the set of sardines to put into the cooler? Since the count can be enormous, print it modulo 1000000007.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 2 \\times 10^5\n\n-10^{18} \\leq A_i, B_i \\leq 10^{18}\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 B_1\n:\nA_N B_N\n\nOutput\n\nPrint the count modulo 1000000007.\n\nSample Input 1\n\n3\n1 2\n-1 1\n2 -1\n\nSample Output 1\n\n5\n\nThere are five ways to choose the set of sardines, as follows:\n\nThe 1-st\n\nThe 1-st and 2-nd\n\nThe 2-nd\n\nThe 2-nd and 3-rd\n\nThe 3-rd\n\nSample Input 2\n\n10\n3 2\n3 2\n-1 1\n2 -1\n-3 -9\n-8 12\n7 7\n8 1\n8 2\n8 4\n\nSample Output 2\n\n479", "sample_input": "3\n1 2\n-1 1\n2 -1\n"}, "reference_outputs": ["5\n"], "source_document_id": "p02679", "source_text": "Score: 500 points\n\nProblem Statement\n\nWe have caught N sardines. The deliciousness and fragrantness of the i-th sardine is A_i and B_i, respectively.\n\nWe will choose one or more of these sardines and put them into a cooler. However, two sardines on bad terms cannot be chosen at the same time.\n\nThe i-th and j-th sardines (i \\neq j) are on bad terms if and only if A_i \\cdot A_j + B_i \\cdot B_j = 0.\n\nIn how many ways can we choose the set of sardines to put into the cooler? Since the count can be enormous, print it modulo 1000000007.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 2 \\times 10^5\n\n-10^{18} \\leq A_i, B_i \\leq 10^{18}\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 B_1\n:\nA_N B_N\n\nOutput\n\nPrint the count modulo 1000000007.\n\nSample Input 1\n\n3\n1 2\n-1 1\n2 -1\n\nSample Output 1\n\n5\n\nThere are five ways to choose the set of sardines, as follows:\n\nThe 1-st\n\nThe 1-st and 2-nd\n\nThe 2-nd\n\nThe 2-nd and 3-rd\n\nThe 3-rd\n\nSample Input 2\n\n10\n3 2\n3 2\n-1 1\n2 -1\n-3 -9\n-8 12\n7 7\n8 1\n8 2\n8 4\n\nSample Output 2\n\n479", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3034, "cpu_time_ms": 619, "memory_kb": 65448}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s175434257", "group_id": "codeNet:p02679", "input_text": "Scanf.scanf \"%d\" (fun n ->\n let rec gcd a b = if b = 0 then a else gcd b (a mod b) in\n let agcd a b = gcd (abs a) (abs b) in\n\n let module M = Map.Make (struct type t = int * int let compare = compare end) in\n\n let rec loop i map a0 b0 c0 d0 e0 =\n if i = n then map, a0, b0, c0, d0, e0 else\n let a, b = Scanf.scanf \" %d %d\" (fun a b -> a, b) in\n if a = 0 && b = 0 then loop (i + 1) map a0 b0 (c0 + 1) d0 e0 else\n if a = 0 then loop (i + 1) map (a0 + 1) b0 c0 d0 e0 else\n if b = 0 then loop (i + 1) map a0 (b0 + 1) c0 d0 e0 else\n if a = b then loop (i + 1) map a0 b0 c0 (d0 + 1) e0 else\n if a = -b then loop (i + 1) map a0 b0 c0 d0 (e0 + 1) else\n let g = agcd a b in\n let a = a / g in\n let b = b / g in\n let flag = if a < 0 && b < 0 || a > 0 && b > 0 then 2 else 0 in\n let flag = if abs a < abs b then flag + 1 else flag in\n let key = if abs a < abs b then abs a, abs b else abs b, abs a in\n let (ca, cb, cc, cd) = try M.find key map with _ -> 0, 0, 0, 0 in\n let abcd = if flag = 0 then ca + 1, cb, cc, cd else\n if flag = 1 then ca, cb + 1, cc, cd else\n if flag = 2 then ca, cb, cc + 1, cd else\n ca, cb, cc, cd + 1\n in\n let map = M.add key abcd map in\n loop (i + 1) map a0 b0 c0 d0 e0\n in\n let map, a0, b0, c0, d0, e0 = loop 0 M.empty 0 0 0 0 0 in\n let m = 1_000_000_007 in\n let ( +@) a b = (a + b) mod m in\n let ( -@) a b = (((a - b) mod m) + m) mod m in\n let ( *@) a b = (a * b) mod m in\n\n let powmod a b =\n let rec loop r i acc =\n if i = 0 then acc else\n loop (r *@ r) (i lsr 1) (if i land 1 = 1 then r *@ acc else acc)\n in\n loop a b 1\n in\n\n let ans1 =\n M.fold (fun (k1, k2) (ca, cb, cc, cd) acc ->\n (powmod 2 ca +@ powmod 2 cd -@ 1) *@ (powmod 2 cb +@ powmod 2 cc -@ 1) *@ acc\n ) map 1\n in\n let ans2 = ans1 *@ (powmod 2 d0 +@ powmod 2 e0 -@ 1) in\n let ans3 = ans2 *@ (powmod 2 a0 +@ powmod 2 b0 -@ 1) in\n if c0 = 1 && n = 1 then Printf.printf \"%d\\n\" 1\n else Printf.printf \"%d\\n\" (ans3 -@ 1)\n)", "language": "OCaml", "metadata": {"date": 1589769319, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p02679.html", "problem_id": "p02679", "resource_group": "low_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/OCaml/s175434257.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s175434257", "user_id": "u342443598"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "Scanf.scanf \"%d\" (fun n ->\n let rec gcd a b = if b = 0 then a else gcd b (a mod b) in\n let agcd a b = gcd (abs a) (abs b) in\n\n let module M = Map.Make (struct type t = int * int let compare = compare end) in\n\n let rec loop i map a0 b0 c0 d0 e0 =\n if i = n then map, a0, b0, c0, d0, e0 else\n let a, b = Scanf.scanf \" %d %d\" (fun a b -> a, b) in\n if a = 0 && b = 0 then loop (i + 1) map a0 b0 (c0 + 1) d0 e0 else\n if a = 0 then loop (i + 1) map (a0 + 1) b0 c0 d0 e0 else\n if b = 0 then loop (i + 1) map a0 (b0 + 1) c0 d0 e0 else\n if a = b then loop (i + 1) map a0 b0 c0 (d0 + 1) e0 else\n if a = -b then loop (i + 1) map a0 b0 c0 d0 (e0 + 1) else\n let g = agcd a b in\n let a = a / g in\n let b = b / g in\n let flag = if a < 0 && b < 0 || a > 0 && b > 0 then 2 else 0 in\n let flag = if abs a < abs b then flag + 1 else flag in\n let key = if abs a < abs b then abs a, abs b else abs b, abs a in\n let (ca, cb, cc, cd) = try M.find key map with _ -> 0, 0, 0, 0 in\n let abcd = if flag = 0 then ca + 1, cb, cc, cd else\n if flag = 1 then ca, cb + 1, cc, cd else\n if flag = 2 then ca, cb, cc + 1, cd else\n ca, cb, cc, cd + 1\n in\n let map = M.add key abcd map in\n loop (i + 1) map a0 b0 c0 d0 e0\n in\n let map, a0, b0, c0, d0, e0 = loop 0 M.empty 0 0 0 0 0 in\n let m = 1_000_000_007 in\n let ( +@) a b = (a + b) mod m in\n let ( -@) a b = (((a - b) mod m) + m) mod m in\n let ( *@) a b = (a * b) mod m in\n\n let powmod a b =\n let rec loop r i acc =\n if i = 0 then acc else\n loop (r *@ r) (i lsr 1) (if i land 1 = 1 then r *@ acc else acc)\n in\n loop a b 1\n in\n\n let ans1 =\n M.fold (fun (k1, k2) (ca, cb, cc, cd) acc ->\n (powmod 2 ca +@ powmod 2 cd -@ 1) *@ (powmod 2 cb +@ powmod 2 cc -@ 1) *@ acc\n ) map 1\n in\n let ans2 = ans1 *@ (powmod 2 d0 +@ powmod 2 e0 -@ 1) in\n let ans3 = ans2 *@ (powmod 2 a0 +@ powmod 2 b0 -@ 1) in\n if c0 = 1 && n = 1 then Printf.printf \"%d\\n\" 1\n else Printf.printf \"%d\\n\" (ans3 -@ 1)\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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2316, "cpu_time_ms": 826, "memory_kb": 42800}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s246303397", "group_id": "codeNet:p02681", "input_text": "let () = \n let s = read_line () in\n let t = read_line () in\n print_endline @@\n if\n List.for_all (fun i -> s.[i] = t.[i]) @@\n List.init (String.length s) Fun.id\n then \"Yes\"\n else \"No\"", "language": "OCaml", "metadata": {"date": 1591585968, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p02681.html", "problem_id": "p02681", "resource_group": "low_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/OCaml/s246303397.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s246303397", "user_id": "u052332717"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "let () = \n let s = read_line () in\n let t = read_line () in\n print_endline @@\n if\n List.for_all (fun i -> s.[i] = t.[i]) @@\n List.init (String.length s) Fun.id\n then \"Yes\"\n else \"No\"", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 8, "memory_kb": 3588}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s416303019", "group_id": "codeNet:p02681", "input_text": "let () = Scanf.scanf \"%d\\n\" @@ fun n ->\n let ss =\n Array.init n @@ fun _ ->\n Scanf.scanf \"%s\\n\" @@ fun s ->\n Array.fold_left (fun (m, c) -> function\n | '(' -> (m, c + 1)\n | ')' -> (min m (c - 1), c - 1)) (0, 0) @@\n Array.init (String.length s) (String.get s) in\n print_endline @@\n if\n ( <> ) 0 @@\n Array.fold_right (fun (_, c) -> ( + ) c) ss 0\n then \"No\"\n else begin\n Array.sort (fun (m, c) (m', c') -> compare (m' + c', c') (m + c, c)) ss;\n try\n ignore\n (Array.fold_left (fun x (m, c) ->\n if x + m < 0 then raise Not_found; x + c) 0 ss);\n \"Yes\"\n with Not_found -> \"No\"\n end\n\n", "language": "OCaml", "metadata": {"date": 1589164807, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p02681.html", "problem_id": "p02681", "resource_group": "low_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/OCaml/s416303019.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s416303019", "user_id": "u504158101"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "let () = Scanf.scanf \"%d\\n\" @@ fun n ->\n let ss =\n Array.init n @@ fun _ ->\n Scanf.scanf \"%s\\n\" @@ fun s ->\n Array.fold_left (fun (m, c) -> function\n | '(' -> (m, c + 1)\n | ')' -> (min m (c - 1), c - 1)) (0, 0) @@\n Array.init (String.length s) (String.get s) in\n print_endline @@\n if\n ( <> ) 0 @@\n Array.fold_right (fun (_, c) -> ( + ) c) ss 0\n then \"No\"\n else begin\n Array.sort (fun (m, c) (m', c') -> compare (m' + c', c') (m + c, c)) ss;\n try\n ignore\n (Array.fold_left (fun x (m, c) ->\n if x + m < 0 then raise Not_found; x + c) 0 ss);\n \"Yes\"\n with Not_found -> \"No\"\n end\n\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nTakahashi wants to be a member of some web service.\n\nHe tried to register himself with the ID S, which turned out to be already used by another user.\n\nThus, he decides to register using a string obtained by appending one character at the end of S as his ID.\n\nHe is now trying to register with the ID T. Determine whether this string satisfies the property above.\n\nConstraints\n\nS and T are strings consisting of lowercase English letters.\n\n1 \\leq |S| \\leq 10\n\n|T| = |S| + 1\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\nT\n\nOutput\n\nIf T satisfies the property in Problem Statement, print Yes; otherwise, print No.\n\nSample Input 1\n\nchokudai\nchokudaiz\n\nSample Output 1\n\nYes\n\nchokudaiz can be obtained by appending z at the end of chokudai.\n\nSample Input 2\n\nsnuke\nsnekee\n\nSample Output 2\n\nNo\n\nsnekee cannot be obtained by appending one character at the end of snuke.\n\nSample Input 3\n\na\naa\n\nSample Output 3\n\nYes", "sample_input": "chokudai\nchokudaiz\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02681", "source_text": "Score : 100 points\n\nProblem Statement\n\nTakahashi wants to be a member of some web service.\n\nHe tried to register himself with the ID S, which turned out to be already used by another user.\n\nThus, he decides to register using a string obtained by appending one character at the end of S as his ID.\n\nHe is now trying to register with the ID T. Determine whether this string satisfies the property above.\n\nConstraints\n\nS and T are strings consisting of lowercase English letters.\n\n1 \\leq |S| \\leq 10\n\n|T| = |S| + 1\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\nT\n\nOutput\n\nIf T satisfies the property in Problem Statement, print Yes; otherwise, print No.\n\nSample Input 1\n\nchokudai\nchokudaiz\n\nSample Output 1\n\nYes\n\nchokudaiz can be obtained by appending z at the end of chokudai.\n\nSample Input 2\n\nsnuke\nsnekee\n\nSample Output 2\n\nNo\n\nsnekee cannot be obtained by appending one character at the end of snuke.\n\nSample Input 3\n\na\naa\n\nSample Output 3\n\nYes", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 7, "memory_kb": 3844}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s357402683", "group_id": "codeNet:p02682", "input_text": "open Scanf\nopen Printf\n\nlet easy_linear a b c k =\n if k <= a then k\n else if k <= a + b then a\n else if k <= a + b + c then a - (k - (a + b))\n else a - c\n\nlet () = scanf \"%d %d %d %d\" easy_linear |> printf \"%d\\n\"", "language": "OCaml", "metadata": {"date": 1596856480, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p02682.html", "problem_id": "p02682", "resource_group": "low_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/OCaml/s357402683.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s357402683", "user_id": "u272377260"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "open Scanf\nopen Printf\n\nlet easy_linear a b c k =\n if k <= a then k\n else if k <= a + b then a\n else if k <= a + b + c then a - (k - (a + b))\n else a - c\n\nlet () = scanf \"%d %d %d %d\" easy_linear |> printf \"%d\\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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 216, "cpu_time_ms": 7, "memory_kb": 3792}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s389448790", "group_id": "codeNet:p02682", "input_text": "open Batteries\nopen Printf\nopen Scanf\n\nlet ($) g f x = g (f x)\nlet nil = ()\n\nmodule MyList = struct\n include List\n let foldl = fold_left\n let foldr = fold_right\n \n let flatmap f ls = concat @@ map f ls\n\n let zipf = map2\n let zipfi = map2i\nend\n\nmodule L = MyList\n\nlet atoi = int_of_string\nlet itoa = string_of_int\nlet atof = float_of_string\nlet ftoa = string_of_float\nlet ctoi = int_of_char\nlet itoc = char_of_int\n\nlet stocl = String.to_list\nlet cltos = String.of_list\nlet spsp s = String.split_on_char ' ' s\n\nmodule MyString = struct\n include String\n\n let map' f s = L.map f (stocl s)\n let mapi' f s = L.map f (stocl s)\n\n let zipf f a b = L.zipf f (stocl a) (stocl b)\n let zipfi f a b = L.zipfi f (stocl a) (stocl b)\n\n let mkstr f sep ls =\n L.foldl (fun acc x -> acc ^ sep ^ (f x)) (f @@ L.hd ls) (List.tl ls)\nend\n\nmodule S = MyString\n\nlet tup2 a b = (a, b)\nlet tup3 a b c = (a, b, c)\nlet tup4 a b c d = (a, b, c, d)\n\nlet rds () = read_line ()\nlet rds2 () = scanf \"%s %s\\n\" tup2\n\nlet rdi () = atoi @@ rds ()\nlet rdi2 () = scanf \"%d %d\\n\" tup2\nlet rdi3 () = scanf \"%d %d %d\\n\" tup3\nlet rdi4 () = scanf \"%d %d %d %d\\n\" tup4\n\nlet rdhs () = spsp @@ rds ()\nlet rdhi () = rdhs () |> L.map atoi\n\nlet rdvs n rdf = L.init n (fun _ -> rdf ())\n\nlet rdvi n = rdvs n rdi\nlet rdvi2 n = rdvs n rdi2\nlet rdvi3 n = rdvs n rdi3\nlet rdvi4 n = rdvs n rdi4\n\nlet puts s = print_endline s\nlet putyn b = puts (if b then \"Yes\" else \"No\")\nlet puti i = puts @@ itoa i\n\nlet _ =\n let (a,b,c,k) = rdi4 () in\n let r =\n if k <= a + b then (min a k)\n else a - (k - (a + b))\n in puti r;;", "language": "OCaml", "metadata": {"date": 1589748426, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p02682.html", "problem_id": "p02682", "resource_group": "low_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/OCaml/s389448790.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s389448790", "user_id": "u970139668"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "open Batteries\nopen Printf\nopen Scanf\n\nlet ($) g f x = g (f x)\nlet nil = ()\n\nmodule MyList = struct\n include List\n let foldl = fold_left\n let foldr = fold_right\n \n let flatmap f ls = concat @@ map f ls\n\n let zipf = map2\n let zipfi = map2i\nend\n\nmodule L = MyList\n\nlet atoi = int_of_string\nlet itoa = string_of_int\nlet atof = float_of_string\nlet ftoa = string_of_float\nlet ctoi = int_of_char\nlet itoc = char_of_int\n\nlet stocl = String.to_list\nlet cltos = String.of_list\nlet spsp s = String.split_on_char ' ' s\n\nmodule MyString = struct\n include String\n\n let map' f s = L.map f (stocl s)\n let mapi' f s = L.map f (stocl s)\n\n let zipf f a b = L.zipf f (stocl a) (stocl b)\n let zipfi f a b = L.zipfi f (stocl a) (stocl b)\n\n let mkstr f sep ls =\n L.foldl (fun acc x -> acc ^ sep ^ (f x)) (f @@ L.hd ls) (List.tl ls)\nend\n\nmodule S = MyString\n\nlet tup2 a b = (a, b)\nlet tup3 a b c = (a, b, c)\nlet tup4 a b c d = (a, b, c, d)\n\nlet rds () = read_line ()\nlet rds2 () = scanf \"%s %s\\n\" tup2\n\nlet rdi () = atoi @@ rds ()\nlet rdi2 () = scanf \"%d %d\\n\" tup2\nlet rdi3 () = scanf \"%d %d %d\\n\" tup3\nlet rdi4 () = scanf \"%d %d %d %d\\n\" tup4\n\nlet rdhs () = spsp @@ rds ()\nlet rdhi () = rdhs () |> L.map atoi\n\nlet rdvs n rdf = L.init n (fun _ -> rdf ())\n\nlet rdvi n = rdvs n rdi\nlet rdvi2 n = rdvs n rdi2\nlet rdvi3 n = rdvs n rdi3\nlet rdvi4 n = rdvs n rdi4\n\nlet puts s = print_endline s\nlet putyn b = puts (if b then \"Yes\" else \"No\")\nlet puti i = puts @@ itoa i\n\nlet _ =\n let (a,b,c,k) = rdi4 () in\n let r =\n if k <= a + b then (min a k)\n else a - (k - (a + b))\n in puti r;;", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1578, "cpu_time_ms": 4, "memory_kb": 5532}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s374549825", "group_id": "codeNet:p02683", "input_text": "open Batteries\nmodule EnumL = Enum.Labels\nmodule ListL = List.Labels\nmodule ArrayL = Array.Labels\n\nlet dbg0 x = Printf.eprintf \"[debug]%s\\n\" @@ dump x\nlet dbg1 x = dbg0 x; x\n\nlet id = identity\n\nlet (++) n m = List.range n `To m\nlet (++-) n m = if n >= m then List.range n `Downto m else []\nlet (++^) n m = if n < m then List.range n `To (pred m) else []\n\nmodule ModOp = struct\n let prime = 1_000_000_007\n let (-) a b = (a + prime - b) mod prime\n let (+) a b = (a + b) mod prime\n let ( * ) a b = (a * b) mod prime\n\n let rec pow x n =\n if n = 0 then 1\n else if n mod 2 = 0 then pow (x*x) (n/2)\n else x * pow (x*x) (n/2)\nend\n\nlet scan fmt = Scanf.sscanf (read_line ()) fmt\n\nlet scan_lines n fmt f =\n if n = 0 then []\n else List.map (fun _ -> scan fmt f) (1 ++ n)\n\nlet scan_list ?sep cnv =\n let line = read_line () in\n (match sep with\n | None -> List.map String.of_char @@ String.to_list line\n | Some sep -> String.split_on_char sep line)\n |> List.map cnv\n\nlet scan_array ?sep cnv = Array.of_list @@ scan_list ?sep cnv\n\nlet scan_matrix n m e ?sep conv =\n let arr = Array.make_matrix n m e in\n ListL.iter (0 ++^ n)\n ~f:(fun i -> arr.(i) <- Array.of_list @@ scan_list ?sep conv);\n arr\n\nlet atoi c = Char.code c - Char.code '0'\n\nlet rec powerset = function\n | [] -> [[]]\n | hd::tl ->\n let pws = powerset tl in\n pws @ ListL.map pws ~f:(fun pw -> hd::pw)\n\nlet permutations l =\n let rec interleave x = function\n | [] -> [[x]]\n | (hd::tl) as l ->\n (x::l) :: (interleave x tl |> ListL.map ~f:(fun l -> hd::l)) in\n let rec aux = function\n | [] -> [[]]\n | a::rest ->\n aux rest |> ListL.map ~f:(interleave a) |> List.concat in\n aux l\n\nlet intersection l =\n EnumL.filter ~f:(fun x -> EnumL.exists ~f:((=) x) @@ Enum.clone l)\n\nlet zip l m =\n let n = min (List.length l) (List.length m) in\n List.combine (List.take n l) (List.take n m)\n\nlet lower_bound n f =\n let rec aux l u =\n if u - l > 1 then\n let m = (l + u) / 2 in\n if f m then aux l m\n else aux m u\n else u in aux (-1) n\n\nlet between n x m = n <= x && x < m\n\nlet (n,m,x) = scan \"%d %d %d\" Tuple3.make\nlet mat = scan_matrix n m ~sep:' ' 0 Int.of_string\n\nlet () =\n ListL.map (powerset (0++^n)) ~f:(fun ls ->\n let arr = Array.make m 0 in\n let w = ref 0 in\n ListL.iter ls ~f:(fun i ->\n w := !w + mat.(i).(0);\n ArrayL.iteri (Array.sub mat.(i) 1 m) ~f:(fun i v -> arr.(i) <- arr.(i) + v));\n if ArrayL.for_all arr ~f:((<=) x) then !w\n else Int.max_num)\n |> List.min\n |> (fun v -> if v = Int.max_num then -1 else v)\n |> Printf.printf \"%d\\n\"\n", "language": "OCaml", "metadata": {"date": 1592080724, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p02683.html", "problem_id": "p02683", "resource_group": "low_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/OCaml/s374549825.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s374549825", "user_id": "u802614675"}, "prompt_components": {"gold_output": "120\n", "input_to_evaluate": "open Batteries\nmodule EnumL = Enum.Labels\nmodule ListL = List.Labels\nmodule ArrayL = Array.Labels\n\nlet dbg0 x = Printf.eprintf \"[debug]%s\\n\" @@ dump x\nlet dbg1 x = dbg0 x; x\n\nlet id = identity\n\nlet (++) n m = List.range n `To m\nlet (++-) n m = if n >= m then List.range n `Downto m else []\nlet (++^) n m = if n < m then List.range n `To (pred m) else []\n\nmodule ModOp = struct\n let prime = 1_000_000_007\n let (-) a b = (a + prime - b) mod prime\n let (+) a b = (a + b) mod prime\n let ( * ) a b = (a * b) mod prime\n\n let rec pow x n =\n if n = 0 then 1\n else if n mod 2 = 0 then pow (x*x) (n/2)\n else x * pow (x*x) (n/2)\nend\n\nlet scan fmt = Scanf.sscanf (read_line ()) fmt\n\nlet scan_lines n fmt f =\n if n = 0 then []\n else List.map (fun _ -> scan fmt f) (1 ++ n)\n\nlet scan_list ?sep cnv =\n let line = read_line () in\n (match sep with\n | None -> List.map String.of_char @@ String.to_list line\n | Some sep -> String.split_on_char sep line)\n |> List.map cnv\n\nlet scan_array ?sep cnv = Array.of_list @@ scan_list ?sep cnv\n\nlet scan_matrix n m e ?sep conv =\n let arr = Array.make_matrix n m e in\n ListL.iter (0 ++^ n)\n ~f:(fun i -> arr.(i) <- Array.of_list @@ scan_list ?sep conv);\n arr\n\nlet atoi c = Char.code c - Char.code '0'\n\nlet rec powerset = function\n | [] -> [[]]\n | hd::tl ->\n let pws = powerset tl in\n pws @ ListL.map pws ~f:(fun pw -> hd::pw)\n\nlet permutations l =\n let rec interleave x = function\n | [] -> [[x]]\n | (hd::tl) as l ->\n (x::l) :: (interleave x tl |> ListL.map ~f:(fun l -> hd::l)) in\n let rec aux = function\n | [] -> [[]]\n | a::rest ->\n aux rest |> ListL.map ~f:(interleave a) |> List.concat in\n aux l\n\nlet intersection l =\n EnumL.filter ~f:(fun x -> EnumL.exists ~f:((=) x) @@ Enum.clone l)\n\nlet zip l m =\n let n = min (List.length l) (List.length m) in\n List.combine (List.take n l) (List.take n m)\n\nlet lower_bound n f =\n let rec aux l u =\n if u - l > 1 then\n let m = (l + u) / 2 in\n if f m then aux l m\n else aux m u\n else u in aux (-1) n\n\nlet between n x m = n <= x && x < m\n\nlet (n,m,x) = scan \"%d %d %d\" Tuple3.make\nlet mat = scan_matrix n m ~sep:' ' 0 Int.of_string\n\nlet () =\n ListL.map (powerset (0++^n)) ~f:(fun ls ->\n let arr = Array.make m 0 in\n let w = ref 0 in\n ListL.iter ls ~f:(fun i ->\n w := !w + mat.(i).(0);\n ArrayL.iteri (Array.sub mat.(i) 1 m) ~f:(fun i v -> arr.(i) <- arr.(i) + v));\n if ArrayL.for_all arr ~f:((<=) x) then !w\n else Int.max_num)\n |> List.min\n |> (fun v -> if v = Int.max_num then -1 else v)\n |> Printf.printf \"%d\\n\"\n", "problem_context": "Score : 300 points\n\nProblem\n\nTakahashi, who is a novice in competitive programming, wants to learn M algorithms.\nInitially, his understanding level of each of the M algorithms is 0.\n\nTakahashi is visiting a bookstore, where he finds N books on algorithms.\nThe i-th book (1\\leq i\\leq N) is sold for C_i yen (the currency of Japan). If he buys and reads it, his understanding level of the j-th algorithm will increase by A_{i,j} for each j (1\\leq j\\leq M).\nThere is no other way to increase the understanding levels of the algorithms.\n\nTakahashi's objective is to make his understanding levels of all the M algorithms X or higher. Determine whether this objective is achievable. If it is achievable, find the minimum amount of money needed to achieve it.\n\nConstraints\n\nAll values in input are integers.\n\n1\\leq N, M\\leq 12\n\n1\\leq X\\leq 10^5\n\n1\\leq C_i \\leq 10^5\n\n0\\leq A_{i, j} \\leq 10^5\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M X\nC_1 A_{1,1} A_{1,2} \\cdots A_{1,M}\nC_2 A_{2,1} A_{2,2} \\cdots A_{2,M}\n\\vdots\nC_N A_{N,1} A_{N,2} \\cdots A_{N,M}\n\nOutput\n\nIf the objective is not achievable, print -1; otherwise, print the minimum amount of money needed to achieve it.\n\nSample Input 1\n\n3 3 10\n60 2 2 4\n70 8 7 9\n50 2 3 9\n\nSample Output 1\n\n120\n\nBuying the second and third books makes his understanding levels of all the algorithms 10 or higher, at the minimum cost possible.\n\nSample Input 2\n\n3 3 10\n100 3 1 4\n100 1 5 9\n100 2 6 5\n\nSample Output 2\n\n-1\n\nBuying all the books is still not enough to make his understanding levels of all the algorithms 10 or higher.\n\nSample Input 3\n\n8 5 22\n100 3 7 5 3 1\n164 4 5 2 7 8\n334 7 2 7 2 9\n234 4 7 2 8 2\n541 5 4 3 3 6\n235 4 8 6 9 7\n394 3 6 1 6 2\n872 8 4 3 7 2\n\nSample Output 3\n\n1067", "sample_input": "3 3 10\n60 2 2 4\n70 8 7 9\n50 2 3 9\n"}, "reference_outputs": ["120\n"], "source_document_id": "p02683", "source_text": "Score : 300 points\n\nProblem\n\nTakahashi, who is a novice in competitive programming, wants to learn M algorithms.\nInitially, his understanding level of each of the M algorithms is 0.\n\nTakahashi is visiting a bookstore, where he finds N books on algorithms.\nThe i-th book (1\\leq i\\leq N) is sold for C_i yen (the currency of Japan). If he buys and reads it, his understanding level of the j-th algorithm will increase by A_{i,j} for each j (1\\leq j\\leq M).\nThere is no other way to increase the understanding levels of the algorithms.\n\nTakahashi's objective is to make his understanding levels of all the M algorithms X or higher. Determine whether this objective is achievable. If it is achievable, find the minimum amount of money needed to achieve it.\n\nConstraints\n\nAll values in input are integers.\n\n1\\leq N, M\\leq 12\n\n1\\leq X\\leq 10^5\n\n1\\leq C_i \\leq 10^5\n\n0\\leq A_{i, j} \\leq 10^5\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M X\nC_1 A_{1,1} A_{1,2} \\cdots A_{1,M}\nC_2 A_{2,1} A_{2,2} \\cdots A_{2,M}\n\\vdots\nC_N A_{N,1} A_{N,2} \\cdots A_{N,M}\n\nOutput\n\nIf the objective is not achievable, print -1; otherwise, print the minimum amount of money needed to achieve it.\n\nSample Input 1\n\n3 3 10\n60 2 2 4\n70 8 7 9\n50 2 3 9\n\nSample Output 1\n\n120\n\nBuying the second and third books makes his understanding levels of all the algorithms 10 or higher, at the minimum cost possible.\n\nSample Input 2\n\n3 3 10\n100 3 1 4\n100 1 5 9\n100 2 6 5\n\nSample Output 2\n\n-1\n\nBuying all the books is still not enough to make his understanding levels of all the algorithms 10 or higher.\n\nSample Input 3\n\n8 5 22\n100 3 7 5 3 1\n164 4 5 2 7 8\n334 7 2 7 2 9\n234 4 7 2 8 2\n541 5 4 3 3 6\n235 4 8 6 9 7\n394 3 6 1 6 2\n872 8 4 3 7 2\n\nSample Output 3\n\n1067", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2607, "cpu_time_ms": 16, "memory_kb": 7796}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s059371158", "group_id": "codeNet:p02683", "input_text": "open Batteries\nmodule EnumL = Enum.Labels\nmodule ListL = List.Labels\nmodule ArrayL = Array.Labels\n\nlet dbg0 x = Printf.eprintf \"[debug]%s\\n\" @@ dump x\nlet dbg1 x = dbg0 x; x\n\nlet id = identity\n\nlet (++) n m = List.range n `To m\nlet (++-) n m = if n >= m then List.range n `Downto m else []\nlet (++^) n m = if n < m then List.range n `To (pred m) else []\n\nmodule ModOp = struct\n let prime = 1_000_000_007\n let (-) a b = (a + prime - b) mod prime\n let (+) a b = (a + b) mod prime\n let ( * ) a b = (a * b) mod prime\n\n let rec pow x n =\n if n = 0 then 1\n else if n mod 2 = 0 then pow (x*x) (n/2)\n else x * pow (x*x) (n/2)\nend\n\nlet scan fmt = Scanf.sscanf (read_line ()) fmt\n\nlet scan_lines n fmt f =\n if n = 0 then []\n else List.map (fun _ -> scan fmt f) (1 ++ n)\n\nlet scan_list ?sep cnv =\n let line = read_line () in\n (match sep with\n | None -> List.map String.of_char @@ String.to_list line\n | Some sep -> String.split_on_char sep line)\n |> List.map cnv\n\nlet scan_array ?sep cnv = Array.of_list @@ scan_list ?sep cnv\n\nlet scan_matrix n m e ?sep conv =\n let arr = Array.make_matrix n m e in\n ListL.iter (0 ++^ n)\n ~f:(fun i -> arr.(i) <- Array.of_list @@ scan_list ?sep conv);\n arr\n\nlet atoi c = Char.code c - Char.code '0'\n\nlet rec powerset = function\n | [] -> [[]]\n | hd::tl ->\n let pws = powerset tl in\n pws @ ListL.map pws ~f:(fun pw -> hd::pw)\n\nlet permutations l =\n let rec interleave x = function\n | [] -> [[x]]\n | (hd::tl) as l ->\n (x::l) :: (interleave x tl |> ListL.map ~f:(fun l -> hd::l)) in\n let rec aux = function\n | [] -> [[]]\n | a::rest ->\n aux rest |> ListL.map ~f:(interleave a) |> List.concat in\n aux l\n\nlet intersection l =\n EnumL.filter ~f:(fun x -> EnumL.exists ~f:((=) x) @@ Enum.clone l)\n\nlet zip l m =\n let n = min (List.length l) (List.length m) in\n List.combine (List.take n l) (List.take n m)\n\nlet lower_bound n f =\n let rec aux l u =\n if u - l > 1 then\n let m = (l + u) / 2 in\n if f m then aux l m\n else aux m u\n else u in aux (-1) n\n\nlet between n x m = n <= x && x < m\n\nlet (n,m,x) = scan \"%d %d %d\" Tuple3.make\nlet mat = scan_matrix n m ~sep:' ' 0 Int.of_string\n\nlet () =\n ListL.map (permutations (0++n)) ~f:(fun ls ->\n let arr = Array.make m 0 in\n let v = ref 0 in\n ListL.iter ls ~f:(fun i ->\n v := !v + mat.(i).(0);\n ArrayL.iteri (Array.sub mat.(i) 1 (m-1)) ~f:(fun i v ->\n arr.(i) <- arr.(i) + v\n )\n );\n if ArrayL.for_all arr ~f:(fun v -> v >= x) then !v\n else Int.max_num\n )\n |> List.min\n |> (fun v -> if v = Int.max_num then -1 else v)\n |> Printf.printf \"%d\\n\"\n", "language": "OCaml", "metadata": {"date": 1592080250, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p02683.html", "problem_id": "p02683", "resource_group": "low_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/OCaml/s059371158.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s059371158", "user_id": "u802614675"}, "prompt_components": {"gold_output": "120\n", "input_to_evaluate": "open Batteries\nmodule EnumL = Enum.Labels\nmodule ListL = List.Labels\nmodule ArrayL = Array.Labels\n\nlet dbg0 x = Printf.eprintf \"[debug]%s\\n\" @@ dump x\nlet dbg1 x = dbg0 x; x\n\nlet id = identity\n\nlet (++) n m = List.range n `To m\nlet (++-) n m = if n >= m then List.range n `Downto m else []\nlet (++^) n m = if n < m then List.range n `To (pred m) else []\n\nmodule ModOp = struct\n let prime = 1_000_000_007\n let (-) a b = (a + prime - b) mod prime\n let (+) a b = (a + b) mod prime\n let ( * ) a b = (a * b) mod prime\n\n let rec pow x n =\n if n = 0 then 1\n else if n mod 2 = 0 then pow (x*x) (n/2)\n else x * pow (x*x) (n/2)\nend\n\nlet scan fmt = Scanf.sscanf (read_line ()) fmt\n\nlet scan_lines n fmt f =\n if n = 0 then []\n else List.map (fun _ -> scan fmt f) (1 ++ n)\n\nlet scan_list ?sep cnv =\n let line = read_line () in\n (match sep with\n | None -> List.map String.of_char @@ String.to_list line\n | Some sep -> String.split_on_char sep line)\n |> List.map cnv\n\nlet scan_array ?sep cnv = Array.of_list @@ scan_list ?sep cnv\n\nlet scan_matrix n m e ?sep conv =\n let arr = Array.make_matrix n m e in\n ListL.iter (0 ++^ n)\n ~f:(fun i -> arr.(i) <- Array.of_list @@ scan_list ?sep conv);\n arr\n\nlet atoi c = Char.code c - Char.code '0'\n\nlet rec powerset = function\n | [] -> [[]]\n | hd::tl ->\n let pws = powerset tl in\n pws @ ListL.map pws ~f:(fun pw -> hd::pw)\n\nlet permutations l =\n let rec interleave x = function\n | [] -> [[x]]\n | (hd::tl) as l ->\n (x::l) :: (interleave x tl |> ListL.map ~f:(fun l -> hd::l)) in\n let rec aux = function\n | [] -> [[]]\n | a::rest ->\n aux rest |> ListL.map ~f:(interleave a) |> List.concat in\n aux l\n\nlet intersection l =\n EnumL.filter ~f:(fun x -> EnumL.exists ~f:((=) x) @@ Enum.clone l)\n\nlet zip l m =\n let n = min (List.length l) (List.length m) in\n List.combine (List.take n l) (List.take n m)\n\nlet lower_bound n f =\n let rec aux l u =\n if u - l > 1 then\n let m = (l + u) / 2 in\n if f m then aux l m\n else aux m u\n else u in aux (-1) n\n\nlet between n x m = n <= x && x < m\n\nlet (n,m,x) = scan \"%d %d %d\" Tuple3.make\nlet mat = scan_matrix n m ~sep:' ' 0 Int.of_string\n\nlet () =\n ListL.map (permutations (0++n)) ~f:(fun ls ->\n let arr = Array.make m 0 in\n let v = ref 0 in\n ListL.iter ls ~f:(fun i ->\n v := !v + mat.(i).(0);\n ArrayL.iteri (Array.sub mat.(i) 1 (m-1)) ~f:(fun i v ->\n arr.(i) <- arr.(i) + v\n )\n );\n if ArrayL.for_all arr ~f:(fun v -> v >= x) then !v\n else Int.max_num\n )\n |> List.min\n |> (fun v -> if v = Int.max_num then -1 else v)\n |> Printf.printf \"%d\\n\"\n", "problem_context": "Score : 300 points\n\nProblem\n\nTakahashi, who is a novice in competitive programming, wants to learn M algorithms.\nInitially, his understanding level of each of the M algorithms is 0.\n\nTakahashi is visiting a bookstore, where he finds N books on algorithms.\nThe i-th book (1\\leq i\\leq N) is sold for C_i yen (the currency of Japan). If he buys and reads it, his understanding level of the j-th algorithm will increase by A_{i,j} for each j (1\\leq j\\leq M).\nThere is no other way to increase the understanding levels of the algorithms.\n\nTakahashi's objective is to make his understanding levels of all the M algorithms X or higher. Determine whether this objective is achievable. If it is achievable, find the minimum amount of money needed to achieve it.\n\nConstraints\n\nAll values in input are integers.\n\n1\\leq N, M\\leq 12\n\n1\\leq X\\leq 10^5\n\n1\\leq C_i \\leq 10^5\n\n0\\leq A_{i, j} \\leq 10^5\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M X\nC_1 A_{1,1} A_{1,2} \\cdots A_{1,M}\nC_2 A_{2,1} A_{2,2} \\cdots A_{2,M}\n\\vdots\nC_N A_{N,1} A_{N,2} \\cdots A_{N,M}\n\nOutput\n\nIf the objective is not achievable, print -1; otherwise, print the minimum amount of money needed to achieve it.\n\nSample Input 1\n\n3 3 10\n60 2 2 4\n70 8 7 9\n50 2 3 9\n\nSample Output 1\n\n120\n\nBuying the second and third books makes his understanding levels of all the algorithms 10 or higher, at the minimum cost possible.\n\nSample Input 2\n\n3 3 10\n100 3 1 4\n100 1 5 9\n100 2 6 5\n\nSample Output 2\n\n-1\n\nBuying all the books is still not enough to make his understanding levels of all the algorithms 10 or higher.\n\nSample Input 3\n\n8 5 22\n100 3 7 5 3 1\n164 4 5 2 7 8\n334 7 2 7 2 9\n234 4 7 2 8 2\n541 5 4 3 3 6\n235 4 8 6 9 7\n394 3 6 1 6 2\n872 8 4 3 7 2\n\nSample Output 3\n\n1067", "sample_input": "3 3 10\n60 2 2 4\n70 8 7 9\n50 2 3 9\n"}, "reference_outputs": ["120\n"], "source_document_id": "p02683", "source_text": "Score : 300 points\n\nProblem\n\nTakahashi, who is a novice in competitive programming, wants to learn M algorithms.\nInitially, his understanding level of each of the M algorithms is 0.\n\nTakahashi is visiting a bookstore, where he finds N books on algorithms.\nThe i-th book (1\\leq i\\leq N) is sold for C_i yen (the currency of Japan). If he buys and reads it, his understanding level of the j-th algorithm will increase by A_{i,j} for each j (1\\leq j\\leq M).\nThere is no other way to increase the understanding levels of the algorithms.\n\nTakahashi's objective is to make his understanding levels of all the M algorithms X or higher. Determine whether this objective is achievable. If it is achievable, find the minimum amount of money needed to achieve it.\n\nConstraints\n\nAll values in input are integers.\n\n1\\leq N, M\\leq 12\n\n1\\leq X\\leq 10^5\n\n1\\leq C_i \\leq 10^5\n\n0\\leq A_{i, j} \\leq 10^5\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M X\nC_1 A_{1,1} A_{1,2} \\cdots A_{1,M}\nC_2 A_{2,1} A_{2,2} \\cdots A_{2,M}\n\\vdots\nC_N A_{N,1} A_{N,2} \\cdots A_{N,M}\n\nOutput\n\nIf the objective is not achievable, print -1; otherwise, print the minimum amount of money needed to achieve it.\n\nSample Input 1\n\n3 3 10\n60 2 2 4\n70 8 7 9\n50 2 3 9\n\nSample Output 1\n\n120\n\nBuying the second and third books makes his understanding levels of all the algorithms 10 or higher, at the minimum cost possible.\n\nSample Input 2\n\n3 3 10\n100 3 1 4\n100 1 5 9\n100 2 6 5\n\nSample Output 2\n\n-1\n\nBuying all the books is still not enough to make his understanding levels of all the algorithms 10 or higher.\n\nSample Input 3\n\n8 5 22\n100 3 7 5 3 1\n164 4 5 2 7 8\n334 7 2 7 2 9\n234 4 7 2 8 2\n541 5 4 3 3 6\n235 4 8 6 9 7\n394 3 6 1 6 2\n872 8 4 3 7 2\n\nSample Output 3\n\n1067", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2664, "cpu_time_ms": 2224, "memory_kb": 668680}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s867682837", "group_id": "codeNet:p02686", "input_text": "\nlet parse s =\n Array.init (String.length s) (fun i -> s.[i])\n |> Array.fold_left (fun (p, b) c ->\n if c = '(' then (p+1, b) else (p-1, min b (p-1))) (0, 0)\n\nlet () =\n Scanf.scanf \"%d\" @@ fun n ->\n let s = Array.init n (fun _ -> Scanf.scanf \" %s\" parse) in\n Array.sort (fun (a, b) (c, d) -> d - b) s;\n let tp, tb =\n Array.fold_left (fun (tp, tb) (p, b) ->\n (tp + p, min tb (tp + b))) (0, 0) s in\n\n Printf.printf \"%d %d\\n\" tp tb;\n let ans = if tp = 0 && tb >= 0 then \"Yes\" else \"No\" in\n print_endline ans", "language": "OCaml", "metadata": {"date": 1589170530, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p02686.html", "problem_id": "p02686", "resource_group": "low_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/OCaml/s867682837.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s867682837", "user_id": "u798181098"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "\nlet parse s =\n Array.init (String.length s) (fun i -> s.[i])\n |> Array.fold_left (fun (p, b) c ->\n if c = '(' then (p+1, b) else (p-1, min b (p-1))) (0, 0)\n\nlet () =\n Scanf.scanf \"%d\" @@ fun n ->\n let s = Array.init n (fun _ -> Scanf.scanf \" %s\" parse) in\n Array.sort (fun (a, b) (c, d) -> d - b) s;\n let tp, tb =\n Array.fold_left (fun (tp, tb) (p, b) ->\n (tp + p, min tb (tp + b))) (0, 0) s in\n\n Printf.printf \"%d %d\\n\" tp tb;\n let ans = if tp = 0 && tb >= 0 then \"Yes\" else \"No\" in\n print_endline ans", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 525, "cpu_time_ms": 565, "memory_kb": 38608}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s053932866", "group_id": "codeNet:p02687", "input_text": "let s = read_line ()\nlet () = print_endline @@ if s.[1] = 'B' then \"ARC\" else \"ABC\"", "language": "OCaml", "metadata": {"date": 1591831624, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p02687.html", "problem_id": "p02687", "resource_group": "low_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/OCaml/s053932866.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s053932866", "user_id": "u811309788"}, "prompt_components": {"gold_output": "ARC\n", "input_to_evaluate": "let s = read_line ()\nlet () = print_endline @@ if s.[1] = 'B' then \"ARC\" else \"ABC\"", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 11, "memory_kb": 3596}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s601703745", "group_id": "codeNet:p02688", "input_text": "Scanf.scanf \"%d %d\" (fun n k ->\n let snuke = Array.make n false in\n for i = 1 to k do\n Scanf.scanf \" %d\" (fun d ->\n for j = 1 to d do\n Scanf.scanf \" %d\" (fun a -> snuke.(a - 1) <- true)\n done\n )\n done;\n Array.fold_left (fun acc v -> if v then acc else acc + 1) 0 snuke |> Printf.printf \"%d\\n\"\n)", "language": "OCaml", "metadata": {"date": 1588554240, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p02688.html", "problem_id": "p02688", "resource_group": "low_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/OCaml/s601703745.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s601703745", "user_id": "u342443598"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "Scanf.scanf \"%d %d\" (fun n k ->\n let snuke = Array.make n false in\n for i = 1 to k do\n Scanf.scanf \" %d\" (fun d ->\n for j = 1 to d do\n Scanf.scanf \" %d\" (fun a -> snuke.(a - 1) <- true)\n done\n )\n done;\n Array.fold_left (fun acc v -> if v then acc else acc + 1) 0 snuke |> Printf.printf \"%d\\n\"\n)", "problem_context": "Score : 200 points\n\nProblem Statement\n\nN Snukes called Snuke 1, Snuke 2, ..., Snuke N live in a town.\n\nThere are K kinds of snacks sold in this town, called Snack 1, Snack 2, ..., Snack K. The following d_i Snukes have Snack i: Snuke A_{i, 1}, A_{i, 2}, \\cdots, A_{i, {d_i}}.\n\nTakahashi will walk around this town and make mischief on the Snukes who have no snacks. How many Snukes will fall victim to Takahashi's mischief?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 100\n\n1 \\leq K \\leq 100\n\n1 \\leq d_i \\leq N\n\n1 \\leq A_{i, 1} < \\cdots < A_{i, d_i} \\leq N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nd_1\nA_{1, 1} \\cdots A_{1, d_1}\n\\vdots\nd_K\nA_{K, 1} \\cdots A_{K, d_K}\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n3 2\n2\n1 3\n1\n3\n\nSample Output 1\n\n1\n\nSnuke 1 has Snack 1.\n\nSnuke 2 has no snacks.\n\nSnuke 3 has Snack 1 and 2.\n\nThus, there will be one victim: Snuke 2.\n\nSample Input 2\n\n3 3\n1\n3\n1\n3\n1\n3\n\nSample Output 2\n\n2", "sample_input": "3 2\n2\n1 3\n1\n3\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02688", "source_text": "Score : 200 points\n\nProblem Statement\n\nN Snukes called Snuke 1, Snuke 2, ..., Snuke N live in a town.\n\nThere are K kinds of snacks sold in this town, called Snack 1, Snack 2, ..., Snack K. The following d_i Snukes have Snack i: Snuke A_{i, 1}, A_{i, 2}, \\cdots, A_{i, {d_i}}.\n\nTakahashi will walk around this town and make mischief on the Snukes who have no snacks. How many Snukes will fall victim to Takahashi's mischief?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 100\n\n1 \\leq K \\leq 100\n\n1 \\leq d_i \\leq N\n\n1 \\leq A_{i, 1} < \\cdots < A_{i, d_i} \\leq N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nd_1\nA_{1, 1} \\cdots A_{1, d_1}\n\\vdots\nd_K\nA_{K, 1} \\cdots A_{K, d_K}\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n3 2\n2\n1 3\n1\n3\n\nSample Output 1\n\n1\n\nSnuke 1 has Snack 1.\n\nSnuke 2 has no snacks.\n\nSnuke 3 has Snack 1 and 2.\n\nThus, there will be one victim: Snuke 2.\n\nSample Input 2\n\n3 3\n1\n3\n1\n3\n1\n3\n\nSample Output 2\n\n2", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 11, "memory_kb": 5768}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s648150402", "group_id": "codeNet:p02689", "input_text": "let () =\n let rec make_list n = if n = 0 then [0] else n :: make_list (n-1) in\n let n,m = Scanf.scanf \"%d %d\\n\" @@ fun a b -> a, b in\n let h = Array.init n @@ fun _ -> Scanf.scanf \"%d \" @@ fun d -> d in\n let arr = Array.make n 0 in\n for i = 1 to m do\n Scanf.scanf \"%d %d\\n\" @@ fun x y ->\n let a = x-1 in let b = y-1 in \n arr.(a) <- (max h.(b) arr.(a)); arr.(b) <- (max h.(a) arr.(b))\n done;\n print_int (List.fold_left (fun i v -> if h.(v) > arr.(v) then i+1 else i) 0 (make_list (n-1)))", "language": "OCaml", "metadata": {"date": 1588707806, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p02689.html", "problem_id": "p02689", "resource_group": "low_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/OCaml/s648150402.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s648150402", "user_id": "u307426615"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "let () =\n let rec make_list n = if n = 0 then [0] else n :: make_list (n-1) in\n let n,m = Scanf.scanf \"%d %d\\n\" @@ fun a b -> a, b in\n let h = Array.init n @@ fun _ -> Scanf.scanf \"%d \" @@ fun d -> d in\n let arr = Array.make n 0 in\n for i = 1 to m do\n Scanf.scanf \"%d %d\\n\" @@ fun x y ->\n let a = x-1 in let b = y-1 in \n arr.(a) <- (max h.(b) arr.(a)); arr.(b) <- (max h.(a) arr.(b))\n done;\n print_int (List.fold_left (fun i v -> if h.(v) > arr.(v) then i+1 else i) 0 (make_list (n-1)))", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 502, "cpu_time_ms": 62, "memory_kb": 11156}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s744909699", "group_id": "codeNet:p02690", "input_text": "open Batteries\nlet x = read_int ()\n\nlet rec loop a =\n let rec loop2 b =\n if b >= 100 then (0, 0) else\n if ((a * a * a * a * a) - (b*b*b*b*b)) = x then (a, b) else loop2 (b+1)\n in if a >= 100 then (0, 0) else (\n let a_, b_ = loop2 (-100) in\n if a_ = 0 && b_ = 0 then loop (a+1) else (a_, b_)\n)\nlet a, b = loop (-100)\nlet _ = Printf.printf \"%d %d\\n\" a b\n\n", "language": "OCaml", "metadata": {"date": 1588557729, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p02690.html", "problem_id": "p02690", "resource_group": "low_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/OCaml/s744909699.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s744909699", "user_id": "u511870776"}, "prompt_components": {"gold_output": "2 -1\n", "input_to_evaluate": "open Batteries\nlet x = read_int ()\n\nlet rec loop a =\n let rec loop2 b =\n if b >= 100 then (0, 0) else\n if ((a * a * a * a * a) - (b*b*b*b*b)) = x then (a, b) else loop2 (b+1)\n in if a >= 100 then (0, 0) else (\n let a_, b_ = loop2 (-100) in\n if a_ = 0 && b_ = 0 then loop (a+1) else (a_, b_)\n)\nlet a, b = loop (-100)\nlet _ = Printf.printf \"%d %d\\n\" a b\n\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nGive a pair of integers (A, B) such that A^5-B^5 = X.\nIt is guaranteed that there exists such a pair for the given integer X.\n\nConstraints\n\n1 \\leq X \\leq 10^9\n\nX is an integer.\n\nThere exists a pair of integers (A, B) satisfying the condition in Problem Statement.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX\n\nOutput\n\nPrint A and B, with space in between.\nIf there are multiple pairs of integers (A, B) satisfying the condition, you may print any of them.\n\nA B\n\nSample Input 1\n\n33\n\nSample Output 1\n\n2 -1\n\nFor A=2 and B=-1, A^5-B^5 = 33.\n\nSample Input 2\n\n1\n\nSample Output 2\n\n0 -1", "sample_input": "33\n"}, "reference_outputs": ["2 -1\n"], "source_document_id": "p02690", "source_text": "Score : 400 points\n\nProblem Statement\n\nGive a pair of integers (A, B) such that A^5-B^5 = X.\nIt is guaranteed that there exists such a pair for the given integer X.\n\nConstraints\n\n1 \\leq X \\leq 10^9\n\nX is an integer.\n\nThere exists a pair of integers (A, B) satisfying the condition in Problem Statement.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX\n\nOutput\n\nPrint A and B, with space in between.\nIf there are multiple pairs of integers (A, B) satisfying the condition, you may print any of them.\n\nA B\n\nSample Input 1\n\n33\n\nSample Output 1\n\n2 -1\n\nFor A=2 and B=-1, A^5-B^5 = 33.\n\nSample Input 2\n\n1\n\nSample Output 2\n\n0 -1", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 363, "cpu_time_ms": 4, "memory_kb": 5356}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s844201040", "group_id": "codeNet:p02690", "input_text": "Scanf.scanf \"%d\" (fun x ->\n let check x i =\n let rec loop c =\n if c < -1000 then None else\n if c * c * c * c * c - (c - i) * (c - i) * (c - i) * (c - i) * (c - i) = x then Some (c, c - i)\n else loop (c - 1)\n in\n loop 1000\n in\n let rec loop i =\n if x mod i = 0 then (\n match check x i with\n | Some (a, b) -> Printf.printf \"%d %d\\n\" a b\n | None -> loop (i + 1)\n ) else loop (i + 1)\n in\n loop 1\n)", "language": "OCaml", "metadata": {"date": 1588556414, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p02690.html", "problem_id": "p02690", "resource_group": "low_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/OCaml/s844201040.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s844201040", "user_id": "u342443598"}, "prompt_components": {"gold_output": "2 -1\n", "input_to_evaluate": "Scanf.scanf \"%d\" (fun x ->\n let check x i =\n let rec loop c =\n if c < -1000 then None else\n if c * c * c * c * c - (c - i) * (c - i) * (c - i) * (c - i) * (c - i) = x then Some (c, c - i)\n else loop (c - 1)\n in\n loop 1000\n in\n let rec loop i =\n if x mod i = 0 then (\n match check x i with\n | Some (a, b) -> Printf.printf \"%d %d\\n\" a b\n | None -> loop (i + 1)\n ) else loop (i + 1)\n in\n loop 1\n)", "problem_context": "Score : 400 points\n\nProblem Statement\n\nGive a pair of integers (A, B) such that A^5-B^5 = X.\nIt is guaranteed that there exists such a pair for the given integer X.\n\nConstraints\n\n1 \\leq X \\leq 10^9\n\nX is an integer.\n\nThere exists a pair of integers (A, B) satisfying the condition in Problem Statement.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX\n\nOutput\n\nPrint A and B, with space in between.\nIf there are multiple pairs of integers (A, B) satisfying the condition, you may print any of them.\n\nA B\n\nSample Input 1\n\n33\n\nSample Output 1\n\n2 -1\n\nFor A=2 and B=-1, A^5-B^5 = 33.\n\nSample Input 2\n\n1\n\nSample Output 2\n\n0 -1", "sample_input": "33\n"}, "reference_outputs": ["2 -1\n"], "source_document_id": "p02690", "source_text": "Score : 400 points\n\nProblem Statement\n\nGive a pair of integers (A, B) such that A^5-B^5 = X.\nIt is guaranteed that there exists such a pair for the given integer X.\n\nConstraints\n\n1 \\leq X \\leq 10^9\n\nX is an integer.\n\nThere exists a pair of integers (A, B) satisfying the condition in Problem Statement.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX\n\nOutput\n\nPrint A and B, with space in between.\nIf there are multiple pairs of integers (A, B) satisfying the condition, you may print any of them.\n\nA B\n\nSample Input 1\n\n33\n\nSample Output 1\n\n2 -1\n\nFor A=2 and B=-1, A^5-B^5 = 33.\n\nSample Input 2\n\n1\n\nSample Output 2\n\n0 -1", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 517, "cpu_time_ms": 11, "memory_kb": 3848}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s569339650", "group_id": "codeNet:p02692", "input_text": "open Batteries\nopen Tuple\nmodule EnumL = Enum.Labels\nmodule ListL = List.Labels\nmodule ArrayL = Array.Labels\n\nlet dbg0 x = Printf.eprintf \"[debug]%s\\n\" @@ dump x\nlet dbg1 x = dbg0 x; x\n\nlet id = identity\n\nlet (++) n m = List.range n `To m\nlet (++^) n m = if n < m then List.range n `To (pred m) else []\n\nlet scan fmt = Scanf.sscanf (read_line ()) fmt\n\nlet scan_lines n fmt f =\n if n = 0 then []\n else List.map (fun _ -> scan fmt f) (1 ++ n)\n\nlet scan_list sep cnv =\n let line = read_line () in\n (match sep with\n | None -> List.map String.of_char @@ String.to_list line\n | Some sep -> String.split_on_char sep line)\n |> List.map cnv\n\nlet scan_array ?sep cnv = Array.of_list @@ scan_list sep cnv\n\nlet scan_matrix n m e ?sep conv =\n let arr = Array.make_matrix n m e in\n ListL.iter (0 ++^ n)\n ~f:(fun i -> arr.(i) <- Array.of_list @@ scan_list sep conv);\n arr\n\nlet rec powerset e =\n match Enum.get e with\n | None -> Enum.singleton @@ Enum.empty ()\n | Some v ->\n let f = powerset e in\n let g = Enum.clone f in\n EnumL.map f ~f:(fun x -> let y = Enum.clone x in push y v; y)\n |> Enum.append g\n\nlet permutations l =\n let rec aux l =\n let rec interleave x = function\n | [] -> [[x]]\n | (hd::tl) as lst ->\n (x::lst) ::\n (ListL.map ~f:(List.cons hd) @@ interleave x tl)\n in\n match l with\n | [] -> [[]]\n | hd::tl -> List.concat @@ List.map (interleave hd) @@ aux tl in\n let l = List.sort (List.compare Int.compare) @@ aux @@ List.of_enum l in\n List.enum % ListL.map ~f:List.enum @@ l\n\nlet intersection l =\n EnumL.filter ~f:(fun x -> EnumL.exists ~f:((=) x) @@ Enum.clone l)\n\nlet lower_bound n f =\n let rec aux l u =\n if u - l > 1 then\n let m = (l + u) / 2 in\n if f m then aux l m\n else aux m u\n else u in aux (-1) n\n\nlet between n x m = n <= x && x < m\n\nlet (n,a,b,c) = scan \"%d %d %d %d\" Tuple4.make\nlet coms = scan_lines n \"%s\" id\n\nopen Option.Infix\nopen Option.Monad\n\nlet rec solve1 a b c= function\n | [] -> Some []\n | com::rest ->\n match com with\n | \"AB\" ->\n if a = 0 && b = 0 then None\n else if a = 1 then\n solve1 (pred a) (succ b) c rest >>= fun ret ->\n return (\"B\" :: ret)\n else\n solve1 (succ a) (pred b) c rest >>= fun ret ->\n return (\"A\" :: ret)\n | \"BC\" ->\n if b = 0 && c = 0 then None\n else if b = 1 then\n solve1 a (pred b) (succ c) rest >>= fun ret ->\n return (\"C\" :: ret)\n else\n solve1 a (succ b) (pred c) rest >>= fun ret ->\n return (\"B\" :: ret)\n | \"AC\" ->\n if a = 0 && c = 0 then None\n else if c = 1 then\n solve1 (succ a) b (pred c) rest >>= fun ret ->\n return (\"A\" :: ret)\n else solve1 (pred a) b (succ c) rest >>= fun ret ->\n return (\"C\" :: ret)\n | _ -> None\n\nlet rec solven a b c = function\n | [] -> Some []\n | com :: rest ->\n begin\n match com with\n | \"AB\" ->\n if a > b then\n solven (pred a) (succ b) c rest >>= fun ret ->\n return (\"B\"::ret)\n else\n solven (succ a) (pred b) c rest >>= fun ret ->\n return (\"A\"::ret)\n | \"BC\" ->\n if b > c then\n solven a (pred b) (succ c) rest >>= fun ret ->\n return (\"C\"::ret)\n else\n solven a (succ b) (pred c) rest >>= fun ret ->\n return (\"B\"::ret)\n | \"AC\" ->\n if a > c then\n solven (pred a) (pred b) (succ c) rest >>= fun ret ->\n return (\"C\"::ret)\n else\n solven (succ a) b (pred c) rest >>= fun ret ->\n return (\"A\"::ret)\n | _ -> None\n end\n\nlet rec solve2 a b c = function\n | [] -> Some []\n | com :: rest ->\n begin\n match com with\n | \"AB\" ->\n if a = 1 && b = 1 && List.at_opt rest 0 |> Option.is_some then\n let next = List.at rest 0 in\n match next with\n | \"AC\" -> solve2 (succ a) (pred b) c rest >>= fun ret ->\n return (\"A\"::ret)\n | \"BC\" -> solve2 (pred a) (succ b) c rest >>= fun ret ->\n return (\"B\"::ret)\n | \"AB\" -> solve2 (pred a) (succ b) c rest >>= fun ret ->\n return (\"B\"::ret)\n | _ -> None\n else if a = 0 then\n solve2 (succ a) (pred b) c rest >>= fun ret ->\n return (\"A\" :: ret)\n else\n solve2 (pred a) (succ b) c rest >>= fun ret ->\n return (\"B\" :: ret)\n | \"BC\" ->\n if b = 1 && c= 1 && List.at_opt rest 0 |> Option.is_some then\n let next = List.at rest 0 in\n match next with\n | \"AB\" -> solve2 a (succ b) (pred c) rest >>= fun ret ->\n return (\"B\" :: ret)\n | \"BC\" -> solve2 a (pred b) (succ c) rest >>= fun ret ->\n return (\"C\"::ret)\n | \"AC\" -> solve2 a (pred b) (succ c) rest >>= fun ret ->\n return (\"C\"::ret)\n | _ -> None\n else if b = 0 then\n solve2 a (succ b) (pred c) rest >>= fun ret ->\n return (\"B\" :: ret)\n else\n solve2 a (pred b) (succ c) rest >>= fun ret ->\n return (\"C\" :: ret)\n | \"AC\" ->\n if c = 1 && a = 1 && List.at_opt rest 0 |> Option.is_some then\n let next = List.at rest 0 in\n match next with\n | \"AB\" -> solve2 (succ a) b (pred c) rest >>= fun ret ->\n return (\"A\" :: ret)\n | \"BC\" -> solve2 (pred a) b (succ c) rest >>= fun ret ->\n return (\"C\"::ret)\n | \"AC\" -> solve2 (succ a) b (pred c) rest >>= fun ret ->\n return (\"A\"::ret)\n | _ -> None\n else if c = 0 then\n solve2 (pred a) b (succ c) rest >>= fun ret ->\n return (\"C\" :: ret)\n else\n solve2 (succ a) b (pred c) rest >>= fun ret ->\n return (\"A\" :: ret)\n | _ -> None\n end\n\nlet () =\n (match List.first coms with\n | \"AB\" when a = 0 && b = 0 -> None\n | \"BC\" when b = 0 && c = 0 -> None\n | \"AC\" when a = 0 && c = 0 -> None\n | _ ->\n if a + b + c = 1 then\n solve1 a b c coms\n else if a + b + c = 2 then\n solve2 a b c coms\n else\n solven a b c coms)\n |> Option.map_default (fun ans -> \"Yes\\n\" ^ String.join \"\\n\" ans) \"No\"\n |> Printf.printf \"%s\\n\"\n", "language": "OCaml", "metadata": {"date": 1588777913, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p02692.html", "problem_id": "p02692", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02692/input.txt", "sample_output_relpath": "derived/input_output/data/p02692/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02692/OCaml/s569339650.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s569339650", "user_id": "u802614675"}, "prompt_components": {"gold_output": "Yes\nA\nC\n", "input_to_evaluate": "open Batteries\nopen Tuple\nmodule EnumL = Enum.Labels\nmodule ListL = List.Labels\nmodule ArrayL = Array.Labels\n\nlet dbg0 x = Printf.eprintf \"[debug]%s\\n\" @@ dump x\nlet dbg1 x = dbg0 x; x\n\nlet id = identity\n\nlet (++) n m = List.range n `To m\nlet (++^) n m = if n < m then List.range n `To (pred m) else []\n\nlet scan fmt = Scanf.sscanf (read_line ()) fmt\n\nlet scan_lines n fmt f =\n if n = 0 then []\n else List.map (fun _ -> scan fmt f) (1 ++ n)\n\nlet scan_list sep cnv =\n let line = read_line () in\n (match sep with\n | None -> List.map String.of_char @@ String.to_list line\n | Some sep -> String.split_on_char sep line)\n |> List.map cnv\n\nlet scan_array ?sep cnv = Array.of_list @@ scan_list sep cnv\n\nlet scan_matrix n m e ?sep conv =\n let arr = Array.make_matrix n m e in\n ListL.iter (0 ++^ n)\n ~f:(fun i -> arr.(i) <- Array.of_list @@ scan_list sep conv);\n arr\n\nlet rec powerset e =\n match Enum.get e with\n | None -> Enum.singleton @@ Enum.empty ()\n | Some v ->\n let f = powerset e in\n let g = Enum.clone f in\n EnumL.map f ~f:(fun x -> let y = Enum.clone x in push y v; y)\n |> Enum.append g\n\nlet permutations l =\n let rec aux l =\n let rec interleave x = function\n | [] -> [[x]]\n | (hd::tl) as lst ->\n (x::lst) ::\n (ListL.map ~f:(List.cons hd) @@ interleave x tl)\n in\n match l with\n | [] -> [[]]\n | hd::tl -> List.concat @@ List.map (interleave hd) @@ aux tl in\n let l = List.sort (List.compare Int.compare) @@ aux @@ List.of_enum l in\n List.enum % ListL.map ~f:List.enum @@ l\n\nlet intersection l =\n EnumL.filter ~f:(fun x -> EnumL.exists ~f:((=) x) @@ Enum.clone l)\n\nlet lower_bound n f =\n let rec aux l u =\n if u - l > 1 then\n let m = (l + u) / 2 in\n if f m then aux l m\n else aux m u\n else u in aux (-1) n\n\nlet between n x m = n <= x && x < m\n\nlet (n,a,b,c) = scan \"%d %d %d %d\" Tuple4.make\nlet coms = scan_lines n \"%s\" id\n\nopen Option.Infix\nopen Option.Monad\n\nlet rec solve1 a b c= function\n | [] -> Some []\n | com::rest ->\n match com with\n | \"AB\" ->\n if a = 0 && b = 0 then None\n else if a = 1 then\n solve1 (pred a) (succ b) c rest >>= fun ret ->\n return (\"B\" :: ret)\n else\n solve1 (succ a) (pred b) c rest >>= fun ret ->\n return (\"A\" :: ret)\n | \"BC\" ->\n if b = 0 && c = 0 then None\n else if b = 1 then\n solve1 a (pred b) (succ c) rest >>= fun ret ->\n return (\"C\" :: ret)\n else\n solve1 a (succ b) (pred c) rest >>= fun ret ->\n return (\"B\" :: ret)\n | \"AC\" ->\n if a = 0 && c = 0 then None\n else if c = 1 then\n solve1 (succ a) b (pred c) rest >>= fun ret ->\n return (\"A\" :: ret)\n else solve1 (pred a) b (succ c) rest >>= fun ret ->\n return (\"C\" :: ret)\n | _ -> None\n\nlet rec solven a b c = function\n | [] -> Some []\n | com :: rest ->\n begin\n match com with\n | \"AB\" ->\n if a > b then\n solven (pred a) (succ b) c rest >>= fun ret ->\n return (\"B\"::ret)\n else\n solven (succ a) (pred b) c rest >>= fun ret ->\n return (\"A\"::ret)\n | \"BC\" ->\n if b > c then\n solven a (pred b) (succ c) rest >>= fun ret ->\n return (\"C\"::ret)\n else\n solven a (succ b) (pred c) rest >>= fun ret ->\n return (\"B\"::ret)\n | \"AC\" ->\n if a > c then\n solven (pred a) (pred b) (succ c) rest >>= fun ret ->\n return (\"C\"::ret)\n else\n solven (succ a) b (pred c) rest >>= fun ret ->\n return (\"A\"::ret)\n | _ -> None\n end\n\nlet rec solve2 a b c = function\n | [] -> Some []\n | com :: rest ->\n begin\n match com with\n | \"AB\" ->\n if a = 1 && b = 1 && List.at_opt rest 0 |> Option.is_some then\n let next = List.at rest 0 in\n match next with\n | \"AC\" -> solve2 (succ a) (pred b) c rest >>= fun ret ->\n return (\"A\"::ret)\n | \"BC\" -> solve2 (pred a) (succ b) c rest >>= fun ret ->\n return (\"B\"::ret)\n | \"AB\" -> solve2 (pred a) (succ b) c rest >>= fun ret ->\n return (\"B\"::ret)\n | _ -> None\n else if a = 0 then\n solve2 (succ a) (pred b) c rest >>= fun ret ->\n return (\"A\" :: ret)\n else\n solve2 (pred a) (succ b) c rest >>= fun ret ->\n return (\"B\" :: ret)\n | \"BC\" ->\n if b = 1 && c= 1 && List.at_opt rest 0 |> Option.is_some then\n let next = List.at rest 0 in\n match next with\n | \"AB\" -> solve2 a (succ b) (pred c) rest >>= fun ret ->\n return (\"B\" :: ret)\n | \"BC\" -> solve2 a (pred b) (succ c) rest >>= fun ret ->\n return (\"C\"::ret)\n | \"AC\" -> solve2 a (pred b) (succ c) rest >>= fun ret ->\n return (\"C\"::ret)\n | _ -> None\n else if b = 0 then\n solve2 a (succ b) (pred c) rest >>= fun ret ->\n return (\"B\" :: ret)\n else\n solve2 a (pred b) (succ c) rest >>= fun ret ->\n return (\"C\" :: ret)\n | \"AC\" ->\n if c = 1 && a = 1 && List.at_opt rest 0 |> Option.is_some then\n let next = List.at rest 0 in\n match next with\n | \"AB\" -> solve2 (succ a) b (pred c) rest >>= fun ret ->\n return (\"A\" :: ret)\n | \"BC\" -> solve2 (pred a) b (succ c) rest >>= fun ret ->\n return (\"C\"::ret)\n | \"AC\" -> solve2 (succ a) b (pred c) rest >>= fun ret ->\n return (\"A\"::ret)\n | _ -> None\n else if c = 0 then\n solve2 (pred a) b (succ c) rest >>= fun ret ->\n return (\"C\" :: ret)\n else\n solve2 (succ a) b (pred c) rest >>= fun ret ->\n return (\"A\" :: ret)\n | _ -> None\n end\n\nlet () =\n (match List.first coms with\n | \"AB\" when a = 0 && b = 0 -> None\n | \"BC\" when b = 0 && c = 0 -> None\n | \"AC\" when a = 0 && c = 0 -> None\n | _ ->\n if a + b + c = 1 then\n solve1 a b c coms\n else if a + b + c = 2 then\n solve2 a b c coms\n else\n solven a b c coms)\n |> Option.map_default (fun ans -> \"Yes\\n\" ^ String.join \"\\n\" ans) \"No\"\n |> Printf.printf \"%s\\n\"\n", "problem_context": "Score : 600 points\n\nProblem Statement\n\nThere is a game that involves three variables, denoted A, B, and C.\n\nAs the game progresses, there will be N events where you are asked to make a choice.\nEach of these choices is represented by a string s_i. If s_i is AB, you must add 1 to A or B then subtract 1 from the other; if s_i is AC, you must add 1 to A or C then subtract 1 from the other; if s_i is BC, you must add 1 to B or C then subtract 1 from the other.\n\nAfter each choice, none of A, B, and C should be negative.\n\nDetermine whether it is possible to make N choices under this condition. If it is possible, also give one such way to make the choices.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n0 \\leq A,B,C \\leq 10^9\n\nN, A, B, C are integers.\n\ns_i is AB, AC, or BC.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN A B C\ns_1\ns_2\n:\ns_N\n\nOutput\n\nIf it is possible to make N choices under the condition, print Yes; otherwise, print No.\n\nAlso, in the former case, show one such way to make the choices in the subsequent N lines. The (i+1)-th line should contain the name of the variable (A, B, or C) to which you add 1 in the i-th choice.\n\nSample Input 1\n\n2 1 3 0\nAB\nAC\n\nSample Output 1\n\nYes\nA\nC\n\nYou can successfully make two choices, as follows:\n\nIn the first choice, add 1 to A and subtract 1 from B. A becomes 2, and B becomes 2.\n\nIn the second choice, add 1 to C and subtract 1 from A. C becomes 1, and A becomes 1.\n\nSample Input 2\n\n3 1 0 0\nAB\nBC\nAB\n\nSample Output 2\n\nNo\n\nSample Input 3\n\n1 0 9 0\nAC\n\nSample Output 3\n\nNo\n\nSample Input 4\n\n8 6 9 1\nAC\nBC\nAB\nBC\nAC\nBC\nAB\nAB\n\nSample Output 4\n\nYes\nC\nB\nB\nC\nC\nB\nA\nA", "sample_input": "2 1 3 0\nAB\nAC\n"}, "reference_outputs": ["Yes\nA\nC\n"], "source_document_id": "p02692", "source_text": "Score : 600 points\n\nProblem Statement\n\nThere is a game that involves three variables, denoted A, B, and C.\n\nAs the game progresses, there will be N events where you are asked to make a choice.\nEach of these choices is represented by a string s_i. If s_i is AB, you must add 1 to A or B then subtract 1 from the other; if s_i is AC, you must add 1 to A or C then subtract 1 from the other; if s_i is BC, you must add 1 to B or C then subtract 1 from the other.\n\nAfter each choice, none of A, B, and C should be negative.\n\nDetermine whether it is possible to make N choices under this condition. If it is possible, also give one such way to make the choices.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n0 \\leq A,B,C \\leq 10^9\n\nN, A, B, C are integers.\n\ns_i is AB, AC, or BC.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN A B C\ns_1\ns_2\n:\ns_N\n\nOutput\n\nIf it is possible to make N choices under the condition, print Yes; otherwise, print No.\n\nAlso, in the former case, show one such way to make the choices in the subsequent N lines. The (i+1)-th line should contain the name of the variable (A, B, or C) to which you add 1 in the i-th choice.\n\nSample Input 1\n\n2 1 3 0\nAB\nAC\n\nSample Output 1\n\nYes\nA\nC\n\nYou can successfully make two choices, as follows:\n\nIn the first choice, add 1 to A and subtract 1 from B. A becomes 2, and B becomes 2.\n\nIn the second choice, add 1 to C and subtract 1 from A. C becomes 1, and A becomes 1.\n\nSample Input 2\n\n3 1 0 0\nAB\nBC\nAB\n\nSample Output 2\n\nNo\n\nSample Input 3\n\n1 0 9 0\nAC\n\nSample Output 3\n\nNo\n\nSample Input 4\n\n8 6 9 1\nAC\nBC\nAB\nBC\nAC\nBC\nAB\nAB\n\nSample Output 4\n\nYes\nC\nB\nB\nC\nC\nB\nA\nA", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 6172, "cpu_time_ms": 68, "memory_kb": 19976}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s498286762", "group_id": "codeNet:p02692", "input_text": "open Batteries\nopen Tuple\nmodule EnumL = Enum.Labels\nmodule ListL = List.Labels\nmodule ArrayL = Array.Labels\n\nlet dbg0 x = Printf.eprintf \"[debug]%s\\n\" @@ dump x\nlet dbg1 x = dbg0 x; x\n\nlet id = identity\n\nlet (++) n m = List.range n `To m\nlet (++^) n m = if n < m then List.range n `To (pred m) else []\n\nlet scan fmt = Scanf.sscanf (read_line ()) fmt\n\nlet scan_lines n fmt f =\n if n = 0 then []\n else List.map (fun _ -> scan fmt f) (1 ++ n)\n\nlet scan_list sep cnv =\n let line = read_line () in\n (match sep with\n | None -> List.map String.of_char @@ String.to_list line\n | Some sep -> String.split_on_char sep line)\n |> List.map cnv\n\nlet scan_array ?sep cnv = Array.of_list @@ scan_list sep cnv\n\nlet scan_matrix n m e ?sep conv =\n let arr = Array.make_matrix n m e in\n ListL.iter (0 ++^ n)\n ~f:(fun i -> arr.(i) <- Array.of_list @@ scan_list sep conv);\n arr\n\nlet rec powerset e =\n match Enum.get e with\n | None -> Enum.singleton @@ Enum.empty ()\n | Some v ->\n let f = powerset e in\n let g = Enum.clone f in\n EnumL.map f ~f:(fun x -> let y = Enum.clone x in push y v; y)\n |> Enum.append g\n\nlet permutations l =\n let rec aux l =\n let rec interleave x = function\n | [] -> [[x]]\n | (hd::tl) as lst ->\n (x::lst) ::\n (ListL.map ~f:(List.cons hd) @@ interleave x tl)\n in\n match l with\n | [] -> [[]]\n | hd::tl -> List.concat @@ List.map (interleave hd) @@ aux tl in\n let l = List.sort (List.compare Int.compare) @@ aux @@ List.of_enum l in\n List.enum % ListL.map ~f:List.enum @@ l\n\nlet intersection l =\n EnumL.filter ~f:(fun x -> EnumL.exists ~f:((=) x) @@ Enum.clone l)\n\nlet lower_bound n f =\n let rec aux l u =\n if u - l > 1 then\n let m = (l + u) / 2 in\n if f m then aux l m\n else aux m u\n else u in aux (-1) n\n\nlet between n x m = n <= x && x < m\n\nlet (n,a,b,c) = scan \"%d %d %d %d\" Tuple4.make\nlet coms = scan_lines n \"%s\" id\n\nopen Option.Infix\nopen Option.Monad\n\nlet rec solve1 a b c= function\n | [] -> Some []\n | com::rest ->\n match com with\n | \"AB\" ->\n if a = 0 && b = 0 then None\n else if a = 1 then\n solve1 (pred a) (succ b) c rest >>= fun ret ->\n return (\"B\" :: ret)\n else\n solve1 (succ a) (pred b) c rest >>= fun ret ->\n return (\"A\" :: ret)\n | \"BC\" ->\n if b = 0 && c = 0 then None\n else if b = 1 then\n solve1 a (pred b) (succ c) rest >>= fun ret ->\n return (\"C\" :: ret)\n else\n solve1 a (succ b) (pred c) rest >>= fun ret ->\n return (\"B\" :: ret)\n | \"AC\" ->\n if a = 0 && c = 0 then None\n else if c = 1 then\n solve1 (succ a) b (pred c) rest >>= fun ret ->\n return (\"A\" :: ret)\n else solve1 (pred a) b (succ c) rest >>= fun ret ->\n return (\"C\" :: ret)\n | _ -> None\n\nlet rec solven a b c = function\n | [] -> Some []\n | com :: rest ->\n begin\n match com with\n | \"AB\" ->\n if a = 0 then\n solven (succ a) (pred b) c rest >>= fun ret ->\n return (\"A\" :: ret)\n else if a = 1 && b = 1 && List.at_opt rest 0 |> Option.is_some then\n let next = List.at rest 0 in\n match next with\n | \"AC\" -> solven (succ a) (pred b) c rest >>= fun ret ->\n return (\"A\"::ret)\n | \"BC\" -> solven (pred a) (succ b) c rest >>= fun ret ->\n return (\"B\"::ret)\n | \"AB\" -> solven (pred a) (succ b) c rest >>= fun ret ->\n return (\"B\"::ret)\n | _ -> None\n else\n solven (pred a) (succ b) c rest >>= fun ret ->\n return (\"B\" :: ret)\n | \"BC\" ->\n if b = 0 then\n solven a (succ b) (pred c) rest >>= fun ret ->\n return (\"B\" :: ret)\n else if b = 1 && c= 1 && List.at_opt rest 0 |> Option.is_some then\n let next = List.at rest 0 in\n match next with\n | \"AB\" -> solven a (succ b) (pred c) rest >>= fun ret ->\n return (\"B\" :: ret)\n | \"BC\" -> solven a (pred b) (succ c) rest >>= fun ret ->\n return (\"C\"::ret)\n | \"AC\" -> solven a (pred b) (succ c) rest >>= fun ret ->\n return (\"C\"::ret)\n | _ -> None\n else\n solven a (pred b) (succ c) rest >>= fun ret ->\n return (\"C\" :: ret)\n | \"AC\" ->\n if c = 0 then\n solven (pred a) b (succ c) rest >>= fun ret ->\n return (\"C\" :: ret)\n else if c = 1 && a = 1 && List.at_opt rest 0 |> Option.is_some then\n let next = List.at rest 0 in\n match next with\n | \"AB\" -> solven (succ a) b (pred c) rest >>= fun ret ->\n return (\"A\" :: ret)\n | \"BC\" -> solven (pred a) b (succ c) rest >>= fun ret ->\n return (\"C\"::ret)\n | \"AC\" -> solven (succ a) b (pred c) rest >>= fun ret ->\n return (\"A\"::ret)\n | _ -> None\n else\n solven (succ a) b (pred c) rest >>= fun ret ->\n return (\"A\" :: ret)\n | _ -> None\n end\n\nlet () =\n (if a + b + c = 0 then None\n else if a + b + c = 1 then\n solve1 a b c coms\n else\n match List.first coms with\n | \"AB\" when a = 0 && b = 0 -> None\n | \"BC\" when b = 0 && c = 0 -> None\n | \"AC\" when a = 0 && c = 0 -> None\n | _ ->\n solven a b c coms)\n |> Option.map_default (fun ans -> \"Yes\\n\" ^ String.join \"\\n\" ans) \"No\"\n |> Printf.printf \"%s\\n\"\n", "language": "OCaml", "metadata": {"date": 1588777167, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p02692.html", "problem_id": "p02692", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02692/input.txt", "sample_output_relpath": "derived/input_output/data/p02692/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02692/OCaml/s498286762.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s498286762", "user_id": "u802614675"}, "prompt_components": {"gold_output": "Yes\nA\nC\n", "input_to_evaluate": "open Batteries\nopen Tuple\nmodule EnumL = Enum.Labels\nmodule ListL = List.Labels\nmodule ArrayL = Array.Labels\n\nlet dbg0 x = Printf.eprintf \"[debug]%s\\n\" @@ dump x\nlet dbg1 x = dbg0 x; x\n\nlet id = identity\n\nlet (++) n m = List.range n `To m\nlet (++^) n m = if n < m then List.range n `To (pred m) else []\n\nlet scan fmt = Scanf.sscanf (read_line ()) fmt\n\nlet scan_lines n fmt f =\n if n = 0 then []\n else List.map (fun _ -> scan fmt f) (1 ++ n)\n\nlet scan_list sep cnv =\n let line = read_line () in\n (match sep with\n | None -> List.map String.of_char @@ String.to_list line\n | Some sep -> String.split_on_char sep line)\n |> List.map cnv\n\nlet scan_array ?sep cnv = Array.of_list @@ scan_list sep cnv\n\nlet scan_matrix n m e ?sep conv =\n let arr = Array.make_matrix n m e in\n ListL.iter (0 ++^ n)\n ~f:(fun i -> arr.(i) <- Array.of_list @@ scan_list sep conv);\n arr\n\nlet rec powerset e =\n match Enum.get e with\n | None -> Enum.singleton @@ Enum.empty ()\n | Some v ->\n let f = powerset e in\n let g = Enum.clone f in\n EnumL.map f ~f:(fun x -> let y = Enum.clone x in push y v; y)\n |> Enum.append g\n\nlet permutations l =\n let rec aux l =\n let rec interleave x = function\n | [] -> [[x]]\n | (hd::tl) as lst ->\n (x::lst) ::\n (ListL.map ~f:(List.cons hd) @@ interleave x tl)\n in\n match l with\n | [] -> [[]]\n | hd::tl -> List.concat @@ List.map (interleave hd) @@ aux tl in\n let l = List.sort (List.compare Int.compare) @@ aux @@ List.of_enum l in\n List.enum % ListL.map ~f:List.enum @@ l\n\nlet intersection l =\n EnumL.filter ~f:(fun x -> EnumL.exists ~f:((=) x) @@ Enum.clone l)\n\nlet lower_bound n f =\n let rec aux l u =\n if u - l > 1 then\n let m = (l + u) / 2 in\n if f m then aux l m\n else aux m u\n else u in aux (-1) n\n\nlet between n x m = n <= x && x < m\n\nlet (n,a,b,c) = scan \"%d %d %d %d\" Tuple4.make\nlet coms = scan_lines n \"%s\" id\n\nopen Option.Infix\nopen Option.Monad\n\nlet rec solve1 a b c= function\n | [] -> Some []\n | com::rest ->\n match com with\n | \"AB\" ->\n if a = 0 && b = 0 then None\n else if a = 1 then\n solve1 (pred a) (succ b) c rest >>= fun ret ->\n return (\"B\" :: ret)\n else\n solve1 (succ a) (pred b) c rest >>= fun ret ->\n return (\"A\" :: ret)\n | \"BC\" ->\n if b = 0 && c = 0 then None\n else if b = 1 then\n solve1 a (pred b) (succ c) rest >>= fun ret ->\n return (\"C\" :: ret)\n else\n solve1 a (succ b) (pred c) rest >>= fun ret ->\n return (\"B\" :: ret)\n | \"AC\" ->\n if a = 0 && c = 0 then None\n else if c = 1 then\n solve1 (succ a) b (pred c) rest >>= fun ret ->\n return (\"A\" :: ret)\n else solve1 (pred a) b (succ c) rest >>= fun ret ->\n return (\"C\" :: ret)\n | _ -> None\n\nlet rec solven a b c = function\n | [] -> Some []\n | com :: rest ->\n begin\n match com with\n | \"AB\" ->\n if a = 0 then\n solven (succ a) (pred b) c rest >>= fun ret ->\n return (\"A\" :: ret)\n else if a = 1 && b = 1 && List.at_opt rest 0 |> Option.is_some then\n let next = List.at rest 0 in\n match next with\n | \"AC\" -> solven (succ a) (pred b) c rest >>= fun ret ->\n return (\"A\"::ret)\n | \"BC\" -> solven (pred a) (succ b) c rest >>= fun ret ->\n return (\"B\"::ret)\n | \"AB\" -> solven (pred a) (succ b) c rest >>= fun ret ->\n return (\"B\"::ret)\n | _ -> None\n else\n solven (pred a) (succ b) c rest >>= fun ret ->\n return (\"B\" :: ret)\n | \"BC\" ->\n if b = 0 then\n solven a (succ b) (pred c) rest >>= fun ret ->\n return (\"B\" :: ret)\n else if b = 1 && c= 1 && List.at_opt rest 0 |> Option.is_some then\n let next = List.at rest 0 in\n match next with\n | \"AB\" -> solven a (succ b) (pred c) rest >>= fun ret ->\n return (\"B\" :: ret)\n | \"BC\" -> solven a (pred b) (succ c) rest >>= fun ret ->\n return (\"C\"::ret)\n | \"AC\" -> solven a (pred b) (succ c) rest >>= fun ret ->\n return (\"C\"::ret)\n | _ -> None\n else\n solven a (pred b) (succ c) rest >>= fun ret ->\n return (\"C\" :: ret)\n | \"AC\" ->\n if c = 0 then\n solven (pred a) b (succ c) rest >>= fun ret ->\n return (\"C\" :: ret)\n else if c = 1 && a = 1 && List.at_opt rest 0 |> Option.is_some then\n let next = List.at rest 0 in\n match next with\n | \"AB\" -> solven (succ a) b (pred c) rest >>= fun ret ->\n return (\"A\" :: ret)\n | \"BC\" -> solven (pred a) b (succ c) rest >>= fun ret ->\n return (\"C\"::ret)\n | \"AC\" -> solven (succ a) b (pred c) rest >>= fun ret ->\n return (\"A\"::ret)\n | _ -> None\n else\n solven (succ a) b (pred c) rest >>= fun ret ->\n return (\"A\" :: ret)\n | _ -> None\n end\n\nlet () =\n (if a + b + c = 0 then None\n else if a + b + c = 1 then\n solve1 a b c coms\n else\n match List.first coms with\n | \"AB\" when a = 0 && b = 0 -> None\n | \"BC\" when b = 0 && c = 0 -> None\n | \"AC\" when a = 0 && c = 0 -> None\n | _ ->\n solven a b c coms)\n |> Option.map_default (fun ans -> \"Yes\\n\" ^ String.join \"\\n\" ans) \"No\"\n |> Printf.printf \"%s\\n\"\n", "problem_context": "Score : 600 points\n\nProblem Statement\n\nThere is a game that involves three variables, denoted A, B, and C.\n\nAs the game progresses, there will be N events where you are asked to make a choice.\nEach of these choices is represented by a string s_i. If s_i is AB, you must add 1 to A or B then subtract 1 from the other; if s_i is AC, you must add 1 to A or C then subtract 1 from the other; if s_i is BC, you must add 1 to B or C then subtract 1 from the other.\n\nAfter each choice, none of A, B, and C should be negative.\n\nDetermine whether it is possible to make N choices under this condition. If it is possible, also give one such way to make the choices.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n0 \\leq A,B,C \\leq 10^9\n\nN, A, B, C are integers.\n\ns_i is AB, AC, or BC.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN A B C\ns_1\ns_2\n:\ns_N\n\nOutput\n\nIf it is possible to make N choices under the condition, print Yes; otherwise, print No.\n\nAlso, in the former case, show one such way to make the choices in the subsequent N lines. The (i+1)-th line should contain the name of the variable (A, B, or C) to which you add 1 in the i-th choice.\n\nSample Input 1\n\n2 1 3 0\nAB\nAC\n\nSample Output 1\n\nYes\nA\nC\n\nYou can successfully make two choices, as follows:\n\nIn the first choice, add 1 to A and subtract 1 from B. A becomes 2, and B becomes 2.\n\nIn the second choice, add 1 to C and subtract 1 from A. C becomes 1, and A becomes 1.\n\nSample Input 2\n\n3 1 0 0\nAB\nBC\nAB\n\nSample Output 2\n\nNo\n\nSample Input 3\n\n1 0 9 0\nAC\n\nSample Output 3\n\nNo\n\nSample Input 4\n\n8 6 9 1\nAC\nBC\nAB\nBC\nAC\nBC\nAB\nAB\n\nSample Output 4\n\nYes\nC\nB\nB\nC\nC\nB\nA\nA", "sample_input": "2 1 3 0\nAB\nAC\n"}, "reference_outputs": ["Yes\nA\nC\n"], "source_document_id": "p02692", "source_text": "Score : 600 points\n\nProblem Statement\n\nThere is a game that involves three variables, denoted A, B, and C.\n\nAs the game progresses, there will be N events where you are asked to make a choice.\nEach of these choices is represented by a string s_i. If s_i is AB, you must add 1 to A or B then subtract 1 from the other; if s_i is AC, you must add 1 to A or C then subtract 1 from the other; if s_i is BC, you must add 1 to B or C then subtract 1 from the other.\n\nAfter each choice, none of A, B, and C should be negative.\n\nDetermine whether it is possible to make N choices under this condition. If it is possible, also give one such way to make the choices.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n0 \\leq A,B,C \\leq 10^9\n\nN, A, B, C are integers.\n\ns_i is AB, AC, or BC.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN A B C\ns_1\ns_2\n:\ns_N\n\nOutput\n\nIf it is possible to make N choices under the condition, print Yes; otherwise, print No.\n\nAlso, in the former case, show one such way to make the choices in the subsequent N lines. The (i+1)-th line should contain the name of the variable (A, B, or C) to which you add 1 in the i-th choice.\n\nSample Input 1\n\n2 1 3 0\nAB\nAC\n\nSample Output 1\n\nYes\nA\nC\n\nYou can successfully make two choices, as follows:\n\nIn the first choice, add 1 to A and subtract 1 from B. A becomes 2, and B becomes 2.\n\nIn the second choice, add 1 to C and subtract 1 from A. C becomes 1, and A becomes 1.\n\nSample Input 2\n\n3 1 0 0\nAB\nBC\nAB\n\nSample Output 2\n\nNo\n\nSample Input 3\n\n1 0 9 0\nAC\n\nSample Output 3\n\nNo\n\nSample Input 4\n\n8 6 9 1\nAC\nBC\nAB\nBC\nAC\nBC\nAB\nAB\n\nSample Output 4\n\nYes\nC\nB\nB\nC\nC\nB\nA\nA", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 5357, "cpu_time_ms": 68, "memory_kb": 20212}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s187677865", "group_id": "codeNet:p02693", "input_text": "open Batteries\n\nlet len = Scanf.scanf \"%d\\n\" (\n fun k -> \n Scanf.scanf \"%d %d\" (\n fun a b -> \n List.range a `To b\n |> List.filter (fun x -> x mod k = 0)\n )\n) |> List.length\n \nlet () = Printf.printf \"%s\\n\" (if len = 0 then\n \"NG\"\n else\n \"OK\"\n )", "language": "OCaml", "metadata": {"date": 1588470123, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p02693.html", "problem_id": "p02693", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02693/input.txt", "sample_output_relpath": "derived/input_output/data/p02693/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02693/OCaml/s187677865.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s187677865", "user_id": "u280335093"}, "prompt_components": {"gold_output": "OK\n", "input_to_evaluate": "open Batteries\n\nlet len = Scanf.scanf \"%d\\n\" (\n fun k -> \n Scanf.scanf \"%d %d\" (\n fun a b -> \n List.range a `To b\n |> List.filter (fun x -> x mod k = 0)\n )\n) |> List.length\n \nlet () = Printf.printf \"%s\\n\" (if len = 0 then\n \"NG\"\n else\n \"OK\"\n )", "problem_context": "Score: 100 points\n\nProblem Statement\n\nTakahashi the Jumbo will practice golf.\n\nHis objective is to get a carry distance that is a multiple of K, while he can only make a carry distance of between A and B (inclusive).\n\nIf he can achieve the objective, print OK; if he cannot, print NG.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq A \\leq B \\leq 1000\n\n1 \\leq K \\leq 1000\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK\nA B\n\nOutput\n\nIf he can achieve the objective, print OK; if he cannot, print NG.\n\nSample Input 1\n\n7\n500 600\n\nSample Output 1\n\nOK\n\nAmong the multiples of 7, for example, 567 lies between 500 and 600.\n\nSample Input 2\n\n4\n5 7\n\nSample Output 2\n\nNG\n\nNo multiple of 4 lies between 5 and 7.\n\nSample Input 3\n\n1\n11 11\n\nSample Output 3\n\nOK", "sample_input": "7\n500 600\n"}, "reference_outputs": ["OK\n"], "source_document_id": "p02693", "source_text": "Score: 100 points\n\nProblem Statement\n\nTakahashi the Jumbo will practice golf.\n\nHis objective is to get a carry distance that is a multiple of K, while he can only make a carry distance of between A and B (inclusive).\n\nIf he can achieve the objective, print OK; if he cannot, print NG.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq A \\leq B \\leq 1000\n\n1 \\leq K \\leq 1000\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK\nA B\n\nOutput\n\nIf he can achieve the objective, print OK; if he cannot, print NG.\n\nSample Input 1\n\n7\n500 600\n\nSample Output 1\n\nOK\n\nAmong the multiples of 7, for example, 567 lies between 500 and 600.\n\nSample Input 2\n\n4\n5 7\n\nSample Output 2\n\nNG\n\nNo multiple of 4 lies between 5 and 7.\n\nSample Input 3\n\n1\n11 11\n\nSample Output 3\n\nOK", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 499, "cpu_time_ms": 8, "memory_kb": 4912}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s112714789", "group_id": "codeNet:p02694", "input_text": "open Batteries\nmodule EnumL = Enum.Labels\nmodule ListL = List.Labels\nmodule ArrayL = Array.Labels\n\nlet dbg0 x = Printf.eprintf \"[debug]%s\\n\" @@ dump x\nlet dbg1 x = dbg0 x; x\n\nlet id = identity\n\nlet (++) n m = List.range n `To m\nlet (++^) n m = if n < m then List.range n `To (pred m) else []\n\nlet scan fmt = Scanf.sscanf (read_line ()) fmt\n\nlet scan_lines n fmt f =\n if n = 0 then []\n else List.map (fun _ -> scan fmt f) (1 ++ n)\n\nlet scan_list sep cnv =\n let line = read_line () in\n (match sep with\n | None -> List.map String.of_char @@ String.to_list line\n | Some sep -> String.split_on_char sep line)\n |> List.map cnv\n\nlet scan_array ?sep cnv = Array.of_list @@ scan_list sep cnv\n\nlet scan_matrix n m e ?sep conv =\n let arr = Array.make_matrix n m e in\n ListL.iter (0 ++^ n)\n ~f:(fun i -> arr.(i) <- Array.of_list @@ scan_list sep conv);\n arr\n\nlet rec powerset e =\n match Enum.get e with\n | None -> Enum.singleton @@ Enum.empty ()\n | Some v ->\n let f = powerset e in\n let g = Enum.clone f in\n EnumL.map f ~f:(fun x -> let y = Enum.clone x in push y v; y)\n |> Enum.append g\n\nlet permutations l =\n let rec aux l =\n let rec interleave x = function\n | [] -> [[x]]\n | (hd::tl) as lst ->\n (x::lst) ::\n (ListL.map ~f:(List.cons hd) @@ interleave x tl)\n in\n match l with\n | [] -> [[]]\n | hd::tl -> List.concat @@ List.map (interleave hd) @@ aux tl in\n let l = List.sort (List.compare Int.compare) @@ aux @@ List.of_enum l in\n List.enum % ListL.map ~f:List.enum @@ l\n\nlet intersection l =\n EnumL.filter ~f:(fun x -> EnumL.exists ~f:((=) x) @@ Enum.clone l)\n\nlet lower_bound n f =\n let rec aux l u =\n if u - l > 1 then\n let m = (l + u) / 2 in\n if f m then aux l m\n else aux m u\n else u in aux (-1) n\n\nlet between n x m = n <= x && x < m\n\nlet x = scan \"%d\" id\n\nexception Found of int\n\nlet () =\n try\n ListL.fold_left ~init:100\n ~f:(fun acc i ->\n let w = Int.of_float @@ 1.01 *. Float.of_int acc in\n if w >= x then raise @@ Found i\n else w) (1++4000) |> ignore\n with\n | Found i -> Printf.printf \"%d\\n\" i\n", "language": "OCaml", "metadata": {"date": 1588806656, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p02694.html", "problem_id": "p02694", "resource_group": "low_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/OCaml/s112714789.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s112714789", "user_id": "u802614675"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "open Batteries\nmodule EnumL = Enum.Labels\nmodule ListL = List.Labels\nmodule ArrayL = Array.Labels\n\nlet dbg0 x = Printf.eprintf \"[debug]%s\\n\" @@ dump x\nlet dbg1 x = dbg0 x; x\n\nlet id = identity\n\nlet (++) n m = List.range n `To m\nlet (++^) n m = if n < m then List.range n `To (pred m) else []\n\nlet scan fmt = Scanf.sscanf (read_line ()) fmt\n\nlet scan_lines n fmt f =\n if n = 0 then []\n else List.map (fun _ -> scan fmt f) (1 ++ n)\n\nlet scan_list sep cnv =\n let line = read_line () in\n (match sep with\n | None -> List.map String.of_char @@ String.to_list line\n | Some sep -> String.split_on_char sep line)\n |> List.map cnv\n\nlet scan_array ?sep cnv = Array.of_list @@ scan_list sep cnv\n\nlet scan_matrix n m e ?sep conv =\n let arr = Array.make_matrix n m e in\n ListL.iter (0 ++^ n)\n ~f:(fun i -> arr.(i) <- Array.of_list @@ scan_list sep conv);\n arr\n\nlet rec powerset e =\n match Enum.get e with\n | None -> Enum.singleton @@ Enum.empty ()\n | Some v ->\n let f = powerset e in\n let g = Enum.clone f in\n EnumL.map f ~f:(fun x -> let y = Enum.clone x in push y v; y)\n |> Enum.append g\n\nlet permutations l =\n let rec aux l =\n let rec interleave x = function\n | [] -> [[x]]\n | (hd::tl) as lst ->\n (x::lst) ::\n (ListL.map ~f:(List.cons hd) @@ interleave x tl)\n in\n match l with\n | [] -> [[]]\n | hd::tl -> List.concat @@ List.map (interleave hd) @@ aux tl in\n let l = List.sort (List.compare Int.compare) @@ aux @@ List.of_enum l in\n List.enum % ListL.map ~f:List.enum @@ l\n\nlet intersection l =\n EnumL.filter ~f:(fun x -> EnumL.exists ~f:((=) x) @@ Enum.clone l)\n\nlet lower_bound n f =\n let rec aux l u =\n if u - l > 1 then\n let m = (l + u) / 2 in\n if f m then aux l m\n else aux m u\n else u in aux (-1) n\n\nlet between n x m = n <= x && x < m\n\nlet x = scan \"%d\" id\n\nexception Found of int\n\nlet () =\n try\n ListL.fold_left ~init:100\n ~f:(fun acc i ->\n let w = Int.of_float @@ 1.01 *. Float.of_int acc in\n if w >= x then raise @@ Found i\n else w) (1++4000) |> ignore\n with\n | Found i -> Printf.printf \"%d\\n\" i\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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2130, "cpu_time_ms": 6, "memory_kb": 5564}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s458203264", "group_id": "codeNet:p02694", "input_text": "let main x =\n let rec loop i y =\n if x <= y then\n print_int i\n else\n loop (i + 1) (int_of_float (float_of_int (y) *. 0.01))\n in\n loop 0 100;;\n\nScanf.sscanf (read_line ()) \"%d\" (fun x ->\n main x\n);;", "language": "OCaml", "metadata": {"date": 1588468872, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p02694.html", "problem_id": "p02694", "resource_group": "low_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/OCaml/s458203264.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s458203264", "user_id": "u354617423"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "let main x =\n let rec loop i y =\n if x <= y then\n print_int i\n else\n loop (i + 1) (int_of_float (float_of_int (y) *. 0.01))\n in\n loop 0 100;;\n\nScanf.sscanf (read_line ()) \"%d\" (fun x ->\n main x\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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 2205, "memory_kb": 3568}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s312280123", "group_id": "codeNet:p02695", "input_text": "open Batteries\nmodule EnumL = Enum.Labels\nmodule ListL = List.Labels\nmodule ArrayL = Array.Labels\n\nlet dbg0 x = Printf.eprintf \"[debug]%s\\n\" @@ dump x\nlet dbg1 x = dbg0 x; x\n\nlet id = identity\n\nlet (++) n m = List.range n `To m\nlet (++^) n m = if n < m then List.range n `To (pred m) else []\n\nlet scan fmt = Scanf.sscanf (read_line ()) fmt\n\nlet scan_lines n fmt f =\n if n = 0 then []\n else List.map (fun _ -> scan fmt f) (1 ++ n)\n\nlet scan_list sep cnv =\n let line = read_line () in\n (match sep with\n | None -> List.map String.of_char @@ String.to_list line\n | Some sep -> String.split_on_char sep line)\n |> List.map cnv\n\nlet scan_array ?sep cnv = Array.of_list @@ scan_list sep cnv\n\nlet scan_matrix n m e ?sep conv =\n let arr = Array.make_matrix n m e in\n ListL.iter (0 ++^ n)\n ~f:(fun i -> arr.(i) <- Array.of_list @@ scan_list sep conv);\n arr\n\nlet rec powerset e =\n match Enum.get e with\n | None -> Enum.singleton @@ Enum.empty ()\n | Some v ->\n let f = powerset e in\n let g = Enum.clone f in\n EnumL.map f ~f:(fun x -> let y = Enum.clone x in push y v; y)\n |> Enum.append g\n\nlet permutations l =\n let rec aux l =\n let rec interleave x = function\n | [] -> [[x]]\n | (hd::tl) as lst ->\n (x::lst) ::\n (ListL.map ~f:(List.cons hd) @@ interleave x tl)\n in\n match l with\n | [] -> [[]]\n | hd::tl -> List.concat @@ List.map (interleave hd) @@ aux tl in\n let l = List.sort (List.compare Int.compare) @@ aux @@ List.of_enum l in\n List.enum % ListL.map ~f:List.enum @@ l\n\nlet intersection l =\n EnumL.filter ~f:(fun x -> EnumL.exists ~f:((=) x) @@ Enum.clone l)\n\nlet lower_bound n f =\n let rec aux l u =\n if u - l > 1 then\n let m = (l + u) / 2 in\n if f m then aux l m\n else aux m u\n else u in aux (-1) n\n\nlet between n x m = n <= x && x < m\n\nlet inc_seq len m =\n let rec aux rest n =\n if rest = 0 then [[]]\n else if n = succ m then []\n else\n (ListL.map ~f:(fun l -> n::l) @@ aux (pred rest) n)\n @ aux rest (succ n)\n in\n aux len 1\n\nlet (n,m,q) = scan \"%d %d %d\" Tuple3.make\nlet qs = scan_lines q \"%d %d %d %d\" Tuple4.make\n\nlet () =\n inc_seq n m\n |> ListL.map ~f:Array.of_list\n (* |> (fun l -> List.print ~sep:\"\\n\" (Array.print Int.print) stderr l; l) *)\n |> ListL.map ~f:(fun l ->\n ListL.map ~f:(fun (a,b,c,d) ->\n if l.(pred b) - l.(pred a) = c then d else 0)\n qs |> List.sum)\n |> List.max\n |> Printf.printf \"%d\\n\"\n", "language": "OCaml", "metadata": {"date": 1588808446, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p02695.html", "problem_id": "p02695", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02695/input.txt", "sample_output_relpath": "derived/input_output/data/p02695/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02695/OCaml/s312280123.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s312280123", "user_id": "u802614675"}, "prompt_components": {"gold_output": "110\n", "input_to_evaluate": "open Batteries\nmodule EnumL = Enum.Labels\nmodule ListL = List.Labels\nmodule ArrayL = Array.Labels\n\nlet dbg0 x = Printf.eprintf \"[debug]%s\\n\" @@ dump x\nlet dbg1 x = dbg0 x; x\n\nlet id = identity\n\nlet (++) n m = List.range n `To m\nlet (++^) n m = if n < m then List.range n `To (pred m) else []\n\nlet scan fmt = Scanf.sscanf (read_line ()) fmt\n\nlet scan_lines n fmt f =\n if n = 0 then []\n else List.map (fun _ -> scan fmt f) (1 ++ n)\n\nlet scan_list sep cnv =\n let line = read_line () in\n (match sep with\n | None -> List.map String.of_char @@ String.to_list line\n | Some sep -> String.split_on_char sep line)\n |> List.map cnv\n\nlet scan_array ?sep cnv = Array.of_list @@ scan_list sep cnv\n\nlet scan_matrix n m e ?sep conv =\n let arr = Array.make_matrix n m e in\n ListL.iter (0 ++^ n)\n ~f:(fun i -> arr.(i) <- Array.of_list @@ scan_list sep conv);\n arr\n\nlet rec powerset e =\n match Enum.get e with\n | None -> Enum.singleton @@ Enum.empty ()\n | Some v ->\n let f = powerset e in\n let g = Enum.clone f in\n EnumL.map f ~f:(fun x -> let y = Enum.clone x in push y v; y)\n |> Enum.append g\n\nlet permutations l =\n let rec aux l =\n let rec interleave x = function\n | [] -> [[x]]\n | (hd::tl) as lst ->\n (x::lst) ::\n (ListL.map ~f:(List.cons hd) @@ interleave x tl)\n in\n match l with\n | [] -> [[]]\n | hd::tl -> List.concat @@ List.map (interleave hd) @@ aux tl in\n let l = List.sort (List.compare Int.compare) @@ aux @@ List.of_enum l in\n List.enum % ListL.map ~f:List.enum @@ l\n\nlet intersection l =\n EnumL.filter ~f:(fun x -> EnumL.exists ~f:((=) x) @@ Enum.clone l)\n\nlet lower_bound n f =\n let rec aux l u =\n if u - l > 1 then\n let m = (l + u) / 2 in\n if f m then aux l m\n else aux m u\n else u in aux (-1) n\n\nlet between n x m = n <= x && x < m\n\nlet inc_seq len m =\n let rec aux rest n =\n if rest = 0 then [[]]\n else if n = succ m then []\n else\n (ListL.map ~f:(fun l -> n::l) @@ aux (pred rest) n)\n @ aux rest (succ n)\n in\n aux len 1\n\nlet (n,m,q) = scan \"%d %d %d\" Tuple3.make\nlet qs = scan_lines q \"%d %d %d %d\" Tuple4.make\n\nlet () =\n inc_seq n m\n |> ListL.map ~f:Array.of_list\n (* |> (fun l -> List.print ~sep:\"\\n\" (Array.print Int.print) stderr l; l) *)\n |> ListL.map ~f:(fun l ->\n ListL.map ~f:(fun (a,b,c,d) ->\n if l.(pred b) - l.(pred a) = c then d else 0)\n qs |> List.sum)\n |> List.max\n |> Printf.printf \"%d\\n\"\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nGiven are positive integers N, M, Q, and Q quadruples of integers ( a_i , b_i , c_i , d_i ).\n\nConsider a sequence A satisfying the following conditions:\n\nA is a sequence of N positive integers.\n\n1 \\leq A_1 \\leq A_2 \\le \\cdots \\leq A_N \\leq M.\n\nLet us define a score of this sequence as follows:\n\nThe score is the sum of d_i over all indices i such that A_{b_i} - A_{a_i} = c_i. (If there is no such i, the score is 0.)\n\nFind the maximum possible score of A.\n\nConstraints\n\nAll values in input are integers.\n\n2 ≤ N ≤ 10\n\n1 \\leq M \\leq 10\n\n1 \\leq Q \\leq 50\n\n1 \\leq a_i < b_i \\leq N ( i = 1, 2, ..., Q )\n\n0 \\leq c_i \\leq M - 1 ( i = 1, 2, ..., Q )\n\n(a_i, b_i, c_i) \\neq (a_j, b_j, c_j) (where i \\neq j)\n\n1 \\leq d_i \\leq 10^5 ( i = 1, 2, ..., Q )\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M Q\na_1 b_1 c_1 d_1\n:\na_Q b_Q c_Q d_Q\n\nOutput\n\nPrint the maximum possible score of A.\n\nSample Input 1\n\n3 4 3\n1 3 3 100\n1 2 2 10\n2 3 2 10\n\nSample Output 1\n\n110\n\nWhen A = \\{1, 3, 4\\}, its score is 110. Under these conditions, no sequence has a score greater than 110, so the answer is 110.\n\nSample Input 2\n\n4 6 10\n2 4 1 86568\n1 4 0 90629\n2 3 0 90310\n3 4 1 29211\n3 4 3 78537\n3 4 2 8580\n1 2 1 96263\n1 4 2 2156\n1 2 0 94325\n1 4 3 94328\n\nSample Output 2\n\n357500\n\nSample Input 3\n\n10 10 1\n1 10 9 1\n\nSample Output 3\n\n1", "sample_input": "3 4 3\n1 3 3 100\n1 2 2 10\n2 3 2 10\n"}, "reference_outputs": ["110\n"], "source_document_id": "p02695", "source_text": "Score : 300 points\n\nProblem Statement\n\nGiven are positive integers N, M, Q, and Q quadruples of integers ( a_i , b_i , c_i , d_i ).\n\nConsider a sequence A satisfying the following conditions:\n\nA is a sequence of N positive integers.\n\n1 \\leq A_1 \\leq A_2 \\le \\cdots \\leq A_N \\leq M.\n\nLet us define a score of this sequence as follows:\n\nThe score is the sum of d_i over all indices i such that A_{b_i} - A_{a_i} = c_i. (If there is no such i, the score is 0.)\n\nFind the maximum possible score of A.\n\nConstraints\n\nAll values in input are integers.\n\n2 ≤ N ≤ 10\n\n1 \\leq M \\leq 10\n\n1 \\leq Q \\leq 50\n\n1 \\leq a_i < b_i \\leq N ( i = 1, 2, ..., Q )\n\n0 \\leq c_i \\leq M - 1 ( i = 1, 2, ..., Q )\n\n(a_i, b_i, c_i) \\neq (a_j, b_j, c_j) (where i \\neq j)\n\n1 \\leq d_i \\leq 10^5 ( i = 1, 2, ..., Q )\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M Q\na_1 b_1 c_1 d_1\n:\na_Q b_Q c_Q d_Q\n\nOutput\n\nPrint the maximum possible score of A.\n\nSample Input 1\n\n3 4 3\n1 3 3 100\n1 2 2 10\n2 3 2 10\n\nSample Output 1\n\n110\n\nWhen A = \\{1, 3, 4\\}, its score is 110. Under these conditions, no sequence has a score greater than 110, so the answer is 110.\n\nSample Input 2\n\n4 6 10\n2 4 1 86568\n1 4 0 90629\n2 3 0 90310\n3 4 1 29211\n3 4 3 78537\n3 4 2 8580\n1 2 1 96263\n1 4 2 2156\n1 2 0 94325\n1 4 3 94328\n\nSample Output 2\n\n357500\n\nSample Input 3\n\n10 10 1\n1 10 9 1\n\nSample Output 3\n\n1", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2450, "cpu_time_ms": 189, "memory_kb": 49288}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s012440762", "group_id": "codeNet:p02695", "input_text": "open Batteries\n(* 重複順列 *)\nlet rec dup_perm n lst =\n if n = 0 then [[]]\n else flatmap (fun x -> List.map (fun y -> x :: y)\n (dup_perm (n - 1) lst))\n lst\nand flatten = function\n [] -> []\n| x::xs -> x @ (flatten xs)\nand flatmap func ls = flatten (List.map func ls)\n\n\nlet n, m, q = Scanf.sscanf (read_line()) \"%d %d %d\" (fun n m q ->\n n, m, q\n)\nlet abcd = List.init q @@ fun a ->Scanf.sscanf (read_line()) \"%d %d %d %d\" (fun a b c d ->\n (a,b,c,d)\n)\n\nlet a_list = dup_perm n @@ List.init m @@ fun b -> b+1\n\n\nlet rec check target lst ans =\n match lst with\n | [] -> ans\n | first :: rest ->\n let a,b,c,d = first in\n if target.(b-1) - target.(a-1) = c then check target rest (d+ans) else check target rest ans\n\n\nlet rec loop lst ans =\n match lst with\n | [] -> ans\n | first :: rest -> (\n let target = List.sort compare first |> Array.of_list in\n let r = check target abcd 0 in if r > ans then loop rest r else loop rest ans\n )\n\nlet _ = Printf.printf \"%d\\n\" @@ loop a_list 0\n\n", "language": "OCaml", "metadata": {"date": 1588474147, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p02695.html", "problem_id": "p02695", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02695/input.txt", "sample_output_relpath": "derived/input_output/data/p02695/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02695/OCaml/s012440762.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s012440762", "user_id": "u511870776"}, "prompt_components": {"gold_output": "110\n", "input_to_evaluate": "open Batteries\n(* 重複順列 *)\nlet rec dup_perm n lst =\n if n = 0 then [[]]\n else flatmap (fun x -> List.map (fun y -> x :: y)\n (dup_perm (n - 1) lst))\n lst\nand flatten = function\n [] -> []\n| x::xs -> x @ (flatten xs)\nand flatmap func ls = flatten (List.map func ls)\n\n\nlet n, m, q = Scanf.sscanf (read_line()) \"%d %d %d\" (fun n m q ->\n n, m, q\n)\nlet abcd = List.init q @@ fun a ->Scanf.sscanf (read_line()) \"%d %d %d %d\" (fun a b c d ->\n (a,b,c,d)\n)\n\nlet a_list = dup_perm n @@ List.init m @@ fun b -> b+1\n\n\nlet rec check target lst ans =\n match lst with\n | [] -> ans\n | first :: rest ->\n let a,b,c,d = first in\n if target.(b-1) - target.(a-1) = c then check target rest (d+ans) else check target rest ans\n\n\nlet rec loop lst ans =\n match lst with\n | [] -> ans\n | first :: rest -> (\n let target = List.sort compare first |> Array.of_list in\n let r = check target abcd 0 in if r > ans then loop rest r else loop rest ans\n )\n\nlet _ = Printf.printf \"%d\\n\" @@ loop a_list 0\n\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nGiven are positive integers N, M, Q, and Q quadruples of integers ( a_i , b_i , c_i , d_i ).\n\nConsider a sequence A satisfying the following conditions:\n\nA is a sequence of N positive integers.\n\n1 \\leq A_1 \\leq A_2 \\le \\cdots \\leq A_N \\leq M.\n\nLet us define a score of this sequence as follows:\n\nThe score is the sum of d_i over all indices i such that A_{b_i} - A_{a_i} = c_i. (If there is no such i, the score is 0.)\n\nFind the maximum possible score of A.\n\nConstraints\n\nAll values in input are integers.\n\n2 ≤ N ≤ 10\n\n1 \\leq M \\leq 10\n\n1 \\leq Q \\leq 50\n\n1 \\leq a_i < b_i \\leq N ( i = 1, 2, ..., Q )\n\n0 \\leq c_i \\leq M - 1 ( i = 1, 2, ..., Q )\n\n(a_i, b_i, c_i) \\neq (a_j, b_j, c_j) (where i \\neq j)\n\n1 \\leq d_i \\leq 10^5 ( i = 1, 2, ..., Q )\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M Q\na_1 b_1 c_1 d_1\n:\na_Q b_Q c_Q d_Q\n\nOutput\n\nPrint the maximum possible score of A.\n\nSample Input 1\n\n3 4 3\n1 3 3 100\n1 2 2 10\n2 3 2 10\n\nSample Output 1\n\n110\n\nWhen A = \\{1, 3, 4\\}, its score is 110. Under these conditions, no sequence has a score greater than 110, so the answer is 110.\n\nSample Input 2\n\n4 6 10\n2 4 1 86568\n1 4 0 90629\n2 3 0 90310\n3 4 1 29211\n3 4 3 78537\n3 4 2 8580\n1 2 1 96263\n1 4 2 2156\n1 2 0 94325\n1 4 3 94328\n\nSample Output 2\n\n357500\n\nSample Input 3\n\n10 10 1\n1 10 9 1\n\nSample Output 3\n\n1", "sample_input": "3 4 3\n1 3 3 100\n1 2 2 10\n2 3 2 10\n"}, "reference_outputs": ["110\n"], "source_document_id": "p02695", "source_text": "Score : 300 points\n\nProblem Statement\n\nGiven are positive integers N, M, Q, and Q quadruples of integers ( a_i , b_i , c_i , d_i ).\n\nConsider a sequence A satisfying the following conditions:\n\nA is a sequence of N positive integers.\n\n1 \\leq A_1 \\leq A_2 \\le \\cdots \\leq A_N \\leq M.\n\nLet us define a score of this sequence as follows:\n\nThe score is the sum of d_i over all indices i such that A_{b_i} - A_{a_i} = c_i. (If there is no such i, the score is 0.)\n\nFind the maximum possible score of A.\n\nConstraints\n\nAll values in input are integers.\n\n2 ≤ N ≤ 10\n\n1 \\leq M \\leq 10\n\n1 \\leq Q \\leq 50\n\n1 \\leq a_i < b_i \\leq N ( i = 1, 2, ..., Q )\n\n0 \\leq c_i \\leq M - 1 ( i = 1, 2, ..., Q )\n\n(a_i, b_i, c_i) \\neq (a_j, b_j, c_j) (where i \\neq j)\n\n1 \\leq d_i \\leq 10^5 ( i = 1, 2, ..., Q )\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M Q\na_1 b_1 c_1 d_1\n:\na_Q b_Q c_Q d_Q\n\nOutput\n\nPrint the maximum possible score of A.\n\nSample Input 1\n\n3 4 3\n1 3 3 100\n1 2 2 10\n2 3 2 10\n\nSample Output 1\n\n110\n\nWhen A = \\{1, 3, 4\\}, its score is 110. Under these conditions, no sequence has a score greater than 110, so the answer is 110.\n\nSample Input 2\n\n4 6 10\n2 4 1 86568\n1 4 0 90629\n2 3 0 90310\n3 4 1 29211\n3 4 3 78537\n3 4 2 8580\n1 2 1 96263\n1 4 2 2156\n1 2 0 94325\n1 4 3 94328\n\nSample Output 2\n\n357500\n\nSample Input 3\n\n10 10 1\n1 10 9 1\n\nSample Output 3\n\n1", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1044, "cpu_time_ms": 2224, "memory_kb": 589048}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s440209183", "group_id": "codeNet:p02696", "input_text": "let () = Scanf.scanf \"%d %d %d\" @@ fun a b n ->\n let x = min (b-1) n in\n Printf.printf \"%d\" @@ (a*x)/b - a * (x/b)\n", "language": "OCaml", "metadata": {"date": 1588887610, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p02696.html", "problem_id": "p02696", "resource_group": "low_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/OCaml/s440209183.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s440209183", "user_id": "u604818425"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "let () = Scanf.scanf \"%d %d %d\" @@ fun a b n ->\n let x = min (b-1) n in\n Printf.printf \"%d\" @@ (a*x)/b - a * (x/b)\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nGiven are integers A, B, and N.\n\nFind the maximum possible value of floor(Ax/B) - A × floor(x/B) for a non-negative integer x not greater than N.\n\nHere floor(t) denotes the greatest integer not greater than the real number t.\n\nConstraints\n\n1 ≤ A ≤ 10^{6}\n\n1 ≤ B ≤ 10^{12}\n\n1 ≤ N ≤ 10^{12}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B N\n\nOutput\n\nPrint the maximum possible value of floor(Ax/B) - A × floor(x/B) for a non-negative integer x not greater than N, as an integer.\n\nSample Input 1\n\n5 7 4\n\nSample Output 1\n\n2\n\nWhen x=3, floor(Ax/B)-A×floor(x/B) = floor(15/7) - 5×floor(3/7) = 2. This is the maximum value possible.\n\nSample Input 2\n\n11 10 9\n\nSample Output 2\n\n9", "sample_input": "5 7 4\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02696", "source_text": "Score : 400 points\n\nProblem Statement\n\nGiven are integers A, B, and N.\n\nFind the maximum possible value of floor(Ax/B) - A × floor(x/B) for a non-negative integer x not greater than N.\n\nHere floor(t) denotes the greatest integer not greater than the real number t.\n\nConstraints\n\n1 ≤ A ≤ 10^{6}\n\n1 ≤ B ≤ 10^{12}\n\n1 ≤ N ≤ 10^{12}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B N\n\nOutput\n\nPrint the maximum possible value of floor(Ax/B) - A × floor(x/B) for a non-negative integer x not greater than N, as an integer.\n\nSample Input 1\n\n5 7 4\n\nSample Output 1\n\n2\n\nWhen x=3, floor(Ax/B)-A×floor(x/B) = floor(15/7) - 5×floor(3/7) = 2. This is the maximum value possible.\n\nSample Input 2\n\n11 10 9\n\nSample Output 2\n\n9", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 6, "memory_kb": 3804}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s307344856", "group_id": "codeNet:p02697", "input_text": "open Batteries\nmodule EnumL = Enum.Labels\nmodule ListL = List.Labels\nmodule ArrayL = Array.Labels\n\nlet dbg0 x = Printf.eprintf \"[debug]%s\\n\" @@ dump x\nlet dbg1 x = dbg0 x; x\n\nlet id = identity\n\nlet (++) n m = if n <= m then List.range n `To m else []\nlet (++-) n m = if n >= m then List.range n `Downto m else []\nlet (++^) n m = if n < m then List.range n `To (pred m) else []\n\nlet scan fmt = Scanf.sscanf (read_line ()) fmt\n\nlet scan_lines n fmt f =\n if n = 0 then []\n else List.map (fun _ -> scan fmt f) (1 ++ n)\n\nlet scan_list sep cnv =\n let line = read_line () in\n (match sep with\n | None -> List.map String.of_char @@ String.to_list line\n | Some sep -> String.split_on_char sep line)\n |> List.map cnv\n\nlet scan_array ?sep cnv = Array.of_list @@ scan_list sep cnv\n\nlet scan_matrix n m e ?sep conv =\n let arr = Array.make_matrix n m e in\n ListL.iter (0 ++^ n)\n ~f:(fun i -> arr.(i) <- Array.of_list @@ scan_list sep conv);\n arr\n\nlet rec powerset e =\n match Enum.get e with\n | None -> Enum.singleton @@ Enum.empty ()\n | Some v ->\n let f = powerset e in\n let g = Enum.clone f in\n EnumL.map f ~f:(fun x -> let y = Enum.clone x in push y v; y)\n |> Enum.append g\n\nlet permutations l =\n let rec aux l =\n let rec interleave x = function\n | [] -> [[x]]\n | (hd::tl) as lst ->\n (x::lst) ::\n (ListL.map ~f:(List.cons hd) @@ interleave x tl)\n in\n match l with\n | [] -> [[]]\n | hd::tl -> List.concat @@ List.map (interleave hd) @@ aux tl in\n let l = List.sort (List.compare Int.compare) @@ aux @@ List.of_enum l in\n List.enum % ListL.map ~f:List.enum @@ l\n\nlet intersection l =\n EnumL.filter ~f:(fun x -> EnumL.exists ~f:((=) x) @@ Enum.clone l)\n\nlet lower_bound n f =\n let rec aux l u =\n if u - l > 1 then\n let m = (l + u) / 2 in\n if f m then aux l m\n else aux m u\n else u in aux (-1) n\n\nlet between n x m = n <= x && x < m\n\nlet (n, m) = scan \"%d %d\" Tuple2.make\n\n\nlet () =\n (if n mod 2 = 1 then\n ListL.map (1++(n/2)) ~f:(fun i -> (i, n-i))\n else\n (1,2)::(ListL.map (List.combine (3++(n/2+1))\n (n-1 ++- (n/2+1)))\n ~f:(fun (i,j) -> (i, j))))\n |> List.take m\n |> ListL.iter ~f:(fun (i,j) -> Printf.printf \"%d %d\\n\" i j)\n", "language": "OCaml", "metadata": {"date": 1589048086, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p02697.html", "problem_id": "p02697", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02697/input.txt", "sample_output_relpath": "derived/input_output/data/p02697/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02697/OCaml/s307344856.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s307344856", "user_id": "u802614675"}, "prompt_components": {"gold_output": "2 3\n", "input_to_evaluate": "open Batteries\nmodule EnumL = Enum.Labels\nmodule ListL = List.Labels\nmodule ArrayL = Array.Labels\n\nlet dbg0 x = Printf.eprintf \"[debug]%s\\n\" @@ dump x\nlet dbg1 x = dbg0 x; x\n\nlet id = identity\n\nlet (++) n m = if n <= m then List.range n `To m else []\nlet (++-) n m = if n >= m then List.range n `Downto m else []\nlet (++^) n m = if n < m then List.range n `To (pred m) else []\n\nlet scan fmt = Scanf.sscanf (read_line ()) fmt\n\nlet scan_lines n fmt f =\n if n = 0 then []\n else List.map (fun _ -> scan fmt f) (1 ++ n)\n\nlet scan_list sep cnv =\n let line = read_line () in\n (match sep with\n | None -> List.map String.of_char @@ String.to_list line\n | Some sep -> String.split_on_char sep line)\n |> List.map cnv\n\nlet scan_array ?sep cnv = Array.of_list @@ scan_list sep cnv\n\nlet scan_matrix n m e ?sep conv =\n let arr = Array.make_matrix n m e in\n ListL.iter (0 ++^ n)\n ~f:(fun i -> arr.(i) <- Array.of_list @@ scan_list sep conv);\n arr\n\nlet rec powerset e =\n match Enum.get e with\n | None -> Enum.singleton @@ Enum.empty ()\n | Some v ->\n let f = powerset e in\n let g = Enum.clone f in\n EnumL.map f ~f:(fun x -> let y = Enum.clone x in push y v; y)\n |> Enum.append g\n\nlet permutations l =\n let rec aux l =\n let rec interleave x = function\n | [] -> [[x]]\n | (hd::tl) as lst ->\n (x::lst) ::\n (ListL.map ~f:(List.cons hd) @@ interleave x tl)\n in\n match l with\n | [] -> [[]]\n | hd::tl -> List.concat @@ List.map (interleave hd) @@ aux tl in\n let l = List.sort (List.compare Int.compare) @@ aux @@ List.of_enum l in\n List.enum % ListL.map ~f:List.enum @@ l\n\nlet intersection l =\n EnumL.filter ~f:(fun x -> EnumL.exists ~f:((=) x) @@ Enum.clone l)\n\nlet lower_bound n f =\n let rec aux l u =\n if u - l > 1 then\n let m = (l + u) / 2 in\n if f m then aux l m\n else aux m u\n else u in aux (-1) n\n\nlet between n x m = n <= x && x < m\n\nlet (n, m) = scan \"%d %d\" Tuple2.make\n\n\nlet () =\n (if n mod 2 = 1 then\n ListL.map (1++(n/2)) ~f:(fun i -> (i, n-i))\n else\n (1,2)::(ListL.map (List.combine (3++(n/2+1))\n (n-1 ++- (n/2+1)))\n ~f:(fun (i,j) -> (i, j))))\n |> List.take m\n |> ListL.iter ~f:(fun (i,j) -> Printf.printf \"%d %d\\n\" i j)\n", "problem_context": "Score : 500 points\n\nProblem Statement\n\nYou are going to hold a competition of one-to-one game called AtCoder Janken. (Janken is the Japanese name for Rock-paper-scissors.)\nN players will participate in this competition, and they are given distinct integers from 1 through N.\nThe arena has M playing fields for two players. You need to assign each playing field two distinct integers between 1 and N (inclusive).\nYou cannot assign the same integer to multiple playing fields.\nThe competition consists of N rounds, each of which proceeds as follows:\n\nFor each player, if there is a playing field that is assigned the player's integer, the player goes to that field and fight the other player who comes there.\n\nThen, each player adds 1 to its integer. If it becomes N+1, change it to 1.\n\nYou want to ensure that no player fights the same opponent more than once during the N rounds.\nPrint an assignment of integers to the playing fields satisfying this condition.\nIt can be proved that such an assignment always exists under the constraints given.\n\nConstraints\n\n1 \\leq M\n\nM \\times 2 +1 \\leq N \\leq 200000\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\n\nOutput\n\nPrint M lines in the format below.\nThe i-th line should contain the two integers a_i and b_i assigned to the i-th playing field.\n\na_1 b_1\na_2 b_2\n:\na_M b_M\n\nSample Input 1\n\n4 1\n\nSample Output 1\n\n2 3\n\nLet us call the four players A, B, C, and D, and assume that they are initially given the integers 1, 2, 3, and 4, respectively.\n\nThe 1-st round is fought by B and C, who has the integers 2 and 3, respectively. After this round, A, B, C, and D have the integers 2, 3, 4, and 1, respectively.\n\nThe 2-nd round is fought by A and B, who has the integers 2 and 3, respectively. After this round, A, B, C, and D have the integers 3, 4, 1, and 2, respectively.\n\nThe 3-rd round is fought by D and A, who has the integers 2 and 3, respectively. After this round, A, B, C, and D have the integers 4, 1, 2, and 3, respectively.\n\nThe 4-th round is fought by C and D, who has the integers 2 and 3, respectively. After this round, A, B, C, and D have the integers 1, 2, 3, and 4, respectively.\n\nNo player fights the same opponent more than once during the four rounds, so this solution will be accepted.\n\nSample Input 2\n\n7 3\n\nSample Output 2\n\n1 6\n2 5\n3 4", "sample_input": "4 1\n"}, "reference_outputs": ["2 3\n"], "source_document_id": "p02697", "source_text": "Score : 500 points\n\nProblem Statement\n\nYou are going to hold a competition of one-to-one game called AtCoder Janken. (Janken is the Japanese name for Rock-paper-scissors.)\nN players will participate in this competition, and they are given distinct integers from 1 through N.\nThe arena has M playing fields for two players. You need to assign each playing field two distinct integers between 1 and N (inclusive).\nYou cannot assign the same integer to multiple playing fields.\nThe competition consists of N rounds, each of which proceeds as follows:\n\nFor each player, if there is a playing field that is assigned the player's integer, the player goes to that field and fight the other player who comes there.\n\nThen, each player adds 1 to its integer. If it becomes N+1, change it to 1.\n\nYou want to ensure that no player fights the same opponent more than once during the N rounds.\nPrint an assignment of integers to the playing fields satisfying this condition.\nIt can be proved that such an assignment always exists under the constraints given.\n\nConstraints\n\n1 \\leq M\n\nM \\times 2 +1 \\leq N \\leq 200000\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\n\nOutput\n\nPrint M lines in the format below.\nThe i-th line should contain the two integers a_i and b_i assigned to the i-th playing field.\n\na_1 b_1\na_2 b_2\n:\na_M b_M\n\nSample Input 1\n\n4 1\n\nSample Output 1\n\n2 3\n\nLet us call the four players A, B, C, and D, and assume that they are initially given the integers 1, 2, 3, and 4, respectively.\n\nThe 1-st round is fought by B and C, who has the integers 2 and 3, respectively. After this round, A, B, C, and D have the integers 2, 3, 4, and 1, respectively.\n\nThe 2-nd round is fought by A and B, who has the integers 2 and 3, respectively. After this round, A, B, C, and D have the integers 3, 4, 1, and 2, respectively.\n\nThe 3-rd round is fought by D and A, who has the integers 2 and 3, respectively. After this round, A, B, C, and D have the integers 4, 1, 2, and 3, respectively.\n\nThe 4-th round is fought by C and D, who has the integers 2 and 3, respectively. After this round, A, B, C, and D have the integers 1, 2, 3, and 4, respectively.\n\nNo player fights the same opponent more than once during the four rounds, so this solution will be accepted.\n\nSample Input 2\n\n7 3\n\nSample Output 2\n\n1 6\n2 5\n3 4", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2258, "cpu_time_ms": 84, "memory_kb": 19180}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s974823739", "group_id": "codeNet:p02697", "input_text": "Scanf.scanf \"%d %d\" (fun n m ->\n if n mod 2 = 1 then (\n for i = 1 to m do\n Printf.printf \"%d %d\\n\" i (n - i)\n done\n ) else (\n let m1 = (m + 1) / 2 in\n let m2 = m - m1 in\n for i = 1 to m1 do\n Printf.printf \"%d %d\\n\" i (m1 * 2 + 1 - i)\n done;\n for i = 1 to m2 do\n Printf.printf \"%d %d\\n\" (m1 * 2 + 1 + i) (m1 * 2 + 1 + m2 * 2 + 2 - i)\n done\n )\n)", "language": "OCaml", "metadata": {"date": 1588480060, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p02697.html", "problem_id": "p02697", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02697/input.txt", "sample_output_relpath": "derived/input_output/data/p02697/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02697/OCaml/s974823739.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s974823739", "user_id": "u342443598"}, "prompt_components": {"gold_output": "2 3\n", "input_to_evaluate": "Scanf.scanf \"%d %d\" (fun n m ->\n if n mod 2 = 1 then (\n for i = 1 to m do\n Printf.printf \"%d %d\\n\" i (n - i)\n done\n ) else (\n let m1 = (m + 1) / 2 in\n let m2 = m - m1 in\n for i = 1 to m1 do\n Printf.printf \"%d %d\\n\" i (m1 * 2 + 1 - i)\n done;\n for i = 1 to m2 do\n Printf.printf \"%d %d\\n\" (m1 * 2 + 1 + i) (m1 * 2 + 1 + m2 * 2 + 2 - i)\n done\n )\n)", "problem_context": "Score : 500 points\n\nProblem Statement\n\nYou are going to hold a competition of one-to-one game called AtCoder Janken. (Janken is the Japanese name for Rock-paper-scissors.)\nN players will participate in this competition, and they are given distinct integers from 1 through N.\nThe arena has M playing fields for two players. You need to assign each playing field two distinct integers between 1 and N (inclusive).\nYou cannot assign the same integer to multiple playing fields.\nThe competition consists of N rounds, each of which proceeds as follows:\n\nFor each player, if there is a playing field that is assigned the player's integer, the player goes to that field and fight the other player who comes there.\n\nThen, each player adds 1 to its integer. If it becomes N+1, change it to 1.\n\nYou want to ensure that no player fights the same opponent more than once during the N rounds.\nPrint an assignment of integers to the playing fields satisfying this condition.\nIt can be proved that such an assignment always exists under the constraints given.\n\nConstraints\n\n1 \\leq M\n\nM \\times 2 +1 \\leq N \\leq 200000\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\n\nOutput\n\nPrint M lines in the format below.\nThe i-th line should contain the two integers a_i and b_i assigned to the i-th playing field.\n\na_1 b_1\na_2 b_2\n:\na_M b_M\n\nSample Input 1\n\n4 1\n\nSample Output 1\n\n2 3\n\nLet us call the four players A, B, C, and D, and assume that they are initially given the integers 1, 2, 3, and 4, respectively.\n\nThe 1-st round is fought by B and C, who has the integers 2 and 3, respectively. After this round, A, B, C, and D have the integers 2, 3, 4, and 1, respectively.\n\nThe 2-nd round is fought by A and B, who has the integers 2 and 3, respectively. After this round, A, B, C, and D have the integers 3, 4, 1, and 2, respectively.\n\nThe 3-rd round is fought by D and A, who has the integers 2 and 3, respectively. After this round, A, B, C, and D have the integers 4, 1, 2, and 3, respectively.\n\nThe 4-th round is fought by C and D, who has the integers 2 and 3, respectively. After this round, A, B, C, and D have the integers 1, 2, 3, and 4, respectively.\n\nNo player fights the same opponent more than once during the four rounds, so this solution will be accepted.\n\nSample Input 2\n\n7 3\n\nSample Output 2\n\n1 6\n2 5\n3 4", "sample_input": "4 1\n"}, "reference_outputs": ["2 3\n"], "source_document_id": "p02697", "source_text": "Score : 500 points\n\nProblem Statement\n\nYou are going to hold a competition of one-to-one game called AtCoder Janken. (Janken is the Japanese name for Rock-paper-scissors.)\nN players will participate in this competition, and they are given distinct integers from 1 through N.\nThe arena has M playing fields for two players. You need to assign each playing field two distinct integers between 1 and N (inclusive).\nYou cannot assign the same integer to multiple playing fields.\nThe competition consists of N rounds, each of which proceeds as follows:\n\nFor each player, if there is a playing field that is assigned the player's integer, the player goes to that field and fight the other player who comes there.\n\nThen, each player adds 1 to its integer. If it becomes N+1, change it to 1.\n\nYou want to ensure that no player fights the same opponent more than once during the N rounds.\nPrint an assignment of integers to the playing fields satisfying this condition.\nIt can be proved that such an assignment always exists under the constraints given.\n\nConstraints\n\n1 \\leq M\n\nM \\times 2 +1 \\leq N \\leq 200000\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\n\nOutput\n\nPrint M lines in the format below.\nThe i-th line should contain the two integers a_i and b_i assigned to the i-th playing field.\n\na_1 b_1\na_2 b_2\n:\na_M b_M\n\nSample Input 1\n\n4 1\n\nSample Output 1\n\n2 3\n\nLet us call the four players A, B, C, and D, and assume that they are initially given the integers 1, 2, 3, and 4, respectively.\n\nThe 1-st round is fought by B and C, who has the integers 2 and 3, respectively. After this round, A, B, C, and D have the integers 2, 3, 4, and 1, respectively.\n\nThe 2-nd round is fought by A and B, who has the integers 2 and 3, respectively. After this round, A, B, C, and D have the integers 3, 4, 1, and 2, respectively.\n\nThe 3-rd round is fought by D and A, who has the integers 2 and 3, respectively. After this round, A, B, C, and D have the integers 4, 1, 2, and 3, respectively.\n\nThe 4-th round is fought by C and D, who has the integers 2 and 3, respectively. After this round, A, B, C, and D have the integers 1, 2, 3, and 4, respectively.\n\nNo player fights the same opponent more than once during the four rounds, so this solution will be accepted.\n\nSample Input 2\n\n7 3\n\nSample Output 2\n\n1 6\n2 5\n3 4", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 441, "cpu_time_ms": 42, "memory_kb": 5900}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s679237334", "group_id": "codeNet:p02699", "input_text": "let s, w = Scanf.sscanf (read_line ()) \"%d %d\" @@ fun s w -> (s, w)\nlet () = print_endline @@ if s > w then \"safe\" else \"unsafe\"", "language": "OCaml", "metadata": {"date": 1594772178, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p02699.html", "problem_id": "p02699", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02699/input.txt", "sample_output_relpath": "derived/input_output/data/p02699/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02699/OCaml/s679237334.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s679237334", "user_id": "u811309788"}, "prompt_components": {"gold_output": "unsafe\n", "input_to_evaluate": "let s, w = Scanf.sscanf (read_line ()) \"%d %d\" @@ fun s w -> (s, w)\nlet () = print_endline @@ if s > w then \"safe\" else \"unsafe\"", "problem_context": "Score : 100 points\n\nProblem Statement\n\nThere are S sheep and W wolves.\n\nIf the number of wolves is greater than or equal to that of sheep, the wolves will attack the sheep.\n\nIf the wolves will attack the sheep, print unsafe; otherwise, print safe.\n\nConstraints\n\n1 \\leq S \\leq 100\n\n1 \\leq W \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS W\n\nOutput\n\nIf the wolves will attack the sheep, print unsafe; otherwise, print safe.\n\nSample Input 1\n\n4 5\n\nSample Output 1\n\nunsafe\n\nThere are four sheep and five wolves. The number of wolves is not less than that of sheep, so they will attack them.\n\nSample Input 2\n\n100 2\n\nSample Output 2\n\nsafe\n\nMany a sheep drive away two wolves.\n\nSample Input 3\n\n10 10\n\nSample Output 3\n\nunsafe", "sample_input": "4 5\n"}, "reference_outputs": ["unsafe\n"], "source_document_id": "p02699", "source_text": "Score : 100 points\n\nProblem Statement\n\nThere are S sheep and W wolves.\n\nIf the number of wolves is greater than or equal to that of sheep, the wolves will attack the sheep.\n\nIf the wolves will attack the sheep, print unsafe; otherwise, print safe.\n\nConstraints\n\n1 \\leq S \\leq 100\n\n1 \\leq W \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS W\n\nOutput\n\nIf the wolves will attack the sheep, print unsafe; otherwise, print safe.\n\nSample Input 1\n\n4 5\n\nSample Output 1\n\nunsafe\n\nThere are four sheep and five wolves. The number of wolves is not less than that of sheep, so they will attack them.\n\nSample Input 2\n\n100 2\n\nSample Output 2\n\nsafe\n\nMany a sheep drive away two wolves.\n\nSample Input 3\n\n10 10\n\nSample Output 3\n\nunsafe", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 10, "memory_kb": 3696}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s369942011", "group_id": "codeNet:p02701", "input_text": "let n = Scanf.sscanf (read_line ()) \"%d\" @@ fun n -> n\nlet s = Array.init n @@ fun _ -> read_line ()\n\nmodule SSet = Set.Make(struct type t = string let compare = compare end)\n\nlet () = Printf.printf \"%d\\n\"\n @@ SSet.cardinal\n @@ Array.fold_left (fun set s -> SSet.add s set ) SSet.empty s", "language": "OCaml", "metadata": {"date": 1594899864, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p02701.html", "problem_id": "p02701", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02701/input.txt", "sample_output_relpath": "derived/input_output/data/p02701/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02701/OCaml/s369942011.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s369942011", "user_id": "u811309788"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "let n = Scanf.sscanf (read_line ()) \"%d\" @@ fun n -> n\nlet s = Array.init n @@ fun _ -> read_line ()\n\nmodule SSet = Set.Make(struct type t = string let compare = compare end)\n\nlet () = Printf.printf \"%d\\n\"\n @@ SSet.cardinal\n @@ Array.fold_left (fun set s -> SSet.add s set ) SSet.empty s", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou drew lottery N times. In the i-th draw, you got an item of the kind represented by a string S_i.\n\nHow many kinds of items did you get?\n\nConstraints\n\n1 \\leq N \\leq 2\\times 10^5\n\nS_i consists of lowercase English letters and has a length between 1 and 10 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS_1\n:\nS_N\n\nOutput\n\nPrint the number of kinds of items you got.\n\nSample Input 1\n\n3\napple\norange\napple\n\nSample Output 1\n\n2\n\nYou got two kinds of items: apple and orange.\n\nSample Input 2\n\n5\ngrape\ngrape\ngrape\ngrape\ngrape\n\nSample Output 2\n\n1\n\nSample Input 3\n\n4\naaaa\na\naaa\naa\n\nSample Output 3\n\n4", "sample_input": "3\napple\norange\napple\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02701", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou drew lottery N times. In the i-th draw, you got an item of the kind represented by a string S_i.\n\nHow many kinds of items did you get?\n\nConstraints\n\n1 \\leq N \\leq 2\\times 10^5\n\nS_i consists of lowercase English letters and has a length between 1 and 10 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS_1\n:\nS_N\n\nOutput\n\nPrint the number of kinds of items you got.\n\nSample Input 1\n\n3\napple\norange\napple\n\nSample Output 1\n\n2\n\nYou got two kinds of items: apple and orange.\n\nSample Input 2\n\n5\ngrape\ngrape\ngrape\ngrape\ngrape\n\nSample Output 2\n\n1\n\nSample Input 3\n\n4\naaaa\na\naaa\naa\n\nSample Output 3\n\n4", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 364, "memory_kb": 30948}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s431041591", "group_id": "codeNet:p02701", "input_text": "module SS = Set.Make(String);;\nlet () =\n let n = read_int () in\n let s = Array.to_list (Array.init n @@ fun _ -> Scanf.scanf \"%s\\n\" @@ fun s -> s) in\n let ans = List.fold_right SS.add s (SS.empty) in\n print_int (SS.cardinal ans)", "language": "OCaml", "metadata": {"date": 1588709218, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p02701.html", "problem_id": "p02701", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02701/input.txt", "sample_output_relpath": "derived/input_output/data/p02701/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02701/OCaml/s431041591.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s431041591", "user_id": "u307426615"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "module SS = Set.Make(String);;\nlet () =\n let n = read_int () in\n let s = Array.to_list (Array.init n @@ fun _ -> Scanf.scanf \"%s\\n\" @@ fun s -> s) in\n let ans = List.fold_right SS.add s (SS.empty) in\n print_int (SS.cardinal ans)", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou drew lottery N times. In the i-th draw, you got an item of the kind represented by a string S_i.\n\nHow many kinds of items did you get?\n\nConstraints\n\n1 \\leq N \\leq 2\\times 10^5\n\nS_i consists of lowercase English letters and has a length between 1 and 10 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS_1\n:\nS_N\n\nOutput\n\nPrint the number of kinds of items you got.\n\nSample Input 1\n\n3\napple\norange\napple\n\nSample Output 1\n\n2\n\nYou got two kinds of items: apple and orange.\n\nSample Input 2\n\n5\ngrape\ngrape\ngrape\ngrape\ngrape\n\nSample Output 2\n\n1\n\nSample Input 3\n\n4\naaaa\na\naaa\naa\n\nSample Output 3\n\n4", "sample_input": "3\napple\norange\napple\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02701", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou drew lottery N times. In the i-th draw, you got an item of the kind represented by a string S_i.\n\nHow many kinds of items did you get?\n\nConstraints\n\n1 \\leq N \\leq 2\\times 10^5\n\nS_i consists of lowercase English letters and has a length between 1 and 10 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS_1\n:\nS_N\n\nOutput\n\nPrint the number of kinds of items you got.\n\nSample Input 1\n\n3\napple\norange\napple\n\nSample Output 1\n\n2\n\nYou got two kinds of items: apple and orange.\n\nSample Input 2\n\n5\ngrape\ngrape\ngrape\ngrape\ngrape\n\nSample Output 2\n\n1\n\nSample Input 3\n\n4\naaaa\na\naaa\naa\n\nSample Output 3\n\n4", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 469, "memory_kb": 44924}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s137218673", "group_id": "codeNet:p02706", "input_text": "Scanf.scanf \"%d %d\" (fun n m ->\n let a = Array.init m (fun _ -> Scanf.scanf \" %d\" (fun a -> a)) in\n let s = Array.fold_left (+) 0 a in\n Printf.printf \"%d\\n\" @@ if n < s then -1 else n - s\n)", "language": "OCaml", "metadata": {"date": 1587344805, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p02706.html", "problem_id": "p02706", "resource_group": "low_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/OCaml/s137218673.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s137218673", "user_id": "u342443598"}, "prompt_components": {"gold_output": "30\n", "input_to_evaluate": "Scanf.scanf \"%d %d\" (fun n m ->\n let a = Array.init m (fun _ -> Scanf.scanf \" %d\" (fun a -> a)) in\n let s = Array.fold_left (+) 0 a in\n Printf.printf \"%d\\n\" @@ if n < s then -1 else n - s\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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 8, "memory_kb": 5924}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s909894401", "group_id": "codeNet:p02706", "input_text": "open Batteries\nlet rec sum lst =\n match lst with\n | [] -> 0\n | first :: rest -> first + sum rest\n\nlet n, m = Scanf.sscanf (read_line()) \"%d %d\" (fun n m ->n,m\n)\nlet a = read_line () |> String.split_on_char ' ' |> List.map int_of_string\nlet _ = (if sum a > n then -1 else n - (sum a)) |> Printf.printf \"%d\\n\"", "language": "OCaml", "metadata": {"date": 1587344736, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p02706.html", "problem_id": "p02706", "resource_group": "low_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/OCaml/s909894401.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s909894401", "user_id": "u511870776"}, "prompt_components": {"gold_output": "30\n", "input_to_evaluate": "open Batteries\nlet rec sum lst =\n match lst with\n | [] -> 0\n | first :: rest -> first + sum rest\n\nlet n, m = Scanf.sscanf (read_line()) \"%d %d\" (fun n m ->n,m\n)\nlet a = read_line () |> String.split_on_char ' ' |> List.map int_of_string\nlet _ = (if sum a > n then -1 else n - (sum a)) |> Printf.printf \"%d\\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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 10, "memory_kb": 6292}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s753584165", "group_id": "codeNet:p02710", "input_text": "open Base\nopen Stdio\n\nlet read_line () =\n In_channel.(input_line_exn stdin)\n\nlet mapt2 ~f (a, b) = (f a, f b)\n\nlet array_replace arr i ~f = arr.(i) <- f (arr.(i))\n\nlet n = Int.of_string @@ read_line ()\n\nlet sums = Array.create ~len:(n+1) 0\nlet neg_res = Array.create ~len:(n+1) 0L\nlet g_hd = Array.create ~len:(n+1) 0\nlet g_nx = Array.create ~len:(2*n) 0\nlet g_to = Array.create ~len:(2*n) 0\nlet g_len = ref 0\nlet g_add u v =\n g_len := !g_len + 1;\n g_nx.(!g_len) <- g_hd.(u);\n g_to.(!g_len) <- v;\n g_hd.(u) <- !g_len\nlet g_adj_iter cur x0 f =\n let rec loop e acc = if e = 0 then acc else\n let ch = g_to.(e) in\n loop g_nx.(e) (f ch acc)\n in\n loop g_hd.(cur) x0\n\nlet colors = read_line () |> String.split ~on:' ' |> List.map ~f:Int.of_string\n |> List.cons 0 |> Array.of_list\n\nlet rec dfs ?(cur=1) ?(par=0) () =\n let memo = sums.(colors.(par)) in\n let tree_size = g_adj_iter cur 1 (fun ch acc ->\n acc + if ch = par then 0 else dfs ~cur:ch ~par:cur ())\n in\n\n array_replace sums colors.(cur) ((+) 1);\n let component_size = Int64.of_int @@ tree_size - (sums.(colors.(par)) - memo) in\n array_replace neg_res colors.(par) (fun x -> Int64.(x + component_size * (component_size + 1L) / 2L));\n sums.(colors.(par)) <- tree_size + memo;\n tree_size\n\nlet () =\n for i = 0 to n - 2 do\n let a, b = read_line () |> String.lsplit2_exn ~on:' ' |> mapt2 ~f:Int.of_string in\n g_add a b;\n g_add b a\n done\n\nlet () =\n ignore (dfs ());\n for i = 1 to n do\n let component_size = Int64.of_int @@ n - sums.(i) in\n let n64 = Int64.of_int n in\n let res = Int64.(n64 * (n64 + 1L) / 2L - component_size * (component_size + 1L) / 2L - neg_res.(i)) in\n printf \"%Ld\\n\" res\n done\n", "language": "OCaml", "metadata": {"date": 1596013770, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p02710.html", "problem_id": "p02710", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02710/input.txt", "sample_output_relpath": "derived/input_output/data/p02710/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02710/OCaml/s753584165.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s753584165", "user_id": "u869306730"}, "prompt_components": {"gold_output": "5\n4\n0\n", "input_to_evaluate": "open Base\nopen Stdio\n\nlet read_line () =\n In_channel.(input_line_exn stdin)\n\nlet mapt2 ~f (a, b) = (f a, f b)\n\nlet array_replace arr i ~f = arr.(i) <- f (arr.(i))\n\nlet n = Int.of_string @@ read_line ()\n\nlet sums = Array.create ~len:(n+1) 0\nlet neg_res = Array.create ~len:(n+1) 0L\nlet g_hd = Array.create ~len:(n+1) 0\nlet g_nx = Array.create ~len:(2*n) 0\nlet g_to = Array.create ~len:(2*n) 0\nlet g_len = ref 0\nlet g_add u v =\n g_len := !g_len + 1;\n g_nx.(!g_len) <- g_hd.(u);\n g_to.(!g_len) <- v;\n g_hd.(u) <- !g_len\nlet g_adj_iter cur x0 f =\n let rec loop e acc = if e = 0 then acc else\n let ch = g_to.(e) in\n loop g_nx.(e) (f ch acc)\n in\n loop g_hd.(cur) x0\n\nlet colors = read_line () |> String.split ~on:' ' |> List.map ~f:Int.of_string\n |> List.cons 0 |> Array.of_list\n\nlet rec dfs ?(cur=1) ?(par=0) () =\n let memo = sums.(colors.(par)) in\n let tree_size = g_adj_iter cur 1 (fun ch acc ->\n acc + if ch = par then 0 else dfs ~cur:ch ~par:cur ())\n in\n\n array_replace sums colors.(cur) ((+) 1);\n let component_size = Int64.of_int @@ tree_size - (sums.(colors.(par)) - memo) in\n array_replace neg_res colors.(par) (fun x -> Int64.(x + component_size * (component_size + 1L) / 2L));\n sums.(colors.(par)) <- tree_size + memo;\n tree_size\n\nlet () =\n for i = 0 to n - 2 do\n let a, b = read_line () |> String.lsplit2_exn ~on:' ' |> mapt2 ~f:Int.of_string in\n g_add a b;\n g_add b a\n done\n\nlet () =\n ignore (dfs ());\n for i = 1 to n do\n let component_size = Int64.of_int @@ n - sums.(i) in\n let n64 = Int64.of_int n in\n let res = Int64.(n64 * (n64 + 1L) / 2L - component_size * (component_size + 1L) / 2L - neg_res.(i)) in\n printf \"%Ld\\n\" res\n done\n", "problem_context": "Score : 600 points\n\nProblem Statement\n\nWe have a tree with N vertices numbered 1 to N. The i-th edge in this tree connects Vertex a_i and b_i.\nAdditionally, each vertex is painted in a color, and the color of Vertex i is c_i. Here, the color of each vertex is represented by an integer between 1 and N (inclusive). The same integer corresponds to the same color; different integers correspond to different colors.\n\nFor each k=1, 2, ..., N, solve the following problem:\n\nFind the number of simple paths that visit a vertex painted in the color k one or more times.\n\nNote: The simple paths from Vertex u to v and from v to u are not distinguished.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq c_i \\leq N\n\n1 \\leq a_i,b_i \\leq N\n\nThe given graph is a tree.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nc_1 c_2 ... c_N\na_1 b_1\n:\na_{N-1} b_{N-1}\n\nOutput\n\nPrint the answers for k = 1, 2, ..., N in order, each in its own line.\n\nSample Input 1\n\n3\n1 2 1\n1 2\n2 3\n\nSample Output 1\n\n5\n4\n0\n\nLet P_{i,j} denote the simple path connecting Vertex i and j.\n\nThere are 5 simple paths that visit a vertex painted in the color 1 one or more times:\n\nP_{1,1}\\,,\\,\nP_{1,2}\\,,\\,\nP_{1,3}\\,,\\,\nP_{2,3}\\,,\\,\nP_{3,3}\n\nThere are 4 simple paths that visit a vertex painted in the color 2 one or more times:\n\nP_{1,2}\\,,\\,\nP_{1,3}\\,,\\,\nP_{2,2}\\,,\\,\nP_{2,3}\n\nThere are no simple paths that visit a vertex painted in the color 3 one or more times.\n\nSample Input 2\n\n1\n1\n\nSample Output 2\n\n1\n\nSample Input 3\n\n2\n1 2\n1 2\n\nSample Output 3\n\n2\n2\n\nSample Input 4\n\n5\n1 2 3 4 5\n1 2\n2 3\n3 4\n3 5\n\nSample Output 4\n\n5\n8\n10\n5\n5\n\nSample Input 5\n\n8\n2 7 2 5 4 1 7 5\n3 1\n1 2\n2 7\n4 5\n5 6\n6 8\n7 8\n\nSample Output 5\n\n18\n15\n0\n14\n23\n0\n23\n0", "sample_input": "3\n1 2 1\n1 2\n2 3\n"}, "reference_outputs": ["5\n4\n0\n"], "source_document_id": "p02710", "source_text": "Score : 600 points\n\nProblem Statement\n\nWe have a tree with N vertices numbered 1 to N. The i-th edge in this tree connects Vertex a_i and b_i.\nAdditionally, each vertex is painted in a color, and the color of Vertex i is c_i. Here, the color of each vertex is represented by an integer between 1 and N (inclusive). The same integer corresponds to the same color; different integers correspond to different colors.\n\nFor each k=1, 2, ..., N, solve the following problem:\n\nFind the number of simple paths that visit a vertex painted in the color k one or more times.\n\nNote: The simple paths from Vertex u to v and from v to u are not distinguished.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq c_i \\leq N\n\n1 \\leq a_i,b_i \\leq N\n\nThe given graph is a tree.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nc_1 c_2 ... c_N\na_1 b_1\n:\na_{N-1} b_{N-1}\n\nOutput\n\nPrint the answers for k = 1, 2, ..., N in order, each in its own line.\n\nSample Input 1\n\n3\n1 2 1\n1 2\n2 3\n\nSample Output 1\n\n5\n4\n0\n\nLet P_{i,j} denote the simple path connecting Vertex i and j.\n\nThere are 5 simple paths that visit a vertex painted in the color 1 one or more times:\n\nP_{1,1}\\,,\\,\nP_{1,2}\\,,\\,\nP_{1,3}\\,,\\,\nP_{2,3}\\,,\\,\nP_{3,3}\n\nThere are 4 simple paths that visit a vertex painted in the color 2 one or more times:\n\nP_{1,2}\\,,\\,\nP_{1,3}\\,,\\,\nP_{2,2}\\,,\\,\nP_{2,3}\n\nThere are no simple paths that visit a vertex painted in the color 3 one or more times.\n\nSample Input 2\n\n1\n1\n\nSample Output 2\n\n1\n\nSample Input 3\n\n2\n1 2\n1 2\n\nSample Output 3\n\n2\n2\n\nSample Input 4\n\n5\n1 2 3 4 5\n1 2\n2 3\n3 4\n3 5\n\nSample Output 4\n\n5\n8\n10\n5\n5\n\nSample Input 5\n\n8\n2 7 2 5 4 1 7 5\n3 1\n1 2\n2 7\n4 5\n5 6\n6 8\n7 8\n\nSample Output 5\n\n18\n15\n0\n14\n23\n0\n23\n0", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1777, "cpu_time_ms": 298, "memory_kb": 63864}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s995243604", "group_id": "codeNet:p02710", "input_text": "open Base\nopen Stdio\n\n(* Core.read_line is deprecated *)\nlet read_line () =\n (* Out_channel.(flush stdout); *)\n In_channel.(input_line_exn stdin)\n\nlet mapt2 ~f (a, b) = (f a, f b)\n\nlet et_size = ref 0\n\nlet n = Int.of_string @@ read_line ()\n\nlet sums = Array.create ~len:(n+1) 0\nlet neg_res = Array.create ~len:(n+1) 0L\nlet g_hd = Array.create ~len:(n+1) 0\nlet g_nx = Array.create ~len:(2*n) 0\nlet g_to = Array.create ~len:(2*n) 0\nlet g_len = ref 0\nlet g_add u v =\n g_len := !g_len + 1;\n g_nx.(!g_len) <- g_hd.(u);\n g_to.(!g_len) <- v;\n g_hd.(u) <- !g_len\n\nlet colors = read_line () |> String.split ~on:' ' |> List.map ~f:Int.of_string |> (List.cons 0) |> Array.of_list\n\nlet rec dfs ?(cur=1) ?(par=0) () =\n let et_in = !et_size in\n let memo = sums.(colors.(par)) in\n et_size := !et_size + 1;\n let rec loop e = if e = 0 then () else\n let ch = g_to.(e) in\n ((if ch = par then () else dfs ~cur:ch ~par:cur ()); loop g_nx.(e)) in\n loop (g_hd.(cur));\n let et_out = !et_size in\n et_size := !et_size + 1;\n\n sums.(colors.(cur)) <- sums.(colors.(cur)) + 1;\n let tree_size = (et_out - et_in + 1) / 2 in\n let component_size = Int64.of_int @@ tree_size - (sums.(colors.(par)) - memo) in\n neg_res.(colors.(par)) <- Int64.(neg_res.(colors.(par)) + component_size * (component_size + 1L) / 2L);\n sums.(colors.(par)) <- tree_size + memo\n\nlet _ =\n for i = 0 to n - 2 do\n let a, b = read_line () |> String.lsplit2_exn ~on:' ' |> mapt2 ~f:Int.of_string in\n g_add a b;\n g_add b a\n done\n\nlet _ =\n dfs ();\n let tree_size = !et_size / 2 in\n for i = 1 to n do\n let component_size = Int64.of_int @@ tree_size - sums.(i) in\n let n64 = Int64.of_int n in\n let res = Int64.(n64 * (n64 + 1L) / 2L - component_size * (component_size + 1L) / 2L - neg_res.(i)) in\n printf \"%Ld\\n\" res\n done\n", "language": "OCaml", "metadata": {"date": 1596007690, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p02710.html", "problem_id": "p02710", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02710/input.txt", "sample_output_relpath": "derived/input_output/data/p02710/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02710/OCaml/s995243604.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s995243604", "user_id": "u869306730"}, "prompt_components": {"gold_output": "5\n4\n0\n", "input_to_evaluate": "open Base\nopen Stdio\n\n(* Core.read_line is deprecated *)\nlet read_line () =\n (* Out_channel.(flush stdout); *)\n In_channel.(input_line_exn stdin)\n\nlet mapt2 ~f (a, b) = (f a, f b)\n\nlet et_size = ref 0\n\nlet n = Int.of_string @@ read_line ()\n\nlet sums = Array.create ~len:(n+1) 0\nlet neg_res = Array.create ~len:(n+1) 0L\nlet g_hd = Array.create ~len:(n+1) 0\nlet g_nx = Array.create ~len:(2*n) 0\nlet g_to = Array.create ~len:(2*n) 0\nlet g_len = ref 0\nlet g_add u v =\n g_len := !g_len + 1;\n g_nx.(!g_len) <- g_hd.(u);\n g_to.(!g_len) <- v;\n g_hd.(u) <- !g_len\n\nlet colors = read_line () |> String.split ~on:' ' |> List.map ~f:Int.of_string |> (List.cons 0) |> Array.of_list\n\nlet rec dfs ?(cur=1) ?(par=0) () =\n let et_in = !et_size in\n let memo = sums.(colors.(par)) in\n et_size := !et_size + 1;\n let rec loop e = if e = 0 then () else\n let ch = g_to.(e) in\n ((if ch = par then () else dfs ~cur:ch ~par:cur ()); loop g_nx.(e)) in\n loop (g_hd.(cur));\n let et_out = !et_size in\n et_size := !et_size + 1;\n\n sums.(colors.(cur)) <- sums.(colors.(cur)) + 1;\n let tree_size = (et_out - et_in + 1) / 2 in\n let component_size = Int64.of_int @@ tree_size - (sums.(colors.(par)) - memo) in\n neg_res.(colors.(par)) <- Int64.(neg_res.(colors.(par)) + component_size * (component_size + 1L) / 2L);\n sums.(colors.(par)) <- tree_size + memo\n\nlet _ =\n for i = 0 to n - 2 do\n let a, b = read_line () |> String.lsplit2_exn ~on:' ' |> mapt2 ~f:Int.of_string in\n g_add a b;\n g_add b a\n done\n\nlet _ =\n dfs ();\n let tree_size = !et_size / 2 in\n for i = 1 to n do\n let component_size = Int64.of_int @@ tree_size - sums.(i) in\n let n64 = Int64.of_int n in\n let res = Int64.(n64 * (n64 + 1L) / 2L - component_size * (component_size + 1L) / 2L - neg_res.(i)) in\n printf \"%Ld\\n\" res\n done\n", "problem_context": "Score : 600 points\n\nProblem Statement\n\nWe have a tree with N vertices numbered 1 to N. The i-th edge in this tree connects Vertex a_i and b_i.\nAdditionally, each vertex is painted in a color, and the color of Vertex i is c_i. Here, the color of each vertex is represented by an integer between 1 and N (inclusive). The same integer corresponds to the same color; different integers correspond to different colors.\n\nFor each k=1, 2, ..., N, solve the following problem:\n\nFind the number of simple paths that visit a vertex painted in the color k one or more times.\n\nNote: The simple paths from Vertex u to v and from v to u are not distinguished.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq c_i \\leq N\n\n1 \\leq a_i,b_i \\leq N\n\nThe given graph is a tree.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nc_1 c_2 ... c_N\na_1 b_1\n:\na_{N-1} b_{N-1}\n\nOutput\n\nPrint the answers for k = 1, 2, ..., N in order, each in its own line.\n\nSample Input 1\n\n3\n1 2 1\n1 2\n2 3\n\nSample Output 1\n\n5\n4\n0\n\nLet P_{i,j} denote the simple path connecting Vertex i and j.\n\nThere are 5 simple paths that visit a vertex painted in the color 1 one or more times:\n\nP_{1,1}\\,,\\,\nP_{1,2}\\,,\\,\nP_{1,3}\\,,\\,\nP_{2,3}\\,,\\,\nP_{3,3}\n\nThere are 4 simple paths that visit a vertex painted in the color 2 one or more times:\n\nP_{1,2}\\,,\\,\nP_{1,3}\\,,\\,\nP_{2,2}\\,,\\,\nP_{2,3}\n\nThere are no simple paths that visit a vertex painted in the color 3 one or more times.\n\nSample Input 2\n\n1\n1\n\nSample Output 2\n\n1\n\nSample Input 3\n\n2\n1 2\n1 2\n\nSample Output 3\n\n2\n2\n\nSample Input 4\n\n5\n1 2 3 4 5\n1 2\n2 3\n3 4\n3 5\n\nSample Output 4\n\n5\n8\n10\n5\n5\n\nSample Input 5\n\n8\n2 7 2 5 4 1 7 5\n3 1\n1 2\n2 7\n4 5\n5 6\n6 8\n7 8\n\nSample Output 5\n\n18\n15\n0\n14\n23\n0\n23\n0", "sample_input": "3\n1 2 1\n1 2\n2 3\n"}, "reference_outputs": ["5\n4\n0\n"], "source_document_id": "p02710", "source_text": "Score : 600 points\n\nProblem Statement\n\nWe have a tree with N vertices numbered 1 to N. The i-th edge in this tree connects Vertex a_i and b_i.\nAdditionally, each vertex is painted in a color, and the color of Vertex i is c_i. Here, the color of each vertex is represented by an integer between 1 and N (inclusive). The same integer corresponds to the same color; different integers correspond to different colors.\n\nFor each k=1, 2, ..., N, solve the following problem:\n\nFind the number of simple paths that visit a vertex painted in the color k one or more times.\n\nNote: The simple paths from Vertex u to v and from v to u are not distinguished.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq c_i \\leq N\n\n1 \\leq a_i,b_i \\leq N\n\nThe given graph is a tree.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nc_1 c_2 ... c_N\na_1 b_1\n:\na_{N-1} b_{N-1}\n\nOutput\n\nPrint the answers for k = 1, 2, ..., N in order, each in its own line.\n\nSample Input 1\n\n3\n1 2 1\n1 2\n2 3\n\nSample Output 1\n\n5\n4\n0\n\nLet P_{i,j} denote the simple path connecting Vertex i and j.\n\nThere are 5 simple paths that visit a vertex painted in the color 1 one or more times:\n\nP_{1,1}\\,,\\,\nP_{1,2}\\,,\\,\nP_{1,3}\\,,\\,\nP_{2,3}\\,,\\,\nP_{3,3}\n\nThere are 4 simple paths that visit a vertex painted in the color 2 one or more times:\n\nP_{1,2}\\,,\\,\nP_{1,3}\\,,\\,\nP_{2,2}\\,,\\,\nP_{2,3}\n\nThere are no simple paths that visit a vertex painted in the color 3 one or more times.\n\nSample Input 2\n\n1\n1\n\nSample Output 2\n\n1\n\nSample Input 3\n\n2\n1 2\n1 2\n\nSample Output 3\n\n2\n2\n\nSample Input 4\n\n5\n1 2 3 4 5\n1 2\n2 3\n3 4\n3 5\n\nSample Output 4\n\n5\n8\n10\n5\n5\n\nSample Input 5\n\n8\n2 7 2 5 4 1 7 5\n3 1\n1 2\n2 7\n4 5\n5 6\n6 8\n7 8\n\nSample Output 5\n\n18\n15\n0\n14\n23\n0\n23\n0", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 235, "memory_kb": 56616}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s855026718", "group_id": "codeNet:p02719", "input_text": "let n, k = Scanf.scanf \"%d %d\\n\" @@ fun a b -> a, b\nlet () = Printf.printf \"%d\\n\" (min (n mod k) (k - n mod k))", "language": "OCaml", "metadata": {"date": 1588800232, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02719.html", "problem_id": "p02719", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02719/input.txt", "sample_output_relpath": "derived/input_output/data/p02719/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02719/OCaml/s855026718.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s855026718", "user_id": "u307426615"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "let n, k = Scanf.scanf \"%d %d\\n\" @@ fun a b -> a, b\nlet () = Printf.printf \"%d\\n\" (min (n mod k) (k - n mod k))", "problem_context": "Score : 300 points\n\nProblem Statement\n\nGiven any integer x, Aoki can do the operation below.\n\nOperation: Replace x with the absolute difference of x and K.\n\nYou are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.\n\nConstraints\n\n0 ≤ N ≤ 10^{18}\n\n1 ≤ K ≤ 10^{18}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\n\nOutput\n\nPrint the minimum possible value taken by N after Aoki does the operation zero or more times.\n\nSample Input 1\n\n7 4\n\nSample Output 1\n\n1\n\nInitially, N=7.\n\nAfter one operation, N becomes |7-4| = 3.\n\nAfter two operations, N becomes |3-4| = 1, which is the minimum value taken by N.\n\nSample Input 2\n\n2 6\n\nSample Output 2\n\n2\n\nN=2 after zero operations is the minimum.\n\nSample Input 3\n\n1000000000000000000 1\n\nSample Output 3\n\n0", "sample_input": "7 4\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02719", "source_text": "Score : 300 points\n\nProblem Statement\n\nGiven any integer x, Aoki can do the operation below.\n\nOperation: Replace x with the absolute difference of x and K.\n\nYou are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.\n\nConstraints\n\n0 ≤ N ≤ 10^{18}\n\n1 ≤ K ≤ 10^{18}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\n\nOutput\n\nPrint the minimum possible value taken by N after Aoki does the operation zero or more times.\n\nSample Input 1\n\n7 4\n\nSample Output 1\n\n1\n\nInitially, N=7.\n\nAfter one operation, N becomes |7-4| = 3.\n\nAfter two operations, N becomes |3-4| = 1, which is the minimum value taken by N.\n\nSample Input 2\n\n2 6\n\nSample Output 2\n\n2\n\nN=2 after zero operations is the minimum.\n\nSample Input 3\n\n1000000000000000000 1\n\nSample Output 3\n\n0", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s917993769", "group_id": "codeNet:p02720", "input_text": "let solve k =\n let q = Queue.create () in\n let rec f i =\n if i < 10 then (\n Queue.push i q;\n f (i + 1)\n )\n in\n f 1;\n let rec f i =\n if i <= k then (\n let x = Queue.pop q in\n let m = x mod 10\n and j = ref i in\n let g y =\n if !j = k then print_int y\n else Queue.push y q;\n j := !j + 1\n in\n if m <> 0 then g (10 * x + m - 1);\n g (10 * x + m);\n if m <> 9 then g (10 * x + m + 1);\n f !j\n )\n in\n f 10\n\nlet ans k =\n if k < 10 then print_int k\n else solve k\n\nlet () = ans (read_int ())\n", "language": "OCaml", "metadata": {"date": 1586059791, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02720.html", "problem_id": "p02720", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02720/input.txt", "sample_output_relpath": "derived/input_output/data/p02720/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02720/OCaml/s917993769.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s917993769", "user_id": "u752907799"}, "prompt_components": {"gold_output": "23\n", "input_to_evaluate": "let solve k =\n let q = Queue.create () in\n let rec f i =\n if i < 10 then (\n Queue.push i q;\n f (i + 1)\n )\n in\n f 1;\n let rec f i =\n if i <= k then (\n let x = Queue.pop q in\n let m = x mod 10\n and j = ref i in\n let g y =\n if !j = k then print_int y\n else Queue.push y q;\n j := !j + 1\n in\n if m <> 0 then g (10 * x + m - 1);\n g (10 * x + m);\n if m <> 9 then g (10 * x + m + 1);\n f !j\n )\n in\n f 10\n\nlet ans k =\n if k < 10 then print_int k\n else solve k\n\nlet () = ans (read_int ())\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nA positive integer X is said to be a lunlun number if and only if the following condition is satisfied:\n\nIn the base ten representation of X (without leading zeros), for every pair of two adjacent digits, the absolute difference of those digits is at most 1.\n\nFor example, 1234, 1, and 334 are lunlun numbers, while none of 31415, 119, or 13579 is.\n\nYou are given a positive integer K. Find the K-th smallest lunlun number.\n\nConstraints\n\n1 \\leq K \\leq 10^5\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n15\n\nSample Output 1\n\n23\n\nWe will list the 15 smallest lunlun numbers in ascending order:\n\n1,\n2,\n3,\n4,\n5,\n6,\n7,\n8,\n9,\n10,\n11,\n12,\n21,\n22,\n23.\n\nThus, the answer is 23.\n\nSample Input 2\n\n1\n\nSample Output 2\n\n1\n\nSample Input 3\n\n13\n\nSample Output 3\n\n21\n\nSample Input 4\n\n100000\n\nSample Output 4\n\n3234566667\n\nNote that the answer may not fit into the 32-bit signed integer type.", "sample_input": "15\n"}, "reference_outputs": ["23\n"], "source_document_id": "p02720", "source_text": "Score : 400 points\n\nProblem Statement\n\nA positive integer X is said to be a lunlun number if and only if the following condition is satisfied:\n\nIn the base ten representation of X (without leading zeros), for every pair of two adjacent digits, the absolute difference of those digits is at most 1.\n\nFor example, 1234, 1, and 334 are lunlun numbers, while none of 31415, 119, or 13579 is.\n\nYou are given a positive integer K. Find the K-th smallest lunlun number.\n\nConstraints\n\n1 \\leq K \\leq 10^5\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n15\n\nSample Output 1\n\n23\n\nWe will list the 15 smallest lunlun numbers in ascending order:\n\n1,\n2,\n3,\n4,\n5,\n6,\n7,\n8,\n9,\n10,\n11,\n12,\n21,\n22,\n23.\n\nThus, the answer is 23.\n\nSample Input 2\n\n1\n\nSample Output 2\n\n1\n\nSample Input 3\n\n13\n\nSample Output 3\n\n21\n\nSample Input 4\n\n100000\n\nSample Output 4\n\n3234566667\n\nNote that the answer may not fit into the 32-bit signed integer type.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 575, "cpu_time_ms": 7, "memory_kb": 5760}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s254958829", "group_id": "codeNet:p02722", "input_text": "module S = Set.Make (struct type t = int let compare = compare end) ;;\n\nScanf.scanf \"%d\" (fun nn ->\n let divisors a =\n let rec loop i acc =\n if i * i > a then acc else\n let acc = if a mod i = 0 then S.add (a / i) (S.add i acc) else acc in\n loop (i + 1) acc\n in\n loop 2 (S.singleton a)\n in\n let rec loop n k =\n if n = 1 then true else\n if n < k then false else\n if n mod k = 0 then loop (n / k) k\n else loop (n mod k) k\n in\n let rec loop2 acc = function\n | [] -> acc\n | hd :: tl ->\n let acc = if loop nn hd then acc + 1 else acc in\n loop2 acc tl\n in\n if nn = 2 then Printf.printf \"%d\\n\" 1 else\n let set = divisors (nn - 1) in\n let set = S.union (divisors nn) set in\n loop2 0 (S.elements set) |> Printf.printf \"%d\\n\"\n)", "language": "OCaml", "metadata": {"date": 1586054118, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02722.html", "problem_id": "p02722", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02722/input.txt", "sample_output_relpath": "derived/input_output/data/p02722/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02722/OCaml/s254958829.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s254958829", "user_id": "u342443598"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "module S = Set.Make (struct type t = int let compare = compare end) ;;\n\nScanf.scanf \"%d\" (fun nn ->\n let divisors a =\n let rec loop i acc =\n if i * i > a then acc else\n let acc = if a mod i = 0 then S.add (a / i) (S.add i acc) else acc in\n loop (i + 1) acc\n in\n loop 2 (S.singleton a)\n in\n let rec loop n k =\n if n = 1 then true else\n if n < k then false else\n if n mod k = 0 then loop (n / k) k\n else loop (n mod k) k\n in\n let rec loop2 acc = function\n | [] -> acc\n | hd :: tl ->\n let acc = if loop nn hd then acc + 1 else acc in\n loop2 acc tl\n in\n if nn = 2 then Printf.printf \"%d\\n\" 1 else\n let set = divisors (nn - 1) in\n let set = S.union (divisors nn) set in\n loop2 0 (S.elements set) |> Printf.printf \"%d\\n\"\n)", "problem_context": "Score : 600 points\n\nProblem Statement\n\nGiven is a positive integer N.\n\nWe will choose an integer K between 2 and N (inclusive), then we will repeat the operation below until N becomes less than K.\n\nOperation: if K divides N, replace N with N/K; otherwise, replace N with N-K.\n\nIn how many choices of K will N become 1 in the end?\n\nConstraints\n\n2 \\leq N \\leq 10^{12}\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the number of choices of K in which N becomes 1 in the end.\n\nSample Input 1\n\n6\n\nSample Output 1\n\n3\n\nThere are three choices of K in which N becomes 1 in the end: 2, 5, and 6.\n\nIn each of these choices, N will change as follows:\n\nWhen K=2: 6 \\to 3 \\to 1\n\nWhen K=5: 6 \\to 1\n\nWhen K=6: 6 \\to 1\n\nSample Input 2\n\n3141\n\nSample Output 2\n\n13\n\nSample Input 3\n\n314159265358\n\nSample Output 3\n\n9", "sample_input": "6\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02722", "source_text": "Score : 600 points\n\nProblem Statement\n\nGiven is a positive integer N.\n\nWe will choose an integer K between 2 and N (inclusive), then we will repeat the operation below until N becomes less than K.\n\nOperation: if K divides N, replace N with N/K; otherwise, replace N with N-K.\n\nIn how many choices of K will N become 1 in the end?\n\nConstraints\n\n2 \\leq N \\leq 10^{12}\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the number of choices of K in which N becomes 1 in the end.\n\nSample Input 1\n\n6\n\nSample Output 1\n\n3\n\nThere are three choices of K in which N becomes 1 in the end: 2, 5, and 6.\n\nIn each of these choices, N will change as follows:\n\nWhen K=2: 6 \\to 3 \\to 1\n\nWhen K=5: 6 \\to 1\n\nWhen K=6: 6 \\to 1\n\nSample Input 2\n\n3141\n\nSample Output 2\n\n13\n\nSample Input 3\n\n314159265358\n\nSample Output 3\n\n9", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 28, "memory_kb": 2816}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s423457183", "group_id": "codeNet:p02723", "input_text": "let s = read_line () in\nprint_endline @@ if s.[2] = s.[3] && s.[4] = s.[5] then \"Yes\" else \"No\"", "language": "OCaml", "metadata": {"date": 1585443658, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02723.html", "problem_id": "p02723", "resource_group": "low_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/OCaml/s423457183.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s423457183", "user_id": "u342443598"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "let s = read_line () in\nprint_endline @@ if s.[2] = s.[3] && s.[4] = s.[5] then \"Yes\" else \"No\"", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 2432}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s845666872", "group_id": "codeNet:p02724", "input_text": "open Batteries\nmodule EnumL = Enum.Labels\nmodule ListL = List.Labels\nmodule ArrayL = Array.Labels\n\nlet dbg0 x = Printf.eprintf \"[debug]%s\\n\" @@ dump x\nlet dbg1 x = dbg0 x; x\n\nlet id = identity\n\nlet (++) n m = List.range n `To m\nlet (++-) n m = if n >= m then List.range n `Downto m else []\nlet (++^) n m = if n < m then List.range n `To (pred m) else []\n\nmodule ModOp = struct\n let prime = 1_000_000_007\n let (-) a b = (a + prime - b) mod prime\n let (+) a b = (a + b) mod prime\n let ( * ) a b = (a * b) mod prime\n\n let rec pow x n =\n if n = 0 then 1\n else if n mod 2 = 0 then pow (x*x) (n/2)\n else x * pow (x*x) (n/2)\nend\n\nlet scan fmt = Scanf.sscanf (read_line ()) fmt\n\nlet scan_lines n fmt f =\n if n = 0 then []\n else List.map (fun _ -> scan fmt f) (1 ++ n)\n\nlet scan_list ?sep cnv =\n let line = read_line () in\n (match sep with\n | None -> List.map String.of_char @@ String.to_list line\n | Some sep -> String.split_on_char sep line)\n |> List.map cnv\n\nlet scan_array ?sep cnv = Array.of_list @@ scan_list ?sep cnv\n\nlet scan_matrix n m e ?sep conv =\n let arr = Array.make_matrix n m e in\n ListL.iter (0 ++^ n)\n ~f:(fun i -> arr.(i) <- Array.of_list @@ scan_list ?sep conv);\n arr\n\nlet atoi c = Char.code c - Char.code '0'\n\nlet rec powerset = function\n | [] -> [[]]\n | hd::tl ->\n let pws = powerset tl in\n pws @ ListL.map pws ~f:(fun pw -> hd::pw)\n\nlet permutations l =\n let rec interleave x = function\n | [] -> [[x]]\n | (hd::tl) as l ->\n (x::l) :: (interleave x tl |> ListL.map ~f:(fun l -> hd::l)) in\n let rec aux = function\n | [] -> [[]]\n | a::rest ->\n aux rest |> ListL.map ~f:(interleave a) |> List.concat in\n aux l\n\nlet intersection l =\n EnumL.filter ~f:(fun x -> EnumL.exists ~f:((=) x) @@ Enum.clone l)\n\nlet zip l m =\n let n = min (List.length l) (List.length m) in\n List.combine (List.take n l) (List.take n m)\n\nlet lower_bound n f =\n let rec aux l u =\n if u - l > 1 then\n let m = (l + u) / 2 in\n if f m then aux l m\n else aux m u\n else u in aux (-1) n\n\nlet between n x m = n <= x && x < m\n\nlet x = scan \"%d\" id\n\nlet () =\n ListL.fold_left [500;5] ~init:(0,x) ~f:(fun (n,x) i ->\n (n+((x/i) * if i = 500 then 1000 else 5), x mod i))\n |> Tuple2.first\n |> Printf.printf \"%d\\n\"\n", "language": "OCaml", "metadata": {"date": 1592704171, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p02724.html", "problem_id": "p02724", "resource_group": "low_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/OCaml/s845666872.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s845666872", "user_id": "u802614675"}, "prompt_components": {"gold_output": "2020\n", "input_to_evaluate": "open Batteries\nmodule EnumL = Enum.Labels\nmodule ListL = List.Labels\nmodule ArrayL = Array.Labels\n\nlet dbg0 x = Printf.eprintf \"[debug]%s\\n\" @@ dump x\nlet dbg1 x = dbg0 x; x\n\nlet id = identity\n\nlet (++) n m = List.range n `To m\nlet (++-) n m = if n >= m then List.range n `Downto m else []\nlet (++^) n m = if n < m then List.range n `To (pred m) else []\n\nmodule ModOp = struct\n let prime = 1_000_000_007\n let (-) a b = (a + prime - b) mod prime\n let (+) a b = (a + b) mod prime\n let ( * ) a b = (a * b) mod prime\n\n let rec pow x n =\n if n = 0 then 1\n else if n mod 2 = 0 then pow (x*x) (n/2)\n else x * pow (x*x) (n/2)\nend\n\nlet scan fmt = Scanf.sscanf (read_line ()) fmt\n\nlet scan_lines n fmt f =\n if n = 0 then []\n else List.map (fun _ -> scan fmt f) (1 ++ n)\n\nlet scan_list ?sep cnv =\n let line = read_line () in\n (match sep with\n | None -> List.map String.of_char @@ String.to_list line\n | Some sep -> String.split_on_char sep line)\n |> List.map cnv\n\nlet scan_array ?sep cnv = Array.of_list @@ scan_list ?sep cnv\n\nlet scan_matrix n m e ?sep conv =\n let arr = Array.make_matrix n m e in\n ListL.iter (0 ++^ n)\n ~f:(fun i -> arr.(i) <- Array.of_list @@ scan_list ?sep conv);\n arr\n\nlet atoi c = Char.code c - Char.code '0'\n\nlet rec powerset = function\n | [] -> [[]]\n | hd::tl ->\n let pws = powerset tl in\n pws @ ListL.map pws ~f:(fun pw -> hd::pw)\n\nlet permutations l =\n let rec interleave x = function\n | [] -> [[x]]\n | (hd::tl) as l ->\n (x::l) :: (interleave x tl |> ListL.map ~f:(fun l -> hd::l)) in\n let rec aux = function\n | [] -> [[]]\n | a::rest ->\n aux rest |> ListL.map ~f:(interleave a) |> List.concat in\n aux l\n\nlet intersection l =\n EnumL.filter ~f:(fun x -> EnumL.exists ~f:((=) x) @@ Enum.clone l)\n\nlet zip l m =\n let n = min (List.length l) (List.length m) in\n List.combine (List.take n l) (List.take n m)\n\nlet lower_bound n f =\n let rec aux l u =\n if u - l > 1 then\n let m = (l + u) / 2 in\n if f m then aux l m\n else aux m u\n else u in aux (-1) n\n\nlet between n x m = n <= x && x < m\n\nlet x = scan \"%d\" id\n\nlet () =\n ListL.fold_left [500;5] ~init:(0,x) ~f:(fun (n,x) i ->\n (n+((x/i) * if i = 500 then 1000 else 5), x mod i))\n |> Tuple2.first\n |> Printf.printf \"%d\\n\"\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nTakahashi loves gold coins. He gains 1000 happiness points for each 500-yen coin he has and gains 5 happiness points for each 5-yen coin he has. (Yen is the currency of Japan.)\n\nTakahashi has X yen. If he exchanges his money so that he will gain the most happiness points, how many happiness points will he earn?\n\n(We assume that there are six kinds of coins available: 500-yen, 100-yen, 50-yen, 10-yen, 5-yen, and 1-yen coins.)\n\nConstraints\n\n0 \\leq X \\leq 10^9\n\nX is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX\n\nOutput\n\nPrint the maximum number of happiness points that can be earned.\n\nSample Input 1\n\n1024\n\nSample Output 1\n\n2020\n\nBy exchanging his money so that he gets two 500-yen coins and four 5-yen coins, he gains 2020 happiness points, which is the maximum number of happiness points that can be earned.\n\nSample Input 2\n\n0\n\nSample Output 2\n\n0\n\nHe is penniless - or yenless.\n\nSample Input 3\n\n1000000000\n\nSample Output 3\n\n2000000000\n\nHe is a billionaire - in yen.", "sample_input": "1024\n"}, "reference_outputs": ["2020\n"], "source_document_id": "p02724", "source_text": "Score : 200 points\n\nProblem Statement\n\nTakahashi loves gold coins. He gains 1000 happiness points for each 500-yen coin he has and gains 5 happiness points for each 5-yen coin he has. (Yen is the currency of Japan.)\n\nTakahashi has X yen. If he exchanges his money so that he will gain the most happiness points, how many happiness points will he earn?\n\n(We assume that there are six kinds of coins available: 500-yen, 100-yen, 50-yen, 10-yen, 5-yen, and 1-yen coins.)\n\nConstraints\n\n0 \\leq X \\leq 10^9\n\nX is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX\n\nOutput\n\nPrint the maximum number of happiness points that can be earned.\n\nSample Input 1\n\n1024\n\nSample Output 1\n\n2020\n\nBy exchanging his money so that he gets two 500-yen coins and four 5-yen coins, he gains 2020 happiness points, which is the maximum number of happiness points that can be earned.\n\nSample Input 2\n\n0\n\nSample Output 2\n\n0\n\nHe is penniless - or yenless.\n\nSample Input 3\n\n1000000000\n\nSample Output 3\n\n2000000000\n\nHe is a billionaire - in yen.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2276, "cpu_time_ms": 12, "memory_kb": 5372}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s907264009", "group_id": "codeNet:p02725", "input_text": "open Batteries\nmodule EnumL = Enum.Labels\nmodule ListL = List.Labels\nmodule ArrayL = Array.Labels\n\nlet dbg0 x = Printf.eprintf \"[debug]%s\\n\" @@ dump x\nlet dbg1 x = dbg0 x; x\n\nlet id = identity\n\nlet (++) n m = List.range n `To m\nlet (++-) n m = if n >= m then List.range n `Downto m else []\nlet (++^) n m = if n < m then List.range n `To (pred m) else []\n\nmodule ModOp = struct\n let prime = 1_000_000_007\n let (-) a b = (a + prime - b) mod prime\n let (+) a b = (a + b) mod prime\n let ( * ) a b = (a * b) mod prime\n\n let rec pow x n =\n if n = 0 then 1\n else if n mod 2 = 0 then pow (x*x) (n/2)\n else x * pow (x*x) (n/2)\nend\n\nlet scan fmt = Scanf.sscanf (read_line ()) fmt\n\nlet scan_lines n fmt f =\n if n = 0 then []\n else List.map (fun _ -> scan fmt f) (1 ++ n)\n\nlet scan_list ?sep cnv =\n let line = read_line () in\n (match sep with\n | None -> List.map String.of_char @@ String.to_list line\n | Some sep -> String.split_on_char sep line)\n |> List.map cnv\n\nlet scan_array ?sep cnv = Array.of_list @@ scan_list ?sep cnv\n\nlet scan_matrix n m e ?sep conv =\n let arr = Array.make_matrix n m e in\n ListL.iter (0 ++^ n)\n ~f:(fun i -> arr.(i) <- Array.of_list @@ scan_list ?sep conv);\n arr\n\nlet atoi c = Char.code c - Char.code '0'\n\nlet rec powerset = function\n | [] -> [[]]\n | hd::tl ->\n let pws = powerset tl in\n pws @ ListL.map pws ~f:(fun pw -> hd::pw)\n\nlet permutations l =\n let rec interleave x = function\n | [] -> [[x]]\n | (hd::tl) as l ->\n (x::l) :: (interleave x tl |> ListL.map ~f:(fun l -> hd::l)) in\n let rec aux = function\n | [] -> [[]]\n | a::rest ->\n aux rest |> ListL.map ~f:(interleave a) |> List.concat in\n aux l\n\nlet intersection l =\n EnumL.filter ~f:(fun x -> EnumL.exists ~f:((=) x) @@ Enum.clone l)\n\nlet zip l m =\n let n = min (List.length l) (List.length m) in\n List.combine (List.take n l) (List.take n m)\n\nlet lower_bound n f =\n let rec aux l u =\n if u - l > 1 then\n let m = (l + u) / 2 in\n if f m then aux l m\n else aux m u\n else u in aux (-1) n\n\nlet between n x m = n <= x && x < m\n\nlet (k,n) = scan \"%d %d\" Tuple2.make\nlet ls = scan_list ~sep:' ' Int.of_string\n\nlet () =\n let ms = ls@[k+List.first ls] in\n ListL.map (zip ms (List.drop 1 ms)) ~f:(fun (a, b) -> b - a)\n |> List.max\n |> ((-) k)\n |> Printf.printf \"%d\\n\"\n", "language": "OCaml", "metadata": {"date": 1592704492, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p02725.html", "problem_id": "p02725", "resource_group": "low_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/OCaml/s907264009.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s907264009", "user_id": "u802614675"}, "prompt_components": {"gold_output": "10\n", "input_to_evaluate": "open Batteries\nmodule EnumL = Enum.Labels\nmodule ListL = List.Labels\nmodule ArrayL = Array.Labels\n\nlet dbg0 x = Printf.eprintf \"[debug]%s\\n\" @@ dump x\nlet dbg1 x = dbg0 x; x\n\nlet id = identity\n\nlet (++) n m = List.range n `To m\nlet (++-) n m = if n >= m then List.range n `Downto m else []\nlet (++^) n m = if n < m then List.range n `To (pred m) else []\n\nmodule ModOp = struct\n let prime = 1_000_000_007\n let (-) a b = (a + prime - b) mod prime\n let (+) a b = (a + b) mod prime\n let ( * ) a b = (a * b) mod prime\n\n let rec pow x n =\n if n = 0 then 1\n else if n mod 2 = 0 then pow (x*x) (n/2)\n else x * pow (x*x) (n/2)\nend\n\nlet scan fmt = Scanf.sscanf (read_line ()) fmt\n\nlet scan_lines n fmt f =\n if n = 0 then []\n else List.map (fun _ -> scan fmt f) (1 ++ n)\n\nlet scan_list ?sep cnv =\n let line = read_line () in\n (match sep with\n | None -> List.map String.of_char @@ String.to_list line\n | Some sep -> String.split_on_char sep line)\n |> List.map cnv\n\nlet scan_array ?sep cnv = Array.of_list @@ scan_list ?sep cnv\n\nlet scan_matrix n m e ?sep conv =\n let arr = Array.make_matrix n m e in\n ListL.iter (0 ++^ n)\n ~f:(fun i -> arr.(i) <- Array.of_list @@ scan_list ?sep conv);\n arr\n\nlet atoi c = Char.code c - Char.code '0'\n\nlet rec powerset = function\n | [] -> [[]]\n | hd::tl ->\n let pws = powerset tl in\n pws @ ListL.map pws ~f:(fun pw -> hd::pw)\n\nlet permutations l =\n let rec interleave x = function\n | [] -> [[x]]\n | (hd::tl) as l ->\n (x::l) :: (interleave x tl |> ListL.map ~f:(fun l -> hd::l)) in\n let rec aux = function\n | [] -> [[]]\n | a::rest ->\n aux rest |> ListL.map ~f:(interleave a) |> List.concat in\n aux l\n\nlet intersection l =\n EnumL.filter ~f:(fun x -> EnumL.exists ~f:((=) x) @@ Enum.clone l)\n\nlet zip l m =\n let n = min (List.length l) (List.length m) in\n List.combine (List.take n l) (List.take n m)\n\nlet lower_bound n f =\n let rec aux l u =\n if u - l > 1 then\n let m = (l + u) / 2 in\n if f m then aux l m\n else aux m u\n else u in aux (-1) n\n\nlet between n x m = n <= x && x < m\n\nlet (k,n) = scan \"%d %d\" Tuple2.make\nlet ls = scan_list ~sep:' ' Int.of_string\n\nlet () =\n let ms = ls@[k+List.first ls] in\n ListL.map (zip ms (List.drop 1 ms)) ~f:(fun (a, b) -> b - a)\n |> List.max\n |> ((-) k)\n |> Printf.printf \"%d\\n\"\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere is a circular pond with a perimeter of K meters, and N houses around them.\n\nThe i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond.\n\nWhen traveling between these houses, you can only go around the pond.\n\nFind the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.\n\nConstraints\n\n2 \\leq K \\leq 10^6\n\n2 \\leq N \\leq 2 \\times 10^5\n\n0 \\leq A_1 < ... < A_N < K\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK N\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.\n\nSample Input 1\n\n20 3\n5 10 15\n\nSample Output 1\n\n10\n\nIf you start at the 1-st house and go to the 2-nd and 3-rd houses in this order, the total distance traveled will be 10.\n\nSample Input 2\n\n20 3\n0 5 15\n\nSample Output 2\n\n10\n\nIf you start at the 2-nd house and go to the 1-st and 3-rd houses in this order, the total distance traveled will be 10.", "sample_input": "20 3\n5 10 15\n"}, "reference_outputs": ["10\n"], "source_document_id": "p02725", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere is a circular pond with a perimeter of K meters, and N houses around them.\n\nThe i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond.\n\nWhen traveling between these houses, you can only go around the pond.\n\nFind the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.\n\nConstraints\n\n2 \\leq K \\leq 10^6\n\n2 \\leq N \\leq 2 \\times 10^5\n\n0 \\leq A_1 < ... < A_N < K\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK N\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.\n\nSample Input 1\n\n20 3\n5 10 15\n\nSample Output 1\n\n10\n\nIf you start at the 1-st house and go to the 2-nd and 3-rd houses in this order, the total distance traveled will be 10.\n\nSample Input 2\n\n20 3\n0 5 15\n\nSample Output 2\n\n10\n\nIf you start at the 2-nd house and go to the 1-st and 3-rd houses in this order, the total distance traveled will be 10.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2326, "cpu_time_ms": 133, "memory_kb": 43280}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s211776384", "group_id": "codeNet:p02725", "input_text": "(*\nocamlfind ocamlopt -package batteries -linkpkg main.ml -o a.out\n*)\nopen Batteries\n\nlet k, n = Scanf.sscanf (read_line ()) \"%d %d\" (\n fun k n -> \n k, n\n)\n\nlet lst = Str.split (Str.regexp \" \") (read_line ())\n |> List.map int_of_string \n |> List.sort compare\n\nlet rec f head tail lst =\n match lst with\n [] -> [0]\n | first :: [] -> \n [head + (k - tail)] @ f head tail [] \n | first :: rest -> \n [(List.hd rest) - first] @ f head tail rest\n\nlet () =\n let tmplst = f (List.min lst) (List.max lst) lst in\n let tmplst2 = List.filter (fun elmnt ->\n elmnt != (List.max tmplst)\n ) tmplst in\n List.fold_right (+) tmplst2 0\n |> Printf.printf \"%d\\n\"\n", "language": "OCaml", "metadata": {"date": 1590104773, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02725.html", "problem_id": "p02725", "resource_group": "low_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/OCaml/s211776384.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s211776384", "user_id": "u280335093"}, "prompt_components": {"gold_output": "10\n", "input_to_evaluate": "(*\nocamlfind ocamlopt -package batteries -linkpkg main.ml -o a.out\n*)\nopen Batteries\n\nlet k, n = Scanf.sscanf (read_line ()) \"%d %d\" (\n fun k n -> \n k, n\n)\n\nlet lst = Str.split (Str.regexp \" \") (read_line ())\n |> List.map int_of_string \n |> List.sort compare\n\nlet rec f head tail lst =\n match lst with\n [] -> [0]\n | first :: [] -> \n [head + (k - tail)] @ f head tail [] \n | first :: rest -> \n [(List.hd rest) - first] @ f head tail rest\n\nlet () =\n let tmplst = f (List.min lst) (List.max lst) lst in\n let tmplst2 = List.filter (fun elmnt ->\n elmnt != (List.max tmplst)\n ) tmplst in\n List.fold_right (+) tmplst2 0\n |> Printf.printf \"%d\\n\"\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere is a circular pond with a perimeter of K meters, and N houses around them.\n\nThe i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond.\n\nWhen traveling between these houses, you can only go around the pond.\n\nFind the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.\n\nConstraints\n\n2 \\leq K \\leq 10^6\n\n2 \\leq N \\leq 2 \\times 10^5\n\n0 \\leq A_1 < ... < A_N < K\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK N\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.\n\nSample Input 1\n\n20 3\n5 10 15\n\nSample Output 1\n\n10\n\nIf you start at the 1-st house and go to the 2-nd and 3-rd houses in this order, the total distance traveled will be 10.\n\nSample Input 2\n\n20 3\n0 5 15\n\nSample Output 2\n\n10\n\nIf you start at the 2-nd house and go to the 1-st and 3-rd houses in this order, the total distance traveled will be 10.", "sample_input": "20 3\n5 10 15\n"}, "reference_outputs": ["10\n"], "source_document_id": "p02725", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere is a circular pond with a perimeter of K meters, and N houses around them.\n\nThe i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond.\n\nWhen traveling between these houses, you can only go around the pond.\n\nFind the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.\n\nConstraints\n\n2 \\leq K \\leq 10^6\n\n2 \\leq N \\leq 2 \\times 10^5\n\n0 \\leq A_1 < ... < A_N < K\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK N\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.\n\nSample Input 1\n\n20 3\n5 10 15\n\nSample Output 1\n\n10\n\nIf you start at the 1-st house and go to the 2-nd and 3-rd houses in this order, the total distance traveled will be 10.\n\nSample Input 2\n\n20 3\n0 5 15\n\nSample Output 2\n\n10\n\nIf you start at the 2-nd house and go to the 1-st and 3-rd houses in this order, the total distance traveled will be 10.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 845, "cpu_time_ms": 2105, "memory_kb": 23976}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s003737654", "group_id": "codeNet:p02725", "input_text": "let () =\n\tlet k, n = Scanf.scanf \"%d %d\\n\" @@ fun a b -> a, b in\n\tlet arr = Array.init n @@ fun _ -> Scanf.scanf \"%d \" @@ fun d -> d in\n\tlet brr = Array.init n @@ fun i -> \n \tif i = 0 then k - arr.(n-1) + arr.(i) else arr.(i) - arr.(i-1) in\n print_int ((Array.fold_left (+) 0 brr) - (Array.fold_left max 0 brr))", "language": "OCaml", "metadata": {"date": 1589664392, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02725.html", "problem_id": "p02725", "resource_group": "low_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/OCaml/s003737654.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s003737654", "user_id": "u307426615"}, "prompt_components": {"gold_output": "10\n", "input_to_evaluate": "let () =\n\tlet k, n = Scanf.scanf \"%d %d\\n\" @@ fun a b -> a, b in\n\tlet arr = Array.init n @@ fun _ -> Scanf.scanf \"%d \" @@ fun d -> d in\n\tlet brr = Array.init n @@ fun i -> \n \tif i = 0 then k - arr.(n-1) + arr.(i) else arr.(i) - arr.(i-1) in\n print_int ((Array.fold_left (+) 0 brr) - (Array.fold_left max 0 brr))", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 317, "cpu_time_ms": 58, "memory_kb": 6272}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s666219152", "group_id": "codeNet:p02726", "input_text": "let id x = x\n\nlet init n f =\n let rec g i ns = if i = 0 then 0 :: ns else g (i - 1) (i :: ns) in\n List.map f (g (n - 1) [])\n\nlet (n, x, y) = Scanf.scanf \"%d %d %d\" @@ fun n x y -> (n, x, y)\n\nlet ix = init n (fun i -> i + 1)\n\nlet pair = \n let xs = fst @@ List.fold_left (fun (ns, ys) i -> ((List.map (fun j -> (i, j)) ys)::ns, List.tl ys)) ([], ix) ix in\n List.fold_left (fun xs ys -> List.rev_append xs ys) [] xs\n\nlet f (i, j) = \n let rec min' m = function\n | [] -> m\n | x :: xs -> min' (min m x) xs \n in\n min' max_int [(abs (i - j)); (abs (i - y)) + 1 + (abs (x - j)); (abs (i - x)) + 1 + (abs (y - j))]\n\nlet g xs i =\n match xs with\n | [] -> [(i, 1)]\n | (j, c) :: xs -> if i = j then (j, c + 1) :: xs else (i, 1) :: (j, c) :: xs\n\nlet () = \n let cs = pair \n |> List.map f\n |> List.fast_sort (fun i j -> i - j)\n |> List.fold_left g [] in\n List.iter (fun k ->\n try Printf.printf \"%d\\n\" (List.assoc k cs)\n with Not_found -> print_endline \"0\"\n ) (init (n - 1) (fun i -> i + 1))\n", "language": "OCaml", "metadata": {"date": 1588623263, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02726.html", "problem_id": "p02726", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02726/input.txt", "sample_output_relpath": "derived/input_output/data/p02726/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02726/OCaml/s666219152.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s666219152", "user_id": "u811309788"}, "prompt_components": {"gold_output": "5\n4\n1\n0\n", "input_to_evaluate": "let id x = x\n\nlet init n f =\n let rec g i ns = if i = 0 then 0 :: ns else g (i - 1) (i :: ns) in\n List.map f (g (n - 1) [])\n\nlet (n, x, y) = Scanf.scanf \"%d %d %d\" @@ fun n x y -> (n, x, y)\n\nlet ix = init n (fun i -> i + 1)\n\nlet pair = \n let xs = fst @@ List.fold_left (fun (ns, ys) i -> ((List.map (fun j -> (i, j)) ys)::ns, List.tl ys)) ([], ix) ix in\n List.fold_left (fun xs ys -> List.rev_append xs ys) [] xs\n\nlet f (i, j) = \n let rec min' m = function\n | [] -> m\n | x :: xs -> min' (min m x) xs \n in\n min' max_int [(abs (i - j)); (abs (i - y)) + 1 + (abs (x - j)); (abs (i - x)) + 1 + (abs (y - j))]\n\nlet g xs i =\n match xs with\n | [] -> [(i, 1)]\n | (j, c) :: xs -> if i = j then (j, c + 1) :: xs else (i, 1) :: (j, c) :: xs\n\nlet () = \n let cs = pair \n |> List.map f\n |> List.fast_sort (fun i j -> i - j)\n |> List.fold_left g [] in\n List.iter (fun k ->\n try Printf.printf \"%d\\n\" (List.assoc k cs)\n with Not_found -> print_endline \"0\"\n ) (init (n - 1) (fun i -> i + 1))\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nWe have an undirected graph G with N vertices numbered 1 to N and N edges as follows:\n\nFor each i=1,2,...,N-1, there is an edge between Vertex i and Vertex i+1.\n\nThere is an edge between Vertex X and Vertex Y.\n\nFor each k=1,2,...,N-1, solve the problem below:\n\nFind the number of pairs of integers (i,j) (1 \\leq i < j \\leq N) such that the shortest distance between Vertex i and Vertex j in G is k.\n\nConstraints\n\n3 \\leq N \\leq 2 \\times 10^3\n\n1 \\leq X,Y \\leq N\n\nX+1 < Y\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN X Y\n\nOutput\n\nFor each k=1, 2, ..., N-1 in this order, print a line containing the answer to the problem.\n\nSample Input 1\n\n5 2 4\n\nSample Output 1\n\n5\n4\n1\n0\n\nThe graph in this input is as follows:\n\nThere are five pairs (i,j) (1 \\leq i < j \\leq N) such that the shortest distance between Vertex i and Vertex j is 1: (1,2)\\,,(2,3)\\,,(2,4)\\,,(3,4)\\,,(4,5).\n\nThere are four pairs (i,j) (1 \\leq i < j \\leq N) such that the shortest distance between Vertex i and Vertex j is 2: (1,3)\\,,(1,4)\\,,(2,5)\\,,(3,5).\n\nThere is one pair (i,j) (1 \\leq i < j \\leq N) such that the shortest distance between Vertex i and Vertex j is 3: (1,5).\n\nThere are no pairs (i,j) (1 \\leq i < j \\leq N) such that the shortest distance between Vertex i and Vertex j is 4.\n\nSample Input 2\n\n3 1 3\n\nSample Output 2\n\n3\n0\n\nThe graph in this input is as follows:\n\nSample Input 3\n\n7 3 7\n\nSample Output 3\n\n7\n8\n4\n2\n0\n0\n\nSample Input 4\n\n10 4 8\n\nSample Output 4\n\n10\n12\n10\n8\n4\n1\n0\n0\n0", "sample_input": "5 2 4\n"}, "reference_outputs": ["5\n4\n1\n0\n"], "source_document_id": "p02726", "source_text": "Score : 400 points\n\nProblem Statement\n\nWe have an undirected graph G with N vertices numbered 1 to N and N edges as follows:\n\nFor each i=1,2,...,N-1, there is an edge between Vertex i and Vertex i+1.\n\nThere is an edge between Vertex X and Vertex Y.\n\nFor each k=1,2,...,N-1, solve the problem below:\n\nFind the number of pairs of integers (i,j) (1 \\leq i < j \\leq N) such that the shortest distance between Vertex i and Vertex j in G is k.\n\nConstraints\n\n3 \\leq N \\leq 2 \\times 10^3\n\n1 \\leq X,Y \\leq N\n\nX+1 < Y\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN X Y\n\nOutput\n\nFor each k=1, 2, ..., N-1 in this order, print a line containing the answer to the problem.\n\nSample Input 1\n\n5 2 4\n\nSample Output 1\n\n5\n4\n1\n0\n\nThe graph in this input is as follows:\n\nThere are five pairs (i,j) (1 \\leq i < j \\leq N) such that the shortest distance between Vertex i and Vertex j is 1: (1,2)\\,,(2,3)\\,,(2,4)\\,,(3,4)\\,,(4,5).\n\nThere are four pairs (i,j) (1 \\leq i < j \\leq N) such that the shortest distance between Vertex i and Vertex j is 2: (1,3)\\,,(1,4)\\,,(2,5)\\,,(3,5).\n\nThere is one pair (i,j) (1 \\leq i < j \\leq N) such that the shortest distance between Vertex i and Vertex j is 3: (1,5).\n\nThere are no pairs (i,j) (1 \\leq i < j \\leq N) such that the shortest distance between Vertex i and Vertex j is 4.\n\nSample Input 2\n\n3 1 3\n\nSample Output 2\n\n3\n0\n\nThe graph in this input is as follows:\n\nSample Input 3\n\n7 3 7\n\nSample Output 3\n\n7\n8\n4\n2\n0\n0\n\nSample Input 4\n\n10 4 8\n\nSample Output 4\n\n10\n12\n10\n8\n4\n1\n0\n0\n0", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1012, "cpu_time_ms": 2108, "memory_kb": 198464}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s312760987", "group_id": "codeNet:p02729", "input_text": "let _ = Scanf.sscanf (read_line()) \"%d %d\" (fun n m ->\n (n * (n-1) + m * (m-1)) / 2\n) |> Printf.printf \"%d\\n\"", "language": "OCaml", "metadata": {"date": 1584926609, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02729.html", "problem_id": "p02729", "resource_group": "low_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/OCaml/s312760987.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s312760987", "user_id": "u511870776"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "let _ = Scanf.sscanf (read_line()) \"%d %d\" (fun n m ->\n (n * (n-1) + m * (m-1)) / 2\n) |> Printf.printf \"%d\\n\"", "problem_context": "Score : 100 points\n\nProblem Statement\n\nWe have N+M balls, each of which has an integer written on it.\n\nIt is known that:\n\nThe numbers written on N of the balls are even.\n\nThe numbers written on M of the balls are odd.\n\nFind the number of ways to choose two of the N+M balls (disregarding order) so that the sum of the numbers written on them is even.\n\nIt can be shown that this count does not depend on the actual values written on the balls.\n\nConstraints\n\n0 \\leq N,M \\leq 100\n\n2 \\leq N+M\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n2 1\n\nSample Output 1\n\n1\n\nFor example, let us assume that the numbers written on the three balls are 1,2,4.\n\nIf we choose the two balls with 1 and 2, the sum is odd;\n\nIf we choose the two balls with 1 and 4, the sum is odd;\n\nIf we choose the two balls with 2 and 4, the sum is even.\n\nThus, the answer is 1.\n\nSample Input 2\n\n4 3\n\nSample Output 2\n\n9\n\nSample Input 3\n\n1 1\n\nSample Output 3\n\n0\n\nSample Input 4\n\n13 3\n\nSample Output 4\n\n81\n\nSample Input 5\n\n0 3\n\nSample Output 5\n\n3", "sample_input": "2 1\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02729", "source_text": "Score : 100 points\n\nProblem Statement\n\nWe have N+M balls, each of which has an integer written on it.\n\nIt is known that:\n\nThe numbers written on N of the balls are even.\n\nThe numbers written on M of the balls are odd.\n\nFind the number of ways to choose two of the N+M balls (disregarding order) so that the sum of the numbers written on them is even.\n\nIt can be shown that this count does not depend on the actual values written on the balls.\n\nConstraints\n\n0 \\leq N,M \\leq 100\n\n2 \\leq N+M\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n2 1\n\nSample Output 1\n\n1\n\nFor example, let us assume that the numbers written on the three balls are 1,2,4.\n\nIf we choose the two balls with 1 and 2, the sum is odd;\n\nIf we choose the two balls with 1 and 4, the sum is odd;\n\nIf we choose the two balls with 2 and 4, the sum is even.\n\nThus, the answer is 1.\n\nSample Input 2\n\n4 3\n\nSample Output 2\n\n9\n\nSample Input 3\n\n1 1\n\nSample Output 3\n\n0\n\nSample Input 4\n\n13 3\n\nSample Output 4\n\n81\n\nSample Input 5\n\n0 3\n\nSample Output 5\n\n3", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s965574454", "group_id": "codeNet:p02730", "input_text": "let is_palindrome s =\n let n = String.length s in\n Array.fold_left ( && ) true @@\n Array.init (n / 2) @@ fun i -> s.[i] = s.[n - i - 1]\n\nlet () =\n let s = read_line () in\n let n = String.length s in\n print_endline @@\n if\n is_palindrome s &&\n is_palindrome (String.sub s 0 ((n - 1) / 2)) &&\n is_palindrome (String.sub s ((n + 1) / 2) ((n - 1) / 2))\n then \"Yes\"\n else \"No\"\n", "language": "OCaml", "metadata": {"date": 1584926978, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02730.html", "problem_id": "p02730", "resource_group": "low_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/OCaml/s965574454.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s965574454", "user_id": "u504158101"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "let is_palindrome s =\n let n = String.length s in\n Array.fold_left ( && ) true @@\n Array.init (n / 2) @@ fun i -> s.[i] = s.[n - i - 1]\n\nlet () =\n let s = read_line () in\n let n = String.length s in\n print_endline @@\n if\n is_palindrome s &&\n is_palindrome (String.sub s 0 ((n - 1) / 2)) &&\n is_palindrome (String.sub s ((n + 1) / 2) ((n - 1) / 2))\n then \"Yes\"\n else \"No\"\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nA string S of an odd length is said to be a strong palindrome if and only if all of the following conditions are satisfied:\n\nS is a palindrome.\n\nLet N be the length of S. The string formed by the 1-st through ((N-1)/2)-th characters of S is a palindrome.\n\nThe string consisting of the (N+3)/2-st through N-th characters of S is a palindrome.\n\nDetermine whether S is a strong palindrome.\n\nConstraints\n\nS consists of lowercase English letters.\n\nThe length of S is an odd number between 3 and 99 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nIf S is a strong palindrome, print Yes;\notherwise, print No.\n\nSample Input 1\n\nakasaka\n\nSample Output 1\n\nYes\n\nS is akasaka.\n\nThe string formed by the 1-st through the 3-rd characters is aka.\n\nThe string formed by the 5-th through the 7-th characters is aka.\nAll of these are palindromes, so S is a strong palindrome.\n\nSample Input 2\n\nlevel\n\nSample Output 2\n\nNo\n\nSample Input 3\n\natcoder\n\nSample Output 3\n\nNo", "sample_input": "akasaka\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02730", "source_text": "Score : 200 points\n\nProblem Statement\n\nA string S of an odd length is said to be a strong palindrome if and only if all of the following conditions are satisfied:\n\nS is a palindrome.\n\nLet N be the length of S. The string formed by the 1-st through ((N-1)/2)-th characters of S is a palindrome.\n\nThe string consisting of the (N+3)/2-st through N-th characters of S is a palindrome.\n\nDetermine whether S is a strong palindrome.\n\nConstraints\n\nS consists of lowercase English letters.\n\nThe length of S is an odd number between 3 and 99 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nIf S is a strong palindrome, print Yes;\notherwise, print No.\n\nSample Input 1\n\nakasaka\n\nSample Output 1\n\nYes\n\nS is akasaka.\n\nThe string formed by the 1-st through the 3-rd characters is aka.\n\nThe string formed by the 5-th through the 7-th characters is aka.\nAll of these are palindromes, so S is a strong palindrome.\n\nSample Input 2\n\nlevel\n\nSample Output 2\n\nNo\n\nSample Input 3\n\natcoder\n\nSample Output 3\n\nNo", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 389, "cpu_time_ms": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s158306083", "group_id": "codeNet:p02731", "input_text": "let () =\n let l = read_float () in\n let l_p = l /. 3. in\n l_p *. l_p *. l_p |> Printf.printf \"%f\\n\" \n", "language": "OCaml", "metadata": {"date": 1585256263, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02731.html", "problem_id": "p02731", "resource_group": "low_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/OCaml/s158306083.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s158306083", "user_id": "u575440531"}, "prompt_components": {"gold_output": "1.000000000000\n", "input_to_evaluate": "let () =\n let l = read_float () in\n let l_p = l /. 3. in\n l_p *. l_p *. l_p |> Printf.printf \"%f\\n\" \n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nGiven is a positive integer L.\nFind the maximum possible volume of a rectangular cuboid whose sum of the dimensions (not necessarily integers) is L.\n\nConstraints\n\n1 ≤ L ≤ 1000\n\nL is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nL\n\nOutput\n\nPrint the maximum possible volume of a rectangular cuboid whose sum of the dimensions (not necessarily integers) is L.\nYour output is considered correct if its absolute or relative error from our answer is at most 10^{-6}.\n\nSample Input 1\n\n3\n\nSample Output 1\n\n1.000000000000\n\nFor example, a rectangular cuboid whose dimensions are 0.8, 1, and 1.2 has a volume of 0.96.\n\nOn the other hand, if the dimensions are 1, 1, and 1, the volume of the rectangular cuboid is 1, which is greater.\n\nSample Input 2\n\n999\n\nSample Output 2\n\n36926037.000000000000", "sample_input": "3\n"}, "reference_outputs": ["1.000000000000\n"], "source_document_id": "p02731", "source_text": "Score : 300 points\n\nProblem Statement\n\nGiven is a positive integer L.\nFind the maximum possible volume of a rectangular cuboid whose sum of the dimensions (not necessarily integers) is L.\n\nConstraints\n\n1 ≤ L ≤ 1000\n\nL is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nL\n\nOutput\n\nPrint the maximum possible volume of a rectangular cuboid whose sum of the dimensions (not necessarily integers) is L.\nYour output is considered correct if its absolute or relative error from our answer is at most 10^{-6}.\n\nSample Input 1\n\n3\n\nSample Output 1\n\n1.000000000000\n\nFor example, a rectangular cuboid whose dimensions are 0.8, 1, and 1.2 has a volume of 0.96.\n\nOn the other hand, if the dimensions are 1, 1, and 1, the volume of the rectangular cuboid is 1, which is greater.\n\nSample Input 2\n\n999\n\nSample Output 2\n\n36926037.000000000000", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s282673357", "group_id": "codeNet:p02731", "input_text": "let l = read_int ()\nlet s = float_of_int (l/3)\nlet _ = (if l mod 3 = 0 then s ** 3. else\n if l mod 3 = 1 then s *. (s +. 0.5) *. (s +. 0.5) else\n (s +. 0.666666667) *. (s +. 0.666666666) *. (s +. 0.666666667)) |> Printf.printf \"%f\\n\"", "language": "OCaml", "metadata": {"date": 1584928022, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02731.html", "problem_id": "p02731", "resource_group": "low_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/OCaml/s282673357.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s282673357", "user_id": "u511870776"}, "prompt_components": {"gold_output": "1.000000000000\n", "input_to_evaluate": "let l = read_int ()\nlet s = float_of_int (l/3)\nlet _ = (if l mod 3 = 0 then s ** 3. else\n if l mod 3 = 1 then s *. (s +. 0.5) *. (s +. 0.5) else\n (s +. 0.666666667) *. (s +. 0.666666666) *. (s +. 0.666666667)) |> Printf.printf \"%f\\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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s764112980", "group_id": "codeNet:p02732", "input_text": "open Batteries\nmodule CountDict = Map.Make(Int)\nlet count_int lst =\n let rec add_lst dict l =\n match l with\n | [] -> dict\n | first :: rest ->\n if CountDict.mem first dict then add_lst (CountDict.add first ((CountDict.find first dict) + 1) dict) rest else\n add_lst (CountDict.add first 1 dict) rest\n in add_lst CountDict.empty lst\n\nlet n = read_int ()\nlet a = read_line () |> String.split_on_char ' ' |> List.map int_of_string\n\nlet dict = count_int a\n\nlet all = (CountDict.fold (fun key value a -> a + (value * (value - 1))) dict 0) / 2\n\nlet rec loop lst =\n match lst with\n | [] -> ()\n | first :: rest -> let value = CountDict.find first dict in Printf.printf \"%d\\n\" (all - value + 1); loop rest\n\nlet _ = loop a\n", "language": "OCaml", "metadata": {"date": 1587732222, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02732.html", "problem_id": "p02732", "resource_group": "low_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/OCaml/s764112980.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s764112980", "user_id": "u511870776"}, "prompt_components": {"gold_output": "2\n2\n3\n2\n3\n", "input_to_evaluate": "open Batteries\nmodule CountDict = Map.Make(Int)\nlet count_int lst =\n let rec add_lst dict l =\n match l with\n | [] -> dict\n | first :: rest ->\n if CountDict.mem first dict then add_lst (CountDict.add first ((CountDict.find first dict) + 1) dict) rest else\n add_lst (CountDict.add first 1 dict) rest\n in add_lst CountDict.empty lst\n\nlet n = read_int ()\nlet a = read_line () |> String.split_on_char ' ' |> List.map int_of_string\n\nlet dict = count_int a\n\nlet all = (CountDict.fold (fun key value a -> a + (value * (value - 1))) dict 0) / 2\n\nlet rec loop lst =\n match lst with\n | [] -> ()\n | first :: rest -> let value = CountDict.find first dict in Printf.printf \"%d\\n\" (all - value + 1); loop rest\n\nlet _ = loop a\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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 735, "cpu_time_ms": 423, "memory_kb": 26552}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s099327777", "group_id": "codeNet:p02734", "input_text": "let m = 998244353\nlet ( +^ ) x y = (x + y) mod m\nlet ( *^ ) x y = (x * y) mod m\n\nlet () = Scanf.scanf \"%d %d\\n\" @@ fun n s ->\n let as_ = Array.init n @@ fun _ -> Scanf.scanf \"%d \" @@ fun a -> a in\n let result = ref 0 in\n let dp = Array.make 3001 0 in\n for i = 0 to n - 1 do\n for j = s downto as_.(i) + 1 do\n dp.(j) <- dp.(j) +^ dp.(j - as_.(i))\n done;\n dp.(as_.(i)) <- dp.(as_.(i)) +^ (i + 1);\n result := !result +^ dp.(s) *^ (n - i);\n dp.(s) <- 0;\n done;\n Printf.printf \"%d\\n\" @@ !result\n", "language": "OCaml", "metadata": {"date": 1584930863, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02734.html", "problem_id": "p02734", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02734/input.txt", "sample_output_relpath": "derived/input_output/data/p02734/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02734/OCaml/s099327777.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s099327777", "user_id": "u504158101"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "let m = 998244353\nlet ( +^ ) x y = (x + y) mod m\nlet ( *^ ) x y = (x * y) mod m\n\nlet () = Scanf.scanf \"%d %d\\n\" @@ fun n s ->\n let as_ = Array.init n @@ fun _ -> Scanf.scanf \"%d \" @@ fun a -> a in\n let result = ref 0 in\n let dp = Array.make 3001 0 in\n for i = 0 to n - 1 do\n for j = s downto as_.(i) + 1 do\n dp.(j) <- dp.(j) +^ dp.(j - as_.(i))\n done;\n dp.(as_.(i)) <- dp.(as_.(i)) +^ (i + 1);\n result := !result +^ dp.(s) *^ (n - i);\n dp.(s) <- 0;\n done;\n Printf.printf \"%d\\n\" @@ !result\n", "problem_context": "Score : 600 points\n\nProblem Statement\n\nGiven are a sequence of N integers A_1, A_2, \\ldots, A_N and a positive integer S.\n\nFor a pair of integers (L, R) such that 1\\leq L \\leq R \\leq N, let us define f(L, R) as follows:\n\nf(L, R) is the number of sequences of integers (x_1, x_2, \\ldots , x_k) such that L \\leq x_1 < x_2 < \\cdots < x_k \\leq R and A_{x_1}+A_{x_2}+\\cdots +A_{x_k} = S.\n\nFind the sum of f(L, R) over all pairs of integers (L, R) such that 1\\leq L \\leq R\\leq N. Since this 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(L, R), modulo 998244353.\n\nSample Input 1\n\n3 4\n2 2 4\n\nSample Output 1\n\n5\n\nThe value of f(L, R) for each pair is as follows, for a total of 5.\n\nf(1,1) = 0\n\nf(1,2) = 1 (for the sequence (1, 2))\n\nf(1,3) = 2 (for (1, 2) and (3))\n\nf(2,2) = 0\n\nf(2,3) = 1 (for (3))\n\nf(3,3) = 1 (for (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\n152", "sample_input": "3 4\n2 2 4\n"}, "reference_outputs": ["5\n"], "source_document_id": "p02734", "source_text": "Score : 600 points\n\nProblem Statement\n\nGiven are a sequence of N integers A_1, A_2, \\ldots, A_N and a positive integer S.\n\nFor a pair of integers (L, R) such that 1\\leq L \\leq R \\leq N, let us define f(L, R) as follows:\n\nf(L, R) is the number of sequences of integers (x_1, x_2, \\ldots , x_k) such that L \\leq x_1 < x_2 < \\cdots < x_k \\leq R and A_{x_1}+A_{x_2}+\\cdots +A_{x_k} = S.\n\nFind the sum of f(L, R) over all pairs of integers (L, R) such that 1\\leq L \\leq R\\leq N. Since this 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(L, R), modulo 998244353.\n\nSample Input 1\n\n3 4\n2 2 4\n\nSample Output 1\n\n5\n\nThe value of f(L, R) for each pair is as follows, for a total of 5.\n\nf(1,1) = 0\n\nf(1,2) = 1 (for the sequence (1, 2))\n\nf(1,3) = 2 (for (1, 2) and (3))\n\nf(2,2) = 0\n\nf(2,3) = 1 (for (3))\n\nf(3,3) = 1 (for (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\n152", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 515, "cpu_time_ms": 26, "memory_kb": 1152}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s759812003", "group_id": "codeNet:p02735", "input_text": "Scanf.scanf \"%d %d\" (fun h w ->\n let s = Array.init h (fun _ -> Scanf.scanf \" %s\" (fun s -> s)) in\n let mat = Array.make_matrix h w 100000 in\n mat.(0).(0) <- if s.(0).[0] = '#' then 1 else 0;\n for y = 0 to h - 1 do\n for x = 0 to w - 1 do\n if x < w - 1 then (\n let q = if s.(y).[x] = '.' && s.(y).[x + 1] = '#' then 1 else 0 in\n mat.(y).(x + 1) <- min mat.(y).(x + 1) (mat.(y).(x) + q)\n );\n if y < h - 1 then (\n let q = if s.(y).[x] = '.' && s.(y + 1).[x] = '#' then 1 else 0 in\n mat.(y + 1).(x) <- min mat.(y + 1).(x) (mat.(y).(x) + q)\n );\n done\n done;\n Printf.printf \"%d\\n\" mat.(h - 1).(w - 1)\n)", "language": "OCaml", "metadata": {"date": 1598490296, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p02735.html", "problem_id": "p02735", "resource_group": "low_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/OCaml/s759812003.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s759812003", "user_id": "u342443598"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "Scanf.scanf \"%d %d\" (fun h w ->\n let s = Array.init h (fun _ -> Scanf.scanf \" %s\" (fun s -> s)) in\n let mat = Array.make_matrix h w 100000 in\n mat.(0).(0) <- if s.(0).[0] = '#' then 1 else 0;\n for y = 0 to h - 1 do\n for x = 0 to w - 1 do\n if x < w - 1 then (\n let q = if s.(y).[x] = '.' && s.(y).[x + 1] = '#' then 1 else 0 in\n mat.(y).(x + 1) <- min mat.(y).(x + 1) (mat.(y).(x) + q)\n );\n if y < h - 1 then (\n let q = if s.(y).[x] = '.' && s.(y + 1).[x] = '#' then 1 else 0 in\n mat.(y + 1).(x) <- min mat.(y + 1).(x) (mat.(y).(x) + q)\n );\n done\n done;\n Printf.printf \"%d\\n\" mat.(h - 1).(w - 1)\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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 733, "cpu_time_ms": 8, "memory_kb": 3860}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s450182825", "group_id": "codeNet:p02741", "input_text": "let l = [1; 1; 1; 2; 1; 2; 1; 5; 2; 2; 1; 5; 1; 2; 1; 14; 1; 5; 1; 5; 2; 2; 1; 15; 2; 2; 5; 4; 1; 4; 1; 51]\nlet k = read_int ()\nlet _ = List.nth l (k-1) |> Printf.printf \"%d\\n\"", "language": "OCaml", "metadata": {"date": 1584303069, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02741.html", "problem_id": "p02741", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02741/input.txt", "sample_output_relpath": "derived/input_output/data/p02741/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02741/OCaml/s450182825.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s450182825", "user_id": "u511870776"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "let l = [1; 1; 1; 2; 1; 2; 1; 5; 2; 2; 1; 5; 1; 2; 1; 14; 1; 5; 1; 5; 2; 2; 1; 15; 2; 2; 5; 4; 1; 4; 1; 51]\nlet k = read_int ()\nlet _ = List.nth l (k-1) |> Printf.printf \"%d\\n\"", "problem_context": "Score : 100 points\n\nProblem Statement\n\nPrint the K-th element of the following sequence of length 32:\n\n1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51\n\nConstraints\n\n1 \\leq K \\leq 32\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK\n\nOutput\n\nPrint the K-th element.\n\nSample Input 1\n\n6\n\nSample Output 1\n\n2\n\nThe 6-th element is 2.\n\nSample Input 2\n\n27\n\nSample Output 2\n\n5\n\nThe 27-th element is 5.", "sample_input": "6\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02741", "source_text": "Score : 100 points\n\nProblem Statement\n\nPrint the K-th element of the following sequence of length 32:\n\n1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51\n\nConstraints\n\n1 \\leq K \\leq 32\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK\n\nOutput\n\nPrint the K-th element.\n\nSample Input 1\n\n6\n\nSample Output 1\n\n2\n\nThe 6-th element is 2.\n\nSample Input 2\n\n27\n\nSample Output 2\n\n5\n\nThe 27-th element is 5.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s443683195", "group_id": "codeNet:p02742", "input_text": "open Printf\nopen Scanf\n\nlet prod h w =\n if w mod 2 = 0 then (w/2)*h\n else if h mod 2 = 0 then (w/2)*(h/2)+(w+1)/2*(h/2)\n else (w/2)*(h/2)+(w+1)/2*(h+1)/2\n\nlet() = \n scanf \"%d %d\" prod |> printf \"%d\\n\"", "language": "OCaml", "metadata": {"date": 1586817482, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02742.html", "problem_id": "p02742", "resource_group": "low_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/OCaml/s443683195.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s443683195", "user_id": "u932465688"}, "prompt_components": {"gold_output": "10\n", "input_to_evaluate": "open Printf\nopen Scanf\n\nlet prod h w =\n if w mod 2 = 0 then (w/2)*h\n else if h mod 2 = 0 then (w/2)*(h/2)+(w+1)/2*(h/2)\n else (w/2)*(h/2)+(w+1)/2*(h+1)/2\n\nlet() = \n scanf \"%d %d\" prod |> printf \"%d\\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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s071519641", "group_id": "codeNet:p02745", "input_text": "let eqs a b o =\n let a, b, o = if o < 0 then b, a, -o else a, b, o in\n let rec f i =\n if i+o >= String.length a || i >= String.length b then true\n else (a.[i+o] = '?' || b.[i] = '?' || a.[i+o] = b.[i]) && f (i+1)\n in f 0\n\nlet max3 a b = max (max a b)\nlet min3 a b = min (min a b)\n\nlet () =\n Scanf.scanf \"%s %s %s\" @@ fun a b c ->\n let la, lb, lc = String.(length a, length b, length c) in\n let ab = Array.init 4001 (fun i -> eqs a b (i-2000)) in\n let bc = Array.init 4001 (fun i -> eqs b c (i-2000)) in\n let ac = Array.init 4001 (fun i -> eqs a c (i-2000)) in\n\n let ans = ref 6000 in\n for i = -4000 to 4000 do\n if la - i < !ans && i < (!ans - lb) && (abs i > 2000 || ab.(i+2000)) then\n for j = -4000 to 4000 do\n if (la - j < !ans) && j < (!ans - lc) &&\n (abs j > 2000 || ac.(j+2000)) &&\n (abs (j-i) > 2000 || bc.(j-i+2000))\n then\n ans := min !ans (max3 la (i+lb) (j+lc) - min3 0 i j)\n done;\n done;\n Printf.printf \"%d\\n\" !ans\n", "language": "OCaml", "metadata": {"date": 1584251027, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02745.html", "problem_id": "p02745", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02745/input.txt", "sample_output_relpath": "derived/input_output/data/p02745/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02745/OCaml/s071519641.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s071519641", "user_id": "u798181098"}, "prompt_components": {"gold_output": "7\n", "input_to_evaluate": "let eqs a b o =\n let a, b, o = if o < 0 then b, a, -o else a, b, o in\n let rec f i =\n if i+o >= String.length a || i >= String.length b then true\n else (a.[i+o] = '?' || b.[i] = '?' || a.[i+o] = b.[i]) && f (i+1)\n in f 0\n\nlet max3 a b = max (max a b)\nlet min3 a b = min (min a b)\n\nlet () =\n Scanf.scanf \"%s %s %s\" @@ fun a b c ->\n let la, lb, lc = String.(length a, length b, length c) in\n let ab = Array.init 4001 (fun i -> eqs a b (i-2000)) in\n let bc = Array.init 4001 (fun i -> eqs b c (i-2000)) in\n let ac = Array.init 4001 (fun i -> eqs a c (i-2000)) in\n\n let ans = ref 6000 in\n for i = -4000 to 4000 do\n if la - i < !ans && i < (!ans - lb) && (abs i > 2000 || ab.(i+2000)) then\n for j = -4000 to 4000 do\n if (la - j < !ans) && j < (!ans - lc) &&\n (abs j > 2000 || ac.(j+2000)) &&\n (abs (j-i) > 2000 || bc.(j-i+2000))\n then\n ans := min !ans (max3 la (i+lb) (j+lc) - min3 0 i j)\n done;\n done;\n Printf.printf \"%d\\n\" !ans\n", "problem_context": "Score : 500 points\n\nProblem Statement\n\nSnuke has a string s.\nFrom this string, Anuke, Bnuke, and Cnuke obtained strings a, b, and c, respectively, as follows:\n\nChoose a non-empty (contiguous) substring of s (possibly s itself). Then, replace some characters (possibly all or none) in it with ?s.\n\nFor example, if s is mississippi, we can choose the substring ssissip and replace its 1-st and 3-rd characters with ? to obtain ?s?ssip.\n\nYou are given the strings a, b, and c.\nFind the minimum possible length of s.\n\nConstraints\n\n1 \\leq |a|, |b|, |c| \\leq 2000\n\na, b, and c consists of lowercase English letters and ?s.\n\nInput\n\nInput is given from Standard Input in the following format:\n\na\nb\nc\n\nOutput\n\nPrint the minimum possible length of s.\n\nSample Input 1\n\na?c\nder\ncod\n\nSample Output 1\n\n7\n\nFor example, s could be atcoder.\n\nSample Input 2\n\natcoder\natcoder\n???????\n\nSample Output 2\n\n7\n\na, b, and c may not be distinct.", "sample_input": "a?c\nder\ncod\n"}, "reference_outputs": ["7\n"], "source_document_id": "p02745", "source_text": "Score : 500 points\n\nProblem Statement\n\nSnuke has a string s.\nFrom this string, Anuke, Bnuke, and Cnuke obtained strings a, b, and c, respectively, as follows:\n\nChoose a non-empty (contiguous) substring of s (possibly s itself). Then, replace some characters (possibly all or none) in it with ?s.\n\nFor example, if s is mississippi, we can choose the substring ssissip and replace its 1-st and 3-rd characters with ? to obtain ?s?ssip.\n\nYou are given the strings a, b, and c.\nFind the minimum possible length of s.\n\nConstraints\n\n1 \\leq |a|, |b|, |c| \\leq 2000\n\na, b, and c consists of lowercase English letters and ?s.\n\nInput\n\nInput is given from Standard Input in the following format:\n\na\nb\nc\n\nOutput\n\nPrint the minimum possible length of s.\n\nSample Input 1\n\na?c\nder\ncod\n\nSample Output 1\n\n7\n\nFor example, s could be atcoder.\n\nSample Input 2\n\natcoder\natcoder\n???????\n\nSample Output 2\n\n7\n\na, b, and c may not be distinct.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 999, "cpu_time_ms": 967, "memory_kb": 4736}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s799328225", "group_id": "codeNet:p02747", "input_text": "let () =\n let s = Scanf.scanf \"%s\\n\" @@ fun s -> s in\n let ans = ref true in\n for i = 0 to String.length s - 1 do\n if (i mod 2 = 0 && s.[i] = 'h') || (i mod 2 = 1 && s.[i] = 'i')\n then ans := !ans && true\n else ans := !ans && false\n done;\n Printf.printf \"%s\\n\" (if !ans then \"Yes\" else \"No\")", "language": "OCaml", "metadata": {"date": 1591409521, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02747.html", "problem_id": "p02747", "resource_group": "low_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/OCaml/s799328225.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s799328225", "user_id": "u307426615"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "let () =\n let s = Scanf.scanf \"%s\\n\" @@ fun s -> s in\n let ans = ref true in\n for i = 0 to String.length s - 1 do\n if (i mod 2 = 0 && s.[i] = 'h') || (i mod 2 = 1 && s.[i] = 'i')\n then ans := !ans && true\n else ans := !ans && false\n done;\n Printf.printf \"%s\\n\" (if !ans then \"Yes\" else \"No\")", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 305, "cpu_time_ms": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s113729050", "group_id": "codeNet:p02747", "input_text": "let s = read_line () in\nlet n = String.length s in\nlet rec loop i =\n if i = n then true else (\n match i mod 2, s.[i] with\n | 0, 'h'\n | 1, 'i' -> loop (i + 1)\n | _ -> false\n )\nin\n(if loop 0 then \"Yes\" else \"No\") |> print_endline", "language": "OCaml", "metadata": {"date": 1583715801, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02747.html", "problem_id": "p02747", "resource_group": "low_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/OCaml/s113729050.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s113729050", "user_id": "u342443598"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "let s = read_line () in\nlet n = String.length s in\nlet rec loop i =\n if i = n then true else (\n match i mod 2, s.[i] with\n | 0, 'h'\n | 1, 'i' -> loop (i + 1)\n | _ -> false\n )\nin\n(if loop 0 then \"Yes\" else \"No\") |> print_endline", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s681926130", "group_id": "codeNet:p02753", "input_text": "let s = read_line () in\nPrintf.printf \"%s\\n\"\n (if s.[0] <> s.[1] || s.[1] <> s.[2] || s.[2] <> s.[0] then \"Yes\"\n else \"No\")", "language": "OCaml", "metadata": {"date": 1588802594, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02753.html", "problem_id": "p02753", "resource_group": "low_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/OCaml/s681926130.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s681926130", "user_id": "u307426615"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "let s = read_line () in\nPrintf.printf \"%s\\n\"\n (if s.[0] <> s.[1] || s.[1] <> s.[2] || s.[2] <> s.[0] then \"Yes\"\n else \"No\")", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s946448897", "group_id": "codeNet:p02754", "input_text": "(*\nocamlfind ocamlopt -package batteries -linkpkg main.ml -o a.out\n*)\nopen Batteries\n\nlet n, a, b = Scanf.sscanf (read_line ()) \"%d %d %d\" (\n fun n a b -> \n n, a, b\n)\n\n\nlet ablue = \n let amari = n mod (a + b) in\n if amari < a then\n amari\n else\n a\n\nlet () =\n (\n let div = n / (a + b) in\n let sblue = a * div in\n sblue + ablue\n ) |> Printf.printf \"%d\\n\"\n", "language": "OCaml", "metadata": {"date": 1590351554, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02754.html", "problem_id": "p02754", "resource_group": "low_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/OCaml/s946448897.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s946448897", "user_id": "u280335093"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "(*\nocamlfind ocamlopt -package batteries -linkpkg main.ml -o a.out\n*)\nopen Batteries\n\nlet n, a, b = Scanf.sscanf (read_line ()) \"%d %d %d\" (\n fun n a b -> \n n, a, b\n)\n\n\nlet ablue = \n let amari = n mod (a + b) in\n if amari < a then\n amari\n else\n a\n\nlet () =\n (\n let div = n / (a + b) in\n let sblue = a * div in\n sblue + ablue\n ) |> Printf.printf \"%d\\n\"\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nTakahashi has many red balls and blue balls. Now, he will place them in a row.\n\nInitially, there is no ball placed.\n\nTakahashi, who is very patient, will do the following operation 10^{100} times:\n\nPlace A blue balls at the end of the row of balls already placed. Then, place B red balls at the end of the row.\n\nHow many blue balls will be there among the first N balls in the row of balls made this way?\n\nConstraints\n\n1 \\leq N \\leq 10^{18}\n\nA, B \\geq 0\n\n0 < A + B \\leq 10^{18}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN A B\n\nOutput\n\nPrint the number of blue balls that will be there among the first N balls in the row of balls.\n\nSample Input 1\n\n8 3 4\n\nSample Output 1\n\n4\n\nLet b denote a blue ball, and r denote a red ball. The first eight balls in the row will be bbbrrrrb, among which there are four blue balls.\n\nSample Input 2\n\n8 0 4\n\nSample Output 2\n\n0\n\nHe placed only red balls from the beginning.\n\nSample Input 3\n\n6 2 4\n\nSample Output 3\n\n2\n\nAmong bbrrrr, there are two blue balls.", "sample_input": "8 3 4\n"}, "reference_outputs": ["4\n"], "source_document_id": "p02754", "source_text": "Score : 200 points\n\nProblem Statement\n\nTakahashi has many red balls and blue balls. Now, he will place them in a row.\n\nInitially, there is no ball placed.\n\nTakahashi, who is very patient, will do the following operation 10^{100} times:\n\nPlace A blue balls at the end of the row of balls already placed. Then, place B red balls at the end of the row.\n\nHow many blue balls will be there among the first N balls in the row of balls made this way?\n\nConstraints\n\n1 \\leq N \\leq 10^{18}\n\nA, B \\geq 0\n\n0 < A + B \\leq 10^{18}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN A B\n\nOutput\n\nPrint the number of blue balls that will be there among the first N balls in the row of balls.\n\nSample Input 1\n\n8 3 4\n\nSample Output 1\n\n4\n\nLet b denote a blue ball, and r denote a red ball. The first eight balls in the row will be bbbrrrrb, among which there are four blue balls.\n\nSample Input 2\n\n8 0 4\n\nSample Output 2\n\n0\n\nHe placed only red balls from the beginning.\n\nSample Input 3\n\n6 2 4\n\nSample Output 3\n\n2\n\nAmong bbrrrr, there are two blue balls.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 524, "cpu_time_ms": 3, "memory_kb": 3072}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s844096674", "group_id": "codeNet:p02754", "input_text": "open Batteries\nlet a = read_line()\n |> String.split_on_char ' '\n |> List.map int_of_string\n\nlet n = (List.nth a 0) mod ((List.nth a 1) + (List.nth a 2))\nlet amari = if n > List.nth a 1 then n else List.nth a 1 \n\nlet _ = (((List.nth a 0) / ((List.nth a 1) + (List.nth a 2))) * (List.nth a 1) + amari) |> string_of_int |> print_endline\n", "language": "OCaml", "metadata": {"date": 1583688899, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02754.html", "problem_id": "p02754", "resource_group": "low_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/OCaml/s844096674.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s844096674", "user_id": "u511870776"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "open Batteries\nlet a = read_line()\n |> String.split_on_char ' '\n |> List.map int_of_string\n\nlet n = (List.nth a 0) mod ((List.nth a 1) + (List.nth a 2))\nlet amari = if n > List.nth a 1 then n else List.nth a 1 \n\nlet _ = (((List.nth a 0) / ((List.nth a 1) + (List.nth a 2))) * (List.nth a 1) + amari) |> string_of_int |> print_endline\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nTakahashi has many red balls and blue balls. Now, he will place them in a row.\n\nInitially, there is no ball placed.\n\nTakahashi, who is very patient, will do the following operation 10^{100} times:\n\nPlace A blue balls at the end of the row of balls already placed. Then, place B red balls at the end of the row.\n\nHow many blue balls will be there among the first N balls in the row of balls made this way?\n\nConstraints\n\n1 \\leq N \\leq 10^{18}\n\nA, B \\geq 0\n\n0 < A + B \\leq 10^{18}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN A B\n\nOutput\n\nPrint the number of blue balls that will be there among the first N balls in the row of balls.\n\nSample Input 1\n\n8 3 4\n\nSample Output 1\n\n4\n\nLet b denote a blue ball, and r denote a red ball. The first eight balls in the row will be bbbrrrrb, among which there are four blue balls.\n\nSample Input 2\n\n8 0 4\n\nSample Output 2\n\n0\n\nHe placed only red balls from the beginning.\n\nSample Input 3\n\n6 2 4\n\nSample Output 3\n\n2\n\nAmong bbrrrr, there are two blue balls.", "sample_input": "8 3 4\n"}, "reference_outputs": ["4\n"], "source_document_id": "p02754", "source_text": "Score : 200 points\n\nProblem Statement\n\nTakahashi has many red balls and blue balls. Now, he will place them in a row.\n\nInitially, there is no ball placed.\n\nTakahashi, who is very patient, will do the following operation 10^{100} times:\n\nPlace A blue balls at the end of the row of balls already placed. Then, place B red balls at the end of the row.\n\nHow many blue balls will be there among the first N balls in the row of balls made this way?\n\nConstraints\n\n1 \\leq N \\leq 10^{18}\n\nA, B \\geq 0\n\n0 < A + B \\leq 10^{18}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN A B\n\nOutput\n\nPrint the number of blue balls that will be there among the first N balls in the row of balls.\n\nSample Input 1\n\n8 3 4\n\nSample Output 1\n\n4\n\nLet b denote a blue ball, and r denote a red ball. The first eight balls in the row will be bbbrrrrb, among which there are four blue balls.\n\nSample Input 2\n\n8 0 4\n\nSample Output 2\n\n0\n\nHe placed only red balls from the beginning.\n\nSample Input 3\n\n6 2 4\n\nSample Output 3\n\n2\n\nAmong bbrrrr, there are two blue balls.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 340, "cpu_time_ms": 2, "memory_kb": 1152}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s970242737", "group_id": "codeNet:p02755", "input_text": "let () = Scanf.scanf \"%d %d\" @@ fun a b ->\n Printf.printf \"%d\\n\" @@\n try\n List.find (fun i -> 2 * i / 25 = a && i / 10 = b) @@\n Array.to_list @@\n Array.init 20000 @@ fun i -> i\n with Not_found -> -1", "language": "OCaml", "metadata": {"date": 1583633895, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02755.html", "problem_id": "p02755", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02755/input.txt", "sample_output_relpath": "derived/input_output/data/p02755/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02755/OCaml/s970242737.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s970242737", "user_id": "u504158101"}, "prompt_components": {"gold_output": "25\n", "input_to_evaluate": "let () = Scanf.scanf \"%d %d\" @@ fun a b ->\n Printf.printf \"%d\\n\" @@\n try\n List.find (fun i -> 2 * i / 25 = a && i / 10 = b) @@\n Array.to_list @@\n Array.init 20000 @@ fun i -> i\n with Not_found -> -1", "problem_context": "Score : 300 points\n\nProblem Statement\n\nFind the price of a product before tax such that, when the consumption tax rate is 8 percent and 10 percent, the amount of consumption tax levied on it is A yen and B yen, respectively. (Yen is the currency of Japan.)\n\nHere, the price before tax must be a positive integer, and the amount of consumption tax is rounded down to the nearest integer.\n\nIf multiple prices satisfy the condition, print the lowest such price; if no price satisfies the condition, print -1.\n\nConstraints\n\n1 \\leq A \\leq B \\leq 100\n\nA and B are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nIf there is a price that satisfies the condition, print an integer representing the lowest such price; otherwise, print -1.\n\nSample Input 1\n\n2 2\n\nSample Output 1\n\n25\n\nIf the price of a product before tax is 25 yen, the amount of consumption tax levied on it is:\n\nWhen the consumption tax rate is 8 percent: \\lfloor 25 \\times 0.08 \\rfloor = \\lfloor 2 \\rfloor = 2 yen.\n\nWhen the consumption tax rate is 10 percent: \\lfloor 25 \\times 0.1 \\rfloor = \\lfloor 2.5 \\rfloor = 2 yen.\n\nThus, the price of 25 yen satisfies the condition. There are other possible prices, such as 26 yen, but print the minimum such price, 25.\n\nSample Input 2\n\n8 10\n\nSample Output 2\n\n100\n\nIf the price of a product before tax is 100 yen, the amount of consumption tax levied on it is:\n\nWhen the consumption tax rate is 8 percent: \\lfloor 100 \\times 0.08 \\rfloor = 8 yen.\n\nWhen the consumption tax rate is 10 percent: \\lfloor 100 \\times 0.1 \\rfloor = 10 yen.\n\nSample Input 3\n\n19 99\n\nSample Output 3\n\n-1\n\nThere is no price before tax satisfying this condition, so print -1.", "sample_input": "2 2\n"}, "reference_outputs": ["25\n"], "source_document_id": "p02755", "source_text": "Score : 300 points\n\nProblem Statement\n\nFind the price of a product before tax such that, when the consumption tax rate is 8 percent and 10 percent, the amount of consumption tax levied on it is A yen and B yen, respectively. (Yen is the currency of Japan.)\n\nHere, the price before tax must be a positive integer, and the amount of consumption tax is rounded down to the nearest integer.\n\nIf multiple prices satisfy the condition, print the lowest such price; if no price satisfies the condition, print -1.\n\nConstraints\n\n1 \\leq A \\leq B \\leq 100\n\nA and B are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nIf there is a price that satisfies the condition, print an integer representing the lowest such price; otherwise, print -1.\n\nSample Input 1\n\n2 2\n\nSample Output 1\n\n25\n\nIf the price of a product before tax is 25 yen, the amount of consumption tax levied on it is:\n\nWhen the consumption tax rate is 8 percent: \\lfloor 25 \\times 0.08 \\rfloor = \\lfloor 2 \\rfloor = 2 yen.\n\nWhen the consumption tax rate is 10 percent: \\lfloor 25 \\times 0.1 \\rfloor = \\lfloor 2.5 \\rfloor = 2 yen.\n\nThus, the price of 25 yen satisfies the condition. There are other possible prices, such as 26 yen, but print the minimum such price, 25.\n\nSample Input 2\n\n8 10\n\nSample Output 2\n\n100\n\nIf the price of a product before tax is 100 yen, the amount of consumption tax levied on it is:\n\nWhen the consumption tax rate is 8 percent: \\lfloor 100 \\times 0.08 \\rfloor = 8 yen.\n\nWhen the consumption tax rate is 10 percent: \\lfloor 100 \\times 0.1 \\rfloor = 10 yen.\n\nSample Input 3\n\n19 99\n\nSample Output 3\n\n-1\n\nThere is no price before tax satisfying this condition, so print -1.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 210, "cpu_time_ms": 2, "memory_kb": 4480}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s908590413", "group_id": "codeNet:p02755", "input_text": "Scanf.scanf \"%d %d\" (fun a b ->\n let rec loop i =\n if i > 1000 then -1 else\n if i * 8 / 100 = a && i / 10 = b then i else\n loop (i + 1)\n in\n loop 1 |> Printf.printf \"%d\\n\"\n)", "language": "OCaml", "metadata": {"date": 1583633422, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02755.html", "problem_id": "p02755", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02755/input.txt", "sample_output_relpath": "derived/input_output/data/p02755/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02755/OCaml/s908590413.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s908590413", "user_id": "u342443598"}, "prompt_components": {"gold_output": "25\n", "input_to_evaluate": "Scanf.scanf \"%d %d\" (fun a b ->\n let rec loop i =\n if i > 1000 then -1 else\n if i * 8 / 100 = a && i / 10 = b then i else\n loop (i + 1)\n in\n loop 1 |> Printf.printf \"%d\\n\"\n)", "problem_context": "Score : 300 points\n\nProblem Statement\n\nFind the price of a product before tax such that, when the consumption tax rate is 8 percent and 10 percent, the amount of consumption tax levied on it is A yen and B yen, respectively. (Yen is the currency of Japan.)\n\nHere, the price before tax must be a positive integer, and the amount of consumption tax is rounded down to the nearest integer.\n\nIf multiple prices satisfy the condition, print the lowest such price; if no price satisfies the condition, print -1.\n\nConstraints\n\n1 \\leq A \\leq B \\leq 100\n\nA and B are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nIf there is a price that satisfies the condition, print an integer representing the lowest such price; otherwise, print -1.\n\nSample Input 1\n\n2 2\n\nSample Output 1\n\n25\n\nIf the price of a product before tax is 25 yen, the amount of consumption tax levied on it is:\n\nWhen the consumption tax rate is 8 percent: \\lfloor 25 \\times 0.08 \\rfloor = \\lfloor 2 \\rfloor = 2 yen.\n\nWhen the consumption tax rate is 10 percent: \\lfloor 25 \\times 0.1 \\rfloor = \\lfloor 2.5 \\rfloor = 2 yen.\n\nThus, the price of 25 yen satisfies the condition. There are other possible prices, such as 26 yen, but print the minimum such price, 25.\n\nSample Input 2\n\n8 10\n\nSample Output 2\n\n100\n\nIf the price of a product before tax is 100 yen, the amount of consumption tax levied on it is:\n\nWhen the consumption tax rate is 8 percent: \\lfloor 100 \\times 0.08 \\rfloor = 8 yen.\n\nWhen the consumption tax rate is 10 percent: \\lfloor 100 \\times 0.1 \\rfloor = 10 yen.\n\nSample Input 3\n\n19 99\n\nSample Output 3\n\n-1\n\nThere is no price before tax satisfying this condition, so print -1.", "sample_input": "2 2\n"}, "reference_outputs": ["25\n"], "source_document_id": "p02755", "source_text": "Score : 300 points\n\nProblem Statement\n\nFind the price of a product before tax such that, when the consumption tax rate is 8 percent and 10 percent, the amount of consumption tax levied on it is A yen and B yen, respectively. (Yen is the currency of Japan.)\n\nHere, the price before tax must be a positive integer, and the amount of consumption tax is rounded down to the nearest integer.\n\nIf multiple prices satisfy the condition, print the lowest such price; if no price satisfies the condition, print -1.\n\nConstraints\n\n1 \\leq A \\leq B \\leq 100\n\nA and B are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nIf there is a price that satisfies the condition, print an integer representing the lowest such price; otherwise, print -1.\n\nSample Input 1\n\n2 2\n\nSample Output 1\n\n25\n\nIf the price of a product before tax is 25 yen, the amount of consumption tax levied on it is:\n\nWhen the consumption tax rate is 8 percent: \\lfloor 25 \\times 0.08 \\rfloor = \\lfloor 2 \\rfloor = 2 yen.\n\nWhen the consumption tax rate is 10 percent: \\lfloor 25 \\times 0.1 \\rfloor = \\lfloor 2.5 \\rfloor = 2 yen.\n\nThus, the price of 25 yen satisfies the condition. There are other possible prices, such as 26 yen, but print the minimum such price, 25.\n\nSample Input 2\n\n8 10\n\nSample Output 2\n\n100\n\nIf the price of a product before tax is 100 yen, the amount of consumption tax levied on it is:\n\nWhen the consumption tax rate is 8 percent: \\lfloor 100 \\times 0.08 \\rfloor = 8 yen.\n\nWhen the consumption tax rate is 10 percent: \\lfloor 100 \\times 0.1 \\rfloor = 10 yen.\n\nSample Input 3\n\n19 99\n\nSample Output 3\n\n-1\n\nThere is no price before tax satisfying this condition, so print -1.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s731736061", "group_id": "codeNet:p02756", "input_text": "open Batteries\nlet s = read_line ()\nlet q = read_int ()\n \nlet string_rev s =\n let len = String.length s in\n String.init len (fun i -> s.[len - 1 - i])\n \nlet add_p result line_list reversed =\n match List.nth line_list 1 with\n | \"1\" -> if not reversed then (List.nth line_list 2) ^ result else result ^ (List.nth line_list 2)\n | _ -> if not reversed then result ^ (List.nth line_list 2) else (List.nth line_list 2) ^ result\n \n \nlet reverse p =\n match p with\n | true -> false\n | false -> true\n \nlet rec ans r s reversed = \n match s with\n | 0 -> if not reversed then r else string_rev r\n | _ -> match read_line() with\n | x -> match x.[0] with\n | '1' -> ans r (s-1) (reverse reversed)\n | _ -> ans (add_p r (String.split_on_char ' ' x) reversed) (s-1) reversed\n \nlet _ = print_endline (ans s q false)\n", "language": "OCaml", "metadata": {"date": 1583640691, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02756.html", "problem_id": "p02756", "resource_group": "low_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/OCaml/s731736061.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s731736061", "user_id": "u511870776"}, "prompt_components": {"gold_output": "cpa\n", "input_to_evaluate": "open Batteries\nlet s = read_line ()\nlet q = read_int ()\n \nlet string_rev s =\n let len = String.length s in\n String.init len (fun i -> s.[len - 1 - i])\n \nlet add_p result line_list reversed =\n match List.nth line_list 1 with\n | \"1\" -> if not reversed then (List.nth line_list 2) ^ result else result ^ (List.nth line_list 2)\n | _ -> if not reversed then result ^ (List.nth line_list 2) else (List.nth line_list 2) ^ result\n \n \nlet reverse p =\n match p with\n | true -> false\n | false -> true\n \nlet rec ans r s reversed = \n match s with\n | 0 -> if not reversed then r else string_rev r\n | _ -> match read_line() with\n | x -> match x.[0] with\n | '1' -> ans r (s-1) (reverse reversed)\n | _ -> ans (add_p r (String.split_on_char ' ' x) reversed) (s-1) reversed\n \nlet _ = print_endline (ans s q false)\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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 2104, "memory_kb": 9140}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s683327117", "group_id": "codeNet:p02757", "input_text": "module IntMap = Map.Make (struct\n type t = int\n let compare = compare\nend)\n\nlet rec power ( * ) e m n =\n if n <= 0 then e\n else power ( * ) (if n land 1 = 0 then e else m * e) (m * m) (n lsr 1)\n\nlet () = Scanf.scanf \"%d %d\\n%s\" @@ fun n p s ->\n let ( +^ ) x y = (x + y) mod p in\n let neg x = (p - x) mod p in\n let ( *^ ) x y = (x * y) mod p in\n let inv x = power ( *^ ) 1 x (p - 2) in\n let acc = Array.make (n + 1) 0 in\n let radix = Array.make (n + 1) 1 in\n for i = 0 to n - 1 do\n radix.(i + 1) <- 10 *^ radix.(i);\n acc.(i + 1) <- 10 *^ acc.(i) +^ (Char.code s.[i] - Char.code '0');\n done;\n let ms = Array.make (n + 2) IntMap.empty in\n for i = n downto 0 do\n ms.(i) <- IntMap.add acc.(i) (1 + try IntMap.find acc.(i) ms.(i + 1) with Not_found -> 0) ms.(i + 1)\n done;\n Printf.printf \"%d\\n\" @@\n Array.fold_left ( + ) 0 @@\n Array.init (n + 1) @@ fun i ->\n try IntMap.find (neg (acc.(i) *^ inv radix.(i))) ms.(i + 1) with Not_found -> 0", "language": "OCaml", "metadata": {"date": 1583635914, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02757.html", "problem_id": "p02757", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02757/input.txt", "sample_output_relpath": "derived/input_output/data/p02757/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02757/OCaml/s683327117.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s683327117", "user_id": "u504158101"}, "prompt_components": {"gold_output": "6\n", "input_to_evaluate": "module IntMap = Map.Make (struct\n type t = int\n let compare = compare\nend)\n\nlet rec power ( * ) e m n =\n if n <= 0 then e\n else power ( * ) (if n land 1 = 0 then e else m * e) (m * m) (n lsr 1)\n\nlet () = Scanf.scanf \"%d %d\\n%s\" @@ fun n p s ->\n let ( +^ ) x y = (x + y) mod p in\n let neg x = (p - x) mod p in\n let ( *^ ) x y = (x * y) mod p in\n let inv x = power ( *^ ) 1 x (p - 2) in\n let acc = Array.make (n + 1) 0 in\n let radix = Array.make (n + 1) 1 in\n for i = 0 to n - 1 do\n radix.(i + 1) <- 10 *^ radix.(i);\n acc.(i + 1) <- 10 *^ acc.(i) +^ (Char.code s.[i] - Char.code '0');\n done;\n let ms = Array.make (n + 2) IntMap.empty in\n for i = n downto 0 do\n ms.(i) <- IntMap.add acc.(i) (1 + try IntMap.find acc.(i) ms.(i + 1) with Not_found -> 0) ms.(i + 1)\n done;\n Printf.printf \"%d\\n\" @@\n Array.fold_left ( + ) 0 @@\n Array.init (n + 1) @@ fun i ->\n try IntMap.find (neg (acc.(i) *^ inv radix.(i))) ms.(i + 1) with Not_found -> 0", "problem_context": "Score : 500 points\n\nProblem Statement\n\nTakahashi has a string S of length N consisting of digits from 0 through 9.\n\nHe loves the prime number P. He wants to know how many non-empty (contiguous) substrings of S - there are N \\times (N + 1) / 2 of them - are divisible by P when regarded as integers written in base ten.\n\nHere substrings starting with a 0 also count, and substrings originated from different positions in S are distinguished, even if they are equal as strings or integers.\n\nCompute this count to help Takahashi.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\nS consists of digits.\n\n|S| = N\n\n2 \\leq P \\leq 10000\n\nP is a prime number.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN P\nS\n\nOutput\n\nPrint the number of non-empty (contiguous) substrings of S that are divisible by P when regarded as an integer written in base ten.\n\nSample Input 1\n\n4 3\n3543\n\nSample Output 1\n\n6\n\nHere S = 3543. There are ten non-empty (contiguous) substrings of S:\n\n3: divisible by 3.\n\n35: not divisible by 3.\n\n354: divisible by 3.\n\n3543: divisible by 3.\n\n5: not divisible by 3.\n\n54: divisible by 3.\n\n543: divisible by 3.\n\n4: not divisible by 3.\n\n43: not divisible by 3.\n\n3: divisible by 3.\n\nSix of these are divisible by 3, so print 6.\n\nSample Input 2\n\n4 2\n2020\n\nSample Output 2\n\n10\n\nHere S = 2020. There are ten non-empty (contiguous) substrings of S, all of which are divisible by 2, so print 10.\n\nNote that substrings beginning with a 0 also count.\n\nSample Input 3\n\n20 11\n33883322005544116655\n\nSample Output 3\n\n68", "sample_input": "4 3\n3543\n"}, "reference_outputs": ["6\n"], "source_document_id": "p02757", "source_text": "Score : 500 points\n\nProblem Statement\n\nTakahashi has a string S of length N consisting of digits from 0 through 9.\n\nHe loves the prime number P. He wants to know how many non-empty (contiguous) substrings of S - there are N \\times (N + 1) / 2 of them - are divisible by P when regarded as integers written in base ten.\n\nHere substrings starting with a 0 also count, and substrings originated from different positions in S are distinguished, even if they are equal as strings or integers.\n\nCompute this count to help Takahashi.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\nS consists of digits.\n\n|S| = N\n\n2 \\leq P \\leq 10000\n\nP is a prime number.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN P\nS\n\nOutput\n\nPrint the number of non-empty (contiguous) substrings of S that are divisible by P when regarded as an integer written in base ten.\n\nSample Input 1\n\n4 3\n3543\n\nSample Output 1\n\n6\n\nHere S = 3543. There are ten non-empty (contiguous) substrings of S:\n\n3: divisible by 3.\n\n35: not divisible by 3.\n\n354: divisible by 3.\n\n3543: divisible by 3.\n\n5: not divisible by 3.\n\n54: divisible by 3.\n\n543: divisible by 3.\n\n4: not divisible by 3.\n\n43: not divisible by 3.\n\n3: divisible by 3.\n\nSix of these are divisible by 3, so print 6.\n\nSample Input 2\n\n4 2\n2020\n\nSample Output 2\n\n10\n\nHere S = 2020. There are ten non-empty (contiguous) substrings of S, all of which are divisible by 2, so print 10.\n\nNote that substrings beginning with a 0 also count.\n\nSample Input 3\n\n20 11\n33883322005544116655\n\nSample Output 3\n\n68", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 962, "cpu_time_ms": 679, "memory_kb": 130104}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s831978259", "group_id": "codeNet:p02757", "input_text": "Scanf.sscanf (read_line ()) \"%d %d\" (fun n p ->\n let s = read_line () in\n let dp = Array.make_matrix 2 p 0 in\n let rec loop i acc =\n if i = n then acc else (\n let cur = i mod 2 in\n let next = 1 - cur in\n let c = int_of_char s.[i] - int_of_char '0' in\n for j = 0 to p - 1 do dp.(next).(j) <- 0 done;\n for j = 0 to p - 1 do\n let v = (j * 10 + c) mod p in\n dp.(next).(v) <- dp.(next).(v) + dp.(cur).(j)\n done;\n dp.(next).(c mod p) <- dp.(next).(c mod p) + 1;\n loop (i + 1) (acc + dp.(next).(0))\n )\n in\n loop 0 0 |> Printf.printf \"%d\\n\"\n)", "language": "OCaml", "metadata": {"date": 1583635348, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02757.html", "problem_id": "p02757", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02757/input.txt", "sample_output_relpath": "derived/input_output/data/p02757/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02757/OCaml/s831978259.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s831978259", "user_id": "u342443598"}, "prompt_components": {"gold_output": "6\n", "input_to_evaluate": "Scanf.sscanf (read_line ()) \"%d %d\" (fun n p ->\n let s = read_line () in\n let dp = Array.make_matrix 2 p 0 in\n let rec loop i acc =\n if i = n then acc else (\n let cur = i mod 2 in\n let next = 1 - cur in\n let c = int_of_char s.[i] - int_of_char '0' in\n for j = 0 to p - 1 do dp.(next).(j) <- 0 done;\n for j = 0 to p - 1 do\n let v = (j * 10 + c) mod p in\n dp.(next).(v) <- dp.(next).(v) + dp.(cur).(j)\n done;\n dp.(next).(c mod p) <- dp.(next).(c mod p) + 1;\n loop (i + 1) (acc + dp.(next).(0))\n )\n in\n loop 0 0 |> Printf.printf \"%d\\n\"\n)", "problem_context": "Score : 500 points\n\nProblem Statement\n\nTakahashi has a string S of length N consisting of digits from 0 through 9.\n\nHe loves the prime number P. He wants to know how many non-empty (contiguous) substrings of S - there are N \\times (N + 1) / 2 of them - are divisible by P when regarded as integers written in base ten.\n\nHere substrings starting with a 0 also count, and substrings originated from different positions in S are distinguished, even if they are equal as strings or integers.\n\nCompute this count to help Takahashi.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\nS consists of digits.\n\n|S| = N\n\n2 \\leq P \\leq 10000\n\nP is a prime number.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN P\nS\n\nOutput\n\nPrint the number of non-empty (contiguous) substrings of S that are divisible by P when regarded as an integer written in base ten.\n\nSample Input 1\n\n4 3\n3543\n\nSample Output 1\n\n6\n\nHere S = 3543. There are ten non-empty (contiguous) substrings of S:\n\n3: divisible by 3.\n\n35: not divisible by 3.\n\n354: divisible by 3.\n\n3543: divisible by 3.\n\n5: not divisible by 3.\n\n54: divisible by 3.\n\n543: divisible by 3.\n\n4: not divisible by 3.\n\n43: not divisible by 3.\n\n3: divisible by 3.\n\nSix of these are divisible by 3, so print 6.\n\nSample Input 2\n\n4 2\n2020\n\nSample Output 2\n\n10\n\nHere S = 2020. There are ten non-empty (contiguous) substrings of S, all of which are divisible by 2, so print 10.\n\nNote that substrings beginning with a 0 also count.\n\nSample Input 3\n\n20 11\n33883322005544116655\n\nSample Output 3\n\n68", "sample_input": "4 3\n3543\n"}, "reference_outputs": ["6\n"], "source_document_id": "p02757", "source_text": "Score : 500 points\n\nProblem Statement\n\nTakahashi has a string S of length N consisting of digits from 0 through 9.\n\nHe loves the prime number P. He wants to know how many non-empty (contiguous) substrings of S - there are N \\times (N + 1) / 2 of them - are divisible by P when regarded as integers written in base ten.\n\nHere substrings starting with a 0 also count, and substrings originated from different positions in S are distinguished, even if they are equal as strings or integers.\n\nCompute this count to help Takahashi.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\nS consists of digits.\n\n|S| = N\n\n2 \\leq P \\leq 10000\n\nP is a prime number.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN P\nS\n\nOutput\n\nPrint the number of non-empty (contiguous) substrings of S that are divisible by P when regarded as an integer written in base ten.\n\nSample Input 1\n\n4 3\n3543\n\nSample Output 1\n\n6\n\nHere S = 3543. There are ten non-empty (contiguous) substrings of S:\n\n3: divisible by 3.\n\n35: not divisible by 3.\n\n354: divisible by 3.\n\n3543: divisible by 3.\n\n5: not divisible by 3.\n\n54: divisible by 3.\n\n543: divisible by 3.\n\n4: not divisible by 3.\n\n43: not divisible by 3.\n\n3: divisible by 3.\n\nSix of these are divisible by 3, so print 6.\n\nSample Input 2\n\n4 2\n2020\n\nSample Output 2\n\n10\n\nHere S = 2020. There are ten non-empty (contiguous) substrings of S, all of which are divisible by 2, so print 10.\n\nNote that substrings beginning with a 0 also count.\n\nSample Input 3\n\n20 11\n33883322005544116655\n\nSample Output 3\n\n68", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 681, "cpu_time_ms": 2103, "memory_kb": 2816}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s990399423", "group_id": "codeNet:p02759", "input_text": "open Batteries\nopen BatPrintf\n\nlet scan fmt f =\n Scanf.sscanf (read_line ()) fmt f\n\nlet scan_list cnv =\n read_line ()\n |> String.split_on_char ' '\n |> List.map cnv\n\nlet scan_listn n cnv =\n (0 --^ n) |> Enum.map (fun _ -> (cnv % read_line) ())\n\nlet bsearch_ge arr a =\n let l = Array.length arr in\n match Array.bsearch Int.ord arr a with\n | `All_lower -> l\n | `All_bigger -> 0\n | `Just_after n -> l - n -1\n | `At n -> l - n\n | `Empty -> 0\n\nlet rec zip xs ys =\n match xs, ys with\n | [], _ -> []\n | _, [] -> []\n | x::xs, y::ys ->\n (x, y) :: zip xs ys\n\nlet square x = x * x\n\nlet dbg n = Printf.eprintf \"%s\\n\" @@ dump n; n\n\nlet n = scan \"%d\" identity\n\nlet () =\n succ n / 2\n |> printf \"%d\"\n", "language": "OCaml", "metadata": {"date": 1583715860, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02759.html", "problem_id": "p02759", "resource_group": "low_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/OCaml/s990399423.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s990399423", "user_id": "u802614675"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "open Batteries\nopen BatPrintf\n\nlet scan fmt f =\n Scanf.sscanf (read_line ()) fmt f\n\nlet scan_list cnv =\n read_line ()\n |> String.split_on_char ' '\n |> List.map cnv\n\nlet scan_listn n cnv =\n (0 --^ n) |> Enum.map (fun _ -> (cnv % read_line) ())\n\nlet bsearch_ge arr a =\n let l = Array.length arr in\n match Array.bsearch Int.ord arr a with\n | `All_lower -> l\n | `All_bigger -> 0\n | `Just_after n -> l - n -1\n | `At n -> l - n\n | `Empty -> 0\n\nlet rec zip xs ys =\n match xs, ys with\n | [], _ -> []\n | _, [] -> []\n | x::xs, y::ys ->\n (x, y) :: zip xs ys\n\nlet square x = x * x\n\nlet dbg n = Printf.eprintf \"%s\\n\" @@ dump n; n\n\nlet n = scan \"%d\" identity\n\nlet () =\n succ n / 2\n |> printf \"%d\"\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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 704, "cpu_time_ms": 3, "memory_kb": 3072}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s565918818", "group_id": "codeNet:p02759", "input_text": "let () = \n let n = read_int () in\n let num_of_paper = (n + 1) / 2 in\n print_int num_of_paper", "language": "OCaml", "metadata": {"date": 1583191587, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02759.html", "problem_id": "p02759", "resource_group": "low_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/OCaml/s565918818.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s565918818", "user_id": "u575440531"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "let () = \n let n = read_int () in\n let num_of_paper = (n + 1) / 2 in\n print_int num_of_paper", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s360147129", "group_id": "codeNet:p02760", "input_text": "open Array\nlet () =\n let arr = List.concat (to_list (init 3 @@ fun _ -> Scanf.scanf \"%d %d %d\\n\" @@ fun a b c -> [a; b; c])) in\n let n = read_int () in\n let check = Array.make_matrix 3 3 false in\n for i = 0 to n-1 do\n Scanf.scanf \"%d\\n\" @@ fun x ->\n if List.mem x arr then List.iteri (fun i a -> if a = x then check.(i / 3).(i mod 3) <- true) arr\n done;\n let ans = ref false in\n for i = 0 to 2 do\n if check.(i).(0) && check.(i).(1) && check.(i).(2) then ans := true (* 横 *)\n else if check.(0).(i) && check.(1).(i) && check.(2).(i) then ans := true (* たて *)\n done;\n if check.(0).(0) && check.(1).(1) && check.(2).(2) then ans := true;\n if check.(0).(2) && check.(1).(1) && check.(2).(0) then ans := true;\n print_endline (if !ans then \"Yes\" else \"No\")", "language": "OCaml", "metadata": {"date": 1591466542, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02760.html", "problem_id": "p02760", "resource_group": "low_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/OCaml/s360147129.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s360147129", "user_id": "u307426615"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "open Array\nlet () =\n let arr = List.concat (to_list (init 3 @@ fun _ -> Scanf.scanf \"%d %d %d\\n\" @@ fun a b c -> [a; b; c])) in\n let n = read_int () in\n let check = Array.make_matrix 3 3 false in\n for i = 0 to n-1 do\n Scanf.scanf \"%d\\n\" @@ fun x ->\n if List.mem x arr then List.iteri (fun i a -> if a = x then check.(i / 3).(i mod 3) <- true) arr\n done;\n let ans = ref false in\n for i = 0 to 2 do\n if check.(i).(0) && check.(i).(1) && check.(i).(2) then ans := true (* 横 *)\n else if check.(0).(i) && check.(1).(i) && check.(2).(i) then ans := true (* たて *)\n done;\n if check.(0).(0) && check.(1).(1) && check.(2).(2) then ans := true;\n if check.(0).(2) && check.(1).(1) && check.(2).(0) then ans := true;\n print_endline (if !ans then \"Yes\" else \"No\")", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 778, "cpu_time_ms": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s362096064", "group_id": "codeNet:p02760", "input_text": "(* 重複なし順列 *)\nlet rec perm n ls =\n if n = 0 then [[]]\n else flatmap (fun x -> List.map (fun y -> x :: y)\n (perm (n - 1) (remove x ls)))\n ls\nand remove x ls = List.filter (fun y -> x <> y) ls\nand flatten = function\n [] -> []\n| x::xs -> x @ (flatten xs)\nand flatmap func ls = flatten (List.map func ls)\n\n\nlet t = Scanf.sscanf (read_line ()) \"%d %d %d\" (fun a b c -> [a; b; c])\nlet c = Scanf.sscanf (read_line ()) \"%d %d %d\" (fun a b c -> [a; b; c])\nlet b = Scanf.sscanf (read_line ()) \"%d %d %d\" (fun a b c -> [a; b; c])\n\nlet bingo_list = [t; c; b; \n [List.hd t; List.nth c 1; List.nth b 2];\n [List.nth t 2; List.nth c 1; List.hd b];\n\n [List.hd t; List.hd c; List.hd b];\n [List.nth t 1; List.nth c 1; List.nth b 1];\n [List.nth t 2; List.nth c 2; List.nth b 2];\n ]\n\nlet n = read_int ()\n\nlet rec read_lines_to_int_list count =\n match count with\n | 0 -> []\n | _ -> read_int () :: read_lines_to_int_list (count-1)\n\nlet value_list = read_lines_to_int_list n\nlet all_perms = perm 3 value_list\n\nlet rec ans lst = match lst with\n [] -> false\n | first :: rest -> if List.exists (fun x -> x = first) all_perms then true else ans rest\n\nlet () = if ans bingo_list then print_endline \"Yes\" else print_endline \"No\"\n", "language": "OCaml", "metadata": {"date": 1583686947, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02760.html", "problem_id": "p02760", "resource_group": "low_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/OCaml/s362096064.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s362096064", "user_id": "u511870776"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "(* 重複なし順列 *)\nlet rec perm n ls =\n if n = 0 then [[]]\n else flatmap (fun x -> List.map (fun y -> x :: y)\n (perm (n - 1) (remove x ls)))\n ls\nand remove x ls = List.filter (fun y -> x <> y) ls\nand flatten = function\n [] -> []\n| x::xs -> x @ (flatten xs)\nand flatmap func ls = flatten (List.map func ls)\n\n\nlet t = Scanf.sscanf (read_line ()) \"%d %d %d\" (fun a b c -> [a; b; c])\nlet c = Scanf.sscanf (read_line ()) \"%d %d %d\" (fun a b c -> [a; b; c])\nlet b = Scanf.sscanf (read_line ()) \"%d %d %d\" (fun a b c -> [a; b; c])\n\nlet bingo_list = [t; c; b; \n [List.hd t; List.nth c 1; List.nth b 2];\n [List.nth t 2; List.nth c 1; List.hd b];\n\n [List.hd t; List.hd c; List.hd b];\n [List.nth t 1; List.nth c 1; List.nth b 1];\n [List.nth t 2; List.nth c 2; List.nth b 2];\n ]\n\nlet n = read_int ()\n\nlet rec read_lines_to_int_list count =\n match count with\n | 0 -> []\n | _ -> read_int () :: read_lines_to_int_list (count-1)\n\nlet value_list = read_lines_to_int_list n\nlet all_perms = perm 3 value_list\n\nlet rec ans lst = match lst with\n [] -> false\n | first :: rest -> if List.exists (fun x -> x = first) all_perms then true else ans rest\n\nlet () = if ans bingo_list then print_endline \"Yes\" else print_endline \"No\"\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nWe have a bingo card with a 3\\times3 grid. The square at the i-th row from the top and the j-th column from the left contains the number A_{i, j}.\n\nThe MC will choose N numbers, b_1, b_2, \\cdots, b_N. If our bingo sheet contains some of those numbers, we will mark them on our sheet.\n\nDetermine whether we will have a bingo when the N numbers are chosen, that is, the sheet will contain three marked numbers in a row, column, or diagonal.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq A_{i, j} \\leq 100\n\nA_{i_1, j_1} \\neq A_{i_2, j_2} ((i_1, j_1) \\neq (i_2, j_2))\n\n1 \\leq N \\leq 10\n\n1 \\leq b_i \\leq 100\n\nb_i \\neq b_j (i \\neq j)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA_{1, 1} A_{1, 2} A_{1, 3}\nA_{2, 1} A_{2, 2} A_{2, 3}\nA_{3, 1} A_{3, 2} A_{3, 3}\nN\nb_1\n\\vdots\nb_N\n\nOutput\n\nIf we will have a bingo, print Yes; otherwise, print No.\n\nSample Input 1\n\n84 97 66\n79 89 11\n61 59 7\n7\n89\n7\n87\n79\n24\n84\n30\n\nSample Output 1\n\nYes\n\nWe will mark A_{1, 1}, A_{2, 1}, A_{2, 2}, A_{3, 3}, and complete the diagonal from the top-left to the bottom-right.\n\nSample Input 2\n\n41 7 46\n26 89 2\n78 92 8\n5\n6\n45\n16\n57\n17\n\nSample Output 2\n\nNo\n\nWe will mark nothing.\n\nSample Input 3\n\n60 88 34\n92 41 43\n65 73 48\n10\n60\n43\n88\n11\n48\n73\n65\n41\n92\n34\n\nSample Output 3\n\nYes\n\nWe will mark all the squares.", "sample_input": "84 97 66\n79 89 11\n61 59 7\n7\n89\n7\n87\n79\n24\n84\n30\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02760", "source_text": "Score : 200 points\n\nProblem Statement\n\nWe have a bingo card with a 3\\times3 grid. The square at the i-th row from the top and the j-th column from the left contains the number A_{i, j}.\n\nThe MC will choose N numbers, b_1, b_2, \\cdots, b_N. If our bingo sheet contains some of those numbers, we will mark them on our sheet.\n\nDetermine whether we will have a bingo when the N numbers are chosen, that is, the sheet will contain three marked numbers in a row, column, or diagonal.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq A_{i, j} \\leq 100\n\nA_{i_1, j_1} \\neq A_{i_2, j_2} ((i_1, j_1) \\neq (i_2, j_2))\n\n1 \\leq N \\leq 10\n\n1 \\leq b_i \\leq 100\n\nb_i \\neq b_j (i \\neq j)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA_{1, 1} A_{1, 2} A_{1, 3}\nA_{2, 1} A_{2, 2} A_{2, 3}\nA_{3, 1} A_{3, 2} A_{3, 3}\nN\nb_1\n\\vdots\nb_N\n\nOutput\n\nIf we will have a bingo, print Yes; otherwise, print No.\n\nSample Input 1\n\n84 97 66\n79 89 11\n61 59 7\n7\n89\n7\n87\n79\n24\n84\n30\n\nSample Output 1\n\nYes\n\nWe will mark A_{1, 1}, A_{2, 1}, A_{2, 2}, A_{3, 3}, and complete the diagonal from the top-left to the bottom-right.\n\nSample Input 2\n\n41 7 46\n26 89 2\n78 92 8\n5\n6\n45\n16\n57\n17\n\nSample Output 2\n\nNo\n\nWe will mark nothing.\n\nSample Input 3\n\n60 88 34\n92 41 43\n65 73 48\n10\n60\n43\n88\n11\n48\n73\n65\n41\n92\n34\n\nSample Output 3\n\nYes\n\nWe will mark all the squares.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1294, "cpu_time_ms": 2, "memory_kb": 4480}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s369130479", "group_id": "codeNet:p02762", "input_text": "module S = Set.Make (struct type t = int let compare = compare end) ;;\n\nScanf.scanf \"%d %d %d\" (fun n m k ->\n let friend = Array.make n S.empty in\n let block = Array.make n S.empty in\n for i = 1 to m do\n Scanf.scanf \" %d %d\" (fun a b ->\n let a = a - 1 in let b = b - 1 in\n friend.(a) <- S.add b friend.(a);\n friend.(b) <- S.add a friend.(b);\n )\n done;\n for i = 1 to k do\n Scanf.scanf \" %d %d\" (fun c d ->\n let c = c - 1 in let d = d - 1 in\n block.(c) <- S.add d block.(c);\n block.(d) <- S.add c block.(d);\n )\n done;\n let clust = Array.make n (-1) in\n let cm = Array.make n S.empty in\n let rec loop i cl =\n if i < n then (\n let cl = if clust.(i) <> -1 then cl else (\n let rec collect acc next = function\n | [] -> if S.is_empty next then acc else collect acc S.empty (S.elements next)\n | hd :: tl ->\n let acc = S.add hd acc in\n let next = S.union (S.diff friend.(hd) acc) next in\n collect acc next tl\n in\n let acc = collect S.empty (S.singleton i) [] in\n S.iter (fun v -> clust.(v) <- cl) acc;\n cm.(cl) <- acc;\n cl + 1\n )\n in\n let c = S.cardinal (S.diff (S.diff cm.(clust.(i)) block.(i)) friend.(i)) in\n let () = Printf.printf \"%d \" (c - 1) in\n loop (i + 1) cl\n )\n in\n loop 0 0\n)", "language": "OCaml", "metadata": {"date": 1583118059, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02762.html", "problem_id": "p02762", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02762/input.txt", "sample_output_relpath": "derived/input_output/data/p02762/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02762/OCaml/s369130479.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s369130479", "user_id": "u342443598"}, "prompt_components": {"gold_output": "0 1 0 1\n", "input_to_evaluate": "module S = Set.Make (struct type t = int let compare = compare end) ;;\n\nScanf.scanf \"%d %d %d\" (fun n m k ->\n let friend = Array.make n S.empty in\n let block = Array.make n S.empty in\n for i = 1 to m do\n Scanf.scanf \" %d %d\" (fun a b ->\n let a = a - 1 in let b = b - 1 in\n friend.(a) <- S.add b friend.(a);\n friend.(b) <- S.add a friend.(b);\n )\n done;\n for i = 1 to k do\n Scanf.scanf \" %d %d\" (fun c d ->\n let c = c - 1 in let d = d - 1 in\n block.(c) <- S.add d block.(c);\n block.(d) <- S.add c block.(d);\n )\n done;\n let clust = Array.make n (-1) in\n let cm = Array.make n S.empty in\n let rec loop i cl =\n if i < n then (\n let cl = if clust.(i) <> -1 then cl else (\n let rec collect acc next = function\n | [] -> if S.is_empty next then acc else collect acc S.empty (S.elements next)\n | hd :: tl ->\n let acc = S.add hd acc in\n let next = S.union (S.diff friend.(hd) acc) next in\n collect acc next tl\n in\n let acc = collect S.empty (S.singleton i) [] in\n S.iter (fun v -> clust.(v) <- cl) acc;\n cm.(cl) <- acc;\n cl + 1\n )\n in\n let c = S.cardinal (S.diff (S.diff cm.(clust.(i)) block.(i)) friend.(i)) in\n let () = Printf.printf \"%d \" (c - 1) in\n loop (i + 1) cl\n )\n in\n loop 0 0\n)", "problem_context": "Score : 400 points\n\nProblem Statement\n\nAn SNS has N users - User 1, User 2, \\cdots, User N.\n\nBetween these N users, there are some relationships - M friendships and K blockships.\n\nFor each i = 1, 2, \\cdots, M, there is a bidirectional friendship between User A_i and User B_i.\n\nFor each i = 1, 2, \\cdots, K, there is a bidirectional blockship between User C_i and User D_i.\n\nWe define User a to be a friend candidate for User b when all of the following four conditions are satisfied:\n\na \\neq b.\n\nThere is not a friendship between User a and User b.\n\nThere is not a blockship between User a and User b.\n\nThere exists a sequence c_0, c_1, c_2, \\cdots, c_L consisting of integers between 1 and N (inclusive) such that c_0 = a, c_L = b, and there is a friendship between User c_i and c_{i+1} for each i = 0, 1, \\cdots, L - 1.\n\nFor each user i = 1, 2, ... N, how many friend candidates does it have?\n\nConstraints\n\nAll values in input are integers.\n\n2 ≤ N ≤ 10^5\n\n0 \\leq M \\leq 10^5\n\n0 \\leq K \\leq 10^5\n\n1 \\leq A_i, B_i \\leq N\n\nA_i \\neq B_i\n\n1 \\leq C_i, D_i \\leq N\n\nC_i \\neq D_i\n\n(A_i, B_i) \\neq (A_j, B_j) (i \\neq j)\n\n(A_i, B_i) \\neq (B_j, A_j)\n\n(C_i, D_i) \\neq (C_j, D_j) (i \\neq j)\n\n(C_i, D_i) \\neq (D_j, C_j)\n\n(A_i, B_i) \\neq (C_j, D_j)\n\n(A_i, B_i) \\neq (D_j, C_j)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M K\nA_1 B_1\n\\vdots\nA_M B_M\nC_1 D_1\n\\vdots\nC_K D_K\n\nOutput\n\nPrint the answers in order, with space in between.\n\nSample Input 1\n\n4 4 1\n2 1\n1 3\n3 2\n3 4\n4 1\n\nSample Output 1\n\n0 1 0 1\n\nThere is a friendship between User 2 and 3, and between 3 and 4. Also, there is no friendship or blockship between User 2 and 4. Thus, User 4 is a friend candidate for User 2.\n\nHowever, neither User 1 or 3 is a friend candidate for User 2, so User 2 has one friend candidate.\n\nSample Input 2\n\n5 10 0\n1 2\n1 3\n1 4\n1 5\n3 2\n2 4\n2 5\n4 3\n5 3\n4 5\n\nSample Output 2\n\n0 0 0 0 0\n\nEveryone is a friend of everyone else and has no friend candidate.\n\nSample Input 3\n\n10 9 3\n10 1\n6 7\n8 2\n2 5\n8 4\n7 3\n10 9\n6 4\n5 8\n2 6\n7 5\n3 1\n\nSample Output 3\n\n1 3 5 4 3 3 3 3 1 0", "sample_input": "4 4 1\n2 1\n1 3\n3 2\n3 4\n4 1\n"}, "reference_outputs": ["0 1 0 1\n"], "source_document_id": "p02762", "source_text": "Score : 400 points\n\nProblem Statement\n\nAn SNS has N users - User 1, User 2, \\cdots, User N.\n\nBetween these N users, there are some relationships - M friendships and K blockships.\n\nFor each i = 1, 2, \\cdots, M, there is a bidirectional friendship between User A_i and User B_i.\n\nFor each i = 1, 2, \\cdots, K, there is a bidirectional blockship between User C_i and User D_i.\n\nWe define User a to be a friend candidate for User b when all of the following four conditions are satisfied:\n\na \\neq b.\n\nThere is not a friendship between User a and User b.\n\nThere is not a blockship between User a and User b.\n\nThere exists a sequence c_0, c_1, c_2, \\cdots, c_L consisting of integers between 1 and N (inclusive) such that c_0 = a, c_L = b, and there is a friendship between User c_i and c_{i+1} for each i = 0, 1, \\cdots, L - 1.\n\nFor each user i = 1, 2, ... N, how many friend candidates does it have?\n\nConstraints\n\nAll values in input are integers.\n\n2 ≤ N ≤ 10^5\n\n0 \\leq M \\leq 10^5\n\n0 \\leq K \\leq 10^5\n\n1 \\leq A_i, B_i \\leq N\n\nA_i \\neq B_i\n\n1 \\leq C_i, D_i \\leq N\n\nC_i \\neq D_i\n\n(A_i, B_i) \\neq (A_j, B_j) (i \\neq j)\n\n(A_i, B_i) \\neq (B_j, A_j)\n\n(C_i, D_i) \\neq (C_j, D_j) (i \\neq j)\n\n(C_i, D_i) \\neq (D_j, C_j)\n\n(A_i, B_i) \\neq (C_j, D_j)\n\n(A_i, B_i) \\neq (D_j, C_j)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M K\nA_1 B_1\n\\vdots\nA_M B_M\nC_1 D_1\n\\vdots\nC_K D_K\n\nOutput\n\nPrint the answers in order, with space in between.\n\nSample Input 1\n\n4 4 1\n2 1\n1 3\n3 2\n3 4\n4 1\n\nSample Output 1\n\n0 1 0 1\n\nThere is a friendship between User 2 and 3, and between 3 and 4. Also, there is no friendship or blockship between User 2 and 4. Thus, User 4 is a friend candidate for User 2.\n\nHowever, neither User 1 or 3 is a friend candidate for User 2, so User 2 has one friend candidate.\n\nSample Input 2\n\n5 10 0\n1 2\n1 3\n1 4\n1 5\n3 2\n2 4\n2 5\n4 3\n5 3\n4 5\n\nSample Output 2\n\n0 0 0 0 0\n\nEveryone is a friend of everyone else and has no friend candidate.\n\nSample Input 3\n\n10 9 3\n10 1\n6 7\n8 2\n2 5\n8 4\n7 3\n10 9\n6 4\n5 8\n2 6\n7 5\n3 1\n\nSample Output 3\n\n1 3 5 4 3 3 3 3 1 0", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1596, "cpu_time_ms": 2105, "memory_kb": 39932}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s062713040", "group_id": "codeNet:p02763", "input_text": "module S = Set.Make (struct type t = int let compare = compare end);;\nlet () =\n let main () =\n let n = read_line () |> int_of_string in\n let s = read_line () in\n let letter = Array.make 26 S.empty in\n for i = 0 to n - 1 do\n let code = int_of_char s.[i] - 97 in\n letter.(code) <- S.add i letter.(code)\n done;\n let q = read_int () in\n for i = 1 to q do\n Scanf.scanf \" %d %d %s\" (fun command a b ->\n if command = 1 then (\n let a = a - 1 in\n let c = int_of_char s.[a] - 97 in\n letter.(c) <- S.remove a letter.(c);\n let c = int_of_char b.[0] - 97 in\n letter.(c) <- S.add a letter.(c)\n ) else (\n let a = a - 1 in\n let r = int_of_string b - 1 in\n let rec loop i acc =\n if i = 26 then acc else\n let _,_,s = S.split (a - 1) letter.(i) in\n let s,_,_ = S.split (r + 1) s in\n let acc = if S.is_empty s then acc else acc + 1 in\n loop (i + 1) acc\n in\n loop 0 0 |> Printf.printf \"%d\\n\"\n )\n )\n done\n in\n main ()", "language": "OCaml", "metadata": {"date": 1583125284, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02763.html", "problem_id": "p02763", "resource_group": "low_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/OCaml/s062713040.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s062713040", "user_id": "u342443598"}, "prompt_components": {"gold_output": "3\n1\n5\n", "input_to_evaluate": "module S = Set.Make (struct type t = int let compare = compare end);;\nlet () =\n let main () =\n let n = read_line () |> int_of_string in\n let s = read_line () in\n let letter = Array.make 26 S.empty in\n for i = 0 to n - 1 do\n let code = int_of_char s.[i] - 97 in\n letter.(code) <- S.add i letter.(code)\n done;\n let q = read_int () in\n for i = 1 to q do\n Scanf.scanf \" %d %d %s\" (fun command a b ->\n if command = 1 then (\n let a = a - 1 in\n let c = int_of_char s.[a] - 97 in\n letter.(c) <- S.remove a letter.(c);\n let c = int_of_char b.[0] - 97 in\n letter.(c) <- S.add a letter.(c)\n ) else (\n let a = a - 1 in\n let r = int_of_string b - 1 in\n let rec loop i acc =\n if i = 26 then acc else\n let _,_,s = S.split (a - 1) letter.(i) in\n let s,_,_ = S.split (r + 1) s in\n let acc = if S.is_empty s then acc else acc + 1 in\n loop (i + 1) acc\n in\n loop 0 0 |> Printf.printf \"%d\\n\"\n )\n )\n done\n in\n main ()", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1370, "cpu_time_ms": 786, "memory_kb": 34684}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s434478485", "group_id": "codeNet:p02763", "input_text": "module SegTree = struct\n\nmodule type SemiGroup = sig\n type t\n val op : t -> t -> t\nend\n\nmodule Make (S : SemiGroup) : sig\n type t\n type elt\n\n (* 与えられたリストの要素からなるセグ木を作る *)\n val of_list : elt list -> t\n (* f 0, ... f (n - 1)のn要素からなるセグ木を作る *)\n val init : int -> (int -> elt) -> t\n (*\n * update i f t\n * i番目の要素x_iをf x_iに変更したセグ木を作る\n *)\n val update : int -> (elt -> elt) -> t -> t\n (*\n * query l r t\n * 添字が[l, r)の要素を半群の演算子で畳み込んだ値を求める\n *)\n val query : int -> int -> t -> elt\nend with type elt = S.t = struct\n type elt = S.t\n\n type body =\n | Leaf of elt\n | Node of elt * body * body\n type t = { size : int; body : body }\n\n (* セグ木の要素をどのように左右に分配するか\n 正整数nについて lsize n + rsize n = n が成り立たなくてはならない *)\n let lsize n = n lsr 1\n let rsize n = (n + 1) lsr 1\n\n (* セグ木の保持する要素を半群の演算子で畳み込んだもの *)\n let data = function\n | Leaf x\n | Node (x, _, _) -> x\n\n let mknode l r = Node (S.op (data l) (data r), l, r)\n\n let rec of_list l = function\n | 1 -> Leaf (List.hd l), List.tl l\n | n ->\n let t1, l = of_list l (lsize n) in\n let t2, l = of_list l (rsize n) in\n mknode t1 t2, l\n let of_list l =\n let n = List.length l in\n assert (0 < n);\n { size = n; body = fst (of_list l n) }\n\n let rec init i f = function\n | 1 -> Leaf (f i)\n | n -> mknode (init i f (lsize n)) (init (i + lsize n) f (rsize n))\n let init n f =\n assert (1 <= n);\n { size = n; body = init 0 f n }\n\n let rec update n i f = function\n | Leaf x -> Leaf (f x)\n | Node (_, l, r) ->\n if i < lsize n\n then mknode (update (lsize n) i f l) r\n else mknode l (update (rsize n) (i - lsize n) f r)\n let update i f t =\n assert (0 <= i && i < t.size);\n { t with body = update t.size i f t.body }\n\n let rec query n l r = function\n | Leaf x -> x\n | Node (x, left, right) ->\n if l = 0 && r = n then x\n else if r <= lsize n then query (lsize n) l r left\n else if lsize n <= l then query (rsize n) (l - lsize n) (r - lsize n) right\n else S.op (query (lsize n) l (lsize n) left) (query (rsize n) 0 (r - lsize n) right)\n let query l r t =\n assert (0 <= l && l < r && r <= t.size);\n query t.size l r t.body\nend\n\nend\n\nmodule ST = SegTree.Make (struct\n type t = int\n let op = ( lor )\nend)\n\nlet popcnt x =\n let x = (x land 0x5555555555555555) + ((x lsr 1) land 0x5555555555555555) in\n let x = (x land 0x3333333333333333) + ((x lsr 2) land 0x3333333333333333) in\n let x = (x land 0x0f0f0f0f0f0f0f0f) + ((x lsr 4) land 0x0f0f0f0f0f0f0f0f) in\n let x = (x land 0x00ff00ff00ff00ff) + ((x lsr 8) land 0x00ff00ff00ff00ff) in\n let x = (x land 0x0000ffff0000ffff) + ((x lsr 16) land 0x0000ffff0000ffff) in\n (x land 0x00000000ffffffff) + ((x lsr 32) land 0x00000000ffffffff)\n\n\nlet () = Scanf.scanf \"%d\\n%s\\n%d\\n\" @@ fun n s q ->\n let segtree = ref @@ ST.init n @@ fun i ->\n 1 lsl (Char.code s.[i] - Char.code 'a') in\n for i = 0 to q - 1 do\n Scanf.scanf \"%d \" @@ function\n | 1 -> Scanf.scanf \"%d %c\\n\" @@ fun i c ->\n segtree := ST.update (i - 1) (fun _ -> 1 lsl (Char.code c - Char.code 'a')) !segtree\n | 2 -> Scanf.scanf \"%d %d\\n\" @@ fun l r ->\n Printf.printf \"%d\\n\" @@ popcnt @@ ST.query (l - 1) r !segtree\n done", "language": "OCaml", "metadata": {"date": 1583116979, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02763.html", "problem_id": "p02763", "resource_group": "low_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/OCaml/s434478485.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s434478485", "user_id": "u504158101"}, "prompt_components": {"gold_output": "3\n1\n5\n", "input_to_evaluate": "module SegTree = struct\n\nmodule type SemiGroup = sig\n type t\n val op : t -> t -> t\nend\n\nmodule Make (S : SemiGroup) : sig\n type t\n type elt\n\n (* 与えられたリストの要素からなるセグ木を作る *)\n val of_list : elt list -> t\n (* f 0, ... f (n - 1)のn要素からなるセグ木を作る *)\n val init : int -> (int -> elt) -> t\n (*\n * update i f t\n * i番目の要素x_iをf x_iに変更したセグ木を作る\n *)\n val update : int -> (elt -> elt) -> t -> t\n (*\n * query l r t\n * 添字が[l, r)の要素を半群の演算子で畳み込んだ値を求める\n *)\n val query : int -> int -> t -> elt\nend with type elt = S.t = struct\n type elt = S.t\n\n type body =\n | Leaf of elt\n | Node of elt * body * body\n type t = { size : int; body : body }\n\n (* セグ木の要素をどのように左右に分配するか\n 正整数nについて lsize n + rsize n = n が成り立たなくてはならない *)\n let lsize n = n lsr 1\n let rsize n = (n + 1) lsr 1\n\n (* セグ木の保持する要素を半群の演算子で畳み込んだもの *)\n let data = function\n | Leaf x\n | Node (x, _, _) -> x\n\n let mknode l r = Node (S.op (data l) (data r), l, r)\n\n let rec of_list l = function\n | 1 -> Leaf (List.hd l), List.tl l\n | n ->\n let t1, l = of_list l (lsize n) in\n let t2, l = of_list l (rsize n) in\n mknode t1 t2, l\n let of_list l =\n let n = List.length l in\n assert (0 < n);\n { size = n; body = fst (of_list l n) }\n\n let rec init i f = function\n | 1 -> Leaf (f i)\n | n -> mknode (init i f (lsize n)) (init (i + lsize n) f (rsize n))\n let init n f =\n assert (1 <= n);\n { size = n; body = init 0 f n }\n\n let rec update n i f = function\n | Leaf x -> Leaf (f x)\n | Node (_, l, r) ->\n if i < lsize n\n then mknode (update (lsize n) i f l) r\n else mknode l (update (rsize n) (i - lsize n) f r)\n let update i f t =\n assert (0 <= i && i < t.size);\n { t with body = update t.size i f t.body }\n\n let rec query n l r = function\n | Leaf x -> x\n | Node (x, left, right) ->\n if l = 0 && r = n then x\n else if r <= lsize n then query (lsize n) l r left\n else if lsize n <= l then query (rsize n) (l - lsize n) (r - lsize n) right\n else S.op (query (lsize n) l (lsize n) left) (query (rsize n) 0 (r - lsize n) right)\n let query l r t =\n assert (0 <= l && l < r && r <= t.size);\n query t.size l r t.body\nend\n\nend\n\nmodule ST = SegTree.Make (struct\n type t = int\n let op = ( lor )\nend)\n\nlet popcnt x =\n let x = (x land 0x5555555555555555) + ((x lsr 1) land 0x5555555555555555) in\n let x = (x land 0x3333333333333333) + ((x lsr 2) land 0x3333333333333333) in\n let x = (x land 0x0f0f0f0f0f0f0f0f) + ((x lsr 4) land 0x0f0f0f0f0f0f0f0f) in\n let x = (x land 0x00ff00ff00ff00ff) + ((x lsr 8) land 0x00ff00ff00ff00ff) in\n let x = (x land 0x0000ffff0000ffff) + ((x lsr 16) land 0x0000ffff0000ffff) in\n (x land 0x00000000ffffffff) + ((x lsr 32) land 0x00000000ffffffff)\n\n\nlet () = Scanf.scanf \"%d\\n%s\\n%d\\n\" @@ fun n s q ->\n let segtree = ref @@ ST.init n @@ fun i ->\n 1 lsl (Char.code s.[i] - Char.code 'a') in\n for i = 0 to q - 1 do\n Scanf.scanf \"%d \" @@ function\n | 1 -> Scanf.scanf \"%d %c\\n\" @@ fun i c ->\n segtree := ST.update (i - 1) (fun _ -> 1 lsl (Char.code c - Char.code 'a')) !segtree\n | 2 -> Scanf.scanf \"%d %d\\n\" @@ fun l r ->\n Printf.printf \"%d\\n\" @@ popcnt @@ ST.query (l - 1) r !segtree\n done", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3513, "cpu_time_ms": 102, "memory_kb": 34044}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s053007484", "group_id": "codeNet:p02765", "input_text": "open Printf\nopen Scanf\n\nlet solve n r =\n if n >= 10 then r\n else r + 100 * (10 - n)\n\nlet () =\n scanf \"%d %d \" solve |> printf \"%d\\n\"\n", "language": "OCaml", "metadata": {"date": 1582652771, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02765.html", "problem_id": "p02765", "resource_group": "low_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/OCaml/s053007484.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s053007484", "user_id": "u388783188"}, "prompt_components": {"gold_output": "3719\n", "input_to_evaluate": "open Printf\nopen Scanf\n\nlet solve n r =\n if n >= 10 then r\n else r + 100 * (10 - n)\n\nlet () =\n scanf \"%d %d \" solve |> printf \"%d\\n\"\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nTakahashi is a member of a programming competition site, ButCoder.\n\nEach member of ButCoder is assigned two values: Inner Rating and Displayed Rating.\n\nThe Displayed Rating of a member is equal to their Inner Rating if the member has participated in 10 or more contests. Otherwise, the Displayed Rating will be their Inner Rating minus 100 \\times (10 - K) when the member has participated in K contests.\n\nTakahashi has participated in N contests, and his Displayed Rating is R. Find his Inner Rating.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 100\n\n0 \\leq R \\leq 4111\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN R\n\nOutput\n\nPrint his Inner Rating.\n\nSample Input 1\n\n2 2919\n\nSample Output 1\n\n3719\n\nTakahashi has participated in 2 contests, which is less than 10, so his Displayed Rating is his Inner Rating minus 100 \\times (10 - 2) = 800.\n\nThus, Takahashi's Inner Rating is 2919 + 800 = 3719.\n\nSample Input 2\n\n22 3051\n\nSample Output 2\n\n3051", "sample_input": "2 2919\n"}, "reference_outputs": ["3719\n"], "source_document_id": "p02765", "source_text": "Score : 100 points\n\nProblem Statement\n\nTakahashi is a member of a programming competition site, ButCoder.\n\nEach member of ButCoder is assigned two values: Inner Rating and Displayed Rating.\n\nThe Displayed Rating of a member is equal to their Inner Rating if the member has participated in 10 or more contests. Otherwise, the Displayed Rating will be their Inner Rating minus 100 \\times (10 - K) when the member has participated in K contests.\n\nTakahashi has participated in N contests, and his Displayed Rating is R. Find his Inner Rating.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 100\n\n0 \\leq R \\leq 4111\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN R\n\nOutput\n\nPrint his Inner Rating.\n\nSample Input 1\n\n2 2919\n\nSample Output 1\n\n3719\n\nTakahashi has participated in 2 contests, which is less than 10, so his Displayed Rating is his Inner Rating minus 100 \\times (10 - 2) = 800.\n\nThus, Takahashi's Inner Rating is 2919 + 800 = 3719.\n\nSample Input 2\n\n22 3051\n\nSample Output 2\n\n3051", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s991854571", "group_id": "codeNet:p02766", "input_text": "let n, k = Scanf.scanf \" %d %d\" @@ fun a b -> a, b\nlet rec f p = if p > n then 1 else 1 + f (p * k)\nlet _ = Printf.printf \"%d\\n\" @@ f k", "language": "OCaml", "metadata": {"date": 1583126644, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02766.html", "problem_id": "p02766", "resource_group": "low_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/OCaml/s991854571.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s991854571", "user_id": "u732304692"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "let n, k = Scanf.scanf \" %d %d\" @@ fun a b -> a, b\nlet rec f p = if p > n then 1 else 1 + f (p * k)\nlet _ = Printf.printf \"%d\\n\" @@ f k", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s267139659", "group_id": "codeNet:p02766", "input_text": "let () = Scanf.scanf \"%d %d\" @@ fun n k ->\n Printf.printf \"%d\\n\" @@ succ @@ int_of_float @@ log (float_of_int n) /. log (float_of_int k)", "language": "OCaml", "metadata": {"date": 1582424467, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02766.html", "problem_id": "p02766", "resource_group": "low_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/OCaml/s267139659.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s267139659", "user_id": "u504158101"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "let () = Scanf.scanf \"%d %d\" @@ fun n k ->\n Printf.printf \"%d\\n\" @@ succ @@ int_of_float @@ log (float_of_int n) /. log (float_of_int k)", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s854960307", "group_id": "codeNet:p02767", "input_text": "open Batteries\nopen BatPrintf\n\nlet scan fmt f =\n Scanf.sscanf (read_line ()) fmt f\n\nlet scan_list cnv =\n read_line ()\n |> String.split_on_char ' '\n |> List.map cnv\n\nlet scan_listn n cnv =\n (0 --^ n) |> Enum.map (fun _ -> (cnv % read_line) ())\n\nlet bsearch_ge arr a =\n let l = Array.length arr in\n match Array.bsearch Int.ord arr a with\n | `All_lower -> l\n | `All_bigger -> 0\n | `Just_after n -> l - n -1\n | `At n -> l - n\n | `Empty -> 0\n\nlet rec zip xs ys =\n match xs, ys with\n | [], _ -> []\n | _, [] -> []\n | x::xs, y::ys ->\n (x, y) :: zip xs ys\n\nlet square x = x * x\n\nlet n = scan \"%d\" identity\nlet xs = scan_list Int.of_string\n\nlet () =\n let half = (List.sum xs) / n in\n let half2 = (List.sum xs) / n + 1 in\n let n = List.sum @@ List.map (fun n -> square @@ n - half) xs in\n let m = List.sum @@ List.map (fun n -> square @@ n - half2) xs in\n printf \"%d\" @@ min n m\n", "language": "OCaml", "metadata": {"date": 1583647607, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02767.html", "problem_id": "p02767", "resource_group": "low_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/OCaml/s854960307.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s854960307", "user_id": "u802614675"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "open Batteries\nopen BatPrintf\n\nlet scan fmt f =\n Scanf.sscanf (read_line ()) fmt f\n\nlet scan_list cnv =\n read_line ()\n |> String.split_on_char ' '\n |> List.map cnv\n\nlet scan_listn n cnv =\n (0 --^ n) |> Enum.map (fun _ -> (cnv % read_line) ())\n\nlet bsearch_ge arr a =\n let l = Array.length arr in\n match Array.bsearch Int.ord arr a with\n | `All_lower -> l\n | `All_bigger -> 0\n | `Just_after n -> l - n -1\n | `At n -> l - n\n | `Empty -> 0\n\nlet rec zip xs ys =\n match xs, ys with\n | [], _ -> []\n | _, [] -> []\n | x::xs, y::ys ->\n (x, y) :: zip xs ys\n\nlet square x = x * x\n\nlet n = scan \"%d\" identity\nlet xs = scan_list Int.of_string\n\nlet () =\n let half = (List.sum xs) / n in\n let half2 = (List.sum xs) / n + 1 in\n let n = List.sum @@ List.map (fun n -> square @@ n - half) xs in\n let m = List.sum @@ List.map (fun n -> square @@ n - half2) xs in\n printf \"%d\" @@ min n m\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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 892, "cpu_time_ms": 4, "memory_kb": 1280}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s157873590", "group_id": "codeNet:p02768", "input_text": "open Batteries\nopen BatPrintf\n\nlet scan fmt f =\n Scanf.sscanf (read_line ()) fmt f\n\nlet scan_list cnv =\n read_line ()\n |> String.split_on_char ' '\n |> List.map cnv\n\nlet scan_listn n cnv =\n (0 --^ n) |> Enum.map (fun _ -> (cnv % read_line) ())\n\nlet bsearch_ge arr a =\n let l = Array.length arr in\n match Array.bsearch Int.ord arr a with\n | `All_lower -> l\n | `All_bigger -> 0\n | `Just_after n -> l - n -1\n | `At n -> l - n\n | `Empty -> 0\n\nlet rec zip xs ys =\n match xs, ys with\n | [], _ -> []\n | _, [] -> []\n | x::xs, y::ys ->\n (x, y) :: zip xs ys\n\nlet square x = x * x\n\nlet dbg n = Printf.printf \"%s\\n\" @@ dump n; n\n\nmodule Comb = struct\n let prime = 1_000_000_000+7\n\n let ( * ) a b = a * b mod prime\n let (-) a b = (a+prime - b) mod prime\n\n let rec pow n m =\n if m = 0 then 1\n else if m mod 2 = 0 then pow (n*n mod prime) (m/2)\n else n * pow (n*n mod prime) (m/2) mod prime\n\n let fact n =\n let rec aux m ret =\n if m = 0 then ret\n else aux (m-1) @@ (m*ret) mod prime in\n aux n 1\n\n let comb n k =\n let x = Enum.fold ( * ) 1 (n-k+1 -- n) in\n x * (pow (fact k) (prime - 2))\nend\n\nlet (n, a, b) = scan \"%d %d %d\" Tuple.Tuple3.make\n\n\nlet () =\n let open Comb in\n pow 2 n\n |> (fun x -> (-) x 1)\n |> (fun x -> (-) x @@ comb n a)\n |> (fun x -> (-) x @@ comb n b)\n |> printf \"%d\\n\"\n", "language": "OCaml", "metadata": {"date": 1583666569, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02768.html", "problem_id": "p02768", "resource_group": "low_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/OCaml/s157873590.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s157873590", "user_id": "u802614675"}, "prompt_components": {"gold_output": "7\n", "input_to_evaluate": "open Batteries\nopen BatPrintf\n\nlet scan fmt f =\n Scanf.sscanf (read_line ()) fmt f\n\nlet scan_list cnv =\n read_line ()\n |> String.split_on_char ' '\n |> List.map cnv\n\nlet scan_listn n cnv =\n (0 --^ n) |> Enum.map (fun _ -> (cnv % read_line) ())\n\nlet bsearch_ge arr a =\n let l = Array.length arr in\n match Array.bsearch Int.ord arr a with\n | `All_lower -> l\n | `All_bigger -> 0\n | `Just_after n -> l - n -1\n | `At n -> l - n\n | `Empty -> 0\n\nlet rec zip xs ys =\n match xs, ys with\n | [], _ -> []\n | _, [] -> []\n | x::xs, y::ys ->\n (x, y) :: zip xs ys\n\nlet square x = x * x\n\nlet dbg n = Printf.printf \"%s\\n\" @@ dump n; n\n\nmodule Comb = struct\n let prime = 1_000_000_000+7\n\n let ( * ) a b = a * b mod prime\n let (-) a b = (a+prime - b) mod prime\n\n let rec pow n m =\n if m = 0 then 1\n else if m mod 2 = 0 then pow (n*n mod prime) (m/2)\n else n * pow (n*n mod prime) (m/2) mod prime\n\n let fact n =\n let rec aux m ret =\n if m = 0 then ret\n else aux (m-1) @@ (m*ret) mod prime in\n aux n 1\n\n let comb n k =\n let x = Enum.fold ( * ) 1 (n-k+1 -- n) in\n x * (pow (fact k) (prime - 2))\nend\n\nlet (n, a, b) = scan \"%d %d %d\" Tuple.Tuple3.make\n\n\nlet () =\n let open Comb in\n pow 2 n\n |> (fun x -> (-) x 1)\n |> (fun x -> (-) x @@ comb n a)\n |> (fun x -> (-) x @@ comb n b)\n |> printf \"%d\\n\"\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nAkari has n kinds of flowers, one of each kind.\n\nShe is going to choose one or more of these flowers to make a bouquet.\n\nHowever, she hates two numbers a and b, so the number of flowers in the bouquet cannot be a or b.\n\nHow many different bouquets are there that Akari can make?\n\nFind the count modulo (10^9 + 7).\n\nHere, two bouquets are considered different when there is a flower that is used in one of the bouquets but not in the other bouquet.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq n \\leq 10^9\n\n1 \\leq a < b \\leq \\textrm{min}(n, 2 \\times 10^5)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nn a b\n\nOutput\n\nPrint the number of bouquets that Akari can make, modulo (10^9 + 7). (If there are no such bouquets, print 0.)\n\nSample Input 1\n\n4 1 3\n\nSample Output 1\n\n7\n\nIn this case, Akari can choose 2 or 4 flowers to make the bouquet.\n\nThere are 6 ways to choose 2 out of the 4 flowers, and 1 way to choose 4, so there are a total of 7 different bouquets that Akari can make.\n\nSample Input 2\n\n1000000000 141421 173205\n\nSample Output 2\n\n34076506\n\nPrint the count modulo (10^9 + 7).", "sample_input": "4 1 3\n"}, "reference_outputs": ["7\n"], "source_document_id": "p02768", "source_text": "Score : 400 points\n\nProblem Statement\n\nAkari has n kinds of flowers, one of each kind.\n\nShe is going to choose one or more of these flowers to make a bouquet.\n\nHowever, she hates two numbers a and b, so the number of flowers in the bouquet cannot be a or b.\n\nHow many different bouquets are there that Akari can make?\n\nFind the count modulo (10^9 + 7).\n\nHere, two bouquets are considered different when there is a flower that is used in one of the bouquets but not in the other bouquet.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq n \\leq 10^9\n\n1 \\leq a < b \\leq \\textrm{min}(n, 2 \\times 10^5)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nn a b\n\nOutput\n\nPrint the number of bouquets that Akari can make, modulo (10^9 + 7). (If there are no such bouquets, print 0.)\n\nSample Input 1\n\n4 1 3\n\nSample Output 1\n\n7\n\nIn this case, Akari can choose 2 or 4 flowers to make the bouquet.\n\nThere are 6 ways to choose 2 out of the 4 flowers, and 1 way to choose 4, so there are a total of 7 different bouquets that Akari can make.\n\nSample Input 2\n\n1000000000 141421 173205\n\nSample Output 2\n\n34076506\n\nPrint the count modulo (10^9 + 7).", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1333, "cpu_time_ms": 16, "memory_kb": 1024}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s886361839", "group_id": "codeNet:p02768", "input_text": "open Batteries\nopen BatPrintf\n\nlet scan fmt f =\n Scanf.sscanf (read_line ()) fmt f\n\nlet scan_list cnv =\n read_line ()\n |> String.split_on_char ' '\n |> List.map cnv\n\nlet scan_listn n cnv =\n (0 --^ n) |> Enum.map (fun _ -> (cnv % read_line) ())\n\nlet bsearch_ge arr a =\n let l = Array.length arr in\n match Array.bsearch Int.ord arr a with\n | `All_lower -> l\n | `All_bigger -> 0\n | `Just_after n -> l - n -1\n | `At n -> l - n\n | `Empty -> 0\n\nlet rec zip xs ys =\n match xs, ys with\n | [], _ -> []\n | _, [] -> []\n | x::xs, y::ys ->\n (x, y) :: zip xs ys\n\nlet square x = x * x\n\nlet dbg n =\n Printf.printf \"%s\\n\" @@ dump n; n\n\nmodule CombMemo = struct\n let prime = 1_000_000_000+7\n let size = 2*1_00_000\n\n let memo = let arr = Array.make size None in\n arr.(0) <- Some 1;\n arr\n\n let ( * ) a b = a * b mod prime\n let (-) a b = (a+prime - b) mod prime\n\n let rec pow n m =\n if m = 0 then 1\n else if m mod 2 = 0 then pow (n*n) (m/2)\n else n * pow (n*n) (m/2)\n\n let rec fact n =\n match memo.(n) with\n | None ->\n let m = n * fact (n-1) in\n memo.(n) <- Some m;\n m\n | Some a -> a\n\n let comb n k =\n fact n * (pow (fact k) (prime-2)) * (pow (fact (n - k)) (prime-2))\nend\n\nmodule Comb = struct\n let prime = 1_000_000_000+7\n\n let ( * ) a b = a * b mod prime\n let (-) a b = (a+prime - b) mod prime\n\n let rec pow n m =\n if m = 0 then 1\n else if m mod 2 = 0 then pow (n*n mod prime) (m/2)\n else n * pow (n*n mod prime) (m/2) mod prime\n\n let fact n =\n let rec aux m ret =\n if m = 0 then ret\n else aux (m-1) @@ (m*ret) mod prime in\n aux n 1\n\n let comb n k =\n let x = Enum.fold ( * ) 1 (n-k+1 -- n) in\n x * (pow (fact k) (prime - 2))\nend\n\nlet (n, a, b) = scan \"%d %d %d\" Tuple.Tuple3.make\n\n\nlet () =\n let open Comb in\n pow 2 n\n |> (fun x -> (-) x 1)\n |> (fun x -> (-) x @@ comb n a)\n |> (fun x -> (-) x @@ comb n b)\n |> printf \"%d\\n\"\n", "language": "OCaml", "metadata": {"date": 1583666364, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02768.html", "problem_id": "p02768", "resource_group": "low_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/OCaml/s886361839.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s886361839", "user_id": "u802614675"}, "prompt_components": {"gold_output": "7\n", "input_to_evaluate": "open Batteries\nopen BatPrintf\n\nlet scan fmt f =\n Scanf.sscanf (read_line ()) fmt f\n\nlet scan_list cnv =\n read_line ()\n |> String.split_on_char ' '\n |> List.map cnv\n\nlet scan_listn n cnv =\n (0 --^ n) |> Enum.map (fun _ -> (cnv % read_line) ())\n\nlet bsearch_ge arr a =\n let l = Array.length arr in\n match Array.bsearch Int.ord arr a with\n | `All_lower -> l\n | `All_bigger -> 0\n | `Just_after n -> l - n -1\n | `At n -> l - n\n | `Empty -> 0\n\nlet rec zip xs ys =\n match xs, ys with\n | [], _ -> []\n | _, [] -> []\n | x::xs, y::ys ->\n (x, y) :: zip xs ys\n\nlet square x = x * x\n\nlet dbg n =\n Printf.printf \"%s\\n\" @@ dump n; n\n\nmodule CombMemo = struct\n let prime = 1_000_000_000+7\n let size = 2*1_00_000\n\n let memo = let arr = Array.make size None in\n arr.(0) <- Some 1;\n arr\n\n let ( * ) a b = a * b mod prime\n let (-) a b = (a+prime - b) mod prime\n\n let rec pow n m =\n if m = 0 then 1\n else if m mod 2 = 0 then pow (n*n) (m/2)\n else n * pow (n*n) (m/2)\n\n let rec fact n =\n match memo.(n) with\n | None ->\n let m = n * fact (n-1) in\n memo.(n) <- Some m;\n m\n | Some a -> a\n\n let comb n k =\n fact n * (pow (fact k) (prime-2)) * (pow (fact (n - k)) (prime-2))\nend\n\nmodule Comb = struct\n let prime = 1_000_000_000+7\n\n let ( * ) a b = a * b mod prime\n let (-) a b = (a+prime - b) mod prime\n\n let rec pow n m =\n if m = 0 then 1\n else if m mod 2 = 0 then pow (n*n mod prime) (m/2)\n else n * pow (n*n mod prime) (m/2) mod prime\n\n let fact n =\n let rec aux m ret =\n if m = 0 then ret\n else aux (m-1) @@ (m*ret) mod prime in\n aux n 1\n\n let comb n k =\n let x = Enum.fold ( * ) 1 (n-k+1 -- n) in\n x * (pow (fact k) (prime - 2))\nend\n\nlet (n, a, b) = scan \"%d %d %d\" Tuple.Tuple3.make\n\n\nlet () =\n let open Comb in\n pow 2 n\n |> (fun x -> (-) x 1)\n |> (fun x -> (-) x @@ comb n a)\n |> (fun x -> (-) x @@ comb n b)\n |> printf \"%d\\n\"\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nAkari has n kinds of flowers, one of each kind.\n\nShe is going to choose one or more of these flowers to make a bouquet.\n\nHowever, she hates two numbers a and b, so the number of flowers in the bouquet cannot be a or b.\n\nHow many different bouquets are there that Akari can make?\n\nFind the count modulo (10^9 + 7).\n\nHere, two bouquets are considered different when there is a flower that is used in one of the bouquets but not in the other bouquet.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq n \\leq 10^9\n\n1 \\leq a < b \\leq \\textrm{min}(n, 2 \\times 10^5)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nn a b\n\nOutput\n\nPrint the number of bouquets that Akari can make, modulo (10^9 + 7). (If there are no such bouquets, print 0.)\n\nSample Input 1\n\n4 1 3\n\nSample Output 1\n\n7\n\nIn this case, Akari can choose 2 or 4 flowers to make the bouquet.\n\nThere are 6 ways to choose 2 out of the 4 flowers, and 1 way to choose 4, so there are a total of 7 different bouquets that Akari can make.\n\nSample Input 2\n\n1000000000 141421 173205\n\nSample Output 2\n\n34076506\n\nPrint the count modulo (10^9 + 7).", "sample_input": "4 1 3\n"}, "reference_outputs": ["7\n"], "source_document_id": "p02768", "source_text": "Score : 400 points\n\nProblem Statement\n\nAkari has n kinds of flowers, one of each kind.\n\nShe is going to choose one or more of these flowers to make a bouquet.\n\nHowever, she hates two numbers a and b, so the number of flowers in the bouquet cannot be a or b.\n\nHow many different bouquets are there that Akari can make?\n\nFind the count modulo (10^9 + 7).\n\nHere, two bouquets are considered different when there is a flower that is used in one of the bouquets but not in the other bouquet.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq n \\leq 10^9\n\n1 \\leq a < b \\leq \\textrm{min}(n, 2 \\times 10^5)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nn a b\n\nOutput\n\nPrint the number of bouquets that Akari can make, modulo (10^9 + 7). (If there are no such bouquets, print 0.)\n\nSample Input 1\n\n4 1 3\n\nSample Output 1\n\n7\n\nIn this case, Akari can choose 2 or 4 flowers to make the bouquet.\n\nThere are 6 ways to choose 2 out of the 4 flowers, and 1 way to choose 4, so there are a total of 7 different bouquets that Akari can make.\n\nSample Input 2\n\n1000000000 141421 173205\n\nSample Output 2\n\n34076506\n\nPrint the count modulo (10^9 + 7).", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1919, "cpu_time_ms": 18, "memory_kb": 4608}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s938345056", "group_id": "codeNet:p02769", "input_text": "Scanf.scanf \"%d %d\" (fun n k ->\n let m = 1_000_000_007 in\n\n let extgcd x y =\n let rec eg r0 r1 a0 a1 b0 b1 =\n if r1 = 0 then a0, b0 else\n let q1 = r0 / r1 in\n eg r1 (r0 mod r1) a1 (a0 - q1 * a1) b1 (b0 - q1 * b1)\n in\n eg x y 1 0 0 1\n in\n\n let inv x y = (* 1/x in mod y *)\n let c, d = extgcd x y in\n if c < 0 then c + y else c\n in\n let ( +@) a b = (a + b) mod m in\n let ( -@) a b = (((a - b) mod m) + m) mod m in\n let ( *@) a b = ((a mod m) * (b mod m)) mod m in\n let ( /@) a b = a *@ inv b m in\n let rec loop i r1 r2 a b acc =\n if i > n || i > k then acc else (\n let acc = acc +@ r1 *@ r2 in\n let r1 = r1 *@ a /@ b in\n let r2 = r2 *@ (a - 1) /@ b in\n let a = a - 1 in\n let b = b + 1 in\n loop (i + 1) r1 r2 a b acc\n )\n in\n loop 0 1 1 n 1 0 |> Printf.printf \"%d\\n\"\n)", "language": "OCaml", "metadata": {"date": 1583457784, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02769.html", "problem_id": "p02769", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02769/input.txt", "sample_output_relpath": "derived/input_output/data/p02769/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02769/OCaml/s938345056.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s938345056", "user_id": "u342443598"}, "prompt_components": {"gold_output": "10\n", "input_to_evaluate": "Scanf.scanf \"%d %d\" (fun n k ->\n let m = 1_000_000_007 in\n\n let extgcd x y =\n let rec eg r0 r1 a0 a1 b0 b1 =\n if r1 = 0 then a0, b0 else\n let q1 = r0 / r1 in\n eg r1 (r0 mod r1) a1 (a0 - q1 * a1) b1 (b0 - q1 * b1)\n in\n eg x y 1 0 0 1\n in\n\n let inv x y = (* 1/x in mod y *)\n let c, d = extgcd x y in\n if c < 0 then c + y else c\n in\n let ( +@) a b = (a + b) mod m in\n let ( -@) a b = (((a - b) mod m) + m) mod m in\n let ( *@) a b = ((a mod m) * (b mod m)) mod m in\n let ( /@) a b = a *@ inv b m in\n let rec loop i r1 r2 a b acc =\n if i > n || i > k then acc else (\n let acc = acc +@ r1 *@ r2 in\n let r1 = r1 *@ a /@ b in\n let r2 = r2 *@ (a - 1) /@ b in\n let a = a - 1 in\n let b = b + 1 in\n loop (i + 1) r1 r2 a b acc\n )\n in\n loop 0 1 1 n 1 0 |> Printf.printf \"%d\\n\"\n)", "problem_context": "Score : 500 points\n\nProblem Statement\n\nThere is a building with n rooms, numbered 1 to n.\n\nWe can move from any room to any other room in the building.\n\nLet us call the following event a move: a person in some room i goes to another room j~ (i \\neq j).\n\nInitially, there was one person in each room in the building.\n\nAfter that, we know that there were exactly k moves happened up to now.\n\nWe are interested in the number of people in each of the n rooms now. How many combinations of numbers of people in the n rooms are possible?\n\nFind the count modulo (10^9 + 7).\n\nConstraints\n\nAll values in input are integers.\n\n3 \\leq n \\leq 2 \\times 10^5\n\n2 \\leq k \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nn k\n\nOutput\n\nPrint the number of possible combinations of numbers of people in the n rooms now, modulo (10^9 + 7).\n\nSample Input 1\n\n3 2\n\nSample Output 1\n\n10\n\nLet c_1, c_2, and c_3 be the number of people in Room 1, 2, and 3 now, respectively. There are 10 possible combination of (c_1, c_2, c_3):\n\n(0, 0, 3)\n\n(0, 1, 2)\n\n(0, 2, 1)\n\n(0, 3, 0)\n\n(1, 0, 2)\n\n(1, 1, 1)\n\n(1, 2, 0)\n\n(2, 0, 1)\n\n(2, 1, 0)\n\n(3, 0, 0)\n\nFor example, (c_1, c_2, c_3) will be (0, 1, 2) if the person in Room 1 goes to Room 2 and then one of the persons in Room 2 goes to Room 3.\n\nSample Input 2\n\n200000 1000000000\n\nSample Output 2\n\n607923868\n\nPrint the count modulo (10^9 + 7).\n\nSample Input 3\n\n15 6\n\nSample Output 3\n\n22583772", "sample_input": "3 2\n"}, "reference_outputs": ["10\n"], "source_document_id": "p02769", "source_text": "Score : 500 points\n\nProblem Statement\n\nThere is a building with n rooms, numbered 1 to n.\n\nWe can move from any room to any other room in the building.\n\nLet us call the following event a move: a person in some room i goes to another room j~ (i \\neq j).\n\nInitially, there was one person in each room in the building.\n\nAfter that, we know that there were exactly k moves happened up to now.\n\nWe are interested in the number of people in each of the n rooms now. How many combinations of numbers of people in the n rooms are possible?\n\nFind the count modulo (10^9 + 7).\n\nConstraints\n\nAll values in input are integers.\n\n3 \\leq n \\leq 2 \\times 10^5\n\n2 \\leq k \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nn k\n\nOutput\n\nPrint the number of possible combinations of numbers of people in the n rooms now, modulo (10^9 + 7).\n\nSample Input 1\n\n3 2\n\nSample Output 1\n\n10\n\nLet c_1, c_2, and c_3 be the number of people in Room 1, 2, and 3 now, respectively. There are 10 possible combination of (c_1, c_2, c_3):\n\n(0, 0, 3)\n\n(0, 1, 2)\n\n(0, 2, 1)\n\n(0, 3, 0)\n\n(1, 0, 2)\n\n(1, 1, 1)\n\n(1, 2, 0)\n\n(2, 0, 1)\n\n(2, 1, 0)\n\n(3, 0, 0)\n\nFor example, (c_1, c_2, c_3) will be (0, 1, 2) if the person in Room 1 goes to Room 2 and then one of the persons in Room 2 goes to Room 3.\n\nSample Input 2\n\n200000 1000000000\n\nSample Output 2\n\n607923868\n\nPrint the count modulo (10^9 + 7).\n\nSample Input 3\n\n15 6\n\nSample Output 3\n\n22583772", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 956, "cpu_time_ms": 121, "memory_kb": 2560}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s675428974", "group_id": "codeNet:p02771", "input_text": "open Batteries\nopen BatPrintf\n\nlet scan fmt f =\n BatScanf.sscanf (read_line ()) fmt f\n\nlet scan_list cnv =\n read_line ()\n |> BatString.split_on_char ' '\n |> List.map cnv\n\nlet rec zip xs ys =\n match xs, ys with\n | [], _ -> []\n | _, [] -> []\n | x::xs, y::ys ->\n (x, y) :: zip xs ys\n\nlet (a,b,c)= scan \"%d %d %d\" @@ BatTuple.Tuple3.make\n\nlet () =\n (if (a != b && b != c && b != c) || ( a == b && b == c && c == a) then\n \"No\"\n else\n \"Yes\")\n |> printf \"%s\\n\"\n", "language": "OCaml", "metadata": {"date": 1582380046, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02771.html", "problem_id": "p02771", "resource_group": "low_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/OCaml/s675428974.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s675428974", "user_id": "u802614675"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "open Batteries\nopen BatPrintf\n\nlet scan fmt f =\n BatScanf.sscanf (read_line ()) fmt f\n\nlet scan_list cnv =\n read_line ()\n |> BatString.split_on_char ' '\n |> List.map cnv\n\nlet rec zip xs ys =\n match xs, ys with\n | [], _ -> []\n | _, [] -> []\n | x::xs, y::ys ->\n (x, y) :: zip xs ys\n\nlet (a,b,c)= scan \"%d %d %d\" @@ BatTuple.Tuple3.make\n\nlet () =\n (if (a != b && b != c && b != c) || ( a == b && b == c && c == a) then\n \"No\"\n else\n \"Yes\")\n |> printf \"%s\\n\"\n", "problem_context": "Score: 100 points\n\nProblem Statement\n\nA triple of numbers is said to be poor when two of those numbers are equal but the other number is different from those two numbers.\n\nYou will be given three integers A, B, and C. If this triple is poor, print Yes; otherwise, print No.\n\nConstraints\n\nA, B, and C are all integers between 1 and 9 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C\n\nOutput\n\nIf the given triple is poor, print Yes; otherwise, print No.\n\nSample Input 1\n\n5 7 5\n\nSample Output 1\n\nYes\n\nA and C are equal, but B is different from those two numbers, so this triple is poor.\n\nSample Input 2\n\n4 4 4\n\nSample Output 2\n\nNo\n\nA, B, and C are all equal, so this triple is not poor.\n\nSample Input 3\n\n4 9 6\n\nSample Output 3\n\nNo\n\nSample Input 4\n\n3 3 4\n\nSample Output 4\n\nYes", "sample_input": "5 7 5\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02771", "source_text": "Score: 100 points\n\nProblem Statement\n\nA triple of numbers is said to be poor when two of those numbers are equal but the other number is different from those two numbers.\n\nYou will be given three integers A, B, and C. If this triple is poor, print Yes; otherwise, print No.\n\nConstraints\n\nA, B, and C are all integers between 1 and 9 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C\n\nOutput\n\nIf the given triple is poor, print Yes; otherwise, print No.\n\nSample Input 1\n\n5 7 5\n\nSample Output 1\n\nYes\n\nA and C are equal, but B is different from those two numbers, so this triple is poor.\n\nSample Input 2\n\n4 4 4\n\nSample Output 2\n\nNo\n\nA, B, and C are all equal, so this triple is not poor.\n\nSample Input 3\n\n4 9 6\n\nSample Output 3\n\nNo\n\nSample Input 4\n\n3 3 4\n\nSample Output 4\n\nYes", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 478, "cpu_time_ms": 2, "memory_kb": 1152}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s626487256", "group_id": "codeNet:p02772", "input_text": "let () =\n\tlet n = Scanf.scanf \"%d\\n\" (fun x -> x) in\n let lst = Array.to_list (Array.init n (fun _ -> Scanf.scanf \"%d \" (fun x -> x))) in\n Printf.printf \n \t(if (List.for_all (fun x -> (x mod 2 = 1) || ((x mod 2 = 0) && (x mod 3 = 0 || x mod 5 = 0))) lst) \n then \"APPROVED\" else \"DENIED\")", "language": "OCaml", "metadata": {"date": 1581884231, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02772.html", "problem_id": "p02772", "resource_group": "low_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/OCaml/s626487256.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s626487256", "user_id": "u307426615"}, "prompt_components": {"gold_output": "APPROVED\n", "input_to_evaluate": "let () =\n\tlet n = Scanf.scanf \"%d\\n\" (fun x -> x) in\n let lst = Array.to_list (Array.init n (fun _ -> Scanf.scanf \"%d \" (fun x -> x))) in\n Printf.printf \n \t(if (List.for_all (fun x -> (x mod 2 = 1) || ((x mod 2 = 0) && (x mod 3 = 0 || x mod 5 = 0))) lst) \n then \"APPROVED\" else \"DENIED\")", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s509281817", "group_id": "codeNet:p02773", "input_text": "open Batteries\nopen BatPrintf\n\nlet scan fmt f =\n Scanf.sscanf (read_line ()) fmt f\n\nlet scan_list cnv =\n read_line ()\n |> String.split_on_char ' '\n |> List.map cnv\n\nlet scan_listn n cnv =\n (0 --^ n) /@ (fun _ -> (cnv % read_line) ())\n\nlet rec zip xs ys =\n match xs, ys with\n | [], _ -> []\n | _, [] -> []\n | x::xs, y::ys ->\n (x, y) :: zip xs ys\n\nlet n = scan \"%d\" identity\nlet s = scan_listn n identity\n\nlet () =\n let assoc =\n fold (fun assoc k -> List.modify_opt k\n (function\n | None -> Some 0\n | Some n -> Some (n + 1)) assoc) [] s in\n let m = List.fold_left (fun m x -> if m < (Tuple.Tuple2.second x) then (Tuple.Tuple2.second x) else m) 0 assoc in\n List.filter (fun x -> (Tuple.Tuple2.second x) = m ) assoc\n |> List.map Tuple.Tuple2.first\n |> List.sort String.compare\n |> String.concat \"\\n\"\n |> printf \"%s\\n\"\n", "language": "OCaml", "metadata": {"date": 1582382981, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02773.html", "problem_id": "p02773", "resource_group": "low_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/OCaml/s509281817.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s509281817", "user_id": "u802614675"}, "prompt_components": {"gold_output": "beet\nvet\n", "input_to_evaluate": "open Batteries\nopen BatPrintf\n\nlet scan fmt f =\n Scanf.sscanf (read_line ()) fmt f\n\nlet scan_list cnv =\n read_line ()\n |> String.split_on_char ' '\n |> List.map cnv\n\nlet scan_listn n cnv =\n (0 --^ n) /@ (fun _ -> (cnv % read_line) ())\n\nlet rec zip xs ys =\n match xs, ys with\n | [], _ -> []\n | _, [] -> []\n | x::xs, y::ys ->\n (x, y) :: zip xs ys\n\nlet n = scan \"%d\" identity\nlet s = scan_listn n identity\n\nlet () =\n let assoc =\n fold (fun assoc k -> List.modify_opt k\n (function\n | None -> Some 0\n | Some n -> Some (n + 1)) assoc) [] s in\n let m = List.fold_left (fun m x -> if m < (Tuple.Tuple2.second x) then (Tuple.Tuple2.second x) else m) 0 assoc in\n List.filter (fun x -> (Tuple.Tuple2.second x) = m ) assoc\n |> List.map Tuple.Tuple2.first\n |> List.sort String.compare\n |> String.concat \"\\n\"\n |> printf \"%s\\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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 874, "cpu_time_ms": 2104, "memory_kb": 6276}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s003488909", "group_id": "codeNet:p02777", "input_text": "let st = Scanf.sscanf (read_line ()) \"%s %s\" (fun s t -> [s;t])\nlet ab = Scanf.sscanf (read_line ()) \"%d %d\" (fun a b -> [a;b])\nlet u = read_line ()\nlet _ = \n match u with\n | u when u = (List.hd st) -> Printf.printf \"%d %d\\n\" ((List.hd ab) - 1) (List.nth ab 1)\n | _ -> Printf.printf \"%d %d\\n\" (List.hd ab) ((List.nth ab 1) - 1)\n\n\n", "language": "OCaml", "metadata": {"date": 1583860384, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02777.html", "problem_id": "p02777", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02777/input.txt", "sample_output_relpath": "derived/input_output/data/p02777/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02777/OCaml/s003488909.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s003488909", "user_id": "u511870776"}, "prompt_components": {"gold_output": "2 4\n", "input_to_evaluate": "let st = Scanf.sscanf (read_line ()) \"%s %s\" (fun s t -> [s;t])\nlet ab = Scanf.sscanf (read_line ()) \"%d %d\" (fun a b -> [a;b])\nlet u = read_line ()\nlet _ = \n match u with\n | u when u = (List.hd st) -> Printf.printf \"%d %d\\n\" ((List.hd ab) - 1) (List.nth ab 1)\n | _ -> Printf.printf \"%d %d\\n\" (List.hd ab) ((List.nth ab 1) - 1)\n\n\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nWe have A balls with the string S written on each of them and B balls with the string T written on each of them.\n\nFrom these balls, Takahashi chooses one with the string U written on it and throws it away.\n\nFind the number of balls with the string S and balls with the string T that we have now.\n\nConstraints\n\nS, T, and U are strings consisting of lowercase English letters.\n\nThe lengths of S and T are each between 1 and 10 (inclusive).\n\nS \\not= T\n\nS=U or T=U.\n\n1 \\leq A,B \\leq 10\n\nA and B are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS T\nA B\nU\n\nOutput\n\nPrint the answer, with space in between.\n\nSample Input 1\n\nred blue\n3 4\nred\n\nSample Output 1\n\n2 4\n\nTakahashi chose a ball with red written on it and threw it away.\nNow we have two balls with the string S and four balls with the string T.\n\nSample Input 2\n\nred blue\n5 5\nblue\n\nSample Output 2\n\n5 4\n\nTakahashi chose a ball with blue written on it and threw it away.\nNow we have five balls with the string S and four balls with the string T.", "sample_input": "red blue\n3 4\nred\n"}, "reference_outputs": ["2 4\n"], "source_document_id": "p02777", "source_text": "Score : 100 points\n\nProblem Statement\n\nWe have A balls with the string S written on each of them and B balls with the string T written on each of them.\n\nFrom these balls, Takahashi chooses one with the string U written on it and throws it away.\n\nFind the number of balls with the string S and balls with the string T that we have now.\n\nConstraints\n\nS, T, and U are strings consisting of lowercase English letters.\n\nThe lengths of S and T are each between 1 and 10 (inclusive).\n\nS \\not= T\n\nS=U or T=U.\n\n1 \\leq A,B \\leq 10\n\nA and B are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS T\nA B\nU\n\nOutput\n\nPrint the answer, with space in between.\n\nSample Input 1\n\nred blue\n3 4\nred\n\nSample Output 1\n\n2 4\n\nTakahashi chose a ball with red written on it and threw it away.\nNow we have two balls with the string S and four balls with the string T.\n\nSample Input 2\n\nred blue\n5 5\nblue\n\nSample Output 2\n\n5 4\n\nTakahashi chose a ball with blue written on it and threw it away.\nNow we have five balls with the string S and four balls with the string T.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s903721472", "group_id": "codeNet:p02779", "input_text": "let () =\n Scanf.scanf \"%d\\n\" @@ fun n ->\n let lst = Array.to_list (Array.init n @@ fun _ -> Scanf.scanf \"%d \" @@ fun d -> d) in\n let ans = (List.length lst) = List.length (List.sort_uniq compare lst) in\n Printf.printf \"%s\\n\" (if ans then \"YES\" else \"NO\")", "language": "OCaml", "metadata": {"date": 1591615676, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02779.html", "problem_id": "p02779", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02779/input.txt", "sample_output_relpath": "derived/input_output/data/p02779/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02779/OCaml/s903721472.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s903721472", "user_id": "u307426615"}, "prompt_components": {"gold_output": "YES\n", "input_to_evaluate": "let () =\n Scanf.scanf \"%d\\n\" @@ fun n ->\n let lst = Array.to_list (Array.init n @@ fun _ -> Scanf.scanf \"%d \" @@ fun d -> d) in\n let ans = (List.length lst) = List.length (List.sort_uniq compare lst) in\n Printf.printf \"%s\\n\" (if ans then \"YES\" else \"NO\")", "problem_context": "Score : 300 points\n\nProblem Statement\n\nGiven is a sequence of integers A_1, A_2, ..., A_N.\nIf its elements are pairwise distinct, print YES; otherwise, print NO.\n\nConstraints\n\n2 ≤ N ≤ 200000\n\n1 ≤ A_i ≤ 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 ... A_N\n\nOutput\n\nIf the elements of the sequence are pairwise distinct, print YES; otherwise, print NO.\n\nSample Input 1\n\n5\n2 6 1 4 5\n\nSample Output 1\n\nYES\n\nThe elements are pairwise distinct.\n\nSample Input 2\n\n6\n4 1 3 1 6 2\n\nSample Output 2\n\nNO\n\nThe second and fourth elements are identical.\n\nSample Input 3\n\n2\n10000000 10000000\n\nSample Output 3\n\nNO", "sample_input": "5\n2 6 1 4 5\n"}, "reference_outputs": ["YES\n"], "source_document_id": "p02779", "source_text": "Score : 300 points\n\nProblem Statement\n\nGiven is a sequence of integers A_1, A_2, ..., A_N.\nIf its elements are pairwise distinct, print YES; otherwise, print NO.\n\nConstraints\n\n2 ≤ N ≤ 200000\n\n1 ≤ A_i ≤ 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 ... A_N\n\nOutput\n\nIf the elements of the sequence are pairwise distinct, print YES; otherwise, print NO.\n\nSample Input 1\n\n5\n2 6 1 4 5\n\nSample Output 1\n\nYES\n\nThe elements are pairwise distinct.\n\nSample Input 2\n\n6\n4 1 3 1 6 2\n\nSample Output 2\n\nNO\n\nThe second and fourth elements are identical.\n\nSample Input 3\n\n2\n10000000 10000000\n\nSample Output 3\n\nNO", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 181, "memory_kb": 20608}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s019525704", "group_id": "codeNet:p02780", "input_text": "let split_string ?(pattern=\" \") = Str.split @@ Str.regexp pattern\nlet (n, k) = Scanf.sscanf (read_line ()) \"%d %d\" @@ fun n k -> (n, k)\n\nlet p = read_line () |> split_string |> List.map int_of_string |> Array.of_list\n |> Array.map (fun i -> float (i * (i + 1)) /. float (i * 2))\n\nlet rec loop i s m =\n if i = n then Printf.printf \"%f\\n\" m\n else \n let s = s +. p.(i) -. if i < k then 0. else p.(i - k) in\n loop (i + 1) s (max s m)\n\nlet () = loop 0 0. 0.", "language": "OCaml", "metadata": {"date": 1589998056, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02780.html", "problem_id": "p02780", "resource_group": "low_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/OCaml/s019525704.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s019525704", "user_id": "u811309788"}, "prompt_components": {"gold_output": "7.000000000000\n", "input_to_evaluate": "let split_string ?(pattern=\" \") = Str.split @@ Str.regexp pattern\nlet (n, k) = Scanf.sscanf (read_line ()) \"%d %d\" @@ fun n k -> (n, k)\n\nlet p = read_line () |> split_string |> List.map int_of_string |> Array.of_list\n |> Array.map (fun i -> float (i * (i + 1)) /. float (i * 2))\n\nlet rec loop i s m =\n if i = n then Printf.printf \"%f\\n\" m\n else \n let s = s +. p.(i) -. if i < k then 0. else p.(i - k) in\n loop (i + 1) s (max s m)\n\nlet () = loop 0 0. 0.", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 461, "cpu_time_ms": 92, "memory_kb": 30976}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s253161286", "group_id": "codeNet:p02782", "input_text": "Scanf.scanf \"%d %d %d %d\" (fun r1 c1 r2 c2 ->\n let m = 1_000_000_007 in\n\n let extgcd x y =\n let rec eg r0 r1 a0 a1 b0 b1 =\n if r1 = 0 then a0 else\n let q1 = r0 / r1 in\n eg r1 (r0 mod r1) a1 (a0 - q1 * a1) b1 (b0 - q1 * b1)\n in\n eg x y 1 0 0 1\n in\n let inv x y = (* 1/x in mod y *)\n let c = extgcd x y in\n if c < 0 then c + y else c\n in\n let ( */) a b = ((a mod m) * (b mod m) ) mod m in\n let ( //) a b = a */ inv b m in\n let ( +/) a b = (a + b) mod m in\n let ( -/) a b = (((a - b) mod m) + m) mod m in\n\n let wholesum r c =\n let rec loop cur acc a b i =\n if i > c then acc else loop (cur */ a // b) (acc + cur) (a + 1) (b + 1) (i + 1)\n in\n loop (r + 1) 0 (r + 2) 2 0\n in\n let ans = wholesum r2 c2 -/ wholesum (r1 - 1) c2 -/ wholesum r2 (c1 - 1) +/ wholesum (r1 - 1) (c1 - 1) in\n Printf.printf \"%d\\n\" ans\n)", "language": "OCaml", "metadata": {"date": 1581283742, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02782.html", "problem_id": "p02782", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02782/input.txt", "sample_output_relpath": "derived/input_output/data/p02782/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02782/OCaml/s253161286.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s253161286", "user_id": "u342443598"}, "prompt_components": {"gold_output": "14\n", "input_to_evaluate": "Scanf.scanf \"%d %d %d %d\" (fun r1 c1 r2 c2 ->\n let m = 1_000_000_007 in\n\n let extgcd x y =\n let rec eg r0 r1 a0 a1 b0 b1 =\n if r1 = 0 then a0 else\n let q1 = r0 / r1 in\n eg r1 (r0 mod r1) a1 (a0 - q1 * a1) b1 (b0 - q1 * b1)\n in\n eg x y 1 0 0 1\n in\n let inv x y = (* 1/x in mod y *)\n let c = extgcd x y in\n if c < 0 then c + y else c\n in\n let ( */) a b = ((a mod m) * (b mod m) ) mod m in\n let ( //) a b = a */ inv b m in\n let ( +/) a b = (a + b) mod m in\n let ( -/) a b = (((a - b) mod m) + m) mod m in\n\n let wholesum r c =\n let rec loop cur acc a b i =\n if i > c then acc else loop (cur */ a // b) (acc + cur) (a + 1) (b + 1) (i + 1)\n in\n loop (r + 1) 0 (r + 2) 2 0\n in\n let ans = wholesum r2 c2 -/ wholesum (r1 - 1) c2 -/ wholesum r2 (c1 - 1) +/ wholesum (r1 - 1) (c1 - 1) in\n Printf.printf \"%d\\n\" ans\n)", "problem_context": "Score : 600 points\n\nProblem Statement\n\nSnuke is standing on a two-dimensional plane. In one operation, he can move by 1 in the positive x-direction, or move by 1 in the positive y-direction.\n\nLet us define a function f(r, c) as follows:\n\nf(r,c) := (The number of paths from the point (0, 0) to the point (r, c) that Snuke can trace by repeating the operation above)\n\nGiven are integers r_1, r_2, c_1, and c_2.\nFind the sum of f(i, j) over all pair of integers (i, j) such that r_1 ≤ i ≤ r_2 and c_1 ≤ j ≤ c_2, and compute this value modulo (10^9+7).\n\nConstraints\n\n1 ≤ r_1 ≤ r_2 ≤ 10^6\n\n1 ≤ c_1 ≤ c_2 ≤ 10^6\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nr_1 c_1 r_2 c_2\n\nOutput\n\nPrint the sum of f(i, j) modulo (10^9+7).\n\nSample Input 1\n\n1 1 2 2\n\nSample Output 1\n\n14\n\nFor example, there are two paths from the point (0, 0) to the point (1, 1): (0,0) → (0,1) → (1,1) and (0,0) → (1,0) → (1,1), so f(1,1)=2.\n\nSimilarly, f(1,2)=3, f(2,1)=3, and f(2,2)=6. Thus, the sum is 14.\n\nSample Input 2\n\n314 159 2653 589\n\nSample Output 2\n\n602215194", "sample_input": "1 1 2 2\n"}, "reference_outputs": ["14\n"], "source_document_id": "p02782", "source_text": "Score : 600 points\n\nProblem Statement\n\nSnuke is standing on a two-dimensional plane. In one operation, he can move by 1 in the positive x-direction, or move by 1 in the positive y-direction.\n\nLet us define a function f(r, c) as follows:\n\nf(r,c) := (The number of paths from the point (0, 0) to the point (r, c) that Snuke can trace by repeating the operation above)\n\nGiven are integers r_1, r_2, c_1, and c_2.\nFind the sum of f(i, j) over all pair of integers (i, j) such that r_1 ≤ i ≤ r_2 and c_1 ≤ j ≤ c_2, and compute this value modulo (10^9+7).\n\nConstraints\n\n1 ≤ r_1 ≤ r_2 ≤ 10^6\n\n1 ≤ c_1 ≤ c_2 ≤ 10^6\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nr_1 c_1 r_2 c_2\n\nOutput\n\nPrint the sum of f(i, j) modulo (10^9+7).\n\nSample Input 1\n\n1 1 2 2\n\nSample Output 1\n\n14\n\nFor example, there are two paths from the point (0, 0) to the point (1, 1): (0,0) → (0,1) → (1,1) and (0,0) → (1,0) → (1,1), so f(1,1)=2.\n\nSimilarly, f(1,2)=3, f(2,1)=3, and f(2,2)=6. Thus, the sum is 14.\n\nSample Input 2\n\n314 159 2653 589\n\nSample Output 2\n\n602215194", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 951, "cpu_time_ms": 1342, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s085681160", "group_id": "codeNet:p02783", "input_text": "let () = Scanf.scanf \"%d %d\" @@ fun h a -> Printf.printf \"%d\\n\" ((h+a-1)/a)", "language": "OCaml", "metadata": {"date": 1592678909, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p02783.html", "problem_id": "p02783", "resource_group": "low_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/OCaml/s085681160.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s085681160", "user_id": "u052332717"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "let () = Scanf.scanf \"%d %d\" @@ fun h a -> Printf.printf \"%d\\n\" ((h+a-1)/a)", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 3800}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s921667451", "group_id": "codeNet:p02784", "input_text": "Scanf.scanf \"%d %d\" (fun h n ->\n let a = Array.init n (fun _ -> Scanf.scanf \" %d\" (fun a -> a)) in\n let s = Array.fold_left (+) 0 a in\n (if s >= h then \"Yes\" else \"No\") |> print_endline\n)", "language": "OCaml", "metadata": {"date": 1580069064, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02784.html", "problem_id": "p02784", "resource_group": "low_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/OCaml/s921667451.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s921667451", "user_id": "u342443598"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "Scanf.scanf \"%d %d\" (fun h n ->\n let a = Array.init n (fun _ -> Scanf.scanf \" %d\" (fun a -> a)) in\n let s = Array.fold_left (+) 0 a in\n (if s >= h then \"Yes\" else \"No\") |> print_endline\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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 26, "memory_kb": 5376}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s060325001", "group_id": "codeNet:p02785", "input_text": "open Batteries\nlet n, k = Scanf.sscanf (read_line ()) \"%d %d\" (fun n k -> n, k)\nlet h = read_line () |> String.split_on_char ' ' |> List.map int_of_string\n\nlet rec loop lst i sum =\n match lst with\n | [] -> sum\n | first :: rest ->\n if i <> 0 then min (loop rest (i-1) sum) (loop rest i (sum+first))\n else loop rest i (sum+first)\n\nlet _ = Printf.printf \"%d\\n\" @@ loop h k 0\n\n\n", "language": "OCaml", "metadata": {"date": 1586383067, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02785.html", "problem_id": "p02785", "resource_group": "low_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/OCaml/s060325001.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s060325001", "user_id": "u511870776"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "open Batteries\nlet n, k = Scanf.sscanf (read_line ()) \"%d %d\" (fun n k -> n, k)\nlet h = read_line () |> String.split_on_char ' ' |> List.map int_of_string\n\nlet rec loop lst i sum =\n match lst with\n | [] -> sum\n | first :: rest ->\n if i <> 0 then min (loop rest (i-1) sum) (loop rest i (sum+first))\n else loop rest i (sum+first)\n\nlet _ = Printf.printf \"%d\\n\" @@ loop h k 0\n\n\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nFennec is fighting with N monsters.\n\nThe health of the i-th monster is H_i.\n\nFennec can do the following two actions:\n\nAttack: Fennec chooses one monster. That monster's health will decrease by 1.\n\nSpecial Move: Fennec chooses one monster. That monster's health will become 0.\n\nThere is no way other than Attack and Special Move to decrease the monsters' health.\n\nFennec wins when all the monsters' healths become 0 or below.\n\nFind the minimum number of times Fennec needs to do Attack (not counting Special Move) before winning when she can use Special Move at most K times.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\n0 \\leq K \\leq 2 \\times 10^5\n\n1 \\leq H_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nH_1 ... H_N\n\nOutput\n\nPrint the minimum number of times Fennec needs to do Attack (not counting Special Move) before winning.\n\nSample Input 1\n\n3 1\n4 1 5\n\nSample Output 1\n\n5\n\nBy using Special Move on the third monster, and doing Attack four times on the first monster and once on the second monster, Fennec can win with five Attacks.\n\nSample Input 2\n\n8 9\n7 9 3 2 3 8 4 6\n\nSample Output 2\n\n0\n\nShe can use Special Move on all the monsters.\n\nSample Input 3\n\n3 0\n1000000000 1000000000 1000000000\n\nSample Output 3\n\n3000000000\n\nWatch out for overflow.", "sample_input": "3 1\n4 1 5\n"}, "reference_outputs": ["5\n"], "source_document_id": "p02785", "source_text": "Score : 300 points\n\nProblem Statement\n\nFennec is fighting with N monsters.\n\nThe health of the i-th monster is H_i.\n\nFennec can do the following two actions:\n\nAttack: Fennec chooses one monster. That monster's health will decrease by 1.\n\nSpecial Move: Fennec chooses one monster. That monster's health will become 0.\n\nThere is no way other than Attack and Special Move to decrease the monsters' health.\n\nFennec wins when all the monsters' healths become 0 or below.\n\nFind the minimum number of times Fennec needs to do Attack (not counting Special Move) before winning when she can use Special Move at most K times.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\n0 \\leq K \\leq 2 \\times 10^5\n\n1 \\leq H_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nH_1 ... H_N\n\nOutput\n\nPrint the minimum number of times Fennec needs to do Attack (not counting Special Move) before winning.\n\nSample Input 1\n\n3 1\n4 1 5\n\nSample Output 1\n\n5\n\nBy using Special Move on the third monster, and doing Attack four times on the first monster and once on the second monster, Fennec can win with five Attacks.\n\nSample Input 2\n\n8 9\n7 9 3 2 3 8 4 6\n\nSample Output 2\n\n0\n\nShe can use Special Move on all the monsters.\n\nSample Input 3\n\n3 0\n1000000000 1000000000 1000000000\n\nSample Output 3\n\n3000000000\n\nWatch out for overflow.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 2105, "memory_kb": 28952}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s378300659", "group_id": "codeNet:p02786", "input_text": "(*\nocamlfind ocamlopt -package batteries -linkpkg main.ml -o a.out\n*)\nopen Batteries\n\nlet h = Scanf.sscanf (read_line ()) \"%d\" (\n fun h -> \n h\n)\n\nlet i = ref 0\n\nlet rec f h =\n if h = 1 then\n 1\n else\n 2 * (f (h / 2)) + 1\n\nlet () =\n f h\n |> Printf.printf \"%d\\n\"\n", "language": "OCaml", "metadata": {"date": 1590328582, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02786.html", "problem_id": "p02786", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02786/input.txt", "sample_output_relpath": "derived/input_output/data/p02786/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02786/OCaml/s378300659.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s378300659", "user_id": "u280335093"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "(*\nocamlfind ocamlopt -package batteries -linkpkg main.ml -o a.out\n*)\nopen Batteries\n\nlet h = Scanf.sscanf (read_line ()) \"%d\" (\n fun h -> \n h\n)\n\nlet i = ref 0\n\nlet rec f h =\n if h = 1 then\n 1\n else\n 2 * (f (h / 2)) + 1\n\nlet () =\n f h\n |> Printf.printf \"%d\\n\"\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nCaracal is fighting with a monster.\n\nThe health of the monster is H.\n\nCaracal can attack by choosing one monster. When a monster is attacked, depending on that monster's health, the following happens:\n\nIf the monster's health is 1, it drops to 0.\n\nIf the monster's health, X, is greater than 1, that monster disappears. Then, two new monsters appear, each with the health of \\lfloor X/2 \\rfloor.\n\n(\\lfloor r \\rfloor denotes the greatest integer not exceeding r.)\n\nCaracal wins when the healths of all existing monsters become 0 or below.\n\nFind the minimum number of attacks Caracal needs to make before winning.\n\nConstraints\n\n1 \\leq H \\leq 10^{12}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH\n\nOutput\n\nFind the minimum number of attacks Caracal needs to make before winning.\n\nSample Input 1\n\n2\n\nSample Output 1\n\n3\n\nWhen Caracal attacks the initial monster, it disappears, and two monsters appear, each with the health of 1.\n\nThen, Caracal can attack each of these new monsters once and win with a total of three attacks.\n\nSample Input 2\n\n4\n\nSample Output 2\n\n7\n\nSample Input 3\n\n1000000000000\n\nSample Output 3\n\n1099511627775", "sample_input": "2\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02786", "source_text": "Score : 400 points\n\nProblem Statement\n\nCaracal is fighting with a monster.\n\nThe health of the monster is H.\n\nCaracal can attack by choosing one monster. When a monster is attacked, depending on that monster's health, the following happens:\n\nIf the monster's health is 1, it drops to 0.\n\nIf the monster's health, X, is greater than 1, that monster disappears. Then, two new monsters appear, each with the health of \\lfloor X/2 \\rfloor.\n\n(\\lfloor r \\rfloor denotes the greatest integer not exceeding r.)\n\nCaracal wins when the healths of all existing monsters become 0 or below.\n\nFind the minimum number of attacks Caracal needs to make before winning.\n\nConstraints\n\n1 \\leq H \\leq 10^{12}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH\n\nOutput\n\nFind the minimum number of attacks Caracal needs to make before winning.\n\nSample Input 1\n\n2\n\nSample Output 1\n\n3\n\nWhen Caracal attacks the initial monster, it disappears, and two monsters appear, each with the health of 1.\n\nThen, Caracal can attack each of these new monsters once and win with a total of three attacks.\n\nSample Input 2\n\n4\n\nSample Output 2\n\n7\n\nSample Input 3\n\n1000000000000\n\nSample Output 3\n\n1099511627775", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 340, "cpu_time_ms": 2, "memory_kb": 3072}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s447372187", "group_id": "codeNet:p02787", "input_text": "let (h, n) = Scanf.sscanf (read_line ()) \"%d %d\" @@ fun h n -> (h, n)\nlet ab = Array.init n @@ fun _ -> Scanf.sscanf (read_line ()) \"%d %d\" @@ fun a b -> (a, b)\n\nlet () =\n let ans = Array.make (h + 1) max_int in\n ans.(0) <- 0;\n for i = 1 to h do\n Array.iter (fun (a, b) -> ans.(i) <- min ans.(i) (ans.(max 0 (i - a)) + b)) ab\n done;\n Printf.printf \"%d\\n\" ans.(h)", "language": "OCaml", "metadata": {"date": 1590351078, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02787.html", "problem_id": "p02787", "resource_group": "low_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/OCaml/s447372187.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s447372187", "user_id": "u811309788"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "let (h, n) = Scanf.sscanf (read_line ()) \"%d %d\" @@ fun h n -> (h, n)\nlet ab = Array.init n @@ fun _ -> Scanf.sscanf (read_line ()) \"%d %d\" @@ fun a b -> (a, b)\n\nlet () =\n let ans = Array.make (h + 1) max_int in\n ans.(0) <- 0;\n for i = 1 to h do\n Array.iter (fun (a, b) -> ans.(i) <- min ans.(i) (ans.(max 0 (i - a)) + b)) ab\n done;\n Printf.printf \"%d\\n\" ans.(h)", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 370, "cpu_time_ms": 273, "memory_kb": 2816}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s764341245", "group_id": "codeNet:p02789", "input_text": "open Printf\nopen Scanf\n\nlet solve n m = if n = m then \"Yes\" else \"No\"\n\nlet () =\n scanf \"%d %d \" solve |> printf \"%s\\n\"\n", "language": "OCaml", "metadata": {"date": 1582293643, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02789.html", "problem_id": "p02789", "resource_group": "low_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/OCaml/s764341245.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s764341245", "user_id": "u388783188"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "open Printf\nopen Scanf\n\nlet solve n m = if n = m then \"Yes\" else \"No\"\n\nlet () =\n scanf \"%d %d \" solve |> printf \"%s\\n\"\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nTakahashi is participating in a programming contest, AXC001. He has just submitted his code to Problem A.\n\nThe problem has N test cases, all of which must be passed to get an AC verdict.\n\nTakahashi's submission has passed M cases out of the N test cases.\n\nDetermine whether Takahashi's submission gets an AC.\n\nConstraints\n\n1 \\leq N \\leq 100\n\n0 \\leq M \\leq N\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\n\nOutput\n\nIf Takahashi's submission gets an AC, print Yes; otherwise, print No.\n\nSample Input 1\n\n3 3\n\nSample Output 1\n\nYes\n\nAll three test cases have been passed, so his submission gets an AC.\n\nSample Input 2\n\n3 2\n\nSample Output 2\n\nNo\n\nOnly two out of the three test cases have been passed, so his submission does not get an AC.\n\nSample Input 3\n\n1 1\n\nSample Output 3\n\nYes", "sample_input": "3 3\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02789", "source_text": "Score : 100 points\n\nProblem Statement\n\nTakahashi is participating in a programming contest, AXC001. He has just submitted his code to Problem A.\n\nThe problem has N test cases, all of which must be passed to get an AC verdict.\n\nTakahashi's submission has passed M cases out of the N test cases.\n\nDetermine whether Takahashi's submission gets an AC.\n\nConstraints\n\n1 \\leq N \\leq 100\n\n0 \\leq M \\leq N\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\n\nOutput\n\nIf Takahashi's submission gets an AC, print Yes; otherwise, print No.\n\nSample Input 1\n\n3 3\n\nSample Output 1\n\nYes\n\nAll three test cases have been passed, so his submission gets an AC.\n\nSample Input 2\n\n3 2\n\nSample Output 2\n\nNo\n\nOnly two out of the three test cases have been passed, so his submission does not get an AC.\n\nSample Input 3\n\n1 1\n\nSample Output 3\n\nYes", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s000175254", "group_id": "codeNet:p02789", "input_text": "let () = Scanf.scanf \"%d %d\" @@ fun n m ->\n print_endline @@ if n = m then \"Yes\" else \"No\"\n", "language": "OCaml", "metadata": {"date": 1579464283, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02789.html", "problem_id": "p02789", "resource_group": "low_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/OCaml/s000175254.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s000175254", "user_id": "u504158101"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "let () = Scanf.scanf \"%d %d\" @@ fun n m ->\n print_endline @@ if n = m then \"Yes\" else \"No\"\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nTakahashi is participating in a programming contest, AXC001. He has just submitted his code to Problem A.\n\nThe problem has N test cases, all of which must be passed to get an AC verdict.\n\nTakahashi's submission has passed M cases out of the N test cases.\n\nDetermine whether Takahashi's submission gets an AC.\n\nConstraints\n\n1 \\leq N \\leq 100\n\n0 \\leq M \\leq N\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\n\nOutput\n\nIf Takahashi's submission gets an AC, print Yes; otherwise, print No.\n\nSample Input 1\n\n3 3\n\nSample Output 1\n\nYes\n\nAll three test cases have been passed, so his submission gets an AC.\n\nSample Input 2\n\n3 2\n\nSample Output 2\n\nNo\n\nOnly two out of the three test cases have been passed, so his submission does not get an AC.\n\nSample Input 3\n\n1 1\n\nSample Output 3\n\nYes", "sample_input": "3 3\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02789", "source_text": "Score : 100 points\n\nProblem Statement\n\nTakahashi is participating in a programming contest, AXC001. He has just submitted his code to Problem A.\n\nThe problem has N test cases, all of which must be passed to get an AC verdict.\n\nTakahashi's submission has passed M cases out of the N test cases.\n\nDetermine whether Takahashi's submission gets an AC.\n\nConstraints\n\n1 \\leq N \\leq 100\n\n0 \\leq M \\leq N\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\n\nOutput\n\nIf Takahashi's submission gets an AC, print Yes; otherwise, print No.\n\nSample Input 1\n\n3 3\n\nSample Output 1\n\nYes\n\nAll three test cases have been passed, so his submission gets an AC.\n\nSample Input 2\n\n3 2\n\nSample Output 2\n\nNo\n\nOnly two out of the three test cases have been passed, so his submission does not get an AC.\n\nSample Input 3\n\n1 1\n\nSample Output 3\n\nYes", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s204797740", "group_id": "codeNet:p02790", "input_text": "Scanf.scanf \"%d %d\" (fun a b ->\n let digits = \"0123456789\" in\n let sa = String.make a digits.[b] in\n let sb = String.make b digits.[a] in\n print_endline (min sa sb)\n)", "language": "OCaml", "metadata": {"date": 1586896141, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02790.html", "problem_id": "p02790", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02790/input.txt", "sample_output_relpath": "derived/input_output/data/p02790/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02790/OCaml/s204797740.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s204797740", "user_id": "u342443598"}, "prompt_components": {"gold_output": "3333\n", "input_to_evaluate": "Scanf.scanf \"%d %d\" (fun a b ->\n let digits = \"0123456789\" in\n let sa = String.make a digits.[b] in\n let sb = String.make b digits.[a] in\n print_endline (min sa sb)\n)", "problem_context": "Score : 200 points\n\nProblem Statement\n\nGiven are 1-digit positive integers a and b. Consider these two strings: the concatenation of b copies of the digit a, and the concatenation of a copies of the digit b. Which of these is lexicographically smaller?\n\nConstraints\n\n1 \\leq a \\leq 9\n\n1 \\leq b \\leq 9\n\na and b are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\na b\n\nOutput\n\nPrint the lexicographically smaller of the two strings. (If the two strings are equal, print one of them.)\n\nSample Input 1\n\n4 3\n\nSample Output 1\n\n3333\n\nWe have two strings 444 and 3333. Between them, 3333 is the lexicographically smaller.\n\nSample Input 2\n\n7 7\n\nSample Output 2\n\n7777777", "sample_input": "4 3\n"}, "reference_outputs": ["3333\n"], "source_document_id": "p02790", "source_text": "Score : 200 points\n\nProblem Statement\n\nGiven are 1-digit positive integers a and b. Consider these two strings: the concatenation of b copies of the digit a, and the concatenation of a copies of the digit b. Which of these is lexicographically smaller?\n\nConstraints\n\n1 \\leq a \\leq 9\n\n1 \\leq b \\leq 9\n\na and b are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\na b\n\nOutput\n\nPrint the lexicographically smaller of the two strings. (If the two strings are equal, print one of them.)\n\nSample Input 1\n\n4 3\n\nSample Output 1\n\n3333\n\nWe have two strings 444 and 3333. Between them, 3333 is the lexicographically smaller.\n\nSample Input 2\n\n7 7\n\nSample Output 2\n\n7777777", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s369378227", "group_id": "codeNet:p02790", "input_text": "let f a b = String.make b (Char.(chr @@ code '0' + a))\nlet _ = Scanf.scanf \"%d %d\" @@ fun a b -> print_endline @@ min (f a b) (f b a)", "language": "OCaml", "metadata": {"date": 1580873279, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02790.html", "problem_id": "p02790", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02790/input.txt", "sample_output_relpath": "derived/input_output/data/p02790/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02790/OCaml/s369378227.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s369378227", "user_id": "u732304692"}, "prompt_components": {"gold_output": "3333\n", "input_to_evaluate": "let f a b = String.make b (Char.(chr @@ code '0' + a))\nlet _ = Scanf.scanf \"%d %d\" @@ fun a b -> print_endline @@ min (f a b) (f b a)", "problem_context": "Score : 200 points\n\nProblem Statement\n\nGiven are 1-digit positive integers a and b. Consider these two strings: the concatenation of b copies of the digit a, and the concatenation of a copies of the digit b. Which of these is lexicographically smaller?\n\nConstraints\n\n1 \\leq a \\leq 9\n\n1 \\leq b \\leq 9\n\na and b are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\na b\n\nOutput\n\nPrint the lexicographically smaller of the two strings. (If the two strings are equal, print one of them.)\n\nSample Input 1\n\n4 3\n\nSample Output 1\n\n3333\n\nWe have two strings 444 and 3333. Between them, 3333 is the lexicographically smaller.\n\nSample Input 2\n\n7 7\n\nSample Output 2\n\n7777777", "sample_input": "4 3\n"}, "reference_outputs": ["3333\n"], "source_document_id": "p02790", "source_text": "Score : 200 points\n\nProblem Statement\n\nGiven are 1-digit positive integers a and b. Consider these two strings: the concatenation of b copies of the digit a, and the concatenation of a copies of the digit b. Which of these is lexicographically smaller?\n\nConstraints\n\n1 \\leq a \\leq 9\n\n1 \\leq b \\leq 9\n\na and b are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\na b\n\nOutput\n\nPrint the lexicographically smaller of the two strings. (If the two strings are equal, print one of them.)\n\nSample Input 1\n\n4 3\n\nSample Output 1\n\n3333\n\nWe have two strings 444 and 3333. Between them, 3333 is the lexicographically smaller.\n\nSample Input 2\n\n7 7\n\nSample Output 2\n\n7777777", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s241590984", "group_id": "codeNet:p02791", "input_text": "let () =\n Scanf.scanf \"%d\\n\" @@ fun n ->\n let prr = Array.init n @@ fun _ -> Scanf.scanf \"%d \" @@ fun d -> d in\n let p = Array.fold_left (fun (minN, ans) x -> if minN >= x then (x, ans+1) else (minN, ans)) (prr.(0), 0) prr in\n Printf.printf \"%d\\n\" (snd p)", "language": "OCaml", "metadata": {"date": 1592160600, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02791.html", "problem_id": "p02791", "resource_group": "low_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/OCaml/s241590984.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s241590984", "user_id": "u307426615"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "let () =\n Scanf.scanf \"%d\\n\" @@ fun n ->\n let prr = Array.init n @@ fun _ -> Scanf.scanf \"%d \" @@ fun d -> d in\n let p = Array.fold_left (fun (minN, ans) x -> if minN >= x then (x, ans+1) else (minN, ans)) (prr.(0), 0) prr in\n Printf.printf \"%d\\n\" (snd p)", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 54, "memory_kb": 6272}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s826880539", "group_id": "codeNet:p02791", "input_text": "open Printf\nopen Scanf\n\nlet id x = x\n\nlet solve n =\n let ar = Array.init n @@ fun _ -> scanf \"%d \" id in\n let f (ct, mn) x = if mn > x then (ct + 1, x) else (ct, mn) in\n fst @@ Array.fold_left f (0, 300000) ar\n\nlet () =\n scanf \"%d \" solve |> printf \"%d\\n\"\n", "language": "OCaml", "metadata": {"date": 1583416395, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02791.html", "problem_id": "p02791", "resource_group": "low_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/OCaml/s826880539.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s826880539", "user_id": "u388783188"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "open Printf\nopen Scanf\n\nlet id x = x\n\nlet solve n =\n let ar = Array.init n @@ fun _ -> scanf \"%d \" id in\n let f (ct, mn) x = if mn > x then (ct + 1, x) else (ct, mn) in\n fst @@ Array.fold_left f (0, 300000) ar\n\nlet () =\n scanf \"%d \" solve |> printf \"%d\\n\"\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nGiven is a permutation P_1, \\ldots, P_N of 1, \\ldots, N.\nFind the number of integers i (1 \\leq i \\leq N) that satisfy the following condition:\n\nFor any integer j (1 \\leq j \\leq i), P_i \\leq P_j.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\nP_1, \\ldots, P_N is a permutation of 1, \\ldots, N.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nP_1 ... P_N\n\nOutput\n\nPrint the number of integers i that satisfy the condition.\n\nSample Input 1\n\n5\n4 2 5 1 3\n\nSample Output 1\n\n3\n\ni=1, 2, and 4 satisfy the condition, but i=3 does not - for example, P_i > P_j holds for j = 1.\n\nSimilarly, i=5 does not satisfy the condition, either. Thus, there are three integers that satisfy the condition.\n\nSample Input 2\n\n4\n4 3 2 1\n\nSample Output 2\n\n4\n\nAll integers i (1 \\leq i \\leq N) satisfy the condition.\n\nSample Input 3\n\n6\n1 2 3 4 5 6\n\nSample Output 3\n\n1\n\nOnly i=1 satisfies the condition.\n\nSample Input 4\n\n8\n5 7 4 2 6 8 1 3\n\nSample Output 4\n\n4\n\nSample Input 5\n\n1\n1\n\nSample Output 5\n\n1", "sample_input": "5\n4 2 5 1 3\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02791", "source_text": "Score : 300 points\n\nProblem Statement\n\nGiven is a permutation P_1, \\ldots, P_N of 1, \\ldots, N.\nFind the number of integers i (1 \\leq i \\leq N) that satisfy the following condition:\n\nFor any integer j (1 \\leq j \\leq i), P_i \\leq P_j.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\nP_1, \\ldots, P_N is a permutation of 1, \\ldots, N.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nP_1 ... P_N\n\nOutput\n\nPrint the number of integers i that satisfy the condition.\n\nSample Input 1\n\n5\n4 2 5 1 3\n\nSample Output 1\n\n3\n\ni=1, 2, and 4 satisfy the condition, but i=3 does not - for example, P_i > P_j holds for j = 1.\n\nSimilarly, i=5 does not satisfy the condition, either. Thus, there are three integers that satisfy the condition.\n\nSample Input 2\n\n4\n4 3 2 1\n\nSample Output 2\n\n4\n\nAll integers i (1 \\leq i \\leq N) satisfy the condition.\n\nSample Input 3\n\n6\n1 2 3 4 5 6\n\nSample Output 3\n\n1\n\nOnly i=1 satisfies the condition.\n\nSample Input 4\n\n8\n5 7 4 2 6 8 1 3\n\nSample Output 4\n\n4\n\nSample Input 5\n\n1\n1\n\nSample Output 5\n\n1", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 56, "memory_kb": 6016}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s690439878", "group_id": "codeNet:p02792", "input_text": "let n = Scanf.sscanf (read_line ()) \"%d\" @@ fun n -> n\n\nlet f a b =\n if a = 0 then 0\n else begin\n let res = ref 0 in\n for i = 1 to n do\n let t = (int_of_char (string_of_int i).[0]) - 48 in\n if t = a && i mod 10 = b then res := !res + 1\n done;\n !res\n end\n\nlet () =\n let ans = ref 0 in\n for i = 0 to 9 do\n for j = 0 to 9 do\n ans := !ans + f i j * f j i\n done\n done;\n Printf.printf \"%d\\n\" !ans", "language": "OCaml", "metadata": {"date": 1590512564, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02792.html", "problem_id": "p02792", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02792/input.txt", "sample_output_relpath": "derived/input_output/data/p02792/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02792/OCaml/s690439878.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s690439878", "user_id": "u811309788"}, "prompt_components": {"gold_output": "17\n", "input_to_evaluate": "let n = Scanf.sscanf (read_line ()) \"%d\" @@ fun n -> n\n\nlet f a b =\n if a = 0 then 0\n else begin\n let res = ref 0 in\n for i = 1 to n do\n let t = (int_of_char (string_of_int i).[0]) - 48 in\n if t = a && i mod 10 = b then res := !res + 1\n done;\n !res\n end\n\nlet () =\n let ans = ref 0 in\n for i = 0 to 9 do\n for j = 0 to 9 do\n ans := !ans + f i j * f j i\n done\n done;\n Printf.printf \"%d\\n\" !ans", "problem_context": "Score : 400 points\n\nProblem Statement\n\nGiven is a positive integer N.\n\nFind the number of pairs (A, B) of positive integers not greater than N that satisfy the following condition:\n\nWhen A and B are written in base ten without leading zeros, the last digit of A is equal to the first digit of B, and the first digit of A is equal to the last digit of B.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n25\n\nSample Output 1\n\n17\n\nThe following 17 pairs satisfy the condition: (1,1), (1,11), (2,2), (2,22), (3,3), (4,4), (5,5), (6,6), (7,7), (8,8), (9,9), (11,1), (11,11), (12,21), (21,12), (22,2), and (22,22).\n\nSample Input 2\n\n1\n\nSample Output 2\n\n1\n\nSample Input 3\n\n100\n\nSample Output 3\n\n108\n\nSample Input 4\n\n2020\n\nSample Output 4\n\n40812\n\nSample Input 5\n\n200000\n\nSample Output 5\n\n400000008", "sample_input": "25\n"}, "reference_outputs": ["17\n"], "source_document_id": "p02792", "source_text": "Score : 400 points\n\nProblem Statement\n\nGiven is a positive integer N.\n\nFind the number of pairs (A, B) of positive integers not greater than N that satisfy the following condition:\n\nWhen A and B are written in base ten without leading zeros, the last digit of A is equal to the first digit of B, and the first digit of A is equal to the last digit of B.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n25\n\nSample Output 1\n\n17\n\nThe following 17 pairs satisfy the condition: (1,1), (1,11), (2,2), (2,22), (3,3), (4,4), (5,5), (6,6), (7,7), (8,8), (9,9), (11,1), (11,11), (12,21), (21,12), (22,2), and (22,22).\n\nSample Input 2\n\n1\n\nSample Output 2\n\n1\n\nSample Input 3\n\n100\n\nSample Output 3\n\n108\n\nSample Input 4\n\n2020\n\nSample Output 4\n\n40812\n\nSample Input 5\n\n200000\n\nSample Output 5\n\n400000008", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 430, "cpu_time_ms": 2103, "memory_kb": 4608}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s463779476", "group_id": "codeNet:p02796", "input_text": "let () =\n let main () =\n let n = int_of_string (read_line ()) in\n let xl = Array.init n (fun _ ->\n Scanf.scanf \" %d %d\" (fun x l -> x, l))\n in\n let l = Array.fold_left (fun acc (x, l) -> (x - l, x + l) :: acc) [] xl in\n let l = List.sort compare l in\n let k = Array.make (n + 1) 1_000_000_001 in\n let () = k.(0) <- -1_000_000_001 in\n let rec loop m = function\n | [] -> m\n | (left, right) :: tl ->\n let rec loop2 m mj =\n if mj < 0 then m else\n let m = if k.(mj) <= left then (\n let () = k.(mj + 1) <- min right k.(mj + 1) in\n max m (mj + 1)\n ) else m\n in\n loop2 m (mj - 1)\n in\n let m = loop2 m m in\n loop m tl\n in\n loop 0 l |> Printf.printf \"%d\\n\"\n in\n main ()", "language": "OCaml", "metadata": {"date": 1579379309, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02796.html", "problem_id": "p02796", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02796/input.txt", "sample_output_relpath": "derived/input_output/data/p02796/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02796/OCaml/s463779476.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s463779476", "user_id": "u342443598"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "let () =\n let main () =\n let n = int_of_string (read_line ()) in\n let xl = Array.init n (fun _ ->\n Scanf.scanf \" %d %d\" (fun x l -> x, l))\n in\n let l = Array.fold_left (fun acc (x, l) -> (x - l, x + l) :: acc) [] xl in\n let l = List.sort compare l in\n let k = Array.make (n + 1) 1_000_000_001 in\n let () = k.(0) <- -1_000_000_001 in\n let rec loop m = function\n | [] -> m\n | (left, right) :: tl ->\n let rec loop2 m mj =\n if mj < 0 then m else\n let m = if k.(mj) <= left then (\n let () = k.(mj + 1) <- min right k.(mj + 1) in\n max m (mj + 1)\n ) else m\n in\n loop2 m (mj - 1)\n in\n let m = loop2 m m in\n loop m tl\n in\n loop 0 l |> Printf.printf \"%d\\n\"\n in\n main ()", "problem_context": "Score : 200 points\n\nProblem Statement\n\nIn a factory, there are N robots placed on a number line.\nRobot i is placed at coordinate X_i and can extend its arms of length L_i in both directions, positive and negative.\n\nWe want to remove zero or more robots so that the movable ranges of arms of no two remaining robots intersect.\nHere, for each i (1 \\leq i \\leq N), the movable range of arms of Robot i is the part of the number line between the coordinates X_i - L_i and X_i + L_i, excluding the endpoints.\n\nFind the maximum number of robots that we can keep.\n\nConstraints\n\n1 \\leq N \\leq 100,000\n\n0 \\leq X_i \\leq 10^9 (1 \\leq i \\leq N)\n\n1 \\leq L_i \\leq 10^9 (1 \\leq i \\leq N)\n\nIf i \\neq j, X_i \\neq X_j.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nX_1 L_1\nX_2 L_2\n\\vdots\nX_N L_N\n\nOutput\n\nPrint the maximum number of robots that we can keep.\n\nSample Input 1\n\n4\n2 4\n4 3\n9 3\n100 5\n\nSample Output 1\n\n3\n\nBy removing Robot 2, we can keep the other three robots.\n\nSample Input 2\n\n2\n8 20\n1 10\n\nSample Output 2\n\n1\n\nSample Input 3\n\n5\n10 1\n2 1\n4 1\n6 1\n8 1\n\nSample Output 3\n\n5", "sample_input": "4\n2 4\n4 3\n9 3\n100 5\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02796", "source_text": "Score : 200 points\n\nProblem Statement\n\nIn a factory, there are N robots placed on a number line.\nRobot i is placed at coordinate X_i and can extend its arms of length L_i in both directions, positive and negative.\n\nWe want to remove zero or more robots so that the movable ranges of arms of no two remaining robots intersect.\nHere, for each i (1 \\leq i \\leq N), the movable range of arms of Robot i is the part of the number line between the coordinates X_i - L_i and X_i + L_i, excluding the endpoints.\n\nFind the maximum number of robots that we can keep.\n\nConstraints\n\n1 \\leq N \\leq 100,000\n\n0 \\leq X_i \\leq 10^9 (1 \\leq i \\leq N)\n\n1 \\leq L_i \\leq 10^9 (1 \\leq i \\leq N)\n\nIf i \\neq j, X_i \\neq X_j.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nX_1 L_1\nX_2 L_2\n\\vdots\nX_N L_N\n\nOutput\n\nPrint the maximum number of robots that we can keep.\n\nSample Input 1\n\n4\n2 4\n4 3\n9 3\n100 5\n\nSample Output 1\n\n3\n\nBy removing Robot 2, we can keep the other three robots.\n\nSample Input 2\n\n2\n8 20\n1 10\n\nSample Output 2\n\n1\n\nSample Input 3\n\n5\n10 1\n2 1\n4 1\n6 1\n8 1\n\nSample Output 3\n\n5", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 996, "cpu_time_ms": 2104, "memory_kb": 17948}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s770055011", "group_id": "codeNet:p02797", "input_text": "let (n, k, s) = Scanf.sscanf (read_line ()) \"%d %d %d\" @@ fun n k s -> (n, k, s)\n\nlet () =\n Array.concat [Array.make k s; Array.make (n - k) (if s = 1000000000 then 1 else s + 1)] \n |> Array.map string_of_int\n |> Array.to_list\n |> String.concat \" \"\n |> print_endline", "language": "OCaml", "metadata": {"date": 1590266040, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02797.html", "problem_id": "p02797", "resource_group": "low_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/OCaml/s770055011.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s770055011", "user_id": "u811309788"}, "prompt_components": {"gold_output": "1 2 3 4\n", "input_to_evaluate": "let (n, k, s) = Scanf.sscanf (read_line ()) \"%d %d %d\" @@ fun n k s -> (n, k, s)\n\nlet () =\n Array.concat [Array.make k s; Array.make (n - k) (if s = 1000000000 then 1 else s + 1)] \n |> Array.map string_of_int\n |> Array.to_list\n |> String.concat \" \"\n |> print_endline", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 31, "memory_kb": 11776}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s536655200", "group_id": "codeNet:p02797", "input_text": "Scanf.scanf \"%d %d %d\" @@ fun n k s -> Array.(append (make k s) @@ make (n - k) (s + if s = 1000000000 then -1 else 1) |> to_list |> List.map string_of_int |> String.concat \" \" |> print_endline)", "language": "OCaml", "metadata": {"date": 1579398773, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02797.html", "problem_id": "p02797", "resource_group": "low_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/OCaml/s536655200.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s536655200", "user_id": "u732304692"}, "prompt_components": {"gold_output": "1 2 3 4\n", "input_to_evaluate": "Scanf.scanf \"%d %d %d\" @@ fun n k s -> Array.(append (make k s) @@ make (n - k) (s + if s = 1000000000 then -1 else 1) |> to_list |> List.map string_of_int |> String.concat \" \" |> print_endline)", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 37, "memory_kb": 15232}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s843791610", "group_id": "codeNet:p02801", "input_text": "let c = (read_line ()).[0] |> Char.code\nlet _ = print_char (Char.chr (c+1))", "language": "OCaml", "metadata": {"date": 1583880117, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02801.html", "problem_id": "p02801", "resource_group": "low_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/OCaml/s843791610.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s843791610", "user_id": "u511870776"}, "prompt_components": {"gold_output": "b\n", "input_to_evaluate": "let c = (read_line ()).[0] |> Char.code\nlet _ = print_char (Char.chr (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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s196921359", "group_id": "codeNet:p02802", "input_text": "let () = Scanf.scanf \"%d %d\\n\" @@ fun n m ->\n let pss = Array.init m @@ fun _ -> Scanf.scanf \"%d %s\\n\" @@ fun p s -> p, s in\n let ac = Array.make n false in\n let wa = Array.make n 0 in\n Array.iter (fun (p, s) ->\n if not ac.(p - 1) then begin\n if s = \"AC\"\n then ac.(p - 1) <- true\n else wa.(p - 1) <- 1 + wa.(p - 1)\n end) pss;\n Printf.printf \"%d %d\\n\"\n (Array.fold_right (fun b -> ( + ) @@ if b then 1 else 0) ac 0) @@\n Array.fold_left ( + ) 0 @@\n Array.init n @@ fun i -> if ac.(i) then wa.(i) else 0\n", "language": "OCaml", "metadata": {"date": 1578887033, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02802.html", "problem_id": "p02802", "resource_group": "low_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/OCaml/s196921359.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s196921359", "user_id": "u504158101"}, "prompt_components": {"gold_output": "2 2\n", "input_to_evaluate": "let () = Scanf.scanf \"%d %d\\n\" @@ fun n m ->\n let pss = Array.init m @@ fun _ -> Scanf.scanf \"%d %s\\n\" @@ fun p s -> p, s in\n let ac = Array.make n false in\n let wa = Array.make n 0 in\n Array.iter (fun (p, s) ->\n if not ac.(p - 1) then begin\n if s = \"AC\"\n then ac.(p - 1) <- true\n else wa.(p - 1) <- 1 + wa.(p - 1)\n end) pss;\n Printf.printf \"%d %d\\n\"\n (Array.fold_right (fun b -> ( + ) @@ if b then 1 else 0) ac 0) @@\n Array.fold_left ( + ) 0 @@\n Array.init n @@ fun i -> if ac.(i) then wa.(i) else 0\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nTakahashi participated in a contest on AtCoder.\n\nThe contest had N problems.\n\nTakahashi made M submissions during the contest.\n\nThe i-th submission was made for the p_i-th problem and received the verdict S_i (AC or WA).\n\nThe number of Takahashi's correct answers is the number of problems on which he received an AC once or more.\n\nThe number of Takahashi's penalties is the sum of the following count for the problems on which he received an AC once or more: the number of WAs received before receiving an AC for the first time on that problem.\n\nFind the numbers of Takahashi's correct answers and penalties.\n\nConstraints\n\nN, M, and p_i are integers.\n\n1 \\leq N \\leq 10^5\n\n0 \\leq M \\leq 10^5\n\n1 \\leq p_i \\leq N\n\nS_i is AC or WA.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\np_1 S_1\n:\np_M S_M\n\nOutput\n\nPrint the number of Takahashi's correct answers and the number of Takahashi's penalties.\n\nSample Input 1\n\n2 5\n1 WA\n1 AC\n2 WA\n2 AC\n2 WA\n\nSample Output 1\n\n2 2\n\nIn his second submission, he received an AC on the first problem for the first time. Before this, he received one WA on this problem.\n\nIn his fourth submission, he received an AC on the second problem for the first time. Before this, he received one WA on this problem.\n\nThus, he has two correct answers and two penalties.\n\nSample Input 2\n\n100000 3\n7777 AC\n7777 AC\n7777 AC\n\nSample Output 2\n\n1 0\n\nNote that it is pointless to get an AC more than once on the same problem.\n\nSample Input 3\n\n6 0\n\nSample Output 3\n\n0 0", "sample_input": "2 5\n1 WA\n1 AC\n2 WA\n2 AC\n2 WA\n"}, "reference_outputs": ["2 2\n"], "source_document_id": "p02802", "source_text": "Score : 300 points\n\nProblem Statement\n\nTakahashi participated in a contest on AtCoder.\n\nThe contest had N problems.\n\nTakahashi made M submissions during the contest.\n\nThe i-th submission was made for the p_i-th problem and received the verdict S_i (AC or WA).\n\nThe number of Takahashi's correct answers is the number of problems on which he received an AC once or more.\n\nThe number of Takahashi's penalties is the sum of the following count for the problems on which he received an AC once or more: the number of WAs received before receiving an AC for the first time on that problem.\n\nFind the numbers of Takahashi's correct answers and penalties.\n\nConstraints\n\nN, M, and p_i are integers.\n\n1 \\leq N \\leq 10^5\n\n0 \\leq M \\leq 10^5\n\n1 \\leq p_i \\leq N\n\nS_i is AC or WA.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\np_1 S_1\n:\np_M S_M\n\nOutput\n\nPrint the number of Takahashi's correct answers and the number of Takahashi's penalties.\n\nSample Input 1\n\n2 5\n1 WA\n1 AC\n2 WA\n2 AC\n2 WA\n\nSample Output 1\n\n2 2\n\nIn his second submission, he received an AC on the first problem for the first time. Before this, he received one WA on this problem.\n\nIn his fourth submission, he received an AC on the second problem for the first time. Before this, he received one WA on this problem.\n\nThus, he has two correct answers and two penalties.\n\nSample Input 2\n\n100000 3\n7777 AC\n7777 AC\n7777 AC\n\nSample Output 2\n\n1 0\n\nNote that it is pointless to get an AC more than once on the same problem.\n\nSample Input 3\n\n6 0\n\nSample Output 3\n\n0 0", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 530, "cpu_time_ms": 54, "memory_kb": 10112}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s959832519", "group_id": "codeNet:p02803", "input_text": "module S = Set.Make (struct type t = int * int let compare = compare end)\n\nlet () =\n let main () =\n let h, w = Scanf.sscanf (read_line ()) \"%d %d\" (fun h w -> h, w) in\n let s = Array.init h (fun _ -> read_line ()) in\n let dfs x y =\n let m = Array.make_matrix h w (-1) in\n let rec loop depth next = function\n | [] -> if S.is_empty next then depth else loop (depth + 1) S.empty (S.elements next)\n | (xx, yy) :: tl ->\n let () = m.(yy).(xx) <- depth in\n let next = if xx > 0 && m.(yy).(xx - 1) < 0 && s.(yy).[xx-1] = '.' then S.add (xx-1, yy) next else next in\n let next = if xx < w - 1 && m.(yy).(xx + 1) < 0 && s.(yy).[xx+1] = '.' then S.add (xx+1, yy) next else next in\n let next = if yy > 0 && m.(yy - 1).(xx) < 0 && s.(yy-1).[xx] = '.' then S.add (xx, yy-1) next else next in\n let next = if yy < h - 1 && m.(yy + 1).(xx) < 0 && s.(yy+1).[xx] = '.' then S.add (xx, yy+1) next else next in\n loop depth next tl\n in\n if s.(y).[x] = '.' then loop 0 S.empty [ x, y ] else 0\n in\n let rec loop_h y acc =\n let rec loop_w x acc =\n if x = w then acc else loop_w (x + 1) (max acc (dfs x y))\n in\n if y = h then acc else loop_h (y + 1) (loop_w 0 acc)\n in\n loop_h 0 0 |> Printf.printf \"%d\\n\"\n in\n main ()", "language": "OCaml", "metadata": {"date": 1578883040, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02803.html", "problem_id": "p02803", "resource_group": "low_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/OCaml/s959832519.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s959832519", "user_id": "u342443598"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "module S = Set.Make (struct type t = int * int let compare = compare end)\n\nlet () =\n let main () =\n let h, w = Scanf.sscanf (read_line ()) \"%d %d\" (fun h w -> h, w) in\n let s = Array.init h (fun _ -> read_line ()) in\n let dfs x y =\n let m = Array.make_matrix h w (-1) in\n let rec loop depth next = function\n | [] -> if S.is_empty next then depth else loop (depth + 1) S.empty (S.elements next)\n | (xx, yy) :: tl ->\n let () = m.(yy).(xx) <- depth in\n let next = if xx > 0 && m.(yy).(xx - 1) < 0 && s.(yy).[xx-1] = '.' then S.add (xx-1, yy) next else next in\n let next = if xx < w - 1 && m.(yy).(xx + 1) < 0 && s.(yy).[xx+1] = '.' then S.add (xx+1, yy) next else next in\n let next = if yy > 0 && m.(yy - 1).(xx) < 0 && s.(yy-1).[xx] = '.' then S.add (xx, yy-1) next else next in\n let next = if yy < h - 1 && m.(yy + 1).(xx) < 0 && s.(yy+1).[xx] = '.' then S.add (xx, yy+1) next else next in\n loop depth next tl\n in\n if s.(y).[x] = '.' then loop 0 S.empty [ x, y ] else 0\n in\n let rec loop_h y acc =\n let rec loop_w x acc =\n if x = w then acc else loop_w (x + 1) (max acc (dfs x y))\n in\n if y = h then acc else loop_h (y + 1) (loop_w 0 acc)\n in\n loop_h 0 0 |> Printf.printf \"%d\\n\"\n in\n main ()", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 46, "memory_kb": 2688}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s930838230", "group_id": "codeNet:p02806", "input_text": "let () = Scanf.scanf \"%d\\n\" @@ fun n ->\n let sts = Array.init n @@ fun _ -> Scanf.scanf \"%s %d\\n\" @@ fun s t -> s, t in\n Scanf.scanf \"%s\\n\" @@ fun x ->\n Printf.printf \"%d\\n\" @@\n snd @@\n List.find (fun (s, _) -> s = x) @@\n snd @@\n Array.fold_right (fun (s, t) (sum, acc) ->\n (sum + t, (s, sum) :: acc)) sts (0, [])", "language": "OCaml", "metadata": {"date": 1579298080, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02806.html", "problem_id": "p02806", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02806/input.txt", "sample_output_relpath": "derived/input_output/data/p02806/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02806/OCaml/s930838230.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s930838230", "user_id": "u504158101"}, "prompt_components": {"gold_output": "30\n", "input_to_evaluate": "let () = Scanf.scanf \"%d\\n\" @@ fun n ->\n let sts = Array.init n @@ fun _ -> Scanf.scanf \"%s %d\\n\" @@ fun s t -> s, t in\n Scanf.scanf \"%s\\n\" @@ fun x ->\n Printf.printf \"%d\\n\" @@\n snd @@\n List.find (fun (s, _) -> s = x) @@\n snd @@\n Array.fold_right (fun (s, t) (sum, acc) ->\n (sum + t, (s, sum) :: acc)) sts (0, [])", "problem_context": "Score : 200 points\n\nProblem Statement\n\nNiwango created a playlist of N songs.\nThe title and the duration of the i-th song are s_i and t_i seconds, respectively.\nIt is guaranteed that s_1,\\ldots,s_N are all distinct.\n\nNiwango was doing some work while playing this playlist. (That is, all the songs were played once, in the order they appear in the playlist, without any pause in between.)\nHowever, he fell asleep during his work, and he woke up after all the songs were played.\nAccording to his record, it turned out that he fell asleep at the very end of the song titled X.\n\nFind the duration of time when some song was played while Niwango was asleep.\n\nConstraints\n\n1 \\leq N \\leq 50\n\ns_i and X are strings of length between 1 and 100 (inclusive) consisting of lowercase English letters.\n\ns_1,\\ldots,s_N are distinct.\n\nThere exists an integer i such that s_i = X.\n\n1 \\leq t_i \\leq 1000\n\nt_i is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\ns_1 t_1\n\\vdots\ns_{N} t_N\nX\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n3\ndwango 2\nsixth 5\nprelims 25\ndwango\n\nSample Output 1\n\n30\n\nWhile Niwango was asleep, two songs were played: sixth and prelims.\n\nThe answer is the total duration of these songs, 30.\n\nSample Input 2\n\n1\nabcde 1000\nabcde\n\nSample Output 2\n\n0\n\nNo songs were played while Niwango was asleep.\n\nIn such a case, the total duration of songs is 0.\n\nSample Input 3\n\n15\nypnxn 279\nkgjgwx 464\nqquhuwq 327\nrxing 549\npmuduhznoaqu 832\ndagktgdarveusju 595\nwunfagppcoi 200\ndhavrncwfw 720\njpcmigg 658\nwrczqxycivdqn 639\nmcmkkbnjfeod 992\nhtqvkgkbhtytsz 130\ntwflegsjz 467\ndswxxrxuzzfhkp 989\nszfwtzfpnscgue 958\npmuduhznoaqu\n\nSample Output 3\n\n6348", "sample_input": "3\ndwango 2\nsixth 5\nprelims 25\ndwango\n"}, "reference_outputs": ["30\n"], "source_document_id": "p02806", "source_text": "Score : 200 points\n\nProblem Statement\n\nNiwango created a playlist of N songs.\nThe title and the duration of the i-th song are s_i and t_i seconds, respectively.\nIt is guaranteed that s_1,\\ldots,s_N are all distinct.\n\nNiwango was doing some work while playing this playlist. (That is, all the songs were played once, in the order they appear in the playlist, without any pause in between.)\nHowever, he fell asleep during his work, and he woke up after all the songs were played.\nAccording to his record, it turned out that he fell asleep at the very end of the song titled X.\n\nFind the duration of time when some song was played while Niwango was asleep.\n\nConstraints\n\n1 \\leq N \\leq 50\n\ns_i and X are strings of length between 1 and 100 (inclusive) consisting of lowercase English letters.\n\ns_1,\\ldots,s_N are distinct.\n\nThere exists an integer i such that s_i = X.\n\n1 \\leq t_i \\leq 1000\n\nt_i is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\ns_1 t_1\n\\vdots\ns_{N} t_N\nX\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n3\ndwango 2\nsixth 5\nprelims 25\ndwango\n\nSample Output 1\n\n30\n\nWhile Niwango was asleep, two songs were played: sixth and prelims.\n\nThe answer is the total duration of these songs, 30.\n\nSample Input 2\n\n1\nabcde 1000\nabcde\n\nSample Output 2\n\n0\n\nNo songs were played while Niwango was asleep.\n\nIn such a case, the total duration of songs is 0.\n\nSample Input 3\n\n15\nypnxn 279\nkgjgwx 464\nqquhuwq 327\nrxing 549\npmuduhznoaqu 832\ndagktgdarveusju 595\nwunfagppcoi 200\ndhavrncwfw 720\njpcmigg 658\nwrczqxycivdqn 639\nmcmkkbnjfeod 992\nhtqvkgkbhtytsz 130\ntwflegsjz 467\ndswxxrxuzzfhkp 989\nszfwtzfpnscgue 958\npmuduhznoaqu\n\nSample Output 3\n\n6348", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 3, "memory_kb": 512}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s934472970", "group_id": "codeNet:p02811", "input_text": "let (k, x) = Scanf.sscanf (read_line()) \"%d %d\" (fun x y -> (x, y))\n\nlet result = if 500 * k >= x then \"Yes\" else \"No\"\n\nlet () = Printf.printf \"%s\\n\" result", "language": "OCaml", "metadata": {"date": 1581223505, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02811.html", "problem_id": "p02811", "resource_group": "low_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/OCaml/s934472970.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s934472970", "user_id": "u818201294"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "let (k, x) = Scanf.sscanf (read_line()) \"%d %d\" (fun x y -> (x, y))\n\nlet result = if 500 * k >= x then \"Yes\" else \"No\"\n\nlet () = Printf.printf \"%s\\n\" result", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s748479243", "group_id": "codeNet:p02812", "input_text": "let count_ABC str sz =\n let rec iter_count pos rest =\n if pos >= sz - 2\n then rest\n else \n if String.sub str pos 3 = \"ABC\"\n then iter_count (pos+1) (rest+1)\n else iter_count (pos+1) rest\n in iter_count 0 0\n\nlet () = Scanf.scanf \"%d\\n %s\" @@ fun n s -> Printf.printf \"%d\\n\" @@ count_ABC s n", "language": "OCaml", "metadata": {"date": 1593141095, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p02812.html", "problem_id": "p02812", "resource_group": "low_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/OCaml/s748479243.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s748479243", "user_id": "u052332717"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "let count_ABC str sz =\n let rec iter_count pos rest =\n if pos >= sz - 2\n then rest\n else \n if String.sub str pos 3 = \"ABC\"\n then iter_count (pos+1) (rest+1)\n else iter_count (pos+1) rest\n in iter_count 0 0\n\nlet () = Scanf.scanf \"%d\\n %s\" @@ fun n s -> Printf.printf \"%d\\n\" @@ count_ABC s n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nWe have a string S of length N consisting of uppercase English letters.\n\nHow many times does ABC occur in S as contiguous subsequences (see Sample Inputs and Outputs)?\n\nConstraints\n\n3 \\leq N \\leq 50\n\nS consists of uppercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS\n\nOutput\n\nPrint number of occurrences of ABC in S as contiguous subsequences.\n\nSample Input 1\n\n10\nZABCDBABCQ\n\nSample Output 1\n\n2\n\nTwo contiguous subsequences of S are equal to ABC: the 2-nd through 4-th characters, and the 7-th through 9-th characters.\n\nSample Input 2\n\n19\nTHREEONEFOURONEFIVE\n\nSample Output 2\n\n0\n\nNo contiguous subsequences of S are equal to ABC.\n\nSample Input 3\n\n33\nABCCABCBABCCABACBCBBABCBCBCBCABCB\n\nSample Output 3\n\n5", "sample_input": "10\nZABCDBABCQ\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02812", "source_text": "Score : 200 points\n\nProblem Statement\n\nWe have a string S of length N consisting of uppercase English letters.\n\nHow many times does ABC occur in S as contiguous subsequences (see Sample Inputs and Outputs)?\n\nConstraints\n\n3 \\leq N \\leq 50\n\nS consists of uppercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS\n\nOutput\n\nPrint number of occurrences of ABC in S as contiguous subsequences.\n\nSample Input 1\n\n10\nZABCDBABCQ\n\nSample Output 1\n\n2\n\nTwo contiguous subsequences of S are equal to ABC: the 2-nd through 4-th characters, and the 7-th through 9-th characters.\n\nSample Input 2\n\n19\nTHREEONEFOURONEFIVE\n\nSample Output 2\n\n0\n\nNo contiguous subsequences of S are equal to ABC.\n\nSample Input 3\n\n33\nABCCABCBABCCABACBCBBABCBCBCBCABCB\n\nSample Output 3\n\n5", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 315, "cpu_time_ms": 9, "memory_kb": 3824}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s357463244", "group_id": "codeNet:p02814", "input_text": "open Batteries\nmodule EnumL = Enum.Labels\nmodule ListL = List.Labels\nmodule ArrayL = Array.Labels\n\nlet dbg0 x = Printf.eprintf \"[debug]%s\\n\" @@ dump x\nlet dbg1 x = dbg0 x; x\n\nlet id = identity\n\nlet (++) n m = List.range n `To m\nlet (++-) n m = if n >= m then List.range n `Downto m else []\nlet (++^) n m = if n < m then List.range n `To (pred m) else []\n\nlet scan fmt = Scanf.sscanf (read_line ()) fmt\n\nlet scan_lines n fmt f =\n if n = 0 then []\n else List.map (fun _ -> scan fmt f) (1 ++ n)\n\nlet scan_list ?sep cnv =\n let line = read_line () in\n (match sep with\n | None -> List.map String.of_char @@ String.to_list line\n | Some sep -> String.split_on_char sep line)\n |> List.map cnv\n\nlet scan_array ?sep cnv = Array.of_list @@ scan_list ?sep cnv\n\nlet scan_matrix n m e ?sep conv =\n let arr = Array.make_matrix n m e in\n ListL.iter (0 ++^ n)\n ~f:(fun i -> arr.(i) <- Array.of_list @@ scan_list ?sep conv);\n arr\n\nlet rec powerset e =\n match Enum.get e with\n | None -> Enum.singleton @@ Enum.empty ()\n | Some v ->\n let f = powerset e in\n let g = Enum.clone f in\n EnumL.map f ~f:(fun x -> let y = Enum.clone x in push y v; y)\n |> Enum.append g\n\nlet permutations l =\n let rec aux l =\n let rec interleave x = function\n | [] -> [[x]]\n | (hd::tl) as lst ->\n (x::lst) ::\n (ListL.map ~f:(List.cons hd) @@ interleave x tl)\n in\n match l with\n | [] -> [[]]\n | hd::tl -> List.concat @@ List.map (interleave hd) @@ aux tl in\n let l = List.sort (List.compare Int.compare) @@ aux @@ List.of_enum l in\n List.enum % ListL.map ~f:List.enum @@ l\n\nlet intersection l =\n EnumL.filter ~f:(fun x -> EnumL.exists ~f:((=) x) @@ Enum.clone l)\n\nlet zip l m =\n let n = min (List.length l) (List.length m) in\n List.combine (List.take n l) (List.take n m)\n\nlet lower_bound n f =\n let rec aux l u =\n if u - l > 1 then\n let m = (l + u) / 2 in\n if f m then aux l m\n else aux m u\n else u in aux (-1) n\n\nlet between n x m = n <= x && x < m\n\nlet (n,m) = scan \"%d %d\" Tuple2.make\nlet ls = scan_list ~sep:' ' Int.of_string\n\nlet rec gcd a b =\n if b = 0 then a\n else gcd b (a mod b)\n\nlet () =\n let ns = ListL.map ls ~f:(fun x ->\n let rec div2 n = if n mod 2 = 0 then succ @@ div2 (n/2) else 0 in\n div2 x) in\n let ms = ListL.map ls ~f:(fun x -> x / 2) in\n List.reduce (fun a b -> a*b / gcd a b) ms\n |> (fun x ->\n if List.for_all ((=) @@ List.hd ns) ns then (m/x + 1) / 2\n else 0)\n |> Printf.printf \"%d\\n\"\n", "language": "OCaml", "metadata": {"date": 1590534618, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02814.html", "problem_id": "p02814", "resource_group": "low_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/OCaml/s357463244.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s357463244", "user_id": "u802614675"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "open Batteries\nmodule EnumL = Enum.Labels\nmodule ListL = List.Labels\nmodule ArrayL = Array.Labels\n\nlet dbg0 x = Printf.eprintf \"[debug]%s\\n\" @@ dump x\nlet dbg1 x = dbg0 x; x\n\nlet id = identity\n\nlet (++) n m = List.range n `To m\nlet (++-) n m = if n >= m then List.range n `Downto m else []\nlet (++^) n m = if n < m then List.range n `To (pred m) else []\n\nlet scan fmt = Scanf.sscanf (read_line ()) fmt\n\nlet scan_lines n fmt f =\n if n = 0 then []\n else List.map (fun _ -> scan fmt f) (1 ++ n)\n\nlet scan_list ?sep cnv =\n let line = read_line () in\n (match sep with\n | None -> List.map String.of_char @@ String.to_list line\n | Some sep -> String.split_on_char sep line)\n |> List.map cnv\n\nlet scan_array ?sep cnv = Array.of_list @@ scan_list ?sep cnv\n\nlet scan_matrix n m e ?sep conv =\n let arr = Array.make_matrix n m e in\n ListL.iter (0 ++^ n)\n ~f:(fun i -> arr.(i) <- Array.of_list @@ scan_list ?sep conv);\n arr\n\nlet rec powerset e =\n match Enum.get e with\n | None -> Enum.singleton @@ Enum.empty ()\n | Some v ->\n let f = powerset e in\n let g = Enum.clone f in\n EnumL.map f ~f:(fun x -> let y = Enum.clone x in push y v; y)\n |> Enum.append g\n\nlet permutations l =\n let rec aux l =\n let rec interleave x = function\n | [] -> [[x]]\n | (hd::tl) as lst ->\n (x::lst) ::\n (ListL.map ~f:(List.cons hd) @@ interleave x tl)\n in\n match l with\n | [] -> [[]]\n | hd::tl -> List.concat @@ List.map (interleave hd) @@ aux tl in\n let l = List.sort (List.compare Int.compare) @@ aux @@ List.of_enum l in\n List.enum % ListL.map ~f:List.enum @@ l\n\nlet intersection l =\n EnumL.filter ~f:(fun x -> EnumL.exists ~f:((=) x) @@ Enum.clone l)\n\nlet zip l m =\n let n = min (List.length l) (List.length m) in\n List.combine (List.take n l) (List.take n m)\n\nlet lower_bound n f =\n let rec aux l u =\n if u - l > 1 then\n let m = (l + u) / 2 in\n if f m then aux l m\n else aux m u\n else u in aux (-1) n\n\nlet between n x m = n <= x && x < m\n\nlet (n,m) = scan \"%d %d\" Tuple2.make\nlet ls = scan_list ~sep:' ' Int.of_string\n\nlet rec gcd a b =\n if b = 0 then a\n else gcd b (a mod b)\n\nlet () =\n let ns = ListL.map ls ~f:(fun x ->\n let rec div2 n = if n mod 2 = 0 then succ @@ div2 (n/2) else 0 in\n div2 x) in\n let ms = ListL.map ls ~f:(fun x -> x / 2) in\n List.reduce (fun a b -> a*b / gcd a b) ms\n |> (fun x ->\n if List.for_all ((=) @@ List.hd ns) ns then (m/x + 1) / 2\n else 0)\n |> Printf.printf \"%d\\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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2489, "cpu_time_ms": 72, "memory_kb": 15616}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s281098289", "group_id": "codeNet:p02814", "input_text": "let () =\n let rec gcd a b = if b = 0 then a else gcd b (a mod b) in\n let lcm a b = a / gcd a b * b in\n let main () =\n let n, m = Scanf.scanf \"%d %d\" (fun n m -> n, m) in\n let a = Array.init n (fun _ -> Scanf.scanf \" %d\" (fun p -> p)) in\n let rec loop i acc =\n if i = n then acc else\n if a.(i) mod 4 = 0 then m + 1 else\n loop (i + 1) (lcm acc (a.(i) / 2))\n in\n let l = loop 1 (a.(0) / 2) in\n (m / l + 1) / 2 |> Printf.printf \"%d\\n\"\n in\n main ()", "language": "OCaml", "metadata": {"date": 1578710793, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02814.html", "problem_id": "p02814", "resource_group": "low_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/OCaml/s281098289.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s281098289", "user_id": "u342443598"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "let () =\n let rec gcd a b = if b = 0 then a else gcd b (a mod b) in\n let lcm a b = a / gcd a b * b in\n let main () =\n let n, m = Scanf.scanf \"%d %d\" (fun n m -> n, m) in\n let a = Array.init n (fun _ -> Scanf.scanf \" %d\" (fun p -> p)) in\n let rec loop i acc =\n if i = n then acc else\n if a.(i) mod 4 = 0 then m + 1 else\n loop (i + 1) (lcm acc (a.(i) / 2))\n in\n let l = loop 1 (a.(0) / 2) in\n (m / l + 1) / 2 |> Printf.printf \"%d\\n\"\n in\n main ()", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 545, "cpu_time_ms": 58, "memory_kb": 5248}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s572421932", "group_id": "codeNet:p02817", "input_text": "let () = Scanf.scanf \"%s %s\" @@ fun s t -> Printf.printf \"%s\\n\" @@ t ^ s", "language": "OCaml", "metadata": {"date": 1593138868, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p02817.html", "problem_id": "p02817", "resource_group": "low_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/OCaml/s572421932.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s572421932", "user_id": "u052332717"}, "prompt_components": {"gold_output": "atcoder\n", "input_to_evaluate": "let () = Scanf.scanf \"%s %s\" @@ fun s t -> Printf.printf \"%s\\n\" @@ 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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 8, "memory_kb": 3660}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s273664865", "group_id": "codeNet:p02817", "input_text": "let _ = Scanf.sscanf (read_line ()) \"%s %s\" (fun a b -> print_endline (b ^ a))", "language": "OCaml", "metadata": {"date": 1587528311, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02817.html", "problem_id": "p02817", "resource_group": "low_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/OCaml/s273664865.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s273664865", "user_id": "u471147483"}, "prompt_components": {"gold_output": "atcoder\n", "input_to_evaluate": "let _ = Scanf.sscanf (read_line ()) \"%s %s\" (fun a b -> print_endline (b ^ a))", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s413927932", "group_id": "codeNet:p02817", "input_text": "let () =\n\tlet s, t = Scanf.scanf \"%s %s\\n\" (fun a b -> a, b) in\n Printf.printf \"%s\\n\" (t ^ s) ", "language": "OCaml", "metadata": {"date": 1578607034, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02817.html", "problem_id": "p02817", "resource_group": "low_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/OCaml/s413927932.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s413927932", "user_id": "u307426615"}, "prompt_components": {"gold_output": "atcoder\n", "input_to_evaluate": "let () =\n\tlet s, t = Scanf.scanf \"%s %s\\n\" (fun a b -> a, b) in\n Printf.printf \"%s\\n\" (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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s566915047", "group_id": "codeNet:p02818", "input_text": "let () =\n Scanf.scanf \"%d %d %d\\n\" @@ fun a b k ->\n let (la, lb) =\n if k <= a then (a-k,b)\n else if k <= a + b then (0,b-(k-a))\n else (0,0) in\n Printf.printf \"%d %d\\n\" la lb", "language": "OCaml", "metadata": {"date": 1600640292, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p02818.html", "problem_id": "p02818", "resource_group": "low_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/OCaml/s566915047.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s566915047", "user_id": "u307426615"}, "prompt_components": {"gold_output": "0 2\n", "input_to_evaluate": "let () =\n Scanf.scanf \"%d %d %d\\n\" @@ fun a b k ->\n let (la, lb) =\n if k <= a then (a-k,b)\n else if k <= a + b then (0,b-(k-a))\n else (0,0) in\n Printf.printf \"%d %d\\n\" la lb", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 6, "memory_kb": 3812}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s052390480", "group_id": "codeNet:p02819", "input_text": "let x = read_int ()\nlet f n = n > 1 && let rec f i = i * i > n || n mod i > 0 && f (i + 1) in f 2\nlet _ = for i = x to 100003 do if f i then (Printf.printf \"%d\\n\" i; exit 0) done", "language": "OCaml", "metadata": {"date": 1577864090, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02819.html", "problem_id": "p02819", "resource_group": "low_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/OCaml/s052390480.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s052390480", "user_id": "u732304692"}, "prompt_components": {"gold_output": "23\n", "input_to_evaluate": "let x = read_int ()\nlet f n = n > 1 && let rec f i = i * i > n || n mod i > 0 && f (i + 1) in f 2\nlet _ = for i = x to 100003 do if f i then (Printf.printf \"%d\\n\" i; exit 0) done", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 2432}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s717460340", "group_id": "codeNet:p02820", "input_text": "let k, ss = Scanf.scanf \"%d %d %d %d %d %s\" @@ fun n k r s p t -> k, Array.init n (fun i -> match t.[i] with 'r' -> p | 's' -> r | _ -> s)\nlet _ = Array.(iteri (fun i s -> if i >= k && s = ss.(i - k) then ss.(i) <- 0) ss; fold_left (+) 0 ss) |> Printf.printf \"%d\\n\"", "language": "OCaml", "metadata": {"date": 1583228828, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02820.html", "problem_id": "p02820", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02820/input.txt", "sample_output_relpath": "derived/input_output/data/p02820/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02820/OCaml/s717460340.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s717460340", "user_id": "u732304692"}, "prompt_components": {"gold_output": "27\n", "input_to_evaluate": "let k, ss = Scanf.scanf \"%d %d %d %d %d %s\" @@ fun n k r s p t -> k, Array.init n (fun i -> match t.[i] with 'r' -> p | 's' -> r | _ -> s)\nlet _ = Array.(iteri (fun i s -> if i >= k && s = ss.(i - k) then ss.(i) <- 0) ss; fold_left (+) 0 ss) |> Printf.printf \"%d\\n\"", "problem_context": "Score : 400 points\n\nProblem Statement\n\nAt an arcade, Takahashi is playing a game called RPS Battle, which is played as follows:\n\nThe player plays N rounds of Rock Paper Scissors against the machine. (See Notes for the description of Rock Paper Scissors. A draw also counts as a round.)\n\nEach time the player wins a round, depending on which hand he/she uses, he/she earns the following score (no points for a draw or a loss):\n\nR points for winning with Rock;\n\nS points for winning with Scissors;\n\nP points for winning with Paper.\n\nHowever, in the i-th round, the player cannot use the hand he/she used in the (i-K)-th round. (In the first K rounds, the player can use any hand.)\n\nBefore the start of the game, the machine decides the hand it will play in each round. With supernatural power, Takahashi managed to read all of those hands.\n\nThe information Takahashi obtained is given as a string T. If the i-th character of T (1 \\leq i \\leq N) is r, the machine will play Rock in the i-th round. Similarly, p and s stand for Paper and Scissors, respectively.\n\nWhat is the maximum total score earned in the game by adequately choosing the hand to play in each round?\n\nNotes\n\nIn this problem, Rock Paper Scissors can be thought of as a two-player game, in which each player simultaneously forms Rock, Paper, or Scissors with a hand.\n\nIf a player chooses Rock and the other chooses Scissors, the player choosing Rock wins;\n\nif a player chooses Scissors and the other chooses Paper, the player choosing Scissors wins;\n\nif a player chooses Paper and the other chooses Rock, the player choosing Paper wins;\n\nif both players play the same hand, it is a draw.\n\nConstraints\n\n2 \\leq N \\leq 10^5\n\n1 \\leq K \\leq N-1\n\n1 \\leq R,S,P \\leq 10^4\n\nN,K,R,S, and P are all integers.\n\n|T| = N\n\nT consists of r, p, and s.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nR S P\nT\n\nOutput\n\nPrint the maximum total score earned in the game.\n\nSample Input 1\n\n5 2\n8 7 6\nrsrpr\n\nSample Output 1\n\n27\n\nThe machine will play {Rock, Scissors, Rock, Paper, Rock}.\n\nWe can, for example, play {Paper, Rock, Rock, Scissors, Paper} against it to earn 27 points.\nWe cannot earn more points, so the answer is 27.\n\nSample Input 2\n\n7 1\n100 10 1\nssssppr\n\nSample Output 2\n\n211\n\nSample Input 3\n\n30 5\n325 234 123\nrspsspspsrpspsppprpsprpssprpsr\n\nSample Output 3\n\n4996", "sample_input": "5 2\n8 7 6\nrsrpr\n"}, "reference_outputs": ["27\n"], "source_document_id": "p02820", "source_text": "Score : 400 points\n\nProblem Statement\n\nAt an arcade, Takahashi is playing a game called RPS Battle, which is played as follows:\n\nThe player plays N rounds of Rock Paper Scissors against the machine. (See Notes for the description of Rock Paper Scissors. A draw also counts as a round.)\n\nEach time the player wins a round, depending on which hand he/she uses, he/she earns the following score (no points for a draw or a loss):\n\nR points for winning with Rock;\n\nS points for winning with Scissors;\n\nP points for winning with Paper.\n\nHowever, in the i-th round, the player cannot use the hand he/she used in the (i-K)-th round. (In the first K rounds, the player can use any hand.)\n\nBefore the start of the game, the machine decides the hand it will play in each round. With supernatural power, Takahashi managed to read all of those hands.\n\nThe information Takahashi obtained is given as a string T. If the i-th character of T (1 \\leq i \\leq N) is r, the machine will play Rock in the i-th round. Similarly, p and s stand for Paper and Scissors, respectively.\n\nWhat is the maximum total score earned in the game by adequately choosing the hand to play in each round?\n\nNotes\n\nIn this problem, Rock Paper Scissors can be thought of as a two-player game, in which each player simultaneously forms Rock, Paper, or Scissors with a hand.\n\nIf a player chooses Rock and the other chooses Scissors, the player choosing Rock wins;\n\nif a player chooses Scissors and the other chooses Paper, the player choosing Scissors wins;\n\nif a player chooses Paper and the other chooses Rock, the player choosing Paper wins;\n\nif both players play the same hand, it is a draw.\n\nConstraints\n\n2 \\leq N \\leq 10^5\n\n1 \\leq K \\leq N-1\n\n1 \\leq R,S,P \\leq 10^4\n\nN,K,R,S, and P are all integers.\n\n|T| = N\n\nT consists of r, p, and s.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nR S P\nT\n\nOutput\n\nPrint the maximum total score earned in the game.\n\nSample Input 1\n\n5 2\n8 7 6\nrsrpr\n\nSample Output 1\n\n27\n\nThe machine will play {Rock, Scissors, Rock, Paper, Rock}.\n\nWe can, for example, play {Paper, Rock, Rock, Scissors, Paper} against it to earn 27 points.\nWe cannot earn more points, so the answer is 27.\n\nSample Input 2\n\n7 1\n100 10 1\nssssppr\n\nSample Output 2\n\n211\n\nSample Input 3\n\n30 5\n325 234 123\nrspsspspsrpspsppprpsprpssprpsr\n\nSample Output 3\n\n4996", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 6, "memory_kb": 3584}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s808655315", "group_id": "codeNet:p02824", "input_text": "let () = Scanf.scanf \"%d %d %d %d\\n\" @@ fun n m v p ->\n let as_ = Array.init n @@ fun _ -> Scanf.scanf \"%d \" @@ fun a -> a in\n Array.sort (fun a a' -> compare a' a) as_;\n let acc = Array.make (n + 1) 0 in\n for i = 0 to n - 1 do\n acc.(i + 1) <- as_.(i) + acc.(i)\n done;\n Printf.printf \"%d\\n\" @@\n Array.fold_left ( + ) 0 @@\n Array.init n @@ fun i ->\n if\n as_.(p - 1) <= as_.(i) ||\n as_.(p - 1) <= as_.(i) + m &&\n acc.(i) - acc.(p - 1)\n <= min (i - p + 1) (n - v) * m + as_.(i) * (i - p + 1)\n then 1\n else 0\n\n", "language": "OCaml", "metadata": {"date": 1577592099, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02824.html", "problem_id": "p02824", "resource_group": "low_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/OCaml/s808655315.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s808655315", "user_id": "u504158101"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "let () = Scanf.scanf \"%d %d %d %d\\n\" @@ fun n m v p ->\n let as_ = Array.init n @@ fun _ -> Scanf.scanf \"%d \" @@ fun a -> a in\n Array.sort (fun a a' -> compare a' a) as_;\n let acc = Array.make (n + 1) 0 in\n for i = 0 to n - 1 do\n acc.(i + 1) <- as_.(i) + acc.(i)\n done;\n Printf.printf \"%d\\n\" @@\n Array.fold_left ( + ) 0 @@\n Array.init n @@ fun i ->\n if\n as_.(p - 1) <= as_.(i) ||\n as_.(p - 1) <= as_.(i) + m &&\n acc.(i) - acc.(p - 1)\n <= min (i - p + 1) (n - v) * m + as_.(i) * (i - p + 1)\n then 1\n else 0\n\n", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 71, "memory_kb": 6784}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s251771786", "group_id": "codeNet:p02829", "input_text": "open Printf\nopen Scanf\n\nlet solve a b = 6 - a - b\n\nlet () =\n scanf \"%d %d \" solve |> printf \"%d\\n\"\n", "language": "OCaml", "metadata": {"date": 1582317811, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02829.html", "problem_id": "p02829", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02829/input.txt", "sample_output_relpath": "derived/input_output/data/p02829/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02829/OCaml/s251771786.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s251771786", "user_id": "u388783188"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "open Printf\nopen Scanf\n\nlet solve a b = 6 - a - b\n\nlet () =\n scanf \"%d %d \" solve |> printf \"%d\\n\"\n", "problem_context": "Score: 100 points\n\nProblem Statement\n\nTakahashi is solving quizzes. He has easily solved all but the last one.\n\nThe last quiz has three choices: 1, 2, and 3.\n\nWith his supernatural power, Takahashi has found out that the choices A and B are both wrong.\n\nPrint the correct choice for this problem.\n\nConstraints\n\nEach of the numbers A and B is 1, 2, or 3.\n\nA and B are different.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA\nB\n\nOutput\n\nPrint the correct choice.\n\nSample Input 1\n\n3\n1\n\nSample Output 1\n\n2\n\nWhen we know 3 and 1 are both wrong, the correct choice is 2.\n\nSample Input 2\n\n1\n2\n\nSample Output 2\n\n3", "sample_input": "3\n1\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02829", "source_text": "Score: 100 points\n\nProblem Statement\n\nTakahashi is solving quizzes. He has easily solved all but the last one.\n\nThe last quiz has three choices: 1, 2, and 3.\n\nWith his supernatural power, Takahashi has found out that the choices A and B are both wrong.\n\nPrint the correct choice for this problem.\n\nConstraints\n\nEach of the numbers A and B is 1, 2, or 3.\n\nA and B are different.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA\nB\n\nOutput\n\nPrint the correct choice.\n\nSample Input 1\n\n3\n1\n\nSample Output 1\n\n2\n\nWhen we know 3 and 1 are both wrong, the correct choice is 2.\n\nSample Input 2\n\n1\n2\n\nSample Output 2\n\n3", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s161704016", "group_id": "codeNet:p02830", "input_text": "let id x = x\n\nlet n = Scanf.scanf \"%d\\n\" id\nlet (s, t) = Scanf.scanf \"%s %s\\n\" @@ fun s t -> (s, t)\n\nlet split = Str.split (Str.regexp \"\")\n\nlet solve = \n List.combine (split s) (split t)\n |> List.map (fun (x, y) -> x ^ y)\n |> String.concat \"\"\n |> print_endline", "language": "OCaml", "metadata": {"date": 1588205778, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02830.html", "problem_id": "p02830", "resource_group": "low_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/OCaml/s161704016.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s161704016", "user_id": "u811309788"}, "prompt_components": {"gold_output": "icpc\n", "input_to_evaluate": "let id x = x\n\nlet n = Scanf.scanf \"%d\\n\" id\nlet (s, t) = Scanf.scanf \"%s %s\\n\" @@ fun s t -> (s, t)\n\nlet split = Str.split (Str.regexp \"\")\n\nlet solve = \n List.combine (split s) (split t)\n |> List.map (fun (x, y) -> x ^ y)\n |> String.concat \"\"\n |> print_endline", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s184643269", "group_id": "codeNet:p02830", "input_text": "let n, st = Scanf.scanf \" %d %s %s\" @@ fun a b c -> a, [|b; c|]\nlet _ = String.init (2 * n) (fun i -> st.(i mod 2).[i / 2]) |> print_endline", "language": "OCaml", "metadata": {"date": 1577224270, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02830.html", "problem_id": "p02830", "resource_group": "low_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/OCaml/s184643269.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s184643269", "user_id": "u732304692"}, "prompt_components": {"gold_output": "icpc\n", "input_to_evaluate": "let n, st = Scanf.scanf \" %d %s %s\" @@ fun a b c -> a, [|b; c|]\nlet _ = String.init (2 * n) (fun i -> st.(i mod 2).[i / 2]) |> print_endline", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 140, "cpu_time_ms": 1, "memory_kb": 2432}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s285522204", "group_id": "codeNet:p02831", "input_text": "let rec gcd a b = if b = 0 then a else gcd b (a mod b)\nlet _ = Printf.printf \"%d\\n\" (Scanf.scanf \"%d %d\" (fun a b -> a / gcd a b * b))\n", "language": "OCaml", "metadata": {"date": 1577073000, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02831.html", "problem_id": "p02831", "resource_group": "low_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/OCaml/s285522204.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s285522204", "user_id": "u798181098"}, "prompt_components": {"gold_output": "6\n", "input_to_evaluate": "let rec gcd a b = if b = 0 then a else gcd b (a mod b)\nlet _ = Printf.printf \"%d\\n\" (Scanf.scanf \"%d %d\" (fun a b -> a / gcd a b * b))\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nTakahashi is organizing a party.\n\nAt the party, each guest will receive one or more snack pieces.\n\nTakahashi predicts that the number of guests at this party will be A or B.\n\nFind the minimum number of pieces that can be evenly distributed to the guests in both of the cases predicted.\n\nWe assume that a piece cannot be divided and distributed to multiple guests.\n\nConstraints\n\n1 \\leq A, B \\leq 10^5\n\nA \\neq B\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the minimum number of pieces that can be evenly distributed to the guests in both of the cases with A guests and B guests.\n\nSample Input 1\n\n2 3\n\nSample Output 1\n\n6\n\nWhen we have six snack pieces, each guest can take three pieces if we have two guests, and each guest can take two if we have three guests.\n\nSample Input 2\n\n123 456\n\nSample Output 2\n\n18696\n\nSample Input 3\n\n100000 99999\n\nSample Output 3\n\n9999900000", "sample_input": "2 3\n"}, "reference_outputs": ["6\n"], "source_document_id": "p02831", "source_text": "Score : 300 points\n\nProblem Statement\n\nTakahashi is organizing a party.\n\nAt the party, each guest will receive one or more snack pieces.\n\nTakahashi predicts that the number of guests at this party will be A or B.\n\nFind the minimum number of pieces that can be evenly distributed to the guests in both of the cases predicted.\n\nWe assume that a piece cannot be divided and distributed to multiple guests.\n\nConstraints\n\n1 \\leq A, B \\leq 10^5\n\nA \\neq B\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the minimum number of pieces that can be evenly distributed to the guests in both of the cases with A guests and B guests.\n\nSample Input 1\n\n2 3\n\nSample Output 1\n\n6\n\nWhen we have six snack pieces, each guest can take three pieces if we have two guests, and each guest can take two if we have three guests.\n\nSample Input 2\n\n123 456\n\nSample Output 2\n\n18696\n\nSample Input 3\n\n100000 99999\n\nSample Output 3\n\n9999900000", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s574054506", "group_id": "codeNet:p02831", "input_text": "let () =\n let rec gcd a b = if b = 0 then a else gcd b (a mod b) in\n let lcm a b = a / gcd a b * b in\n let main () =\n let a, b = Scanf.scanf \"%d %d\" (fun a b -> a, b) in\n Printf.printf \"%d\\n\" (lcm a b)\n in\n main ()", "language": "OCaml", "metadata": {"date": 1577066752, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02831.html", "problem_id": "p02831", "resource_group": "low_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/OCaml/s574054506.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s574054506", "user_id": "u342443598"}, "prompt_components": {"gold_output": "6\n", "input_to_evaluate": "let () =\n let rec gcd a b = if b = 0 then a else gcd b (a mod b) in\n let lcm a b = a / gcd a b * b in\n let main () =\n let a, b = Scanf.scanf \"%d %d\" (fun a b -> a, b) in\n Printf.printf \"%d\\n\" (lcm a b)\n in\n main ()", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 243, "cpu_time_ms": 2, "memory_kb": 4480}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s858131943", "group_id": "codeNet:p02832", "input_text": "let id x = x\n\nlet repeat f = \n let rec loop lst = function\n | 0 -> List.rev lst\n | n -> loop (f () :: lst) (n-1) in\n loop []\n\nlet n = Scanf.scanf \"%d\\n\" id\n\nlet a = repeat (fun () -> Scanf.scanf \" %d\" id) n\n\nlet () = \n let ans = List.fold_left (fun v i -> if i = (v + 1) then v + 1 else v) 0 a in\n print_int @@ if ans = 0 then -1 else n - ans", "language": "OCaml", "metadata": {"date": 1588250595, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02832.html", "problem_id": "p02832", "resource_group": "low_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/OCaml/s858131943.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s858131943", "user_id": "u811309788"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "let id x = x\n\nlet repeat f = \n let rec loop lst = function\n | 0 -> List.rev lst\n | n -> loop (f () :: lst) (n-1) in\n loop []\n\nlet n = Scanf.scanf \"%d\\n\" id\n\nlet a = repeat (fun () -> Scanf.scanf \" %d\" id) n\n\nlet () = \n let ans = List.fold_left (fun v i -> if i = (v + 1) then v + 1 else v) 0 a in\n print_int @@ if ans = 0 then -1 else n - ans", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 69, "memory_kb": 11520}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s517615332", "group_id": "codeNet:p02832", "input_text": "let n, ans = read_int (), ref 0\nlet a_s = Array.init n @@ fun _ -> Scanf.scanf \" %d\" (+) 0\nlet _ = Array.fold_left (fun c a -> if a = c then c + 1 else (incr ans; c)) 1 a_s\nlet _ = Printf.printf \"%d\\n\" @@ if !ans = n then -1 else !ans", "language": "OCaml", "metadata": {"date": 1577134879, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02832.html", "problem_id": "p02832", "resource_group": "low_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/OCaml/s517615332.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s517615332", "user_id": "u732304692"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "let n, ans = read_int (), ref 0\nlet a_s = Array.init n @@ fun _ -> Scanf.scanf \" %d\" (+) 0\nlet _ = Array.fold_left (fun c a -> if a = c then c + 1 else (incr ans; c)) 1 a_s\nlet _ = Printf.printf \"%d\\n\" @@ if !ans = n then -1 else !ans", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 54, "memory_kb": 6272}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s478806244", "group_id": "codeNet:p02833", "input_text": "let () =\n let main () =\n let n = int_of_string (read_line ()) in\n let zeros = if n mod 2 = 1 then 0 else (\n let rec loop i t acc =\n if i > n then acc else\n loop (i * 5) (t + 0) (acc + t * (n / i))\n in\n loop 10 1 0\n )\n in\n Printf.printf \"%d\\n\" zeros\n in\n main ()", "language": "OCaml", "metadata": {"date": 1577068378, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02833.html", "problem_id": "p02833", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02833/input.txt", "sample_output_relpath": "derived/input_output/data/p02833/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02833/OCaml/s478806244.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s478806244", "user_id": "u342443598"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "let () =\n let main () =\n let n = int_of_string (read_line ()) in\n let zeros = if n mod 2 = 1 then 0 else (\n let rec loop i t acc =\n if i > n then acc else\n loop (i * 5) (t + 0) (acc + t * (n / i))\n in\n loop 10 1 0\n )\n in\n Printf.printf \"%d\\n\" zeros\n in\n main ()", "problem_context": "Score : 500 points\n\nProblem Statement\n\nFor an integer n not less than 0, let us define f(n) as follows:\n\nf(n) = 1 (if n < 2)\n\nf(n) = n f(n-2) (if n \\geq 2)\n\nGiven is an integer N. Find the number of trailing zeros in the decimal notation of f(N).\n\nConstraints\n\n0 \\leq N \\leq 10^{18}\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the number of trailing zeros in the decimal notation of f(N).\n\nSample Input 1\n\n12\n\nSample Output 1\n\n1\n\nf(12) = 12 × 10 × 8 × 6 × 4 × 2 = 46080, which has one trailing zero.\n\nSample Input 2\n\n5\n\nSample Output 2\n\n0\n\nf(5) = 5 × 3 × 1 = 15, which has no trailing zeros.\n\nSample Input 3\n\n1000000000000000000\n\nSample Output 3\n\n124999999999999995", "sample_input": "12\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02833", "source_text": "Score : 500 points\n\nProblem Statement\n\nFor an integer n not less than 0, let us define f(n) as follows:\n\nf(n) = 1 (if n < 2)\n\nf(n) = n f(n-2) (if n \\geq 2)\n\nGiven is an integer N. Find the number of trailing zeros in the decimal notation of f(N).\n\nConstraints\n\n0 \\leq N \\leq 10^{18}\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the number of trailing zeros in the decimal notation of f(N).\n\nSample Input 1\n\n12\n\nSample Output 1\n\n1\n\nf(12) = 12 × 10 × 8 × 6 × 4 × 2 = 46080, which has one trailing zero.\n\nSample Input 2\n\n5\n\nSample Output 2\n\n0\n\nf(5) = 5 × 3 × 1 = 15, which has no trailing zeros.\n\nSample Input 3\n\n1000000000000000000\n\nSample Output 3\n\n124999999999999995", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s128707396", "group_id": "codeNet:p02835", "input_text": "let _ = Scanf.sscanf (read_line ()) \"%d %d %d\" (fun a b c ->\n match a + b + c with\n | x when x >= 22 -> print_endline \"bust\"\n | _ -> print_endline \"win\"\n)", "language": "OCaml", "metadata": {"date": 1583898823, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02835.html", "problem_id": "p02835", "resource_group": "low_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/OCaml/s128707396.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s128707396", "user_id": "u511870776"}, "prompt_components": {"gold_output": "win\n", "input_to_evaluate": "let _ = Scanf.sscanf (read_line ()) \"%d %d %d\" (fun a b c ->\n match a + b + c with\n | x when x >= 22 -> print_endline \"bust\"\n | _ -> print_endline \"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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s297586152", "group_id": "codeNet:p02836", "input_text": "let s = read_line () in\nlet rec loop a b acc =\n if a > b then acc else loop (a + 1) (b - 1) (if s.[a] != s.[b] then acc + 1 else acc)\nin\nPrintf.printf \"%d\\n\" (loop 0 (String.length s - 1) 0)", "language": "OCaml", "metadata": {"date": 1575857003, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02836.html", "problem_id": "p02836", "resource_group": "low_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/OCaml/s297586152.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s297586152", "user_id": "u342443598"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "let s = read_line () in\nlet rec loop a b acc =\n if a > b then acc else loop (a + 1) (b - 1) (if s.[a] != s.[b] then acc + 1 else acc)\nin\nPrintf.printf \"%d\\n\" (loop 0 (String.length s - 1) 0)", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 2432}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s199141733", "group_id": "codeNet:p02837", "input_text": "let () =\n let main () =\n let n = int_of_string (read_line ()) in\n let xy = Array.make_matrix n n (-1) in\n for i = 0 to n - 1 do\n let a1 = int_of_string (read_line ()) in\n for j = 0 to a1 - 1 do\n Scanf.sscanf (read_line ()) \"%d %d\" (fun x y -> xy.(i).(x - 1) <- y)\n done\n done;\n let bits a = \n let rec loop a acc =\n if a = 0 then acc else loop (a lsr 1) (acc + (a land 1))\n in\n loop a 0\n in\n let judge i =\n let judge2 t =\n if i land (1 lsl t) = 0 then true else (\n let rec loop2 k =\n if k = n then true else (\n if xy.(t).(k) < 0 then loop2 (k + 1) else (\n if (xy.(t).(k) = 0 && (i land (1 lsl k) = 0)) ||\n (xy.(t).(k) = 1 && (i land (1 lsl k) != 0)) then loop2 (k + 1)\n else false\n )\n )\n in\n loop2 0\n )\n in\n let rec loop s =\n if s = n then true else (\n if judge2 s then loop (s + 1) else false\n )\n in\n loop 0\n in\n let maxn = 1 lsl n in\n let rec loop i acc =\n if i = maxn then acc else\n let acc = if judge i then max acc (bits i) else acc in\n loop (i + 1) acc\n in\n let r = loop 0 0 in\n Printf.printf \"%d\\n\" r\n in\n main ()", "language": "OCaml", "metadata": {"date": 1575858653, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02837.html", "problem_id": "p02837", "resource_group": "low_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/OCaml/s199141733.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s199141733", "user_id": "u342443598"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "let () =\n let main () =\n let n = int_of_string (read_line ()) in\n let xy = Array.make_matrix n n (-1) in\n for i = 0 to n - 1 do\n let a1 = int_of_string (read_line ()) in\n for j = 0 to a1 - 1 do\n Scanf.sscanf (read_line ()) \"%d %d\" (fun x y -> xy.(i).(x - 1) <- y)\n done\n done;\n let bits a = \n let rec loop a acc =\n if a = 0 then acc else loop (a lsr 1) (acc + (a land 1))\n in\n loop a 0\n in\n let judge i =\n let judge2 t =\n if i land (1 lsl t) = 0 then true else (\n let rec loop2 k =\n if k = n then true else (\n if xy.(t).(k) < 0 then loop2 (k + 1) else (\n if (xy.(t).(k) = 0 && (i land (1 lsl k) = 0)) ||\n (xy.(t).(k) = 1 && (i land (1 lsl k) != 0)) then loop2 (k + 1)\n else false\n )\n )\n in\n loop2 0\n )\n in\n let rec loop s =\n if s = n then true else (\n if judge2 s then loop (s + 1) else false\n )\n in\n loop 0\n in\n let maxn = 1 lsl n in\n let rec loop i acc =\n if i = maxn then acc else\n let acc = if judge i then max acc (bits i) else acc in\n loop (i + 1) acc\n in\n let r = loop 0 0 in\n Printf.printf \"%d\\n\" r\n in\n main ()", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1643, "cpu_time_ms": 14, "memory_kb": 4608}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s857007654", "group_id": "codeNet:p02839", "input_text": "module S = Set.Make (struct type t = int let compare = compare end)\n\nlet () =\n let main () =\n let h, w = Scanf.scanf \"%d %d\" (fun h w -> h, w) in\n let a = Array.init h (fun _ -> Array.init w (fun _ -> Scanf.scanf \" %d\" (fun n -> n))) in\n let b = Array.init h (fun _ -> Array.init w (fun _ -> Scanf.scanf \" %d\" (fun n -> n))) in\n let ar = Array.make_matrix (h + 1) (w + 1) (S.singleton 0) in\n let merge s1 s2 v1 v2 =\n let s = S.fold (fun v acc -> S.add (v + v2 - v1) (S.add (v + v1 - v2) acc)) s1 S.empty in\n S.fold (fun v acc -> S.add (v + v2 - v1) (S.add (v + v1 - v2) acc)) s2 s\n in\n for y = 1 to h do\n for x = 1 to w do\n ar.(y).(x) <- merge ar.(y - 1).(x) ar.(y).(x - 1) a.(y - 1).(x - 1) b.(y - 1).(x - 1)\n done\n done;\n let s = S.fold (fun v acc -> min (abs v) acc) ar.(h).(w) max_int in\n Printf.printf \"%d\\n\" s\n in\n main ()", "language": "OCaml", "metadata": {"date": 1575860270, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02839.html", "problem_id": "p02839", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02839/input.txt", "sample_output_relpath": "derived/input_output/data/p02839/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02839/OCaml/s857007654.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s857007654", "user_id": "u342443598"}, "prompt_components": {"gold_output": "0\n", "input_to_evaluate": "module S = Set.Make (struct type t = int let compare = compare end)\n\nlet () =\n let main () =\n let h, w = Scanf.scanf \"%d %d\" (fun h w -> h, w) in\n let a = Array.init h (fun _ -> Array.init w (fun _ -> Scanf.scanf \" %d\" (fun n -> n))) in\n let b = Array.init h (fun _ -> Array.init w (fun _ -> Scanf.scanf \" %d\" (fun n -> n))) in\n let ar = Array.make_matrix (h + 1) (w + 1) (S.singleton 0) in\n let merge s1 s2 v1 v2 =\n let s = S.fold (fun v acc -> S.add (v + v2 - v1) (S.add (v + v1 - v2) acc)) s1 S.empty in\n S.fold (fun v acc -> S.add (v + v2 - v1) (S.add (v + v1 - v2) acc)) s2 s\n in\n for y = 1 to h do\n for x = 1 to w do\n ar.(y).(x) <- merge ar.(y - 1).(x) ar.(y).(x - 1) a.(y - 1).(x - 1) b.(y - 1).(x - 1)\n done\n done;\n let s = S.fold (fun v acc -> min (abs v) acc) ar.(h).(w) max_int in\n Printf.printf \"%d\\n\" s\n in\n main ()", "problem_context": "Score : 500 points\n\nProblem Statement\n\nWe have a grid with H horizontal rows and W vertical columns. Let (i,j) denote the square at the i-th row from the top and the j-th column from the left.\n\nThe square (i, j) has two numbers A_{ij} and B_{ij} written on it.\n\nFirst, for each square, Takahashi paints one of the written numbers red and the other blue.\n\nThen, he travels from the square (1, 1) to the square (H, W). In one move, he can move from a square (i, j) to the square (i+1, j) or the square (i, j+1). He must not leave the grid.\n\nLet the unbalancedness be the absolute difference of the sum of red numbers and the sum of blue numbers written on the squares along Takahashi's path, including the squares (1, 1) and (H, W).\n\nTakahashi wants to make the unbalancedness as small as possible by appropriately painting the grid and traveling on it.\n\nFind the minimum unbalancedness possible.\n\nConstraints\n\n2 \\leq H \\leq 80\n\n2 \\leq W \\leq 80\n\n0 \\leq A_{ij} \\leq 80\n\n0 \\leq B_{ij} \\leq 80\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\nA_{11} A_{12} \\ldots A_{1W}\n:\nA_{H1} A_{H2} \\ldots A_{HW}\nB_{11} B_{12} \\ldots B_{1W}\n:\nB_{H1} B_{H2} \\ldots B_{HW}\n\nOutput\n\nPrint the minimum unbalancedness possible.\n\nSample Input 1\n\n2 2\n1 2\n3 4\n3 4\n2 1\n\nSample Output 1\n\n0\n\nBy painting the grid and traveling on it as shown in the figure below, the sum of red numbers and the sum of blue numbers are 3+3+1=7 and 1+2+4=7, respectively, for the unbalancedness of 0.\n\nSample Input 2\n\n2 3\n1 10 80\n80 10 1\n1 2 3\n4 5 6\n\nSample Output 2\n\n2", "sample_input": "2 2\n1 2\n3 4\n3 4\n2 1\n"}, "reference_outputs": ["0\n"], "source_document_id": "p02839", "source_text": "Score : 500 points\n\nProblem Statement\n\nWe have a grid with H horizontal rows and W vertical columns. Let (i,j) denote the square at the i-th row from the top and the j-th column from the left.\n\nThe square (i, j) has two numbers A_{ij} and B_{ij} written on it.\n\nFirst, for each square, Takahashi paints one of the written numbers red and the other blue.\n\nThen, he travels from the square (1, 1) to the square (H, W). In one move, he can move from a square (i, j) to the square (i+1, j) or the square (i, j+1). He must not leave the grid.\n\nLet the unbalancedness be the absolute difference of the sum of red numbers and the sum of blue numbers written on the squares along Takahashi's path, including the squares (1, 1) and (H, W).\n\nTakahashi wants to make the unbalancedness as small as possible by appropriately painting the grid and traveling on it.\n\nFind the minimum unbalancedness possible.\n\nConstraints\n\n2 \\leq H \\leq 80\n\n2 \\leq W \\leq 80\n\n0 \\leq A_{ij} \\leq 80\n\n0 \\leq B_{ij} \\leq 80\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\nA_{11} A_{12} \\ldots A_{1W}\n:\nA_{H1} A_{H2} \\ldots A_{HW}\nB_{11} B_{12} \\ldots B_{1W}\n:\nB_{H1} B_{H2} \\ldots B_{HW}\n\nOutput\n\nPrint the minimum unbalancedness possible.\n\nSample Input 1\n\n2 2\n1 2\n3 4\n3 4\n2 1\n\nSample Output 1\n\n0\n\nBy painting the grid and traveling on it as shown in the figure below, the sum of red numbers and the sum of blue numbers are 3+3+1=7 and 1+2+4=7, respectively, for the unbalancedness of 0.\n\nSample Input 2\n\n2 3\n1 10 80\n80 10 1\n1 2 3\n4 5 6\n\nSample Output 2\n\n2", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 974, "cpu_time_ms": 2106, "memory_kb": 109048}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s195478092", "group_id": "codeNet:p02841", "input_text": "let m1 = Scanf.sscanf (read_line()) \"%d %d\" (fun a b -> a)\nlet m2 = Scanf.sscanf (read_line()) \"%d %d\" (fun a b -> a)\nlet _ = if m1 != m2 then print_endline \"1\" else print_endline \"0\"", "language": "OCaml", "metadata": {"date": 1583898973, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02841.html", "problem_id": "p02841", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02841/input.txt", "sample_output_relpath": "derived/input_output/data/p02841/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02841/OCaml/s195478092.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s195478092", "user_id": "u511870776"}, "prompt_components": {"gold_output": "0\n", "input_to_evaluate": "let m1 = Scanf.sscanf (read_line()) \"%d %d\" (fun a b -> a)\nlet m2 = Scanf.sscanf (read_line()) \"%d %d\" (fun a b -> a)\nlet _ = if m1 != m2 then print_endline \"1\" else print_endline \"0\"", "problem_context": "Score: 100 points\n\nProblem Statement\n\nIn this problem, a date is written as Y-M-D. For example, 2019-11-30 means November 30, 2019.\n\nIntegers M_1, D_1, M_2, and D_2 will be given as input.\n\nIt is known that the date 2019-M_2-D_2 follows 2019-M_1-D_1.\n\nDetermine whether the date 2019-M_1-D_1 is the last day of a month.\n\nConstraints\n\nBoth 2019-M_1-D_1 and 2019-M_2-D_2 are valid dates in the Gregorian calendar.\n\nThe date 2019-M_2-D_2 follows 2019-M_1-D_1.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nM_1 D_1\nM_2 D_2\n\nOutput\n\nIf the date 2019-M_1-D_1 is the last day of a month, print 1; otherwise, print 0.\n\nSample Input 1\n\n11 16\n11 17\n\nSample Output 1\n\n0\n\nNovember 16 is not the last day of a month.\n\nSample Input 2\n\n11 30\n12 1\n\nSample Output 2\n\n1\n\nNovember 30 is the last day of November.", "sample_input": "11 16\n11 17\n"}, "reference_outputs": ["0\n"], "source_document_id": "p02841", "source_text": "Score: 100 points\n\nProblem Statement\n\nIn this problem, a date is written as Y-M-D. For example, 2019-11-30 means November 30, 2019.\n\nIntegers M_1, D_1, M_2, and D_2 will be given as input.\n\nIt is known that the date 2019-M_2-D_2 follows 2019-M_1-D_1.\n\nDetermine whether the date 2019-M_1-D_1 is the last day of a month.\n\nConstraints\n\nBoth 2019-M_1-D_1 and 2019-M_2-D_2 are valid dates in the Gregorian calendar.\n\nThe date 2019-M_2-D_2 follows 2019-M_1-D_1.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nM_1 D_1\nM_2 D_2\n\nOutput\n\nIf the date 2019-M_1-D_1 is the last day of a month, print 1; otherwise, print 0.\n\nSample Input 1\n\n11 16\n11 17\n\nSample Output 1\n\n0\n\nNovember 16 is not the last day of a month.\n\nSample Input 2\n\n11 30\n12 1\n\nSample Output 2\n\n1\n\nNovember 30 is the last day of November.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s982085481", "group_id": "codeNet:p02842", "input_text": "let () =\n let n = read_int () in\n let ans = n * 100 / 108 in\n let rec check x =\n if x > 46300 then print_endline \":(\"\n else if x * 108 / 100 = n then print_int ans\n else check (x+1) in\n check 1", "language": "OCaml", "metadata": {"date": 1592438306, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02842.html", "problem_id": "p02842", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02842/input.txt", "sample_output_relpath": "derived/input_output/data/p02842/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02842/OCaml/s982085481.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s982085481", "user_id": "u307426615"}, "prompt_components": {"gold_output": "400\n", "input_to_evaluate": "let () =\n let n = read_int () in\n let ans = n * 100 / 108 in\n let rec check x =\n if x > 46300 then print_endline \":(\"\n else if x * 108 / 100 = n then print_int ans\n else check (x+1) in\n check 1", "problem_context": "Score: 200 points\n\nProblem Statement\n\nTakahashi bought a piece of apple pie at ABC Confiserie. According to his memory, he paid N yen (the currency of Japan) for it.\n\nThe consumption tax rate for foods in this shop is 8 percent. That is, to buy an apple pie priced at X yen before tax, you have to pay X \\times 1.08 yen (rounded down to the nearest integer).\n\nTakahashi forgot the price of his apple pie before tax, X, and wants to know it again. Write a program that takes N as input and finds X. We assume X is an integer.\n\nIf there are multiple possible values for X, find any one of them. Also, Takahashi's memory of N, the amount he paid, may be incorrect. If no value could be X, report that fact.\n\nConstraints\n\n1 \\leq N \\leq 50000\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nIf there are values that could be X, the price of the apple pie before tax, print any one of them.\n\nIf there are multiple such values, printing any one of them will be accepted.\n\nIf no value could be X, print :(.\n\nSample Input 1\n\n432\n\nSample Output 1\n\n400\n\nIf the apple pie is priced at 400 yen before tax, you have to pay 400 \\times 1.08 = 432 yen to buy one.\n\nOtherwise, the amount you have to pay will not be 432 yen.\n\nSample Input 2\n\n1079\n\nSample Output 2\n\n:(\n\nThere is no possible price before tax for which you have to pay 1079 yen with tax.\n\nSample Input 3\n\n1001\n\nSample Output 3\n\n927\n\nIf the apple pie is priced 927 yen before tax, by rounding down 927 \\times 1.08 = 1001.16, you have to pay 1001 yen.", "sample_input": "432\n"}, "reference_outputs": ["400\n"], "source_document_id": "p02842", "source_text": "Score: 200 points\n\nProblem Statement\n\nTakahashi bought a piece of apple pie at ABC Confiserie. According to his memory, he paid N yen (the currency of Japan) for it.\n\nThe consumption tax rate for foods in this shop is 8 percent. That is, to buy an apple pie priced at X yen before tax, you have to pay X \\times 1.08 yen (rounded down to the nearest integer).\n\nTakahashi forgot the price of his apple pie before tax, X, and wants to know it again. Write a program that takes N as input and finds X. We assume X is an integer.\n\nIf there are multiple possible values for X, find any one of them. Also, Takahashi's memory of N, the amount he paid, may be incorrect. If no value could be X, report that fact.\n\nConstraints\n\n1 \\leq N \\leq 50000\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nIf there are values that could be X, the price of the apple pie before tax, print any one of them.\n\nIf there are multiple such values, printing any one of them will be accepted.\n\nIf no value could be X, print :(.\n\nSample Input 1\n\n432\n\nSample Output 1\n\n400\n\nIf the apple pie is priced at 400 yen before tax, you have to pay 400 \\times 1.08 = 432 yen to buy one.\n\nOtherwise, the amount you have to pay will not be 432 yen.\n\nSample Input 2\n\n1079\n\nSample Output 2\n\n:(\n\nThere is no possible price before tax for which you have to pay 1079 yen with tax.\n\nSample Input 3\n\n1001\n\nSample Output 3\n\n927\n\nIf the apple pie is priced 927 yen before tax, by rounding down 927 \\times 1.08 = 1001.16, you have to pay 1001 yen.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 2, "memory_kb": 512}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s613252865", "group_id": "codeNet:p02842", "input_text": "(*\nocamlfind ocamlopt -package batteries -linkpkg main.ml -o a.out\n*)\nopen Batteries\n\nlet () =\n Scanf.sscanf (read_line ()) \"%f\" (\n fun n -> \n let a = n /. 1.08 in\n let fa = truncate ((floor a) *. 1.08) in\n let ca = truncate ((ceil a) *. 1.08) in\n if fa = int_of_float n then\n string_of_int (truncate (floor a))\n else if ca = int_of_float n then\n string_of_int (truncate (ceil a))\n else\n \":(\"\n ) |> Printf.printf \"%s\\n\"\n", "language": "OCaml", "metadata": {"date": 1589936284, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02842.html", "problem_id": "p02842", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02842/input.txt", "sample_output_relpath": "derived/input_output/data/p02842/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02842/OCaml/s613252865.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s613252865", "user_id": "u280335093"}, "prompt_components": {"gold_output": "400\n", "input_to_evaluate": "(*\nocamlfind ocamlopt -package batteries -linkpkg main.ml -o a.out\n*)\nopen Batteries\n\nlet () =\n Scanf.sscanf (read_line ()) \"%f\" (\n fun n -> \n let a = n /. 1.08 in\n let fa = truncate ((floor a) *. 1.08) in\n let ca = truncate ((ceil a) *. 1.08) in\n if fa = int_of_float n then\n string_of_int (truncate (floor a))\n else if ca = int_of_float n then\n string_of_int (truncate (ceil a))\n else\n \":(\"\n ) |> Printf.printf \"%s\\n\"\n", "problem_context": "Score: 200 points\n\nProblem Statement\n\nTakahashi bought a piece of apple pie at ABC Confiserie. According to his memory, he paid N yen (the currency of Japan) for it.\n\nThe consumption tax rate for foods in this shop is 8 percent. That is, to buy an apple pie priced at X yen before tax, you have to pay X \\times 1.08 yen (rounded down to the nearest integer).\n\nTakahashi forgot the price of his apple pie before tax, X, and wants to know it again. Write a program that takes N as input and finds X. We assume X is an integer.\n\nIf there are multiple possible values for X, find any one of them. Also, Takahashi's memory of N, the amount he paid, may be incorrect. If no value could be X, report that fact.\n\nConstraints\n\n1 \\leq N \\leq 50000\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nIf there are values that could be X, the price of the apple pie before tax, print any one of them.\n\nIf there are multiple such values, printing any one of them will be accepted.\n\nIf no value could be X, print :(.\n\nSample Input 1\n\n432\n\nSample Output 1\n\n400\n\nIf the apple pie is priced at 400 yen before tax, you have to pay 400 \\times 1.08 = 432 yen to buy one.\n\nOtherwise, the amount you have to pay will not be 432 yen.\n\nSample Input 2\n\n1079\n\nSample Output 2\n\n:(\n\nThere is no possible price before tax for which you have to pay 1079 yen with tax.\n\nSample Input 3\n\n1001\n\nSample Output 3\n\n927\n\nIf the apple pie is priced 927 yen before tax, by rounding down 927 \\times 1.08 = 1001.16, you have to pay 1001 yen.", "sample_input": "432\n"}, "reference_outputs": ["400\n"], "source_document_id": "p02842", "source_text": "Score: 200 points\n\nProblem Statement\n\nTakahashi bought a piece of apple pie at ABC Confiserie. According to his memory, he paid N yen (the currency of Japan) for it.\n\nThe consumption tax rate for foods in this shop is 8 percent. That is, to buy an apple pie priced at X yen before tax, you have to pay X \\times 1.08 yen (rounded down to the nearest integer).\n\nTakahashi forgot the price of his apple pie before tax, X, and wants to know it again. Write a program that takes N as input and finds X. We assume X is an integer.\n\nIf there are multiple possible values for X, find any one of them. Also, Takahashi's memory of N, the amount he paid, may be incorrect. If no value could be X, report that fact.\n\nConstraints\n\n1 \\leq N \\leq 50000\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nIf there are values that could be X, the price of the apple pie before tax, print any one of them.\n\nIf there are multiple such values, printing any one of them will be accepted.\n\nIf no value could be X, print :(.\n\nSample Input 1\n\n432\n\nSample Output 1\n\n400\n\nIf the apple pie is priced at 400 yen before tax, you have to pay 400 \\times 1.08 = 432 yen to buy one.\n\nOtherwise, the amount you have to pay will not be 432 yen.\n\nSample Input 2\n\n1079\n\nSample Output 2\n\n:(\n\nThere is no possible price before tax for which you have to pay 1079 yen with tax.\n\nSample Input 3\n\n1001\n\nSample Output 3\n\n927\n\nIf the apple pie is priced 927 yen before tax, by rounding down 927 \\times 1.08 = 1001.16, you have to pay 1001 yen.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 6, "memory_kb": 1536}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s270494941", "group_id": "codeNet:p02842", "input_text": "let () =\n let n = read_int () in\n let ans = ref (-1) in\n for i = 0 to n do\n let x = float_of_int i *. 1.08 |> int_of_float in\n if x = n then ans := i else ()\n done;\n if !ans >= 0 then print_int !ans else print_string \":(\";\n print_newline ()\n", "language": "OCaml", "metadata": {"date": 1587097695, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02842.html", "problem_id": "p02842", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02842/input.txt", "sample_output_relpath": "derived/input_output/data/p02842/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02842/OCaml/s270494941.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s270494941", "user_id": "u395620499"}, "prompt_components": {"gold_output": "400\n", "input_to_evaluate": "let () =\n let n = read_int () in\n let ans = ref (-1) in\n for i = 0 to n do\n let x = float_of_int i *. 1.08 |> int_of_float in\n if x = n then ans := i else ()\n done;\n if !ans >= 0 then print_int !ans else print_string \":(\";\n print_newline ()\n", "problem_context": "Score: 200 points\n\nProblem Statement\n\nTakahashi bought a piece of apple pie at ABC Confiserie. According to his memory, he paid N yen (the currency of Japan) for it.\n\nThe consumption tax rate for foods in this shop is 8 percent. That is, to buy an apple pie priced at X yen before tax, you have to pay X \\times 1.08 yen (rounded down to the nearest integer).\n\nTakahashi forgot the price of his apple pie before tax, X, and wants to know it again. Write a program that takes N as input and finds X. We assume X is an integer.\n\nIf there are multiple possible values for X, find any one of them. Also, Takahashi's memory of N, the amount he paid, may be incorrect. If no value could be X, report that fact.\n\nConstraints\n\n1 \\leq N \\leq 50000\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nIf there are values that could be X, the price of the apple pie before tax, print any one of them.\n\nIf there are multiple such values, printing any one of them will be accepted.\n\nIf no value could be X, print :(.\n\nSample Input 1\n\n432\n\nSample Output 1\n\n400\n\nIf the apple pie is priced at 400 yen before tax, you have to pay 400 \\times 1.08 = 432 yen to buy one.\n\nOtherwise, the amount you have to pay will not be 432 yen.\n\nSample Input 2\n\n1079\n\nSample Output 2\n\n:(\n\nThere is no possible price before tax for which you have to pay 1079 yen with tax.\n\nSample Input 3\n\n1001\n\nSample Output 3\n\n927\n\nIf the apple pie is priced 927 yen before tax, by rounding down 927 \\times 1.08 = 1001.16, you have to pay 1001 yen.", "sample_input": "432\n"}, "reference_outputs": ["400\n"], "source_document_id": "p02842", "source_text": "Score: 200 points\n\nProblem Statement\n\nTakahashi bought a piece of apple pie at ABC Confiserie. According to his memory, he paid N yen (the currency of Japan) for it.\n\nThe consumption tax rate for foods in this shop is 8 percent. That is, to buy an apple pie priced at X yen before tax, you have to pay X \\times 1.08 yen (rounded down to the nearest integer).\n\nTakahashi forgot the price of his apple pie before tax, X, and wants to know it again. Write a program that takes N as input and finds X. We assume X is an integer.\n\nIf there are multiple possible values for X, find any one of them. Also, Takahashi's memory of N, the amount he paid, may be incorrect. If no value could be X, report that fact.\n\nConstraints\n\n1 \\leq N \\leq 50000\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nIf there are values that could be X, the price of the apple pie before tax, print any one of them.\n\nIf there are multiple such values, printing any one of them will be accepted.\n\nIf no value could be X, print :(.\n\nSample Input 1\n\n432\n\nSample Output 1\n\n400\n\nIf the apple pie is priced at 400 yen before tax, you have to pay 400 \\times 1.08 = 432 yen to buy one.\n\nOtherwise, the amount you have to pay will not be 432 yen.\n\nSample Input 2\n\n1079\n\nSample Output 2\n\n:(\n\nThere is no possible price before tax for which you have to pay 1079 yen with tax.\n\nSample Input 3\n\n1001\n\nSample Output 3\n\n927\n\nIf the apple pie is priced 927 yen before tax, by rounding down 927 \\times 1.08 = 1001.16, you have to pay 1001 yen.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 253, "cpu_time_ms": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s186175973", "group_id": "codeNet:p02842", "input_text": "let () = Scanf.scanf \"%d\" @@ fun n ->\n try\n Printf.printf \"%d\\n\" @@\n List.find (fun i -> i * 108 / 100 = n) @@\n Array.to_list @@\n Array.init (n + 1) @@ fun i -> i\n with Not_found -> print_endline \":(\"\n", "language": "OCaml", "metadata": {"date": 1575706722, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02842.html", "problem_id": "p02842", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02842/input.txt", "sample_output_relpath": "derived/input_output/data/p02842/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02842/OCaml/s186175973.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s186175973", "user_id": "u504158101"}, "prompt_components": {"gold_output": "400\n", "input_to_evaluate": "let () = Scanf.scanf \"%d\" @@ fun n ->\n try\n Printf.printf \"%d\\n\" @@\n List.find (fun i -> i * 108 / 100 = n) @@\n Array.to_list @@\n Array.init (n + 1) @@ fun i -> i\n with Not_found -> print_endline \":(\"\n", "problem_context": "Score: 200 points\n\nProblem Statement\n\nTakahashi bought a piece of apple pie at ABC Confiserie. According to his memory, he paid N yen (the currency of Japan) for it.\n\nThe consumption tax rate for foods in this shop is 8 percent. That is, to buy an apple pie priced at X yen before tax, you have to pay X \\times 1.08 yen (rounded down to the nearest integer).\n\nTakahashi forgot the price of his apple pie before tax, X, and wants to know it again. Write a program that takes N as input and finds X. We assume X is an integer.\n\nIf there are multiple possible values for X, find any one of them. Also, Takahashi's memory of N, the amount he paid, may be incorrect. If no value could be X, report that fact.\n\nConstraints\n\n1 \\leq N \\leq 50000\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nIf there are values that could be X, the price of the apple pie before tax, print any one of them.\n\nIf there are multiple such values, printing any one of them will be accepted.\n\nIf no value could be X, print :(.\n\nSample Input 1\n\n432\n\nSample Output 1\n\n400\n\nIf the apple pie is priced at 400 yen before tax, you have to pay 400 \\times 1.08 = 432 yen to buy one.\n\nOtherwise, the amount you have to pay will not be 432 yen.\n\nSample Input 2\n\n1079\n\nSample Output 2\n\n:(\n\nThere is no possible price before tax for which you have to pay 1079 yen with tax.\n\nSample Input 3\n\n1001\n\nSample Output 3\n\n927\n\nIf the apple pie is priced 927 yen before tax, by rounding down 927 \\times 1.08 = 1001.16, you have to pay 1001 yen.", "sample_input": "432\n"}, "reference_outputs": ["400\n"], "source_document_id": "p02842", "source_text": "Score: 200 points\n\nProblem Statement\n\nTakahashi bought a piece of apple pie at ABC Confiserie. According to his memory, he paid N yen (the currency of Japan) for it.\n\nThe consumption tax rate for foods in this shop is 8 percent. That is, to buy an apple pie priced at X yen before tax, you have to pay X \\times 1.08 yen (rounded down to the nearest integer).\n\nTakahashi forgot the price of his apple pie before tax, X, and wants to know it again. Write a program that takes N as input and finds X. We assume X is an integer.\n\nIf there are multiple possible values for X, find any one of them. Also, Takahashi's memory of N, the amount he paid, may be incorrect. If no value could be X, report that fact.\n\nConstraints\n\n1 \\leq N \\leq 50000\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nIf there are values that could be X, the price of the apple pie before tax, print any one of them.\n\nIf there are multiple such values, printing any one of them will be accepted.\n\nIf no value could be X, print :(.\n\nSample Input 1\n\n432\n\nSample Output 1\n\n400\n\nIf the apple pie is priced at 400 yen before tax, you have to pay 400 \\times 1.08 = 432 yen to buy one.\n\nOtherwise, the amount you have to pay will not be 432 yen.\n\nSample Input 2\n\n1079\n\nSample Output 2\n\n:(\n\nThere is no possible price before tax for which you have to pay 1079 yen with tax.\n\nSample Input 3\n\n1001\n\nSample Output 3\n\n927\n\nIf the apple pie is priced 927 yen before tax, by rounding down 927 \\times 1.08 = 1001.16, you have to pay 1001 yen.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 2, "memory_kb": 1920}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s538185341", "group_id": "codeNet:p02843", "input_text": "Scanf.scanf \"%d\" (fun x -> if x mod 100 > x / 100 * 5 then \"0\" else \"1\")\n|> print_endline\n", "language": "OCaml", "metadata": {"date": 1575255154, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02843.html", "problem_id": "p02843", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02843/input.txt", "sample_output_relpath": "derived/input_output/data/p02843/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02843/OCaml/s538185341.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s538185341", "user_id": "u798181098"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "Scanf.scanf \"%d\" (fun x -> if x mod 100 > x / 100 * 5 then \"0\" else \"1\")\n|> print_endline\n", "problem_context": "Score: 300 points\n\nProblem Statement\n\nAtCoder Mart sells 1000000 of each of the six items below:\n\nRiceballs, priced at 100 yen (the currency of Japan) each\n\nSandwiches, priced at 101 yen each\n\nCookies, priced at 102 yen each\n\nCakes, priced at 103 yen each\n\nCandies, priced at 104 yen each\n\nComputers, priced at 105 yen each\n\nTakahashi wants to buy some of them that cost exactly X yen in total.\nDetermine whether this is possible.\n\n(Ignore consumption tax.)\n\nConstraints\n\n1 \\leq X \\leq 100000\n\nX is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX\n\nOutput\n\nIf it is possible to buy some set of items that cost exactly X yen in total, print 1; otherwise, print 0.\n\nSample Input 1\n\n615\n\nSample Output 1\n\n1\n\nFor example, we can buy one of each kind of item, which will cost 100+101+102+103+104+105=615 yen in total.\n\nSample Input 2\n\n217\n\nSample Output 2\n\n0\n\nNo set of items costs 217 yen in total.", "sample_input": "615\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02843", "source_text": "Score: 300 points\n\nProblem Statement\n\nAtCoder Mart sells 1000000 of each of the six items below:\n\nRiceballs, priced at 100 yen (the currency of Japan) each\n\nSandwiches, priced at 101 yen each\n\nCookies, priced at 102 yen each\n\nCakes, priced at 103 yen each\n\nCandies, priced at 104 yen each\n\nComputers, priced at 105 yen each\n\nTakahashi wants to buy some of them that cost exactly X yen in total.\nDetermine whether this is possible.\n\n(Ignore consumption tax.)\n\nConstraints\n\n1 \\leq X \\leq 100000\n\nX is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX\n\nOutput\n\nIf it is possible to buy some set of items that cost exactly X yen in total, print 1; otherwise, print 0.\n\nSample Input 1\n\n615\n\nSample Output 1\n\n1\n\nFor example, we can buy one of each kind of item, which will cost 100+101+102+103+104+105=615 yen in total.\n\nSample Input 2\n\n217\n\nSample Output 2\n\n0\n\nNo set of items costs 217 yen in total.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s398302014", "group_id": "codeNet:p02844", "input_text": "open Batteries\n\nlet scan fmt f =\n Scanf.sscanf (read_line ()) fmt f\n\nlet scan_list cnv =\n read_line ()\n |> String.split_on_char ' '\n |> List.map cnv\n\nlet scan_array n m e conv =\n let arr = Array.make_matrix n m e in\n Enum.Labels.iter (0 --^ n)\n ~f:(fun i -> arr.(i) <- Array.of_list @@ scan_list conv);\n arr\n\nlet rec zip xs ys =\n match xs, ys with\n | [], _ -> []\n | _, [] -> []\n | x::xs, y::ys ->\n (x, y) :: zip xs ys\n\nlet dbg x = Printf.eprintf \"[debug]%s\\n\" @@ dump x; x\n\nlet n = scan \"%d\" identity\nlet s = scan \"%s\" identity\n\nlet () =\n Enum.Labels.map (0 --^ 1000)\n ~f:(fun i ->\n let d = String.to_list @@ Printf.sprintf \"%03d\" i in\n let (result, _) = List.Labels.fold_left d\n ~init:(true, 0) ~f:(fun (b, i) c ->\n if b then\n let e = String.of_char c in\n match String.Exceptionless.find_from s i e with\n | Some i -> (true, i+1)\n | None -> (false, i)\n else (false, i))\n in\n if result then 1 else 0)\n |> Enum.sum\n |> Printf.printf \"%d\\n\"\n", "language": "OCaml", "metadata": {"date": 1586875907, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02844.html", "problem_id": "p02844", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02844/input.txt", "sample_output_relpath": "derived/input_output/data/p02844/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02844/OCaml/s398302014.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s398302014", "user_id": "u802614675"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "open Batteries\n\nlet scan fmt f =\n Scanf.sscanf (read_line ()) fmt f\n\nlet scan_list cnv =\n read_line ()\n |> String.split_on_char ' '\n |> List.map cnv\n\nlet scan_array n m e conv =\n let arr = Array.make_matrix n m e in\n Enum.Labels.iter (0 --^ n)\n ~f:(fun i -> arr.(i) <- Array.of_list @@ scan_list conv);\n arr\n\nlet rec zip xs ys =\n match xs, ys with\n | [], _ -> []\n | _, [] -> []\n | x::xs, y::ys ->\n (x, y) :: zip xs ys\n\nlet dbg x = Printf.eprintf \"[debug]%s\\n\" @@ dump x; x\n\nlet n = scan \"%d\" identity\nlet s = scan \"%s\" identity\n\nlet () =\n Enum.Labels.map (0 --^ 1000)\n ~f:(fun i ->\n let d = String.to_list @@ Printf.sprintf \"%03d\" i in\n let (result, _) = List.Labels.fold_left d\n ~init:(true, 0) ~f:(fun (b, i) c ->\n if b then\n let e = String.of_char c in\n match String.Exceptionless.find_from s i e with\n | Some i -> (true, i+1)\n | None -> (false, i)\n else (false, i))\n in\n if result then 1 else 0)\n |> Enum.sum\n |> Printf.printf \"%d\\n\"\n", "problem_context": "Score: 400 points\n\nProblem Statement\n\nAtCoder Inc. has decided to lock the door of its office with a 3-digit PIN code.\n\nThe company has an N-digit lucky number, S. Takahashi, the president, will erase N-3 digits from S and concatenate the remaining 3 digits without changing the order to set the PIN code.\n\nHow many different PIN codes can he set this way?\n\nBoth the lucky number and the PIN code may begin with a 0.\n\nConstraints\n\n4 \\leq N \\leq 30000\n\nS is a string of length N consisting of digits.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS\n\nOutput\n\nPrint the number of different PIN codes Takahashi can set.\n\nSample Input 1\n\n4\n0224\n\nSample Output 1\n\n3\n\nTakahashi has the following options:\n\nErase the first digit of S and set 224.\n\nErase the second digit of S and set 024.\n\nErase the third digit of S and set 024.\n\nErase the fourth digit of S and set 022.\n\nThus, he can set three different PIN codes: 022, 024, and 224.\n\nSample Input 2\n\n6\n123123\n\nSample Output 2\n\n17\n\nSample Input 3\n\n19\n3141592653589793238\n\nSample Output 3\n\n329", "sample_input": "4\n0224\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02844", "source_text": "Score: 400 points\n\nProblem Statement\n\nAtCoder Inc. has decided to lock the door of its office with a 3-digit PIN code.\n\nThe company has an N-digit lucky number, S. Takahashi, the president, will erase N-3 digits from S and concatenate the remaining 3 digits without changing the order to set the PIN code.\n\nHow many different PIN codes can he set this way?\n\nBoth the lucky number and the PIN code may begin with a 0.\n\nConstraints\n\n4 \\leq N \\leq 30000\n\nS is a string of length N consisting of digits.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS\n\nOutput\n\nPrint the number of different PIN codes Takahashi can set.\n\nSample Input 1\n\n4\n0224\n\nSample Output 1\n\n3\n\nTakahashi has the following options:\n\nErase the first digit of S and set 224.\n\nErase the second digit of S and set 024.\n\nErase the third digit of S and set 024.\n\nErase the fourth digit of S and set 022.\n\nThus, he can set three different PIN codes: 022, 024, and 224.\n\nSample Input 2\n\n6\n123123\n\nSample Output 2\n\n17\n\nSample Input 3\n\n19\n3141592653589793238\n\nSample Output 3\n\n329", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1098, "cpu_time_ms": 50, "memory_kb": 4224}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s433690874", "group_id": "codeNet:p02845", "input_text": "let m_1e9 = int_of_float 1e9 + 7\nlet ( *^ ) x y = ((x mod m_1e9) * (y mod m_1e9)) mod m_1e9\nlet split_string ?(pattern=\" \") = Str.split @@ Str.regexp pattern\n\nlet n = Scanf.sscanf (read_line ()) \"%d\" @@ fun n -> n\nlet a = read_line () |> split_string |> List.map int_of_string\n\nlet rec loop ans arr = function\n | [] -> Printf.printf \"%d\\n\" @@ ans\n | x :: xs -> \n let t = Array.fold_left (fun s i -> s + if i = x then 1 else 0) 0 arr in\n let i = if arr.(0) = x then 0 else if arr.(1) = x then 1 else 2 in\n arr.(i) <- arr.(i) + 1;\n loop (ans *^ t) arr xs\n\nlet () = loop 1 (Array.make 3 0) a", "language": "OCaml", "metadata": {"date": 1590546227, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02845.html", "problem_id": "p02845", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02845/input.txt", "sample_output_relpath": "derived/input_output/data/p02845/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02845/OCaml/s433690874.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s433690874", "user_id": "u811309788"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "let m_1e9 = int_of_float 1e9 + 7\nlet ( *^ ) x y = ((x mod m_1e9) * (y mod m_1e9)) mod m_1e9\nlet split_string ?(pattern=\" \") = Str.split @@ Str.regexp pattern\n\nlet n = Scanf.sscanf (read_line ()) \"%d\" @@ fun n -> n\nlet a = read_line () |> split_string |> List.map int_of_string\n\nlet rec loop ans arr = function\n | [] -> Printf.printf \"%d\\n\" @@ ans\n | x :: xs -> \n let t = Array.fold_left (fun s i -> s + if i = x then 1 else 0) 0 arr in\n let i = if arr.(0) = x then 0 else if arr.(1) = x then 1 else 2 in\n arr.(i) <- arr.(i) + 1;\n loop (ans *^ t) arr xs\n\nlet () = loop 1 (Array.make 3 0) a", "problem_context": "Score: 500 points\n\nProblem Statement\n\nN people are standing in a queue, numbered 1, 2, 3, ..., N from front to back. Each person wears a hat, which is red, blue, or green.\n\nThe person numbered i says:\n\n\"In front of me, exactly A_i people are wearing hats with the same color as mine.\"\n\nAssuming that all these statements are correct, find the number of possible combinations of colors of the N people's hats.\n\nSince the count can be enormous, compute it modulo 1000000007.\n\nConstraints\n\n1 \\leq N \\leq 100000\n\n0 \\leq A_i \\leq N-1\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 A_3 ... A_N\n\nOutput\n\nPrint the number of possible combinations of colors of the N people's hats, modulo 1000000007.\n\nSample Input 1\n\n6\n0 1 2 3 4 5\n\nSample Output 1\n\n3\n\nWe have three possible combinations, as follows:\n\nRed, Red, Red, Red, Red, Red\n\nBlue, Blue, Blue, Blue, Blue, Blue\n\nGreen, Green, Green, Green, Green, Green\n\nSample Input 2\n\n3\n0 0 0\n\nSample Output 2\n\n6\n\nSample Input 3\n\n54\n0 0 1 0 1 2 1 2 3 2 3 3 4 4 5 4 6 5 7 8 5 6 6 7 7 8 8 9 9 10 10 11 9 12 10 13 14 11 11 12 12 13 13 14 14 15 15 15 16 16 16 17 17 17\n\nSample Output 3\n\n115295190", "sample_input": "6\n0 1 2 3 4 5\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02845", "source_text": "Score: 500 points\n\nProblem Statement\n\nN people are standing in a queue, numbered 1, 2, 3, ..., N from front to back. Each person wears a hat, which is red, blue, or green.\n\nThe person numbered i says:\n\n\"In front of me, exactly A_i people are wearing hats with the same color as mine.\"\n\nAssuming that all these statements are correct, find the number of possible combinations of colors of the N people's hats.\n\nSince the count can be enormous, compute it modulo 1000000007.\n\nConstraints\n\n1 \\leq N \\leq 100000\n\n0 \\leq A_i \\leq N-1\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 A_3 ... A_N\n\nOutput\n\nPrint the number of possible combinations of colors of the N people's hats, modulo 1000000007.\n\nSample Input 1\n\n6\n0 1 2 3 4 5\n\nSample Output 1\n\n3\n\nWe have three possible combinations, as follows:\n\nRed, Red, Red, Red, Red, Red\n\nBlue, Blue, Blue, Blue, Blue, Blue\n\nGreen, Green, Green, Green, Green, Green\n\nSample Input 2\n\n3\n0 0 0\n\nSample Output 2\n\n6\n\nSample Input 3\n\n54\n0 0 1 0 1 2 1 2 3 2 3 3 4 4 5 4 6 5 7 8 5 6 6 7 7 8 8 9 9 10 10 11 9 12 10 13 14 11 11 12 12 13 13 14 14 15 15 15 16 16 16 17 17 17\n\nSample Output 3\n\n115295190", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 610, "cpu_time_ms": 37, "memory_kb": 13696}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s967280051", "group_id": "codeNet:p02846", "input_text": "let rec solve t1 t2 a1 a2 b1 b2 =\n let la, lb = a1*t1 + a2*t2, b1*t1 + b2*t2 in\n if la = lb then \"infinity\" \n else if la > lb then solve t1 t2 b1 b2 a1 a2 \n else if a1 < b1 then \"0\"\n else\n let d = lb - la in\n let x = (a1-b1) * t1 in\n string_of_int @@ x / d * 2 + (x mod d + d - 1) / d\nlet () = Scanf.scanf \"%d %d %d %d %d %d\" solve |> print_endline\n \n", "language": "OCaml", "metadata": {"date": 1575259465, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02846.html", "problem_id": "p02846", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02846/input.txt", "sample_output_relpath": "derived/input_output/data/p02846/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02846/OCaml/s967280051.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s967280051", "user_id": "u798181098"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "let rec solve t1 t2 a1 a2 b1 b2 =\n let la, lb = a1*t1 + a2*t2, b1*t1 + b2*t2 in\n if la = lb then \"infinity\" \n else if la > lb then solve t1 t2 b1 b2 a1 a2 \n else if a1 < b1 then \"0\"\n else\n let d = lb - la in\n let x = (a1-b1) * t1 in\n string_of_int @@ x / d * 2 + (x mod d + d - 1) / d\nlet () = Scanf.scanf \"%d %d %d %d %d %d\" solve |> print_endline\n \n", "problem_context": "Score: 600 points\n\nProblem Statement\n\nTakahashi and Aoki are training for long-distance races in an infinitely long straight course running from west to east.\n\nThey start simultaneously at the same point and moves as follows towards the east:\n\nTakahashi runs A_1 meters per minute for the first T_1 minutes, then runs at A_2 meters per minute for the subsequent T_2 minutes, and alternates between these two modes forever.\n\nAoki runs B_1 meters per minute for the first T_1 minutes, then runs at B_2 meters per minute for the subsequent T_2 minutes, and alternates between these two modes forever.\n\nHow many times will Takahashi and Aoki meet each other, that is, come to the same point? We do not count the start of the run. If they meet infinitely many times, report that fact.\n\nConstraints\n\n1 \\leq T_i \\leq 100000\n\n1 \\leq A_i \\leq 10^{10}\n\n1 \\leq B_i \\leq 10^{10}\n\nA_1 \\neq B_1\n\nA_2 \\neq B_2\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nT_1 T_2\nA_1 A_2\nB_1 B_2\n\nOutput\n\nPrint the number of times Takahashi and Aoki will meet each other.\n\nIf they meet infinitely many times, print infinity instead.\n\nSample Input 1\n\n1 2\n10 10\n12 4\n\nSample Output 1\n\n1\n\nThey will meet just once, \\frac{4}{3} minutes after they start, at \\frac{40}{3} meters from where they start.\n\nSample Input 2\n\n100 1\n101 101\n102 1\n\nSample Output 2\n\ninfinity\n\nThey will meet 101, 202, 303, 404, 505, 606, ... minutes after they start, that is, they will meet infinitely many times.\n\nSample Input 3\n\n12000 15700\n3390000000 3810000000\n5550000000 2130000000\n\nSample Output 3\n\n113\n\nThe values in input may not fit into a 32-bit integer type.", "sample_input": "1 2\n10 10\n12 4\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02846", "source_text": "Score: 600 points\n\nProblem Statement\n\nTakahashi and Aoki are training for long-distance races in an infinitely long straight course running from west to east.\n\nThey start simultaneously at the same point and moves as follows towards the east:\n\nTakahashi runs A_1 meters per minute for the first T_1 minutes, then runs at A_2 meters per minute for the subsequent T_2 minutes, and alternates between these two modes forever.\n\nAoki runs B_1 meters per minute for the first T_1 minutes, then runs at B_2 meters per minute for the subsequent T_2 minutes, and alternates between these two modes forever.\n\nHow many times will Takahashi and Aoki meet each other, that is, come to the same point? We do not count the start of the run. If they meet infinitely many times, report that fact.\n\nConstraints\n\n1 \\leq T_i \\leq 100000\n\n1 \\leq A_i \\leq 10^{10}\n\n1 \\leq B_i \\leq 10^{10}\n\nA_1 \\neq B_1\n\nA_2 \\neq B_2\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nT_1 T_2\nA_1 A_2\nB_1 B_2\n\nOutput\n\nPrint the number of times Takahashi and Aoki will meet each other.\n\nIf they meet infinitely many times, print infinity instead.\n\nSample Input 1\n\n1 2\n10 10\n12 4\n\nSample Output 1\n\n1\n\nThey will meet just once, \\frac{4}{3} minutes after they start, at \\frac{40}{3} meters from where they start.\n\nSample Input 2\n\n100 1\n101 101\n102 1\n\nSample Output 2\n\ninfinity\n\nThey will meet 101, 202, 303, 404, 505, 606, ... minutes after they start, that is, they will meet infinitely many times.\n\nSample Input 3\n\n12000 15700\n3390000000 3810000000\n5550000000 2130000000\n\nSample Output 3\n\n113\n\nThe values in input may not fit into a 32-bit integer type.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s000640177", "group_id": "codeNet:p02847", "input_text": "let sunday week = \n if week = \"MON\" then 6\n else if week = \"TUE\" then 5\n else if week = \"WED\" then 4\n else if week = \"THU\" then 3\n else if week = \"FRI\" then 2\n else if week = \"SAT\" then 1\n else 7\n\nlet ans = sunday (read_line ())\n\nlet () = print_endline @@ string_of_int ans", "language": "OCaml", "metadata": {"date": 1595543249, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p02847.html", "problem_id": "p02847", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02847/input.txt", "sample_output_relpath": "derived/input_output/data/p02847/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02847/OCaml/s000640177.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s000640177", "user_id": "u272377260"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "let sunday week = \n if week = \"MON\" then 6\n else if week = \"TUE\" then 5\n else if week = \"WED\" then 4\n else if week = \"THU\" then 3\n else if week = \"FRI\" then 2\n else if week = \"SAT\" then 1\n else 7\n\nlet ans = sunday (read_line ())\n\nlet () = print_endline @@ string_of_int ans", "problem_context": "Score : 100 points\n\nProblem Statement\n\nGiven is a string S representing the day of the week today.\n\nS is SUN, MON, TUE, WED, THU, FRI, or SAT, for Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, and Saturday, respectively.\n\nAfter how many days is the next Sunday (tomorrow or later)?\n\nConstraints\n\nS is SUN, MON, TUE, WED, THU, FRI, or SAT.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the number of days before the next Sunday.\n\nSample Input 1\n\nSAT\n\nSample Output 1\n\n1\n\nIt is Saturday today, and tomorrow will be Sunday.\n\nSample Input 2\n\nSUN\n\nSample Output 2\n\n7\n\nIt is Sunday today, and seven days later, it will be Sunday again.", "sample_input": "SAT\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02847", "source_text": "Score : 100 points\n\nProblem Statement\n\nGiven is a string S representing the day of the week today.\n\nS is SUN, MON, TUE, WED, THU, FRI, or SAT, for Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, and Saturday, respectively.\n\nAfter how many days is the next Sunday (tomorrow or later)?\n\nConstraints\n\nS is SUN, MON, TUE, WED, THU, FRI, or SAT.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the number of days before the next Sunday.\n\nSample Input 1\n\nSAT\n\nSample Output 1\n\n1\n\nIt is Saturday today, and tomorrow will be Sunday.\n\nSample Input 2\n\nSUN\n\nSample Output 2\n\n7\n\nIt is Sunday today, and seven days later, it will be Sunday again.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 294, "cpu_time_ms": 6, "memory_kb": 3648}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s591797020", "group_id": "codeNet:p02847", "input_text": "(* 基本 *)\n(* ocamlc str.cma main.ml でコンパイルできる *)\nlet () =\n let l = [(\"SUN\",7);(\"MON\",6);(\"TUE\",5);(\"WED\",4);(\"THU\",3);(\"FRI\",2);(\"SAT\",1)] in\n let s = Scanf.sscanf (input_line stdin) \"%s\" (fun a -> a) in\n let ans = List.assoc s l in\n print_int ans;\n print_newline ()\n", "language": "OCaml", "metadata": {"date": 1574647454, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02847.html", "problem_id": "p02847", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02847/input.txt", "sample_output_relpath": "derived/input_output/data/p02847/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02847/OCaml/s591797020.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s591797020", "user_id": "u977566741"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "(* 基本 *)\n(* ocamlc str.cma main.ml でコンパイルできる *)\nlet () =\n let l = [(\"SUN\",7);(\"MON\",6);(\"TUE\",5);(\"WED\",4);(\"THU\",3);(\"FRI\",2);(\"SAT\",1)] in\n let s = Scanf.sscanf (input_line stdin) \"%s\" (fun a -> a) in\n let ans = List.assoc s l in\n print_int ans;\n print_newline ()\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nGiven is a string S representing the day of the week today.\n\nS is SUN, MON, TUE, WED, THU, FRI, or SAT, for Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, and Saturday, respectively.\n\nAfter how many days is the next Sunday (tomorrow or later)?\n\nConstraints\n\nS is SUN, MON, TUE, WED, THU, FRI, or SAT.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the number of days before the next Sunday.\n\nSample Input 1\n\nSAT\n\nSample Output 1\n\n1\n\nIt is Saturday today, and tomorrow will be Sunday.\n\nSample Input 2\n\nSUN\n\nSample Output 2\n\n7\n\nIt is Sunday today, and seven days later, it will be Sunday again.", "sample_input": "SAT\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02847", "source_text": "Score : 100 points\n\nProblem Statement\n\nGiven is a string S representing the day of the week today.\n\nS is SUN, MON, TUE, WED, THU, FRI, or SAT, for Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, and Saturday, respectively.\n\nAfter how many days is the next Sunday (tomorrow or later)?\n\nConstraints\n\nS is SUN, MON, TUE, WED, THU, FRI, or SAT.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the number of days before the next Sunday.\n\nSample Input 1\n\nSAT\n\nSample Output 1\n\n1\n\nIt is Saturday today, and tomorrow will be Sunday.\n\nSample Input 2\n\nSUN\n\nSample Output 2\n\n7\n\nIt is Sunday today, and seven days later, it will be Sunday again.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 293, "cpu_time_ms": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s118713106", "group_id": "codeNet:p02850", "input_text": "let () = Scanf.scanf \"%d\\n\" @@ fun n ->\n let es = Array.make n [] in\n for i = 0 to n - 2 do\n Scanf.scanf \"%d %d\\n\" @@ fun a b ->\n es.(a - 1) <- (b - 1, i) :: es.(a - 1);\n es.(b - 1) <- (a - 1, i) :: es.(b - 1)\n done;\n let colours = Array.make (n - 1) 0 in\n let visited = Array.make n false in\n let rec solve s v =\n visited.(v) <- true;\n ignore\n (List.fold_left (fun colour (u, i) ->\n let rec skip colour =\n if List.mem colour s then skip (colour + 1) else colour in\n let colour = skip colour in\n if visited.(u)\n then colour\n else begin\n colours.(i) <- colour;\n solve [colour] u;\n colour + 1\n end) 1 es.(v)) in\n solve [] 0;\n Printf.printf \"%d\\n\" (Array.fold_left max min_int colours);\n Array.iter (Printf.printf \"%d\\n\") colours\n\n", "language": "OCaml", "metadata": {"date": 1574653962, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02850.html", "problem_id": "p02850", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02850/input.txt", "sample_output_relpath": "derived/input_output/data/p02850/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02850/OCaml/s118713106.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s118713106", "user_id": "u504158101"}, "prompt_components": {"gold_output": "2\n1\n2\n", "input_to_evaluate": "let () = Scanf.scanf \"%d\\n\" @@ fun n ->\n let es = Array.make n [] in\n for i = 0 to n - 2 do\n Scanf.scanf \"%d %d\\n\" @@ fun a b ->\n es.(a - 1) <- (b - 1, i) :: es.(a - 1);\n es.(b - 1) <- (a - 1, i) :: es.(b - 1)\n done;\n let colours = Array.make (n - 1) 0 in\n let visited = Array.make n false in\n let rec solve s v =\n visited.(v) <- true;\n ignore\n (List.fold_left (fun colour (u, i) ->\n let rec skip colour =\n if List.mem colour s then skip (colour + 1) else colour in\n let colour = skip colour in\n if visited.(u)\n then colour\n else begin\n colours.(i) <- colour;\n solve [colour] u;\n colour + 1\n end) 1 es.(v)) in\n solve [] 0;\n Printf.printf \"%d\\n\" (Array.fold_left max min_int colours);\n Array.iter (Printf.printf \"%d\\n\") colours\n\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nGiven is a tree G with N vertices.\nThe vertices are numbered 1 through N, and the i-th edge connects Vertex a_i and Vertex b_i.\n\nConsider painting the edges in G with some number of colors.\nWe want to paint them so that, for each vertex, the colors of the edges incident to that vertex are all different.\n\nAmong the colorings satisfying the condition above, construct one that uses the minimum number of colors.\n\nConstraints\n\n2 \\le N \\le 10^5\n\n1 \\le a_i \\lt b_i \\le N\n\nAll values in input are integers.\n\nThe given graph is a tree.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 b_1\na_2 b_2\n\\vdots\na_{N-1} b_{N-1}\n\nOutput\n\nPrint N lines.\n\nThe first line should contain K, the number of colors used.\n\nThe (i+1)-th line (1 \\le i \\le N-1) should contain c_i, the integer representing the color of the i-th edge, where 1 \\le c_i \\le K must hold.\n\nIf there are multiple colorings with the minimum number of colors that satisfy the condition, printing any of them will be accepted.\n\nSample Input 1\n\n3\n1 2\n2 3\n\nSample Output 1\n\n2\n1\n2\n\nSample Input 2\n\n8\n1 2\n2 3\n2 4\n2 5\n4 7\n5 6\n6 8\n\nSample Output 2\n\n4\n1\n2\n3\n4\n1\n1\n2\n\nSample Input 3\n\n6\n1 2\n1 3\n1 4\n1 5\n1 6\n\nSample Output 3\n\n5\n1\n2\n3\n4\n5", "sample_input": "3\n1 2\n2 3\n"}, "reference_outputs": ["2\n1\n2\n"], "source_document_id": "p02850", "source_text": "Score : 400 points\n\nProblem Statement\n\nGiven is a tree G with N vertices.\nThe vertices are numbered 1 through N, and the i-th edge connects Vertex a_i and Vertex b_i.\n\nConsider painting the edges in G with some number of colors.\nWe want to paint them so that, for each vertex, the colors of the edges incident to that vertex are all different.\n\nAmong the colorings satisfying the condition above, construct one that uses the minimum number of colors.\n\nConstraints\n\n2 \\le N \\le 10^5\n\n1 \\le a_i \\lt b_i \\le N\n\nAll values in input are integers.\n\nThe given graph is a tree.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 b_1\na_2 b_2\n\\vdots\na_{N-1} b_{N-1}\n\nOutput\n\nPrint N lines.\n\nThe first line should contain K, the number of colors used.\n\nThe (i+1)-th line (1 \\le i \\le N-1) should contain c_i, the integer representing the color of the i-th edge, where 1 \\le c_i \\le K must hold.\n\nIf there are multiple colorings with the minimum number of colors that satisfy the condition, printing any of them will be accepted.\n\nSample Input 1\n\n3\n1 2\n2 3\n\nSample Output 1\n\n2\n1\n2\n\nSample Input 2\n\n8\n1 2\n2 3\n2 4\n2 5\n4 7\n5 6\n6 8\n\nSample Output 2\n\n4\n1\n2\n3\n4\n1\n1\n2\n\nSample Input 3\n\n6\n1 2\n1 3\n1 4\n1 5\n1 6\n\nSample Output 3\n\n5\n1\n2\n3\n4\n5", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 839, "cpu_time_ms": 115, "memory_kb": 19328}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s027292784", "group_id": "codeNet:p02851", "input_text": "module Mi = Map.Make(struct type t = int let compare = (-) end)\nlet rec fix f x = f (fix f) x\nlet () =\n Scanf.scanf \"%d %d\" @@ fun n k ->\n let a = Array.init n (fun _ -> Scanf.scanf \" %d\" pred) in\n (1, Mi.singleton 0 0, Mi.singleton 0 1, 0) |> fix (fun f (i, sa, cm, ans) ->\n if i > n then ans else\n let si = (Mi.find (i-1) sa + a.(i-1)) mod k in\n let cm =\n if i < k then cm else\n let idx = Mi.find (i-k) sa in\n Mi.add idx (Mi.find idx cm - 1) cm in\n let ans = ans + try Mi.find si cm with _ -> 0 in\n let sa = Mi.add i si sa in\n let cm = Mi.add si (1 + try Mi.find si cm with _ -> 0) cm in\n f (i+1, sa, cm, ans))\n |> Printf.printf \"%d\\n\"\n", "language": "OCaml", "metadata": {"date": 1574742094, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02851.html", "problem_id": "p02851", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02851/input.txt", "sample_output_relpath": "derived/input_output/data/p02851/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02851/OCaml/s027292784.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s027292784", "user_id": "u798181098"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "module Mi = Map.Make(struct type t = int let compare = (-) end)\nlet rec fix f x = f (fix f) x\nlet () =\n Scanf.scanf \"%d %d\" @@ fun n k ->\n let a = Array.init n (fun _ -> Scanf.scanf \" %d\" pred) in\n (1, Mi.singleton 0 0, Mi.singleton 0 1, 0) |> fix (fun f (i, sa, cm, ans) ->\n if i > n then ans else\n let si = (Mi.find (i-1) sa + a.(i-1)) mod k in\n let cm =\n if i < k then cm else\n let idx = Mi.find (i-k) sa in\n Mi.add idx (Mi.find idx cm - 1) cm in\n let ans = ans + try Mi.find si cm with _ -> 0 in\n let sa = Mi.add i si sa in\n let cm = Mi.add si (1 + try Mi.find si cm with _ -> 0) cm in\n f (i+1, sa, cm, ans))\n |> Printf.printf \"%d\\n\"\n", "problem_context": "Score : 500 points\n\nProblem Statement\n\nGiven are a sequence of N positive integers A_1, A_2, \\ldots, A_N, and a positive integer K.\n\nFind the number of non-empty contiguous subsequences in A such that the remainder when dividing the sum of its elements by K is equal to the number of its elements. We consider two subsequences different if they are taken from different positions, even if they are equal sequences.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 2\\times 10^5\n\n1 \\leq K \\leq 10^9\n\n1 \\leq A_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nA_1 A_2 \\cdots A_N\n\nOutput\n\nPrint the number of subsequences that satisfy the condition.\n\nSample Input 1\n\n5 4\n1 4 2 3 5\n\nSample Output 1\n\n4\n\nFour sequences satisfy the condition: (1), (4,2), (1,4,2), and (5).\n\nSample Input 2\n\n8 4\n4 2 4 2 4 2 4 2\n\nSample Output 2\n\n7\n\n(4,2) is counted four times, and (2,4) is counted three times.\n\nSample Input 3\n\n10 7\n14 15 92 65 35 89 79 32 38 46\n\nSample Output 3\n\n8", "sample_input": "5 4\n1 4 2 3 5\n"}, "reference_outputs": ["4\n"], "source_document_id": "p02851", "source_text": "Score : 500 points\n\nProblem Statement\n\nGiven are a sequence of N positive integers A_1, A_2, \\ldots, A_N, and a positive integer K.\n\nFind the number of non-empty contiguous subsequences in A such that the remainder when dividing the sum of its elements by K is equal to the number of its elements. We consider two subsequences different if they are taken from different positions, even if they are equal sequences.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 2\\times 10^5\n\n1 \\leq K \\leq 10^9\n\n1 \\leq A_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nA_1 A_2 \\cdots A_N\n\nOutput\n\nPrint the number of subsequences that satisfy the condition.\n\nSample Input 1\n\n5 4\n1 4 2 3 5\n\nSample Output 1\n\n4\n\nFour sequences satisfy the condition: (1), (4,2), (1,4,2), and (5).\n\nSample Input 2\n\n8 4\n4 2 4 2 4 2 4 2\n\nSample Output 2\n\n7\n\n(4,2) is counted four times, and (2,4) is counted three times.\n\nSample Input 3\n\n10 7\n14 15 92 65 35 89 79 32 38 46\n\nSample Output 3\n\n8", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 682, "cpu_time_ms": 443, "memory_kb": 34300}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s071056571", "group_id": "codeNet:p02854", "input_text": "(* 横一列のn個の整数の入力を、配列に格納する *)\nlet i_inp_array : 'a array -> int -> unit = fun a n ->\n let rec loop i =\n if i = n then ()\n else\n (a.(i) <- (Scanf.scanf \" %d\" (fun x -> x));\n loop (i + 1))\n in loop 0\n\nlet floop init_v init_i condition acc body =\n let rec loop i v =\n if condition i then loop (acc i) (body i v)\n else v\n in\n loop init_i init_v\n \n(* ocamlc str.cma main.ml でコンパイルできる *)\nlet () =\n let n = Scanf.sscanf (input_line stdin) \"%d\" (fun a -> a) in\n let a = Array.make n 0 in\n let () = i_inp_array a n in\n let b = Array.make n 0 in\n let c = Array.make n 0 in\n let sum = floop 0 0 (fun i -> i < n) (fun i -> i + 1) (fun i v -> v + a.(i)) in\n for i = 0 to (n - 1) do\n if i = 0 then (b.(i) <- a.(i); c.(i) <- a.(i) - 1)\n else\n (b.(i) <- b.(i - 1) + a.(i) ; c.(i) <- c.(i - 1) + a.(i) - 1)\n done;\n \n let l = floop [] 0 (fun i -> i < n) (fun i -> i + 1) (fun i v -> let tmp = (abs (b.(i) - (sum - b.(i)))) in\n if tmp <= c.(i) then tmp :: v else 1000000 :: v) in\n let ans = List.fold_right min l 100000000 in\n print_int ans;\n print_newline ()\n", "language": "OCaml", "metadata": {"date": 1574562227, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02854.html", "problem_id": "p02854", "resource_group": "low_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/OCaml/s071056571.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s071056571", "user_id": "u977566741"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "(* 横一列のn個の整数の入力を、配列に格納する *)\nlet i_inp_array : 'a array -> int -> unit = fun a n ->\n let rec loop i =\n if i = n then ()\n else\n (a.(i) <- (Scanf.scanf \" %d\" (fun x -> x));\n loop (i + 1))\n in loop 0\n\nlet floop init_v init_i condition acc body =\n let rec loop i v =\n if condition i then loop (acc i) (body i v)\n else v\n in\n loop init_i init_v\n \n(* ocamlc str.cma main.ml でコンパイルできる *)\nlet () =\n let n = Scanf.sscanf (input_line stdin) \"%d\" (fun a -> a) in\n let a = Array.make n 0 in\n let () = i_inp_array a n in\n let b = Array.make n 0 in\n let c = Array.make n 0 in\n let sum = floop 0 0 (fun i -> i < n) (fun i -> i + 1) (fun i v -> v + a.(i)) in\n for i = 0 to (n - 1) do\n if i = 0 then (b.(i) <- a.(i); c.(i) <- a.(i) - 1)\n else\n (b.(i) <- b.(i - 1) + a.(i) ; c.(i) <- c.(i - 1) + a.(i) - 1)\n done;\n \n let l = floop [] 0 (fun i -> i < n) (fun i -> i + 1) (fun i v -> let tmp = (abs (b.(i) - (sum - b.(i)))) in\n if tmp <= c.(i) then tmp :: v else 1000000 :: v) in\n let ans = List.fold_right min l 100000000 in\n print_int ans;\n print_newline ()\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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1217, "cpu_time_ms": 83, "memory_kb": 19852}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s009475910", "group_id": "codeNet:p02854", "input_text": "let () =\n let split s =\n let rec loop i cur flag acc =\n if i = String.length s then ( if flag then cur :: acc else acc) else (\n match flag, s.[i] with\n | true, ' ' -> loop (i + 1) \"\" false (cur :: acc)\n | false, ' ' -> loop (i + 1) \"\" false acc\n | true, v -> loop (i + 1) (Printf.sprintf \"%s%c\" cur v) true acc\n | false, v -> loop (i + 1) (Printf.sprintf \"%s%c\" cur v) true acc\n )\n in\n List.map int_of_string (List.rev (loop 0 \"\" false []))\n in\n let rec proc left right acc = function\n | [_] -> acc\n | [] -> acc\n | hd :: tl -> \n let left = left + hd in\n let right = right - hd in\n let acc = min acc (max left right - min left right) in\n proc left right acc tl\n in\n\n let main () =\n let _ = int_of_string (read_line ()) in\n let a = split (read_line ()) in\n let s = List.fold_left (+) 0 a in\n let r = match a with\n | hd :: tl -> proc hd (s - hd) (max hd (s - hd) - min hd (s - hd)) tl\n | _ -> 0\n in\n Printf.printf \"%d\\n\" r\n in\n main ()", "language": "OCaml", "metadata": {"date": 1574561532, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02854.html", "problem_id": "p02854", "resource_group": "low_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/OCaml/s009475910.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s009475910", "user_id": "u342443598"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "let () =\n let split s =\n let rec loop i cur flag acc =\n if i = String.length s then ( if flag then cur :: acc else acc) else (\n match flag, s.[i] with\n | true, ' ' -> loop (i + 1) \"\" false (cur :: acc)\n | false, ' ' -> loop (i + 1) \"\" false acc\n | true, v -> loop (i + 1) (Printf.sprintf \"%s%c\" cur v) true acc\n | false, v -> loop (i + 1) (Printf.sprintf \"%s%c\" cur v) true acc\n )\n in\n List.map int_of_string (List.rev (loop 0 \"\" false []))\n in\n let rec proc left right acc = function\n | [_] -> acc\n | [] -> acc\n | hd :: tl -> \n let left = left + hd in\n let right = right - hd in\n let acc = min acc (max left right - min left right) in\n proc left right acc tl\n in\n\n let main () =\n let _ = int_of_string (read_line ()) in\n let a = split (read_line ()) in\n let s = List.fold_left (+) 0 a in\n let r = match a with\n | hd :: tl -> proc hd (s - hd) (max hd (s - hd) - min hd (s - hd)) tl\n | _ -> 0\n in\n Printf.printf \"%d\\n\" r\n in\n main ()", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1215, "cpu_time_ms": 280, "memory_kb": 31104}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s419356961", "group_id": "codeNet:p02856", "input_text": "let () =\n let calc1 d c =\n let restv = Array.make 10 (-1) in\n let accv = Array.make 10 (-1) in\n let rec loop v rest acc =\n if rest = 0 then v, acc else\n if restv.(v) >= 0 then (\n let cycle = restv.(v) - rest in\n let acyc = acc - accv.(v) in\n restv.(v) <- -1;\n accv.(v) <- -1;\n let count = rest / cycle in\n let rest = rest - count * cycle in\n let acc = acc + count * acyc in\n loop v rest acc \n ) else (\n restv.(v) <- rest;\n accv.(v) <- acc;\n let v = v + d in\n if v >= 10 then loop ((v / 10) + (v mod 10)) (rest - 1) (acc + 2) else\n loop v (rest - 1) (acc + 1)\n )\n in\n if c = 1 then d, 0 else\n let v = d * 2 in\n if v >= 10 then loop ((v / 10) + (v mod 10)) (c - 2) 2 else loop v (c - 2) 1 \n in\n let calc2 dc =\n let rec loop cur acc = function\n | [] -> acc\n | (v, s) :: tl ->\n let v = v + cur in\n if v >= 10 then loop ((v / 10) + (v mod 10)) (acc + s + 2) tl else loop v (acc + s + 1) tl\n in\n loop 0 (-1)dc\n in\n let main () =\n let m = int_of_string (read_line ()) in\n let dc = Array.init m (fun _ -> Scanf.sscanf (read_line ()) \"%d %d\" calc1) in\n let r = calc2 (Array.to_list dc) in\n Printf.printf \"%d\\n\" r\n in\n main ()", "language": "OCaml", "metadata": {"date": 1574566699, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02856.html", "problem_id": "p02856", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02856/input.txt", "sample_output_relpath": "derived/input_output/data/p02856/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02856/OCaml/s419356961.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s419356961", "user_id": "u342443598"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "let () =\n let calc1 d c =\n let restv = Array.make 10 (-1) in\n let accv = Array.make 10 (-1) in\n let rec loop v rest acc =\n if rest = 0 then v, acc else\n if restv.(v) >= 0 then (\n let cycle = restv.(v) - rest in\n let acyc = acc - accv.(v) in\n restv.(v) <- -1;\n accv.(v) <- -1;\n let count = rest / cycle in\n let rest = rest - count * cycle in\n let acc = acc + count * acyc in\n loop v rest acc \n ) else (\n restv.(v) <- rest;\n accv.(v) <- acc;\n let v = v + d in\n if v >= 10 then loop ((v / 10) + (v mod 10)) (rest - 1) (acc + 2) else\n loop v (rest - 1) (acc + 1)\n )\n in\n if c = 1 then d, 0 else\n let v = d * 2 in\n if v >= 10 then loop ((v / 10) + (v mod 10)) (c - 2) 2 else loop v (c - 2) 1 \n in\n let calc2 dc =\n let rec loop cur acc = function\n | [] -> acc\n | (v, s) :: tl ->\n let v = v + cur in\n if v >= 10 then loop ((v / 10) + (v mod 10)) (acc + s + 2) tl else loop v (acc + s + 1) tl\n in\n loop 0 (-1)dc\n in\n let main () =\n let m = int_of_string (read_line ()) in\n let dc = Array.init m (fun _ -> Scanf.sscanf (read_line ()) \"%d %d\" calc1) in\n let r = calc2 (Array.to_list dc) in\n Printf.printf \"%d\\n\" r\n in\n main ()", "problem_context": "Score: 500 points\n\nProblem Statement\n\nN programmers are going to participate in the preliminary stage of DDCC 20XX. Due to the size of the venue, however, at most 9 contestants can participate in the finals.\n\nThe preliminary stage consists of several rounds, which will take place as follows:\n\nAll the N contestants will participate in the first round.\n\nWhen X contestants participate in some round, the number of contestants advancing to the next round will be decided as follows:\n\nThe organizer will choose two consecutive digits in the decimal notation of X, and replace them with the sum of these digits. The number resulted will be the number of contestants advancing to the next round.\n\nFor example, when X = 2378, the number of contestants advancing to the next round will be 578 (if 2 and 3 are chosen), 2108 (if 3 and 7 are chosen), or 2315 (if 7 and 8 are chosen).\n\nWhen X = 100, the number of contestants advancing to the next round will be 10, no matter which two digits are chosen.\n\nThe preliminary stage ends when 9 or fewer contestants remain.\n\nRingo, the chief organizer, wants to hold as many rounds as possible.\nFind the maximum possible number of rounds in the preliminary stage.\n\nSince the number of contestants, N, can be enormous, it is given to you as two integer sequences d_1, \\ldots, d_M and c_1, \\ldots, c_M, which means the following: the decimal notation of N consists of c_1 + c_2 + \\ldots + c_M digits, whose first c_1 digits are all d_1, the following c_2 digits are all d_2, \\ldots, and the last c_M digits are all d_M.\n\nConstraints\n\n1 \\leq M \\leq 200000\n\n0 \\leq d_i \\leq 9\n\nd_1 \\neq 0\n\nd_i \\neq d_{i+1}\n\nc_i \\geq 1\n\n2 \\leq c_1 + \\ldots + c_M \\leq 10^{15}\n\nInput\n\nInput is given from Standard Input in the following format:\n\nM\nd_1 c_1\nd_2 c_2\n:\nd_M c_M\n\nOutput\n\nPrint the maximum possible number of rounds in the preliminary stage.\n\nSample Input 1\n\n2\n2 2\n9 1\n\nSample Output 1\n\n3\n\nIn this case, N = 229 contestants will participate in the first round. One possible progression of the preliminary stage is as follows:\n\n229 contestants participate in Round 1, 49 contestants participate in Round 2, 13 contestants participate in Round 3, and 4 contestants advance to the finals.\n\nHere, three rounds take place in the preliminary stage, which is the maximum possible number.\n\nSample Input 2\n\n3\n1 1\n0 8\n7 1\n\nSample Output 2\n\n9\n\nIn this case, 1000000007 will participate in the first round.", "sample_input": "2\n2 2\n9 1\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02856", "source_text": "Score: 500 points\n\nProblem Statement\n\nN programmers are going to participate in the preliminary stage of DDCC 20XX. Due to the size of the venue, however, at most 9 contestants can participate in the finals.\n\nThe preliminary stage consists of several rounds, which will take place as follows:\n\nAll the N contestants will participate in the first round.\n\nWhen X contestants participate in some round, the number of contestants advancing to the next round will be decided as follows:\n\nThe organizer will choose two consecutive digits in the decimal notation of X, and replace them with the sum of these digits. The number resulted will be the number of contestants advancing to the next round.\n\nFor example, when X = 2378, the number of contestants advancing to the next round will be 578 (if 2 and 3 are chosen), 2108 (if 3 and 7 are chosen), or 2315 (if 7 and 8 are chosen).\n\nWhen X = 100, the number of contestants advancing to the next round will be 10, no matter which two digits are chosen.\n\nThe preliminary stage ends when 9 or fewer contestants remain.\n\nRingo, the chief organizer, wants to hold as many rounds as possible.\nFind the maximum possible number of rounds in the preliminary stage.\n\nSince the number of contestants, N, can be enormous, it is given to you as two integer sequences d_1, \\ldots, d_M and c_1, \\ldots, c_M, which means the following: the decimal notation of N consists of c_1 + c_2 + \\ldots + c_M digits, whose first c_1 digits are all d_1, the following c_2 digits are all d_2, \\ldots, and the last c_M digits are all d_M.\n\nConstraints\n\n1 \\leq M \\leq 200000\n\n0 \\leq d_i \\leq 9\n\nd_1 \\neq 0\n\nd_i \\neq d_{i+1}\n\nc_i \\geq 1\n\n2 \\leq c_1 + \\ldots + c_M \\leq 10^{15}\n\nInput\n\nInput is given from Standard Input in the following format:\n\nM\nd_1 c_1\nd_2 c_2\n:\nd_M c_M\n\nOutput\n\nPrint the maximum possible number of rounds in the preliminary stage.\n\nSample Input 1\n\n2\n2 2\n9 1\n\nSample Output 1\n\n3\n\nIn this case, N = 229 contestants will participate in the first round. One possible progression of the preliminary stage is as follows:\n\n229 contestants participate in Round 1, 49 contestants participate in Round 2, 13 contestants participate in Round 3, and 4 contestants advance to the finals.\n\nHere, three rounds take place in the preliminary stage, which is the maximum possible number.\n\nSample Input 2\n\n3\n1 1\n0 8\n7 1\n\nSample Output 2\n\n9\n\nIn this case, 1000000007 will participate in the first round.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1626, "cpu_time_ms": 184, "memory_kb": 14336}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s507736660", "group_id": "codeNet:p02856", "input_text": "let () =\n let calc1 d c =\n let rec loop v rest acc =\n if rest = 0 then v, acc else\n let v = v + d in\n if v >= 10 then loop ((v / 10) + (v mod 10)) (rest - 1) (acc + 2) else\n loop v (rest - 1) (acc + 1)\n in\n if c = 1 then d, 0 else\n let v = d * 2 in\n if v >= 10 then loop ((v / 10) + (v mod 10)) (c - 2) 2 else loop v (c - 2) 1 \n in\n let calc2 dc =\n let rec loop cur acc = function\n | [] -> acc\n | (v, s) :: tl ->\n let v = v + cur in\n if v >= 10 then loop ((v / 10) + (v mod 10)) (acc + s + 2) tl else loop v (acc + s + 1) tl\n in\n loop 0 (-1)dc\n in\n let main () =\n let m = int_of_string (read_line ()) in\n let dc = Array.init m (fun _ -> Scanf.sscanf (read_line ()) \"%d %d\" calc1) in\n let r = calc2 (Array.to_list dc) in\n Printf.printf \"%d\\n\" r\n in\n main ()", "language": "OCaml", "metadata": {"date": 1574566096, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02856.html", "problem_id": "p02856", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02856/input.txt", "sample_output_relpath": "derived/input_output/data/p02856/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02856/OCaml/s507736660.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s507736660", "user_id": "u342443598"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "let () =\n let calc1 d c =\n let rec loop v rest acc =\n if rest = 0 then v, acc else\n let v = v + d in\n if v >= 10 then loop ((v / 10) + (v mod 10)) (rest - 1) (acc + 2) else\n loop v (rest - 1) (acc + 1)\n in\n if c = 1 then d, 0 else\n let v = d * 2 in\n if v >= 10 then loop ((v / 10) + (v mod 10)) (c - 2) 2 else loop v (c - 2) 1 \n in\n let calc2 dc =\n let rec loop cur acc = function\n | [] -> acc\n | (v, s) :: tl ->\n let v = v + cur in\n if v >= 10 then loop ((v / 10) + (v mod 10)) (acc + s + 2) tl else loop v (acc + s + 1) tl\n in\n loop 0 (-1)dc\n in\n let main () =\n let m = int_of_string (read_line ()) in\n let dc = Array.init m (fun _ -> Scanf.sscanf (read_line ()) \"%d %d\" calc1) in\n let r = calc2 (Array.to_list dc) in\n Printf.printf \"%d\\n\" r\n in\n main ()", "problem_context": "Score: 500 points\n\nProblem Statement\n\nN programmers are going to participate in the preliminary stage of DDCC 20XX. Due to the size of the venue, however, at most 9 contestants can participate in the finals.\n\nThe preliminary stage consists of several rounds, which will take place as follows:\n\nAll the N contestants will participate in the first round.\n\nWhen X contestants participate in some round, the number of contestants advancing to the next round will be decided as follows:\n\nThe organizer will choose two consecutive digits in the decimal notation of X, and replace them with the sum of these digits. The number resulted will be the number of contestants advancing to the next round.\n\nFor example, when X = 2378, the number of contestants advancing to the next round will be 578 (if 2 and 3 are chosen), 2108 (if 3 and 7 are chosen), or 2315 (if 7 and 8 are chosen).\n\nWhen X = 100, the number of contestants advancing to the next round will be 10, no matter which two digits are chosen.\n\nThe preliminary stage ends when 9 or fewer contestants remain.\n\nRingo, the chief organizer, wants to hold as many rounds as possible.\nFind the maximum possible number of rounds in the preliminary stage.\n\nSince the number of contestants, N, can be enormous, it is given to you as two integer sequences d_1, \\ldots, d_M and c_1, \\ldots, c_M, which means the following: the decimal notation of N consists of c_1 + c_2 + \\ldots + c_M digits, whose first c_1 digits are all d_1, the following c_2 digits are all d_2, \\ldots, and the last c_M digits are all d_M.\n\nConstraints\n\n1 \\leq M \\leq 200000\n\n0 \\leq d_i \\leq 9\n\nd_1 \\neq 0\n\nd_i \\neq d_{i+1}\n\nc_i \\geq 1\n\n2 \\leq c_1 + \\ldots + c_M \\leq 10^{15}\n\nInput\n\nInput is given from Standard Input in the following format:\n\nM\nd_1 c_1\nd_2 c_2\n:\nd_M c_M\n\nOutput\n\nPrint the maximum possible number of rounds in the preliminary stage.\n\nSample Input 1\n\n2\n2 2\n9 1\n\nSample Output 1\n\n3\n\nIn this case, N = 229 contestants will participate in the first round. One possible progression of the preliminary stage is as follows:\n\n229 contestants participate in Round 1, 49 contestants participate in Round 2, 13 contestants participate in Round 3, and 4 contestants advance to the finals.\n\nHere, three rounds take place in the preliminary stage, which is the maximum possible number.\n\nSample Input 2\n\n3\n1 1\n0 8\n7 1\n\nSample Output 2\n\n9\n\nIn this case, 1000000007 will participate in the first round.", "sample_input": "2\n2 2\n9 1\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02856", "source_text": "Score: 500 points\n\nProblem Statement\n\nN programmers are going to participate in the preliminary stage of DDCC 20XX. Due to the size of the venue, however, at most 9 contestants can participate in the finals.\n\nThe preliminary stage consists of several rounds, which will take place as follows:\n\nAll the N contestants will participate in the first round.\n\nWhen X contestants participate in some round, the number of contestants advancing to the next round will be decided as follows:\n\nThe organizer will choose two consecutive digits in the decimal notation of X, and replace them with the sum of these digits. The number resulted will be the number of contestants advancing to the next round.\n\nFor example, when X = 2378, the number of contestants advancing to the next round will be 578 (if 2 and 3 are chosen), 2108 (if 3 and 7 are chosen), or 2315 (if 7 and 8 are chosen).\n\nWhen X = 100, the number of contestants advancing to the next round will be 10, no matter which two digits are chosen.\n\nThe preliminary stage ends when 9 or fewer contestants remain.\n\nRingo, the chief organizer, wants to hold as many rounds as possible.\nFind the maximum possible number of rounds in the preliminary stage.\n\nSince the number of contestants, N, can be enormous, it is given to you as two integer sequences d_1, \\ldots, d_M and c_1, \\ldots, c_M, which means the following: the decimal notation of N consists of c_1 + c_2 + \\ldots + c_M digits, whose first c_1 digits are all d_1, the following c_2 digits are all d_2, \\ldots, and the last c_M digits are all d_M.\n\nConstraints\n\n1 \\leq M \\leq 200000\n\n0 \\leq d_i \\leq 9\n\nd_1 \\neq 0\n\nd_i \\neq d_{i+1}\n\nc_i \\geq 1\n\n2 \\leq c_1 + \\ldots + c_M \\leq 10^{15}\n\nInput\n\nInput is given from Standard Input in the following format:\n\nM\nd_1 c_1\nd_2 c_2\n:\nd_M c_M\n\nOutput\n\nPrint the maximum possible number of rounds in the preliminary stage.\n\nSample Input 1\n\n2\n2 2\n9 1\n\nSample Output 1\n\n3\n\nIn this case, N = 229 contestants will participate in the first round. One possible progression of the preliminary stage is as follows:\n\n229 contestants participate in Round 1, 49 contestants participate in Round 2, 13 contestants participate in Round 3, and 4 contestants advance to the finals.\n\nHere, three rounds take place in the preliminary stage, which is the maximum possible number.\n\nSample Input 2\n\n3\n1 1\n0 8\n7 1\n\nSample Output 2\n\n9\n\nIn this case, 1000000007 will participate in the first round.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 2103, "memory_kb": 3200}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s461004864", "group_id": "codeNet:p02859", "input_text": "Printf.printf \"%d\\n\" @@ match read_line () with \"SUN\" -> 7 | \"MON\" -> 6 | \"TUE\" -> 5 | \"WED\" -> 4 | \"THU\" -> 3 | \"FRI\" -> 2 | _ -> 1", "language": "OCaml", "metadata": {"date": 1574697429, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02859.html", "problem_id": "p02859", "resource_group": "low_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/OCaml/s461004864.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s461004864", "user_id": "u732304692"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "Printf.printf \"%d\\n\" @@ match read_line () with \"SUN\" -> 7 | \"MON\" -> 6 | \"TUE\" -> 5 | \"WED\" -> 4 | \"THU\" -> 3 | \"FRI\" -> 2 | _ -> 1", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s662379968", "group_id": "codeNet:p02860", "input_text": "let () =\n let rec charlist_of_string str n i =\n if i = n then [] else str.[i] :: charlist_of_string str n (i+1) in\n Scanf.scanf \"%d\\n%s\\n\" @@ fun n s ->\n let former = charlist_of_string (String.sub s 0 (n/2)) (n/2) 0 in\n let later = charlist_of_string (String.sub s (n/2) (n/2)) (n/2) 0 in\n let ans = List.fold_left2\n (fun ans x y -> if x=y then ans && true else false) true former later in\n Printf.printf \"%s\\n\" (if ans && n mod 2 = 0 then \"Yes\" else \"No\")", "language": "OCaml", "metadata": {"date": 1599420112, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p02860.html", "problem_id": "p02860", "resource_group": "low_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/OCaml/s662379968.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s662379968", "user_id": "u307426615"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "let () =\n let rec charlist_of_string str n i =\n if i = n then [] else str.[i] :: charlist_of_string str n (i+1) in\n Scanf.scanf \"%d\\n%s\\n\" @@ fun n s ->\n let former = charlist_of_string (String.sub s 0 (n/2)) (n/2) 0 in\n let later = charlist_of_string (String.sub s (n/2) (n/2)) (n/2) 0 in\n let ans = List.fold_left2\n (fun ans x y -> if x=y then ans && true else false) true former later in\n Printf.printf \"%s\\n\" (if ans && n mod 2 = 0 then \"Yes\" else \"No\")", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 471, "cpu_time_ms": 4, "memory_kb": 3708}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s672094554", "group_id": "codeNet:p02860", "input_text": "open Batteries\n(* 前からst文字を消す *)\nlet cut st str = String.init (String.length str - st) (fun a -> String.get str (a+st))\n(* 後ろからed文字を消す *)\nlet back_cut ed str = String.init (String.length str - ed) (String.get str)\nlet n = read_int ()\nlet s = read_line ()\nlet l = String.length s / 2\nlet _ = \n (if n mod 2 = 1 then \"No\" else\n if cut l s = back_cut l s then \"Yes\" else \"No\") |> print_endline", "language": "OCaml", "metadata": {"date": 1585712422, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02860.html", "problem_id": "p02860", "resource_group": "low_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/OCaml/s672094554.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s672094554", "user_id": "u511870776"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "open Batteries\n(* 前からst文字を消す *)\nlet cut st str = String.init (String.length str - st) (fun a -> String.get str (a+st))\n(* 後ろからed文字を消す *)\nlet back_cut ed str = String.init (String.length str - ed) (String.get str)\nlet n = read_int ()\nlet s = read_line ()\nlet l = String.length s / 2\nlet _ = \n (if n mod 2 = 1 then \"No\" else\n if cut l s = back_cut l s then \"Yes\" else \"No\") |> print_endline", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 2, "memory_kb": 3072}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s005412918", "group_id": "codeNet:p02860", "input_text": "let scan_int () = Scanf.scanf \" %d\" (fun x -> x)\nlet scan_string () = Scanf.scanf \" %s\" (fun x -> x)\n\nlet rec judge s i h =\n if i = h then true\n else if s.[i] = s.[i+h] then judge s (i+1) h\n else false\n\nlet () =\n let n = scan_int() in\n let s = scan_string() in\n if n mod 2 = 0 && judge s 0 (n/2) then Printf.printf \"Yes\\n\"\n else Printf.printf \"No\\n\"", "language": "OCaml", "metadata": {"date": 1574796404, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02860.html", "problem_id": "p02860", "resource_group": "low_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/OCaml/s005412918.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s005412918", "user_id": "u521364030"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "let scan_int () = Scanf.scanf \" %d\" (fun x -> x)\nlet scan_string () = Scanf.scanf \" %s\" (fun x -> x)\n\nlet rec judge s i h =\n if i = h then true\n else if s.[i] = s.[i+h] then judge s (i+1) h\n else false\n\nlet () =\n let n = scan_int() in\n let s = scan_string() in\n if n mod 2 = 0 && judge s 0 (n/2) then Printf.printf \"Yes\\n\"\n else Printf.printf \"No\\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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 356, "cpu_time_ms": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s615522096", "group_id": "codeNet:p02860", "input_text": "let explode s =\n let rec exp i l =\n if i < 0 then l else exp (i - 1) (s.[i] :: l) in\n exp (String.length s - 1) []\n \nlet rec take n l =\n match l with\n [] -> []\n | x :: xs ->\n if n = 0 then\n []\n else x :: take (n - 1) xs\n\nlet rec drop n l =\n match l with\n [] -> []\n | x :: xs ->\n if n = 0 then\n l\n else drop (n - 1) xs \n\nlet () =\n let n = Scanf.sscanf (input_line stdin) \"%d\" (fun a -> a) in\n let s = Scanf.sscanf (input_line stdin) \"%s\" (fun a -> a) in\n let judge cs =\n let mae = take (n/2) cs in\n let ushiro = drop (n/2) cs in\n List.for_all2 (fun a b -> a = b) mae ushiro in\n let ans = if n mod 2 = 1 then \"No\" else if judge (explode s) then \"Yes\" else \"no\"\n in\n print_string ans;\n print_newline ()\n", "language": "OCaml", "metadata": {"date": 1574368516, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02860.html", "problem_id": "p02860", "resource_group": "low_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/OCaml/s615522096.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s615522096", "user_id": "u977566741"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "let explode s =\n let rec exp i l =\n if i < 0 then l else exp (i - 1) (s.[i] :: l) in\n exp (String.length s - 1) []\n \nlet rec take n l =\n match l with\n [] -> []\n | x :: xs ->\n if n = 0 then\n []\n else x :: take (n - 1) xs\n\nlet rec drop n l =\n match l with\n [] -> []\n | x :: xs ->\n if n = 0 then\n l\n else drop (n - 1) xs \n\nlet () =\n let n = Scanf.sscanf (input_line stdin) \"%d\" (fun a -> a) in\n let s = Scanf.sscanf (input_line stdin) \"%s\" (fun a -> a) in\n let judge cs =\n let mae = take (n/2) cs in\n let ushiro = drop (n/2) cs in\n List.for_all2 (fun a b -> a = b) mae ushiro in\n let ans = if n mod 2 = 1 then \"No\" else if judge (explode s) then \"Yes\" else \"no\"\n in\n print_string ans;\n print_newline ()\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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 756, "cpu_time_ms": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s707296690", "group_id": "codeNet:p02860", "input_text": "let () = Scanf.scanf \"%d\\n%s\" @@ fun n s ->\n print_endline @@\n if\n Array.fold_left ( && ) (n mod 2 = 0) @@\n Array.init (n / 2) @@ fun i -> s.[i] = s.[i + n / 2]\n then \"Yes\"\n else \"No\"\n", "language": "OCaml", "metadata": {"date": 1573958340, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02860.html", "problem_id": "p02860", "resource_group": "low_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/OCaml/s707296690.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s707296690", "user_id": "u504158101"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "let () = Scanf.scanf \"%d\\n%s\" @@ fun n s ->\n print_endline @@\n if\n Array.fold_left ( && ) (n mod 2 = 0) @@\n Array.init (n / 2) @@ fun i -> s.[i] = s.[i + n / 2]\n then \"Yes\"\n else \"No\"\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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s881925510", "group_id": "codeNet:p02862", "input_text": "let () =\n let extgcd x y =\n let rec eg r0 r1 a0 a1 b0 b1 =\n if r1 = 0 then a0 else\n let q1 = r0 / r1 in\n eg r1 (r0 mod r1) a1 (a0 - q1 * a1) b1 (b0 - q1 * b1)\n in\n eg x y 1 0 0 1\n in\n let inv x y = (* 1/x in mod y *)\n let c = extgcd x y in\n if c < 0 then c + y else c\n in\n let z = 1_000_000_000 + 7 in\n (*\n let () =\n for i = 0 to z - 1 do\n let c = inv i z in\n if c < 0 then Printf.printf \"%d %d!!\\n%!\" i c\n done\n in\n *)\n let ( *@) a b = ((a mod z) * (b mod z)) mod z in\n let binomial a b =\n let rec loop i j acc =\n if j > b then acc else\n let acc = acc *@ i *@ inv j z in\n loop (i - 1) (j + 1) acc\n in\n loop a 1 1\n in\n let main () =\n let x, y = Scanf.sscanf (read_line ()) \"%d %d\" (fun x y -> x, y) in\n let ans = if (2*y - x) mod 3 <> 0 ||\n (2*x - y) mod 3 <> 0 then 0 else (\n let m = (2 * y - x) / 3 in\n let n = (2 * x - y) / 3 in\n if m < 0 || n < 0 then 0 else\n binomial (m + n) m\n )\n in\n Printf.printf \"%d\\n\" ans\n in\n main ()", "language": "OCaml", "metadata": {"date": 1573960591, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02862.html", "problem_id": "p02862", "resource_group": "low_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/OCaml/s881925510.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s881925510", "user_id": "u342443598"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "let () =\n let extgcd x y =\n let rec eg r0 r1 a0 a1 b0 b1 =\n if r1 = 0 then a0 else\n let q1 = r0 / r1 in\n eg r1 (r0 mod r1) a1 (a0 - q1 * a1) b1 (b0 - q1 * b1)\n in\n eg x y 1 0 0 1\n in\n let inv x y = (* 1/x in mod y *)\n let c = extgcd x y in\n if c < 0 then c + y else c\n in\n let z = 1_000_000_000 + 7 in\n (*\n let () =\n for i = 0 to z - 1 do\n let c = inv i z in\n if c < 0 then Printf.printf \"%d %d!!\\n%!\" i c\n done\n in\n *)\n let ( *@) a b = ((a mod z) * (b mod z)) mod z in\n let binomial a b =\n let rec loop i j acc =\n if j > b then acc else\n let acc = acc *@ i *@ inv j z in\n loop (i - 1) (j + 1) acc\n in\n loop a 1 1\n in\n let main () =\n let x, y = Scanf.sscanf (read_line ()) \"%d %d\" (fun x y -> x, y) in\n let ans = if (2*y - x) mod 3 <> 0 ||\n (2*x - y) mod 3 <> 0 then 0 else (\n let m = (2 * y - x) / 3 in\n let n = (2 * x - y) / 3 in\n if m < 0 || n < 0 then 0 else\n binomial (m + n) m\n )\n in\n Printf.printf \"%d\\n\" ans\n in\n main ()", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1249, "cpu_time_ms": 135, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s732867565", "group_id": "codeNet:p02865", "input_text": "let () =\n Scanf.scanf \"%d\\n\" @@ fun n ->\n Printf.printf \"%d\\n\" (if n mod 2 = 0 then n / 2 - 1 else n / 2)", "language": "OCaml", "metadata": {"date": 1599420258, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p02865.html", "problem_id": "p02865", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02865/input.txt", "sample_output_relpath": "derived/input_output/data/p02865/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02865/OCaml/s732867565.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s732867565", "user_id": "u307426615"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "let () =\n Scanf.scanf \"%d\\n\" @@ fun n ->\n Printf.printf \"%d\\n\" (if n mod 2 = 0 then n / 2 - 1 else n / 2)", "problem_context": "Score : 100 points\n\nProblem Statement\n\nHow many ways are there to choose two distinct positive integers totaling N, disregarding the order?\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.\n\nSample Input 1\n\n4\n\nSample Output 1\n\n1\n\nThere is only one way to choose two distinct integers totaling 4: to choose 1 and 3. (Choosing 3 and 1 is not considered different from this.)\n\nSample Input 2\n\n999999\n\nSample Output 2\n\n499999", "sample_input": "4\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02865", "source_text": "Score : 100 points\n\nProblem Statement\n\nHow many ways are there to choose two distinct positive integers totaling N, disregarding the order?\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.\n\nSample Input 1\n\n4\n\nSample Output 1\n\n1\n\nThere is only one way to choose two distinct integers totaling 4: to choose 1 and 3. (Choosing 3 and 1 is not considered different from this.)\n\nSample Input 2\n\n999999\n\nSample Output 2\n\n499999", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 3772}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s450243224", "group_id": "codeNet:p02865", "input_text": "let () = Scanf.scanf \"%d\" @@ fun n ->\n Printf.printf \"%d\\n\" @@ (n - 1) / 2\n\n", "language": "OCaml", "metadata": {"date": 1573353817, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02865.html", "problem_id": "p02865", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02865/input.txt", "sample_output_relpath": "derived/input_output/data/p02865/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02865/OCaml/s450243224.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s450243224", "user_id": "u504158101"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "let () = Scanf.scanf \"%d\" @@ fun n ->\n Printf.printf \"%d\\n\" @@ (n - 1) / 2\n\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nHow many ways are there to choose two distinct positive integers totaling N, disregarding the order?\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.\n\nSample Input 1\n\n4\n\nSample Output 1\n\n1\n\nThere is only one way to choose two distinct integers totaling 4: to choose 1 and 3. (Choosing 3 and 1 is not considered different from this.)\n\nSample Input 2\n\n999999\n\nSample Output 2\n\n499999", "sample_input": "4\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02865", "source_text": "Score : 100 points\n\nProblem Statement\n\nHow many ways are there to choose two distinct positive integers totaling N, disregarding the order?\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.\n\nSample Input 1\n\n4\n\nSample Output 1\n\n1\n\nThere is only one way to choose two distinct integers totaling 4: to choose 1 and 3. (Choosing 3 and 1 is not considered different from this.)\n\nSample Input 2\n\n999999\n\nSample Output 2\n\n499999", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s944898991", "group_id": "codeNet:p02873", "input_text": "Scanf.scanf \"%s\" (fun s ->\n let n = String.length s in\n let b = Array.make (n + 1) (-1) in\n\n (* 0 1 2 3 4 5 n = 6\n * s: > > > < < <\n * b: 3 2 1 0 1 2 3\n * 0 1 2 3 4 5 6\n *)\n\n let fill start =\n let rec left i cur =\n if b.(i) < cur then (\n b.(i) <- cur;\n if i > 0 && s.[i - 1] = '>' then (\n left (i - 1) (cur + 1)\n )\n )\n in\n let rec right i cur =\n b.(i) <- cur;\n if i < n && s.[i] ='<' then (\n right (i + 1) (cur + 1)\n ) else i\n in\n left start 0;\n right start 0\n in\n\n let rec loop i =\n if i = n then (if b.(i) < 0 then fill i else 0) else\n if s.[i] = '>' then loop (i + 1) else\n loop (fill i)\n in\n let _ = loop 0 in\n Array.fold_left (+) 0 b |> Printf.printf \"%d\\n\"\n)\n\n(*\n . . . \n 0 1 2 3 4 5 6 7 8 9 A B C D E F\n < > > > < < > < < < < < > > > <\n0 3 2 1 0 1 2 0 1 2 3 4 5 2 1 0 0\n0 1 2 3 4 5 6 7 8 9 A B C D E F 0\n*)", "language": "OCaml", "metadata": {"date": 1597460176, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p02873.html", "problem_id": "p02873", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02873/input.txt", "sample_output_relpath": "derived/input_output/data/p02873/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02873/OCaml/s944898991.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s944898991", "user_id": "u342443598"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "Scanf.scanf \"%s\" (fun s ->\n let n = String.length s in\n let b = Array.make (n + 1) (-1) in\n\n (* 0 1 2 3 4 5 n = 6\n * s: > > > < < <\n * b: 3 2 1 0 1 2 3\n * 0 1 2 3 4 5 6\n *)\n\n let fill start =\n let rec left i cur =\n if b.(i) < cur then (\n b.(i) <- cur;\n if i > 0 && s.[i - 1] = '>' then (\n left (i - 1) (cur + 1)\n )\n )\n in\n let rec right i cur =\n b.(i) <- cur;\n if i < n && s.[i] ='<' then (\n right (i + 1) (cur + 1)\n ) else i\n in\n left start 0;\n right start 0\n in\n\n let rec loop i =\n if i = n then (if b.(i) < 0 then fill i else 0) else\n if s.[i] = '>' then loop (i + 1) else\n loop (fill i)\n in\n let _ = loop 0 in\n Array.fold_left (+) 0 b |> Printf.printf \"%d\\n\"\n)\n\n(*\n . . . \n 0 1 2 3 4 5 6 7 8 9 A B C D E F\n < > > > < < > < < < < < > > > <\n0 3 2 1 0 1 2 0 1 2 3 4 5 2 1 0 0\n0 1 2 3 4 5 6 7 8 9 A B C D E F 0\n*)", "problem_context": "Score : 300 points\n\nProblem Statement\n\nGiven is a string S of length N-1.\nEach character in S is < or >.\n\nA sequence of N non-negative integers, a_1,a_2,\\cdots,a_N, is said to be good when the following condition is satisfied for all i (1 \\leq i \\leq N-1):\n\nIf S_i= <: a_i: a_i>a_{i+1}\n\nFind the minimum possible sum of the elements of a good sequence of N non-negative integers.\n\nConstraints\n\n2 \\leq N \\leq 5 \\times 10^5\n\nS is a string of length N-1 consisting of < and >.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nFind the minimum possible sum of the elements of a good sequence of N non-negative integers.\n\nSample Input 1\n\n<>>\n\nSample Output 1\n\n3\n\na=(0,2,1,0) is a good sequence whose sum is 3.\nThere is no good sequence whose sum is less than 3.\n\nSample Input 2\n\n<>>><<><<<<<>>><\n\nSample Output 2\n\n28", "sample_input": "<>>\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02873", "source_text": "Score : 300 points\n\nProblem Statement\n\nGiven is a string S of length N-1.\nEach character in S is < or >.\n\nA sequence of N non-negative integers, a_1,a_2,\\cdots,a_N, is said to be good when the following condition is satisfied for all i (1 \\leq i \\leq N-1):\n\nIf S_i= <: a_i: a_i>a_{i+1}\n\nFind the minimum possible sum of the elements of a good sequence of N non-negative integers.\n\nConstraints\n\n2 \\leq N \\leq 5 \\times 10^5\n\nS is a string of length N-1 consisting of < and >.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nFind the minimum possible sum of the elements of a good sequence of N non-negative integers.\n\nSample Input 1\n\n<>>\n\nSample Output 1\n\n3\n\na=(0,2,1,0) is a good sequence whose sum is 3.\nThere is no good sequence whose sum is less than 3.\n\nSample Input 2\n\n<>>><<><<<<<>>><\n\nSample Output 2\n\n28", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1097, "cpu_time_ms": 29, "memory_kb": 11300}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s589553505", "group_id": "codeNet:p02874", "input_text": "Scanf.scanf \"%d\" (fun n ->\n let l = Array.make n 0 in\n let r = Array.make n 0 in\n for i = 0 to n - 1 do\n Scanf.scanf \" %d %d\" (fun a b -> l.(i) <- a; r.(i) <- b + 1)\n done;\n\n let rec loop i p q =\n if i = n then p, q else\n let p = if l.(i) > l.(p) then i else p in\n let q = if r.(i) < r.(q) then i else q in\n loop (i + 1) p q\n in\n let p, q = loop 0 0 0 in\n\n let result1 =\n let rec loop j acc =\n if j = n then acc + max (r.(q) - l.(p)) 0 else\n if j = p || j = q then loop (j + 1) acc else\n loop (j + 1) (max acc (r.(j) - l.(j)))\n in\n loop 0 0\n in\n \n Printf.printf \"%d\\n\" @@ (\n let work = Array.init n (fun i -> max (r.(i) - l.(p)) 0, max (r.(q) - l.(i)) 0) in\n Array.sort (fun (a0, b0) (a1, b1) -> compare (a0, -b0) (a1, -b1)) work;\n let s = Array.make (n + 1) (r.(q) - l.(q)) in\n let t = Array.make (n + 1) (r.(p) - l.(p)) in\n for i = 1 to n do t.(i) <- min t.(i - 1) (snd work.(i - 1)); done;\n for i = n - 1 downto 0 do s.(i) <- min s.(i + 1) (fst work.(i )); done;\n\n let rec loop i acc =\n if i = n + 1 then acc else loop (i + 1) (max acc (s.(i) + t.(i)))\n in\n loop 0 result1\n )\n)", "language": "OCaml", "metadata": {"date": 1599408919, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p02874.html", "problem_id": "p02874", "resource_group": "low_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/OCaml/s589553505.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s589553505", "user_id": "u342443598"}, "prompt_components": {"gold_output": "6\n", "input_to_evaluate": "Scanf.scanf \"%d\" (fun n ->\n let l = Array.make n 0 in\n let r = Array.make n 0 in\n for i = 0 to n - 1 do\n Scanf.scanf \" %d %d\" (fun a b -> l.(i) <- a; r.(i) <- b + 1)\n done;\n\n let rec loop i p q =\n if i = n then p, q else\n let p = if l.(i) > l.(p) then i else p in\n let q = if r.(i) < r.(q) then i else q in\n loop (i + 1) p q\n in\n let p, q = loop 0 0 0 in\n\n let result1 =\n let rec loop j acc =\n if j = n then acc + max (r.(q) - l.(p)) 0 else\n if j = p || j = q then loop (j + 1) acc else\n loop (j + 1) (max acc (r.(j) - l.(j)))\n in\n loop 0 0\n in\n \n Printf.printf \"%d\\n\" @@ (\n let work = Array.init n (fun i -> max (r.(i) - l.(p)) 0, max (r.(q) - l.(i)) 0) in\n Array.sort (fun (a0, b0) (a1, b1) -> compare (a0, -b0) (a1, -b1)) work;\n let s = Array.make (n + 1) (r.(q) - l.(q)) in\n let t = Array.make (n + 1) (r.(p) - l.(p)) in\n for i = 1 to n do t.(i) <- min t.(i - 1) (snd work.(i - 1)); done;\n for i = n - 1 downto 0 do s.(i) <- min s.(i + 1) (fst work.(i )); done;\n\n let rec loop i acc =\n if i = n + 1 then acc else loop (i + 1) (max acc (s.(i) + t.(i)))\n in\n loop 0 result1\n )\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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1303, "cpu_time_ms": 136, "memory_kb": 12892}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s394667535", "group_id": "codeNet:p02874", "input_text": "Scanf.scanf \"%d\" (fun n ->\n let lr = Array.init n (fun _ -> Scanf.scanf \" %d %d\" (fun l r -> l, r)) in\n let lp = Array.fold_left (fun acc (l, r) -> max acc l) 0 lr in\n let rq = Array.fold_left (fun acc (l, r) -> min acc r) max_int lr in\n let ab = Array.init n (fun i ->\n let l, r = lr.(i) in\n max (r + 1 - lp) 0, - max (rq + 1 - l) 0, i)\n in\n Array.sort compare ab;\n let s = Array.make (n - 1) 0 in\n let rec loop i l r =\n if i = n - 1 then () else\n let (_, _, j) = ab.(i) in\n let ll, rr = lr.(j) in\n let l = max ll l in\n let r = min rr r in\n let () = s.(i) <- max 0 (r - l + 1) in\n loop (i + 1) l r\n in\n loop 0 0 max_int;\n\n let rec loop i l r =\n if i = 0 then () else\n let (_, _, j) = ab.(i) in\n let ll, rr = lr.(j) in\n let l = max ll l in\n let r = min rr r in\n let () = s.(i - 1) <- s.(i - 1) + max 0 (r - l + 1) in\n loop (i - 1) l r\n in\n loop (n - 1) 0 max_int;\n\n Array.fold_left max 0 s |> Printf.printf \"%d\\n\"\n)", "language": "OCaml", "metadata": {"date": 1596509918, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p02874.html", "problem_id": "p02874", "resource_group": "low_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/OCaml/s394667535.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s394667535", "user_id": "u342443598"}, "prompt_components": {"gold_output": "6\n", "input_to_evaluate": "Scanf.scanf \"%d\" (fun n ->\n let lr = Array.init n (fun _ -> Scanf.scanf \" %d %d\" (fun l r -> l, r)) in\n let lp = Array.fold_left (fun acc (l, r) -> max acc l) 0 lr in\n let rq = Array.fold_left (fun acc (l, r) -> min acc r) max_int lr in\n let ab = Array.init n (fun i ->\n let l, r = lr.(i) in\n max (r + 1 - lp) 0, - max (rq + 1 - l) 0, i)\n in\n Array.sort compare ab;\n let s = Array.make (n - 1) 0 in\n let rec loop i l r =\n if i = n - 1 then () else\n let (_, _, j) = ab.(i) in\n let ll, rr = lr.(j) in\n let l = max ll l in\n let r = min rr r in\n let () = s.(i) <- max 0 (r - l + 1) in\n loop (i + 1) l r\n in\n loop 0 0 max_int;\n\n let rec loop i l r =\n if i = 0 then () else\n let (_, _, j) = ab.(i) in\n let ll, rr = lr.(j) in\n let l = max ll l in\n let r = min rr r in\n let () = s.(i - 1) <- s.(i - 1) + max 0 (r - l + 1) in\n loop (i - 1) l r\n in\n loop (n - 1) 0 max_int;\n\n Array.fold_left max 0 s |> Printf.printf \"%d\\n\"\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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1123, "cpu_time_ms": 157, "memory_kb": 14400}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s911225370", "group_id": "codeNet:p02880", "input_text": "let divisible n =\n let rec loop_i i =\n if i > 9 then false else\n if n mod i = 0 && n / i < 10 then true else loop_i (i + 1)\n in\n loop_i 1\n;;\nScanf.sscanf (read_line ()) \"%d\" (fun n -> Printf.printf \"%s\\n\" (if divisible n then \"Yes\" else \"No\"))", "language": "OCaml", "metadata": {"date": 1572224722, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02880.html", "problem_id": "p02880", "resource_group": "low_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/OCaml/s911225370.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s911225370", "user_id": "u342443598"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "let divisible n =\n let rec loop_i i =\n if i > 9 then false else\n if n mod i = 0 && n / i < 10 then true else loop_i (i + 1)\n in\n loop_i 1\n;;\nScanf.sscanf (read_line ()) \"%d\" (fun n -> Printf.printf \"%s\\n\" (if divisible n then \"Yes\" else \"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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s578132982", "group_id": "codeNet:p02881", "input_text": "open Scanf ;;\nopen Printf ;;\n\nlet divisors n =\n let rec f i =\n if i * i > n then []\n else if n mod i = 0 then i :: f (i + 1)\n else f (i + 1)\n in\n f 1\n ;;\n\nlet min_list a = List.fold_left min max_int a ;;\n\nlet () =\n let n = scanf \"%d\" (fun x -> x) in\n let ans = divisors n |> List.map (fun x -> x + n / x - 2) |> min_list in\n printf \"%d\\n\" ans\n ;;\n\n\n", "language": "OCaml", "metadata": {"date": 1572486503, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02881.html", "problem_id": "p02881", "resource_group": "low_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/OCaml/s578132982.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s578132982", "user_id": "u006493569"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "open Scanf ;;\nopen Printf ;;\n\nlet divisors n =\n let rec f i =\n if i * i > n then []\n else if n mod i = 0 then i :: f (i + 1)\n else f (i + 1)\n in\n f 1\n ;;\n\nlet min_list a = List.fold_left min max_int a ;;\n\nlet () =\n let n = scanf \"%d\" (fun x -> x) in\n let ans = divisors n |> List.map (fun x -> x + n / x - 2) |> min_list in\n printf \"%d\\n\" ans\n ;;\n\n\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nTakahashi is standing on a multiplication table with infinitely many rows and columns.\n\nThe square (i,j) contains the integer i \\times j. Initially, Takahashi is standing at (1,1).\n\nIn one move, he can move from (i,j) to either (i+1,j) or (i,j+1).\n\nGiven an integer N, find the minimum number of moves needed to reach a square that contains N.\n\nConstraints\n\n2 \\leq N \\leq 10^{12}\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the minimum number of moves needed to reach a square that contains the integer N.\n\nSample Input 1\n\n10\n\nSample Output 1\n\n5\n\n(2,5) can be reached in five moves. We cannot reach a square that contains 10 in less than five moves.\n\nSample Input 2\n\n50\n\nSample Output 2\n\n13\n\n(5, 10) can be reached in 13 moves.\n\nSample Input 3\n\n10000000019\n\nSample Output 3\n\n10000000018\n\nBoth input and output may be enormous.", "sample_input": "10\n"}, "reference_outputs": ["5\n"], "source_document_id": "p02881", "source_text": "Score : 300 points\n\nProblem Statement\n\nTakahashi is standing on a multiplication table with infinitely many rows and columns.\n\nThe square (i,j) contains the integer i \\times j. Initially, Takahashi is standing at (1,1).\n\nIn one move, he can move from (i,j) to either (i+1,j) or (i,j+1).\n\nGiven an integer N, find the minimum number of moves needed to reach a square that contains N.\n\nConstraints\n\n2 \\leq N \\leq 10^{12}\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the minimum number of moves needed to reach a square that contains the integer N.\n\nSample Input 1\n\n10\n\nSample Output 1\n\n5\n\n(2,5) can be reached in five moves. We cannot reach a square that contains 10 in less than five moves.\n\nSample Input 2\n\n50\n\nSample Output 2\n\n13\n\n(5, 10) can be reached in 13 moves.\n\nSample Input 3\n\n10000000019\n\nSample Output 3\n\n10000000018\n\nBoth input and output may be enormous.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 13, "memory_kb": 640}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s909301647", "group_id": "codeNet:p02881", "input_text": "let n, i, ans = read_int (), ref 1, ref max_int\nlet _ = while !i * !i <= n do if n mod !i = 0 then ans := min !ans @@ !i + n / !i - 2; incr i done; Printf.printf \"%d\\n\" @@ !ans", "language": "OCaml", "metadata": {"date": 1572282294, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02881.html", "problem_id": "p02881", "resource_group": "low_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/OCaml/s909301647.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s909301647", "user_id": "u732304692"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "let n, i, ans = read_int (), ref 1, ref max_int\nlet _ = while !i * !i <= n do if n mod !i = 0 then ans := min !ans @@ !i + n / !i - 2; incr i done; Printf.printf \"%d\\n\" @@ !ans", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 13, "memory_kb": 2432}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s421056520", "group_id": "codeNet:p02882", "input_text": "let pi = atan 1. *. 4.\nlet (a, b, x) = Scanf.sscanf (read_line ()) \"%f %f %f\" @@ fun a b x -> (a, b, x /. a)\n\nlet s = a *. b /. 2.\n\nlet r1 = atan (2. *. x /. (b *. b))\n\nlet r2 = atan ((2. *. (a *. b -. x) /. (a *. a)))\n\nlet angle_of_rad r = r *. 180. /. pi\n\nlet () = Printf.printf \"%f\\n\" @@ \n if s = x then angle_of_rad @@ atan (a /. b)\n else if s > x then 90. -. angle_of_rad r1\n else angle_of_rad r2", "language": "OCaml", "metadata": {"date": 1590260829, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02882.html", "problem_id": "p02882", "resource_group": "low_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/OCaml/s421056520.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s421056520", "user_id": "u811309788"}, "prompt_components": {"gold_output": "45.0000000000\n", "input_to_evaluate": "let pi = atan 1. *. 4.\nlet (a, b, x) = Scanf.sscanf (read_line ()) \"%f %f %f\" @@ fun a b x -> (a, b, x /. a)\n\nlet s = a *. b /. 2.\n\nlet r1 = atan (2. *. x /. (b *. b))\n\nlet r2 = atan ((2. *. (a *. b -. x) /. (a *. a)))\n\nlet angle_of_rad r = r *. 180. /. pi\n\nlet () = Printf.printf \"%f\\n\" @@ \n if s = x then angle_of_rad @@ atan (a /. b)\n else if s > x then 90. -. angle_of_rad r1\n else angle_of_rad r2", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s782831349", "group_id": "codeNet:p02882", "input_text": "let a, b, x = Scanf.scanf \" %f %f %f\" @@ fun a b c -> a, b, c\nlet f r = 180. *. r /. acos (-1.) |> Printf.printf \"%.10f\\n\"\nlet _ = f @@ if x <= b *. a *. a /. 2. then let d = 2. *. x /. (a *. b) in let k = sqrt (b *. b +. d *. d) in acos @@ 2. *. x /. (a *. k) /. b\n else let s = a *. b -. x /. a in let l = 2. *. s /. a in acos @@ a /. sqrt (a *. a +. l *. l)", "language": "OCaml", "metadata": {"date": 1572798026, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02882.html", "problem_id": "p02882", "resource_group": "low_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/OCaml/s782831349.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s782831349", "user_id": "u732304692"}, "prompt_components": {"gold_output": "45.0000000000\n", "input_to_evaluate": "let a, b, x = Scanf.scanf \" %f %f %f\" @@ fun a b c -> a, b, c\nlet f r = 180. *. r /. acos (-1.) |> Printf.printf \"%.10f\\n\"\nlet _ = f @@ if x <= b *. a *. a /. 2. then let d = 2. *. x /. (a *. b) in let k = sqrt (b *. b +. d *. d) in acos @@ 2. *. x /. (a *. k) /. b\n else let s = a *. b -. x /. a in let l = 2. *. s /. a in acos @@ a /. sqrt (a *. a +. l *. l)", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s143192022", "group_id": "codeNet:p02882", "input_text": "let () = Scanf.scanf \"%d %d %d\" @@ fun a b x ->\n Printf.printf \"%.12f\\n\" @@\n if x <= a * a * b / 2\n then 90. -. 45. *. atan2 (2. *. float_of_int x) (float_of_int (a * b * b)) /. atan 1.\n else 90. -. 45. *. atan2 (float_of_int (a * a * a)) (2. *. float_of_int (a * a * b - x)) /. atan 1.\n", "language": "OCaml", "metadata": {"date": 1572226414, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02882.html", "problem_id": "p02882", "resource_group": "low_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/OCaml/s143192022.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s143192022", "user_id": "u504158101"}, "prompt_components": {"gold_output": "45.0000000000\n", "input_to_evaluate": "let () = Scanf.scanf \"%d %d %d\" @@ fun a b x ->\n Printf.printf \"%.12f\\n\" @@\n if x <= a * a * b / 2\n then 90. -. 45. *. atan2 (2. *. float_of_int x) (float_of_int (a * b * b)) /. atan 1.\n else 90. -. 45. *. atan2 (float_of_int (a * a * a)) (2. *. float_of_int (a * a * b - x)) /. atan 1.\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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s009654586", "group_id": "codeNet:p02884", "input_text": "let scan_int () = Scanf.scanf \" %d\" (fun x -> x)\nlet print_float n = Printf.printf \"%.12f\\n\" n\n\n(* 辺の入力 *)\nlet input_edge edges m =\n for i = 0 to m-1 do\n let s = scan_int() and t = scan_int() in\n edges.(s-1) <- (t-1) :: edges.(s-1) \n done\n\n(* 頂点vからの期待値の計算 *)\nlet calc_expected_value n edges =\n let expected = Array.make n 0.0 in\n let prop expect p u v = expect.(u) <- expect.(u) +. (expect.(v) +. 1.0) *. p in\n let rec rev_calc curr edges ret =\n if curr < 0 then ret\n else\n let p = 1.0 /. (float (List.length edges.(curr))) in\n let _ = List.iter (prop ret p curr) edges.(curr) in\n rev_calc (curr-1) edges ret in\n rev_calc (n-1) edges expected\n\n(* 頂点vを通る確率の計算 *)\nlet calc_probability n edges =\n let probability = Array.make n 0.0 in\n let _ = probability.(0) <- 1.0 in\n let prop prob p u v = prob.(v) <- prob.(v) +. prob.(u) *. p in\n let rec calc curr edges ret =\n if curr = n then ret\n else\n let p = 1.0 /. (float (List.length edges.(curr))) in\n let _ = List.iter (prop ret p curr) edges.(curr) in\n calc (curr+1) edges ret in\n calc 0 edges probability\n\n\nlet solve n edges expected probability =\n let ans = ref expected.(0) in\n let p = expected.(0) in\n let _ =\n for u = 0 to n-1 do\n let l = List.length edges.(u) in\n if l <= 1 then ()\n else\n let add_prob = 1.0 /. (float (l-1)) -. 1.0 /. (float l) in\n let fold_func p v = p +. add_prob *. expected.(v) *. probability.(u) in\n let ref_value = List.fold_left fold_func p edges.(u) in\n let sub_prob = 1.0 /. (float (l-1)) in\n let calc_func v =\n let result = ref_value -. sub_prob *. expected.(v) *. probability.(u) in\n ans := min !ans result in\n List.iter calc_func edges.(u)\n done in\n print_float !ans\n\n\nlet () =\n let n = scan_int() and m = scan_int() in\n let edges = Array.make n [] in\n let _ = input_edge edges m in\n let expected = calc_expected_value n edges in\n let probability = calc_probability n edges in\n solve n edges expected probability", "language": "OCaml", "metadata": {"date": 1572332886, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02884.html", "problem_id": "p02884", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02884/input.txt", "sample_output_relpath": "derived/input_output/data/p02884/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02884/OCaml/s009654586.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s009654586", "user_id": "u521364030"}, "prompt_components": {"gold_output": "1.5000000000\n", "input_to_evaluate": "let scan_int () = Scanf.scanf \" %d\" (fun x -> x)\nlet print_float n = Printf.printf \"%.12f\\n\" n\n\n(* 辺の入力 *)\nlet input_edge edges m =\n for i = 0 to m-1 do\n let s = scan_int() and t = scan_int() in\n edges.(s-1) <- (t-1) :: edges.(s-1) \n done\n\n(* 頂点vからの期待値の計算 *)\nlet calc_expected_value n edges =\n let expected = Array.make n 0.0 in\n let prop expect p u v = expect.(u) <- expect.(u) +. (expect.(v) +. 1.0) *. p in\n let rec rev_calc curr edges ret =\n if curr < 0 then ret\n else\n let p = 1.0 /. (float (List.length edges.(curr))) in\n let _ = List.iter (prop ret p curr) edges.(curr) in\n rev_calc (curr-1) edges ret in\n rev_calc (n-1) edges expected\n\n(* 頂点vを通る確率の計算 *)\nlet calc_probability n edges =\n let probability = Array.make n 0.0 in\n let _ = probability.(0) <- 1.0 in\n let prop prob p u v = prob.(v) <- prob.(v) +. prob.(u) *. p in\n let rec calc curr edges ret =\n if curr = n then ret\n else\n let p = 1.0 /. (float (List.length edges.(curr))) in\n let _ = List.iter (prop ret p curr) edges.(curr) in\n calc (curr+1) edges ret in\n calc 0 edges probability\n\n\nlet solve n edges expected probability =\n let ans = ref expected.(0) in\n let p = expected.(0) in\n let _ =\n for u = 0 to n-1 do\n let l = List.length edges.(u) in\n if l <= 1 then ()\n else\n let add_prob = 1.0 /. (float (l-1)) -. 1.0 /. (float l) in\n let fold_func p v = p +. add_prob *. expected.(v) *. probability.(u) in\n let ref_value = List.fold_left fold_func p edges.(u) in\n let sub_prob = 1.0 /. (float (l-1)) in\n let calc_func v =\n let result = ref_value -. sub_prob *. expected.(v) *. probability.(u) in\n ans := min !ans result in\n List.iter calc_func edges.(u)\n done in\n print_float !ans\n\n\nlet () =\n let n = scan_int() and m = scan_int() in\n let edges = Array.make n [] in\n let _ = input_edge edges m in\n let expected = calc_expected_value n edges in\n let probability = calc_probability n edges in\n solve n edges expected probability", "problem_context": "Score : 600 points\n\nProblem Statement\n\nThere is a cave consisting of N rooms and M one-directional passages. The rooms are numbered 1 through N.\n\nTakahashi is now in Room 1, and Room N has the exit. The i-th passage connects Room s_i and Room t_i (s_i < t_i) and can only be traversed in the direction from Room s_i to Room t_i. It is known that, for each room except Room N, there is at least one passage going from that room.\n\nTakahashi will escape from the cave. Each time he reaches a room (assume that he has reached Room 1 at the beginning), he will choose a passage uniformly at random from the ones going from that room and take that passage.\n\nAoki, a friend of Takahashi's, can block one of the passages (or do nothing) before Takahashi leaves Room 1. However, it is not allowed to block a passage so that Takahashi is potentially unable to reach Room N.\n\nLet E be the expected number of passages Takahashi takes before he reaches Room N. Find the value of E when Aoki makes a choice that minimizes E.\n\nConstraints\n\n2 \\leq N \\leq 600\n\nN-1 \\leq M \\leq \\frac{N(N-1)}{2}\n\ns_i < t_i\n\nIf i != j, (s_i, t_i) \\neq (s_j, t_j). (Added 21:23 JST)\n\nFor every v = 1, 2, ..., N-1, there exists i such that v = s_i.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\ns_1 t_1\n:\ns_M t_M\n\nOutput\n\nPrint the value of E when Aoki makes a choice that minimizes E.\nYour output will be judged as correct when the absolute or relative error from the judge's output is at most 10^{-6}.\n\nSample Input 1\n\n4 6\n1 4\n2 3\n1 3\n1 2\n3 4\n2 4\n\nSample Output 1\n\n1.5000000000\n\nIf Aoki blocks the passage from Room 1 to Room 2, Takahashi will go along the path 1 → 3 → 4 with probability \\frac{1}{2} and 1 → 4 with probability \\frac{1}{2}. E = 1.5 here, and this is the minimum possible value of E.\n\nSample Input 2\n\n3 2\n1 2\n2 3\n\nSample Output 2\n\n2.0000000000\n\nBlocking any one passage makes Takahashi unable to reach Room N, so Aoki cannot block a passage.\n\nSample Input 3\n\n10 33\n3 7\n5 10\n8 9\n1 10\n4 6\n2 5\n1 7\n6 10\n1 4\n1 3\n8 10\n1 5\n2 6\n6 9\n5 6\n5 8\n3 6\n4 8\n2 7\n2 9\n6 7\n1 2\n5 9\n6 8\n9 10\n3 9\n7 8\n4 5\n2 10\n5 7\n3 5\n4 7\n4 9\n\nSample Output 3\n\n3.0133333333", "sample_input": "4 6\n1 4\n2 3\n1 3\n1 2\n3 4\n2 4\n"}, "reference_outputs": ["1.5000000000\n"], "source_document_id": "p02884", "source_text": "Score : 600 points\n\nProblem Statement\n\nThere is a cave consisting of N rooms and M one-directional passages. The rooms are numbered 1 through N.\n\nTakahashi is now in Room 1, and Room N has the exit. The i-th passage connects Room s_i and Room t_i (s_i < t_i) and can only be traversed in the direction from Room s_i to Room t_i. It is known that, for each room except Room N, there is at least one passage going from that room.\n\nTakahashi will escape from the cave. Each time he reaches a room (assume that he has reached Room 1 at the beginning), he will choose a passage uniformly at random from the ones going from that room and take that passage.\n\nAoki, a friend of Takahashi's, can block one of the passages (or do nothing) before Takahashi leaves Room 1. However, it is not allowed to block a passage so that Takahashi is potentially unable to reach Room N.\n\nLet E be the expected number of passages Takahashi takes before he reaches Room N. Find the value of E when Aoki makes a choice that minimizes E.\n\nConstraints\n\n2 \\leq N \\leq 600\n\nN-1 \\leq M \\leq \\frac{N(N-1)}{2}\n\ns_i < t_i\n\nIf i != j, (s_i, t_i) \\neq (s_j, t_j). (Added 21:23 JST)\n\nFor every v = 1, 2, ..., N-1, there exists i such that v = s_i.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\ns_1 t_1\n:\ns_M t_M\n\nOutput\n\nPrint the value of E when Aoki makes a choice that minimizes E.\nYour output will be judged as correct when the absolute or relative error from the judge's output is at most 10^{-6}.\n\nSample Input 1\n\n4 6\n1 4\n2 3\n1 3\n1 2\n3 4\n2 4\n\nSample Output 1\n\n1.5000000000\n\nIf Aoki blocks the passage from Room 1 to Room 2, Takahashi will go along the path 1 → 3 → 4 with probability \\frac{1}{2} and 1 → 4 with probability \\frac{1}{2}. E = 1.5 here, and this is the minimum possible value of E.\n\nSample Input 2\n\n3 2\n1 2\n2 3\n\nSample Output 2\n\n2.0000000000\n\nBlocking any one passage makes Takahashi unable to reach Room N, so Aoki cannot block a passage.\n\nSample Input 3\n\n10 33\n3 7\n5 10\n8 9\n1 10\n4 6\n2 5\n1 7\n6 10\n1 4\n1 3\n8 10\n1 5\n2 6\n6 9\n5 6\n5 8\n3 6\n4 8\n2 7\n2 9\n6 7\n1 2\n5 9\n6 8\n9 10\n3 9\n7 8\n4 5\n2 10\n5 7\n3 5\n4 7\n4 9\n\nSample Output 3\n\n3.0133333333", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2092, "cpu_time_ms": 97, "memory_kb": 6912}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s711778738", "group_id": "codeNet:p02885", "input_text": "let () = Scanf.scanf \"%d %d\" @@ fun a b -> Printf.printf \"%d\\n\" @@ max 0 (a - 2*b)", "language": "OCaml", "metadata": {"date": 1594975330, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p02885.html", "problem_id": "p02885", "resource_group": "low_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/OCaml/s711778738.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s711778738", "user_id": "u052332717"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "let () = Scanf.scanf \"%d %d\" @@ fun a b -> Printf.printf \"%d\\n\" @@ max 0 (a - 2*b)", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 9, "memory_kb": 3824}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s843393058", "group_id": "codeNet:p02885", "input_text": "let a, b = Scanf.scanf \"%d %d\\n\" @@ fun a b -> a, b\nlet ans = if a <= b * 2 then 0 else a - b * 2\nlet () = print_int ans", "language": "OCaml", "metadata": {"date": 1588325765, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02885.html", "problem_id": "p02885", "resource_group": "low_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/OCaml/s843393058.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s843393058", "user_id": "u307426615"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "let a, b = Scanf.scanf \"%d %d\\n\" @@ fun a b -> a, b\nlet ans = if a <= b * 2 then 0 else a - b * 2\nlet () = print_int ans", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s899225725", "group_id": "codeNet:p02886", "input_text": "let () =\n let split s =\n let rec loop i cur flag acc =\n if i = String.length s then ( if flag then cur :: acc else acc) else (\n match flag, s.[i] with\n | true, ' ' -> loop (i + 1) \"\" false (cur :: acc)\n | false, ' ' -> loop (i + 1) \"\" false acc\n | true, v -> loop (i + 1) (Printf.sprintf \"%s%c\" cur v) true acc\n | false, v -> loop (i + 1) (Printf.sprintf \"%s%c\" cur v) true acc\n )\n in\n List.map int_of_string (List.rev (loop 0 \"\" false []))\n in\n let main () =\n let n = int_of_string (read_line ()) in\n let d = split (read_line ()) in\n let s1 = List.fold_left (+) 0 d in\n let s2 = List.fold_left (fun acc v -> acc + v * v) 0 d in\n Printf.printf \"%d\\n\" (((s1 * s1) - s2) / 2)\n in\n main ()", "language": "OCaml", "metadata": {"date": 1571533572, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02886.html", "problem_id": "p02886", "resource_group": "low_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/OCaml/s899225725.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s899225725", "user_id": "u342443598"}, "prompt_components": {"gold_output": "11\n", "input_to_evaluate": "let () =\n let split s =\n let rec loop i cur flag acc =\n if i = String.length s then ( if flag then cur :: acc else acc) else (\n match flag, s.[i] with\n | true, ' ' -> loop (i + 1) \"\" false (cur :: acc)\n | false, ' ' -> loop (i + 1) \"\" false acc\n | true, v -> loop (i + 1) (Printf.sprintf \"%s%c\" cur v) true acc\n | false, v -> loop (i + 1) (Printf.sprintf \"%s%c\" cur v) true acc\n )\n in\n List.map int_of_string (List.rev (loop 0 \"\" false []))\n in\n let main () =\n let n = int_of_string (read_line ()) in\n let d = split (read_line ()) in\n let s1 = List.fold_left (+) 0 d in\n let s2 = List.fold_left (fun acc v -> acc + v * v) 0 d in\n Printf.printf \"%d\\n\" (((s1 * s1) - s2) / 2)\n in\n main ()", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 860, "cpu_time_ms": 1, "memory_kb": 512}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s698043146", "group_id": "codeNet:p02887", "input_text": "let () =\n Scanf.scanf \"%d\\n%s\\n\" @@ fun n s ->\n let ans, bfr = ref 1, ref s.[0] in\n String.iter (fun c -> if c <> !bfr then ans := !ans + 1; bfr := c) s;\n Printf.printf \"%d\\n\" !ans", "language": "OCaml", "metadata": {"date": 1599421073, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p02887.html", "problem_id": "p02887", "resource_group": "low_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/OCaml/s698043146.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s698043146", "user_id": "u307426615"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "let () =\n Scanf.scanf \"%d\\n%s\\n\" @@ fun n s ->\n let ans, bfr = ref 1, ref s.[0] in\n String.iter (fun c -> if c <> !bfr then ans := !ans + 1; bfr := c) s;\n Printf.printf \"%d\\n\" !ans", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 184, "cpu_time_ms": 10, "memory_kb": 4160}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s131052213", "group_id": "codeNet:p02888", "input_text": "let ans, k, n = ref 0, ref 0, Scanf.scanf \" %d\" (+) 0\nlet ss, ls = Array.(make (n * (n - 1) / 2) 0, init n @@ fun _ -> Scanf.scanf \" %d\" (+) 0)\nlet g i k a = a.(i) > k\nlet f k a = let l, r = ref @@ -1, ref @@ Array.length a in while !r - !l > 1 do let m = !l + (!r - !l) / 2 in if g m k a then r := m else l := m done; !r\nlet _ = for i = 0 to n - 1 do for j = i + 1 to n - 1 do ss.(!k) <- ls.(i) + ls.(j); incr k done done;\n Array.(sort (-) ss; sort (fun x y -> y - x) ls; iteri (fun i l -> ans := !ans + max 0 ((n - i - 1) * (n - i - 2) / 2 - f l ss)) ls); Printf.printf \"%d\\n\" !ans", "language": "OCaml", "metadata": {"date": 1572911805, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02888.html", "problem_id": "p02888", "resource_group": "low_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/OCaml/s131052213.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s131052213", "user_id": "u732304692"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "let ans, k, n = ref 0, ref 0, Scanf.scanf \" %d\" (+) 0\nlet ss, ls = Array.(make (n * (n - 1) / 2) 0, init n @@ fun _ -> Scanf.scanf \" %d\" (+) 0)\nlet g i k a = a.(i) > k\nlet f k a = let l, r = ref @@ -1, ref @@ Array.length a in while !r - !l > 1 do let m = !l + (!r - !l) / 2 in if g m k a then r := m else l := m done; !r\nlet _ = for i = 0 to n - 1 do for j = i + 1 to n - 1 do ss.(!k) <- ls.(i) + ls.(j); incr k done done;\n Array.(sort (-) ss; sort (fun x y -> y - x) ls; iteri (fun i l -> ans := !ans + max 0 ((n - i - 1) * (n - i - 2) / 2 - f l ss)) ls); Printf.printf \"%d\\n\" !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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 584, "cpu_time_ms": 826, "memory_kb": 20476}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s278168016", "group_id": "codeNet:p02888", "input_text": "let scan_int () = Scanf.scanf \" %d\" (fun x -> x)\nlet scan_array len read_func = Array.init len (fun _ -> read_func())\nlet print_int n = Printf.printf \"%d\\n\" n\n\nlet rec binary_search left right array value =\n if right - left <= 1 then right\n else\n let mid = (left + right) / 2 in\n if array.(mid) < value then binary_search mid right array value\n else binary_search left mid array value\n \n\nlet () =\n let n = scan_int() in\n let l = scan_array n scan_int in\n let _ = Array.fast_sort compare l in\n let ans = ref 0 in\n let _ =\n for i = 0 to n-2 do\n for j = i+1 to n-1 do\n let sum = l.(i) + l.(j) in\n let k = binary_search j n l sum in\n ans := !ans + (k-j-1)\n done\n done in\n print_int !ans\n", "language": "OCaml", "metadata": {"date": 1571874348, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02888.html", "problem_id": "p02888", "resource_group": "low_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/OCaml/s278168016.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s278168016", "user_id": "u521364030"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "let scan_int () = Scanf.scanf \" %d\" (fun x -> x)\nlet scan_array len read_func = Array.init len (fun _ -> read_func())\nlet print_int n = Printf.printf \"%d\\n\" n\n\nlet rec binary_search left right array value =\n if right - left <= 1 then right\n else\n let mid = (left + right) / 2 in\n if array.(mid) < value then binary_search mid right array value\n else binary_search left mid array value\n \n\nlet () =\n let n = scan_int() in\n let l = scan_array n scan_int in\n let _ = Array.fast_sort compare l in\n let ans = ref 0 in\n let _ =\n for i = 0 to n-2 do\n for j = i+1 to n-1 do\n let sum = l.(i) + l.(j) in\n let k = binary_search j n l sum in\n ans := !ans + (k-j-1)\n done\n done in\n print_int !ans\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nTakahashi has N sticks that are distinguishable from each other. The length of the i-th stick is L_i.\n\nHe is going to form a triangle using three of these sticks. Let a, b, and c be the lengths of the three sticks used. Here, all of the following conditions must be satisfied:\n\na < b + c\n\nb < c + a\n\nc < a + b\n\nHow many different triangles can be formed? Two triangles are considered different when there is a stick used in only one of them.\n\nConstraints\n\nAll values in input are integers.\n\n3 \\leq N \\leq 2 \\times 10^3\n\n1 \\leq L_i \\leq 10^3\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nL_1 L_2 ... L_N\n\nConstraints\n\nPrint the number of different triangles that can be formed.\n\nSample Input 1\n\n4\n3 4 2 1\n\nSample Output 1\n\n1\n\nOnly one triangle can be formed: the triangle formed by the first, second, and third sticks.\n\nSample Input 2\n\n3\n1 1000 1\n\nSample Output 2\n\n0\n\nNo triangles can be formed.\n\nSample Input 3\n\n7\n218 786 704 233 645 728 389\n\nSample Output 3\n\n23", "sample_input": "4\n3 4 2 1\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02888", "source_text": "Score : 400 points\n\nProblem Statement\n\nTakahashi has N sticks that are distinguishable from each other. The length of the i-th stick is L_i.\n\nHe is going to form a triangle using three of these sticks. Let a, b, and c be the lengths of the three sticks used. Here, all of the following conditions must be satisfied:\n\na < b + c\n\nb < c + a\n\nc < a + b\n\nHow many different triangles can be formed? Two triangles are considered different when there is a stick used in only one of them.\n\nConstraints\n\nAll values in input are integers.\n\n3 \\leq N \\leq 2 \\times 10^3\n\n1 \\leq L_i \\leq 10^3\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nL_1 L_2 ... L_N\n\nConstraints\n\nPrint the number of different triangles that can be formed.\n\nSample Input 1\n\n4\n3 4 2 1\n\nSample Output 1\n\n1\n\nOnly one triangle can be formed: the triangle formed by the first, second, and third sticks.\n\nSample Input 2\n\n3\n1 1000 1\n\nSample Output 2\n\n0\n\nNo triangles can be formed.\n\nSample Input 3\n\n7\n218 786 704 233 645 728 389\n\nSample Output 3\n\n23", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 738, "cpu_time_ms": 243, "memory_kb": 896}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s075612013", "group_id": "codeNet:p02898", "input_text": "let scan_int () = Scanf.scanf \" %d\" (fun x -> x)\nlet print_int n = Printf.printf \"%d\\n\" n\n\nlet rec solve i n k ret =\n if i = n then ret\n else\n let a = scan_int() in\n if a < k then solve (i+1) n k ret\n else solve (i+1) n k (ret+1)\n\nlet () =\n let n = scan_int() and k = scan_int() in\n print_int (solve 0 n k 0)\n", "language": "OCaml", "metadata": {"date": 1571890962, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02898.html", "problem_id": "p02898", "resource_group": "low_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/OCaml/s075612013.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s075612013", "user_id": "u521364030"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "let scan_int () = Scanf.scanf \" %d\" (fun x -> x)\nlet print_int n = Printf.printf \"%d\\n\" n\n\nlet rec solve i n k ret =\n if i = n then ret\n else\n let a = scan_int() in\n if a < k then solve (i+1) n k ret\n else solve (i+1) n k (ret+1)\n\nlet () =\n let n = scan_int() and k = scan_int() in\n print_int (solve 0 n k 0)\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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 21, "memory_kb": 2688}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s065160680", "group_id": "codeNet:p02898", "input_text": "let () = Scanf.scanf \"%d %d\\n\" @@ fun n k ->\n let hs = Array.init n @@ fun _ -> Scanf.scanf \"%d \" @@ fun h -> h in\n Printf.printf \"%d\\n\" @@\n Array.fold_right (fun h -> ( + ) @@ if k <= h then 1 else 0) hs 0\n", "language": "OCaml", "metadata": {"date": 1569719712, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02898.html", "problem_id": "p02898", "resource_group": "low_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/OCaml/s065160680.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s065160680", "user_id": "u504158101"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "let () = Scanf.scanf \"%d %d\\n\" @@ fun n k ->\n let hs = Array.init n @@ fun _ -> Scanf.scanf \"%d \" @@ fun h -> h in\n Printf.printf \"%d\\n\" @@\n Array.fold_right (fun h -> ( + ) @@ if k <= h then 1 else 0) hs 0\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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 210, "cpu_time_ms": 24, "memory_kb": 5376}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s139195419", "group_id": "codeNet:p02899", "input_text": "(*\nocamlfind ocamlopt -package batteries -linkpkg main.ml -o a.out\n*)\nopen Batteries\n\nlet n = Scanf.sscanf (read_line ()) \"%d\" (\n fun n -> \n n\n)\n\nlet lst = Str.split (Str.regexp \" \") (read_line ())\n |> List.map int_of_string\n\nlet lst2 = List.map2 (fun i elmnt -> (i, elmnt)) (List.range 1 `To n) lst\n |> List.fast_sort (fun (ai, ae) (bi, be) -> compare ae be)\n |> List.map (fun (i, e) -> i)\n\nlet () = \n List.iter (fun elmnt -> Printf.printf \"%d \" elmnt) lst2;\n Printf.printf \"\\n\"\n", "language": "OCaml", "metadata": {"date": 1590191869, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02899.html", "problem_id": "p02899", "resource_group": "low_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/OCaml/s139195419.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s139195419", "user_id": "u280335093"}, "prompt_components": {"gold_output": "3 1 2\n", "input_to_evaluate": "(*\nocamlfind ocamlopt -package batteries -linkpkg main.ml -o a.out\n*)\nopen Batteries\n\nlet n = Scanf.sscanf (read_line ()) \"%d\" (\n fun n -> \n n\n)\n\nlet lst = Str.split (Str.regexp \" \") (read_line ())\n |> List.map int_of_string\n\nlet lst2 = List.map2 (fun i elmnt -> (i, elmnt)) (List.range 1 `To n) lst\n |> List.fast_sort (fun (ai, ae) (bi, be) -> compare ae be)\n |> List.map (fun (i, e) -> i)\n\nlet () = \n List.iter (fun elmnt -> Printf.printf \"%d \" elmnt) lst2;\n Printf.printf \"\\n\"\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nTakahashi is a teacher responsible for a class of N students.\n\nThe students are given distinct student numbers from 1 to N.\n\nToday, all the students entered the classroom at different times.\n\nAccording to Takahashi's record, there were A_i students in the classroom when student number i entered the classroom (including student number i).\n\nFrom these records, reconstruct the order in which the students entered the classroom.\n\nConstraints\n\n1 \\le N \\le 10^5\n\n1 \\le A_i \\le N\n\nA_i \\neq A_j (i \\neq j)\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 \\ldots A_N\n\nOutput\n\nPrint the student numbers of the students in the order the students entered the classroom.\n\nSample Input 1\n\n3\n2 3 1\n\nSample Output 1\n\n3 1 2\n\nFirst, student number 3 entered the classroom.\n\nThen, student number 1 entered the classroom.\n\nFinally, student number 2 entered the classroom.\n\nSample Input 2\n\n5\n1 2 3 4 5\n\nSample Output 2\n\n1 2 3 4 5\n\nSample Input 3\n\n8\n8 2 7 3 4 5 6 1\n\nSample Output 3\n\n8 2 4 5 6 7 3 1", "sample_input": "3\n2 3 1\n"}, "reference_outputs": ["3 1 2\n"], "source_document_id": "p02899", "source_text": "Score : 300 points\n\nProblem Statement\n\nTakahashi is a teacher responsible for a class of N students.\n\nThe students are given distinct student numbers from 1 to N.\n\nToday, all the students entered the classroom at different times.\n\nAccording to Takahashi's record, there were A_i students in the classroom when student number i entered the classroom (including student number i).\n\nFrom these records, reconstruct the order in which the students entered the classroom.\n\nConstraints\n\n1 \\le N \\le 10^5\n\n1 \\le A_i \\le N\n\nA_i \\neq A_j (i \\neq j)\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 \\ldots A_N\n\nOutput\n\nPrint the student numbers of the students in the order the students entered the classroom.\n\nSample Input 1\n\n3\n2 3 1\n\nSample Output 1\n\n3 1 2\n\nFirst, student number 3 entered the classroom.\n\nThen, student number 1 entered the classroom.\n\nFinally, student number 2 entered the classroom.\n\nSample Input 2\n\n5\n1 2 3 4 5\n\nSample Output 2\n\n1 2 3 4 5\n\nSample Input 3\n\n8\n8 2 7 3 4 5 6 1\n\nSample Output 3\n\n8 2 4 5 6 7 3 1", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 545, "cpu_time_ms": 150, "memory_kb": 21436}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s640101935", "group_id": "codeNet:p02899", "input_text": "(*\nocamlfind ocamlopt -package batteries -linkpkg main.ml -o a.out\n*)\nopen Batteries\n\nlet n = Scanf.sscanf (read_line ()) \"%d\" (\n fun n -> \n n\n)\n\nlet lst = Str.split (Str.regexp \" \") (read_line ())\n |> List.map int_of_string\n\nlet lst2 = List.map2 (fun i elmnt -> (i, elmnt)) (List.range 1 `To n) lst\n |> List.fast_sort (fun (ai, ae) (bi, be) -> compare ae be)\n |> List.map (fun (i, e) -> i)\n\nlet () = \n List.iter (fun elmnt ->\n Printf.printf \"%d \" elmnt\n ) lst2;\n Printf.printf \"\\n\"\n", "language": "OCaml", "metadata": {"date": 1590191713, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02899.html", "problem_id": "p02899", "resource_group": "low_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/OCaml/s640101935.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s640101935", "user_id": "u280335093"}, "prompt_components": {"gold_output": "3 1 2\n", "input_to_evaluate": "(*\nocamlfind ocamlopt -package batteries -linkpkg main.ml -o a.out\n*)\nopen Batteries\n\nlet n = Scanf.sscanf (read_line ()) \"%d\" (\n fun n -> \n n\n)\n\nlet lst = Str.split (Str.regexp \" \") (read_line ())\n |> List.map int_of_string\n\nlet lst2 = List.map2 (fun i elmnt -> (i, elmnt)) (List.range 1 `To n) lst\n |> List.fast_sort (fun (ai, ae) (bi, be) -> compare ae be)\n |> List.map (fun (i, e) -> i)\n\nlet () = \n List.iter (fun elmnt ->\n Printf.printf \"%d \" elmnt\n ) lst2;\n Printf.printf \"\\n\"\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nTakahashi is a teacher responsible for a class of N students.\n\nThe students are given distinct student numbers from 1 to N.\n\nToday, all the students entered the classroom at different times.\n\nAccording to Takahashi's record, there were A_i students in the classroom when student number i entered the classroom (including student number i).\n\nFrom these records, reconstruct the order in which the students entered the classroom.\n\nConstraints\n\n1 \\le N \\le 10^5\n\n1 \\le A_i \\le N\n\nA_i \\neq A_j (i \\neq j)\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 \\ldots A_N\n\nOutput\n\nPrint the student numbers of the students in the order the students entered the classroom.\n\nSample Input 1\n\n3\n2 3 1\n\nSample Output 1\n\n3 1 2\n\nFirst, student number 3 entered the classroom.\n\nThen, student number 1 entered the classroom.\n\nFinally, student number 2 entered the classroom.\n\nSample Input 2\n\n5\n1 2 3 4 5\n\nSample Output 2\n\n1 2 3 4 5\n\nSample Input 3\n\n8\n8 2 7 3 4 5 6 1\n\nSample Output 3\n\n8 2 4 5 6 7 3 1", "sample_input": "3\n2 3 1\n"}, "reference_outputs": ["3 1 2\n"], "source_document_id": "p02899", "source_text": "Score : 300 points\n\nProblem Statement\n\nTakahashi is a teacher responsible for a class of N students.\n\nThe students are given distinct student numbers from 1 to N.\n\nToday, all the students entered the classroom at different times.\n\nAccording to Takahashi's record, there were A_i students in the classroom when student number i entered the classroom (including student number i).\n\nFrom these records, reconstruct the order in which the students entered the classroom.\n\nConstraints\n\n1 \\le N \\le 10^5\n\n1 \\le A_i \\le N\n\nA_i \\neq A_j (i \\neq j)\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 \\ldots A_N\n\nOutput\n\nPrint the student numbers of the students in the order the students entered the classroom.\n\nSample Input 1\n\n3\n2 3 1\n\nSample Output 1\n\n3 1 2\n\nFirst, student number 3 entered the classroom.\n\nThen, student number 1 entered the classroom.\n\nFinally, student number 2 entered the classroom.\n\nSample Input 2\n\n5\n1 2 3 4 5\n\nSample Output 2\n\n1 2 3 4 5\n\nSample Input 3\n\n8\n8 2 7 3 4 5 6 1\n\nSample Output 3\n\n8 2 4 5 6 7 3 1", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 570, "cpu_time_ms": 146, "memory_kb": 21436}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s592995764", "group_id": "codeNet:p02900", "input_text": "let filter n =\n match n with\n | 1 ->\n true\n | 2 ->\n true\n | n ->\n if n < 2 || n mod 2 = 0 then false\n else\n let rec f i =\n if float_of_int i > sqrt (float_of_int n) then true\n else if n mod i = 0 then false\n else f (i + 2)\n in\n f 3\n\nlet common_div a b =\n let sml = min a b and lrg = max a b in\n let num = Array.init sml (fun i -> i + 1) and acc = ref [] in\n for i = 0 to sml - 1 do\n if sml mod num.(i) = 0 && lrg mod num.(i) = 0 then acc := num.(i) :: !acc\n done ;\n Array.of_list @@ List.rev !acc\n\nlet () =\n let a, b = Scanf.scanf \"%d %d\\n\" (fun a b -> (a, b)) in\n let divs = common_div a b in\n let c = ref 0 in\n Array.iter (fun n -> if filter n = true then c := !c + 1) divs ;\n print_int !c\n", "language": "OCaml", "metadata": {"date": 1585686463, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02900.html", "problem_id": "p02900", "resource_group": "low_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/OCaml/s592995764.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s592995764", "user_id": "u575440531"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "let filter n =\n match n with\n | 1 ->\n true\n | 2 ->\n true\n | n ->\n if n < 2 || n mod 2 = 0 then false\n else\n let rec f i =\n if float_of_int i > sqrt (float_of_int n) then true\n else if n mod i = 0 then false\n else f (i + 2)\n in\n f 3\n\nlet common_div a b =\n let sml = min a b and lrg = max a b in\n let num = Array.init sml (fun i -> i + 1) and acc = ref [] in\n for i = 0 to sml - 1 do\n if sml mod num.(i) = 0 && lrg mod num.(i) = 0 then acc := num.(i) :: !acc\n done ;\n Array.of_list @@ List.rev !acc\n\nlet () =\n let a, b = Scanf.scanf \"%d %d\\n\" (fun a b -> (a, b)) in\n let divs = common_div a b in\n let c = ref 0 in\n Array.iter (fun n -> if filter n = true then c := !c + 1) divs ;\n print_int !c\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nGiven are positive integers A and B.\n\nLet us choose some number of positive common divisors of A and B.\n\nHere, any two of the chosen divisors must be coprime.\n\nAt most, how many divisors can we choose?\n\nDefinition of common divisor\n\nAn integer d is said to be a common divisor of integers x and y when d divides both x and y.\n\nDefinition of being coprime\n\nIntegers x and y are said to be coprime when x and y have no positive common divisors other than 1.\n\nDefinition of dividing\n\nAn integer x is said to divide another integer y when there exists an integer \\alpha such that y = \\alpha x.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq A, B \\leq 10^{12}\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the maximum number of divisors that can be chosen to satisfy the condition.\n\nSample Input 1\n\n12 18\n\nSample Output 1\n\n3\n\n12 and 18 have the following positive common divisors: 1, 2, 3, and 6.\n\n1 and 2 are coprime, 2 and 3 are coprime, and 3 and 1 are coprime, so we can choose 1, 2, and 3, which achieve the maximum result.\n\nSample Input 2\n\n420 660\n\nSample Output 2\n\n4\n\nSample Input 3\n\n1 2019\n\nSample Output 3\n\n1\n\n1 and 2019 have no positive common divisors other than 1.", "sample_input": "12 18\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02900", "source_text": "Score : 400 points\n\nProblem Statement\n\nGiven are positive integers A and B.\n\nLet us choose some number of positive common divisors of A and B.\n\nHere, any two of the chosen divisors must be coprime.\n\nAt most, how many divisors can we choose?\n\nDefinition of common divisor\n\nAn integer d is said to be a common divisor of integers x and y when d divides both x and y.\n\nDefinition of being coprime\n\nIntegers x and y are said to be coprime when x and y have no positive common divisors other than 1.\n\nDefinition of dividing\n\nAn integer x is said to divide another integer y when there exists an integer \\alpha such that y = \\alpha x.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq A, B \\leq 10^{12}\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the maximum number of divisors that can be chosen to satisfy the condition.\n\nSample Input 1\n\n12 18\n\nSample Output 1\n\n3\n\n12 and 18 have the following positive common divisors: 1, 2, 3, and 6.\n\n1 and 2 are coprime, 2 and 3 are coprime, and 3 and 1 are coprime, so we can choose 1, 2, and 3, which achieve the maximum result.\n\nSample Input 2\n\n420 660\n\nSample Output 2\n\n4\n\nSample Input 3\n\n1 2019\n\nSample Output 3\n\n1\n\n1 and 2019 have no positive common divisors other than 1.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 777, "cpu_time_ms": 1, "memory_kb": 2432}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s552701256", "group_id": "codeNet:p02901", "input_text": "let scan_int () = Scanf.scanf \" %d\" (fun x -> x)\nlet scan_array len read_func = Array.init len (fun _ -> read_func())\nlet print_int n = Printf.printf \"%d\\n\" n\n\nlet rec calc_bit i n ret =\n if i = n then ret\n else\n let c = scan_int() in\n calc_bit (i+1) n (ret lor (1 lsl (c-1)))\n\nlet rec input i n arr =\n if i = n then arr\n else\n let a = scan_int() and b = scan_int() in\n let c = calc_bit 0 b 0 in\n let _ = arr.(i) <- (a, c) in\n input (i+1) n arr\n\nlet rec dp table i n m arr =\n if i = m then table.((1 lsl n) - 1)\n else\n let a, c = arr.(i) in\n let rec update_dp_table j n a c =\n if j = n then ()\n else\n let _ = table.(j lor c) <- min table.(j lor c) (table.(j) + a) in\n update_dp_table (j+1) n a c in\n let _ = update_dp_table 0 (1 lsl n) a c in\n dp table (i+1) n m arr\n\n\nlet max_cost = int_of_float 1e15\n\nlet () = \n let n = scan_int() and m = scan_int() in\n let arr = Array.make m (0, 0) and dp_table = Array.make (1 lsl n) max_cost in\n let _ = dp_table.(0) <- 0 in\n let _ = input 0 m arr in\n let ret = dp dp_table 0 n m arr in\n if ret = max_cost then print_int (-1)\n else print_int ret\n ", "language": "OCaml", "metadata": {"date": 1571893219, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02901.html", "problem_id": "p02901", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02901/input.txt", "sample_output_relpath": "derived/input_output/data/p02901/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02901/OCaml/s552701256.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s552701256", "user_id": "u521364030"}, "prompt_components": {"gold_output": "25\n", "input_to_evaluate": "let scan_int () = Scanf.scanf \" %d\" (fun x -> x)\nlet scan_array len read_func = Array.init len (fun _ -> read_func())\nlet print_int n = Printf.printf \"%d\\n\" n\n\nlet rec calc_bit i n ret =\n if i = n then ret\n else\n let c = scan_int() in\n calc_bit (i+1) n (ret lor (1 lsl (c-1)))\n\nlet rec input i n arr =\n if i = n then arr\n else\n let a = scan_int() and b = scan_int() in\n let c = calc_bit 0 b 0 in\n let _ = arr.(i) <- (a, c) in\n input (i+1) n arr\n\nlet rec dp table i n m arr =\n if i = m then table.((1 lsl n) - 1)\n else\n let a, c = arr.(i) in\n let rec update_dp_table j n a c =\n if j = n then ()\n else\n let _ = table.(j lor c) <- min table.(j lor c) (table.(j) + a) in\n update_dp_table (j+1) n a c in\n let _ = update_dp_table 0 (1 lsl n) a c in\n dp table (i+1) n m arr\n\n\nlet max_cost = int_of_float 1e15\n\nlet () = \n let n = scan_int() and m = scan_int() in\n let arr = Array.make m (0, 0) and dp_table = Array.make (1 lsl n) max_cost in\n let _ = dp_table.(0) <- 0 in\n let _ = input 0 m arr in\n let ret = dp dp_table 0 n m arr in\n if ret = max_cost then print_int (-1)\n else print_int ret\n ", "problem_context": "Score : 500 points\n\nProblem Statement\n\nWe have N locked treasure boxes, numbered 1 to N.\n\nA shop sells M keys. The i-th key is sold for a_i yen (the currency of Japan), and it can unlock b_i of the boxes: Box c_{i1}, c_{i2}, ..., c_{i{b_i}}. Each key purchased can be used any number of times.\n\nFind the minimum cost required to unlock all the treasure boxes. If it is impossible to unlock all of them, print -1.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 12\n\n1 \\leq M \\leq 10^3\n\n1 \\leq a_i \\leq 10^5\n\n1 \\leq b_i \\leq N\n\n1 \\leq c_{i1} < c_{i2} < ... < c_{i{b_i}} \\leq N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\na_1 b_1\nc_{11} c_{12} ... c_{1{b_1}}\n:\na_M b_M\nc_{M1} c_{M2} ... c_{M{b_M}}\n\nOutput\n\nPrint the minimum cost required to unlock all the treasure boxes.\nIf it is impossible to unlock all of them, print -1.\n\nSample Input 1\n\n2 3\n10 1\n1\n15 1\n2\n30 2\n1 2\n\nSample Output 1\n\n25\n\nWe can unlock all the boxes by purchasing the first and second keys, at the cost of 25 yen, which is the minimum cost required.\n\nSample Input 2\n\n12 1\n100000 1\n2\n\nSample Output 2\n\n-1\n\nWe cannot unlock all the boxes.\n\nSample Input 3\n\n4 6\n67786 3\n1 3 4\n3497 1\n2\n44908 3\n2 3 4\n2156 3\n2 3 4\n26230 1\n2\n86918 1\n3\n\nSample Output 3\n\n69942", "sample_input": "2 3\n10 1\n1\n15 1\n2\n30 2\n1 2\n"}, "reference_outputs": ["25\n"], "source_document_id": "p02901", "source_text": "Score : 500 points\n\nProblem Statement\n\nWe have N locked treasure boxes, numbered 1 to N.\n\nA shop sells M keys. The i-th key is sold for a_i yen (the currency of Japan), and it can unlock b_i of the boxes: Box c_{i1}, c_{i2}, ..., c_{i{b_i}}. Each key purchased can be used any number of times.\n\nFind the minimum cost required to unlock all the treasure boxes. If it is impossible to unlock all of them, print -1.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 12\n\n1 \\leq M \\leq 10^3\n\n1 \\leq a_i \\leq 10^5\n\n1 \\leq b_i \\leq N\n\n1 \\leq c_{i1} < c_{i2} < ... < c_{i{b_i}} \\leq N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\na_1 b_1\nc_{11} c_{12} ... c_{1{b_1}}\n:\na_M b_M\nc_{M1} c_{M2} ... c_{M{b_M}}\n\nOutput\n\nPrint the minimum cost required to unlock all the treasure boxes.\nIf it is impossible to unlock all of them, print -1.\n\nSample Input 1\n\n2 3\n10 1\n1\n15 1\n2\n30 2\n1 2\n\nSample Output 1\n\n25\n\nWe can unlock all the boxes by purchasing the first and second keys, at the cost of 25 yen, which is the minimum cost required.\n\nSample Input 2\n\n12 1\n100000 1\n2\n\nSample Output 2\n\n-1\n\nWe cannot unlock all the boxes.\n\nSample Input 3\n\n4 6\n67786 3\n1 3 4\n3497 1\n2\n44908 3\n2 3 4\n2156 3\n2 3 4\n26230 1\n2\n86918 1\n3\n\nSample Output 3\n\n69942", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1154, "cpu_time_ms": 55, "memory_kb": 3200}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s825683994", "group_id": "codeNet:p02902", "input_text": "let rec drop n xs =\n if n = 0\n then xs\n else drop (n - 1) (List.tl xs)\n\nexception Exit of int list\n\nlet () = Scanf.scanf \"%d %d\\n\" @@ fun n m ->\n let es = Array.make n [] in\n for i = 0 to m - 1 do\n Scanf.scanf \"%d %d\\n\" @@ fun a b ->\n es.(a - 1) <- b - 1 :: es.(a - 1)\n done;\n let trace = Array.make n None in\n let visited = Array.make n false in\n let rec visit vs v =\n match trace.(v) with\n | Some us -> raise (Exit (drop (List.length us) (List.rev vs)))\n | None ->\n visited.(v) <- true;\n trace.(v) <- Some vs;\n List.iter (fun u -> visit (v :: vs) u) es.(v);\n trace.(v) <- None in\n try\n for v = 0 to n - 1 do\n if not visited.(v) then visit [] v\n done;\n print_endline \"-1\"\n with Exit vs ->\n Printf.printf \"%d\\n\" (List.length vs);\n List.iter (fun v -> Printf.printf \"%d\\n\" @@ v + 1) vs\n", "language": "OCaml", "metadata": {"date": 1577538097, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02902.html", "problem_id": "p02902", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02902/input.txt", "sample_output_relpath": "derived/input_output/data/p02902/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02902/OCaml/s825683994.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s825683994", "user_id": "u504158101"}, "prompt_components": {"gold_output": "3\n1\n2\n4\n", "input_to_evaluate": "let rec drop n xs =\n if n = 0\n then xs\n else drop (n - 1) (List.tl xs)\n\nexception Exit of int list\n\nlet () = Scanf.scanf \"%d %d\\n\" @@ fun n m ->\n let es = Array.make n [] in\n for i = 0 to m - 1 do\n Scanf.scanf \"%d %d\\n\" @@ fun a b ->\n es.(a - 1) <- b - 1 :: es.(a - 1)\n done;\n let trace = Array.make n None in\n let visited = Array.make n false in\n let rec visit vs v =\n match trace.(v) with\n | Some us -> raise (Exit (drop (List.length us) (List.rev vs)))\n | None ->\n visited.(v) <- true;\n trace.(v) <- Some vs;\n List.iter (fun u -> visit (v :: vs) u) es.(v);\n trace.(v) <- None in\n try\n for v = 0 to n - 1 do\n if not visited.(v) then visit [] v\n done;\n print_endline \"-1\"\n with Exit vs ->\n Printf.printf \"%d\\n\" (List.length vs);\n List.iter (fun v -> Printf.printf \"%d\\n\" @@ v + 1) vs\n", "problem_context": "Score : 600 points\n\nProblem Statement\n\nGiven is a directed graph G with N vertices and M edges.\n\nThe vertices are numbered 1 to N, and the i-th edge is directed from Vertex A_i to Vertex B_i.\n\nIt is guaranteed that the graph contains no self-loops or multiple edges.\n\nDetermine whether there exists an induced subgraph (see Notes) of G such that the in-degree and out-degree of every vertex are both 1. If the answer is yes, show one such subgraph.\n\nHere the null graph is not considered as a subgraph.\n\nNotes\n\nFor a directed graph G = (V, E), we call a directed graph G' = (V', E') satisfying the following conditions an induced subgraph of G:\n\nV' is a (non-empty) subset of V.\n\nE' is the set of all the edges in E that have both endpoints in V'.\n\nConstraints\n\n1 \\leq N \\leq 1000\n\n0 \\leq M \\leq 2000\n\n1 \\leq A_i,B_i \\leq N\n\nA_i \\neq B_i\n\nAll pairs (A_i, B_i) are distinct.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 B_1\nA_2 B_2\n:\nA_M B_M\n\nOutput\n\nIf there is no induced subgraph of G that satisfies the condition, print -1.\nOtherwise, print an induced subgraph of G that satisfies the condition, in the following format:\n\nK\nv_1\nv_2\n:\nv_K\n\nThis represents the induced subgraph of G with K vertices whose vertex set is \\{v_1, v_2, \\ldots, v_K\\}. (The order of v_1, v_2, \\ldots, v_K does not matter.)\nIf there are multiple subgraphs of G that satisfy the condition, printing any of them is accepted.\n\nSample Input 1\n\n4 5\n1 2\n2 3\n2 4\n4 1\n4 3\n\nSample Output 1\n\n3\n1\n2\n4\n\nThe induced subgraph of G whose vertex set is \\{1, 2, 4\\} has the edge set \\{(1, 2), (2, 4), (4, 1)\\}. The in-degree and out-degree of every vertex in this graph are both 1.\n\nSample Input 2\n\n4 5\n1 2\n2 3\n2 4\n1 4\n4 3\n\nSample Output 2\n\n-1\n\nThere is no induced subgraph of G that satisfies the condition.\n\nSample Input 3\n\n6 9\n1 2\n2 3\n3 4\n4 5\n5 6\n5 1\n5 2\n6 1\n6 2\n\nSample Output 3\n\n4\n2\n3\n4\n5", "sample_input": "4 5\n1 2\n2 3\n2 4\n4 1\n4 3\n"}, "reference_outputs": ["3\n1\n2\n4\n"], "source_document_id": "p02902", "source_text": "Score : 600 points\n\nProblem Statement\n\nGiven is a directed graph G with N vertices and M edges.\n\nThe vertices are numbered 1 to N, and the i-th edge is directed from Vertex A_i to Vertex B_i.\n\nIt is guaranteed that the graph contains no self-loops or multiple edges.\n\nDetermine whether there exists an induced subgraph (see Notes) of G such that the in-degree and out-degree of every vertex are both 1. If the answer is yes, show one such subgraph.\n\nHere the null graph is not considered as a subgraph.\n\nNotes\n\nFor a directed graph G = (V, E), we call a directed graph G' = (V', E') satisfying the following conditions an induced subgraph of G:\n\nV' is a (non-empty) subset of V.\n\nE' is the set of all the edges in E that have both endpoints in V'.\n\nConstraints\n\n1 \\leq N \\leq 1000\n\n0 \\leq M \\leq 2000\n\n1 \\leq A_i,B_i \\leq N\n\nA_i \\neq B_i\n\nAll pairs (A_i, B_i) are distinct.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 B_1\nA_2 B_2\n:\nA_M B_M\n\nOutput\n\nIf there is no induced subgraph of G that satisfies the condition, print -1.\nOtherwise, print an induced subgraph of G that satisfies the condition, in the following format:\n\nK\nv_1\nv_2\n:\nv_K\n\nThis represents the induced subgraph of G with K vertices whose vertex set is \\{v_1, v_2, \\ldots, v_K\\}. (The order of v_1, v_2, \\ldots, v_K does not matter.)\nIf there are multiple subgraphs of G that satisfy the condition, printing any of them is accepted.\n\nSample Input 1\n\n4 5\n1 2\n2 3\n2 4\n4 1\n4 3\n\nSample Output 1\n\n3\n1\n2\n4\n\nThe induced subgraph of G whose vertex set is \\{1, 2, 4\\} has the edge set \\{(1, 2), (2, 4), (4, 1)\\}. The in-degree and out-degree of every vertex in this graph are both 1.\n\nSample Input 2\n\n4 5\n1 2\n2 3\n2 4\n1 4\n4 3\n\nSample Output 2\n\n-1\n\nThere is no induced subgraph of G that satisfies the condition.\n\nSample Input 3\n\n6 9\n1 2\n2 3\n3 4\n4 5\n5 6\n5 1\n5 2\n6 1\n6 2\n\nSample Output 3\n\n4\n2\n3\n4\n5", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 861, "cpu_time_ms": 3, "memory_kb": 2432}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s230756492", "group_id": "codeNet:p02903", "input_text": "let () = Scanf.scanf \"%d %d %d %d\" @@ fun h w a b ->\n for i = 0 to h - 1 do\n for j = 0 to w - 1 do\n print_char @@\n if (i < b) = (j < a)\n then '0'\n else '1'\n done;\n print_newline ()\n done\n", "language": "OCaml", "metadata": {"date": 1569281098, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02903.html", "problem_id": "p02903", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02903/input.txt", "sample_output_relpath": "derived/input_output/data/p02903/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02903/OCaml/s230756492.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s230756492", "user_id": "u504158101"}, "prompt_components": {"gold_output": "100\n010\n001\n", "input_to_evaluate": "let () = Scanf.scanf \"%d %d %d %d\" @@ fun h w a b ->\n for i = 0 to h - 1 do\n for j = 0 to w - 1 do\n print_char @@\n if (i < b) = (j < a)\n then '0'\n else '1'\n done;\n print_newline ()\n done\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nWe have a square grid with H rows and W columns.\nSnuke wants to write 0 or 1 in each of the squares.\nHere, all of the following conditions have to be satisfied:\n\nFor every row, the smaller of the following is A: the number of 0s contained in the row, and the number of 1s contained in the row. (If these two numbers are equal, “the smaller” should be read as “either”.)\n\nFor every column, the smaller of the following is B: the number of 0s contained in the column, and the number of 1s contained in the column.\n\nDetermine if these conditions can be satisfied by writing 0 or 1 in each of the squares. If the answer is yes, show one way to fill the squares so that the conditions are satisfied.\n\nConstraints\n\n1 \\leq H,W \\leq 1000\n\n0 \\leq A\n\n2 \\times A \\leq W\n\n0 \\leq B\n\n2 \\times B \\leq H\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W A B\n\nOutput\n\nIf the conditions cannot be satisfied by writing 0 or 1 in each of the squares, print -1.\n\nIf the conditions can be satisfied, print one way to fill the squares so that the conditions are satisfied, in the following format:\n\ns_{11}s_{12}\\cdots s_{1W}\ns_{21}s_{22}\\cdots s_{2W}\n\\vdots\ns_{H1}s_{H2}\\cdots s_{HW}\n\nHere s_{ij} is the digit written in the square at the i-th row from the top and the j-th column from the left in the grid.\n\nIf multiple solutions exist, printing any of them will be accepted.\n\nSample Input 1\n\n3 3 1 1\n\nSample Output 1\n\n100\n010\n001\n\nEvery row contains two 0s and one 1, so the first condition is satisfied.\nAlso, every column contains two 0s and one 1, so the second condition is satisfied.\n\nSample Input 2\n\n1 5 2 0\n\nSample Output 2\n\n01010", "sample_input": "3 3 1 1\n"}, "reference_outputs": ["100\n010\n001\n"], "source_document_id": "p02903", "source_text": "Score : 300 points\n\nProblem Statement\n\nWe have a square grid with H rows and W columns.\nSnuke wants to write 0 or 1 in each of the squares.\nHere, all of the following conditions have to be satisfied:\n\nFor every row, the smaller of the following is A: the number of 0s contained in the row, and the number of 1s contained in the row. (If these two numbers are equal, “the smaller” should be read as “either”.)\n\nFor every column, the smaller of the following is B: the number of 0s contained in the column, and the number of 1s contained in the column.\n\nDetermine if these conditions can be satisfied by writing 0 or 1 in each of the squares. If the answer is yes, show one way to fill the squares so that the conditions are satisfied.\n\nConstraints\n\n1 \\leq H,W \\leq 1000\n\n0 \\leq A\n\n2 \\times A \\leq W\n\n0 \\leq B\n\n2 \\times B \\leq H\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W A B\n\nOutput\n\nIf the conditions cannot be satisfied by writing 0 or 1 in each of the squares, print -1.\n\nIf the conditions can be satisfied, print one way to fill the squares so that the conditions are satisfied, in the following format:\n\ns_{11}s_{12}\\cdots s_{1W}\ns_{21}s_{22}\\cdots s_{2W}\n\\vdots\ns_{H1}s_{H2}\\cdots s_{HW}\n\nHere s_{ij} is the digit written in the square at the i-th row from the top and the j-th column from the left in the grid.\n\nIf multiple solutions exist, printing any of them will be accepted.\n\nSample Input 1\n\n3 3 1 1\n\nSample Output 1\n\n100\n010\n001\n\nEvery row contains two 0s and one 1, so the first condition is satisfied.\nAlso, every column contains two 0s and one 1, so the second condition is satisfied.\n\nSample Input 2\n\n1 5 2 0\n\nSample Output 2\n\n01010", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 22, "memory_kb": 1408}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s147506402", "group_id": "codeNet:p02904", "input_text": "Scanf.scanf \"%d %d\" (fun n k ->\n let p = Array.init n (fun _ -> Scanf.scanf \" %d\" (fun p -> p)) in\n let module S = Set.Make (struct type t = int let compare = compare end) in\n\n let grp = Array.make n 0 in\n\n let rec loop i prev cur =\n if i = n then () else\n let cur = if p.(i) > prev then cur else cur + 1 in\n let () = grp.(i) <- cur in\n loop (i + 1) p.(i) cur\n in\n loop 1 p.(0) 0;\n\n let par = Array.init (n - k + 2) (fun i -> i) in\n let rec root x =\n if x = par.(x) then x else\n let r = root par.(x) in\n let () = par.(x) <- r in\n r\n in\n let merge a b =\n if root a <> root b then par.(par.(b)) <- par.(a)\n in\n\n let e = n - k + 1 in\n\n let rec loop i set =\n if grp.(i) = grp.(i + k - 1) then merge i e;\n if i + k = n then () else\n let cmi = S.min_elt set in\n let cmx = S.max_elt set in\n let set = S.remove p.(i) set in\n let set = S.add p.(i + k) set in\n let nmi = S.min_elt set in\n let nmx = S.max_elt set in\n\n if grp.(i) <> grp.(i + k - 1) && cmi = nmi && cmx = nmx then merge i (i + 1);\n loop (i + 1) set\n in\n let init =\n let rec loop i set =\n if i = k then set else loop (i + 1) (S.add p.(i) set)\n in\n loop 0 S.empty\n in\n loop 0 init;\n let rec loop i set =\n if i + k > n then S.cardinal set else\n loop (i + 1) (S.add (root i) set)\n in\n loop 0 S.empty |> Printf.printf \"%d\\n\"\n)", "language": "OCaml", "metadata": {"date": 1591233734, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02904.html", "problem_id": "p02904", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02904/input.txt", "sample_output_relpath": "derived/input_output/data/p02904/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02904/OCaml/s147506402.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s147506402", "user_id": "u342443598"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "Scanf.scanf \"%d %d\" (fun n k ->\n let p = Array.init n (fun _ -> Scanf.scanf \" %d\" (fun p -> p)) in\n let module S = Set.Make (struct type t = int let compare = compare end) in\n\n let grp = Array.make n 0 in\n\n let rec loop i prev cur =\n if i = n then () else\n let cur = if p.(i) > prev then cur else cur + 1 in\n let () = grp.(i) <- cur in\n loop (i + 1) p.(i) cur\n in\n loop 1 p.(0) 0;\n\n let par = Array.init (n - k + 2) (fun i -> i) in\n let rec root x =\n if x = par.(x) then x else\n let r = root par.(x) in\n let () = par.(x) <- r in\n r\n in\n let merge a b =\n if root a <> root b then par.(par.(b)) <- par.(a)\n in\n\n let e = n - k + 1 in\n\n let rec loop i set =\n if grp.(i) = grp.(i + k - 1) then merge i e;\n if i + k = n then () else\n let cmi = S.min_elt set in\n let cmx = S.max_elt set in\n let set = S.remove p.(i) set in\n let set = S.add p.(i + k) set in\n let nmi = S.min_elt set in\n let nmx = S.max_elt set in\n\n if grp.(i) <> grp.(i + k - 1) && cmi = nmi && cmx = nmx then merge i (i + 1);\n loop (i + 1) set\n in\n let init =\n let rec loop i set =\n if i = k then set else loop (i + 1) (S.add p.(i) set)\n in\n loop 0 S.empty\n in\n loop 0 init;\n let rec loop i set =\n if i + k > n then S.cardinal set else\n loop (i + 1) (S.add (root i) set)\n in\n loop 0 S.empty |> Printf.printf \"%d\\n\"\n)", "problem_context": "Score : 700 points\n\nProblem Statement\n\nSnuke has a permutation (P_0,P_1,\\cdots,P_{N-1}) of (0,1,\\cdots,N-1).\n\nNow, he will perform the following operation exactly once:\n\nChoose K consecutive elements in P and sort them in ascending order.\n\nFind the number of permutations that can be produced as P after the operation.\n\nConstraints\n\n2 \\leq N \\leq 200000\n\n2 \\leq K \\leq N\n\n0 \\leq P_i \\leq N-1\n\nP_0,P_1,\\cdots,P_{N-1} are all different.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nP_0 P_1 \\cdots P_{N-1}\n\nOutput\n\nPrint the number of permutations that can be produced as P after the operation.\n\nSample Input 1\n\n5 3\n0 2 1 4 3\n\nSample Output 1\n\n2\n\nTwo permutations can be produced as P after the operation: (0,1,2,4,3) and (0,2,1,3,4).\n\nSample Input 2\n\n4 4\n0 1 2 3\n\nSample Output 2\n\n1\n\nSample Input 3\n\n10 4\n2 0 1 3 7 5 4 6 8 9\n\nSample Output 3\n\n6", "sample_input": "5 3\n0 2 1 4 3\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02904", "source_text": "Score : 700 points\n\nProblem Statement\n\nSnuke has a permutation (P_0,P_1,\\cdots,P_{N-1}) of (0,1,\\cdots,N-1).\n\nNow, he will perform the following operation exactly once:\n\nChoose K consecutive elements in P and sort them in ascending order.\n\nFind the number of permutations that can be produced as P after the operation.\n\nConstraints\n\n2 \\leq N \\leq 200000\n\n2 \\leq K \\leq N\n\n0 \\leq P_i \\leq N-1\n\nP_0,P_1,\\cdots,P_{N-1} are all different.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nP_0 P_1 \\cdots P_{N-1}\n\nOutput\n\nPrint the number of permutations that can be produced as P after the operation.\n\nSample Input 1\n\n5 3\n0 2 1 4 3\n\nSample Output 1\n\n2\n\nTwo permutations can be produced as P after the operation: (0,1,2,4,3) and (0,2,1,3,4).\n\nSample Input 2\n\n4 4\n0 1 2 3\n\nSample Output 2\n\n1\n\nSample Input 3\n\n10 4\n2 0 1 3 7 5 4 6 8 9\n\nSample Output 3\n\n6", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1575, "cpu_time_ms": 334, "memory_kb": 22528}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s690839391", "group_id": "codeNet:p02909", "input_text": "print_endline @@ match read_line () with \"Sunny\" -> \"Cloudy\" | \"Cloudy\" -> \"Rainy\" | _ -> \"Sunny\"", "language": "OCaml", "metadata": {"date": 1568658392, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02909.html", "problem_id": "p02909", "resource_group": "low_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/OCaml/s690839391.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s690839391", "user_id": "u732304692"}, "prompt_components": {"gold_output": "Cloudy\n", "input_to_evaluate": "print_endline @@ match read_line () with \"Sunny\" -> \"Cloudy\" | \"Cloudy\" -> \"Rainy\" | _ -> \"Sunny\"", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s370321665", "group_id": "codeNet:p02909", "input_text": "let () =\n print_endline @@\n match read_line () with\n | \"Sunny\" -> \"Cloudy\"\n | \"Cloudy\" -> \"Rainy\"\n | \"Rainy\" -> \"Sunny\"\n", "language": "OCaml", "metadata": {"date": 1568601676, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02909.html", "problem_id": "p02909", "resource_group": "low_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/OCaml/s370321665.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s370321665", "user_id": "u504158101"}, "prompt_components": {"gold_output": "Cloudy\n", "input_to_evaluate": "let () =\n print_endline @@\n match read_line () with\n | \"Sunny\" -> \"Cloudy\"\n | \"Cloudy\" -> \"Rainy\"\n | \"Rainy\" -> \"Sunny\"\n", "problem_context": "Score: 100 points\n\nProblem Statement\n\nThe weather in Takahashi's town changes day by day, in the following cycle: Sunny, Cloudy, Rainy, Sunny, Cloudy, Rainy, ...\n\nGiven is a string S representing the weather in the town today. Predict the weather tomorrow.\n\nConstraints\n\nS is Sunny, Cloudy, or Rainy.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint a string representing the expected weather tomorrow, in the same format in which input is given.\n\nSample Input 1\n\nSunny\n\nSample Output 1\n\nCloudy\n\nIn Takahashi's town, a sunny day is followed by a cloudy day.\n\nSample Input 2\n\nRainy\n\nSample Output 2\n\nSunny", "sample_input": "Sunny\n"}, "reference_outputs": ["Cloudy\n"], "source_document_id": "p02909", "source_text": "Score: 100 points\n\nProblem Statement\n\nThe weather in Takahashi's town changes day by day, in the following cycle: Sunny, Cloudy, Rainy, Sunny, Cloudy, Rainy, ...\n\nGiven is a string S representing the weather in the town today. Predict the weather tomorrow.\n\nConstraints\n\nS is Sunny, Cloudy, or Rainy.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint a string representing the expected weather tomorrow, in the same format in which input is given.\n\nSample Input 1\n\nSunny\n\nSample Output 1\n\nCloudy\n\nIn Takahashi's town, a sunny day is followed by a cloudy day.\n\nSample Input 2\n\nRainy\n\nSample Output 2\n\nSunny", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s180444024", "group_id": "codeNet:p02910", "input_text": "(* Vicfred\n * https://atcoder.jp/contests/abc141/tasks/abc141_b\n * implementation\n * *)\nScanf.scanf \"%s\\n\" (fun s ->\n if\n Array.fold_left ( && ) true @@\n Array.init (String.length s) @@ fun i ->\n if i mod 2 = 0 && s.[i] = 'L' then false\n else if i mod 2 = 1 && s.[i] = 'R' then false\n else true\n then \"Yes\"\n else \"No\"\n) |> Printf.printf \"%s\\n\"\n\n", "language": "OCaml", "metadata": {"date": 1593629266, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p02910.html", "problem_id": "p02910", "resource_group": "low_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/OCaml/s180444024.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s180444024", "user_id": "u737840172"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "(* Vicfred\n * https://atcoder.jp/contests/abc141/tasks/abc141_b\n * implementation\n * *)\nScanf.scanf \"%s\\n\" (fun s ->\n if\n Array.fold_left ( && ) true @@\n Array.init (String.length s) @@ fun i ->\n if i mod 2 = 0 && s.[i] = 'L' then false\n else if i mod 2 = 1 && s.[i] = 'R' then false\n else true\n then \"Yes\"\n else \"No\"\n) |> Printf.printf \"%s\\n\"\n\n", "problem_context": "Score: 200 points\n\nProblem Statement\n\nTakahashi will do a tap dance. The dance is described by a string S where each character is L, R, U, or D. These characters indicate the positions on which Takahashi should step. He will follow these instructions one by one in order, starting with the first character.\n\nS is said to be easily playable if and only if it satisfies both of the following conditions:\n\nEvery character in an odd position (1-st, 3-rd, 5-th, \\ldots) is R, U, or D.\n\nEvery character in an even position (2-nd, 4-th, 6-th, \\ldots) is L, U, or D.\n\nYour task is to print Yes if S is easily playable, and No otherwise.\n\nConstraints\n\nS is a string of length between 1 and 100 (inclusive).\n\nEach character of S is L, R, U, or D.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint Yes if S is easily playable, and No otherwise.\n\nSample Input 1\n\nRUDLUDR\n\nSample Output 1\n\nYes\n\nEvery character in an odd position (1-st, 3-rd, 5-th, 7-th) is R, U, or D.\n\nEvery character in an even position (2-nd, 4-th, 6-th) is L, U, or D.\n\nThus, S is easily playable.\n\nSample Input 2\n\nDULL\n\nSample Output 2\n\nNo\n\nThe 3-rd character is not R, U, nor D, so S is not easily playable.\n\nSample Input 3\n\nUUUUUUUUUUUUUUU\n\nSample Output 3\n\nYes\n\nSample Input 4\n\nULURU\n\nSample Output 4\n\nNo\n\nSample Input 5\n\nRDULULDURURLRDULRLR\n\nSample Output 5\n\nYes", "sample_input": "RUDLUDR\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02910", "source_text": "Score: 200 points\n\nProblem Statement\n\nTakahashi will do a tap dance. The dance is described by a string S where each character is L, R, U, or D. These characters indicate the positions on which Takahashi should step. He will follow these instructions one by one in order, starting with the first character.\n\nS is said to be easily playable if and only if it satisfies both of the following conditions:\n\nEvery character in an odd position (1-st, 3-rd, 5-th, \\ldots) is R, U, or D.\n\nEvery character in an even position (2-nd, 4-th, 6-th, \\ldots) is L, U, or D.\n\nYour task is to print Yes if S is easily playable, and No otherwise.\n\nConstraints\n\nS is a string of length between 1 and 100 (inclusive).\n\nEach character of S is L, R, U, or D.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint Yes if S is easily playable, and No otherwise.\n\nSample Input 1\n\nRUDLUDR\n\nSample Output 1\n\nYes\n\nEvery character in an odd position (1-st, 3-rd, 5-th, 7-th) is R, U, or D.\n\nEvery character in an even position (2-nd, 4-th, 6-th) is L, U, or D.\n\nThus, S is easily playable.\n\nSample Input 2\n\nDULL\n\nSample Output 2\n\nNo\n\nThe 3-rd character is not R, U, nor D, so S is not easily playable.\n\nSample Input 3\n\nUUUUUUUUUUUUUUU\n\nSample Output 3\n\nYes\n\nSample Input 4\n\nULURU\n\nSample Output 4\n\nNo\n\nSample Input 5\n\nRDULULDURURLRDULRLR\n\nSample Output 5\n\nYes", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 3748}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s684592306", "group_id": "codeNet:p02911", "input_text": "let () =\n Scanf.scanf \"%d %d %d\\n\" @@ fun n k q ->\n let arr = Array.init q @@ fun _ -> Scanf.scanf \"%d\\n\" @@ fun d -> d in\n let points = Array.make n k in\n let change n =\n Array.iteri (fun i x -> if i <> n then points.(i) <- points.(i) - 1) points in\n Array.iter (fun a -> change (a-1)) arr;\n Array.iter (fun p -> if p > 0 then print_endline \"Yes\" else print_endline \"No\") points", "language": "OCaml", "metadata": {"date": 1599510391, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p02911.html", "problem_id": "p02911", "resource_group": "low_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/OCaml/s684592306.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s684592306", "user_id": "u307426615"}, "prompt_components": {"gold_output": "No\nNo\nYes\nNo\nNo\nNo\n", "input_to_evaluate": "let () =\n Scanf.scanf \"%d %d %d\\n\" @@ fun n k q ->\n let arr = Array.init q @@ fun _ -> Scanf.scanf \"%d\\n\" @@ fun d -> d in\n let points = Array.make n k in\n let change n =\n Array.iteri (fun i x -> if i <> n then points.(i) <- points.(i) - 1) points in\n Array.iter (fun a -> change (a-1)) arr;\n Array.iter (fun p -> if p > 0 then print_endline \"Yes\" else print_endline \"No\") points", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 2205, "memory_kb": 7236}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s639813179", "group_id": "codeNet:p02915", "input_text": "(* Vicfred\n * https://atcoder.jp/contests/abc140/tasks/abc140_a\n * math\n * *)\nScanf.scanf \"%d\" ( fun n ->\n n * n * n\n) |> Printf.printf \"%d\\n\"\n\n", "language": "OCaml", "metadata": {"date": 1593648594, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p02915.html", "problem_id": "p02915", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02915/input.txt", "sample_output_relpath": "derived/input_output/data/p02915/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02915/OCaml/s639813179.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s639813179", "user_id": "u737840172"}, "prompt_components": {"gold_output": "8\n", "input_to_evaluate": "(* Vicfred\n * https://atcoder.jp/contests/abc140/tasks/abc140_a\n * math\n * *)\nScanf.scanf \"%d\" ( fun n ->\n n * n * n\n) |> Printf.printf \"%d\\n\"\n\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nTakahashi is going to set a 3-character password.\n\nHow many possible passwords are there if each of its characters must be a digit between 1 and N (inclusive)?\n\nConstraints\n\n1 \\leq N \\leq 9\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the number of possible passwords.\n\nSample Input 1\n\n2\n\nSample Output 1\n\n8\n\nThere are eight possible passwords: 111, 112, 121, 122, 211, 212, 221, and 222.\n\nSample Input 2\n\n1\n\nSample Output 2\n\n1\n\nThere is only one possible password if you can only use one kind of character.", "sample_input": "2\n"}, "reference_outputs": ["8\n"], "source_document_id": "p02915", "source_text": "Score : 100 points\n\nProblem Statement\n\nTakahashi is going to set a 3-character password.\n\nHow many possible passwords are there if each of its characters must be a digit between 1 and N (inclusive)?\n\nConstraints\n\n1 \\leq N \\leq 9\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the number of possible passwords.\n\nSample Input 1\n\n2\n\nSample Output 1\n\n8\n\nThere are eight possible passwords: 111, 112, 121, 122, 211, 212, 221, and 222.\n\nSample Input 2\n\n1\n\nSample Output 2\n\n1\n\nThere is only one possible password if you can only use one kind of character.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 8, "memory_kb": 3784}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s670985734", "group_id": "codeNet:p02915", "input_text": "(* べき乗 *)\nlet rec ( ** ) a n =\n if n = 0 then 1\n else if n mod 2 = 1 then a * a ** (n - 1)\n else let t = a ** (n / 2) in t * t\n\nlet () =\n let n = Scanf.sscanf (input_line stdin) \"%d\" (fun a -> a) in\n let ans = n ** 3 in\n print_int ans;\n print_newline ()", "language": "OCaml", "metadata": {"date": 1572720307, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02915.html", "problem_id": "p02915", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02915/input.txt", "sample_output_relpath": "derived/input_output/data/p02915/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02915/OCaml/s670985734.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s670985734", "user_id": "u977566741"}, "prompt_components": {"gold_output": "8\n", "input_to_evaluate": "(* べき乗 *)\nlet rec ( ** ) a n =\n if n = 0 then 1\n else if n mod 2 = 1 then a * a ** (n - 1)\n else let t = a ** (n / 2) in t * t\n\nlet () =\n let n = Scanf.sscanf (input_line stdin) \"%d\" (fun a -> a) in\n let ans = n ** 3 in\n print_int ans;\n print_newline ()", "problem_context": "Score : 100 points\n\nProblem Statement\n\nTakahashi is going to set a 3-character password.\n\nHow many possible passwords are there if each of its characters must be a digit between 1 and N (inclusive)?\n\nConstraints\n\n1 \\leq N \\leq 9\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the number of possible passwords.\n\nSample Input 1\n\n2\n\nSample Output 1\n\n8\n\nThere are eight possible passwords: 111, 112, 121, 122, 211, 212, 221, and 222.\n\nSample Input 2\n\n1\n\nSample Output 2\n\n1\n\nThere is only one possible password if you can only use one kind of character.", "sample_input": "2\n"}, "reference_outputs": ["8\n"], "source_document_id": "p02915", "source_text": "Score : 100 points\n\nProblem Statement\n\nTakahashi is going to set a 3-character password.\n\nHow many possible passwords are there if each of its characters must be a digit between 1 and N (inclusive)?\n\nConstraints\n\n1 \\leq N \\leq 9\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the number of possible passwords.\n\nSample Input 1\n\n2\n\nSample Output 1\n\n8\n\nThere are eight possible passwords: 111, 112, 121, 122, 211, 212, 221, and 222.\n\nSample Input 2\n\n1\n\nSample Output 2\n\n1\n\nThere is only one possible password if you can only use one kind of character.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 266, "cpu_time_ms": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s584392828", "group_id": "codeNet:p02916", "input_text": "let () =\n Scanf.scanf \"%d\\n\" @@ fun n ->\n let arr = Array.init n @@ fun _ -> Scanf.scanf \"%d \" @@ fun a -> a in\n let brr = Array.init n @@ fun _ -> Scanf.scanf \"%d \" @@ fun b -> b in\n let crr = Array.init (n-1) @@ fun _ -> Scanf.scanf \"%d \" @@ fun c -> c in\n let ans = ref 0 in\n let bfr = ref arr.(0) in\n for i = 0 to n - 1 do\n ans := !ans + brr.(arr.(i)-1);\n if i <> 0 && arr.(i) - !bfr = 1 then ans := !ans + crr.(!bfr-1);\n bfr := arr.(i)\n done;\n Printf.printf \"%d\\n\" !ans", "language": "OCaml", "metadata": {"date": 1599519501, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p02916.html", "problem_id": "p02916", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02916/input.txt", "sample_output_relpath": "derived/input_output/data/p02916/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02916/OCaml/s584392828.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s584392828", "user_id": "u307426615"}, "prompt_components": {"gold_output": "14\n", "input_to_evaluate": "let () =\n Scanf.scanf \"%d\\n\" @@ fun n ->\n let arr = Array.init n @@ fun _ -> Scanf.scanf \"%d \" @@ fun a -> a in\n let brr = Array.init n @@ fun _ -> Scanf.scanf \"%d \" @@ fun b -> b in\n let crr = Array.init (n-1) @@ fun _ -> Scanf.scanf \"%d \" @@ fun c -> c in\n let ans = ref 0 in\n let bfr = ref arr.(0) in\n for i = 0 to n - 1 do\n ans := !ans + brr.(arr.(i)-1);\n if i <> 0 && arr.(i) - !bfr = 1 then ans := !ans + crr.(!bfr-1);\n bfr := arr.(i)\n done;\n Printf.printf \"%d\\n\" !ans", "problem_context": "Score : 200 points\n\nProblem Statement\n\nTakahashi went to an all-you-can-eat buffet with N kinds of dishes and ate all of them (Dish 1, Dish 2, \\ldots, Dish N) once.\n\nThe i-th dish (1 \\leq i \\leq N) he ate was Dish A_i.\n\nWhen he eats Dish i (1 \\leq i \\leq N), he gains B_i satisfaction points.\n\nAdditionally, when he eats Dish i+1 just after eating Dish i (1 \\leq i \\leq N - 1), he gains C_i more satisfaction points.\n\nFind the sum of the satisfaction points he gained.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 20\n\n1 \\leq A_i \\leq N\n\nA_1, A_2, ..., A_N are all different.\n\n1 \\leq B_i \\leq 50\n\n1 \\leq C_i \\leq 50\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\nB_1 B_2 ... B_N\nC_1 C_2 ... C_{N-1}\n\nOutput\n\nPrint the sum of the satisfaction points Takahashi gained, as an integer.\n\nSample Input 1\n\n3\n3 1 2\n2 5 4\n3 6\n\nSample Output 1\n\n14\n\nTakahashi gained 14 satisfaction points in total, as follows:\n\nFirst, he ate Dish 3 and gained 4 satisfaction points.\n\nNext, he ate Dish 1 and gained 2 satisfaction points.\n\nLastly, he ate Dish 2 and gained 5 + 3 = 8 satisfaction points.\n\nSample Input 2\n\n4\n2 3 4 1\n13 5 8 24\n45 9 15\n\nSample Output 2\n\n74\n\nSample Input 3\n\n2\n1 2\n50 50\n50\n\nSample Output 3\n\n150", "sample_input": "3\n3 1 2\n2 5 4\n3 6\n"}, "reference_outputs": ["14\n"], "source_document_id": "p02916", "source_text": "Score : 200 points\n\nProblem Statement\n\nTakahashi went to an all-you-can-eat buffet with N kinds of dishes and ate all of them (Dish 1, Dish 2, \\ldots, Dish N) once.\n\nThe i-th dish (1 \\leq i \\leq N) he ate was Dish A_i.\n\nWhen he eats Dish i (1 \\leq i \\leq N), he gains B_i satisfaction points.\n\nAdditionally, when he eats Dish i+1 just after eating Dish i (1 \\leq i \\leq N - 1), he gains C_i more satisfaction points.\n\nFind the sum of the satisfaction points he gained.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 20\n\n1 \\leq A_i \\leq N\n\nA_1, A_2, ..., A_N are all different.\n\n1 \\leq B_i \\leq 50\n\n1 \\leq C_i \\leq 50\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\nB_1 B_2 ... B_N\nC_1 C_2 ... C_{N-1}\n\nOutput\n\nPrint the sum of the satisfaction points Takahashi gained, as an integer.\n\nSample Input 1\n\n3\n3 1 2\n2 5 4\n3 6\n\nSample Output 1\n\n14\n\nTakahashi gained 14 satisfaction points in total, as follows:\n\nFirst, he ate Dish 3 and gained 4 satisfaction points.\n\nNext, he ate Dish 1 and gained 2 satisfaction points.\n\nLastly, he ate Dish 2 and gained 5 + 3 = 8 satisfaction points.\n\nSample Input 2\n\n4\n2 3 4 1\n13 5 8 24\n45 9 15\n\nSample Output 2\n\n74\n\nSample Input 3\n\n2\n1 2\n50 50\n50\n\nSample Output 3\n\n150", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 492, "cpu_time_ms": 12, "memory_kb": 3756}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s748282815", "group_id": "codeNet:p02917", "input_text": "let () =\n Scanf.scanf \"%d\\n\" @@ fun n ->\n let blst = Array.to_list\n (Array.init (n-1) @@ fun _ -> Scanf.scanf \"%d \" @@ fun d -> d) in\n let (_,ans) = List.fold_left\n (fun (bfr,ans) x -> (x,ans + (min bfr x)))\n (List.hd blst, 0) blst in\n Printf.printf \"%d\\n\" (ans + (List.hd (List.rev blst)))", "language": "OCaml", "metadata": {"date": 1599580405, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p02917.html", "problem_id": "p02917", "resource_group": "low_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/OCaml/s748282815.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s748282815", "user_id": "u307426615"}, "prompt_components": {"gold_output": "9\n", "input_to_evaluate": "let () =\n Scanf.scanf \"%d\\n\" @@ fun n ->\n let blst = Array.to_list\n (Array.init (n-1) @@ fun _ -> Scanf.scanf \"%d \" @@ fun d -> d) in\n let (_,ans) = List.fold_left\n (fun (bfr,ans) x -> (x,ans + (min bfr x)))\n (List.hd blst, 0) blst in\n Printf.printf \"%d\\n\" (ans + (List.hd (List.rev blst)))", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 3, "memory_kb": 3820}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s300678054", "group_id": "codeNet:p02918", "input_text": "let () =\n let main () =\n let n, k = Scanf.sscanf (read_line ()) \"%d %d\" (fun n k -> n, k) in\n let s = read_line () in\n let rec loop i prev acc =\n if i = n then acc else\n if prev = s.[i] then loop (i + 1) s.[i] acc else\n loop (i + 1) s.[i] (acc + 1)\n in\n let a = loop 1 s.[0] 0 in\n let rest_k = k - min (a / 2) k in\n let rest_a = a - 2 * (k - rest_k) in\n let rest_a = if rest_a = 1 && rest_k > 0 then rest_a - 1 else rest_a in\n\n let r = n - (rest_a + 1) in\n Printf.printf \"%d\\n\" r\n in\n main ()", "language": "OCaml", "metadata": {"date": 1567908260, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02918.html", "problem_id": "p02918", "resource_group": "low_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/OCaml/s300678054.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s300678054", "user_id": "u342443598"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "let () =\n let main () =\n let n, k = Scanf.sscanf (read_line ()) \"%d %d\" (fun n k -> n, k) in\n let s = read_line () in\n let rec loop i prev acc =\n if i = n then acc else\n if prev = s.[i] then loop (i + 1) s.[i] acc else\n loop (i + 1) s.[i] (acc + 1)\n in\n let a = loop 1 s.[0] 0 in\n let rest_k = k - min (a / 2) k in\n let rest_a = a - 2 * (k - rest_k) in\n let rest_a = if rest_a = 1 && rest_k > 0 then rest_a - 1 else rest_a in\n\n let r = n - (rest_a + 1) in\n Printf.printf \"%d\\n\" r\n in\n main ()", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 620, "cpu_time_ms": 2, "memory_kb": 640}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s632162416", "group_id": "codeNet:p02919", "input_text": "module M = Map.Make (struct type t = int let compare (a:int) (b:int) = compare a b end)\n\nlet () =\n let split s =\n let rec loop i cur flag acc =\n if i = String.length s then ( if flag then cur :: acc else acc) else ( match flag, s.[i] with\n | true, ' ' -> loop (i + 1) \"\" false (cur :: acc)\n | false, ' ' -> loop (i + 1) \"\" false acc\n | true, v -> loop (i + 1) (Printf.sprintf \"%s%c\" cur v) true acc\n | false, v -> loop (i + 1) (Printf.sprintf \"%s%c\" cur v) true acc\n )\n in\n List.map int_of_string (List.rev (loop 0 \"\" false []))\n in\n let m = 1 lsl 20 in\n let main () =\n let n = int_of_string (read_line ()) in\n let p = Array.of_list (split (read_line ())) in\n let rec loop i map acc =\n if i = n then acc else\n let next = M.fold (fun org v next ->\n let first = org / m in\n let second = org mod m in\n let key = if p.(i) > first then p.(i) * m + first else\n if p.(i) > second then first * m + p.(i) else org\n in\n M.add key (v + try M.find key next with _ -> 0) next) map M.empty\n in\n let acc = acc + M.fold (fun org v acc -> (org mod m) * v + acc) next 0 in\n loop (i + 1) (M.add (p.(i) * m) 1 next) acc\n in\n let r = loop 1 (M.singleton (p.(0) * m) 1) 0 in\n Printf.printf \"%d\\n\" r\n in\n main ()", "language": "OCaml", "metadata": {"date": 1567888392, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02919.html", "problem_id": "p02919", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02919/input.txt", "sample_output_relpath": "derived/input_output/data/p02919/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02919/OCaml/s632162416.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s632162416", "user_id": "u342443598"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "module M = Map.Make (struct type t = int let compare (a:int) (b:int) = compare a b end)\n\nlet () =\n let split s =\n let rec loop i cur flag acc =\n if i = String.length s then ( if flag then cur :: acc else acc) else ( match flag, s.[i] with\n | true, ' ' -> loop (i + 1) \"\" false (cur :: acc)\n | false, ' ' -> loop (i + 1) \"\" false acc\n | true, v -> loop (i + 1) (Printf.sprintf \"%s%c\" cur v) true acc\n | false, v -> loop (i + 1) (Printf.sprintf \"%s%c\" cur v) true acc\n )\n in\n List.map int_of_string (List.rev (loop 0 \"\" false []))\n in\n let m = 1 lsl 20 in\n let main () =\n let n = int_of_string (read_line ()) in\n let p = Array.of_list (split (read_line ())) in\n let rec loop i map acc =\n if i = n then acc else\n let next = M.fold (fun org v next ->\n let first = org / m in\n let second = org mod m in\n let key = if p.(i) > first then p.(i) * m + first else\n if p.(i) > second then first * m + p.(i) else org\n in\n M.add key (v + try M.find key next with _ -> 0) next) map M.empty\n in\n let acc = acc + M.fold (fun org v acc -> (org mod m) * v + acc) next 0 in\n loop (i + 1) (M.add (p.(i) * m) 1 next) acc\n in\n let r = loop 1 (M.singleton (p.(0) * m) 1) 0 in\n Printf.printf \"%d\\n\" r\n in\n main ()", "problem_context": "Score: 500 points\n\nProblem Statement\n\nGiven is a permutation P of \\{1, 2, \\ldots, N\\}.\n\nFor a pair (L, R) (1 \\le L \\lt R \\le N), let X_{L, R} be the second largest value among P_L, P_{L+1}, \\ldots, P_R.\n\nFind \\displaystyle \\sum_{L=1}^{N-1} \\sum_{R=L+1}^{N} X_{L,R}.\n\nConstraints\n\n2 \\le N \\le 10^5\n\n1 \\le P_i \\le N\n\nP_i \\neq P_j (i \\neq j)\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nP_1 P_2 \\ldots P_N\n\nOutput\n\nPrint \\displaystyle \\sum_{L=1}^{N-1} \\sum_{R=L+1}^{N} X_{L,R}.\n\nSample Input 1\n\n3\n2 3 1\n\nSample Output 1\n\n5\n\nX_{1, 2} = 2, X_{1, 3} = 2, and X_{2, 3} = 1, so the sum is 2 + 2 + 1 = 5.\n\nSample Input 2\n\n5\n1 2 3 4 5\n\nSample Output 2\n\n30\n\nSample Input 3\n\n8\n8 2 7 3 4 5 6 1\n\nSample Output 3\n\n136", "sample_input": "3\n2 3 1\n"}, "reference_outputs": ["5\n"], "source_document_id": "p02919", "source_text": "Score: 500 points\n\nProblem Statement\n\nGiven is a permutation P of \\{1, 2, \\ldots, N\\}.\n\nFor a pair (L, R) (1 \\le L \\lt R \\le N), let X_{L, R} be the second largest value among P_L, P_{L+1}, \\ldots, P_R.\n\nFind \\displaystyle \\sum_{L=1}^{N-1} \\sum_{R=L+1}^{N} X_{L,R}.\n\nConstraints\n\n2 \\le N \\le 10^5\n\n1 \\le P_i \\le N\n\nP_i \\neq P_j (i \\neq j)\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nP_1 P_2 \\ldots P_N\n\nOutput\n\nPrint \\displaystyle \\sum_{L=1}^{N-1} \\sum_{R=L+1}^{N} X_{L,R}.\n\nSample Input 1\n\n3\n2 3 1\n\nSample Output 1\n\n5\n\nX_{1, 2} = 2, X_{1, 3} = 2, and X_{2, 3} = 1, so the sum is 2 + 2 + 1 = 5.\n\nSample Input 2\n\n5\n1 2 3 4 5\n\nSample Output 2\n\n30\n\nSample Input 3\n\n8\n8 2 7 3 4 5 6 1\n\nSample Output 3\n\n136", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1547, "cpu_time_ms": 2104, "memory_kb": 15104}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s186537995", "group_id": "codeNet:p02921", "input_text": "(* unihernandez22\n * https://atcoder.jp/contests/abc139/tasks/abc139_a\n * implementation\n * *)\n\nlet rec count_eq s t i c =\n if i == String.length s then c\n else if s.[i] == t.[i] then count_eq s t (i+1) (c+1)\n else count_eq s t (i+1) c;;\n\nPrintf.printf \"%d\\n\" @@\nScanf.scanf \"%s\\n%s\\n\" @@ fun s t ->\n count_eq s t 0 0;;\n \n\n", "language": "OCaml", "metadata": {"date": 1593762944, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p02921.html", "problem_id": "p02921", "resource_group": "low_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/OCaml/s186537995.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s186537995", "user_id": "u878654696"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "(* unihernandez22\n * https://atcoder.jp/contests/abc139/tasks/abc139_a\n * implementation\n * *)\n\nlet rec count_eq s t i c =\n if i == String.length s then c\n else if s.[i] == t.[i] then count_eq s t (i+1) (c+1)\n else count_eq s t (i+1) c;;\n\nPrintf.printf \"%d\\n\" @@\nScanf.scanf \"%s\\n%s\\n\" @@ fun s t ->\n count_eq s t 0 0;;\n \n\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou will be given a string S of length 3 representing the weather forecast for three days in the past.\n\nThe i-th character (1 \\leq i \\leq 3) of S represents the forecast for the i-th day. S, C, and R stand for sunny, cloudy, and rainy, respectively.\n\nYou will also be given a string T of length 3 representing the actual weather on those three days.\n\nThe i-th character (1 \\leq i \\leq 3) of S represents the actual weather on the i-th day. S, C, and R stand for sunny, cloudy, and rainy, respectively.\n\nPrint the number of days for which the forecast was correct.\n\nConstraints\n\nS and T are strings of length 3 each.\n\nS and T consist of S, C, and R.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\nT\n\nOutput\n\nPrint the number of days for which the forecast was correct.\n\nSample Input 1\n\nCSS\nCSR\n\nSample Output 1\n\n2\n\nFor the first day, it was forecast to be cloudy, and it was indeed cloudy.\n\nFor the second day, it was forecast to be sunny, and it was indeed sunny.\n\nFor the third day, it was forecast to be sunny, but it was rainy.\n\nThus, the forecast was correct for two days in this case.\n\nSample Input 2\n\nSSR\nSSR\n\nSample Output 2\n\n3\n\nSample Input 3\n\nRRR\nSSS\n\nSample Output 3\n\n0", "sample_input": "CSS\nCSR\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02921", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou will be given a string S of length 3 representing the weather forecast for three days in the past.\n\nThe i-th character (1 \\leq i \\leq 3) of S represents the forecast for the i-th day. S, C, and R stand for sunny, cloudy, and rainy, respectively.\n\nYou will also be given a string T of length 3 representing the actual weather on those three days.\n\nThe i-th character (1 \\leq i \\leq 3) of S represents the actual weather on the i-th day. S, C, and R stand for sunny, cloudy, and rainy, respectively.\n\nPrint the number of days for which the forecast was correct.\n\nConstraints\n\nS and T are strings of length 3 each.\n\nS and T consist of S, C, and R.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\nT\n\nOutput\n\nPrint the number of days for which the forecast was correct.\n\nSample Input 1\n\nCSS\nCSR\n\nSample Output 1\n\n2\n\nFor the first day, it was forecast to be cloudy, and it was indeed cloudy.\n\nFor the second day, it was forecast to be sunny, and it was indeed sunny.\n\nFor the third day, it was forecast to be sunny, but it was rainy.\n\nThus, the forecast was correct for two days in this case.\n\nSample Input 2\n\nSSR\nSSR\n\nSample Output 2\n\n3\n\nSample Input 3\n\nRRR\nSSS\n\nSample Output 3\n\n0", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 8, "memory_kb": 3788}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s503745910", "group_id": "codeNet:p02921", "input_text": "open Batteries\nlet s = String.explode (read_line ())\nlet t = String.explode (read_line ())\nlet ans = List.fold_left2 (fun a b c -> if b = c then a + 1 else a) 0 s t\nlet () = print_int ans", "language": "OCaml", "metadata": {"date": 1588248528, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02921.html", "problem_id": "p02921", "resource_group": "low_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/OCaml/s503745910.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s503745910", "user_id": "u307426615"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "open Batteries\nlet s = String.explode (read_line ())\nlet t = String.explode (read_line ())\nlet ans = List.fold_left2 (fun a b c -> if b = c then a + 1 else a) 0 s t\nlet () = print_int ans", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 3, "memory_kb": 1152}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s170843596", "group_id": "codeNet:p02921", "input_text": "let () = Scanf.scanf \"%s\\n%s\" @@ fun s t ->\n Printf.printf \"%d\\n\" @@\n Array.fold_left ( + ) 0 @@\n Array.init 3 @@ fun i -> if s.[i] = t.[i] then 1 else 0\n\n", "language": "OCaml", "metadata": {"date": 1567370503, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02921.html", "problem_id": "p02921", "resource_group": "low_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/OCaml/s170843596.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s170843596", "user_id": "u504158101"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "let () = Scanf.scanf \"%s\\n%s\" @@ fun s t ->\n Printf.printf \"%d\\n\" @@\n Array.fold_left ( + ) 0 @@\n Array.init 3 @@ fun i -> if s.[i] = t.[i] then 1 else 0\n\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou will be given a string S of length 3 representing the weather forecast for three days in the past.\n\nThe i-th character (1 \\leq i \\leq 3) of S represents the forecast for the i-th day. S, C, and R stand for sunny, cloudy, and rainy, respectively.\n\nYou will also be given a string T of length 3 representing the actual weather on those three days.\n\nThe i-th character (1 \\leq i \\leq 3) of S represents the actual weather on the i-th day. S, C, and R stand for sunny, cloudy, and rainy, respectively.\n\nPrint the number of days for which the forecast was correct.\n\nConstraints\n\nS and T are strings of length 3 each.\n\nS and T consist of S, C, and R.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\nT\n\nOutput\n\nPrint the number of days for which the forecast was correct.\n\nSample Input 1\n\nCSS\nCSR\n\nSample Output 1\n\n2\n\nFor the first day, it was forecast to be cloudy, and it was indeed cloudy.\n\nFor the second day, it was forecast to be sunny, and it was indeed sunny.\n\nFor the third day, it was forecast to be sunny, but it was rainy.\n\nThus, the forecast was correct for two days in this case.\n\nSample Input 2\n\nSSR\nSSR\n\nSample Output 2\n\n3\n\nSample Input 3\n\nRRR\nSSS\n\nSample Output 3\n\n0", "sample_input": "CSS\nCSR\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02921", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou will be given a string S of length 3 representing the weather forecast for three days in the past.\n\nThe i-th character (1 \\leq i \\leq 3) of S represents the forecast for the i-th day. S, C, and R stand for sunny, cloudy, and rainy, respectively.\n\nYou will also be given a string T of length 3 representing the actual weather on those three days.\n\nThe i-th character (1 \\leq i \\leq 3) of S represents the actual weather on the i-th day. S, C, and R stand for sunny, cloudy, and rainy, respectively.\n\nPrint the number of days for which the forecast was correct.\n\nConstraints\n\nS and T are strings of length 3 each.\n\nS and T consist of S, C, and R.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\nT\n\nOutput\n\nPrint the number of days for which the forecast was correct.\n\nSample Input 1\n\nCSS\nCSR\n\nSample Output 1\n\n2\n\nFor the first day, it was forecast to be cloudy, and it was indeed cloudy.\n\nFor the second day, it was forecast to be sunny, and it was indeed sunny.\n\nFor the third day, it was forecast to be sunny, but it was rainy.\n\nThus, the forecast was correct for two days in this case.\n\nSample Input 2\n\nSSR\nSSR\n\nSample Output 2\n\n3\n\nSample Input 3\n\nRRR\nSSS\n\nSample Output 3\n\n0", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s116774744", "group_id": "codeNet:p02922", "input_text": "let a, b = Scanf.scanf \" %d %d\" @@ fun a b -> a, b\nlet _ = Printf.printf \"%d\\n\" @@ (b + a - 3) / (a - 1)", "language": "OCaml", "metadata": {"date": 1567473036, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02922.html", "problem_id": "p02922", "resource_group": "low_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/OCaml/s116774744.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s116774744", "user_id": "u732304692"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "let a, b = Scanf.scanf \" %d %d\" @@ fun a b -> a, b\nlet _ = Printf.printf \"%d\\n\" @@ (b + a - 3) / (a - 1)", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s950804610", "group_id": "codeNet:p02922", "input_text": "let () =\n let main () =\n let a, b = Scanf.sscanf (read_line ()) \"%d %d\" (fun a b -> a, b) in\n Printf.printf \"%d\\n\" (((b - 1) + a - 2) / (a - 1))\n in\n main ()", "language": "OCaml", "metadata": {"date": 1567364716, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02922.html", "problem_id": "p02922", "resource_group": "low_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/OCaml/s950804610.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s950804610", "user_id": "u342443598"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "let () =\n let main () =\n let a, b = Scanf.sscanf (read_line ()) \"%d %d\" (fun a b -> a, b) in\n Printf.printf \"%d\\n\" (((b - 1) + a - 2) / (a - 1))\n in\n main ()", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s452712550", "group_id": "codeNet:p02923", "input_text": "let scan_int () = Scanf.scanf \" %d\" (fun x -> x)\nlet scan_array len read_func = Array.init len (fun _ -> read_func())\nlet print_int n = Printf.printf \"%d\\n\" n\n\nlet () =\n let n = scan_int() in\n let h = scan_array n scan_int in\n let ans =\n let rec loop i curr ret =\n if i = n then ret\n else\n if h.(i-1) >= h.(i) then loop (i+1) (curr+1) (max ret (curr+1))\n else loop (i+1) 0 ret in\n loop 1 0 0 in\n print_int ans", "language": "OCaml", "metadata": {"date": 1567462516, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02923.html", "problem_id": "p02923", "resource_group": "low_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/OCaml/s452712550.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s452712550", "user_id": "u521364030"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "let scan_int () = Scanf.scanf \" %d\" (fun x -> x)\nlet scan_array len read_func = Array.init len (fun _ -> read_func())\nlet print_int n = Printf.printf \"%d\\n\" n\n\nlet () =\n let n = scan_int() in\n let h = scan_array n scan_int in\n let ans =\n let rec loop i curr ret =\n if i = n then ret\n else\n if h.(i-1) >= h.(i) then loop (i+1) (curr+1) (max ret (curr+1))\n else loop (i+1) 0 ret in\n loop 1 0 0 in\n print_int 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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 33, "memory_kb": 5376}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s557608478", "group_id": "codeNet:p02925", "input_text": "open Printf\nopen Scanf\n\nlet read_intlist: unit -> int list = fun () ->\n let sl = Str.split (Str.regexp \" \") @@ read_line () in\n List.map (fun s -> sscanf s \"%d\" (fun x -> x)) sl\n\nlet n = sscanf (read_line ()) \"%d\" (fun x -> x)\nlet a: int array array = Array.make (n+1) [|0|]\nlet () = for y = 1 to n do\n a.(y) <- 0 :: (read_intlist ()) @ [0] |> Array.of_list\n done\n\n(* *)\nlet ans = ref 0\nlet inds = Array.make (n+1) 1\n\nlet () =\n let bflag = ref true in\n while !bflag do\n let dp = Array.make (n+1) false in\n let flag = ref true in\n\n for i = 1 to n do\n let x = inds.(i) in\n if not dp.(i) && x < n then begin\n let target = a.(i).(x) in\n let targeti = inds.(target) in\n if not dp.(target) && targeti < n && a.(target).(targeti) = i then begin\n dp.(i) <- true;\n dp.(target) <- true;\n\n inds.(i) <- inds.(i) + 1;\n inds.(target) <- inds.(target) + 1;\n\n if !flag then\n flag := false\n end\n end;\n done;\n\n if !flag then\n let hoge = List.tl (Array.to_list inds)\n |> List.for_all (fun e -> e = n) in\n if hoge then\n bflag := false\n else begin\n ans := -1;\n bflag := false\n end\n else\n incr ans\n done\n\nlet () = print_endline @@ string_of_int !ans\n \n \n", "language": "OCaml", "metadata": {"date": 1567370081, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02925.html", "problem_id": "p02925", "resource_group": "low_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/OCaml/s557608478.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s557608478", "user_id": "u098968285"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "open Printf\nopen Scanf\n\nlet read_intlist: unit -> int list = fun () ->\n let sl = Str.split (Str.regexp \" \") @@ read_line () in\n List.map (fun s -> sscanf s \"%d\" (fun x -> x)) sl\n\nlet n = sscanf (read_line ()) \"%d\" (fun x -> x)\nlet a: int array array = Array.make (n+1) [|0|]\nlet () = for y = 1 to n do\n a.(y) <- 0 :: (read_intlist ()) @ [0] |> Array.of_list\n done\n\n(* *)\nlet ans = ref 0\nlet inds = Array.make (n+1) 1\n\nlet () =\n let bflag = ref true in\n while !bflag do\n let dp = Array.make (n+1) false in\n let flag = ref true in\n\n for i = 1 to n do\n let x = inds.(i) in\n if not dp.(i) && x < n then begin\n let target = a.(i).(x) in\n let targeti = inds.(target) in\n if not dp.(target) && targeti < n && a.(target).(targeti) = i then begin\n dp.(i) <- true;\n dp.(target) <- true;\n\n inds.(i) <- inds.(i) + 1;\n inds.(target) <- inds.(target) + 1;\n\n if !flag then\n flag := false\n end\n end;\n done;\n\n if !flag then\n let hoge = List.tl (Array.to_list inds)\n |> List.for_all (fun e -> e = n) in\n if hoge then\n bflag := false\n else begin\n ans := -1;\n bflag := false\n end\n else\n incr ans\n done\n\nlet () = print_endline @@ string_of_int !ans\n \n \n", "problem_context": "Score : 500 points\n\nProblem Statement\n\nN players will participate in a tennis tournament. We will call them Player 1, Player 2, \\ldots, Player N.\n\nThe tournament is round-robin format, and there will be N(N-1)/2 matches in total.\nIs it possible to schedule these matches so that all of the following conditions are satisfied? If the answer is yes, also find the minimum number of days required.\n\nEach player plays at most one matches in a day.\n\nEach player i (1 \\leq i \\leq N) plays one match against Player A_{i, 1}, A_{i, 2}, \\ldots, A_{i, N-1} in this order.\n\nConstraints\n\n3 \\leq N \\leq 1000\n\n1 \\leq A_{i, j} \\leq N\n\nA_{i, j} \\neq i\n\nA_{i, 1}, A_{i, 2}, \\ldots, A_{i, N-1} are all different.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_{1, 1} A_{1, 2} \\ldots A_{1, N-1}\nA_{2, 1} A_{2, 2} \\ldots A_{2, N-1}\n:\nA_{N, 1} A_{N, 2} \\ldots A_{N, N-1}\n\nOutput\n\nIf it is possible to schedule all the matches so that all of the conditions are satisfied, print the minimum number of days required; if it is impossible, print -1.\n\nSample Input 1\n\n3\n2 3\n1 3\n1 2\n\nSample Output 1\n\n3\n\nAll the conditions can be satisfied if the matches are scheduled for three days as follows:\n\nDay 1: Player 1 vs Player 2\n\nDay 2: Player 1 vs Player 3\n\nDay 3: Player 2 vs Player 3\n\nThis is the minimum number of days required.\n\nSample Input 2\n\n4\n2 3 4\n1 3 4\n4 1 2\n3 1 2\n\nSample Output 2\n\n4\n\nAll the conditions can be satisfied if the matches are scheduled for four days as follows:\n\nDay 1: Player 1 vs Player 2, Player 3 vs Player 4\n\nDay 2: Player 1 vs Player 3\n\nDay 3: Player 1 vs Player 4, Player 2 vs Player 3\n\nDay 4: Player 2 vs Player 4\n\nThis is the minimum number of days required.\n\nSample Input 3\n\n3\n2 3\n3 1\n1 2\n\nSample Output 3\n\n-1\n\nAny scheduling of the matches violates some condition.", "sample_input": "3\n2 3\n1 3\n1 2\n"}, "reference_outputs": ["3\n"], "source_document_id": "p02925", "source_text": "Score : 500 points\n\nProblem Statement\n\nN players will participate in a tennis tournament. We will call them Player 1, Player 2, \\ldots, Player N.\n\nThe tournament is round-robin format, and there will be N(N-1)/2 matches in total.\nIs it possible to schedule these matches so that all of the following conditions are satisfied? If the answer is yes, also find the minimum number of days required.\n\nEach player plays at most one matches in a day.\n\nEach player i (1 \\leq i \\leq N) plays one match against Player A_{i, 1}, A_{i, 2}, \\ldots, A_{i, N-1} in this order.\n\nConstraints\n\n3 \\leq N \\leq 1000\n\n1 \\leq A_{i, j} \\leq N\n\nA_{i, j} \\neq i\n\nA_{i, 1}, A_{i, 2}, \\ldots, A_{i, N-1} are all different.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_{1, 1} A_{1, 2} \\ldots A_{1, N-1}\nA_{2, 1} A_{2, 2} \\ldots A_{2, N-1}\n:\nA_{N, 1} A_{N, 2} \\ldots A_{N, N-1}\n\nOutput\n\nIf it is possible to schedule all the matches so that all of the conditions are satisfied, print the minimum number of days required; if it is impossible, print -1.\n\nSample Input 1\n\n3\n2 3\n1 3\n1 2\n\nSample Output 1\n\n3\n\nAll the conditions can be satisfied if the matches are scheduled for three days as follows:\n\nDay 1: Player 1 vs Player 2\n\nDay 2: Player 1 vs Player 3\n\nDay 3: Player 2 vs Player 3\n\nThis is the minimum number of days required.\n\nSample Input 2\n\n4\n2 3 4\n1 3 4\n4 1 2\n3 1 2\n\nSample Output 2\n\n4\n\nAll the conditions can be satisfied if the matches are scheduled for four days as follows:\n\nDay 1: Player 1 vs Player 2, Player 3 vs Player 4\n\nDay 2: Player 1 vs Player 3\n\nDay 3: Player 1 vs Player 4, Player 2 vs Player 3\n\nDay 4: Player 2 vs Player 4\n\nThis is the minimum number of days required.\n\nSample Input 3\n\n3\n2 3\n3 1\n1 2\n\nSample Output 3\n\n-1\n\nAny scheduling of the matches violates some condition.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1398, "cpu_time_ms": 2105, "memory_kb": 23588}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s659645945", "group_id": "codeNet:p02926", "input_text": "Scanf.scanf \"%d\" (fun n ->\n let xy = Array.init n (fun _ -> Scanf.scanf \" %d %d\" (fun x y -> x, y)) in\n Array.sort (fun (x0, y0) (x1, y1) ->\n compare (atan2 (float y0) (float x0)) (atan2 (float y1) (float x1))) xy;\n let rec loop i s cx cy acc =\n if i = n then (\n if s = n then float acc |> sqrt else\n let (x, y) = xy.(s) in\n let bx = cx - x in\n let by = cy - y in\n let b = bx * bx + by * by in\n loop i (s + 1) bx by (max b acc)\n ) else\n let c = cx * cx + cy * cy in\n let (x, y) = xy.(i) in\n let bx = cx + x in\n let by = cy + y in\n let b = bx * bx + by * by in\n if b >= c then loop (i + 1) s bx by (max b acc) else\n let (x, y) = xy.(s) in\n let bx = cx - x in\n let by = cy - y in\n let b = bx * bx + by * by in\n loop i (s + 1) bx by (max b acc)\n in\n loop 0 0 0 0 0 |> Printf.printf \"%.10f\\n\"\n)", "language": "OCaml", "metadata": {"date": 1598901055, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p02926.html", "problem_id": "p02926", "resource_group": "low_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/OCaml/s659645945.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s659645945", "user_id": "u342443598"}, "prompt_components": {"gold_output": "10.000000000000000000000000000000000000000000000000\n", "input_to_evaluate": "Scanf.scanf \"%d\" (fun n ->\n let xy = Array.init n (fun _ -> Scanf.scanf \" %d %d\" (fun x y -> x, y)) in\n Array.sort (fun (x0, y0) (x1, y1) ->\n compare (atan2 (float y0) (float x0)) (atan2 (float y1) (float x1))) xy;\n let rec loop i s cx cy acc =\n if i = n then (\n if s = n then float acc |> sqrt else\n let (x, y) = xy.(s) in\n let bx = cx - x in\n let by = cy - y in\n let b = bx * bx + by * by in\n loop i (s + 1) bx by (max b acc)\n ) else\n let c = cx * cx + cy * cy in\n let (x, y) = xy.(i) in\n let bx = cx + x in\n let by = cy + y in\n let b = bx * bx + by * by in\n if b >= c then loop (i + 1) s bx by (max b acc) else\n let (x, y) = xy.(s) in\n let bx = cx - x in\n let by = cy - y in\n let b = bx * bx + by * by in\n loop i (s + 1) bx by (max b acc)\n in\n loop 0 0 0 0 0 |> Printf.printf \"%.10f\\n\"\n)", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1053, "cpu_time_ms": 8, "memory_kb": 4340}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s840607234", "group_id": "codeNet:p02927", "input_text": "let () = Scanf.scanf \"%d %d\" @@ fun m d ->\n Printf.printf \"%d\\n\" @@\n Array.fold_left (Array.fold_left ( + )) 0 @@\n Array.init m @@ fun i ->\n Array.init d @@ fun j ->\n if\n 2 <= (j + 1) mod 10 &&\n 2 <= (j + 1) / 10 &&\n ((j + 1) mod 10) * ((j + 1) / 10) = i + 1\n then 1\n else 0", "language": "OCaml", "metadata": {"date": 1567306251, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02927.html", "problem_id": "p02927", "resource_group": "low_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/OCaml/s840607234.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s840607234", "user_id": "u504158101"}, "prompt_components": {"gold_output": "10\n", "input_to_evaluate": "let () = Scanf.scanf \"%d %d\" @@ fun m d ->\n Printf.printf \"%d\\n\" @@\n Array.fold_left (Array.fold_left ( + )) 0 @@\n Array.init m @@ fun i ->\n Array.init d @@ fun j ->\n if\n 2 <= (j + 1) mod 10 &&\n 2 <= (j + 1) / 10 &&\n ((j + 1) mod 10) * ((j + 1) / 10) = i + 1\n then 1\n else 0", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 316, "cpu_time_ms": 1, "memory_kb": 2432}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s206426358", "group_id": "codeNet:p02929", "input_text": "let scan_int () = Scanf.scanf \" %d\" (fun x -> x)\nlet scan_string () = Scanf.scanf \" %s\" (fun x -> x)\nlet print_int n = Printf.printf \"%d\\n\" n\n\nlet modulo = 1000000007\nlet modmul a b = a * b mod modulo\n\nlet () =\n let n = scan_int() in\n let s = scan_string() in\n let rec loop i curr ret =\n if i = 2 * n && curr = 0 then ret\n else if i = 2 * n || curr < 0 then 0 \n else\n if s.[i] = 'B' then\n if curr mod 2 = 1 then loop (i+1) (curr-1) (modmul ret curr)\n else loop (i+1) (curr+1) ret\n else\n if curr mod 2 = 1 then loop (i+1) (curr+1) ret\n else loop (i+1) (curr-1) (modmul ret curr) in\n let rec calc_factorial i n ret =\n if i > n then ret else calc_factorial (i+1) n (modmul ret i) in\n let a = loop 0 0 1 and b = calc_factorial 1 n 1 in\n print_int (modmul a b)\n\n", "language": "OCaml", "metadata": {"date": 1567233049, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02929.html", "problem_id": "p02929", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02929/input.txt", "sample_output_relpath": "derived/input_output/data/p02929/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02929/OCaml/s206426358.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s206426358", "user_id": "u521364030"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "let scan_int () = Scanf.scanf \" %d\" (fun x -> x)\nlet scan_string () = Scanf.scanf \" %s\" (fun x -> x)\nlet print_int n = Printf.printf \"%d\\n\" n\n\nlet modulo = 1000000007\nlet modmul a b = a * b mod modulo\n\nlet () =\n let n = scan_int() in\n let s = scan_string() in\n let rec loop i curr ret =\n if i = 2 * n && curr = 0 then ret\n else if i = 2 * n || curr < 0 then 0 \n else\n if s.[i] = 'B' then\n if curr mod 2 = 1 then loop (i+1) (curr-1) (modmul ret curr)\n else loop (i+1) (curr+1) ret\n else\n if curr mod 2 = 1 then loop (i+1) (curr+1) ret\n else loop (i+1) (curr-1) (modmul ret curr) in\n let rec calc_factorial i n ret =\n if i > n then ret else calc_factorial (i+1) n (modmul ret i) in\n let a = loop 0 0 1 and b = calc_factorial 1 n 1 in\n print_int (modmul a b)\n\n", "problem_context": "Score : 500 points\n\nProblem Statement\n\nThere are 2N squares arranged from left to right. You are given a string of length 2N representing the color of each of the squares.\n\nThe color of the i-th square from the left is black if the i-th character of S is B, and white if that character is W.\n\nYou will perform the following operation exactly N times: choose two distinct squares, then invert the colors of these squares and the squares between them. Here, to invert the color of a square is to make it white if it is black, and vice versa.\n\nThroughout this process, you cannot choose the same square twice or more. That is, each square has to be chosen exactly once.\n\nFind the number of ways to make all the squares white at the end of the process, modulo 10^9+7.\n\nTwo ways to make the squares white are considered different if and only if there exists i (1 \\leq i \\leq N) such that the pair of the squares chosen in the i-th operation is different.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n|S| = 2N\n\nEach character of S is B or W.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS\n\nOutput\n\nPrint the number of ways to make all the squares white at the end of the process, modulo 10^9+7. If there are no such ways, print 0.\n\nSample Input 1\n\n2\nBWWB\n\nSample Output 1\n\n4\n\nThere are four ways to make all the squares white, as follows:\n\nChoose Squares 1, 3 in the first operation, and choose Squares 2, 4 in the second operation.\n\nChoose Squares 2, 4 in the first operation, and choose Squares 1, 3 in the second operation.\n\nChoose Squares 1, 4 in the first operation, and choose Squares 2, 3 in the second operation.\n\nChoose Squares 2, 3 in the first operation, and choose Squares 1, 4 in the second operation.\n\nSample Input 2\n\n4\nBWBBWWWB\n\nSample Output 2\n\n288\n\nSample Input 3\n\n5\nWWWWWWWWWW\n\nSample Output 3\n\n0", "sample_input": "2\nBWWB\n"}, "reference_outputs": ["4\n"], "source_document_id": "p02929", "source_text": "Score : 500 points\n\nProblem Statement\n\nThere are 2N squares arranged from left to right. You are given a string of length 2N representing the color of each of the squares.\n\nThe color of the i-th square from the left is black if the i-th character of S is B, and white if that character is W.\n\nYou will perform the following operation exactly N times: choose two distinct squares, then invert the colors of these squares and the squares between them. Here, to invert the color of a square is to make it white if it is black, and vice versa.\n\nThroughout this process, you cannot choose the same square twice or more. That is, each square has to be chosen exactly once.\n\nFind the number of ways to make all the squares white at the end of the process, modulo 10^9+7.\n\nTwo ways to make the squares white are considered different if and only if there exists i (1 \\leq i \\leq N) such that the pair of the squares chosen in the i-th operation is different.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n|S| = 2N\n\nEach character of S is B or W.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS\n\nOutput\n\nPrint the number of ways to make all the squares white at the end of the process, modulo 10^9+7. If there are no such ways, print 0.\n\nSample Input 1\n\n2\nBWWB\n\nSample Output 1\n\n4\n\nThere are four ways to make all the squares white, as follows:\n\nChoose Squares 1, 3 in the first operation, and choose Squares 2, 4 in the second operation.\n\nChoose Squares 2, 4 in the first operation, and choose Squares 1, 3 in the second operation.\n\nChoose Squares 1, 4 in the first operation, and choose Squares 2, 3 in the second operation.\n\nChoose Squares 2, 3 in the first operation, and choose Squares 1, 4 in the second operation.\n\nSample Input 2\n\n4\nBWBBWWWB\n\nSample Output 2\n\n288\n\nSample Input 3\n\n5\nWWWWWWWWWW\n\nSample Output 3\n\n0", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 6, "memory_kb": 3200}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s027522388", "group_id": "codeNet:p02934", "input_text": "(* Vicfred\n * https://atcoder.jp/contests/abc138/tasks/abc138_b\n * implementation\n * *)\nlet n = Scanf.scanf \"%d\\n\" ( + ) 0\nlet a = Array.init n @@ fun _ -> Scanf.scanf \" %f\" ( +. ) 0.0\nlet main = Printf.printf \"%.9f\\n\" @@\n((/.) 1.0) @@\nArray.fold_left (fun x y -> x +. (1.0 /. y)) 0.0 a\n\n", "language": "OCaml", "metadata": {"date": 1593793635, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p02934.html", "problem_id": "p02934", "resource_group": "low_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/OCaml/s027522388.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s027522388", "user_id": "u737840172"}, "prompt_components": {"gold_output": "7.5\n", "input_to_evaluate": "(* Vicfred\n * https://atcoder.jp/contests/abc138/tasks/abc138_b\n * implementation\n * *)\nlet n = Scanf.scanf \"%d\\n\" ( + ) 0\nlet a = Array.init n @@ fun _ -> Scanf.scanf \" %f\" ( +. ) 0.0\nlet main = Printf.printf \"%.9f\\n\" @@\n((/.) 1.0) @@\nArray.fold_left (fun x y -> x +. (1.0 /. y)) 0.0 a\n\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nGiven is a sequence of N integers A_1, \\ldots, A_N.\n\nFind the (multiplicative) inverse of the sum of the inverses of these numbers, \\frac{1}{\\frac{1}{A_1} + \\ldots + \\frac{1}{A_N}}.\n\nConstraints\n\n1 \\leq N \\leq 100\n\n1 \\leq A_i \\leq 1000\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 \\ldots A_N\n\nOutput\n\nPrint a decimal number (or an integer) representing the value of \\frac{1}{\\frac{1}{A_1} + \\ldots + \\frac{1}{A_N}}.\n\nYour output will be judged correct when its absolute or relative error from the judge's output is at most 10^{-5}.\n\nSample Input 1\n\n2\n10 30\n\nSample Output 1\n\n7.5\n\n\\frac{1}{\\frac{1}{10} + \\frac{1}{30}} = \\frac{1}{\\frac{4}{30}} = \\frac{30}{4} = 7.5.\n\nPrinting 7.50001, 7.49999, and so on will also be accepted.\n\nSample Input 2\n\n3\n200 200 200\n\nSample Output 2\n\n66.66666666666667\n\n\\frac{1}{\\frac{1}{200} + \\frac{1}{200} + \\frac{1}{200}} = \\frac{1}{\\frac{3}{200}} = \\frac{200}{3} = 66.6666....\n\nPrinting 6.66666e+1 and so on will also be accepted.\n\nSample Input 3\n\n1\n1000\n\nSample Output 3\n\n1000\n\n\\frac{1}{\\frac{1}{1000}} = 1000.\n\nPrinting +1000.0 and so on will also be accepted.", "sample_input": "2\n10 30\n"}, "reference_outputs": ["7.5\n"], "source_document_id": "p02934", "source_text": "Score : 200 points\n\nProblem Statement\n\nGiven is a sequence of N integers A_1, \\ldots, A_N.\n\nFind the (multiplicative) inverse of the sum of the inverses of these numbers, \\frac{1}{\\frac{1}{A_1} + \\ldots + \\frac{1}{A_N}}.\n\nConstraints\n\n1 \\leq N \\leq 100\n\n1 \\leq A_i \\leq 1000\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 \\ldots A_N\n\nOutput\n\nPrint a decimal number (or an integer) representing the value of \\frac{1}{\\frac{1}{A_1} + \\ldots + \\frac{1}{A_N}}.\n\nYour output will be judged correct when its absolute or relative error from the judge's output is at most 10^{-5}.\n\nSample Input 1\n\n2\n10 30\n\nSample Output 1\n\n7.5\n\n\\frac{1}{\\frac{1}{10} + \\frac{1}{30}} = \\frac{1}{\\frac{4}{30}} = \\frac{30}{4} = 7.5.\n\nPrinting 7.50001, 7.49999, and so on will also be accepted.\n\nSample Input 2\n\n3\n200 200 200\n\nSample Output 2\n\n66.66666666666667\n\n\\frac{1}{\\frac{1}{200} + \\frac{1}{200} + \\frac{1}{200}} = \\frac{1}{\\frac{3}{200}} = \\frac{200}{3} = 66.6666....\n\nPrinting 6.66666e+1 and so on will also be accepted.\n\nSample Input 3\n\n1\n1000\n\nSample Output 3\n\n1000\n\n\\frac{1}{\\frac{1}{1000}} = 1000.\n\nPrinting +1000.0 and so on will also be accepted.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 8, "memory_kb": 3968}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s338514830", "group_id": "codeNet:p02934", "input_text": "(* abc138 b problem *)\nopen Scanf;;\nopen Array;;\n\nlet () = Scanf.scanf \"%d\"\n (fun n -> Array.init n (fun _ -> Scanf.scanf \" %f\" (fun a -> a)))\n |> Array.fold_left (fun x a -> x +. (1.0 /. a)) 0.0\n |> ((/.) 1.0)\n |> print_float\n |> print_newline;;\n\nexit 0;;", "language": "OCaml", "metadata": {"date": 1566785833, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02934.html", "problem_id": "p02934", "resource_group": "low_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/OCaml/s338514830.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s338514830", "user_id": "u115306811"}, "prompt_components": {"gold_output": "7.5\n", "input_to_evaluate": "(* abc138 b problem *)\nopen Scanf;;\nopen Array;;\n\nlet () = Scanf.scanf \"%d\"\n (fun n -> Array.init n (fun _ -> Scanf.scanf \" %f\" (fun a -> a)))\n |> Array.fold_left (fun x a -> x +. (1.0 /. a)) 0.0\n |> ((/.) 1.0)\n |> print_float\n |> print_newline;;\n\nexit 0;;", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s935625777", "group_id": "codeNet:p02935", "input_text": "(* Vicfred\n * https://atcoder.jp/contests/abc138/tasks/abc138_c\n * sorting, greedy\n * *)\n\nlet main =\n Scanf.scanf \"%d\\n\" (fun n ->\n Array.init n (fun _ -> Scanf.scanf \" %f\" (fun f -> f))\n |> Array.to_list\n |> List.sort compare\n |> (fun arr -> List.fold_left (fun x y -> (x +. y) /. 2.0) (List.hd arr) arr)\n |> Printf.printf \"%.9f\\n\"\n)\n", "language": "OCaml", "metadata": {"date": 1593796746, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p02935.html", "problem_id": "p02935", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02935/input.txt", "sample_output_relpath": "derived/input_output/data/p02935/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02935/OCaml/s935625777.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s935625777", "user_id": "u737840172"}, "prompt_components": {"gold_output": "3.5\n", "input_to_evaluate": "(* Vicfred\n * https://atcoder.jp/contests/abc138/tasks/abc138_c\n * sorting, greedy\n * *)\n\nlet main =\n Scanf.scanf \"%d\\n\" (fun n ->\n Array.init n (fun _ -> Scanf.scanf \" %f\" (fun f -> f))\n |> Array.to_list\n |> List.sort compare\n |> (fun arr -> List.fold_left (fun x y -> (x +. y) /. 2.0) (List.hd arr) arr)\n |> Printf.printf \"%.9f\\n\"\n)\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou have a pot and N ingredients. Each ingredient has a real number parameter called value, and the value of the i-th ingredient (1 \\leq i \\leq N) is v_i.\n\nWhen you put two ingredients in the pot, they will vanish and result in the formation of a new ingredient. The value of the new ingredient will be (x + y) / 2 where x and y are the values of the ingredients consumed, and you can put this ingredient again in the pot.\n\nAfter you compose ingredients in this way N-1 times, you will end up with one ingredient. Find the maximum possible value of this ingredient.\n\nConstraints\n\n2 \\leq N \\leq 50\n\n1 \\leq v_i \\leq 1000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nv_1 v_2 \\ldots v_N\n\nOutput\n\nPrint a decimal number (or an integer) representing the maximum possible value of the last ingredient remaining.\n\nYour output will be judged correct when its absolute or relative error from the judge's output is at most 10^{-5}.\n\nSample Input 1\n\n2\n3 4\n\nSample Output 1\n\n3.5\n\nIf you start with two ingredients, the only choice is to put both of them in the pot. The value of the ingredient resulting from the ingredients of values 3 and 4 is (3 + 4) / 2 = 3.5.\n\nPrinting 3.50001, 3.49999, and so on will also be accepted.\n\nSample Input 2\n\n3\n500 300 200\n\nSample Output 2\n\n375\n\nYou start with three ingredients this time, and you can choose what to use in the first composition. There are three possible choices:\n\nUse the ingredients of values 500 and 300 to produce an ingredient of value (500 + 300) / 2 = 400. The next composition will use this ingredient and the ingredient of value 200, resulting in an ingredient of value (400 + 200) / 2 = 300.\n\nUse the ingredients of values 500 and 200 to produce an ingredient of value (500 + 200) / 2 = 350. The next composition will use this ingredient and the ingredient of value 300, resulting in an ingredient of value (350 + 300) / 2 = 325.\n\nUse the ingredients of values 300 and 200 to produce an ingredient of value (300 + 200) / 2 = 250. The next composition will use this ingredient and the ingredient of value 500, resulting in an ingredient of value (250 + 500) / 2 = 375.\n\nThus, the maximum possible value of the last ingredient remaining is 375.\n\nPrinting 375.0 and so on will also be accepted.\n\nSample Input 3\n\n5\n138 138 138 138 138\n\nSample Output 3\n\n138", "sample_input": "2\n3 4\n"}, "reference_outputs": ["3.5\n"], "source_document_id": "p02935", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou have a pot and N ingredients. Each ingredient has a real number parameter called value, and the value of the i-th ingredient (1 \\leq i \\leq N) is v_i.\n\nWhen you put two ingredients in the pot, they will vanish and result in the formation of a new ingredient. The value of the new ingredient will be (x + y) / 2 where x and y are the values of the ingredients consumed, and you can put this ingredient again in the pot.\n\nAfter you compose ingredients in this way N-1 times, you will end up with one ingredient. Find the maximum possible value of this ingredient.\n\nConstraints\n\n2 \\leq N \\leq 50\n\n1 \\leq v_i \\leq 1000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nv_1 v_2 \\ldots v_N\n\nOutput\n\nPrint a decimal number (or an integer) representing the maximum possible value of the last ingredient remaining.\n\nYour output will be judged correct when its absolute or relative error from the judge's output is at most 10^{-5}.\n\nSample Input 1\n\n2\n3 4\n\nSample Output 1\n\n3.5\n\nIf you start with two ingredients, the only choice is to put both of them in the pot. The value of the ingredient resulting from the ingredients of values 3 and 4 is (3 + 4) / 2 = 3.5.\n\nPrinting 3.50001, 3.49999, and so on will also be accepted.\n\nSample Input 2\n\n3\n500 300 200\n\nSample Output 2\n\n375\n\nYou start with three ingredients this time, and you can choose what to use in the first composition. There are three possible choices:\n\nUse the ingredients of values 500 and 300 to produce an ingredient of value (500 + 300) / 2 = 400. The next composition will use this ingredient and the ingredient of value 200, resulting in an ingredient of value (400 + 200) / 2 = 300.\n\nUse the ingredients of values 500 and 200 to produce an ingredient of value (500 + 200) / 2 = 350. The next composition will use this ingredient and the ingredient of value 300, resulting in an ingredient of value (350 + 300) / 2 = 325.\n\nUse the ingredients of values 300 and 200 to produce an ingredient of value (300 + 200) / 2 = 250. The next composition will use this ingredient and the ingredient of value 500, resulting in an ingredient of value (250 + 500) / 2 = 375.\n\nThus, the maximum possible value of the last ingredient remaining is 375.\n\nPrinting 375.0 and so on will also be accepted.\n\nSample Input 3\n\n5\n138 138 138 138 138\n\nSample Output 3\n\n138", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 6, "memory_kb": 3928}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s151272051", "group_id": "codeNet:p02937", "input_text": "let s = read_line ()\nlet t = read_line ()\n\nlet s_len = String.length s\nlet t_len = String.length t\n\nlet ch_pos =\n let ss = s ^ s in\n let len = s_len * 2 in\n let rec f arr i =\n if i = -1 then arr\n else begin\n arr.(i) <- Array.copy arr.(i + 1);\n arr.(i).(int_of_char ss.[i] - int_of_char 'a') <- i;\n f arr (i - 1)\n end\n in\n f (Array.init (len + 1) (fun _ -> Array.make 26 (-1))) (len - 1)\n\nlet rec loop sum i pos =\n if i = t_len then\n print_int sum\n else \n let next = ch_pos.(pos).(int_of_char t.[i] - int_of_char 'a') in\n if next = -1 then begin\n print_int (-1); exit 0;\n end else loop (sum + next - pos) (i + 1) (next mod s_len)\n\nlet () = loop 1 0 0", "language": "OCaml", "metadata": {"date": 1588906833, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02937.html", "problem_id": "p02937", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02937/input.txt", "sample_output_relpath": "derived/input_output/data/p02937/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02937/OCaml/s151272051.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s151272051", "user_id": "u811309788"}, "prompt_components": {"gold_output": "10\n", "input_to_evaluate": "let s = read_line ()\nlet t = read_line ()\n\nlet s_len = String.length s\nlet t_len = String.length t\n\nlet ch_pos =\n let ss = s ^ s in\n let len = s_len * 2 in\n let rec f arr i =\n if i = -1 then arr\n else begin\n arr.(i) <- Array.copy arr.(i + 1);\n arr.(i).(int_of_char ss.[i] - int_of_char 'a') <- i;\n f arr (i - 1)\n end\n in\n f (Array.init (len + 1) (fun _ -> Array.make 26 (-1))) (len - 1)\n\nlet rec loop sum i pos =\n if i = t_len then\n print_int sum\n else \n let next = ch_pos.(pos).(int_of_char t.[i] - int_of_char 'a') in\n if next = -1 then begin\n print_int (-1); exit 0;\n end else loop (sum + next - pos) (i + 1) (next mod s_len)\n\nlet () = loop 1 0 0", "problem_context": "Score : 500 points\n\nProblem Statement\n\nGiven are two strings s and t consisting of lowercase English letters. Determine if there exists an integer i satisfying the following condition, and find the minimum such i if it exists.\n\nLet s' be the concatenation of 10^{100} copies of s. t is a subsequence of the string {s'}_1{s'}_2\\ldots{s'}_i (the first i characters in s').\n\nNotes\n\nA subsequence of a string a is a string obtained by deleting zero or more characters from a and concatenating the remaining characters without changing the relative order. For example, the subsequences of contest include net, c, and contest.\n\nConstraints\n\n1 \\leq |s| \\leq 10^5\n\n1 \\leq |t| \\leq 10^5\n\ns and t consists of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\ns\nt\n\nOutput\n\nIf there exists an integer i satisfying the following condition, print the minimum such i; otherwise, print -1.\n\nSample Input 1\n\ncontest\nson\n\nSample Output 1\n\n10\n\nt = son is a subsequence of the string contestcon (the first 10 characters in s' = contestcontestcontest...), so i = 10 satisfies the condition.\n\nOn the other hand, t is not a subsequence of the string contestco (the first 9 characters in s'), so i = 9 does not satisfy the condition.\n\nSimilarly, any integer less than 9 does not satisfy the condition, either. Thus, the minimum integer i satisfying the condition is 10.\n\nSample Input 2\n\ncontest\nprogramming\n\nSample Output 2\n\n-1\n\nt = programming is not a substring of s' = contestcontestcontest.... Thus, there is no integer i satisfying the condition.\n\nSample Input 3\n\ncontest\nsentence\n\nSample Output 3\n\n33\n\nNote that the answer may not fit into a 32-bit integer type, though we cannot put such a case here.", "sample_input": "contest\nson\n"}, "reference_outputs": ["10\n"], "source_document_id": "p02937", "source_text": "Score : 500 points\n\nProblem Statement\n\nGiven are two strings s and t consisting of lowercase English letters. Determine if there exists an integer i satisfying the following condition, and find the minimum such i if it exists.\n\nLet s' be the concatenation of 10^{100} copies of s. t is a subsequence of the string {s'}_1{s'}_2\\ldots{s'}_i (the first i characters in s').\n\nNotes\n\nA subsequence of a string a is a string obtained by deleting zero or more characters from a and concatenating the remaining characters without changing the relative order. For example, the subsequences of contest include net, c, and contest.\n\nConstraints\n\n1 \\leq |s| \\leq 10^5\n\n1 \\leq |t| \\leq 10^5\n\ns and t consists of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\ns\nt\n\nOutput\n\nIf there exists an integer i satisfying the following condition, print the minimum such i; otherwise, print -1.\n\nSample Input 1\n\ncontest\nson\n\nSample Output 1\n\n10\n\nt = son is a subsequence of the string contestcon (the first 10 characters in s' = contestcontestcontest...), so i = 10 satisfies the condition.\n\nOn the other hand, t is not a subsequence of the string contestco (the first 9 characters in s'), so i = 9 does not satisfy the condition.\n\nSimilarly, any integer less than 9 does not satisfy the condition, either. Thus, the minimum integer i satisfying the condition is 10.\n\nSample Input 2\n\ncontest\nprogramming\n\nSample Output 2\n\n-1\n\nt = programming is not a substring of s' = contestcontestcontest.... Thus, there is no integer i satisfying the condition.\n\nSample Input 3\n\ncontest\nsentence\n\nSample Output 3\n\n33\n\nNote that the answer may not fit into a 32-bit integer type, though we cannot put such a case here.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 167, "memory_kb": 88384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s235134845", "group_id": "codeNet:p02945", "input_text": "let () = Scanf.scanf \"%d %d\" @@ fun a b ->\n Printf.printf \"%d\\n\" @@ max (a + b) @@ max (a - b) (a * b)\n", "language": "OCaml", "metadata": {"date": 1565487087, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02945.html", "problem_id": "p02945", "resource_group": "low_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/OCaml/s235134845.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s235134845", "user_id": "u504158101"}, "prompt_components": {"gold_output": "-10\n", "input_to_evaluate": "let () = Scanf.scanf \"%d %d\" @@ fun a b ->\n Printf.printf \"%d\\n\" @@ max (a + b) @@ max (a - b) (a * b)\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nWe have two integers: A and B.\n\nPrint the largest number among A + B, A - B, and A \\times B.\n\nConstraints\n\nAll values in input are integers.\n\n-100 \\leq A,\\ B \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the largest number among A + B, A - B, and A \\times B.\n\nSample Input 1\n\n-13 3\n\nSample Output 1\n\n-10\n\nThe largest number among A + B = -10, A - B = -16, and A \\times B = -39 is -10.\n\nSample Input 2\n\n1 -33\n\nSample Output 2\n\n34\n\nThe largest number among A + B = -32, A - B = 34, and A \\times B = -33 is 34.\n\nSample Input 3\n\n13 3\n\nSample Output 3\n\n39\n\nThe largest number among A + B = 16, A - B = 10, and A \\times B = 39 is 39.", "sample_input": "-13 3\n"}, "reference_outputs": ["-10\n"], "source_document_id": "p02945", "source_text": "Score : 100 points\n\nProblem Statement\n\nWe have two integers: A and B.\n\nPrint the largest number among A + B, A - B, and A \\times B.\n\nConstraints\n\nAll values in input are integers.\n\n-100 \\leq A,\\ B \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the largest number among A + B, A - B, and A \\times B.\n\nSample Input 1\n\n-13 3\n\nSample Output 1\n\n-10\n\nThe largest number among A + B = -10, A - B = -16, and A \\times B = -39 is -10.\n\nSample Input 2\n\n1 -33\n\nSample Output 2\n\n34\n\nThe largest number among A + B = -32, A - B = 34, and A \\times B = -33 is 34.\n\nSample Input 3\n\n13 3\n\nSample Output 3\n\n39\n\nThe largest number among A + B = 16, A - B = 10, and A \\times B = 39 is 39.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s286156393", "group_id": "codeNet:p02945", "input_text": "let scan_int () = Scanf.scanf \" %d\" (fun x -> x)\nlet print_int n = Printf.printf \"%d\\n\" n\n\nlet () =\n let a = scan_int() and b = scan_int() in\n print_int (max (a*b) (max (a+b) (a-b)))\n", "language": "OCaml", "metadata": {"date": 1565485362, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02945.html", "problem_id": "p02945", "resource_group": "low_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/OCaml/s286156393.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s286156393", "user_id": "u521364030"}, "prompt_components": {"gold_output": "-10\n", "input_to_evaluate": "let scan_int () = Scanf.scanf \" %d\" (fun x -> x)\nlet print_int n = Printf.printf \"%d\\n\" n\n\nlet () =\n let a = scan_int() and b = scan_int() in\n print_int (max (a*b) (max (a+b) (a-b)))\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nWe have two integers: A and B.\n\nPrint the largest number among A + B, A - B, and A \\times B.\n\nConstraints\n\nAll values in input are integers.\n\n-100 \\leq A,\\ B \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the largest number among A + B, A - B, and A \\times B.\n\nSample Input 1\n\n-13 3\n\nSample Output 1\n\n-10\n\nThe largest number among A + B = -10, A - B = -16, and A \\times B = -39 is -10.\n\nSample Input 2\n\n1 -33\n\nSample Output 2\n\n34\n\nThe largest number among A + B = -32, A - B = 34, and A \\times B = -33 is 34.\n\nSample Input 3\n\n13 3\n\nSample Output 3\n\n39\n\nThe largest number among A + B = 16, A - B = 10, and A \\times B = 39 is 39.", "sample_input": "-13 3\n"}, "reference_outputs": ["-10\n"], "source_document_id": "p02945", "source_text": "Score : 100 points\n\nProblem Statement\n\nWe have two integers: A and B.\n\nPrint the largest number among A + B, A - B, and A \\times B.\n\nConstraints\n\nAll values in input are integers.\n\n-100 \\leq A,\\ B \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the largest number among A + B, A - B, and A \\times B.\n\nSample Input 1\n\n-13 3\n\nSample Output 1\n\n-10\n\nThe largest number among A + B = -10, A - B = -16, and A \\times B = -39 is -10.\n\nSample Input 2\n\n1 -33\n\nSample Output 2\n\n34\n\nThe largest number among A + B = -32, A - B = 34, and A \\times B = -33 is 34.\n\nSample Input 3\n\n13 3\n\nSample Output 3\n\n39\n\nThe largest number among A + B = 16, A - B = 10, and A \\times B = 39 is 39.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s129560481", "group_id": "codeNet:p02945", "input_text": "open Scanf\nopen Printf\n\nlet rint () = scanf \" %d\" (fun x -> x)\nlet stoa s = Array.init (String.length s) (String.get s)\nlet atos a = String.init (Array.length a) (Array.get a)\n\nlet () =\n let a = rint() and b = rint() in\n printf \"%d\\n\" (max (a + b) (max (a - b) (a * b)))", "language": "OCaml", "metadata": {"date": 1565485274, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02945.html", "problem_id": "p02945", "resource_group": "low_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/OCaml/s129560481.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s129560481", "user_id": "u006493569"}, "prompt_components": {"gold_output": "-10\n", "input_to_evaluate": "open Scanf\nopen Printf\n\nlet rint () = scanf \" %d\" (fun x -> x)\nlet stoa s = Array.init (String.length s) (String.get s)\nlet atos a = String.init (Array.length a) (Array.get a)\n\nlet () =\n let a = rint() and b = rint() in\n printf \"%d\\n\" (max (a + b) (max (a - b) (a * b)))", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 2432}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s192085167", "group_id": "codeNet:p02946", "input_text": "(* Vicfred\n * https://atcoder.jp/contests/abc137/tasks/abc137_b\n * implementation\n * *)\n\nlet rec solve i n =\n if i > n then Printf.printf \"\\n\" else\n (Printf.printf \"%d \" i; solve (i+1) n);;\n\nScanf.scanf \"%d %d\" @@ fun k x ->\n solve (x - k + 1) (x + k - 1);;\n\n", "language": "OCaml", "metadata": {"date": 1593799119, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p02946.html", "problem_id": "p02946", "resource_group": "low_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/OCaml/s192085167.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s192085167", "user_id": "u737840172"}, "prompt_components": {"gold_output": "5 6 7 8 9\n", "input_to_evaluate": "(* Vicfred\n * https://atcoder.jp/contests/abc137/tasks/abc137_b\n * implementation\n * *)\n\nlet rec solve i n =\n if i > n then Printf.printf \"\\n\" else\n (Printf.printf \"%d \" i; solve (i+1) n);;\n\nScanf.scanf \"%d %d\" @@ fun k x ->\n solve (x - k + 1) (x + k - 1);;\n\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nThere are 2000001 stones placed on a number line. The coordinates of these stones are -1000000, -999999, -999998, \\ldots, 999999, 1000000.\n\nAmong them, some K consecutive stones are painted black, and the others are painted white.\n\nAdditionally, we know that the stone at coordinate X is painted black.\n\nPrint all coordinates that potentially contain a stone painted black, in ascending order.\n\nConstraints\n\n1 \\leq K \\leq 100\n\n0 \\leq X \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK X\n\nOutput\n\nPrint all coordinates that potentially contain a stone painted black, in ascending order, with spaces in between.\n\nSample Input 1\n\n3 7\n\nSample Output 1\n\n5 6 7 8 9\n\nWe know that there are three stones painted black, and the stone at coordinate 7 is painted black. There are three possible cases:\n\nThe three stones painted black are placed at coordinates 5, 6, and 7.\n\nThe three stones painted black are placed at coordinates 6, 7, and 8.\n\nThe three stones painted black are placed at coordinates 7, 8, and 9.\n\nThus, five coordinates potentially contain a stone painted black: 5, 6, 7, 8, and 9.\n\nSample Input 2\n\n4 0\n\nSample Output 2\n\n-3 -2 -1 0 1 2 3\n\nNegative coordinates can also contain a stone painted black.\n\nSample Input 3\n\n1 100\n\nSample Output 3\n\n100", "sample_input": "3 7\n"}, "reference_outputs": ["5 6 7 8 9\n"], "source_document_id": "p02946", "source_text": "Score : 200 points\n\nProblem Statement\n\nThere are 2000001 stones placed on a number line. The coordinates of these stones are -1000000, -999999, -999998, \\ldots, 999999, 1000000.\n\nAmong them, some K consecutive stones are painted black, and the others are painted white.\n\nAdditionally, we know that the stone at coordinate X is painted black.\n\nPrint all coordinates that potentially contain a stone painted black, in ascending order.\n\nConstraints\n\n1 \\leq K \\leq 100\n\n0 \\leq X \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK X\n\nOutput\n\nPrint all coordinates that potentially contain a stone painted black, in ascending order, with spaces in between.\n\nSample Input 1\n\n3 7\n\nSample Output 1\n\n5 6 7 8 9\n\nWe know that there are three stones painted black, and the stone at coordinate 7 is painted black. There are three possible cases:\n\nThe three stones painted black are placed at coordinates 5, 6, and 7.\n\nThe three stones painted black are placed at coordinates 6, 7, and 8.\n\nThe three stones painted black are placed at coordinates 7, 8, and 9.\n\nThus, five coordinates potentially contain a stone painted black: 5, 6, 7, 8, and 9.\n\nSample Input 2\n\n4 0\n\nSample Output 2\n\n-3 -2 -1 0 1 2 3\n\nNegative coordinates can also contain a stone painted black.\n\nSample Input 3\n\n1 100\n\nSample Output 3\n\n100", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 8, "memory_kb": 3840}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s850467786", "group_id": "codeNet:p02946", "input_text": "let rec make_list n m =\n if n = m then [n] else n :: make_list (n+1) m\nlet rec string_of_list lst = match lst with\n | [] -> \"\"\n | f :: r -> string_of_int f ^ \" \" ^ string_of_list r\nlet () =\n let k, x = Scanf.scanf \"%d %d\\n\" (fun a b -> a, b) in\n let str = string_of_list (make_list (x-k+1) (x+k-1)) in\n Printf.printf \"%s\\n\" str", "language": "OCaml", "metadata": {"date": 1565486491, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02946.html", "problem_id": "p02946", "resource_group": "low_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/OCaml/s850467786.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s850467786", "user_id": "u307426615"}, "prompt_components": {"gold_output": "5 6 7 8 9\n", "input_to_evaluate": "let rec make_list n m =\n if n = m then [n] else n :: make_list (n+1) m\nlet rec string_of_list lst = match lst with\n | [] -> \"\"\n | f :: r -> string_of_int f ^ \" \" ^ string_of_list r\nlet () =\n let k, x = Scanf.scanf \"%d %d\\n\" (fun a b -> a, b) in\n let str = string_of_list (make_list (x-k+1) (x+k-1)) in\n Printf.printf \"%s\\n\" str", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 512}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s521005731", "group_id": "codeNet:p02948", "input_text": "open Scanf\nopen Printf\n\nlet (n,m) = sscanf (read_line ()) \"%d %d\" (fun a b -> (a,b));;\n(*\nlet array = Array.make n (0,0);;\nfor i = 0 to (n-1) do\n let (x,y) = sscanf (read_line ()) \"%d %d\" (fun a b -> (a,b)) in\n array.(i) <- (x,y)\ndone;;\n*)\n\nlet rec input_list = function\n | 0 -> []\n | x -> sscanf (read_line ()) \"%d %d\" (fun a b -> (a,b)) :: (input_list (x-1));;\n\nlet list = input_list n;;\nlet sort_list = List.sort (fun a b -> compare (fst a) (fst b)) list;;\n\nmodule PrioQueue =\nstruct\n type priority = int\n type 'a queue = Empty | Node of priority * 'a * 'a queue * 'a queue\n let empty = Empty\n let rec insert queue prio elt =\n match queue with\n Empty -> Node(prio, elt, Empty, Empty)\n | Node(p, e, left, right) ->\n (* prio <= p なら小さいほうが優先 prio >= p なら大きい方が優先 *)\n if prio = p then (* prio = p なら eltが小さい方を優先 *)\n if e >= elt\n then Node(prio, elt, insert right p e, left)\n else Node(p, e, insert right prio elt, left)\n else \n if prio > p\n then Node(prio, elt, insert right p e, left)\n else Node(p, e, insert right prio elt, left)\n exception Queue_is_empty\n let rec remove_top = function\n Empty -> raise Queue_is_empty\n | Node(prio, elt, left, Empty) -> left\n | Node(prio, elt, Empty, right) -> right\n | Node(prio, elt, (Node(lprio, lelt, _, _) as left), (Node(rprio, relt, _, _) as right)) ->\n if lprio = rprio then (* prio <= p なら小さいほうが優先 prio >= p なら大きい方が優先 *)\n if relt >= lelt\n then Node(lprio, lelt, remove_top left, right)\n else Node(rprio, relt, left, remove_top right)\n else if lprio > rprio \n then Node(lprio, lelt, remove_top left, right)\n else Node(rprio, relt, left, remove_top right)\n let rec print_queue = function\n Empty -> Printf.printf \"Empty\\n\"\n | Node(prio, elt, left, right) -> \n let _ = Printf.printf \"prio = %d, elt = %d \\n\" prio elt in\n let _ = Printf.printf \"left = \" in\n let _ = print_queue left in\n let _ = Printf.printf \"right = \" in\n let _ = print_queue right in ()\n let extract = function\n Empty -> raise Queue_is_empty\n | Node(prio, elt, _, _) as queue -> (prio, elt, remove_top queue)\nend;;\n\nopen PrioQueue;;\n\nlet rec solve_aux list m pq =\n match list with\n | [] -> ([], pq)\n | (x,y) :: rest ->\n if x <= m then \n let new_pq = PrioQueue.insert pq y x in\n solve_aux rest m new_pq\n else\n (list,pq);;\n\nlet solve () =\nlet rec loop rest_day ans candi pq =\n (*let _ = printf \"candi = \" in\n let _ = List.iter (fun a -> printf \"%d / \" (fst a)) candi in*)\n if rest_day = m+1 then ans\n else\n (* let _ = printf \"rest_day = %d, ans = %d, \\n pq = \" rest_day ans in*)\n let (rest, new_pq) = solve_aux candi rest_day pq in\n (*let _ = PrioQueue.print_queue new_pq in*)\n match new_pq with\n | Empty -> \n loop (rest_day + 1) ans rest Empty\n | Node(prio, elt, _, _) as queue -> \n loop (rest_day + 1) (ans + prio) rest (PrioQueue.remove_top queue)\nin loop 1 0 sort_list Empty;;\n\nlet _ = printf \"%d\\n\" (solve ());;", "language": "OCaml", "metadata": {"date": 1565926283, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02948.html", "problem_id": "p02948", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02948/input.txt", "sample_output_relpath": "derived/input_output/data/p02948/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02948/OCaml/s521005731.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s521005731", "user_id": "u947517859"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "open Scanf\nopen Printf\n\nlet (n,m) = sscanf (read_line ()) \"%d %d\" (fun a b -> (a,b));;\n(*\nlet array = Array.make n (0,0);;\nfor i = 0 to (n-1) do\n let (x,y) = sscanf (read_line ()) \"%d %d\" (fun a b -> (a,b)) in\n array.(i) <- (x,y)\ndone;;\n*)\n\nlet rec input_list = function\n | 0 -> []\n | x -> sscanf (read_line ()) \"%d %d\" (fun a b -> (a,b)) :: (input_list (x-1));;\n\nlet list = input_list n;;\nlet sort_list = List.sort (fun a b -> compare (fst a) (fst b)) list;;\n\nmodule PrioQueue =\nstruct\n type priority = int\n type 'a queue = Empty | Node of priority * 'a * 'a queue * 'a queue\n let empty = Empty\n let rec insert queue prio elt =\n match queue with\n Empty -> Node(prio, elt, Empty, Empty)\n | Node(p, e, left, right) ->\n (* prio <= p なら小さいほうが優先 prio >= p なら大きい方が優先 *)\n if prio = p then (* prio = p なら eltが小さい方を優先 *)\n if e >= elt\n then Node(prio, elt, insert right p e, left)\n else Node(p, e, insert right prio elt, left)\n else \n if prio > p\n then Node(prio, elt, insert right p e, left)\n else Node(p, e, insert right prio elt, left)\n exception Queue_is_empty\n let rec remove_top = function\n Empty -> raise Queue_is_empty\n | Node(prio, elt, left, Empty) -> left\n | Node(prio, elt, Empty, right) -> right\n | Node(prio, elt, (Node(lprio, lelt, _, _) as left), (Node(rprio, relt, _, _) as right)) ->\n if lprio = rprio then (* prio <= p なら小さいほうが優先 prio >= p なら大きい方が優先 *)\n if relt >= lelt\n then Node(lprio, lelt, remove_top left, right)\n else Node(rprio, relt, left, remove_top right)\n else if lprio > rprio \n then Node(lprio, lelt, remove_top left, right)\n else Node(rprio, relt, left, remove_top right)\n let rec print_queue = function\n Empty -> Printf.printf \"Empty\\n\"\n | Node(prio, elt, left, right) -> \n let _ = Printf.printf \"prio = %d, elt = %d \\n\" prio elt in\n let _ = Printf.printf \"left = \" in\n let _ = print_queue left in\n let _ = Printf.printf \"right = \" in\n let _ = print_queue right in ()\n let extract = function\n Empty -> raise Queue_is_empty\n | Node(prio, elt, _, _) as queue -> (prio, elt, remove_top queue)\nend;;\n\nopen PrioQueue;;\n\nlet rec solve_aux list m pq =\n match list with\n | [] -> ([], pq)\n | (x,y) :: rest ->\n if x <= m then \n let new_pq = PrioQueue.insert pq y x in\n solve_aux rest m new_pq\n else\n (list,pq);;\n\nlet solve () =\nlet rec loop rest_day ans candi pq =\n (*let _ = printf \"candi = \" in\n let _ = List.iter (fun a -> printf \"%d / \" (fst a)) candi in*)\n if rest_day = m+1 then ans\n else\n (* let _ = printf \"rest_day = %d, ans = %d, \\n pq = \" rest_day ans in*)\n let (rest, new_pq) = solve_aux candi rest_day pq in\n (*let _ = PrioQueue.print_queue new_pq in*)\n match new_pq with\n | Empty -> \n loop (rest_day + 1) ans rest Empty\n | Node(prio, elt, _, _) as queue -> \n loop (rest_day + 1) (ans + prio) rest (PrioQueue.remove_top queue)\nin loop 1 0 sort_list Empty;;\n\nlet _ = printf \"%d\\n\" (solve ());;", "problem_context": "Score : 400 points\n\nProblem Statement\n\nThere are N one-off jobs available. If you take the i-th job and complete it, you will earn the reward of B_i after A_i days from the day you do it.\n\nYou can take and complete at most one of these jobs in a day.\n\nHowever, you cannot retake a job that you have already done.\n\nFind the maximum total reward that you can earn no later than M days from today.\n\nYou can already start working today.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n1 \\leq A_i \\leq 10^5\n\n1 \\leq B_i \\leq 10^4\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 B_1\nA_2 B_2\n\\vdots\nA_N B_N\n\nOutput\n\nPrint the maximum total reward that you can earn no later than M days from today.\n\nSample Input 1\n\n3 4\n4 3\n4 1\n2 2\n\nSample Output 1\n\n5\n\nYou can earn the total reward of 5 by taking the jobs as follows:\n\nTake and complete the first job today. You will earn the reward of 3 after four days from today.\n\nTake and complete the third job tomorrow. You will earn the reward of 2 after two days from tomorrow, that is, after three days from today.\n\nSample Input 2\n\n5 3\n1 2\n1 3\n1 4\n2 1\n2 3\n\nSample Output 2\n\n10\n\nSample Input 3\n\n1 1\n2 1\n\nSample Output 3\n\n0", "sample_input": "3 4\n4 3\n4 1\n2 2\n"}, "reference_outputs": ["5\n"], "source_document_id": "p02948", "source_text": "Score : 400 points\n\nProblem Statement\n\nThere are N one-off jobs available. If you take the i-th job and complete it, you will earn the reward of B_i after A_i days from the day you do it.\n\nYou can take and complete at most one of these jobs in a day.\n\nHowever, you cannot retake a job that you have already done.\n\nFind the maximum total reward that you can earn no later than M days from today.\n\nYou can already start working today.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n1 \\leq A_i \\leq 10^5\n\n1 \\leq B_i \\leq 10^4\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 B_1\nA_2 B_2\n\\vdots\nA_N B_N\n\nOutput\n\nPrint the maximum total reward that you can earn no later than M days from today.\n\nSample Input 1\n\n3 4\n4 3\n4 1\n2 2\n\nSample Output 1\n\n5\n\nYou can earn the total reward of 5 by taking the jobs as follows:\n\nTake and complete the first job today. You will earn the reward of 3 after four days from today.\n\nTake and complete the third job tomorrow. You will earn the reward of 2 after two days from tomorrow, that is, after three days from today.\n\nSample Input 2\n\n5 3\n1 2\n1 3\n1 4\n2 1\n2 3\n\nSample Output 2\n\n10\n\nSample Input 3\n\n1 1\n2 1\n\nSample Output 3\n\n0", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3146, "cpu_time_ms": 281, "memory_kb": 27916}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s608395708", "group_id": "codeNet:p02948", "input_text": "open Scanf\nopen Printf\n\ntype heap = Nil | Node of int * heap * heap\n\nlet rec merge a b =\n match a, b with\n | a, Nil -> a\n | Nil, b -> b\n | Node (av, al, ar), Node (bv, bl, br) ->\n if av > bv then\n Node (av, (merge ar b), al)\n else\n Node (bv, (merge br a), bl)\n\nlet is_empty = function\n | Nil -> true\n | _ -> false\n\nlet push a v = merge a (Node (v, Nil, Nil))\nlet peek = function\n | Nil -> invalid_arg \"nil\"\n | Node (v, _, _) -> v\n\nlet pop = function\n | Nil -> invalid_arg \"nil\"\n | Node (_, l, r) -> merge l r\n\n\nlet () =\n let n, m = scanf \" %d %d\" (fun a b -> a, b) in\n let ab = Array.init n (fun _ -> scanf \" %d %d\" (fun a b -> a, b)) in\n Array.sort compare ab;\n let k = ref 0 in\n let q = ref Nil in\n let ans = ref 0 in\n for i = m - 1 downto 0 do\n while !k < n && i + fst ab.(!k) <= m do\n q := push !q (snd ab.(!k));\n incr k\n done;\n if not (is_empty !q) then begin\n ans := !ans + peek !q;\n q := pop !q\n end;\n done;\n printf \"%d\\n\" !ans", "language": "OCaml", "metadata": {"date": 1565498468, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02948.html", "problem_id": "p02948", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02948/input.txt", "sample_output_relpath": "derived/input_output/data/p02948/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02948/OCaml/s608395708.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s608395708", "user_id": "u006493569"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "open Scanf\nopen Printf\n\ntype heap = Nil | Node of int * heap * heap\n\nlet rec merge a b =\n match a, b with\n | a, Nil -> a\n | Nil, b -> b\n | Node (av, al, ar), Node (bv, bl, br) ->\n if av > bv then\n Node (av, (merge ar b), al)\n else\n Node (bv, (merge br a), bl)\n\nlet is_empty = function\n | Nil -> true\n | _ -> false\n\nlet push a v = merge a (Node (v, Nil, Nil))\nlet peek = function\n | Nil -> invalid_arg \"nil\"\n | Node (v, _, _) -> v\n\nlet pop = function\n | Nil -> invalid_arg \"nil\"\n | Node (_, l, r) -> merge l r\n\n\nlet () =\n let n, m = scanf \" %d %d\" (fun a b -> a, b) in\n let ab = Array.init n (fun _ -> scanf \" %d %d\" (fun a b -> a, b)) in\n Array.sort compare ab;\n let k = ref 0 in\n let q = ref Nil in\n let ans = ref 0 in\n for i = m - 1 downto 0 do\n while !k < n && i + fst ab.(!k) <= m do\n q := push !q (snd ab.(!k));\n incr k\n done;\n if not (is_empty !q) then begin\n ans := !ans + peek !q;\n q := pop !q\n end;\n done;\n printf \"%d\\n\" !ans", "problem_context": "Score : 400 points\n\nProblem Statement\n\nThere are N one-off jobs available. If you take the i-th job and complete it, you will earn the reward of B_i after A_i days from the day you do it.\n\nYou can take and complete at most one of these jobs in a day.\n\nHowever, you cannot retake a job that you have already done.\n\nFind the maximum total reward that you can earn no later than M days from today.\n\nYou can already start working today.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n1 \\leq A_i \\leq 10^5\n\n1 \\leq B_i \\leq 10^4\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 B_1\nA_2 B_2\n\\vdots\nA_N B_N\n\nOutput\n\nPrint the maximum total reward that you can earn no later than M days from today.\n\nSample Input 1\n\n3 4\n4 3\n4 1\n2 2\n\nSample Output 1\n\n5\n\nYou can earn the total reward of 5 by taking the jobs as follows:\n\nTake and complete the first job today. You will earn the reward of 3 after four days from today.\n\nTake and complete the third job tomorrow. You will earn the reward of 2 after two days from tomorrow, that is, after three days from today.\n\nSample Input 2\n\n5 3\n1 2\n1 3\n1 4\n2 1\n2 3\n\nSample Output 2\n\n10\n\nSample Input 3\n\n1 1\n2 1\n\nSample Output 3\n\n0", "sample_input": "3 4\n4 3\n4 1\n2 2\n"}, "reference_outputs": ["5\n"], "source_document_id": "p02948", "source_text": "Score : 400 points\n\nProblem Statement\n\nThere are N one-off jobs available. If you take the i-th job and complete it, you will earn the reward of B_i after A_i days from the day you do it.\n\nYou can take and complete at most one of these jobs in a day.\n\nHowever, you cannot retake a job that you have already done.\n\nFind the maximum total reward that you can earn no later than M days from today.\n\nYou can already start working today.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n1 \\leq A_i \\leq 10^5\n\n1 \\leq B_i \\leq 10^4\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 B_1\nA_2 B_2\n\\vdots\nA_N B_N\n\nOutput\n\nPrint the maximum total reward that you can earn no later than M days from today.\n\nSample Input 1\n\n3 4\n4 3\n4 1\n2 2\n\nSample Output 1\n\n5\n\nYou can earn the total reward of 5 by taking the jobs as follows:\n\nTake and complete the first job today. You will earn the reward of 3 after four days from today.\n\nTake and complete the third job tomorrow. You will earn the reward of 2 after two days from tomorrow, that is, after three days from today.\n\nSample Input 2\n\n5 3\n1 2\n1 3\n1 4\n2 1\n2 3\n\nSample Output 2\n\n10\n\nSample Input 3\n\n1 1\n2 1\n\nSample Output 3\n\n0", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 157, "memory_kb": 10368}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s810635471", "group_id": "codeNet:p02951", "input_text": "Scanf.scanf \"%d %d %d\" @@ fun a b c -> Printf.printf \"%d\\n\" @@ c - min c (a - b)", "language": "OCaml", "metadata": {"date": 1578054860, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02951.html", "problem_id": "p02951", "resource_group": "low_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/OCaml/s810635471.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s810635471", "user_id": "u732304692"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "Scanf.scanf \"%d %d %d\" @@ fun a b c -> Printf.printf \"%d\\n\" @@ c - min c (a - b)", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s756088781", "group_id": "codeNet:p02951", "input_text": "let () = Scanf.scanf \"%d %d %d\" @@ fun a b c ->\n Printf.printf \"%d\\n\" @@ c - min c (a - b)\n", "language": "OCaml", "metadata": {"date": 1564966895, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02951.html", "problem_id": "p02951", "resource_group": "low_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/OCaml/s756088781.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s756088781", "user_id": "u504158101"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "let () = Scanf.scanf \"%d %d %d\" @@ fun a b c ->\n Printf.printf \"%d\\n\" @@ c - min c (a - b)\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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 2432}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s281818406", "group_id": "codeNet:p02954", "input_text": "let s = read_line ()\nlet n = String.length s\nlet eo, ans = Array.(make 2 0, make n 0)\nlet g a i = a.(i) <- a.(i) + 1\nlet rec f i p j = if i < n then\n if p = 'R' then if s.[i] = 'R' then (g eo @@ i mod 2; f (i + 1) p j)\n else (ans.(i - 1) <- eo.(1 - i mod 2); ans.(i) <- eo.(i mod 2) + 1; f (i + 1) 'L' i)\n else if s.[i] = 'L' then (g ans @@ j - (i - j) mod 2; f (i + 1) p j) else (eo.(0) <- 0; eo.(1) <- 0; eo.(i mod 2) <- 1; f (i + 1) 'R' j)\nlet _ = eo.(0) <- 1; f 1 'R' 0; Array.iteri (fun i n -> Printf.printf (if i = 0 then \"%d\" else \" %d\") n) ans; print_newline ()", "language": "OCaml", "metadata": {"date": 1567683626, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02954.html", "problem_id": "p02954", "resource_group": "low_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/OCaml/s281818406.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s281818406", "user_id": "u732304692"}, "prompt_components": {"gold_output": "0 1 2 1 1\n", "input_to_evaluate": "let s = read_line ()\nlet n = String.length s\nlet eo, ans = Array.(make 2 0, make n 0)\nlet g a i = a.(i) <- a.(i) + 1\nlet rec f i p j = if i < n then\n if p = 'R' then if s.[i] = 'R' then (g eo @@ i mod 2; f (i + 1) p j)\n else (ans.(i - 1) <- eo.(1 - i mod 2); ans.(i) <- eo.(i mod 2) + 1; f (i + 1) 'L' i)\n else if s.[i] = 'L' then (g ans @@ j - (i - j) mod 2; f (i + 1) p j) else (eo.(0) <- 0; eo.(1) <- 0; eo.(i mod 2) <- 1; f (i + 1) 'R' j)\nlet _ = eo.(0) <- 1; f 1 'R' 0; Array.iteri (fun i n -> Printf.printf (if i = 0 then \"%d\" else \" %d\") n) ans; print_newline ()", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 574, "cpu_time_ms": 27, "memory_kb": 5888}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s448330648", "group_id": "codeNet:p02955", "input_text": "open Scanf\nopen Printf\n\nlet readInt () = scanf \" %d\" (fun x -> x)\n\nlet divisors x =\n let l = ref [] in\n let r = ref [] in\n let y = ref 1 in\n while !y * !y <= x do\n if x mod !y = 0 then begin\n l := !y :: !l;\n if x <> !y * !y then r := (x / !y) :: !r\n end;\n incr y\n done;\n List.rev !l @ !r\n\nlet cost n a d =\n let open Array in\n let a = map (fun x -> x mod d) a in\n fast_sort compare a;\n let tot = fold_left (+) 0 a in\n assert (tot mod d = 0);\n let m = tot / d in\n let def = ref 0 in\n for i=n-m to n-1 do def := !def + d - a.(i) done;\n !def\n\nlet solve n k a =\n let tot = Array.fold_left (+) 0 a in\n let divs = divisors tot in\n List.fold_left (fun cur d -> if cost n a d <= k then d else cur) 1 divs\n\nlet main () =\n let n = readInt () in\n let k = readInt () in\n let a = Array.init n (fun _ -> readInt ()) in\n printf \"%d\\n\" (solve n k a)\n\nlet () = main ()\n", "language": "OCaml", "metadata": {"date": 1565009681, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02955.html", "problem_id": "p02955", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02955/input.txt", "sample_output_relpath": "derived/input_output/data/p02955/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02955/OCaml/s448330648.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s448330648", "user_id": "u310083442"}, "prompt_components": {"gold_output": "7\n", "input_to_evaluate": "open Scanf\nopen Printf\n\nlet readInt () = scanf \" %d\" (fun x -> x)\n\nlet divisors x =\n let l = ref [] in\n let r = ref [] in\n let y = ref 1 in\n while !y * !y <= x do\n if x mod !y = 0 then begin\n l := !y :: !l;\n if x <> !y * !y then r := (x / !y) :: !r\n end;\n incr y\n done;\n List.rev !l @ !r\n\nlet cost n a d =\n let open Array in\n let a = map (fun x -> x mod d) a in\n fast_sort compare a;\n let tot = fold_left (+) 0 a in\n assert (tot mod d = 0);\n let m = tot / d in\n let def = ref 0 in\n for i=n-m to n-1 do def := !def + d - a.(i) done;\n !def\n\nlet solve n k a =\n let tot = Array.fold_left (+) 0 a in\n let divs = divisors tot in\n List.fold_left (fun cur d -> if cost n a d <= k then d else cur) 1 divs\n\nlet main () =\n let n = readInt () in\n let k = readInt () in\n let a = Array.init n (fun _ -> readInt ()) in\n printf \"%d\\n\" (solve n k a)\n\nlet () = main ()\n", "problem_context": "Score : 500 points\n\nProblem Statement\n\nWe have a sequence of N integers: A_1, A_2, \\cdots, A_N.\n\nYou can perform the following operation between 0 and K times (inclusive):\n\nChoose two integers i and j such that i \\neq j, each between 1 and N (inclusive). Add 1 to A_i and -1 to A_j, possibly producing a negative element.\n\nCompute the maximum possible positive integer that divides every element of A after the operations. Here a positive integer x divides an integer y if and only if there exists an integer z such that y = xz.\n\nConstraints\n\n2 \\leq N \\leq 500\n\n1 \\leq A_i \\leq 10^6\n\n0 \\leq K \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nA_1 A_2 \\cdots A_{N-1} A_{N}\n\nOutput\n\nPrint the maximum possible positive integer that divides every element of A after the operations.\n\nSample Input 1\n\n2 3\n8 20\n\nSample Output 1\n\n7\n\n7 will divide every element of A if, for example, we perform the following operation:\n\nChoose i = 2, j = 1. A becomes (7, 21).\n\nWe cannot reach the situation where 8 or greater integer divides every element of A.\n\nSample Input 2\n\n2 10\n3 5\n\nSample Output 2\n\n8\n\nConsider performing the following five operations:\n\nChoose i = 2, j = 1. A becomes (2, 6).\n\nChoose i = 2, j = 1. A becomes (1, 7).\n\nChoose i = 2, j = 1. A becomes (0, 8).\n\nChoose i = 2, j = 1. A becomes (-1, 9).\n\nChoose i = 1, j = 2. A becomes (0, 8).\n\nThen, 0 = 8 \\times 0 and 8 = 8 \\times 1, so 8 divides every element of A. We cannot reach the situation where 9 or greater integer divides every element of A.\n\nSample Input 3\n\n4 5\n10 1 2 22\n\nSample Output 3\n\n7\n\nSample Input 4\n\n8 7\n1 7 5 6 8 2 6 5\n\nSample Output 4\n\n5", "sample_input": "2 3\n8 20\n"}, "reference_outputs": ["7\n"], "source_document_id": "p02955", "source_text": "Score : 500 points\n\nProblem Statement\n\nWe have a sequence of N integers: A_1, A_2, \\cdots, A_N.\n\nYou can perform the following operation between 0 and K times (inclusive):\n\nChoose two integers i and j such that i \\neq j, each between 1 and N (inclusive). Add 1 to A_i and -1 to A_j, possibly producing a negative element.\n\nCompute the maximum possible positive integer that divides every element of A after the operations. Here a positive integer x divides an integer y if and only if there exists an integer z such that y = xz.\n\nConstraints\n\n2 \\leq N \\leq 500\n\n1 \\leq A_i \\leq 10^6\n\n0 \\leq K \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nA_1 A_2 \\cdots A_{N-1} A_{N}\n\nOutput\n\nPrint the maximum possible positive integer that divides every element of A after the operations.\n\nSample Input 1\n\n2 3\n8 20\n\nSample Output 1\n\n7\n\n7 will divide every element of A if, for example, we perform the following operation:\n\nChoose i = 2, j = 1. A becomes (7, 21).\n\nWe cannot reach the situation where 8 or greater integer divides every element of A.\n\nSample Input 2\n\n2 10\n3 5\n\nSample Output 2\n\n8\n\nConsider performing the following five operations:\n\nChoose i = 2, j = 1. A becomes (2, 6).\n\nChoose i = 2, j = 1. A becomes (1, 7).\n\nChoose i = 2, j = 1. A becomes (0, 8).\n\nChoose i = 2, j = 1. A becomes (-1, 9).\n\nChoose i = 1, j = 2. A becomes (0, 8).\n\nThen, 0 = 8 \\times 0 and 8 = 8 \\times 1, so 8 divides every element of A. We cannot reach the situation where 9 or greater integer divides every element of A.\n\nSample Input 3\n\n4 5\n10 1 2 22\n\nSample Output 3\n\n7\n\nSample Input 4\n\n8 7\n1 7 5 6 8 2 6 5\n\nSample Output 4\n\n5", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 892, "cpu_time_ms": 119, "memory_kb": 6400}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s258852450", "group_id": "codeNet:p02957", "input_text": "let a, b = Scanf.scanf \" %d %d\" @@ fun a b -> a, b\nlet k = (a + b) / 2\nlet _ = if (a + b) mod 2 = 1 || (a - k) * (b - k) >= 0 then print_endline \"IMPOSSIBLE\" else Printf.printf \"%d\\n\" k", "language": "OCaml", "metadata": {"date": 1564386895, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02957.html", "problem_id": "p02957", "resource_group": "low_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/OCaml/s258852450.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s258852450", "user_id": "u732304692"}, "prompt_components": {"gold_output": "9\n", "input_to_evaluate": "let a, b = Scanf.scanf \" %d %d\" @@ fun a b -> a, b\nlet k = (a + b) / 2\nlet _ = if (a + b) mod 2 = 1 || (a - k) * (b - k) >= 0 then print_endline \"IMPOSSIBLE\" else Printf.printf \"%d\\n\" k", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 3, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s452983303", "group_id": "codeNet:p02957", "input_text": "let answer a b =\n let sa = a - b in\n if (sa mod 2) = 1 then\n \"IMPOSSIBLE\"\n else\n if sa < 0 then\n sa / 2 * (-1) |> string_of_int\n else\n sa / 2 |> string_of_int\n\n\nlet () = Scanf.scanf \"%d %d\" (fun a b -> print_endline (answer a b))\n", "language": "OCaml", "metadata": {"date": 1564277959, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02957.html", "problem_id": "p02957", "resource_group": "low_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/OCaml/s452983303.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s452983303", "user_id": "u950428333"}, "prompt_components": {"gold_output": "9\n", "input_to_evaluate": "let answer a b =\n let sa = a - b in\n if (sa mod 2) = 1 then\n \"IMPOSSIBLE\"\n else\n if sa < 0 then\n sa / 2 * (-1) |> string_of_int\n else\n sa / 2 |> string_of_int\n\n\nlet () = Scanf.scanf \"%d %d\" (fun a b -> print_endline (answer a b))\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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 266, "cpu_time_ms": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s794792438", "group_id": "codeNet:p02958", "input_text": "let () = Scanf.scanf \"%d\\n\" @@ fun n ->\n let pp = Array.init n @@ fun _ -> Scanf.scanf \" %d\" @@ fun d -> d - 1 in\n let changed = ref 0 in\n for i = 0 to n - 1 do\n if pp.(i) <> i then changed := !changed + 1\n done;\n Printf.printf \"%s\\n\" @@\n if !changed <= 2 then \"YES\" else \"NO\"\n", "language": "OCaml", "metadata": {"date": 1597041350, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p02958.html", "problem_id": "p02958", "resource_group": "low_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/OCaml/s794792438.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s794792438", "user_id": "u052332717"}, "prompt_components": {"gold_output": "YES\n", "input_to_evaluate": "let () = Scanf.scanf \"%d\\n\" @@ fun n ->\n let pp = Array.init n @@ fun _ -> Scanf.scanf \" %d\" @@ fun d -> d - 1 in\n let changed = ref 0 in\n for i = 0 to n - 1 do\n if pp.(i) <> i then changed := !changed + 1\n done;\n Printf.printf \"%s\\n\" @@\n if !changed <= 2 then \"YES\" else \"NO\"\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nWe have a sequence p = {p_1,\\ p_2,\\ ...,\\ p_N} which is a permutation of {1,\\ 2,\\ ...,\\ N}.\n\nYou can perform the following operation at most once: choose integers i and j (1 \\leq i < j \\leq N), and swap p_i and p_j. Note that you can also choose not to perform it.\n\nPrint YES if you can sort p in ascending order in this way, and NO otherwise.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 50\n\np is a permutation of {1,\\ 2,\\ ...,\\ N}.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\np_1 p_2 ... p_N\n\nOutput\n\nPrint YES if you can sort p in ascending order in the way stated in the problem statement, and NO otherwise.\n\nSample Input 1\n\n5\n5 2 3 4 1\n\nSample Output 1\n\nYES\n\nYou can sort p in ascending order by swapping p_1 and p_5.\n\nSample Input 2\n\n5\n2 4 3 5 1\n\nSample Output 2\n\nNO\n\nIn this case, swapping any two elements does not sort p in ascending order.\n\nSample Input 3\n\n7\n1 2 3 4 5 6 7\n\nSample Output 3\n\nYES\n\np is already sorted in ascending order, so no operation is needed.", "sample_input": "5\n5 2 3 4 1\n"}, "reference_outputs": ["YES\n"], "source_document_id": "p02958", "source_text": "Score : 200 points\n\nProblem Statement\n\nWe have a sequence p = {p_1,\\ p_2,\\ ...,\\ p_N} which is a permutation of {1,\\ 2,\\ ...,\\ N}.\n\nYou can perform the following operation at most once: choose integers i and j (1 \\leq i < j \\leq N), and swap p_i and p_j. Note that you can also choose not to perform it.\n\nPrint YES if you can sort p in ascending order in this way, and NO otherwise.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 50\n\np is a permutation of {1,\\ 2,\\ ...,\\ N}.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\np_1 p_2 ... p_N\n\nOutput\n\nPrint YES if you can sort p in ascending order in the way stated in the problem statement, and NO otherwise.\n\nSample Input 1\n\n5\n5 2 3 4 1\n\nSample Output 1\n\nYES\n\nYou can sort p in ascending order by swapping p_1 and p_5.\n\nSample Input 2\n\n5\n2 4 3 5 1\n\nSample Output 2\n\nNO\n\nIn this case, swapping any two elements does not sort p in ascending order.\n\nSample Input 3\n\n7\n1 2 3 4 5 6 7\n\nSample Output 3\n\nYES\n\np is already sorted in ascending order, so no operation is needed.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 9, "memory_kb": 3692}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s461900101", "group_id": "codeNet:p02958", "input_text": "let () = Scanf.scanf \"%d\\n\" @@ fun n ->\n let ps = Array.init n @@ fun _ -> Scanf.scanf \"%d \" @@ fun p -> p in\n print_endline @@ if\n ( >= ) 2 @@\n Array.fold_left ( + ) 0 @@\n Array.init n @@ fun i ->\n if ps.(i) = i + 1 then 0 else 1\n then \"YES\"\n else \"NO\"\n\n", "language": "OCaml", "metadata": {"date": 1564281670, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02958.html", "problem_id": "p02958", "resource_group": "low_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/OCaml/s461900101.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s461900101", "user_id": "u504158101"}, "prompt_components": {"gold_output": "YES\n", "input_to_evaluate": "let () = Scanf.scanf \"%d\\n\" @@ fun n ->\n let ps = Array.init n @@ fun _ -> Scanf.scanf \"%d \" @@ fun p -> p in\n print_endline @@ if\n ( >= ) 2 @@\n Array.fold_left ( + ) 0 @@\n Array.init n @@ fun i ->\n if ps.(i) = i + 1 then 0 else 1\n then \"YES\"\n else \"NO\"\n\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nWe have a sequence p = {p_1,\\ p_2,\\ ...,\\ p_N} which is a permutation of {1,\\ 2,\\ ...,\\ N}.\n\nYou can perform the following operation at most once: choose integers i and j (1 \\leq i < j \\leq N), and swap p_i and p_j. Note that you can also choose not to perform it.\n\nPrint YES if you can sort p in ascending order in this way, and NO otherwise.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 50\n\np is a permutation of {1,\\ 2,\\ ...,\\ N}.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\np_1 p_2 ... p_N\n\nOutput\n\nPrint YES if you can sort p in ascending order in the way stated in the problem statement, and NO otherwise.\n\nSample Input 1\n\n5\n5 2 3 4 1\n\nSample Output 1\n\nYES\n\nYou can sort p in ascending order by swapping p_1 and p_5.\n\nSample Input 2\n\n5\n2 4 3 5 1\n\nSample Output 2\n\nNO\n\nIn this case, swapping any two elements does not sort p in ascending order.\n\nSample Input 3\n\n7\n1 2 3 4 5 6 7\n\nSample Output 3\n\nYES\n\np is already sorted in ascending order, so no operation is needed.", "sample_input": "5\n5 2 3 4 1\n"}, "reference_outputs": ["YES\n"], "source_document_id": "p02958", "source_text": "Score : 200 points\n\nProblem Statement\n\nWe have a sequence p = {p_1,\\ p_2,\\ ...,\\ p_N} which is a permutation of {1,\\ 2,\\ ...,\\ N}.\n\nYou can perform the following operation at most once: choose integers i and j (1 \\leq i < j \\leq N), and swap p_i and p_j. Note that you can also choose not to perform it.\n\nPrint YES if you can sort p in ascending order in this way, and NO otherwise.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 50\n\np is a permutation of {1,\\ 2,\\ ...,\\ N}.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\np_1 p_2 ... p_N\n\nOutput\n\nPrint YES if you can sort p in ascending order in the way stated in the problem statement, and NO otherwise.\n\nSample Input 1\n\n5\n5 2 3 4 1\n\nSample Output 1\n\nYES\n\nYou can sort p in ascending order by swapping p_1 and p_5.\n\nSample Input 2\n\n5\n2 4 3 5 1\n\nSample Output 2\n\nNO\n\nIn this case, swapping any two elements does not sort p in ascending order.\n\nSample Input 3\n\n7\n1 2 3 4 5 6 7\n\nSample Output 3\n\nYES\n\np is already sorted in ascending order, so no operation is needed.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s880537159", "group_id": "codeNet:p02960", "input_text": "let m = 1000000007\nlet ( +^ ) x y = (x + y) mod m\n\nlet () =\n let s = read_line () in\n let dp = Array.make_matrix (String.length s + 1) 13 0 in\n dp.(0).(0) <- 1;\n String.iteri (fun i ->\n let go n =\n for j = 0 to 12 do\n dp.(i + 1).((10 * j + n) mod 13) <-\n dp.(i + 1).((10 * j + n) mod 13) +^ dp.(i).(j)\n done in\n function\n | '?' ->\n for i = 0 to 9 do\n go i\n done\n | c -> go (int_of_char c - int_of_char '0')) s;\n Printf.printf \"%d\\n\" dp.(String.length s).(5)\n", "language": "OCaml", "metadata": {"date": 1564281734, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02960.html", "problem_id": "p02960", "resource_group": "low_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/OCaml/s880537159.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s880537159", "user_id": "u504158101"}, "prompt_components": {"gold_output": "768\n", "input_to_evaluate": "let m = 1000000007\nlet ( +^ ) x y = (x + y) mod m\n\nlet () =\n let s = read_line () in\n let dp = Array.make_matrix (String.length s + 1) 13 0 in\n dp.(0).(0) <- 1;\n String.iteri (fun i ->\n let go n =\n for j = 0 to 12 do\n dp.(i + 1).((10 * j + n) mod 13) <-\n dp.(i + 1).((10 * j + n) mod 13) +^ dp.(i).(j)\n done in\n function\n | '?' ->\n for i = 0 to 9 do\n go i\n done\n | c -> go (int_of_char c - int_of_char '0')) s;\n Printf.printf \"%d\\n\" dp.(String.length s).(5)\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nGiven is a string S. Each character in S is either a digit (0, ..., 9) or ?.\n\nAmong the integers obtained by replacing each occurrence of ? with a digit, how many have a remainder of 5 when divided by 13? An integer may begin with 0.\n\nSince the answer can be enormous, print the count modulo 10^9+7.\n\nConstraints\n\nS is a string consisting of digits (0, ..., 9) and ?.\n\n1 \\leq |S| \\leq 10^5\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the number of integers satisfying the condition, modulo 10^9+7.\n\nSample Input 1\n\n??2??5\n\nSample Output 1\n\n768\n\nFor example, 482305, 002865, and 972665 satisfy the condition.\n\nSample Input 2\n\n?44\n\nSample Output 2\n\n1\n\nOnly 044 satisfies the condition.\n\nSample Input 3\n\n7?4\n\nSample Output 3\n\n0\n\nWe may not be able to produce an integer satisfying the condition.\n\nSample Input 4\n\n?6?42???8??2??06243????9??3???7258??5??7???????774????4?1??17???9?5?70???76???\n\nSample Output 4\n\n153716888", "sample_input": "??2??5\n"}, "reference_outputs": ["768\n"], "source_document_id": "p02960", "source_text": "Score : 400 points\n\nProblem Statement\n\nGiven is a string S. Each character in S is either a digit (0, ..., 9) or ?.\n\nAmong the integers obtained by replacing each occurrence of ? with a digit, how many have a remainder of 5 when divided by 13? An integer may begin with 0.\n\nSince the answer can be enormous, print the count modulo 10^9+7.\n\nConstraints\n\nS is a string consisting of digits (0, ..., 9) and ?.\n\n1 \\leq |S| \\leq 10^5\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the number of integers satisfying the condition, modulo 10^9+7.\n\nSample Input 1\n\n??2??5\n\nSample Output 1\n\n768\n\nFor example, 482305, 002865, and 972665 satisfy the condition.\n\nSample Input 2\n\n?44\n\nSample Output 2\n\n1\n\nOnly 044 satisfies the condition.\n\nSample Input 3\n\n7?4\n\nSample Output 3\n\n0\n\nWe may not be able to produce an integer satisfying the condition.\n\nSample Input 4\n\n?6?42???8??2??06243????9??3???7258??5??7???????774????4?1??17???9?5?70???76???\n\nSample Output 4\n\n153716888", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 102, "memory_kb": 15488}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s808243055", "group_id": "codeNet:p02963", "input_text": "let () =\n let main n =\n let s = n in\n let x1 = 0 in\n let y1 = 0 in\n let sq = int_of_float (ceil (sqrt (float (s)))) in\n let rec loop offs =\n let x2 = sq + offs in\n let y3 = sq - offs in\n let sq2 = x2 * y3 - s in\n if x2 > 1_000_000_000 || sq2 < 0 then failwith \"??\" else\n let rec loop_2 sq3 count =\n if count > 1000000 || sq3 < 1 then loop (offs + 1) else\n if sq2 mod sq3 = 0 then\n let x3 = sq3 in\n let y2 = sq2 / sq3 in\n x1, y1, x2, y2, x3, y3\n else loop_2 (sq3 - 1) (count + 1)\n in\n if sq2 = 0 then x1, y1, x2, 0, 0, y3 else\n let sq3 = int_of_float (floor (sqrt (float (sq2)))) in\n loop_2 sq3 0\n in\n loop 0\n in\n let x1, y1, x2, y2, x3, y3 = main (int_of_string (read_line ())) in\n Printf.printf \"%d %d %d %d %d %d\\n\" x1 y1 x2 y2 x3 y3", "language": "OCaml", "metadata": {"date": 1563761974, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02963.html", "problem_id": "p02963", "resource_group": "low_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/OCaml/s808243055.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s808243055", "user_id": "u342443598"}, "prompt_components": {"gold_output": "1 0 2 2 0 1\n", "input_to_evaluate": "let () =\n let main n =\n let s = n in\n let x1 = 0 in\n let y1 = 0 in\n let sq = int_of_float (ceil (sqrt (float (s)))) in\n let rec loop offs =\n let x2 = sq + offs in\n let y3 = sq - offs in\n let sq2 = x2 * y3 - s in\n if x2 > 1_000_000_000 || sq2 < 0 then failwith \"??\" else\n let rec loop_2 sq3 count =\n if count > 1000000 || sq3 < 1 then loop (offs + 1) else\n if sq2 mod sq3 = 0 then\n let x3 = sq3 in\n let y2 = sq2 / sq3 in\n x1, y1, x2, y2, x3, y3\n else loop_2 (sq3 - 1) (count + 1)\n in\n if sq2 = 0 then x1, y1, x2, 0, 0, y3 else\n let sq3 = int_of_float (floor (sqrt (float (sq2)))) in\n loop_2 sq3 0\n in\n loop 0\n in\n let x1, y1, x2, y2, x3, y3 = main (int_of_string (read_line ())) in\n Printf.printf \"%d %d %d %d %d %d\\n\" x1 y1 x2 y2 x3 y3", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1041, "cpu_time_ms": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s395611151", "group_id": "codeNet:p02963", "input_text": "let () =\n let main n =\n let s = n in\n let x1 = 0 in\n let y1 = 0 in\n let sq = int_of_float (ceil (sqrt (float (s)))) in\n let rec loop offs =\n let x2 = sq + offs in\n let y3 = sq - offs in\n let sq2 = x2 * y3 - s in\n if x2 > 1_000_000_000 || sq2 < 0 then failwith \"??\" else\n let rec loop_2 sq3 count =\n if count > 1000000 || sq3 > sq2 then loop (offs + 1) else\n if sq2 mod sq3 = 0 then\n let x3 = sq3 in\n let y2 = sq2 / sq3 in\n x1, y1, x2, y2, x3, y3\n else loop_2 (sq3 + 1) (count + 1)\n in\n if sq2 = 0 then x1, y1, x2, 0, 0, y3 else\n let sq3 = int_of_float (floor (sqrt (float (sq2)))) in\n loop_2 sq3 0\n in\n loop 0\n in\n let x1, y1, x2, y2, x3, y3 = main (int_of_string (read_line ())) in\n Printf.printf \"%d %d %d %d %d %d\\n\" x1 y1 x2 y2 x3 y3", "language": "OCaml", "metadata": {"date": 1563761843, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02963.html", "problem_id": "p02963", "resource_group": "low_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/OCaml/s395611151.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s395611151", "user_id": "u342443598"}, "prompt_components": {"gold_output": "1 0 2 2 0 1\n", "input_to_evaluate": "let () =\n let main n =\n let s = n in\n let x1 = 0 in\n let y1 = 0 in\n let sq = int_of_float (ceil (sqrt (float (s)))) in\n let rec loop offs =\n let x2 = sq + offs in\n let y3 = sq - offs in\n let sq2 = x2 * y3 - s in\n if x2 > 1_000_000_000 || sq2 < 0 then failwith \"??\" else\n let rec loop_2 sq3 count =\n if count > 1000000 || sq3 > sq2 then loop (offs + 1) else\n if sq2 mod sq3 = 0 then\n let x3 = sq3 in\n let y2 = sq2 / sq3 in\n x1, y1, x2, y2, x3, y3\n else loop_2 (sq3 + 1) (count + 1)\n in\n if sq2 = 0 then x1, y1, x2, 0, 0, y3 else\n let sq3 = int_of_float (floor (sqrt (float (sq2)))) in\n loop_2 sq3 0\n in\n loop 0\n in\n let x1, y1, x2, y2, x3, y3 = main (int_of_string (read_line ())) in\n Printf.printf \"%d %d %d %d %d %d\\n\" x1 y1 x2 y2 x3 y3", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1043, "cpu_time_ms": 15, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s402419601", "group_id": "codeNet:p02969", "input_text": "let () =\n let main () =\n let a = Scanf.sscanf (read_line ()) \"%d\" (fun a -> a) in\n let n = 3 * a * a in\n Printf.printf \"%d\\n\" n\n in\n main ()", "language": "OCaml", "metadata": {"date": 1563670870, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02969.html", "problem_id": "p02969", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02969/input.txt", "sample_output_relpath": "derived/input_output/data/p02969/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02969/OCaml/s402419601.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s402419601", "user_id": "u342443598"}, "prompt_components": {"gold_output": "48\n", "input_to_evaluate": "let () =\n let main () =\n let a = Scanf.sscanf (read_line ()) \"%d\" (fun a -> a) in\n let n = 3 * a * a in\n Printf.printf \"%d\\n\" n\n in\n main ()", "problem_context": "Score : 100 points\n\nProblem Statement\n\nIt is known that the area of a regular dodecagon inscribed in a circle of radius a is 3a^2.\n\nGiven an integer r, find the area of a regular dodecagon inscribed in a circle of radius r.\n\nConstraints\n\n1 \\leq r \\leq 100\n\nr is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nr\n\nOutput\n\nPrint an integer representing the area of the regular dodecagon.\n\nSample Input 1\n\n4\n\nSample Output 1\n\n48\n\nThe area of the regular dodecagon is 3 \\times 4^2 = 48.\n\nSample Input 2\n\n15\n\nSample Output 2\n\n675\n\nSample Input 3\n\n80\n\nSample Output 3\n\n19200", "sample_input": "4\n"}, "reference_outputs": ["48\n"], "source_document_id": "p02969", "source_text": "Score : 100 points\n\nProblem Statement\n\nIt is known that the area of a regular dodecagon inscribed in a circle of radius a is 3a^2.\n\nGiven an integer r, find the area of a regular dodecagon inscribed in a circle of radius r.\n\nConstraints\n\n1 \\leq r \\leq 100\n\nr is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nr\n\nOutput\n\nPrint an integer representing the area of the regular dodecagon.\n\nSample Input 1\n\n4\n\nSample Output 1\n\n48\n\nThe area of the regular dodecagon is 3 \\times 4^2 = 48.\n\nSample Input 2\n\n15\n\nSample Output 2\n\n675\n\nSample Input 3\n\n80\n\nSample Output 3\n\n19200", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s562070599", "group_id": "codeNet:p02970", "input_text": "let () = Scanf.scanf \"%d %d\" @@ fun n d -> Printf.printf \"%d\\n\" @@ (n + 2 * d) / (2 * d + 1)", "language": "OCaml", "metadata": {"date": 1597150575, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p02970.html", "problem_id": "p02970", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02970/input.txt", "sample_output_relpath": "derived/input_output/data/p02970/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02970/OCaml/s562070599.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s562070599", "user_id": "u052332717"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "let () = Scanf.scanf \"%d %d\" @@ fun n d -> Printf.printf \"%d\\n\" @@ (n + 2 * d) / (2 * d + 1)", "problem_context": "Score : 200 points\n\nProblem Statement\n\nThere are N apple trees in a row. People say that one of them will bear golden apples.\n\nWe want to deploy some number of inspectors so that each of these trees will be inspected.\n\nEach inspector will be deployed under one of the trees. For convenience, we will assign numbers from 1 through N to the trees. An inspector deployed under the i-th tree (1 \\leq i \\leq N) will inspect the trees with numbers between i-D and i+D (inclusive).\n\nFind the minimum number of inspectors that we need to deploy to achieve the objective.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 20\n\n1 \\leq D \\leq 20\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN D\n\nOutput\n\nPrint the minimum number of inspectors that we need to deploy to achieve the objective.\n\nSample Input 1\n\n6 2\n\nSample Output 1\n\n2\n\nWe can achieve the objective by, for example, placing an inspector under Tree 3 and Tree 4.\n\nSample Input 2\n\n14 3\n\nSample Output 2\n\n2\n\nSample Input 3\n\n20 4\n\nSample Output 3\n\n3", "sample_input": "6 2\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02970", "source_text": "Score : 200 points\n\nProblem Statement\n\nThere are N apple trees in a row. People say that one of them will bear golden apples.\n\nWe want to deploy some number of inspectors so that each of these trees will be inspected.\n\nEach inspector will be deployed under one of the trees. For convenience, we will assign numbers from 1 through N to the trees. An inspector deployed under the i-th tree (1 \\leq i \\leq N) will inspect the trees with numbers between i-D and i+D (inclusive).\n\nFind the minimum number of inspectors that we need to deploy to achieve the objective.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 20\n\n1 \\leq D \\leq 20\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN D\n\nOutput\n\nPrint the minimum number of inspectors that we need to deploy to achieve the objective.\n\nSample Input 1\n\n6 2\n\nSample Output 1\n\n2\n\nWe can achieve the objective by, for example, placing an inspector under Tree 3 and Tree 4.\n\nSample Input 2\n\n14 3\n\nSample Output 2\n\n2\n\nSample Input 3\n\n20 4\n\nSample Output 3\n\n3", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 10, "memory_kb": 3836}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s973361785", "group_id": "codeNet:p02972", "input_text": "let () = Scanf.scanf \"%d\\n\" @@ fun n ->\n let as_ = Array.init n @@ fun _ -> Scanf.scanf \"%d \" @@ fun a -> a in\n let ans = Array.make (n + 1) 0 in\n for i = n downto 1 do\n ans.(i) <- Array.fold_left ( lxor ) as_.(i - 1) @@\n Array.init (n / i - 1) @@ fun j -> as_.(i * (j + 2) - 1)\n done;\n match Array.fold_left ( + ) 0 ans with\n | 0 -> print_endline \"0\"\n | n ->\n Printf.printf \"%d\\n\" n;\n for i = 1 to n do\n if ans.(i) = 1 then Printf.printf \"%d \" i\n done;\n print_newline ()\n \n", "language": "OCaml", "metadata": {"date": 1563673385, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02972.html", "problem_id": "p02972", "resource_group": "low_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/OCaml/s973361785.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s973361785", "user_id": "u504158101"}, "prompt_components": {"gold_output": "1\n1\n", "input_to_evaluate": "let () = Scanf.scanf \"%d\\n\" @@ fun n ->\n let as_ = Array.init n @@ fun _ -> Scanf.scanf \"%d \" @@ fun a -> a in\n let ans = Array.make (n + 1) 0 in\n for i = n downto 1 do\n ans.(i) <- Array.fold_left ( lxor ) as_.(i - 1) @@\n Array.init (n / i - 1) @@ fun j -> as_.(i * (j + 2) - 1)\n done;\n match Array.fold_left ( + ) 0 ans with\n | 0 -> print_endline \"0\"\n | n ->\n Printf.printf \"%d\\n\" n;\n for i = 1 to n do\n if ans.(i) = 1 then Printf.printf \"%d \" i\n done;\n print_newline ()\n \n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nThere are N empty boxes arranged in a row from left to right.\nThe integer i is written on the i-th box from the left (1 \\leq i \\leq N).\n\nFor each of these boxes, Snuke can choose either to put a ball in it or to put nothing in it.\n\nWe say a set of choices to put a ball or not in the boxes is good when the following condition is satisfied:\n\nFor every integer i between 1 and N (inclusive), the total number of balls contained in the boxes with multiples of i written on them is congruent to a_i modulo 2.\n\nDoes there exist a good set of choices? If the answer is yes, find one good set of choices.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 2 \\times 10^5\n\na_i is 0 or 1.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 ... a_N\n\nOutput\n\nIf a good set of choices does not exist, print -1.\n\nIf a good set of choices exists, print one such set of choices in the following format:\n\nM\nb_1 b_2 ... b_M\n\nwhere M denotes the number of boxes that will contain a ball, and b_1,\\ b_2,\\ ...,\\ b_M are the integers written on these boxes, in any order.\n\nSample Input 1\n\n3\n1 0 0\n\nSample Output 1\n\n1\n1\n\nConsider putting a ball only in the box with 1 written on it.\n\nThere are three boxes with multiples of 1 written on them: the boxes with 1, 2, and 3. The total number of balls contained in these boxes is 1.\n\nThere is only one box with a multiple of 2 written on it: the box with 2. The total number of balls contained in these boxes is 0.\n\nThere is only one box with a multiple of 3 written on it: the box with 3. The total number of balls contained in these boxes is 0.\n\nThus, the condition is satisfied, so this set of choices is good.\n\nSample Input 2\n\n5\n0 0 0 0 0\n\nSample Output 2\n\n0\n\nPutting nothing in the boxes can be a good set of choices.", "sample_input": "3\n1 0 0\n"}, "reference_outputs": ["1\n1\n"], "source_document_id": "p02972", "source_text": "Score : 400 points\n\nProblem Statement\n\nThere are N empty boxes arranged in a row from left to right.\nThe integer i is written on the i-th box from the left (1 \\leq i \\leq N).\n\nFor each of these boxes, Snuke can choose either to put a ball in it or to put nothing in it.\n\nWe say a set of choices to put a ball or not in the boxes is good when the following condition is satisfied:\n\nFor every integer i between 1 and N (inclusive), the total number of balls contained in the boxes with multiples of i written on them is congruent to a_i modulo 2.\n\nDoes there exist a good set of choices? If the answer is yes, find one good set of choices.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 2 \\times 10^5\n\na_i is 0 or 1.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 ... a_N\n\nOutput\n\nIf a good set of choices does not exist, print -1.\n\nIf a good set of choices exists, print one such set of choices in the following format:\n\nM\nb_1 b_2 ... b_M\n\nwhere M denotes the number of boxes that will contain a ball, and b_1,\\ b_2,\\ ...,\\ b_M are the integers written on these boxes, in any order.\n\nSample Input 1\n\n3\n1 0 0\n\nSample Output 1\n\n1\n1\n\nConsider putting a ball only in the box with 1 written on it.\n\nThere are three boxes with multiples of 1 written on them: the boxes with 1, 2, and 3. The total number of balls contained in these boxes is 1.\n\nThere is only one box with a multiple of 2 written on it: the box with 2. The total number of balls contained in these boxes is 0.\n\nThere is only one box with a multiple of 3 written on it: the box with 3. The total number of balls contained in these boxes is 0.\n\nThus, the condition is satisfied, so this set of choices is good.\n\nSample Input 2\n\n5\n0 0 0 0 0\n\nSample Output 2\n\n0\n\nPutting nothing in the boxes can be a good set of choices.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 517, "cpu_time_ms": 97, "memory_kb": 13016}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s869867493", "group_id": "codeNet:p02975", "input_text": "module IntMap = Map.Make (struct\n type t = int\n let compare = compare\nend)\n\nlet remove a s =\n match IntMap.find a s with\n | exception Not_found -> s\n | 1 -> IntMap.remove a s\n | n -> IntMap.add a (n - 1) s\n\nlet add a s =\n IntMap.add a (1 + try IntMap.find a s with Not_found -> 0) s\n\nlet () = Scanf.scanf \"%d\\n\" @@ fun n ->\n let a :: as_ =\n Array.to_list @@\n Array.init n @@ fun _ -> Scanf.scanf \"%d \" @@ fun a -> a in\n print_endline @@\n if\n let s = List.fold_right add as_ IntMap.empty in\n let rec solve s a1 a2 = function\n | 0 -> a2 = a\n | n -> IntMap.mem a2 s && solve (remove a2 s) a2 (a1 lxor a2) (n - 1) in\n solve s a (fst (IntMap.min_binding s)) (n - 1)\n then \"Yes\"\n else \"No\"\n", "language": "OCaml", "metadata": {"date": 1568450340, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02975.html", "problem_id": "p02975", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02975/input.txt", "sample_output_relpath": "derived/input_output/data/p02975/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02975/OCaml/s869867493.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s869867493", "user_id": "u504158101"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "module IntMap = Map.Make (struct\n type t = int\n let compare = compare\nend)\n\nlet remove a s =\n match IntMap.find a s with\n | exception Not_found -> s\n | 1 -> IntMap.remove a s\n | n -> IntMap.add a (n - 1) s\n\nlet add a s =\n IntMap.add a (1 + try IntMap.find a s with Not_found -> 0) s\n\nlet () = Scanf.scanf \"%d\\n\" @@ fun n ->\n let a :: as_ =\n Array.to_list @@\n Array.init n @@ fun _ -> Scanf.scanf \"%d \" @@ fun a -> a in\n print_endline @@\n if\n let s = List.fold_right add as_ IntMap.empty in\n let rec solve s a1 a2 = function\n | 0 -> a2 = a\n | n -> IntMap.mem a2 s && solve (remove a2 s) a2 (a1 lxor a2) (n - 1) in\n solve s a (fst (IntMap.min_binding s)) (n - 1)\n then \"Yes\"\n else \"No\"\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nSnuke has N hats. The i-th hat has an integer a_i written on it.\n\nThere are N camels standing in a circle.\nSnuke will put one of his hats on each of these camels.\n\nIf there exists a way to distribute the hats to the camels such that the following condition is satisfied for every camel, print Yes; otherwise, print No.\n\nThe bitwise XOR of the numbers written on the hats on both adjacent camels is equal to the number on the hat on itself.\n\nWhat is XOR?\n\nThe bitwise XOR x_1 \\oplus x_2 \\oplus \\ldots \\oplus x_n of n non-negative integers x_1, x_2, \\ldots, x_n is defined as follows:\n\n- When x_1 \\oplus x_2 \\oplus \\ldots \\oplus x_n is written in base two, the digit in the 2^k's place (k \\geq 0) is 1 if the number of integers among x_1, x_2, \\ldots, x_n whose binary representations have 1 in the 2^k's place is odd, and 0 if that count is even.\n\nFor example, 3 \\oplus 5 = 6.\n\nConstraints\n\nAll values in input are integers.\n\n3 \\leq N \\leq 10^{5}\n\n0 \\leq a_i \\leq 10^{9}\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 \\ldots a_{N}\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n3\n1 2 3\n\nSample Output 1\n\nYes\n\nIf we put the hats with 1, 2, and 3 in this order, clockwise, the condition will be satisfied for every camel, so the answer is Yes.\n\nSample Input 2\n\n4\n1 2 4 8\n\nSample Output 2\n\nNo\n\nThere is no such way to distribute the hats; the answer is No.", "sample_input": "3\n1 2 3\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02975", "source_text": "Score : 300 points\n\nProblem Statement\n\nSnuke has N hats. The i-th hat has an integer a_i written on it.\n\nThere are N camels standing in a circle.\nSnuke will put one of his hats on each of these camels.\n\nIf there exists a way to distribute the hats to the camels such that the following condition is satisfied for every camel, print Yes; otherwise, print No.\n\nThe bitwise XOR of the numbers written on the hats on both adjacent camels is equal to the number on the hat on itself.\n\nWhat is XOR?\n\nThe bitwise XOR x_1 \\oplus x_2 \\oplus \\ldots \\oplus x_n of n non-negative integers x_1, x_2, \\ldots, x_n is defined as follows:\n\n- When x_1 \\oplus x_2 \\oplus \\ldots \\oplus x_n is written in base two, the digit in the 2^k's place (k \\geq 0) is 1 if the number of integers among x_1, x_2, \\ldots, x_n whose binary representations have 1 in the 2^k's place is odd, and 0 if that count is even.\n\nFor example, 3 \\oplus 5 = 6.\n\nConstraints\n\nAll values in input are integers.\n\n3 \\leq N \\leq 10^{5}\n\n0 \\leq a_i \\leq 10^{9}\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 \\ldots a_{N}\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n3\n1 2 3\n\nSample Output 1\n\nYes\n\nIf we put the hats with 1, 2, and 3 in this order, clockwise, the condition will be satisfied for every camel, so the answer is Yes.\n\nSample Input 2\n\n4\n1 2 4 8\n\nSample Output 2\n\nNo\n\nThere is no such way to distribute the hats; the answer is No.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 721, "cpu_time_ms": 130, "memory_kb": 15488}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s028925426", "group_id": "codeNet:p02977", "input_text": "let () =\n let main () =\n let n = int_of_string (read_line ()) in\n if n <> 1 && n mod 2 = 1 then (\n print_endline \"Yes\";\n for i = 1 to (n - 1) / 2 do\n Printf.printf \"%d %d\\n\" 1 (2 * i);\n Printf.printf \"%d %d\\n\" (2 * i) (2 * i + 1);\n Printf.printf \"%d %d\\n\" 1 (2 * i + 1 + n);\n Printf.printf \"%d %d\\n\" (2 * i + n) (2 * i + 1 + n);\n done;\n Printf.printf \"%d %d\\n\" 3 (n + 1)\n ) else if n > 3 && (n - 2) land (n - 3) = 0 then (\n print_endline \"Yes\";\n for i = 1 to (n - 4) / 2 do\n Printf.printf \"%d %d\\n\" 1 (2 * i);\n Printf.printf \"%d %d\\n\" (2 * i) (2 * i + 1);\n Printf.printf \"%d %d\\n\" 1 (2 * i + 1 + n);\n Printf.printf \"%d %d\\n\" (2 * i + n) (2 * i + 1 + n);\n done;\n Printf.printf \"%d %d\\n\" 3 (n + 1);\n Printf.printf \"%d %d\\n\" 3 (n + n - 1);\n Printf.printf \"%d %d\\n\" (n + 2) (n - 2);\n Printf.printf \"%d %d\\n\" (n - 2) (n - 1);\n Printf.printf \"%d %d\\n\" (n - 2) n;\n Printf.printf \"%d %d\\n\" (n + 2) (n + n);\n Printf.printf \"%d %d\\n\" (n + n) (n + n - 2);\n ) else print_endline \"No\"\n in\n main ()", "language": "OCaml", "metadata": {"date": 1563161120, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02977.html", "problem_id": "p02977", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02977/input.txt", "sample_output_relpath": "derived/input_output/data/p02977/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02977/OCaml/s028925426.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s028925426", "user_id": "u342443598"}, "prompt_components": {"gold_output": "Yes\n1 2\n2 3\n3 4\n4 5\n5 6\n", "input_to_evaluate": "let () =\n let main () =\n let n = int_of_string (read_line ()) in\n if n <> 1 && n mod 2 = 1 then (\n print_endline \"Yes\";\n for i = 1 to (n - 1) / 2 do\n Printf.printf \"%d %d\\n\" 1 (2 * i);\n Printf.printf \"%d %d\\n\" (2 * i) (2 * i + 1);\n Printf.printf \"%d %d\\n\" 1 (2 * i + 1 + n);\n Printf.printf \"%d %d\\n\" (2 * i + n) (2 * i + 1 + n);\n done;\n Printf.printf \"%d %d\\n\" 3 (n + 1)\n ) else if n > 3 && (n - 2) land (n - 3) = 0 then (\n print_endline \"Yes\";\n for i = 1 to (n - 4) / 2 do\n Printf.printf \"%d %d\\n\" 1 (2 * i);\n Printf.printf \"%d %d\\n\" (2 * i) (2 * i + 1);\n Printf.printf \"%d %d\\n\" 1 (2 * i + 1 + n);\n Printf.printf \"%d %d\\n\" (2 * i + n) (2 * i + 1 + n);\n done;\n Printf.printf \"%d %d\\n\" 3 (n + 1);\n Printf.printf \"%d %d\\n\" 3 (n + n - 1);\n Printf.printf \"%d %d\\n\" (n + 2) (n - 2);\n Printf.printf \"%d %d\\n\" (n - 2) (n - 1);\n Printf.printf \"%d %d\\n\" (n - 2) n;\n Printf.printf \"%d %d\\n\" (n + 2) (n + n);\n Printf.printf \"%d %d\\n\" (n + n) (n + n - 2);\n ) else print_endline \"No\"\n in\n main ()", "problem_context": "Score : 700 points\n\nProblem Statement\n\nYou are given an integer N. Determine if there exists a tree with 2N vertices numbered 1 to 2N satisfying the following condition, and show one such tree if the answer is yes.\n\nAssume that, for each integer i between 1 and N (inclusive), Vertex i and N+i have the weight i. Then, for each integer i between 1 and N, the bitwise XOR of the weights of the vertices on the path between Vertex i and N+i (including themselves) is i.\n\nConstraints\n\nN is an integer.\n\n1 \\leq N \\leq 10^{5}\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nIf there exists a tree satisfying the condition in the statement, print Yes; otherwise, print No.\nThen, if such a tree exists, print the 2N-1 edges of such a tree in the subsequent 2N-1 lines, in the following format:\n\na_{1} b_{1}\n\\vdots\na_{2N-1} b_{2N-1}\n\nHere each pair (a_i, b_i) means that there is an edge connecting Vertex a_i and b_i. The edges may be printed in any order.\n\nSample Input 1\n\n3\n\nSample Output 1\n\nYes\n1 2\n2 3\n3 4\n4 5\n5 6\n\nThe sample output represents the following graph:\n\nSample Input 2\n\n1\n\nSample Output 2\n\nNo\n\nThere is no tree satisfying the condition.", "sample_input": "3\n"}, "reference_outputs": ["Yes\n1 2\n2 3\n3 4\n4 5\n5 6\n"], "source_document_id": "p02977", "source_text": "Score : 700 points\n\nProblem Statement\n\nYou are given an integer N. Determine if there exists a tree with 2N vertices numbered 1 to 2N satisfying the following condition, and show one such tree if the answer is yes.\n\nAssume that, for each integer i between 1 and N (inclusive), Vertex i and N+i have the weight i. Then, for each integer i between 1 and N, the bitwise XOR of the weights of the vertices on the path between Vertex i and N+i (including themselves) is i.\n\nConstraints\n\nN is an integer.\n\n1 \\leq N \\leq 10^{5}\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nIf there exists a tree satisfying the condition in the statement, print Yes; otherwise, print No.\nThen, if such a tree exists, print the 2N-1 edges of such a tree in the subsequent 2N-1 lines, in the following format:\n\na_{1} b_{1}\n\\vdots\na_{2N-1} b_{2N-1}\n\nHere each pair (a_i, b_i) means that there is an edge connecting Vertex a_i and b_i. The edges may be printed in any order.\n\nSample Input 1\n\n3\n\nSample Output 1\n\nYes\n1 2\n2 3\n3 4\n4 5\n5 6\n\nThe sample output represents the following graph:\n\nSample Input 2\n\n1\n\nSample Output 2\n\nNo\n\nThere is no tree satisfying the condition.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1295, "cpu_time_ms": 86, "memory_kb": 4736}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s422178640", "group_id": "codeNet:p02981", "input_text": "let _ = Scanf.sscanf (read_line ()) \"%d %d %d\" (fun n a b -> \n match n * a with\n | x when x < b -> print_endline (string_of_int (x))\n | _ -> print_endline (string_of_int b)\n)", "language": "OCaml", "metadata": {"date": 1583931768, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02981.html", "problem_id": "p02981", "resource_group": "low_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/OCaml/s422178640.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s422178640", "user_id": "u511870776"}, "prompt_components": {"gold_output": "8\n", "input_to_evaluate": "let _ = Scanf.sscanf (read_line ()) \"%d %d %d\" (fun n a b -> \n match n * a with\n | x when x < b -> print_endline (string_of_int (x))\n | _ -> print_endline (string_of_int 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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s364160926", "group_id": "codeNet:p02982", "input_text": "let is_integer xs ys =\n let dim = Array.length xs in\n let sq_dist = Array.fold_left ( + ) 0 @@\n Array.init dim @@ fun i -> (xs.(i) - ys.(i)) * (xs.(i) - ys.(i)) in\n let check = Array.exists (fun d -> d * d = sq_dist) (Array.init 44 @@ fun i -> (i + 1)) in\n if check then 1 else 0\n\nlet () = Scanf.scanf \"%d %d\\n\" @@ fun n d ->\n let points =\n Array.init n @@ fun _ ->\n Array.init d @@ fun _ -> Scanf.scanf \" %d\" Fun.id in\n let check_boxes =\n Array.init (n - 1) @@ fun i ->\n Array.init (n - 1 - i) @@ fun j -> is_integer points.(i) points.(i + j + 1) in\n let ans = \n Array.fold_left (Array.fold_left ( + )) 0 check_boxes in\n Printf.printf \"%d\\n\" ans \n\n\n(*\n Array.fold_left: ('a -> 'b -> 'a) -> 'a -> 'b array -> 'a\n 1つ目の fold_left は (int -> int array -> int) -> int -> int array array -> int\n 2つ目の fold_left は ( + ) を渡しているので ('a -> 'a array -> 'a) になる\n ここで期待するのは int -> int list -> int\n*)\n\n", "language": "OCaml", "metadata": {"date": 1597255897, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p02982.html", "problem_id": "p02982", "resource_group": "low_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/OCaml/s364160926.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s364160926", "user_id": "u052332717"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "let is_integer xs ys =\n let dim = Array.length xs in\n let sq_dist = Array.fold_left ( + ) 0 @@\n Array.init dim @@ fun i -> (xs.(i) - ys.(i)) * (xs.(i) - ys.(i)) in\n let check = Array.exists (fun d -> d * d = sq_dist) (Array.init 44 @@ fun i -> (i + 1)) in\n if check then 1 else 0\n\nlet () = Scanf.scanf \"%d %d\\n\" @@ fun n d ->\n let points =\n Array.init n @@ fun _ ->\n Array.init d @@ fun _ -> Scanf.scanf \" %d\" Fun.id in\n let check_boxes =\n Array.init (n - 1) @@ fun i ->\n Array.init (n - 1 - i) @@ fun j -> is_integer points.(i) points.(i + j + 1) in\n let ans = \n Array.fold_left (Array.fold_left ( + )) 0 check_boxes in\n Printf.printf \"%d\\n\" ans \n\n\n(*\n Array.fold_left: ('a -> 'b -> 'a) -> 'a -> 'b array -> 'a\n 1つ目の fold_left は (int -> int array -> int) -> int -> int array array -> int\n 2つ目の fold_left は ( + ) を渡しているので ('a -> 'a array -> 'a) になる\n ここで期待するのは int -> int list -> int\n*)\n\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nThere are N points in a D-dimensional space.\n\nThe coordinates of the i-th point are (X_{i1}, X_{i2}, ..., X_{iD}).\n\nThe distance between two points with coordinates (y_1, y_2, ..., y_D) and (z_1, z_2, ..., z_D) is \\sqrt{(y_1 - z_1)^2 + (y_2 - z_2)^2 + ... + (y_D - z_D)^2}.\n\nHow many pairs (i, j) (i < j) are there such that the distance between the i-th point and the j-th point is an integer?\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10\n\n1 \\leq D \\leq 10\n\n-20 \\leq X_{ij} \\leq 20\n\nNo two given points have the same coordinates. That is, if i \\neq j, there exists k such that X_{ik} \\neq X_{jk}.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN D\nX_{11} X_{12} ... X_{1D}\nX_{21} X_{22} ... X_{2D}\n\\vdots\nX_{N1} X_{N2} ... X_{ND}\n\nOutput\n\nPrint the number of pairs (i, j) (i < j) such that the distance between the i-th point and the j-th point is an integer.\n\nSample Input 1\n\n3 2\n1 2\n5 5\n-2 8\n\nSample Output 1\n\n1\n\nThe number of pairs with an integer distance is one, as follows:\n\nThe distance between the first point and the second point is \\sqrt{|1-5|^2 + |2-5|^2} = 5, which is an integer.\n\nThe distance between the second point and the third point is \\sqrt{|5-(-2)|^2 + |5-8|^2} = \\sqrt{58}, which is not an integer.\n\nThe distance between the third point and the first point is \\sqrt{|-2-1|^2+|8-2|^2} = 3\\sqrt{5}, which is not an integer.\n\nSample Input 2\n\n3 4\n-3 7 8 2\n-12 1 10 2\n-2 8 9 3\n\nSample Output 2\n\n2\n\nSample Input 3\n\n5 1\n1\n2\n3\n4\n5\n\nSample Output 3\n\n10", "sample_input": "3 2\n1 2\n5 5\n-2 8\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02982", "source_text": "Score : 200 points\n\nProblem Statement\n\nThere are N points in a D-dimensional space.\n\nThe coordinates of the i-th point are (X_{i1}, X_{i2}, ..., X_{iD}).\n\nThe distance between two points with coordinates (y_1, y_2, ..., y_D) and (z_1, z_2, ..., z_D) is \\sqrt{(y_1 - z_1)^2 + (y_2 - z_2)^2 + ... + (y_D - z_D)^2}.\n\nHow many pairs (i, j) (i < j) are there such that the distance between the i-th point and the j-th point is an integer?\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10\n\n1 \\leq D \\leq 10\n\n-20 \\leq X_{ij} \\leq 20\n\nNo two given points have the same coordinates. That is, if i \\neq j, there exists k such that X_{ik} \\neq X_{jk}.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN D\nX_{11} X_{12} ... X_{1D}\nX_{21} X_{22} ... X_{2D}\n\\vdots\nX_{N1} X_{N2} ... X_{ND}\n\nOutput\n\nPrint the number of pairs (i, j) (i < j) such that the distance between the i-th point and the j-th point is an integer.\n\nSample Input 1\n\n3 2\n1 2\n5 5\n-2 8\n\nSample Output 1\n\n1\n\nThe number of pairs with an integer distance is one, as follows:\n\nThe distance between the first point and the second point is \\sqrt{|1-5|^2 + |2-5|^2} = 5, which is an integer.\n\nThe distance between the second point and the third point is \\sqrt{|5-(-2)|^2 + |5-8|^2} = \\sqrt{58}, which is not an integer.\n\nThe distance between the third point and the first point is \\sqrt{|-2-1|^2+|8-2|^2} = 3\\sqrt{5}, which is not an integer.\n\nSample Input 2\n\n3 4\n-3 7 8 2\n-12 1 10 2\n-2 8 9 3\n\nSample Output 2\n\n2\n\nSample Input 3\n\n5 1\n1\n2\n3\n4\n5\n\nSample Output 3\n\n10", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 977, "cpu_time_ms": 11, "memory_kb": 3812}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s637536283", "group_id": "codeNet:p02982", "input_text": "let is_integer xs ys =\n let dim = Array.length xs in\n let sq_dist = Array.fold_left ( + ) 0 @@\n Array.init dim @@ fun i -> (xs.(i) - ys.(i)) * (xs.(i) - ys.(i)) in\n let check = Array.exists (fun d -> d * d = sq_dist) (Array.init 44 @@ fun i -> (i + 1)) in\n if check then 1 else 0\n\nlet () = Scanf.scanf \"%d %d\\n\" @@ fun n d ->\n let points =\n Array.init n @@ fun _ ->\n Array.init d @@ fun _ -> Scanf.scanf \" %d\" Fun.id in\n let check_boxes =\n Array.init (n - 1) @@ fun i ->\n Array.init (n - i) @@ fun j -> is_integer points.(i) points.(i + j) in\n let ans = \n Array.fold_left (Array.fold_left ( + )) 0 check_boxes in\n Printf.printf \"%d\\n\" ans \n\n\n(*\n Array.fold_left: ('a -> 'b -> 'a) -> 'a -> 'b array -> 'a\n 1つ目の fold_left は (int -> int array -> int) -> int -> int array array -> int\n 2つ目の fold_left は ( + ) を渡しているので ('a -> 'a array -> 'a) になる\n ここで期待するのは int -> int list -> int\n*)\n\n", "language": "OCaml", "metadata": {"date": 1597255626, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p02982.html", "problem_id": "p02982", "resource_group": "low_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/OCaml/s637536283.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s637536283", "user_id": "u052332717"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "let is_integer xs ys =\n let dim = Array.length xs in\n let sq_dist = Array.fold_left ( + ) 0 @@\n Array.init dim @@ fun i -> (xs.(i) - ys.(i)) * (xs.(i) - ys.(i)) in\n let check = Array.exists (fun d -> d * d = sq_dist) (Array.init 44 @@ fun i -> (i + 1)) in\n if check then 1 else 0\n\nlet () = Scanf.scanf \"%d %d\\n\" @@ fun n d ->\n let points =\n Array.init n @@ fun _ ->\n Array.init d @@ fun _ -> Scanf.scanf \" %d\" Fun.id in\n let check_boxes =\n Array.init (n - 1) @@ fun i ->\n Array.init (n - i) @@ fun j -> is_integer points.(i) points.(i + j) in\n let ans = \n Array.fold_left (Array.fold_left ( + )) 0 check_boxes in\n Printf.printf \"%d\\n\" ans \n\n\n(*\n Array.fold_left: ('a -> 'b -> 'a) -> 'a -> 'b array -> 'a\n 1つ目の fold_left は (int -> int array -> int) -> int -> int array array -> int\n 2つ目の fold_left は ( + ) を渡しているので ('a -> 'a array -> 'a) になる\n ここで期待するのは int -> int list -> int\n*)\n\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nThere are N points in a D-dimensional space.\n\nThe coordinates of the i-th point are (X_{i1}, X_{i2}, ..., X_{iD}).\n\nThe distance between two points with coordinates (y_1, y_2, ..., y_D) and (z_1, z_2, ..., z_D) is \\sqrt{(y_1 - z_1)^2 + (y_2 - z_2)^2 + ... + (y_D - z_D)^2}.\n\nHow many pairs (i, j) (i < j) are there such that the distance between the i-th point and the j-th point is an integer?\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10\n\n1 \\leq D \\leq 10\n\n-20 \\leq X_{ij} \\leq 20\n\nNo two given points have the same coordinates. That is, if i \\neq j, there exists k such that X_{ik} \\neq X_{jk}.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN D\nX_{11} X_{12} ... X_{1D}\nX_{21} X_{22} ... X_{2D}\n\\vdots\nX_{N1} X_{N2} ... X_{ND}\n\nOutput\n\nPrint the number of pairs (i, j) (i < j) such that the distance between the i-th point and the j-th point is an integer.\n\nSample Input 1\n\n3 2\n1 2\n5 5\n-2 8\n\nSample Output 1\n\n1\n\nThe number of pairs with an integer distance is one, as follows:\n\nThe distance between the first point and the second point is \\sqrt{|1-5|^2 + |2-5|^2} = 5, which is an integer.\n\nThe distance between the second point and the third point is \\sqrt{|5-(-2)|^2 + |5-8|^2} = \\sqrt{58}, which is not an integer.\n\nThe distance between the third point and the first point is \\sqrt{|-2-1|^2+|8-2|^2} = 3\\sqrt{5}, which is not an integer.\n\nSample Input 2\n\n3 4\n-3 7 8 2\n-12 1 10 2\n-2 8 9 3\n\nSample Output 2\n\n2\n\nSample Input 3\n\n5 1\n1\n2\n3\n4\n5\n\nSample Output 3\n\n10", "sample_input": "3 2\n1 2\n5 5\n-2 8\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02982", "source_text": "Score : 200 points\n\nProblem Statement\n\nThere are N points in a D-dimensional space.\n\nThe coordinates of the i-th point are (X_{i1}, X_{i2}, ..., X_{iD}).\n\nThe distance between two points with coordinates (y_1, y_2, ..., y_D) and (z_1, z_2, ..., z_D) is \\sqrt{(y_1 - z_1)^2 + (y_2 - z_2)^2 + ... + (y_D - z_D)^2}.\n\nHow many pairs (i, j) (i < j) are there such that the distance between the i-th point and the j-th point is an integer?\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10\n\n1 \\leq D \\leq 10\n\n-20 \\leq X_{ij} \\leq 20\n\nNo two given points have the same coordinates. That is, if i \\neq j, there exists k such that X_{ik} \\neq X_{jk}.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN D\nX_{11} X_{12} ... X_{1D}\nX_{21} X_{22} ... X_{2D}\n\\vdots\nX_{N1} X_{N2} ... X_{ND}\n\nOutput\n\nPrint the number of pairs (i, j) (i < j) such that the distance between the i-th point and the j-th point is an integer.\n\nSample Input 1\n\n3 2\n1 2\n5 5\n-2 8\n\nSample Output 1\n\n1\n\nThe number of pairs with an integer distance is one, as follows:\n\nThe distance between the first point and the second point is \\sqrt{|1-5|^2 + |2-5|^2} = 5, which is an integer.\n\nThe distance between the second point and the third point is \\sqrt{|5-(-2)|^2 + |5-8|^2} = \\sqrt{58}, which is not an integer.\n\nThe distance between the third point and the first point is \\sqrt{|-2-1|^2+|8-2|^2} = 3\\sqrt{5}, which is not an integer.\n\nSample Input 2\n\n3 4\n-3 7 8 2\n-12 1 10 2\n-2 8 9 3\n\nSample Output 2\n\n2\n\nSample Input 3\n\n5 1\n1\n2\n3\n4\n5\n\nSample Output 3\n\n10", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 969, "cpu_time_ms": 8, "memory_kb": 3868}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s373696439", "group_id": "codeNet:p02986", "input_text": "module IntMap = Map.Make (struct\n type t = int\n let compare = compare\nend)\n\nlet () = Scanf.scanf \"%d %d\\n\" @@ fun n q ->\n let es = Array.make n [] in\n for i = 0 to n - 2 do\n Scanf.scanf \"%d %d %d %d\\n\" @@ fun a b c d ->\n es.(a - 1) <- (b - 1, c, d) :: es.(a - 1);\n es.(b - 1) <- (a - 1, c, d) :: es.(b - 1)\n done;\n let dist = Array.make n (-1) in\n let count_colors = Array.make n IntMap.empty in\n let acc_colors = Array.make n IntMap.empty in\n let parent = Array.make_matrix 17 n 0 in\n let rec visit c cd d u v =\n if 0 <= dist.(v) then ()\n else begin\n dist.(v) <- d;\n parent.(0).(v) <- u;\n acc_colors.(v) <- cd;\n count_colors.(v) <- c;\n List.iter (fun (u, c', d') ->\n visit\n (IntMap.add c'\n (1 +\n try IntMap.find c' c\n with Not_found -> 0) c)\n (IntMap.add c'\n (d' +\n try IntMap.find c' c\n with Not_found -> 0) c)\n (d + d') v u) es.(v)\n end in\n visit IntMap.empty IntMap.empty 0 0 0;\n for i = 1 to 16 do\n for v = 0 to n - 1 do\n parent.(i).(v) <- parent.(i - 1).(parent.(i - 1).(v))\n done\n done;\n let rec lca u v = function\n | 0 ->\n if parent.(0).(u) = parent.(0).(v)\n then parent.(0).(u)\n else begin\n assert (parent.(1).(u) = parent.(1).(v));\n parent.(1).(u)\n end\n | i ->\n ( if parent.(i).(u) = parent.(i).(v)\n then lca u v\n else lca (parent.(i).(u)) (parent.(i).(u)) ) (i - 1) in\n for i = 0 to q - 1 do\n Scanf.scanf \"%d %d %d %d\\n\" @@ fun x y u v ->\n let w = lca (u - 1) (v - 1) 16 in\n Printf.printf \"%d\\n\" @@\n (dist.(u - 1) - (try IntMap.find x acc_colors.(u - 1) with Not_found -> 0) + y * (try IntMap.find x count_colors.(u - 1) with Not_found -> 0))\n + (dist.(v - 1) - (try IntMap.find x acc_colors.(v - 1) with Not_found -> 0) + y * (try IntMap.find x count_colors.(v - 1) with Not_found -> 0))\n - 2 * (dist.(w) - (try IntMap.find x acc_colors.(w) with Not_found -> 0) + y * (try IntMap.find x count_colors.(w) with Not_found -> 0))\n done\n\n", "language": "OCaml", "metadata": {"date": 1562553555, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02986.html", "problem_id": "p02986", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02986/input.txt", "sample_output_relpath": "derived/input_output/data/p02986/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02986/OCaml/s373696439.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s373696439", "user_id": "u504158101"}, "prompt_components": {"gold_output": "130\n200\n60\n", "input_to_evaluate": "module IntMap = Map.Make (struct\n type t = int\n let compare = compare\nend)\n\nlet () = Scanf.scanf \"%d %d\\n\" @@ fun n q ->\n let es = Array.make n [] in\n for i = 0 to n - 2 do\n Scanf.scanf \"%d %d %d %d\\n\" @@ fun a b c d ->\n es.(a - 1) <- (b - 1, c, d) :: es.(a - 1);\n es.(b - 1) <- (a - 1, c, d) :: es.(b - 1)\n done;\n let dist = Array.make n (-1) in\n let count_colors = Array.make n IntMap.empty in\n let acc_colors = Array.make n IntMap.empty in\n let parent = Array.make_matrix 17 n 0 in\n let rec visit c cd d u v =\n if 0 <= dist.(v) then ()\n else begin\n dist.(v) <- d;\n parent.(0).(v) <- u;\n acc_colors.(v) <- cd;\n count_colors.(v) <- c;\n List.iter (fun (u, c', d') ->\n visit\n (IntMap.add c'\n (1 +\n try IntMap.find c' c\n with Not_found -> 0) c)\n (IntMap.add c'\n (d' +\n try IntMap.find c' c\n with Not_found -> 0) c)\n (d + d') v u) es.(v)\n end in\n visit IntMap.empty IntMap.empty 0 0 0;\n for i = 1 to 16 do\n for v = 0 to n - 1 do\n parent.(i).(v) <- parent.(i - 1).(parent.(i - 1).(v))\n done\n done;\n let rec lca u v = function\n | 0 ->\n if parent.(0).(u) = parent.(0).(v)\n then parent.(0).(u)\n else begin\n assert (parent.(1).(u) = parent.(1).(v));\n parent.(1).(u)\n end\n | i ->\n ( if parent.(i).(u) = parent.(i).(v)\n then lca u v\n else lca (parent.(i).(u)) (parent.(i).(u)) ) (i - 1) in\n for i = 0 to q - 1 do\n Scanf.scanf \"%d %d %d %d\\n\" @@ fun x y u v ->\n let w = lca (u - 1) (v - 1) 16 in\n Printf.printf \"%d\\n\" @@\n (dist.(u - 1) - (try IntMap.find x acc_colors.(u - 1) with Not_found -> 0) + y * (try IntMap.find x count_colors.(u - 1) with Not_found -> 0))\n + (dist.(v - 1) - (try IntMap.find x acc_colors.(v - 1) with Not_found -> 0) + y * (try IntMap.find x count_colors.(v - 1) with Not_found -> 0))\n - 2 * (dist.(w) - (try IntMap.find x acc_colors.(w) with Not_found -> 0) + y * (try IntMap.find x count_colors.(w) with Not_found -> 0))\n done\n\n", "problem_context": "Score : 600 points\n\nProblem Statement\n\nThere is a tree with N vertices numbered 1 to N.\nThe i-th edge in this tree connects Vertex a_i and Vertex b_i, and the color and length of that edge are c_i and d_i, respectively.\nHere the color of each edge is represented by an integer between 1 and N-1 (inclusive). The same integer corresponds to the same color, and different integers correspond to different colors.\n\nAnswer the following Q queries:\n\nQuery j (1 \\leq j \\leq Q): assuming that the length of every edge whose color is x_j is changed to y_j, find the distance between Vertex u_j and Vertex v_j. (The changes of the lengths of edges do not affect the subsequent queries.)\n\nConstraints\n\n2 \\leq N \\leq 10^5\n\n1 \\leq Q \\leq 10^5\n\n1 \\leq a_i, b_i \\leq N\n\n1 \\leq c_i \\leq N-1\n\n1 \\leq d_i \\leq 10^4\n\n1 \\leq x_j \\leq N-1\n\n1 \\leq y_j \\leq 10^4\n\n1 \\leq u_j < v_j \\leq N\n\nThe given graph is a tree.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN Q\na_1 b_1 c_1 d_1\n:\na_{N-1} b_{N-1} c_{N-1} d_{N-1}\nx_1 y_1 u_1 v_1\n:\nx_Q y_Q u_Q v_Q\n\nOutput\n\nPrint Q lines. The j-th line (1 \\leq j \\leq Q) should contain the answer to Query j.\n\nSample Input 1\n\n5 3\n1 2 1 10\n1 3 2 20\n2 4 4 30\n5 2 1 40\n1 100 1 4\n1 100 1 5\n3 1000 3 4\n\nSample Output 1\n\n130\n200\n60\n\nThe graph in this input is as follows:\n\nHere the edges of Color 1 are shown as solid red lines, the edge of Color 2 is shown as a bold green line, and the edge of Color 4 is shown as a blue dashed line.\n\nQuery 1: Assuming that the length of every edge whose color is 1 is changed to 100, the distance between Vertex 1 and Vertex 4 is 100 + 30 = 130.\n\nQuery 2: Assuming that the length of every edge whose color is 1 is changed to 100, the distance between Vertex 1 and Vertex 5 is 100 + 100 = 200.\n\nQuery 3: Assuming that the length of every edge whose color is 3 is changed to 1000 (there is no such edge), the distance between Vertex 3 and Vertex 4 is 20 + 10 + 30 = 60. Note that the edges of Color 1 now have their original lengths.", "sample_input": "5 3\n1 2 1 10\n1 3 2 20\n2 4 4 30\n5 2 1 40\n1 100 1 4\n1 100 1 5\n3 1000 3 4\n"}, "reference_outputs": ["130\n200\n60\n"], "source_document_id": "p02986", "source_text": "Score : 600 points\n\nProblem Statement\n\nThere is a tree with N vertices numbered 1 to N.\nThe i-th edge in this tree connects Vertex a_i and Vertex b_i, and the color and length of that edge are c_i and d_i, respectively.\nHere the color of each edge is represented by an integer between 1 and N-1 (inclusive). The same integer corresponds to the same color, and different integers correspond to different colors.\n\nAnswer the following Q queries:\n\nQuery j (1 \\leq j \\leq Q): assuming that the length of every edge whose color is x_j is changed to y_j, find the distance between Vertex u_j and Vertex v_j. (The changes of the lengths of edges do not affect the subsequent queries.)\n\nConstraints\n\n2 \\leq N \\leq 10^5\n\n1 \\leq Q \\leq 10^5\n\n1 \\leq a_i, b_i \\leq N\n\n1 \\leq c_i \\leq N-1\n\n1 \\leq d_i \\leq 10^4\n\n1 \\leq x_j \\leq N-1\n\n1 \\leq y_j \\leq 10^4\n\n1 \\leq u_j < v_j \\leq N\n\nThe given graph is a tree.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN Q\na_1 b_1 c_1 d_1\n:\na_{N-1} b_{N-1} c_{N-1} d_{N-1}\nx_1 y_1 u_1 v_1\n:\nx_Q y_Q u_Q v_Q\n\nOutput\n\nPrint Q lines. The j-th line (1 \\leq j \\leq Q) should contain the answer to Query j.\n\nSample Input 1\n\n5 3\n1 2 1 10\n1 3 2 20\n2 4 4 30\n5 2 1 40\n1 100 1 4\n1 100 1 5\n3 1000 3 4\n\nSample Output 1\n\n130\n200\n60\n\nThe graph in this input is as follows:\n\nHere the edges of Color 1 are shown as solid red lines, the edge of Color 2 is shown as a bold green line, and the edge of Color 4 is shown as a blue dashed line.\n\nQuery 1: Assuming that the length of every edge whose color is 1 is changed to 100, the distance between Vertex 1 and Vertex 4 is 100 + 30 = 130.\n\nQuery 2: Assuming that the length of every edge whose color is 1 is changed to 100, the distance between Vertex 1 and Vertex 5 is 100 + 100 = 200.\n\nQuery 3: Assuming that the length of every edge whose color is 3 is changed to 1000 (there is no such edge), the distance between Vertex 3 and Vertex 4 is 20 + 10 + 30 = 60. Note that the edges of Color 1 now have their original lengths.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2132, "cpu_time_ms": 1008, "memory_kb": 116856}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s335525225", "group_id": "codeNet:p02987", "input_text": "let rec floor_sqrt acc acc_x_2_x_r sq_acc_minus_z r sq_r =\n if r = 0 then acc\n else\n let sq_acc_minus_z' = sq_acc_minus_z + acc_x_2_x_r + sq_r in\n ( if sq_acc_minus_z' <= 0 then\n floor_sqrt (acc + r) ((acc_x_2_x_r lsr 1) + sq_r) sq_acc_minus_z'\n else\n floor_sqrt acc (acc_x_2_x_r lsr 1) sq_acc_minus_z) (r lsr 1) (sq_r lsr 2)\nlet floor_sqrt z = floor_sqrt 0 0 (~-z) (1 lsl 30) (1 lsl 60)\n\nlet () = Scanf.scanf \"%d %d\\n\" @@ fun n d ->\n let xss =\n Array.init n @@ fun _ ->\n Array.init d @@ fun _ -> Scanf.scanf \"%d \" @@ fun x -> x in\n Printf.printf \"%d\\n\" @@ \n Array.fold_left (Array.fold_left ( + )) 0 @@\n Array.init n @@ fun i ->\n Array.init i @@ fun j ->\n let sqd = \n Array.fold_left ( + ) 0 @@ \n Array.init d @@ fun k ->\n (xss.(i).(k) - xss.(j).(k)) * (xss.(i).(k) - xss.(j).(k)) in\n let d = floor_sqrt sqd in\n if d * d = sqd then 1 else 0\n\n", "language": "OCaml", "metadata": {"date": 1597335699, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p02987.html", "problem_id": "p02987", "resource_group": "low_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/OCaml/s335525225.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s335525225", "user_id": "u052332717"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "let rec floor_sqrt acc acc_x_2_x_r sq_acc_minus_z r sq_r =\n if r = 0 then acc\n else\n let sq_acc_minus_z' = sq_acc_minus_z + acc_x_2_x_r + sq_r in\n ( if sq_acc_minus_z' <= 0 then\n floor_sqrt (acc + r) ((acc_x_2_x_r lsr 1) + sq_r) sq_acc_minus_z'\n else\n floor_sqrt acc (acc_x_2_x_r lsr 1) sq_acc_minus_z) (r lsr 1) (sq_r lsr 2)\nlet floor_sqrt z = floor_sqrt 0 0 (~-z) (1 lsl 30) (1 lsl 60)\n\nlet () = Scanf.scanf \"%d %d\\n\" @@ fun n d ->\n let xss =\n Array.init n @@ fun _ ->\n Array.init d @@ fun _ -> Scanf.scanf \"%d \" @@ fun x -> x in\n Printf.printf \"%d\\n\" @@ \n Array.fold_left (Array.fold_left ( + )) 0 @@\n Array.init n @@ fun i ->\n Array.init i @@ fun j ->\n let sqd = \n Array.fold_left ( + ) 0 @@ \n Array.init d @@ fun k ->\n (xss.(i).(k) - xss.(j).(k)) * (xss.(i).(k) - xss.(j).(k)) in\n let d = floor_sqrt sqd in\n if d * d = sqd then 1 else 0\n\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou are given a 4-character string S consisting of uppercase English letters.\nDetermine if S consists of exactly two kinds of characters which both appear twice in S.\n\nConstraints\n\nThe length of S is 4.\n\nS consists of uppercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nIf S consists of exactly two kinds of characters which both appear twice in S, print Yes; otherwise, print No.\n\nSample Input 1\n\nASSA\n\nSample Output 1\n\nYes\n\nS consists of A and S which both appear twice in S.\n\nSample Input 2\n\nSTOP\n\nSample Output 2\n\nNo\n\nSample Input 3\n\nFFEE\n\nSample Output 3\n\nYes\n\nSample Input 4\n\nFREE\n\nSample Output 4\n\nNo", "sample_input": "ASSA\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p02987", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou are given a 4-character string S consisting of uppercase English letters.\nDetermine if S consists of exactly two kinds of characters which both appear twice in S.\n\nConstraints\n\nThe length of S is 4.\n\nS consists of uppercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nIf S consists of exactly two kinds of characters which both appear twice in S, print Yes; otherwise, print No.\n\nSample Input 1\n\nASSA\n\nSample Output 1\n\nYes\n\nS consists of A and S which both appear twice in S.\n\nSample Input 2\n\nSTOP\n\nSample Output 2\n\nNo\n\nSample Input 3\n\nFFEE\n\nSample Output 3\n\nYes\n\nSample Input 4\n\nFREE\n\nSample Output 4\n\nNo", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 923, "cpu_time_ms": 7, "memory_kb": 3832}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s696030814", "group_id": "codeNet:p02988", "input_text": "let () = Scanf.scanf \"%d\\n\" @@ fun n ->\n let ps = Array.init n @@ fun _ -> Scanf.scanf \"%d \" @@ fun p -> p in\n Printf.printf \"%d\\n\" @@\n List.length @@\n List.filter (fun b -> b) @@\n Array.to_list @@\n Array.init (n - 2) @@ fun i ->\n let ps' = [| ps.(i); ps.(i + 1); ps.(i + 2) |] in\n Array.sort compare ps';\n ps'.(1) = ps.(i + 1)", "language": "OCaml", "metadata": {"date": 1561856897, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02988.html", "problem_id": "p02988", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02988/input.txt", "sample_output_relpath": "derived/input_output/data/p02988/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02988/OCaml/s696030814.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s696030814", "user_id": "u504158101"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "let () = Scanf.scanf \"%d\\n\" @@ fun n ->\n let ps = Array.init n @@ fun _ -> Scanf.scanf \"%d \" @@ fun p -> p in\n Printf.printf \"%d\\n\" @@\n List.length @@\n List.filter (fun b -> b) @@\n Array.to_list @@\n Array.init (n - 2) @@ fun i ->\n let ps' = [| ps.(i); ps.(i + 1); ps.(i + 2) |] in\n Array.sort compare ps';\n ps'.(1) = ps.(i + 1)", "problem_context": "Score : 200 points\n\nProblem Statement\n\nWe have a permutation p = {p_1,\\ p_2,\\ ...,\\ p_n} of {1,\\ 2,\\ ...,\\ n}.\n\nPrint the number of elements p_i (1 < i < n) that satisfy the following condition:\n\np_i is the second smallest number among the three numbers p_{i - 1}, p_i, and p_{i + 1}.\n\nConstraints\n\nAll values in input are integers.\n\n3 \\leq n \\leq 20\n\np is a permutation of {1,\\ 2,\\ ...,\\ n}.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nn\np_1 p_2 ... p_n\n\nOutput\n\nPrint the number of elements p_i (1 < i < n) that satisfy the condition.\n\nSample Input 1\n\n5\n1 3 5 4 2\n\nSample Output 1\n\n2\n\np_2 = 3 is the second smallest number among p_1 = 1, p_2 = 3, and p_3 = 5. Also, p_4 = 4 is the second smallest number among p_3 = 5, p_4 = 4, and p_5 = 2. These two elements satisfy the condition.\n\nSample Input 2\n\n9\n9 6 3 2 5 8 7 4 1\n\nSample Output 2\n\n5", "sample_input": "5\n1 3 5 4 2\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02988", "source_text": "Score : 200 points\n\nProblem Statement\n\nWe have a permutation p = {p_1,\\ p_2,\\ ...,\\ p_n} of {1,\\ 2,\\ ...,\\ n}.\n\nPrint the number of elements p_i (1 < i < n) that satisfy the following condition:\n\np_i is the second smallest number among the three numbers p_{i - 1}, p_i, and p_{i + 1}.\n\nConstraints\n\nAll values in input are integers.\n\n3 \\leq n \\leq 20\n\np is a permutation of {1,\\ 2,\\ ...,\\ n}.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nn\np_1 p_2 ... p_n\n\nOutput\n\nPrint the number of elements p_i (1 < i < n) that satisfy the condition.\n\nSample Input 1\n\n5\n1 3 5 4 2\n\nSample Output 1\n\n2\n\np_2 = 3 is the second smallest number among p_1 = 1, p_2 = 3, and p_3 = 5. Also, p_4 = 4 is the second smallest number among p_3 = 5, p_4 = 4, and p_5 = 2. These two elements satisfy the condition.\n\nSample Input 2\n\n9\n9 6 3 2 5 8 7 4 1\n\nSample Output 2\n\n5", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 342, "cpu_time_ms": 1, "memory_kb": 2432}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s391799910", "group_id": "codeNet:p02989", "input_text": "let n = Scanf.scanf \" %d\" @@ (+) 0\nlet ds = Array.init n @@ fun _ -> Scanf.scanf \" %d\" @@ (+) 0\nlet _ =\n Array.sort (-) ds;\n ds.(n / 2) - ds.(n / 2 - 1) |> Printf.printf \"%d\\n\"", "language": "OCaml", "metadata": {"date": 1561858565, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02989.html", "problem_id": "p02989", "resource_group": "low_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/OCaml/s391799910.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s391799910", "user_id": "u732304692"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "let n = Scanf.scanf \" %d\" @@ (+) 0\nlet ds = Array.init n @@ fun _ -> Scanf.scanf \" %d\" @@ (+) 0\nlet _ =\n Array.sort (-) ds;\n ds.(n / 2) - ds.(n / 2 - 1) |> Printf.printf \"%d\\n\"", "problem_context": "Score : 300 points\n\nProblem Statement\n\nTakahashi made N problems for competitive programming.\nThe problems are numbered 1 to N, and the difficulty of Problem i is represented as an integer d_i (the higher, the harder).\n\nHe is dividing the problems into two categories by choosing an integer K, as follows:\n\nA problem with difficulty K or higher will be for ARCs.\n\nA problem with difficulty lower than K will be for ABCs.\n\nHow many choices of the integer K make the number of problems for ARCs and the number of problems for ABCs the same?\n\nProblem Statement\n\n2 \\leq N \\leq 10^5\n\nN is an even number.\n\n1 \\leq d_i \\leq 10^5\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nd_1 d_2 ... d_N\n\nOutput\n\nPrint the number of choices of the integer K that make the number of problems for ARCs and the number of problems for ABCs the same.\n\nSample Input 1\n\n6\n9 1 4 4 6 7\n\nSample Output 1\n\n2\n\nIf we choose K=5 or 6, Problem 1, 5, and 6 will be for ARCs, Problem 2, 3, and 4 will be for ABCs, and the objective is achieved.\nThus, the answer is 2.\n\nSample Input 2\n\n8\n9 1 14 5 5 4 4 14\n\nSample Output 2\n\n0\n\nThere may be no choice of the integer K that make the number of problems for ARCs and the number of problems for ABCs the same.\n\nSample Input 3\n\n14\n99592 10342 29105 78532 83018 11639 92015 77204 30914 21912 34519 80835 100000 1\n\nSample Output 3\n\n42685", "sample_input": "6\n9 1 4 4 6 7\n"}, "reference_outputs": ["2\n"], "source_document_id": "p02989", "source_text": "Score : 300 points\n\nProblem Statement\n\nTakahashi made N problems for competitive programming.\nThe problems are numbered 1 to N, and the difficulty of Problem i is represented as an integer d_i (the higher, the harder).\n\nHe is dividing the problems into two categories by choosing an integer K, as follows:\n\nA problem with difficulty K or higher will be for ARCs.\n\nA problem with difficulty lower than K will be for ABCs.\n\nHow many choices of the integer K make the number of problems for ARCs and the number of problems for ABCs the same?\n\nProblem Statement\n\n2 \\leq N \\leq 10^5\n\nN is an even number.\n\n1 \\leq d_i \\leq 10^5\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nd_1 d_2 ... d_N\n\nOutput\n\nPrint the number of choices of the integer K that make the number of problems for ARCs and the number of problems for ABCs the same.\n\nSample Input 1\n\n6\n9 1 4 4 6 7\n\nSample Output 1\n\n2\n\nIf we choose K=5 or 6, Problem 1, 5, and 6 will be for ARCs, Problem 2, 3, and 4 will be for ABCs, and the objective is achieved.\nThus, the answer is 2.\n\nSample Input 2\n\n8\n9 1 14 5 5 4 4 14\n\nSample Output 2\n\n0\n\nThere may be no choice of the integer K that make the number of problems for ARCs and the number of problems for ABCs the same.\n\nSample Input 3\n\n14\n99592 10342 29105 78532 83018 11639 92015 77204 30914 21912 34519 80835 100000 1\n\nSample Output 3\n\n42685", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 58, "memory_kb": 5248}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s581635132", "group_id": "codeNet:p02990", "input_text": "let m = 1000000000 + 7\n\nlet rec apb a b =\n if b = 0 then 1\n else\n (a * apb (a - 1) (b - 1))\n\nlet rec powab a b =\n if b = 0 then 1\n else\n (a * powab a (b - 1))\n\nlet nCr n r =\n (apb n r / apb r r) mod m\n \nlet () =\n let (n, k) = Scanf.sscanf (input_line stdin) \"%d %d\" (fun a b -> (a, b)) in\n let rec loop i =\n if i > k then ()\n else\n if k - i >= 0 && n - k - i + 1 >= 0 then\n let ans = (nCr (k - 1) (k - i) * nCr (n - k + 1) (n - k - i + 1)) mod m in\n (print_int ans;\n print_newline ();\n loop (i + 1))\n else\n (print_endline \"0\";\n loop (i + 1))\n in loop 1\n", "language": "OCaml", "metadata": {"date": 1561862192, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02990.html", "problem_id": "p02990", "resource_group": "low_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/OCaml/s581635132.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s581635132", "user_id": "u977566741"}, "prompt_components": {"gold_output": "3\n6\n1\n", "input_to_evaluate": "let m = 1000000000 + 7\n\nlet rec apb a b =\n if b = 0 then 1\n else\n (a * apb (a - 1) (b - 1))\n\nlet rec powab a b =\n if b = 0 then 1\n else\n (a * powab a (b - 1))\n\nlet nCr n r =\n (apb n r / apb r r) mod m\n \nlet () =\n let (n, k) = Scanf.sscanf (input_line stdin) \"%d %d\" (fun a b -> (a, b)) in\n let rec loop i =\n if i > k then ()\n else\n if k - i >= 0 && n - k - i + 1 >= 0 then\n let ans = (nCr (k - 1) (k - i) * nCr (n - k + 1) (n - k - i + 1)) mod m in\n (print_int ans;\n print_newline ();\n loop (i + 1))\n else\n (print_endline \"0\";\n loop (i + 1))\n in loop 1\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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 628, "cpu_time_ms": 1, "memory_kb": 2432}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s112685855", "group_id": "codeNet:p02991", "input_text": "module PQ = Set.Make(struct type t = int * int * int let compare = compare end)\nlet () =\n Scanf.scanf \"%d %d\" @@ fun n m ->\n let g = Array.init n (fun _ -> []) in\n for _ = 1 to m do\n Scanf.scanf \" %d %d\" @@ fun u v ->\n g.(u-1) <- v-1 :: g.(u-1);\n done;\n Scanf.scanf \" %d %d\" @@ fun s t ->\n let s, t = s-1, t-1 in\n let dist = Array.init 3 (fun _ -> Array.make n (max_int / 3)) in\n let rec loop pq =\n if PQ.is_empty pq then () else\n let d,x,m = PQ.min_elt pq in\n let pq = PQ.remove (d,x,m) pq in\n if d > dist.(m).(x) then loop pq else begin\n let m = (m+1) mod 3 in\n List.fold_left (fun pq y -> \n if d+1 >= dist.(m).(y) then pq else begin\n dist.(m).(y) <- d+1;\n PQ.add (d+1, y, m) pq\n end\n ) pq g.(x) |> loop\n end\n in\n loop PQ.(singleton (0, s, 0));\n if dist.(0).(t) < max_int/3 then Printf.printf \"%d\\n\" (dist.(0).(t) / 3)\n else print_endline \"-1\"\n", "language": "OCaml", "metadata": {"date": 1561861357, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02991.html", "problem_id": "p02991", "resource_group": "low_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/OCaml/s112685855.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s112685855", "user_id": "u798181098"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "module PQ = Set.Make(struct type t = int * int * int let compare = compare end)\nlet () =\n Scanf.scanf \"%d %d\" @@ fun n m ->\n let g = Array.init n (fun _ -> []) in\n for _ = 1 to m do\n Scanf.scanf \" %d %d\" @@ fun u v ->\n g.(u-1) <- v-1 :: g.(u-1);\n done;\n Scanf.scanf \" %d %d\" @@ fun s t ->\n let s, t = s-1, t-1 in\n let dist = Array.init 3 (fun _ -> Array.make n (max_int / 3)) in\n let rec loop pq =\n if PQ.is_empty pq then () else\n let d,x,m = PQ.min_elt pq in\n let pq = PQ.remove (d,x,m) pq in\n if d > dist.(m).(x) then loop pq else begin\n let m = (m+1) mod 3 in\n List.fold_left (fun pq y -> \n if d+1 >= dist.(m).(y) then pq else begin\n dist.(m).(y) <- d+1;\n PQ.add (d+1, y, m) pq\n end\n ) pq g.(x) |> loop\n end\n in\n loop PQ.(singleton (0, s, 0));\n if dist.(0).(t) < max_int/3 then Printf.printf \"%d\\n\" (dist.(0).(t) / 3)\n else print_endline \"-1\"\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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 926, "cpu_time_ms": 333, "memory_kb": 15232}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s396468763", "group_id": "codeNet:p02993", "input_text": "let i_inp : unit -> int = fun () ->\n int_of_string (input_line stdin)\nlet () =\n let s = i_inp () in\n let rec loop s n pred =\n if n = 0 then true\n else if s = 0 then false\n else\n let a = s mod 10 in\n if a = pred then false\n else loop (s / 10) (n - 1) a\n in\n if loop s 4 (-1) then\n print_endline \"Good\"\n else\n print_endline \"Bad\"\n ", "language": "OCaml", "metadata": {"date": 1561252163, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02993.html", "problem_id": "p02993", "resource_group": "low_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/OCaml/s396468763.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s396468763", "user_id": "u977566741"}, "prompt_components": {"gold_output": "Bad\n", "input_to_evaluate": "let i_inp : unit -> int = fun () ->\n int_of_string (input_line stdin)\nlet () =\n let s = i_inp () in\n let rec loop s n pred =\n if n = 0 then true\n else if s = 0 then false\n else\n let a = s mod 10 in\n if a = pred then false\n else loop (s / 10) (n - 1) a\n in\n if loop s 4 (-1) then\n print_endline \"Good\"\n else\n print_endline \"Bad\"\n ", "problem_context": "Score : 100 points\n\nProblem Statement\n\nThe door of Snuke's laboratory is locked with a security code.\n\nThe security code is a 4-digit number. We say the security code is hard to enter when it contains two consecutive digits that are the same.\n\nYou are given the current security code S. If S is hard to enter, print Bad; otherwise, print Good.\n\nConstraints\n\nS is a 4-character string consisting of digits.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nIf S is hard to enter, print Bad; otherwise, print Good.\n\nSample Input 1\n\n3776\n\nSample Output 1\n\nBad\n\nThe second and third digits are the same, so 3776 is hard to enter.\n\nSample Input 2\n\n8080\n\nSample Output 2\n\nGood\n\nThere are no two consecutive digits that are the same, so 8080 is not hard to enter.\n\nSample Input 3\n\n1333\n\nSample Output 3\n\nBad\n\nSample Input 4\n\n0024\n\nSample Output 4\n\nBad", "sample_input": "3776\n"}, "reference_outputs": ["Bad\n"], "source_document_id": "p02993", "source_text": "Score : 100 points\n\nProblem Statement\n\nThe door of Snuke's laboratory is locked with a security code.\n\nThe security code is a 4-digit number. We say the security code is hard to enter when it contains two consecutive digits that are the same.\n\nYou are given the current security code S. If S is hard to enter, print Bad; otherwise, print Good.\n\nConstraints\n\nS is a 4-character string consisting of digits.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nIf S is hard to enter, print Bad; otherwise, print Good.\n\nSample Input 1\n\n3776\n\nSample Output 1\n\nBad\n\nThe second and third digits are the same, so 3776 is hard to enter.\n\nSample Input 2\n\n8080\n\nSample Output 2\n\nGood\n\nThere are no two consecutive digits that are the same, so 8080 is not hard to enter.\n\nSample Input 3\n\n1333\n\nSample Output 3\n\nBad\n\nSample Input 4\n\n0024\n\nSample Output 4\n\nBad", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 370, "cpu_time_ms": 1, "memory_kb": 2432}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s890757977", "group_id": "codeNet:p02994", "input_text": "type apple_t = {abs_tst:int; id:int}\n\nlet () = Scanf.scanf \"%d %d\" @@ fun n l ->\n let abs_ary = Array.init n @@ fun i -> {abs_tst = abs (l + i); id = i} in\n let all = n * (l - 1) + (n * (n + 1) / 2) in\n let () = Array.sort compare abs_ary in\n let sub = l + abs_ary.(0).id in\n let ans = all - sub in\n Printf.printf \"%d\\n\" ans\n", "language": "OCaml", "metadata": {"date": 1597426302, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p02994.html", "problem_id": "p02994", "resource_group": "low_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/OCaml/s890757977.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s890757977", "user_id": "u052332717"}, "prompt_components": {"gold_output": "18\n", "input_to_evaluate": "type apple_t = {abs_tst:int; id:int}\n\nlet () = Scanf.scanf \"%d %d\" @@ fun n l ->\n let abs_ary = Array.init n @@ fun i -> {abs_tst = abs (l + i); id = i} in\n let all = n * (l - 1) + (n * (n + 1) / 2) in\n let () = Array.sort compare abs_ary in\n let sub = l + abs_ary.(0).id in\n let ans = all - sub in\n Printf.printf \"%d\\n\" ans\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nYou have N apples, called Apple 1, Apple 2, Apple 3, ..., Apple N. The flavor of Apple i is L+i-1, which can be negative.\n\nYou can make an apple pie using one or more of the apples. The flavor of the apple pie will be the sum of the flavors of the apples used.\n\nYou planned to make an apple pie using all of the apples, but being hungry tempts you to eat one of them, which can no longer be used to make the apple pie.\n\nYou want to make an apple pie that is as similar as possible to the one that you planned to make. Thus, you will choose the apple to eat so that the flavor of the apple pie made of the remaining N-1 apples will have the smallest possible absolute difference from the flavor of the apple pie made of all the N apples.\n\nFind the flavor of the apple pie made of the remaining N-1 apples when you choose the apple to eat as above.\n\nWe can prove that this value is uniquely determined.\n\nConstraints\n\n2 \\leq N \\leq 200\n\n-100 \\leq L \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN L\n\nOutput\n\nFind the flavor of the apple pie made of the remaining N-1 apples when you optimally choose the apple to eat.\n\nSample Input 1\n\n5 2\n\nSample Output 1\n\n18\n\nThe flavors of Apple 1, 2, 3, 4, and 5 are 2, 3, 4, 5, and 6, respectively. The optimal choice is to eat Apple 1, so the answer is 3+4+5+6=18.\n\nSample Input 2\n\n3 -1\n\nSample Output 2\n\n0\n\nThe flavors of Apple 1, 2, and 3 are -1, 0, and 1, respectively. The optimal choice is to eat Apple 2, so the answer is (-1)+1=0.\n\nSample Input 3\n\n30 -50\n\nSample Output 3\n\n-1044", "sample_input": "5 2\n"}, "reference_outputs": ["18\n"], "source_document_id": "p02994", "source_text": "Score : 200 points\n\nProblem Statement\n\nYou have N apples, called Apple 1, Apple 2, Apple 3, ..., Apple N. The flavor of Apple i is L+i-1, which can be negative.\n\nYou can make an apple pie using one or more of the apples. The flavor of the apple pie will be the sum of the flavors of the apples used.\n\nYou planned to make an apple pie using all of the apples, but being hungry tempts you to eat one of them, which can no longer be used to make the apple pie.\n\nYou want to make an apple pie that is as similar as possible to the one that you planned to make. Thus, you will choose the apple to eat so that the flavor of the apple pie made of the remaining N-1 apples will have the smallest possible absolute difference from the flavor of the apple pie made of all the N apples.\n\nFind the flavor of the apple pie made of the remaining N-1 apples when you choose the apple to eat as above.\n\nWe can prove that this value is uniquely determined.\n\nConstraints\n\n2 \\leq N \\leq 200\n\n-100 \\leq L \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN L\n\nOutput\n\nFind the flavor of the apple pie made of the remaining N-1 apples when you optimally choose the apple to eat.\n\nSample Input 1\n\n5 2\n\nSample Output 1\n\n18\n\nThe flavors of Apple 1, 2, 3, 4, and 5 are 2, 3, 4, 5, and 6, respectively. The optimal choice is to eat Apple 1, so the answer is 3+4+5+6=18.\n\nSample Input 2\n\n3 -1\n\nSample Output 2\n\n0\n\nThe flavors of Apple 1, 2, and 3 are -1, 0, and 1, respectively. The optimal choice is to eat Apple 2, so the answer is (-1)+1=0.\n\nSample Input 3\n\n30 -50\n\nSample Output 3\n\n-1044", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 8, "memory_kb": 3824}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s252226921", "group_id": "codeNet:p02995", "input_text": "let split c s = (\n let res = ref [] in\n let i = ref 0 in\n let n = String.length s in\n while !i < n do\n let j = !i in\n while !i < n && s.[!i] <> c do i := !i + 1 done;\n res := String.sub s j (!i - j) :: !res;\n i := !i + 1;\n done;\n List.rev !res\n );;\n\nlet rec range a b = if a > b then [] else a :: range (a + 1) b;;\nlet read_ints () = read_line () |> split ' ' |> List.map int_of_string;;\n\nlet rec gcd x y = if y = 0 then x else gcd y (x mod y);;\nlet lcm x y = x / gcd x y * y;;\n\nlet [a; b; c; d] = read_ints ();;\nlet a = a - 1;;\n\nlet f x c d = x - x / c - x / d + x / lcm c d;;\n\nprint_int (f b c d - f a c d);;\nprint_newline ();;\n", "language": "OCaml", "metadata": {"date": 1561374002, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02995.html", "problem_id": "p02995", "resource_group": "low_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/OCaml/s252226921.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s252226921", "user_id": "u006493569"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "let split c s = (\n let res = ref [] in\n let i = ref 0 in\n let n = String.length s in\n while !i < n do\n let j = !i in\n while !i < n && s.[!i] <> c do i := !i + 1 done;\n res := String.sub s j (!i - j) :: !res;\n i := !i + 1;\n done;\n List.rev !res\n );;\n\nlet rec range a b = if a > b then [] else a :: range (a + 1) b;;\nlet read_ints () = read_line () |> split ' ' |> List.map int_of_string;;\n\nlet rec gcd x y = if y = 0 then x else gcd y (x mod y);;\nlet lcm x y = x / gcd x y * y;;\n\nlet [a; b; c; d] = read_ints ();;\nlet a = a - 1;;\n\nlet f x c d = x - x / c - x / d + x / lcm c d;;\n\nprint_int (f b c d - f a c d);;\nprint_newline ();;\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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 669, "cpu_time_ms": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s170241661", "group_id": "codeNet:p02995", "input_text": "let () =\n let rec gcd a b = if b = 0 then a else gcd b (a mod b) in\n let lcm a b = let g = gcd a b in a / g * b in\n let calc a c d =\n let divisible_by_c = a / c in\n let divisible_by_d = a / d in\n let divisible_by_c_and_d = a / lcm c d in\n a - divisible_by_c - divisible_by_d + divisible_by_c_and_d\n in\n let main () =\n let a, b, c, d = Scanf.sscanf (read_line ()) \"%d %d %d %d\" (fun a b c d -> a, b, c, d) in\n let s = calc b c d - calc (a - 1) c d in\n Printf.printf \"%d\\n\" s\n in\n main ()", "language": "OCaml", "metadata": {"date": 1561231715, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02995.html", "problem_id": "p02995", "resource_group": "low_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/OCaml/s170241661.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s170241661", "user_id": "u342443598"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "let () =\n let rec gcd a b = if b = 0 then a else gcd b (a mod b) in\n let lcm a b = let g = gcd a b in a / g * b in\n let calc a c d =\n let divisible_by_c = a / c in\n let divisible_by_d = a / d in\n let divisible_by_c_and_d = a / lcm c d in\n a - divisible_by_c - divisible_by_d + divisible_by_c_and_d\n in\n let main () =\n let a, b, c, d = Scanf.sscanf (read_line ()) \"%d %d %d %d\" (fun a b c d -> a, b, c, d) in\n let s = calc b c d - calc (a - 1) c d in\n Printf.printf \"%d\\n\" s\n in\n main ()", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 556, "cpu_time_ms": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s167758124", "group_id": "codeNet:p02996", "input_text": "(* O(n log n) *)\nlet n = Scanf.scanf \" %d\" @@ (+) 0\nlet bas = Array.init n @@ fun i -> Scanf.scanf \" %d %d\" @@ fun a b -> b, a\nlet _ =\n Array.sort compare bas;\n Array.fold_left (fun t (b, a) -> if a + t > b then (print_endline \"No\"; exit 0) else a + t) 0 bas |> ignore;\n print_endline \"Yes\"", "language": "OCaml", "metadata": {"date": 1561243544, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02996.html", "problem_id": "p02996", "resource_group": "low_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/OCaml/s167758124.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s167758124", "user_id": "u732304692"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "(* O(n log n) *)\nlet n = Scanf.scanf \" %d\" @@ (+) 0\nlet bas = Array.init n @@ fun i -> Scanf.scanf \" %d %d\" @@ fun a b -> b, a\nlet _ =\n Array.sort compare bas;\n Array.fold_left (fun t (b, a) -> if a + t > b then (print_endline \"No\"; exit 0) else a + t) 0 bas |> ignore;\n print_endline \"Yes\"", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 293, "cpu_time_ms": 310, "memory_kb": 9600}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s332931501", "group_id": "codeNet:p02998", "input_text": "let n = read_int ();;\nlet g = Array.init 200000 (fun _ -> []);;\nlet visited = Array.make 200000 false;;\n\nfor i = 0 to n - 1 do\n let x, y = Scanf.scanf \" %d %d\" (fun x y -> x - 1, y - 1 + 100000) in\n g.(x) <- y :: g.(x);\n g.(y) <- x :: g.(y);\ndone\n\nlet rec dfs u cl cr = \n if not visited.(u) then (\n if u < 100000 then\n cl := !cl + 1\n else\n cr := !cr + 1;\n visited.(u) <- true;\n List.iter (fun v -> dfs v cl cr) g.(u);\n );;\n\n\nlet ans = ref (-n);;\nfor i = 0 to 199999 do\n let cl = ref 0 and cr = ref 0 in\n dfs i cl cr;\n ans := !ans + !cl * !cr;\ndone;;\n\nPrintf.printf \"%d\\n\" !ans;;\n", "language": "OCaml", "metadata": {"date": 1561375918, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p02998.html", "problem_id": "p02998", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p02998/input.txt", "sample_output_relpath": "derived/input_output/data/p02998/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p02998/OCaml/s332931501.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s332931501", "user_id": "u006493569"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "let n = read_int ();;\nlet g = Array.init 200000 (fun _ -> []);;\nlet visited = Array.make 200000 false;;\n\nfor i = 0 to n - 1 do\n let x, y = Scanf.scanf \" %d %d\" (fun x y -> x - 1, y - 1 + 100000) in\n g.(x) <- y :: g.(x);\n g.(y) <- x :: g.(y);\ndone\n\nlet rec dfs u cl cr = \n if not visited.(u) then (\n if u < 100000 then\n cl := !cl + 1\n else\n cr := !cr + 1;\n visited.(u) <- true;\n List.iter (fun v -> dfs v cl cr) g.(u);\n );;\n\n\nlet ans = ref (-n);;\nfor i = 0 to 199999 do\n let cl = ref 0 and cr = ref 0 in\n dfs i cl cr;\n ans := !ans + !cl * !cr;\ndone;;\n\nPrintf.printf \"%d\\n\" !ans;;\n", "problem_context": "Score : 600 points\n\nProblem Statement\n\nThere are N dots in a two-dimensional plane. The coordinates of the i-th dot are (x_i, y_i).\n\nWe will repeat the following operation as long as possible:\n\nChoose four integers a, b, c, d (a \\neq c, b \\neq d) such that there are dots at exactly three of the positions (a, b), (a, d), (c, b) and (c, d), and add a dot at the remaining position.\n\nWe can prove that we can only do this operation a finite number of times. Find the maximum number of times we can do the operation.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq x_i, y_i \\leq 10^5\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 maximum number of times we can do the operation.\n\nSample Input 1\n\n3\n1 1\n5 1\n5 5\n\nSample Output 1\n\n1\n\nBy choosing a = 1, b = 1, c = 5, d = 5, we can add a dot at (1, 5). We cannot do the operation any more, so the maximum number of operations is 1.\n\nSample Input 2\n\n2\n10 10\n20 20\n\nSample Output 2\n\n0\n\nThere are only two dots, so we cannot do the operation at all.\n\nSample Input 3\n\n9\n1 1\n2 1\n3 1\n4 1\n5 1\n1 2\n1 3\n1 4\n1 5\n\nSample Output 3\n\n16\n\nWe can do the operation for all choices of the form a = 1, b = 1, c = i, d = j (2 \\leq i,j \\leq 5), and no more. Thus, the maximum number of operations is 16.", "sample_input": "3\n1 1\n5 1\n5 5\n"}, "reference_outputs": ["1\n"], "source_document_id": "p02998", "source_text": "Score : 600 points\n\nProblem Statement\n\nThere are N dots in a two-dimensional plane. The coordinates of the i-th dot are (x_i, y_i).\n\nWe will repeat the following operation as long as possible:\n\nChoose four integers a, b, c, d (a \\neq c, b \\neq d) such that there are dots at exactly three of the positions (a, b), (a, d), (c, b) and (c, d), and add a dot at the remaining position.\n\nWe can prove that we can only do this operation a finite number of times. Find the maximum number of times we can do the operation.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq x_i, y_i \\leq 10^5\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 maximum number of times we can do the operation.\n\nSample Input 1\n\n3\n1 1\n5 1\n5 5\n\nSample Output 1\n\n1\n\nBy choosing a = 1, b = 1, c = 5, d = 5, we can add a dot at (1, 5). We cannot do the operation any more, so the maximum number of operations is 1.\n\nSample Input 2\n\n2\n10 10\n20 20\n\nSample Output 2\n\n0\n\nThere are only two dots, so we cannot do the operation at all.\n\nSample Input 3\n\n9\n1 1\n2 1\n3 1\n4 1\n5 1\n1 2\n1 3\n1 4\n1 5\n\nSample Output 3\n\n16\n\nWe can do the operation for all choices of the form a = 1, b = 1, c = i, d = j (2 \\leq i,j \\leq 5), and no more. Thus, the maximum number of operations is 16.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 609, "cpu_time_ms": 89, "memory_kb": 15488}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s845321298", "group_id": "codeNet:p02999", "input_text": "let () = Scanf.scanf \"%d %d\" @@ fun x a ->\n let ans = if x < a then 0 else 10 in\n Printf.printf \"%d\\n\" ans", "language": "OCaml", "metadata": {"date": 1597487635, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p02999.html", "problem_id": "p02999", "resource_group": "low_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/OCaml/s845321298.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s845321298", "user_id": "u052332717"}, "prompt_components": {"gold_output": "0\n", "input_to_evaluate": "let () = Scanf.scanf \"%d %d\" @@ fun x a ->\n let ans = if x < a then 0 else 10 in\n Printf.printf \"%d\\n\" ans", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 3812}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s879394903", "group_id": "codeNet:p03000", "input_text": "(* Vicfred\n * https://atcoder.jp/contests/abc130/tasks/abc130_b\n * implementation\n * *)\nScanf.scanf \"%d %d\\n\" @@ fun n x ->\n Array.init n (fun _ -> Scanf.scanf \" %d\" ( + ) 0)\n |> Array.fold_left (fun (a, b) c -> (if b + c <= x then a + 1 else a), b + c) (1, 0)\n |> fst\n |> Printf.printf \"%d\\n\"\n\n", "language": "OCaml", "metadata": {"date": 1594628827, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p03000.html", "problem_id": "p03000", "resource_group": "low_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/OCaml/s879394903.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s879394903", "user_id": "u737840172"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "(* Vicfred\n * https://atcoder.jp/contests/abc130/tasks/abc130_b\n * implementation\n * *)\nScanf.scanf \"%d %d\\n\" @@ fun n x ->\n Array.init n (fun _ -> Scanf.scanf \" %d\" ( + ) 0)\n |> Array.fold_left (fun (a, b) c -> (if b + c <= x then a + 1 else a), b + c) (1, 0)\n |> fst\n |> Printf.printf \"%d\\n\"\n\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nA ball will bounce along a number line, making N + 1 bounces. It will make the first bounce at coordinate D_1 = 0, and the i-th bounce (2 \\leq i \\leq N+1) at coordinate D_i = D_{i-1} + L_{i-1}.\n\nHow many times will the ball make a bounce where the coordinate is at most X?\n\nConstraints\n\n1 \\leq N \\leq 100\n\n1 \\leq L_i \\leq 100\n\n1 \\leq X \\leq 10000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN X\nL_1 L_2 ... L_{N-1} L_N\n\nOutput\n\nPrint the number of times the ball will make a bounce where the coordinate is at most X.\n\nSample Input 1\n\n3 6\n3 4 5\n\nSample Output 1\n\n2\n\nThe ball will make a bounce at the coordinates 0, 3, 7 and 12, among which two are less than or equal to 6.\n\nSample Input 2\n\n4 9\n3 3 3 3\n\nSample Output 2\n\n4\n\nThe ball will make a bounce at the coordinates 0, 3, 6, 9 and 12, among which four are less than or equal to 9.", "sample_input": "3 6\n3 4 5\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03000", "source_text": "Score : 200 points\n\nProblem Statement\n\nA ball will bounce along a number line, making N + 1 bounces. It will make the first bounce at coordinate D_1 = 0, and the i-th bounce (2 \\leq i \\leq N+1) at coordinate D_i = D_{i-1} + L_{i-1}.\n\nHow many times will the ball make a bounce where the coordinate is at most X?\n\nConstraints\n\n1 \\leq N \\leq 100\n\n1 \\leq L_i \\leq 100\n\n1 \\leq X \\leq 10000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN X\nL_1 L_2 ... L_{N-1} L_N\n\nOutput\n\nPrint the number of times the ball will make a bounce where the coordinate is at most X.\n\nSample Input 1\n\n3 6\n3 4 5\n\nSample Output 1\n\n2\n\nThe ball will make a bounce at the coordinates 0, 3, 7 and 12, among which two are less than or equal to 6.\n\nSample Input 2\n\n4 9\n3 3 3 3\n\nSample Output 2\n\n4\n\nThe ball will make a bounce at the coordinates 0, 3, 6, 9 and 12, among which four are less than or equal to 9.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 7, "memory_kb": 3848}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s143370396", "group_id": "codeNet:p03000", "input_text": "let n, x = Scanf.scanf \" %d %d\" @@ fun a b -> a, b\nlet ls = Array.init n @@ fun _ -> Scanf.scanf \" %d\" (+) 0\nlet d, i = ref 0, ref 0\nlet _ = while !d < x do d := !d + ls.(!i); incr i done; Printf.printf \"%d\\n\" @@ !i + if !d = x then 1 else 0", "language": "OCaml", "metadata": {"date": 1571178388, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03000.html", "problem_id": "p03000", "resource_group": "low_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/OCaml/s143370396.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s143370396", "user_id": "u732304692"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "let n, x = Scanf.scanf \" %d %d\" @@ fun a b -> a, b\nlet ls = Array.init n @@ fun _ -> Scanf.scanf \" %d\" (+) 0\nlet d, i = ref 0, ref 0\nlet _ = while !d < x do d := !d + ls.(!i); incr i done; Printf.printf \"%d\\n\" @@ !i + if !d = x then 1 else 0", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s484387480", "group_id": "codeNet:p03001", "input_text": "let () = Scanf.scanf \"%d %d %d %d\" @@ fun w h x y ->\n ( if w = 2 * x && h = 2 * y\n then Printf.printf \"%f 1\"\n else Printf.printf \"%f 0\" ) @@ 0.5 *. float_of_int w *. float_of_int h", "language": "OCaml", "metadata": {"date": 1560803380, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03001.html", "problem_id": "p03001", "resource_group": "low_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/OCaml/s484387480.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s484387480", "user_id": "u504158101"}, "prompt_components": {"gold_output": "3.000000 0\n", "input_to_evaluate": "let () = Scanf.scanf \"%d %d %d %d\" @@ fun w h x y ->\n ( if w = 2 * x && h = 2 * y\n then Printf.printf \"%f 1\"\n else Printf.printf \"%f 0\" ) @@ 0.5 *. float_of_int w *. float_of_int h", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s715271870", "group_id": "codeNet:p03001", "input_text": "let w, h, x, y = Scanf.scanf \" %d %d %d %d\" @@ fun a b c d -> a, b, c, d\nlet _ =\n Printf.printf \"%.12f \" @@ float w *. float h /. 2.;\n print_endline @@ if x * 2 = w && y * 2 = h then \"1\" else \"0\"", "language": "OCaml", "metadata": {"date": 1560715380, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03001.html", "problem_id": "p03001", "resource_group": "low_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/OCaml/s715271870.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s715271870", "user_id": "u732304692"}, "prompt_components": {"gold_output": "3.000000 0\n", "input_to_evaluate": "let w, h, x, y = Scanf.scanf \" %d %d %d %d\" @@ fun a b c d -> a, b, c, d\nlet _ =\n Printf.printf \"%.12f \" @@ float w *. float h /. 2.;\n print_endline @@ if x * 2 = w && y * 2 = h then \"1\" else \"0\"", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 197, "cpu_time_ms": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s471872300", "group_id": "codeNet:p03003", "input_text": "module Mod = struct\n module type S = sig val modulo : int end\n module Make (S : S) = struct\n open S\n let modulo = modulo\n let (+) a b = (a + b) mod modulo\n let ( * ) a b = (a * b) mod modulo\n let rec ( ** ) a n =\n if n = 0 then 1\n else if n mod 2 = 1 then a * a**(n-1)\n else let t = a ** (n/2) in t * t\n let inv a = a ** (modulo-2)\n end\nend\nmodule M = Mod.Make(struct let modulo = 1000000007 end)\n\nlet () =\n Scanf.scanf \"%d %d\" @@ fun n m ->\n let s = Array.init n (fun _ -> Scanf.scanf \" %d\" ((+) 0)) in\n let t = Array.init m (fun _ -> Scanf.scanf \" %d\" ((+) 0)) in\n let dp = Array.init (n+1) (fun _ -> Array.make (m+1) 0) in\n for i = 0 to n do\n for j = 0 to m do\n let open M in\n if i = 0 || j = 0 then dp.(i).(j) <- 1 else\n dp.(i).(j) <-\n if s.(i-1) = t.(j-1) then\n dp.(i).(j-1) + dp.(i-1).(j)\n else\n dp.(i).(j-1) + dp.(i-1).(j) + (modulo - dp.(i-1).(j-1));\n done;\n done;\n Printf.printf \"%d\\n\" dp.(n).(m)\n", "language": "OCaml", "metadata": {"date": 1560736869, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03003.html", "problem_id": "p03003", "resource_group": "low_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/OCaml/s471872300.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s471872300", "user_id": "u798181098"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "module Mod = struct\n module type S = sig val modulo : int end\n module Make (S : S) = struct\n open S\n let modulo = modulo\n let (+) a b = (a + b) mod modulo\n let ( * ) a b = (a * b) mod modulo\n let rec ( ** ) a n =\n if n = 0 then 1\n else if n mod 2 = 1 then a * a**(n-1)\n else let t = a ** (n/2) in t * t\n let inv a = a ** (modulo-2)\n end\nend\nmodule M = Mod.Make(struct let modulo = 1000000007 end)\n\nlet () =\n Scanf.scanf \"%d %d\" @@ fun n m ->\n let s = Array.init n (fun _ -> Scanf.scanf \" %d\" ((+) 0)) in\n let t = Array.init m (fun _ -> Scanf.scanf \" %d\" ((+) 0)) in\n let dp = Array.init (n+1) (fun _ -> Array.make (m+1) 0) in\n for i = 0 to n do\n for j = 0 to m do\n let open M in\n if i = 0 || j = 0 then dp.(i).(j) <- 1 else\n dp.(i).(j) <-\n if s.(i-1) = t.(j-1) then\n dp.(i).(j-1) + dp.(i-1).(j)\n else\n dp.(i).(j-1) + dp.(i-1).(j) + (modulo - dp.(i-1).(j-1));\n done;\n done;\n Printf.printf \"%d\\n\" dp.(n).(m)\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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1002, "cpu_time_ms": 164, "memory_kb": 33532}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s118197741", "group_id": "codeNet:p03005", "input_text": "let n, k = Scanf.scanf \" %d %d\" @@ fun a b -> a, b\nlet _ = Printf.printf \"%d\\n\" @@ if k = 1 then 0 else n - k", "language": "OCaml", "metadata": {"date": 1571193293, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03005.html", "problem_id": "p03005", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03005/input.txt", "sample_output_relpath": "derived/input_output/data/p03005/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03005/OCaml/s118197741.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s118197741", "user_id": "u732304692"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "let n, k = Scanf.scanf \" %d %d\" @@ fun a b -> a, b\nlet _ = Printf.printf \"%d\\n\" @@ if k = 1 then 0 else n - k", "problem_context": "Score : 100 points\n\nProblem Statement\n\nTakahashi is distributing N balls to K persons.\n\nIf each person has to receive at least one ball, what is the maximum possible difference in the number of balls received between the person with the most balls and the person with the fewest balls?\n\nConstraints\n\n1 \\leq K \\leq N \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\n\nOutput\n\nPrint the maximum possible difference in the number of balls received.\n\nSample Input 1\n\n3 2\n\nSample Output 1\n\n1\n\nThe only way to distribute three balls to two persons so that each of them receives at least one ball is to give one ball to one person and give two balls to the other person.\n\nThus, the maximum possible difference in the number of balls received is 1.\n\nSample Input 2\n\n3 1\n\nSample Output 2\n\n0\n\nWe have no choice but to give three balls to the only person, in which case the difference in the number of balls received is 0.\n\nSample Input 3\n\n8 5\n\nSample Output 3\n\n3\n\nFor example, if we give 1, 4, 1, 1, 1 balls to the five persons, the number of balls received between the person with the most balls and the person with the fewest balls would be 3, which is the maximum result.", "sample_input": "3 2\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03005", "source_text": "Score : 100 points\n\nProblem Statement\n\nTakahashi is distributing N balls to K persons.\n\nIf each person has to receive at least one ball, what is the maximum possible difference in the number of balls received between the person with the most balls and the person with the fewest balls?\n\nConstraints\n\n1 \\leq K \\leq N \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\n\nOutput\n\nPrint the maximum possible difference in the number of balls received.\n\nSample Input 1\n\n3 2\n\nSample Output 1\n\n1\n\nThe only way to distribute three balls to two persons so that each of them receives at least one ball is to give one ball to one person and give two balls to the other person.\n\nThus, the maximum possible difference in the number of balls received is 1.\n\nSample Input 2\n\n3 1\n\nSample Output 2\n\n0\n\nWe have no choice but to give three balls to the only person, in which case the difference in the number of balls received is 0.\n\nSample Input 3\n\n8 5\n\nSample Output 3\n\n3\n\nFor example, if we give 1, 4, 1, 1, 1 balls to the five persons, the number of balls received between the person with the most balls and the person with the fewest balls would be 3, which is the maximum result.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s392650341", "group_id": "codeNet:p03007", "input_text": "(* O(n log n) *)\nlet n = Scanf.scanf \" %d\" @@ (+) 0\nlet a_s = Array.init n @@ fun _ -> Scanf.scanf \" %d\" @@ (+) 0\nlet p = ref @@ -1\nlet xys = ref []\nlet _ =\n Array.sort (-) a_s;\n let i = ref 0 in while !p < 0 && !i < n do if a_s.(!i) >= 0 then p := !i; incr i done;\n if !p = -1 then p := n - 1\n else if !p = 0 then p := 1;\n for i = !p to n - 2 do\n xys := (a_s.(0), a_s.(i)) :: !xys;\n a_s.(0) <- a_s.(0) - a_s.(i)\n done;\n for i = 0 to !p - 1 do\n xys := (a_s.(n - 1), a_s.(i)) :: !xys;\n a_s.(n - 1) <- a_s.(n - 1) - a_s.(i)\n done;\n Printf.printf \"%d\\n\" a_s.(n - 1);\n List.rev !xys |> List.iter @@ fun (x, y) -> Printf.printf \"%d %d\\n\" x y", "language": "OCaml", "metadata": {"date": 1560805695, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03007.html", "problem_id": "p03007", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03007/input.txt", "sample_output_relpath": "derived/input_output/data/p03007/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03007/OCaml/s392650341.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s392650341", "user_id": "u732304692"}, "prompt_components": {"gold_output": "4\n-1 1\n2 -2\n", "input_to_evaluate": "(* O(n log n) *)\nlet n = Scanf.scanf \" %d\" @@ (+) 0\nlet a_s = Array.init n @@ fun _ -> Scanf.scanf \" %d\" @@ (+) 0\nlet p = ref @@ -1\nlet xys = ref []\nlet _ =\n Array.sort (-) a_s;\n let i = ref 0 in while !p < 0 && !i < n do if a_s.(!i) >= 0 then p := !i; incr i done;\n if !p = -1 then p := n - 1\n else if !p = 0 then p := 1;\n for i = !p to n - 2 do\n xys := (a_s.(0), a_s.(i)) :: !xys;\n a_s.(0) <- a_s.(0) - a_s.(i)\n done;\n for i = 0 to !p - 1 do\n xys := (a_s.(n - 1), a_s.(i)) :: !xys;\n a_s.(n - 1) <- a_s.(n - 1) - a_s.(i)\n done;\n Printf.printf \"%d\\n\" a_s.(n - 1);\n List.rev !xys |> List.iter @@ fun (x, y) -> Printf.printf \"%d %d\\n\" x y", "problem_context": "Score : 500 points\n\nProblem Statement\n\nThere are N integers, A_1, A_2, ..., A_N, written on a blackboard.\n\nWe will repeat the following operation N-1 times so that we have only one integer on the blackboard.\n\nChoose two integers x and y on the blackboard and erase these two integers. Then, write a new integer x-y.\n\nFind the maximum possible value of the final integer on the blackboard and a sequence of operations that maximizes the final integer.\n\nConstraints\n\n2 \\leq N \\leq 10^5\n\n-10^4 \\leq A_i \\leq 10^4\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the maximum possible value M of the final integer on the blackboard, and a sequence of operations x_i, y_i that maximizes the final integer, in the format below.\n\nHere x_i and y_i represent the integers x and y chosen in the i-th operation, respectively.\n\nIf there are multiple sequences of operations that maximize the final integer, any of them will be accepted.\n\nM\nx_1 y_1\n:\nx_{N-1} y_{N-1}\n\nSample Input 1\n\n3\n1 -1 2\n\nSample Output 1\n\n4\n-1 1\n2 -2\n\nIf we choose x = -1 and y = 1 in the first operation, the set of integers written on the blackboard becomes (-2, 2).\n\nThen, if we choose x = 2 and y = -2 in the second operation, the set of integers written on the blackboard becomes (4).\n\nIn this case, we have 4 as the final integer. We cannot end with a greater integer, so the answer is 4.\n\nSample Input 2\n\n3\n1 1 1\n\nSample Output 2\n\n1\n1 1\n1 0", "sample_input": "3\n1 -1 2\n"}, "reference_outputs": ["4\n-1 1\n2 -2\n"], "source_document_id": "p03007", "source_text": "Score : 500 points\n\nProblem Statement\n\nThere are N integers, A_1, A_2, ..., A_N, written on a blackboard.\n\nWe will repeat the following operation N-1 times so that we have only one integer on the blackboard.\n\nChoose two integers x and y on the blackboard and erase these two integers. Then, write a new integer x-y.\n\nFind the maximum possible value of the final integer on the blackboard and a sequence of operations that maximizes the final integer.\n\nConstraints\n\n2 \\leq N \\leq 10^5\n\n-10^4 \\leq A_i \\leq 10^4\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the maximum possible value M of the final integer on the blackboard, and a sequence of operations x_i, y_i that maximizes the final integer, in the format below.\n\nHere x_i and y_i represent the integers x and y chosen in the i-th operation, respectively.\n\nIf there are multiple sequences of operations that maximize the final integer, any of them will be accepted.\n\nM\nx_1 y_1\n:\nx_{N-1} y_{N-1}\n\nSample Input 1\n\n3\n1 -1 2\n\nSample Output 1\n\n4\n-1 1\n2 -2\n\nIf we choose x = -1 and y = 1 in the first operation, the set of integers written on the blackboard becomes (-2, 2).\n\nThen, if we choose x = 2 and y = -2 in the second operation, the set of integers written on the blackboard becomes (4).\n\nIn this case, we have 4 as the final integer. We cannot end with a greater integer, so the answer is 4.\n\nSample Input 2\n\n3\n1 1 1\n\nSample Output 2\n\n1\n1 1\n1 0", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 115, "memory_kb": 13056}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s649383038", "group_id": "codeNet:p03011", "input_text": "let () = Scanf.scanf \"%d %d %d\" @@ fun p q r ->\n Printf.printf \"%d\" @@ List.fold_left min max_int [p+q;q+r;r+p]\n\n \n", "language": "OCaml", "metadata": {"date": 1564972592, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03011.html", "problem_id": "p03011", "resource_group": "low_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/OCaml/s649383038.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s649383038", "user_id": "u604818425"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "let () = Scanf.scanf \"%d %d %d\" @@ fun p q r ->\n Printf.printf \"%d\" @@ List.fold_left min max_int [p+q;q+r;r+p]\n\n \n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nThere are three airports A, B and C, and flights between each pair of airports in both directions.\n\nA one-way flight between airports A and B takes P hours, a one-way flight between airports B and C takes Q hours, and a one-way flight between airports C and A takes R hours.\n\nConsider a route where we start at one of the airports, fly to another airport and then fly to the other airport.\n\nWhat is the minimum possible sum of the flight times?\n\nConstraints\n\n1 \\leq P,Q,R \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nP Q R\n\nOutput\n\nPrint the minimum possible sum of the flight times.\n\nSample Input 1\n\n1 3 4\n\nSample Output 1\n\n4\n\nThe sum of the flight times in the route A \\rightarrow B \\rightarrow C: 1 + 3 = 4 hours\n\nThe sum of the flight times in the route A \\rightarrow C \\rightarrow C: 4 + 3 = 7 hours\n\nThe sum of the flight times in the route B \\rightarrow A \\rightarrow C: 1 + 4 = 5 hours\n\nThe sum of the flight times in the route B \\rightarrow C \\rightarrow A: 3 + 4 = 7 hours\n\nThe sum of the flight times in the route C \\rightarrow A \\rightarrow B: 4 + 1 = 5 hours\n\nThe sum of the flight times in the route C \\rightarrow B \\rightarrow A: 3 + 1 = 4 hours\n\nThe minimum of these is 4 hours.\n\nSample Input 2\n\n3 2 3\n\nSample Output 2\n\n5", "sample_input": "1 3 4\n"}, "reference_outputs": ["4\n"], "source_document_id": "p03011", "source_text": "Score : 100 points\n\nProblem Statement\n\nThere are three airports A, B and C, and flights between each pair of airports in both directions.\n\nA one-way flight between airports A and B takes P hours, a one-way flight between airports B and C takes Q hours, and a one-way flight between airports C and A takes R hours.\n\nConsider a route where we start at one of the airports, fly to another airport and then fly to the other airport.\n\nWhat is the minimum possible sum of the flight times?\n\nConstraints\n\n1 \\leq P,Q,R \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nP Q R\n\nOutput\n\nPrint the minimum possible sum of the flight times.\n\nSample Input 1\n\n1 3 4\n\nSample Output 1\n\n4\n\nThe sum of the flight times in the route A \\rightarrow B \\rightarrow C: 1 + 3 = 4 hours\n\nThe sum of the flight times in the route A \\rightarrow C \\rightarrow C: 4 + 3 = 7 hours\n\nThe sum of the flight times in the route B \\rightarrow A \\rightarrow C: 1 + 4 = 5 hours\n\nThe sum of the flight times in the route B \\rightarrow C \\rightarrow A: 3 + 4 = 7 hours\n\nThe sum of the flight times in the route C \\rightarrow A \\rightarrow B: 4 + 1 = 5 hours\n\nThe sum of the flight times in the route C \\rightarrow B \\rightarrow A: 3 + 1 = 4 hours\n\nThe minimum of these is 4 hours.\n\nSample Input 2\n\n3 2 3\n\nSample Output 2\n\n5", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 2432}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s290362938", "group_id": "codeNet:p03013", "input_text": "let n, m = Scanf.scanf \" %d %d\" @@ fun a b -> a, b\nlet a_s = Array.init m @@ fun _ -> Scanf.scanf \" %d\" (+) 0\nlet dp = Array.make (n + 1) 0\nlet os = Array.make (n + 1) true\nlet f i v = if os.(i) then dp.(i) <- v\nlet _ = Array.iter (fun a -> os.(a) <- false) a_s; f 0 1; f 1 1;\n for i = 2 to n do f i @@ (dp.(i - 1) + dp.(i - 2)) mod 1000000007 done;\n Printf.printf \"%d\\n\" dp.(n)", "language": "OCaml", "metadata": {"date": 1563242383, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03013.html", "problem_id": "p03013", "resource_group": "low_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/OCaml/s290362938.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s290362938", "user_id": "u732304692"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "let n, m = Scanf.scanf \" %d %d\" @@ fun a b -> a, b\nlet a_s = Array.init m @@ fun _ -> Scanf.scanf \" %d\" (+) 0\nlet dp = Array.make (n + 1) 0\nlet os = Array.make (n + 1) true\nlet f i v = if os.(i) then dp.(i) <- v\nlet _ = Array.iter (fun a -> os.(a) <- false) a_s; f 0 1; f 1 1;\n for i = 2 to n do f i @@ (dp.(i - 1) + dp.(i - 2)) mod 1000000007 done;\n Printf.printf \"%d\\n\" dp.(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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 380, "cpu_time_ms": 28, "memory_kb": 6144}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s690321412", "group_id": "codeNet:p03013", "input_text": "open List \n(* 1行読み込みする関数 *)\n(* i_inp : 1行読み込んで整数に変換, f_inp, s_inpもある *)\nlet inp : unit -> string = fun () -> \n\tinput_line stdin\nlet s_inp = inp\nlet i_inp : unit -> int = fun () ->\n\tint_of_string (inp ())\nlet f_inp : unit -> float = fun () ->\n\tfloat_of_string (inp ())\n \n(* 1行読み込んで、空白で分割する関数 *)\nlet inp_list : unit -> string list = fun () ->\n\tStr.split (Str.regexp \" \") (inp ())\nlet s_inp_list : unit -> string list = inp_list\nlet i_inp_list : unit -> int list = fun () ->\n\tmap (fun x -> int_of_string x) (inp_list ())\nlet f_inp_list : unit -> float list = fun () ->\n map (fun x -> float_of_string x) (inp_list ())\n\n(* n行読み込む関数 *)\nlet rec inp_loop : (unit -> 'a) -> int -> 'a list = fun inp_fun n ->\n if n = 0 then []\n else\n let x = inp_fun () in\n x :: inp_loop inp_fun (n - 1) \n\n \n(* 関数本体 *)\nlet () =\n let [n; m] = i_inp_list () in\n let brokens = inp_loop (i_inp) m in\n let memo = Array.make (n + 1) None in\n let rec loop a =\n match memo.(a) with\n None ->\n if mem a brokens then 0\n else\n if a + 2 <= n then\n let x = (loop (a + 1) + loop (a + 2)) mod 1000000007 in\n memo.(a) <- Some x;\n x\n else if a + 1 <= n then\n let x = (loop (a + 1)) mod 1000000007 in\n memo.(a) <- Some x;\n x\n else\n (memo.(a) <- Some 1;\n 1)\n | Some x -> x\n in\n print_int (loop 0);\n print_newline ()", "language": "OCaml", "metadata": {"date": 1560614355, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03013.html", "problem_id": "p03013", "resource_group": "low_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/OCaml/s690321412.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s690321412", "user_id": "u977566741"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "open List \n(* 1行読み込みする関数 *)\n(* i_inp : 1行読み込んで整数に変換, f_inp, s_inpもある *)\nlet inp : unit -> string = fun () -> \n\tinput_line stdin\nlet s_inp = inp\nlet i_inp : unit -> int = fun () ->\n\tint_of_string (inp ())\nlet f_inp : unit -> float = fun () ->\n\tfloat_of_string (inp ())\n \n(* 1行読み込んで、空白で分割する関数 *)\nlet inp_list : unit -> string list = fun () ->\n\tStr.split (Str.regexp \" \") (inp ())\nlet s_inp_list : unit -> string list = inp_list\nlet i_inp_list : unit -> int list = fun () ->\n\tmap (fun x -> int_of_string x) (inp_list ())\nlet f_inp_list : unit -> float list = fun () ->\n map (fun x -> float_of_string x) (inp_list ())\n\n(* n行読み込む関数 *)\nlet rec inp_loop : (unit -> 'a) -> int -> 'a list = fun inp_fun n ->\n if n = 0 then []\n else\n let x = inp_fun () in\n x :: inp_loop inp_fun (n - 1) \n\n \n(* 関数本体 *)\nlet () =\n let [n; m] = i_inp_list () in\n let brokens = inp_loop (i_inp) m in\n let memo = Array.make (n + 1) None in\n let rec loop a =\n match memo.(a) with\n None ->\n if mem a brokens then 0\n else\n if a + 2 <= n then\n let x = (loop (a + 1) + loop (a + 2)) mod 1000000007 in\n memo.(a) <- Some x;\n x\n else if a + 1 <= n then\n let x = (loop (a + 1)) mod 1000000007 in\n memo.(a) <- Some x;\n x\n else\n (memo.(a) <- Some 1;\n 1)\n | Some x -> x\n in\n print_int (loop 0);\n print_newline ()", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 2104, "memory_kb": 9216}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s851682275", "group_id": "codeNet:p03014", "input_text": "(* O(h w) *)\nlet h, w = Scanf.scanf \" %d %d\" @@ fun a b -> a, b\nlet ss = Array.init h @@ fun _ -> Scanf.scanf \" %s\" @@ fun s -> s\nlet ys = Array.make_matrix h w 0\nlet xs = Array.make_matrix h w 0\nlet ans = ref 0\nlet _ =\n for y = 0 to h - 1 do\n let c = ref 0 in\n for x = 0 to w - 1 do\n if ss.(y).[x] = '#' then\n (for i = 1 to !c do\n xs.(y).(x - i) <- !c\n done;\n c := 0; xs.(y).(x) <- 0)\n else\n (incr c; xs.(y).(x) <- !c)\n done;\n for i = 1 to !c do\n xs.(y).(w - i) <- !c\n done\n done;\n for x = 0 to w - 1 do\n let c = ref 0 in\n for y = 0 to h - 1 do\n if ss.(y).[x] = '#' then\n (for i = 1 to !c do\n ys.(y - i).(x) <- !c\n done;\n c := 0; ys.(y).(x) <- 0)\n else\n (incr c; ys.(y).(x) <- !c)\n done;\n for i = 1 to !c do\n ys.(h - i).(x) <- !c\n done\n done;\n for y = 0 to h - 1 do\n for x = 0 to w - 1 do\n if ss.(y).[x] <> '#' then\n ans := max !ans @@ ys.(y).(x) + xs.(y).(x) - 1\n done\n done;\n Printf.printf \"%d\\n\" !ans", "language": "OCaml", "metadata": {"date": 1560135592, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03014.html", "problem_id": "p03014", "resource_group": "low_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/OCaml/s851682275.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s851682275", "user_id": "u732304692"}, "prompt_components": {"gold_output": "8\n", "input_to_evaluate": "(* O(h w) *)\nlet h, w = Scanf.scanf \" %d %d\" @@ fun a b -> a, b\nlet ss = Array.init h @@ fun _ -> Scanf.scanf \" %s\" @@ fun s -> s\nlet ys = Array.make_matrix h w 0\nlet xs = Array.make_matrix h w 0\nlet ans = ref 0\nlet _ =\n for y = 0 to h - 1 do\n let c = ref 0 in\n for x = 0 to w - 1 do\n if ss.(y).[x] = '#' then\n (for i = 1 to !c do\n xs.(y).(x - i) <- !c\n done;\n c := 0; xs.(y).(x) <- 0)\n else\n (incr c; xs.(y).(x) <- !c)\n done;\n for i = 1 to !c do\n xs.(y).(w - i) <- !c\n done\n done;\n for x = 0 to w - 1 do\n let c = ref 0 in\n for y = 0 to h - 1 do\n if ss.(y).[x] = '#' then\n (for i = 1 to !c do\n ys.(y - i).(x) <- !c\n done;\n c := 0; ys.(y).(x) <- 0)\n else\n (incr c; ys.(y).(x) <- !c)\n done;\n for i = 1 to !c do\n ys.(h - i).(x) <- !c\n done\n done;\n for y = 0 to h - 1 do\n for x = 0 to w - 1 do\n if ss.(y).[x] <> '#' then\n ans := max !ans @@ ys.(y).(x) + xs.(y).(x) - 1\n done\n done;\n Printf.printf \"%d\\n\" !ans", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1063, "cpu_time_ms": 331, "memory_kb": 71928}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s170909576", "group_id": "codeNet:p03016", "input_text": "let rec fold_for a b v f = if a >= b then v else fold_for (a+1) b (f a v) f\n\nlet rec pow ( * ) z a n =\n if n = 0 then z\n else if n mod 2 = 1 then a * (pow ( * ) z a (n-1))\n else let h = pow ( * ) z a (n/2) in h * h\n\nlet rec intpow = pow ( * ) 1\n\nlet i3 = [| [|1; 0; 0|]; [|0; 1; 0|]; [|0; 0; 1|] |]\n\nlet () =\n Scanf.scanf \"%d %d %d %d\" @@ fun l a b modulo ->\n \n let (+@) a b = (a + b + modulo) mod modulo in\n let modmul a b = (a * b) mod modulo in\n let modpow = pow modmul 1 in\n\n let matmul a b =\n let m = Array.length b in\n Array.init (Array.length a) (fun i ->\n Array.init (Array.length b.(0)) (fun j ->\n fold_for 0 m 0 (fun k s -> s +@ modmul a.(i).(k) b.(k).(j))))\n in\n\n let rec loop i d z =\n if i >= l then z else\n let j = (intpow 10 d - a - 1) / b |> min (l-1) in\n if a + b * j < intpow 10 (d-1) then loop i (d+1) z\n else ((\n let c = j-i+1 in\n let r = [| [| z; a +@ modmul b i; 1 |] |] in\n let m = [| [| modpow 10 d; 0; 0 |]; [| 1; 1; 0 |]; [| 0; b mod modulo; 1 |]; |] in\n let mc = pow matmul i3 m c in\n let r' = matmul r mc in\n loop (j+1) (d+1) r'.(0).(0)\n ))\n in\n\n loop 0 1 0 |> Printf.printf \"%d\\n\"\n\n", "language": "OCaml", "metadata": {"date": 1560143409, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03016.html", "problem_id": "p03016", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03016/input.txt", "sample_output_relpath": "derived/input_output/data/p03016/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03016/OCaml/s170909576.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s170909576", "user_id": "u798181098"}, "prompt_components": {"gold_output": "5563\n", "input_to_evaluate": "let rec fold_for a b v f = if a >= b then v else fold_for (a+1) b (f a v) f\n\nlet rec pow ( * ) z a n =\n if n = 0 then z\n else if n mod 2 = 1 then a * (pow ( * ) z a (n-1))\n else let h = pow ( * ) z a (n/2) in h * h\n\nlet rec intpow = pow ( * ) 1\n\nlet i3 = [| [|1; 0; 0|]; [|0; 1; 0|]; [|0; 0; 1|] |]\n\nlet () =\n Scanf.scanf \"%d %d %d %d\" @@ fun l a b modulo ->\n \n let (+@) a b = (a + b + modulo) mod modulo in\n let modmul a b = (a * b) mod modulo in\n let modpow = pow modmul 1 in\n\n let matmul a b =\n let m = Array.length b in\n Array.init (Array.length a) (fun i ->\n Array.init (Array.length b.(0)) (fun j ->\n fold_for 0 m 0 (fun k s -> s +@ modmul a.(i).(k) b.(k).(j))))\n in\n\n let rec loop i d z =\n if i >= l then z else\n let j = (intpow 10 d - a - 1) / b |> min (l-1) in\n if a + b * j < intpow 10 (d-1) then loop i (d+1) z\n else ((\n let c = j-i+1 in\n let r = [| [| z; a +@ modmul b i; 1 |] |] in\n let m = [| [| modpow 10 d; 0; 0 |]; [| 1; 1; 0 |]; [| 0; b mod modulo; 1 |]; |] in\n let mc = pow matmul i3 m c in\n let r' = matmul r mc in\n loop (j+1) (d+1) r'.(0).(0)\n ))\n in\n\n loop 0 1 0 |> Printf.printf \"%d\\n\"\n\n", "problem_context": "Score : 600 points\n\nProblem Statement\n\nThere is an arithmetic progression with L terms: s_0, s_1, s_2, ... , s_{L-1}.\n\nThe initial term is A, and the common difference is B. That is, s_i = A + B \\times i holds.\n\nConsider the integer obtained by concatenating the terms written in base ten without leading zeros. For example, the sequence 3, 7, 11, 15, 19 would be concatenated into 37111519. What is the remainder when that integer is divided by M?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq L, A, B < 10^{18}\n\n2 \\leq M \\leq 10^9\n\nAll terms in the arithmetic progression are less than 10^{18}.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nL A B M\n\nOutput\n\nPrint the remainder when the integer obtained by concatenating the terms is divided by M.\n\nSample Input 1\n\n5 3 4 10007\n\nSample Output 1\n\n5563\n\nOur arithmetic progression is 3, 7, 11, 15, 19, so the answer is 37111519 mod 10007, that is, 5563.\n\nSample Input 2\n\n4 8 1 1000000\n\nSample Output 2\n\n891011\n\nSample Input 3\n\n107 10000000000007 1000000000000007 998244353\n\nSample Output 3\n\n39122908", "sample_input": "5 3 4 10007\n"}, "reference_outputs": ["5563\n"], "source_document_id": "p03016", "source_text": "Score : 600 points\n\nProblem Statement\n\nThere is an arithmetic progression with L terms: s_0, s_1, s_2, ... , s_{L-1}.\n\nThe initial term is A, and the common difference is B. That is, s_i = A + B \\times i holds.\n\nConsider the integer obtained by concatenating the terms written in base ten without leading zeros. For example, the sequence 3, 7, 11, 15, 19 would be concatenated into 37111519. What is the remainder when that integer is divided by M?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq L, A, B < 10^{18}\n\n2 \\leq M \\leq 10^9\n\nAll terms in the arithmetic progression are less than 10^{18}.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nL A B M\n\nOutput\n\nPrint the remainder when the integer obtained by concatenating the terms is divided by M.\n\nSample Input 1\n\n5 3 4 10007\n\nSample Output 1\n\n5563\n\nOur arithmetic progression is 3, 7, 11, 15, 19, so the answer is 37111519 mod 10007, that is, 5563.\n\nSample Input 2\n\n4 8 1 1000000\n\nSample Output 2\n\n891011\n\nSample Input 3\n\n107 10000000000007 1000000000000007 998244353\n\nSample Output 3\n\n39122908", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1182, "cpu_time_ms": 2, "memory_kb": 1280}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s087271744", "group_id": "codeNet:p03017", "input_text": "let n, a, b, c, d, s = Scanf.scanf \" %d %d %d %d %d %s\" @@ fun a b c d e f -> a, b - 1, c - 1, d - 1, e - 1, f\nlet s2, s3 = String.sub s a @@ c - a + 1, String.sub s b @@ d - b + 1\nlet f s = try Str.search_forward (Str.regexp \"##\") s 0 |> ignore; false with _ -> true\nlet s4 = String.sub s (b - 1) @@ min (n - b + 1) @@ d - b + 3\nlet _ = print_endline @@ \n if f s2 && f s3 then\n if d < c then\n try Str.search_forward (Str.regexp \"\\\\.\\\\.\\\\.\") s4 0 |> ignore; \"Yes\" with _ -> \"No\"\n else \"Yes\"\n else \"No\"", "language": "OCaml", "metadata": {"date": 1562509529, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03017.html", "problem_id": "p03017", "resource_group": "low_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/OCaml/s087271744.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s087271744", "user_id": "u732304692"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "let n, a, b, c, d, s = Scanf.scanf \" %d %d %d %d %d %s\" @@ fun a b c d e f -> a, b - 1, c - 1, d - 1, e - 1, f\nlet s2, s3 = String.sub s a @@ c - a + 1, String.sub s b @@ d - b + 1\nlet f s = try Str.search_forward (Str.regexp \"##\") s 0 |> ignore; false with _ -> true\nlet s4 = String.sub s (b - 1) @@ min (n - b + 1) @@ d - b + 3\nlet _ = print_endline @@ \n if f s2 && f s3 then\n if d < c then\n try Str.search_forward (Str.regexp \"\\\\.\\\\.\\\\.\") s4 0 |> ignore; \"Yes\" with _ -> \"No\"\n else \"Yes\"\n else \"No\"", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 514, "cpu_time_ms": 6, "memory_kb": 3200}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s409571004", "group_id": "codeNet:p03023", "input_text": "let n = read_int ()\nlet _ = Printf.printf \"%d\\n\" (180*(n-2))", "language": "OCaml", "metadata": {"date": 1583853850, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03023.html", "problem_id": "p03023", "resource_group": "low_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/OCaml/s409571004.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s409571004", "user_id": "u511870776"}, "prompt_components": {"gold_output": "180\n", "input_to_evaluate": "let n = read_int ()\nlet _ = Printf.printf \"%d\\n\" (180*(n-2))", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s743229166", "group_id": "codeNet:p03024", "input_text": "let f s x = let n = ref 0 in String.iter (fun c -> if c = x then incr n) s; !n\nlet _ = print_endline @@ if f (read_line ()) 'x' > 7 then \"NO\" else \"YES\"", "language": "OCaml", "metadata": {"date": 1579032819, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03024.html", "problem_id": "p03024", "resource_group": "low_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/OCaml/s743229166.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s743229166", "user_id": "u732304692"}, "prompt_components": {"gold_output": "YES\n", "input_to_evaluate": "let f s x = let n = ref 0 in String.iter (fun c -> if c = x then incr n) s; !n\nlet _ = print_endline @@ if f (read_line ()) 'x' > 7 then \"NO\" else \"YES\"", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s084068614", "group_id": "codeNet:p03026", "input_text": "let split_string ?(pattern=\" \") = Str.split @@ Str.regexp pattern\n\nlet n = Scanf.sscanf (read_line ()) \"%d\" @@ fun n -> n\nlet ab = Array.init (n - 1) @@ fun _ -> Scanf.sscanf (read_line ()) \"%d %d\" @@ fun a b -> (a - 1, b - 1)\nlet c = List.sort (fun a b -> b - a) @@ List.map int_of_string @@ split_string @@ read_line ()\n\nlet rec sum = function | [] -> 0 | x :: xs -> x + sum xs\nlet sum = sum c - List.hd c\n\nlet rec find_index i arr f = \n if Array.length arr = i then -1\n else if f arr.(i) then i\n else find_index (i + 1) arr f\nlet find_index = find_index 0 ab\n\nlet s = Array.make n false\nlet ans = Array.make n 0\n\nlet rec loop = function\n | [] -> ()\n | x :: xs ->\n let idx = find_index (fun (a, b) -> a + b > 0 && (s.(a) || s.(b))) in\n let (a, b) = ab.(idx) in\n ab.(idx) <- (-1, -1);\n if s.(a) then begin\n s.(b) <- true; ans.(b) <- x\n end\n else begin\n s.(a) <- true; ans.(a) <- x\n end;\n loop xs\n\nlet () =\n match c with\n | x :: [] -> print_endline \"0\"\n | x :: y :: xs ->\n let (a, b) = ab.(0) in\n ab.(0) <- (-1, -1);\n ans.(a) <- x; s.(a) <- true;\n ans.(b) <- y; s.(b) <- true;\n loop xs;\n Printf.printf \"%d\\n\" sum;\n print_endline @@ String.concat \" \" @@ Array.to_list @@ Array.map string_of_int ans;\n | _ -> failwith \"\"", "language": "OCaml", "metadata": {"date": 1589416507, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03026.html", "problem_id": "p03026", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03026/input.txt", "sample_output_relpath": "derived/input_output/data/p03026/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03026/OCaml/s084068614.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s084068614", "user_id": "u811309788"}, "prompt_components": {"gold_output": "10\n1 2 3 4 5\n", "input_to_evaluate": "let split_string ?(pattern=\" \") = Str.split @@ Str.regexp pattern\n\nlet n = Scanf.sscanf (read_line ()) \"%d\" @@ fun n -> n\nlet ab = Array.init (n - 1) @@ fun _ -> Scanf.sscanf (read_line ()) \"%d %d\" @@ fun a b -> (a - 1, b - 1)\nlet c = List.sort (fun a b -> b - a) @@ List.map int_of_string @@ split_string @@ read_line ()\n\nlet rec sum = function | [] -> 0 | x :: xs -> x + sum xs\nlet sum = sum c - List.hd c\n\nlet rec find_index i arr f = \n if Array.length arr = i then -1\n else if f arr.(i) then i\n else find_index (i + 1) arr f\nlet find_index = find_index 0 ab\n\nlet s = Array.make n false\nlet ans = Array.make n 0\n\nlet rec loop = function\n | [] -> ()\n | x :: xs ->\n let idx = find_index (fun (a, b) -> a + b > 0 && (s.(a) || s.(b))) in\n let (a, b) = ab.(idx) in\n ab.(idx) <- (-1, -1);\n if s.(a) then begin\n s.(b) <- true; ans.(b) <- x\n end\n else begin\n s.(a) <- true; ans.(a) <- x\n end;\n loop xs\n\nlet () =\n match c with\n | x :: [] -> print_endline \"0\"\n | x :: y :: xs ->\n let (a, b) = ab.(0) in\n ab.(0) <- (-1, -1);\n ans.(a) <- x; s.(a) <- true;\n ans.(b) <- y; s.(b) <- true;\n loop xs;\n Printf.printf \"%d\\n\" sum;\n print_endline @@ String.concat \" \" @@ Array.to_list @@ Array.map string_of_int ans;\n | _ -> failwith \"\"", "problem_context": "Score : 500 points\n\nProblem Statement\n\nYou are given a tree with N vertices 1,2,\\ldots,N, and positive integers c_1,c_2,\\ldots,c_N.\nThe i-th edge in the tree (1 \\leq i \\leq N-1) connects Vertex a_i and Vertex b_i.\n\nWe will write a positive integer on each vertex in T and calculate our score as follows:\n\nOn each edge, write the smaller of the integers written on the two endpoints.\n\nLet our score be the sum of the integers written on all the edges.\n\nFind the maximum possible score when we write each of c_1,c_2,\\ldots,c_N on one vertex in T, and show one way to achieve it. If an integer occurs multiple times in c_1,c_2,\\ldots,c_N, we must use it that number of times.\n\nConstraints\n\n1 \\leq N \\leq 10000\n\n1 \\leq a_i,b_i \\leq N\n\n1 \\leq c_i \\leq 10^5\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}\nc_1 \\ldots c_N\n\nOutput\n\nUse the following format:\n\nM\nd_1 \\ldots d_N\n\nwhere M is the maximum possible score, and d_i is the integer to write on Vertex i.\nd_1,d_2,\\ldots,d_N must be a permutation of c_1,c_2,\\ldots,c_N.\nIf there are multiple ways to achieve the maximum score, any of them will be accepted.\n\nSample Input 1\n\n5\n1 2\n2 3\n3 4\n4 5\n1 2 3 4 5\n\nSample Output 1\n\n10\n1 2 3 4 5\n\nIf we write 1,2,3,4,5 on Vertex 1,2,3,4,5, respectively, the integers written on the four edges will be 1,2,3,4, for the score of 10. This is the maximum possible score.\n\nSample Input 2\n\n5\n1 2\n1 3\n1 4\n1 5\n3141 59 26 53 59\n\nSample Output 2\n\n197\n59 26 3141 59 53\n\nc_1,c_2,\\ldots,c_N may not be pairwise distinct.", "sample_input": "5\n1 2\n2 3\n3 4\n4 5\n1 2 3 4 5\n"}, "reference_outputs": ["10\n1 2 3 4 5\n"], "source_document_id": "p03026", "source_text": "Score : 500 points\n\nProblem Statement\n\nYou are given a tree with N vertices 1,2,\\ldots,N, and positive integers c_1,c_2,\\ldots,c_N.\nThe i-th edge in the tree (1 \\leq i \\leq N-1) connects Vertex a_i and Vertex b_i.\n\nWe will write a positive integer on each vertex in T and calculate our score as follows:\n\nOn each edge, write the smaller of the integers written on the two endpoints.\n\nLet our score be the sum of the integers written on all the edges.\n\nFind the maximum possible score when we write each of c_1,c_2,\\ldots,c_N on one vertex in T, and show one way to achieve it. If an integer occurs multiple times in c_1,c_2,\\ldots,c_N, we must use it that number of times.\n\nConstraints\n\n1 \\leq N \\leq 10000\n\n1 \\leq a_i,b_i \\leq N\n\n1 \\leq c_i \\leq 10^5\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}\nc_1 \\ldots c_N\n\nOutput\n\nUse the following format:\n\nM\nd_1 \\ldots d_N\n\nwhere M is the maximum possible score, and d_i is the integer to write on Vertex i.\nd_1,d_2,\\ldots,d_N must be a permutation of c_1,c_2,\\ldots,c_N.\nIf there are multiple ways to achieve the maximum score, any of them will be accepted.\n\nSample Input 1\n\n5\n1 2\n2 3\n3 4\n4 5\n1 2 3 4 5\n\nSample Output 1\n\n10\n1 2 3 4 5\n\nIf we write 1,2,3,4,5 on Vertex 1,2,3,4,5, respectively, the integers written on the four edges will be 1,2,3,4, for the score of 10. This is the maximum possible score.\n\nSample Input 2\n\n5\n1 2\n1 3\n1 4\n1 5\n3141 59 26 53 59\n\nSample Output 2\n\n197\n59 26 3141 59 53\n\nc_1,c_2,\\ldots,c_N may not be pairwise distinct.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1302, "cpu_time_ms": 461, "memory_kb": 6656}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s512409578", "group_id": "codeNet:p03029", "input_text": "let () =\n let main () =\n let a, p = Scanf.sscanf (read_line ()) \"%d %d\" (fun a p -> a, p) in\n Printf.printf \"%d\\n\" ((a * 3 + p) / 2)\n in\n main ()", "language": "OCaml", "metadata": {"date": 1558919080, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03029.html", "problem_id": "p03029", "resource_group": "low_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/OCaml/s512409578.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s512409578", "user_id": "u342443598"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "let () =\n let main () =\n let a, p = Scanf.sscanf (read_line ()) \"%d %d\" (fun a p -> a, p) in\n Printf.printf \"%d\\n\" ((a * 3 + p) / 2)\n in\n main ()", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s778479908", "group_id": "codeNet:p03030", "input_text": "let n = Scanf.scanf \" %d\" (+) 0\nlet sps = Array.init n @@ fun i -> Scanf.scanf \" %s %d\" @@ fun a b -> a, b, i + 1\nlet f (s, p, i) (s2, p2, i2) = if s = s2 then compare p2 p else compare s s2\nlet _ = Array.sort f sps; Array.iter (fun (_, _, i) -> Printf.printf \"%d\\n\" i) sps", "language": "OCaml", "metadata": {"date": 1564108667, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03030.html", "problem_id": "p03030", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03030/input.txt", "sample_output_relpath": "derived/input_output/data/p03030/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03030/OCaml/s778479908.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s778479908", "user_id": "u732304692"}, "prompt_components": {"gold_output": "3\n4\n6\n1\n5\n2\n", "input_to_evaluate": "let n = Scanf.scanf \" %d\" (+) 0\nlet sps = Array.init n @@ fun i -> Scanf.scanf \" %s %d\" @@ fun a b -> a, b, i + 1\nlet f (s, p, i) (s2, p2, i2) = if s = s2 then compare p2 p else compare s s2\nlet _ = Array.sort f sps; Array.iter (fun (_, _, i) -> Printf.printf \"%d\\n\" i) sps", "problem_context": "Score : 200 points\n\nProblem Statement\n\nYou have decided to write a book introducing good restaurants.\nThere are N restaurants that you want to introduce: Restaurant 1, Restaurant 2, ..., Restaurant N. Restaurant i is in city S_i, and your assessment score of that restaurant on a 100-point scale is P_i.\nNo two restaurants have the same score.\n\nYou want to introduce the restaurants in the following order:\n\nThe restaurants are arranged in lexicographical order of the names of their cities.\n\nIf there are multiple restaurants in the same city, they are arranged in descending order of score.\n\nPrint the identification numbers of the restaurants in the order they are introduced in the book.\n\nConstraints\n\n1 ≤ N ≤ 100\n\nS is a string of length between 1 and 10 (inclusive) consisting of lowercase English letters.\n\n0 ≤ P_i ≤ 100\n\nP_i is an integer.\n\nP_i ≠ P_j (1 ≤ i < j ≤ N)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS_1 P_1\n:\nS_N P_N\n\nOutput\n\nPrint N lines. The i-th line (1 ≤ i ≤ N) should contain the identification number of the restaurant that is introduced i-th in the book.\n\nSample Input 1\n\n6\nkhabarovsk 20\nmoscow 10\nkazan 50\nkazan 35\nmoscow 60\nkhabarovsk 40\n\nSample Output 1\n\n3\n4\n6\n1\n5\n2\n\nThe lexicographical order of the names of the three cities is kazan < khabarovsk < moscow. For each of these cities, the restaurants in it are introduced in descending order of score. Thus, the restaurants are introduced in the order 3,4,6,1,5,2.\n\nSample Input 2\n\n10\nyakutsk 10\nyakutsk 20\nyakutsk 30\nyakutsk 40\nyakutsk 50\nyakutsk 60\nyakutsk 70\nyakutsk 80\nyakutsk 90\nyakutsk 100\n\nSample Output 2\n\n10\n9\n8\n7\n6\n5\n4\n3\n2\n1", "sample_input": "6\nkhabarovsk 20\nmoscow 10\nkazan 50\nkazan 35\nmoscow 60\nkhabarovsk 40\n"}, "reference_outputs": ["3\n4\n6\n1\n5\n2\n"], "source_document_id": "p03030", "source_text": "Score : 200 points\n\nProblem Statement\n\nYou have decided to write a book introducing good restaurants.\nThere are N restaurants that you want to introduce: Restaurant 1, Restaurant 2, ..., Restaurant N. Restaurant i is in city S_i, and your assessment score of that restaurant on a 100-point scale is P_i.\nNo two restaurants have the same score.\n\nYou want to introduce the restaurants in the following order:\n\nThe restaurants are arranged in lexicographical order of the names of their cities.\n\nIf there are multiple restaurants in the same city, they are arranged in descending order of score.\n\nPrint the identification numbers of the restaurants in the order they are introduced in the book.\n\nConstraints\n\n1 ≤ N ≤ 100\n\nS is a string of length between 1 and 10 (inclusive) consisting of lowercase English letters.\n\n0 ≤ P_i ≤ 100\n\nP_i is an integer.\n\nP_i ≠ P_j (1 ≤ i < j ≤ N)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS_1 P_1\n:\nS_N P_N\n\nOutput\n\nPrint N lines. The i-th line (1 ≤ i ≤ N) should contain the identification number of the restaurant that is introduced i-th in the book.\n\nSample Input 1\n\n6\nkhabarovsk 20\nmoscow 10\nkazan 50\nkazan 35\nmoscow 60\nkhabarovsk 40\n\nSample Output 1\n\n3\n4\n6\n1\n5\n2\n\nThe lexicographical order of the names of the three cities is kazan < khabarovsk < moscow. For each of these cities, the restaurants in it are introduced in descending order of score. Thus, the restaurants are introduced in the order 3,4,6,1,5,2.\n\nSample Input 2\n\n10\nyakutsk 10\nyakutsk 20\nyakutsk 30\nyakutsk 40\nyakutsk 50\nyakutsk 60\nyakutsk 70\nyakutsk 80\nyakutsk 90\nyakutsk 100\n\nSample Output 2\n\n10\n9\n8\n7\n6\n5\n4\n3\n2\n1", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 512}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s730813367", "group_id": "codeNet:p03031", "input_text": "open Batteries\nmodule EnumL = Enum.Labels\nopen Tuple\n\nlet dbg x = Printf.eprintf \"[debug]%s\\n\" @@ dump x; x\n\nlet scan fmt f =\n Scanf.sscanf (read_line ()) fmt f\n\nlet scan_lines n fmt f =\n List.Labels.map\n (List.range 1 `To n)\n ~f:(fun _ -> scan fmt f)\n |> List.enum\n\nlet scan_list cnv =\n let l = read_line ()\n |> String.split_on_char ' '\n |> List.map cnv in\n List.enum l\n\nlet scan_lists n cnv =\n let ll = List.Labels.map (List.range 1 `To n)\n ~f:(fun _ -> scan_list cnv) in\n List.enum ll\n\nlet scan_array n m e conv =\n let arr = Array.make_matrix n m e in\n EnumL.iter (0 --^ n)\n ~f:(fun i -> arr.(i) <- Array.of_enum @@ scan_list conv);\n arr\n\nlet (n, m) = scan \"%d %d\" Tuple2.make\nlet lights = scan_lists m Int.of_string\nlet onoff = scan_list Int.of_string\n\nlet rec superset e =\n match Enum.get e with\n | None -> List.enum [Enum.empty ()]\n | Some v ->\n let f = superset e in\n let g = Enum.clone f in\n EnumL.map f ~f:(fun f -> let h = Enum.clone f in push h v; h)\n |> Enum.append g\n\nlet intersection l =\n EnumL.filter ~f:(fun x -> EnumL.exists ~f:((=) x) @@ Enum.clone l)\n\nlet () =\n let sets = superset (1 -- n) in\n EnumL.map sets ~f:(fun set ->\n (* EnumL.map (Enum.combine (Enum.clone onoff) (Enum.clone lights)) *)\n EnumL.map (Enum.combine (Enum.clone onoff, Enum.clone lights))\n ~f:(fun (b, l) ->\n let n = Enum.count @@\n intersection set @@ Enum.skip 1 @@ Enum.clone l\n in n mod 2 = b)\n |> EnumL.for_all ~f:((=) true))\n |> EnumL.filter ~f:((=) true)\n |> Enum.count\n |> Printf.printf \"%d\\n\"\n", "language": "OCaml", "metadata": {"date": 1587011573, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03031.html", "problem_id": "p03031", "resource_group": "low_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/OCaml/s730813367.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s730813367", "user_id": "u802614675"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "open Batteries\nmodule EnumL = Enum.Labels\nopen Tuple\n\nlet dbg x = Printf.eprintf \"[debug]%s\\n\" @@ dump x; x\n\nlet scan fmt f =\n Scanf.sscanf (read_line ()) fmt f\n\nlet scan_lines n fmt f =\n List.Labels.map\n (List.range 1 `To n)\n ~f:(fun _ -> scan fmt f)\n |> List.enum\n\nlet scan_list cnv =\n let l = read_line ()\n |> String.split_on_char ' '\n |> List.map cnv in\n List.enum l\n\nlet scan_lists n cnv =\n let ll = List.Labels.map (List.range 1 `To n)\n ~f:(fun _ -> scan_list cnv) in\n List.enum ll\n\nlet scan_array n m e conv =\n let arr = Array.make_matrix n m e in\n EnumL.iter (0 --^ n)\n ~f:(fun i -> arr.(i) <- Array.of_enum @@ scan_list conv);\n arr\n\nlet (n, m) = scan \"%d %d\" Tuple2.make\nlet lights = scan_lists m Int.of_string\nlet onoff = scan_list Int.of_string\n\nlet rec superset e =\n match Enum.get e with\n | None -> List.enum [Enum.empty ()]\n | Some v ->\n let f = superset e in\n let g = Enum.clone f in\n EnumL.map f ~f:(fun f -> let h = Enum.clone f in push h v; h)\n |> Enum.append g\n\nlet intersection l =\n EnumL.filter ~f:(fun x -> EnumL.exists ~f:((=) x) @@ Enum.clone l)\n\nlet () =\n let sets = superset (1 -- n) in\n EnumL.map sets ~f:(fun set ->\n (* EnumL.map (Enum.combine (Enum.clone onoff) (Enum.clone lights)) *)\n EnumL.map (Enum.combine (Enum.clone onoff, Enum.clone lights))\n ~f:(fun (b, l) ->\n let n = Enum.count @@\n intersection set @@ Enum.skip 1 @@ Enum.clone l\n in n mod 2 = b)\n |> EnumL.for_all ~f:((=) true))\n |> EnumL.filter ~f:((=) true)\n |> Enum.count\n |> Printf.printf \"%d\\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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1612, "cpu_time_ms": 20, "memory_kb": 5632}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s204771913", "group_id": "codeNet:p03031", "input_text": "open Batteries\nmodule EnumL = Enum.Labels\nopen Tuple\n\nlet dbg x = Printf.eprintf \"[debug]%s\\n\" @@ dump x; x\n\nlet scan fmt f =\n Scanf.sscanf (read_line ()) fmt f\n\nlet scan_lines n fmt f =\n List.Labels.map\n (List.range 1 `To n)\n ~f:(fun _ -> scan fmt f)\n |> List.enum\n\nlet scan_list cnv =\n read_line ()\n |> String.split_on_char ' '\n |> List.map cnv\n |> List.enum\n\nlet scan_lists n cnv =\n List.Labels.map (List.range 1 `To n)\n ~f:(fun _ -> scan_list cnv)\n |> List.enum\n\nlet scan_array n m e conv =\n let arr = Array.make_matrix n m e in\n EnumL.iter (0 --^ n)\n ~f:(fun i -> arr.(i) <- Array.of_enum @@ scan_list conv);\n arr\n\nlet rec zip xs ys =\n match xs, ys with\n | [], _ -> []\n | _, [] -> []\n | x::xs, y::ys ->\n (x, y) :: zip xs ys\n\nlet (n, m) = scan \"%d %d\" Tuple2.make\nlet lights = scan_lists m Int.of_string\nlet onoff = scan_list Int.of_string\n\nlet rec superset = function\n | [] -> [[]]\n | x :: xs ->\n let ps = superset xs in\n ps @ List.map (fun ss -> x :: ss) ps\n\nlet rec intersection l = function\n | [] -> []\n | h::t ->\n if List.exists ((=) h) l then\n h::intersection l t\n else intersection l t\n\nlet () =\n let sets = List.enum @@ superset (List.range 1 `To n) in\n EnumL.map sets ~f:(fun set ->\n EnumL.map (Enum.combine ((Enum.clone onoff), (Enum.clone lights)))\n ~f:(fun (b, l) ->\n let n = List.length @@\n intersection set @@ List.of_enum @@ Enum.take 1 @@ Enum.clone l\n in n mod 2 = b)\n |> EnumL.for_all ~f:((=) true))\n |> EnumL.filter ~f:((=) true)\n |> Enum.count\n |> Printf.printf \"%d\\n\"\n", "language": "OCaml", "metadata": {"date": 1587003891, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03031.html", "problem_id": "p03031", "resource_group": "low_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/OCaml/s204771913.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s204771913", "user_id": "u802614675"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "open Batteries\nmodule EnumL = Enum.Labels\nopen Tuple\n\nlet dbg x = Printf.eprintf \"[debug]%s\\n\" @@ dump x; x\n\nlet scan fmt f =\n Scanf.sscanf (read_line ()) fmt f\n\nlet scan_lines n fmt f =\n List.Labels.map\n (List.range 1 `To n)\n ~f:(fun _ -> scan fmt f)\n |> List.enum\n\nlet scan_list cnv =\n read_line ()\n |> String.split_on_char ' '\n |> List.map cnv\n |> List.enum\n\nlet scan_lists n cnv =\n List.Labels.map (List.range 1 `To n)\n ~f:(fun _ -> scan_list cnv)\n |> List.enum\n\nlet scan_array n m e conv =\n let arr = Array.make_matrix n m e in\n EnumL.iter (0 --^ n)\n ~f:(fun i -> arr.(i) <- Array.of_enum @@ scan_list conv);\n arr\n\nlet rec zip xs ys =\n match xs, ys with\n | [], _ -> []\n | _, [] -> []\n | x::xs, y::ys ->\n (x, y) :: zip xs ys\n\nlet (n, m) = scan \"%d %d\" Tuple2.make\nlet lights = scan_lists m Int.of_string\nlet onoff = scan_list Int.of_string\n\nlet rec superset = function\n | [] -> [[]]\n | x :: xs ->\n let ps = superset xs in\n ps @ List.map (fun ss -> x :: ss) ps\n\nlet rec intersection l = function\n | [] -> []\n | h::t ->\n if List.exists ((=) h) l then\n h::intersection l t\n else intersection l t\n\nlet () =\n let sets = List.enum @@ superset (List.range 1 `To n) in\n EnumL.map sets ~f:(fun set ->\n EnumL.map (Enum.combine ((Enum.clone onoff), (Enum.clone lights)))\n ~f:(fun (b, l) ->\n let n = List.length @@\n intersection set @@ List.of_enum @@ Enum.take 1 @@ Enum.clone l\n in n mod 2 = b)\n |> EnumL.for_all ~f:((=) true))\n |> EnumL.filter ~f:((=) true)\n |> Enum.count\n |> Printf.printf \"%d\\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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1602, "cpu_time_ms": 8, "memory_kb": 4992}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s254311428", "group_id": "codeNet:p03032", "input_text": "(* O(k M^2) (M = min n k) *)\nScanf.scanf \" %d %d\" @@ fun n k ->\n let vs = Array.init n @@ fun _ -> Scanf.scanf \" %d\" @@ (+) 0 in\n let ans = ref 0 in\n let m = min n k in\n for l = 0 to m do\n for r = 0 to m - l do\n let c = l + r in\n for b = 0 to k - c do\n if b <= c then\n let a = Array.make c 0 in\n let a_i = ref 0 in\n let rec loop acc f i rest =\n if rest <= 0 then acc\n else\n let v = vs.(f i) in\n a.(!a_i) <- v; incr a_i;\n loop (acc + v) f (i + 1) (rest - 1) in\n let sum = ref @@ loop 0 ((+) 0) 0 l + loop 0 ((-) (n - 1)) 0 r in\n Array.sort (-) a;\n for i = 0 to b - 1 do\n sum := !sum - a.(i)\n done;\n ans := max !ans !sum\n done\n done\n done;\n Printf.printf \"%d\\n\" !ans", "language": "OCaml", "metadata": {"date": 1559021676, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03032.html", "problem_id": "p03032", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03032/input.txt", "sample_output_relpath": "derived/input_output/data/p03032/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03032/OCaml/s254311428.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s254311428", "user_id": "u732304692"}, "prompt_components": {"gold_output": "14\n", "input_to_evaluate": "(* O(k M^2) (M = min n k) *)\nScanf.scanf \" %d %d\" @@ fun n k ->\n let vs = Array.init n @@ fun _ -> Scanf.scanf \" %d\" @@ (+) 0 in\n let ans = ref 0 in\n let m = min n k in\n for l = 0 to m do\n for r = 0 to m - l do\n let c = l + r in\n for b = 0 to k - c do\n if b <= c then\n let a = Array.make c 0 in\n let a_i = ref 0 in\n let rec loop acc f i rest =\n if rest <= 0 then acc\n else\n let v = vs.(f i) in\n a.(!a_i) <- v; incr a_i;\n loop (acc + v) f (i + 1) (rest - 1) in\n let sum = ref @@ loop 0 ((+) 0) 0 l + loop 0 ((-) (n - 1)) 0 r in\n Array.sort (-) a;\n for i = 0 to b - 1 do\n sum := !sum - a.(i)\n done;\n ans := max !ans !sum\n done\n done\n done;\n Printf.printf \"%d\\n\" !ans", "problem_context": "Score : 400 points\n\nProblem Statement\n\nYour friend gave you a dequeue D as a birthday present.\n\nD is a horizontal cylinder that contains a row of N jewels.\n\nThe values of the jewels are V_1, V_2, ..., V_N from left to right. There may be jewels with negative values.\n\nIn the beginning, you have no jewel in your hands.\n\nYou can perform at most K operations on D, chosen from the following, at most K times (possibly zero):\n\nOperation A: Take out the leftmost jewel contained in D and have it in your hand. You cannot do this operation when D is empty.\n\nOperation B: Take out the rightmost jewel contained in D and have it in your hand. You cannot do this operation when D is empty.\n\nOperation C: Choose a jewel in your hands and insert it to the left end of D. You cannot do this operation when you have no jewel in your hand.\n\nOperation D: Choose a jewel in your hands and insert it to the right end of D. You cannot do this operation when you have no jewel in your hand.\n\nFind the maximum possible sum of the values of jewels in your hands after the operations.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 50\n\n1 \\leq K \\leq 100\n\n-10^7 \\leq V_i \\leq 10^7\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nV_1 V_2 ... V_N\n\nOutput\n\nPrint the maximum possible sum of the values of jewels in your hands after the operations.\n\nSample Input 1\n\n6 4\n-10 8 2 1 2 6\n\nSample Output 1\n\n14\n\nAfter the following sequence of operations, you have two jewels of values 8 and 6 in your hands for a total of 14, which is the maximum result.\n\nDo operation A. You take out the jewel of value -10 from the left end of D.\n\nDo operation B. You take out the jewel of value 6 from the right end of D.\n\nDo operation A. You take out the jewel of value 8 from the left end of D.\n\nDo operation D. You insert the jewel of value -10 to the right end of D.\n\nSample Input 2\n\n6 4\n-6 -100 50 -2 -5 -3\n\nSample Output 2\n\n44\n\nSample Input 3\n\n6 3\n-6 -100 50 -2 -5 -3\n\nSample Output 3\n\n0\n\nIt is optimal to do no operation.", "sample_input": "6 4\n-10 8 2 1 2 6\n"}, "reference_outputs": ["14\n"], "source_document_id": "p03032", "source_text": "Score : 400 points\n\nProblem Statement\n\nYour friend gave you a dequeue D as a birthday present.\n\nD is a horizontal cylinder that contains a row of N jewels.\n\nThe values of the jewels are V_1, V_2, ..., V_N from left to right. There may be jewels with negative values.\n\nIn the beginning, you have no jewel in your hands.\n\nYou can perform at most K operations on D, chosen from the following, at most K times (possibly zero):\n\nOperation A: Take out the leftmost jewel contained in D and have it in your hand. You cannot do this operation when D is empty.\n\nOperation B: Take out the rightmost jewel contained in D and have it in your hand. You cannot do this operation when D is empty.\n\nOperation C: Choose a jewel in your hands and insert it to the left end of D. You cannot do this operation when you have no jewel in your hand.\n\nOperation D: Choose a jewel in your hands and insert it to the right end of D. You cannot do this operation when you have no jewel in your hand.\n\nFind the maximum possible sum of the values of jewels in your hands after the operations.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 50\n\n1 \\leq K \\leq 100\n\n-10^7 \\leq V_i \\leq 10^7\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nV_1 V_2 ... V_N\n\nOutput\n\nPrint the maximum possible sum of the values of jewels in your hands after the operations.\n\nSample Input 1\n\n6 4\n-10 8 2 1 2 6\n\nSample Output 1\n\n14\n\nAfter the following sequence of operations, you have two jewels of values 8 and 6 in your hands for a total of 14, which is the maximum result.\n\nDo operation A. You take out the jewel of value -10 from the left end of D.\n\nDo operation B. You take out the jewel of value 6 from the right end of D.\n\nDo operation A. You take out the jewel of value 8 from the left end of D.\n\nDo operation D. You insert the jewel of value -10 to the right end of D.\n\nSample Input 2\n\n6 4\n-6 -100 50 -2 -5 -3\n\nSample Output 2\n\n44\n\nSample Input 3\n\n6 3\n-6 -100 50 -2 -5 -3\n\nSample Output 3\n\n0\n\nIt is optimal to do no operation.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 842, "cpu_time_ms": 192, "memory_kb": 2560}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s825377217", "group_id": "codeNet:p03033", "input_text": "type t =\n | Leaf\n | Node of body\nand body = { left : t; right : t; data : int; l : int; r : int }\n\nlet rec drop n l =\n if n = 0 then l else drop (n - 1) (List.tl l)\n\nlet rec init l n xs =\n if n = 1\n then\n (Node\n { left = Leaf;\n right = Leaf;\n data = max_int; l;\n r = List.hd xs }, List.hd xs)\n else\n let (left, m) = init l (n / 2) xs in\n let (right, r) = init m ((n + 1) / 2) (drop (n / 2) xs) in\n (Node { left; right; data = max_int; l; r }, r)\nlet init (x :: xs) = fst @@ init x (List.length xs) xs\n\nlet rec update a b x = function\n | Leaf -> Leaf\n | Node ({ left; right; data; l; r } as t) ->\n if b <= l || r <= a || t.data <= x\n then Node t\n else begin\n if a <= l && r <= b\n then Node { t with data = min x t.data }\n else Node { t with left = update a b x left; right = update a b x right }\n end\n\nlet rec query acc i = function\n | Leaf -> acc\n | Node { left; right; data; l; r } ->\n if i < l || r <= i\n then acc\n else query (query (min acc data) i left) i right\nlet query = query max_int\n\nlet () = Scanf.scanf \"%d %d\\n\" @@ fun n q ->\n let stxs =\n Array.init n @@ fun _ ->\n Scanf.scanf \"%d %d %d\\n\" @@ fun s t x -> s, t, x in\n let tr =\n Array.fold_right (fun (s, t, x) -> update (s - x) (t - x) x) stxs @@\n init @@\n List.sort_uniq compare @@\n Array.fold_left (fun acc (s, t, x) -> s - x :: t - x :: acc) [] stxs in\n for i = 0 to q - 1 do\n Printf.printf \"%d\\n\" @@ Scanf.scanf \"%d\\n\" @@ fun d ->\n let ans = query d tr in\n if ans = max_int then -1 else ans\n done\n", "language": "OCaml", "metadata": {"date": 1568922408, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03033.html", "problem_id": "p03033", "resource_group": "low_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/OCaml/s825377217.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s825377217", "user_id": "u504158101"}, "prompt_components": {"gold_output": "2\n2\n10\n-1\n13\n-1\n", "input_to_evaluate": "type t =\n | Leaf\n | Node of body\nand body = { left : t; right : t; data : int; l : int; r : int }\n\nlet rec drop n l =\n if n = 0 then l else drop (n - 1) (List.tl l)\n\nlet rec init l n xs =\n if n = 1\n then\n (Node\n { left = Leaf;\n right = Leaf;\n data = max_int; l;\n r = List.hd xs }, List.hd xs)\n else\n let (left, m) = init l (n / 2) xs in\n let (right, r) = init m ((n + 1) / 2) (drop (n / 2) xs) in\n (Node { left; right; data = max_int; l; r }, r)\nlet init (x :: xs) = fst @@ init x (List.length xs) xs\n\nlet rec update a b x = function\n | Leaf -> Leaf\n | Node ({ left; right; data; l; r } as t) ->\n if b <= l || r <= a || t.data <= x\n then Node t\n else begin\n if a <= l && r <= b\n then Node { t with data = min x t.data }\n else Node { t with left = update a b x left; right = update a b x right }\n end\n\nlet rec query acc i = function\n | Leaf -> acc\n | Node { left; right; data; l; r } ->\n if i < l || r <= i\n then acc\n else query (query (min acc data) i left) i right\nlet query = query max_int\n\nlet () = Scanf.scanf \"%d %d\\n\" @@ fun n q ->\n let stxs =\n Array.init n @@ fun _ ->\n Scanf.scanf \"%d %d %d\\n\" @@ fun s t x -> s, t, x in\n let tr =\n Array.fold_right (fun (s, t, x) -> update (s - x) (t - x) x) stxs @@\n init @@\n List.sort_uniq compare @@\n Array.fold_left (fun acc (s, t, x) -> s - x :: t - x :: acc) [] stxs in\n for i = 0 to q - 1 do\n Printf.printf \"%d\\n\" @@ Scanf.scanf \"%d\\n\" @@ fun d ->\n let ans = query d tr in\n if ans = max_int then -1 else ans\n done\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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1604, "cpu_time_ms": 1546, "memory_kb": 115996}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s519575346", "group_id": "codeNet:p03035", "input_text": "let a = ref 0;;\nlet b = ref 0;;\nScanf.scanf \"%d %d\" (fun x y -> a := x; b := y);;\n\nlet p =\n if !a >= 13 then !b\n else if !a >= 6 then !b / 2\n else 0 in\n print_endline(string_of_int p)\n;;", "language": "OCaml", "metadata": {"date": 1587427694, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03035.html", "problem_id": "p03035", "resource_group": "low_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/OCaml/s519575346.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s519575346", "user_id": "u541055501"}, "prompt_components": {"gold_output": "100\n", "input_to_evaluate": "let a = ref 0;;\nlet b = ref 0;;\nScanf.scanf \"%d %d\" (fun x y -> a := x; b := y);;\n\nlet p =\n if !a >= 13 then !b\n else if !a >= 6 then !b / 2\n else 0 in\n print_endline(string_of_int p)\n;;", "problem_context": "Score : 100 points\n\nProblem Statement\n\nTakahashi, who is A years old, is riding a Ferris wheel.\n\nIt costs B yen (B is an even number) to ride the Ferris wheel if you are 13 years old or older, but children between 6 and 12 years old (inclusive) can ride it for half the cost, and children who are 5 years old or younger are free of charge. (Yen is the currency of Japan.)\n\nFind the cost of the Ferris wheel for Takahashi.\n\nConstraints\n\n0 ≤ A ≤ 100\n\n2 ≤ B ≤ 1000\n\nB is an even number.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the cost of the Ferris wheel for Takahashi.\n\nSample Input 1\n\n30 100\n\nSample Output 1\n\n100\n\nTakahashi is 30 years old now, and the cost of the Ferris wheel is 100 yen.\n\nSample Input 2\n\n12 100\n\nSample Output 2\n\n50\n\nTakahashi is 12 years old, and the cost of the Ferris wheel is the half of 100 yen, that is, 50 yen.\n\nSample Input 3\n\n0 100\n\nSample Output 3\n\n0\n\nTakahashi is 0 years old, and he can ride the Ferris wheel for free.", "sample_input": "30 100\n"}, "reference_outputs": ["100\n"], "source_document_id": "p03035", "source_text": "Score : 100 points\n\nProblem Statement\n\nTakahashi, who is A years old, is riding a Ferris wheel.\n\nIt costs B yen (B is an even number) to ride the Ferris wheel if you are 13 years old or older, but children between 6 and 12 years old (inclusive) can ride it for half the cost, and children who are 5 years old or younger are free of charge. (Yen is the currency of Japan.)\n\nFind the cost of the Ferris wheel for Takahashi.\n\nConstraints\n\n0 ≤ A ≤ 100\n\n2 ≤ B ≤ 1000\n\nB is an even number.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the cost of the Ferris wheel for Takahashi.\n\nSample Input 1\n\n30 100\n\nSample Output 1\n\n100\n\nTakahashi is 30 years old now, and the cost of the Ferris wheel is 100 yen.\n\nSample Input 2\n\n12 100\n\nSample Output 2\n\n50\n\nTakahashi is 12 years old, and the cost of the Ferris wheel is the half of 100 yen, that is, 50 yen.\n\nSample Input 3\n\n0 100\n\nSample Output 3\n\n0\n\nTakahashi is 0 years old, and he can ride the Ferris wheel for free.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 2432}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s603531133", "group_id": "codeNet:p03035", "input_text": "open Printf\nopen Scanf\n\nlet solve a b =\n if a >= 13 then b\n else if a >= 6 then b / 2\n else 0\n\nlet () =\n scanf \"%d %d \" solve |> printf \"%d\\n\"\n", "language": "OCaml", "metadata": {"date": 1582590335, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03035.html", "problem_id": "p03035", "resource_group": "low_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/OCaml/s603531133.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s603531133", "user_id": "u388783188"}, "prompt_components": {"gold_output": "100\n", "input_to_evaluate": "open Printf\nopen Scanf\n\nlet solve a b =\n if a >= 13 then b\n else if a >= 6 then b / 2\n else 0\n\nlet () =\n scanf \"%d %d \" solve |> printf \"%d\\n\"\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nTakahashi, who is A years old, is riding a Ferris wheel.\n\nIt costs B yen (B is an even number) to ride the Ferris wheel if you are 13 years old or older, but children between 6 and 12 years old (inclusive) can ride it for half the cost, and children who are 5 years old or younger are free of charge. (Yen is the currency of Japan.)\n\nFind the cost of the Ferris wheel for Takahashi.\n\nConstraints\n\n0 ≤ A ≤ 100\n\n2 ≤ B ≤ 1000\n\nB is an even number.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the cost of the Ferris wheel for Takahashi.\n\nSample Input 1\n\n30 100\n\nSample Output 1\n\n100\n\nTakahashi is 30 years old now, and the cost of the Ferris wheel is 100 yen.\n\nSample Input 2\n\n12 100\n\nSample Output 2\n\n50\n\nTakahashi is 12 years old, and the cost of the Ferris wheel is the half of 100 yen, that is, 50 yen.\n\nSample Input 3\n\n0 100\n\nSample Output 3\n\n0\n\nTakahashi is 0 years old, and he can ride the Ferris wheel for free.", "sample_input": "30 100\n"}, "reference_outputs": ["100\n"], "source_document_id": "p03035", "source_text": "Score : 100 points\n\nProblem Statement\n\nTakahashi, who is A years old, is riding a Ferris wheel.\n\nIt costs B yen (B is an even number) to ride the Ferris wheel if you are 13 years old or older, but children between 6 and 12 years old (inclusive) can ride it for half the cost, and children who are 5 years old or younger are free of charge. (Yen is the currency of Japan.)\n\nFind the cost of the Ferris wheel for Takahashi.\n\nConstraints\n\n0 ≤ A ≤ 100\n\n2 ≤ B ≤ 1000\n\nB is an even number.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the cost of the Ferris wheel for Takahashi.\n\nSample Input 1\n\n30 100\n\nSample Output 1\n\n100\n\nTakahashi is 30 years old now, and the cost of the Ferris wheel is 100 yen.\n\nSample Input 2\n\n12 100\n\nSample Output 2\n\n50\n\nTakahashi is 12 years old, and the cost of the Ferris wheel is the half of 100 yen, that is, 50 yen.\n\nSample Input 3\n\n0 100\n\nSample Output 3\n\n0\n\nTakahashi is 0 years old, and he can ride the Ferris wheel for free.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s441066548", "group_id": "codeNet:p03035", "input_text": "let answer a b =\n if a >= 13 then b\n else\n if a <= 6 then 0\n else\n b / 2\n\n let () = Scanf.scanf \"%d %d\" (fun a b -> print_endline (string_of_int (answer a b)))\n", "language": "OCaml", "metadata": {"date": 1558832657, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03035.html", "problem_id": "p03035", "resource_group": "low_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/OCaml/s441066548.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s441066548", "user_id": "u950428333"}, "prompt_components": {"gold_output": "100\n", "input_to_evaluate": "let answer a b =\n if a >= 13 then b\n else\n if a <= 6 then 0\n else\n b / 2\n\n let () = Scanf.scanf \"%d %d\" (fun a b -> print_endline (string_of_int (answer a b)))\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nTakahashi, who is A years old, is riding a Ferris wheel.\n\nIt costs B yen (B is an even number) to ride the Ferris wheel if you are 13 years old or older, but children between 6 and 12 years old (inclusive) can ride it for half the cost, and children who are 5 years old or younger are free of charge. (Yen is the currency of Japan.)\n\nFind the cost of the Ferris wheel for Takahashi.\n\nConstraints\n\n0 ≤ A ≤ 100\n\n2 ≤ B ≤ 1000\n\nB is an even number.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the cost of the Ferris wheel for Takahashi.\n\nSample Input 1\n\n30 100\n\nSample Output 1\n\n100\n\nTakahashi is 30 years old now, and the cost of the Ferris wheel is 100 yen.\n\nSample Input 2\n\n12 100\n\nSample Output 2\n\n50\n\nTakahashi is 12 years old, and the cost of the Ferris wheel is the half of 100 yen, that is, 50 yen.\n\nSample Input 3\n\n0 100\n\nSample Output 3\n\n0\n\nTakahashi is 0 years old, and he can ride the Ferris wheel for free.", "sample_input": "30 100\n"}, "reference_outputs": ["100\n"], "source_document_id": "p03035", "source_text": "Score : 100 points\n\nProblem Statement\n\nTakahashi, who is A years old, is riding a Ferris wheel.\n\nIt costs B yen (B is an even number) to ride the Ferris wheel if you are 13 years old or older, but children between 6 and 12 years old (inclusive) can ride it for half the cost, and children who are 5 years old or younger are free of charge. (Yen is the currency of Japan.)\n\nFind the cost of the Ferris wheel for Takahashi.\n\nConstraints\n\n0 ≤ A ≤ 100\n\n2 ≤ B ≤ 1000\n\nB is an even number.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the cost of the Ferris wheel for Takahashi.\n\nSample Input 1\n\n30 100\n\nSample Output 1\n\n100\n\nTakahashi is 30 years old now, and the cost of the Ferris wheel is 100 yen.\n\nSample Input 2\n\n12 100\n\nSample Output 2\n\n50\n\nTakahashi is 12 years old, and the cost of the Ferris wheel is the half of 100 yen, that is, 50 yen.\n\nSample Input 3\n\n0 100\n\nSample Output 3\n\n0\n\nTakahashi is 0 years old, and he can ride the Ferris wheel for free.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s041701708", "group_id": "codeNet:p03036", "input_text": "let r, d, x2000 = Scanf.scanf \" %d %d %d\" @@ fun a b c -> a, b, c\nlet x = ref x2000\nlet _ = for _ = 1 to 10 do x := r * !x - d; Printf.printf \"%d\\n\" !x done", "language": "OCaml", "metadata": {"date": 1564028727, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03036.html", "problem_id": "p03036", "resource_group": "low_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/OCaml/s041701708.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s041701708", "user_id": "u732304692"}, "prompt_components": {"gold_output": "30\n50\n90\n170\n330\n650\n1290\n2570\n5130\n10250\n", "input_to_evaluate": "let r, d, x2000 = Scanf.scanf \" %d %d %d\" @@ fun a b c -> a, b, c\nlet x = ref x2000\nlet _ = for _ = 1 to 10 do x := r * !x - d; Printf.printf \"%d\\n\" !x done", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s079833622", "group_id": "codeNet:p03036", "input_text": "let () =\n let r, d, x = Scanf.scanf \"%d %d %d\\n\" (fun a b c -> a, b, c) in\n let rec f x i = if i = 10 then [] else string_of_int (r*x-d) :: f (r*x-d) (i+1) in\n let lst = (f x 0) in List.iter print_endline lst\n", "language": "OCaml", "metadata": {"date": 1559492347, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03036.html", "problem_id": "p03036", "resource_group": "low_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/OCaml/s079833622.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s079833622", "user_id": "u307426615"}, "prompt_components": {"gold_output": "30\n50\n90\n170\n330\n650\n1290\n2570\n5130\n10250\n", "input_to_evaluate": "let () =\n let r, d, x = Scanf.scanf \"%d %d %d\\n\" (fun a b c -> a, b, c) in\n let rec f x i = if i = 10 then [] else string_of_int (r*x-d) :: f (r*x-d) (i+1) in\n let lst = (f x 0) in List.iter print_endline lst\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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s367944868", "group_id": "codeNet:p03037", "input_text": "(*\nocamlfind ocamlopt -package batteries -linkpkg main.ml -o a.out\n*)\nopen Batteries\n\nlet n, m = Scanf.sscanf (read_line ()) \"%d %d\" ( fun n m -> n, m)\n\nlet plst = List.init m (\n fun _ -> \n Scanf.sscanf (read_line ()) \"%d %d\" (\n fun l r -> \n (l, r)\n )\n)\n\nlet rec f lst =\n match lst with\n [] -> (1, n)\n | (lf, rf) :: rest -> \n let (lr, rr) = f rest in\n if lf < lr && rf < rr then\n (lr, rf)\n else\n if lf < lr && rf > rr then\n (lr, rr)\n else\n if lf > lr && rf < rr then\n (lf, rf)\n else\n (lf, rr)\n\nlet () =\n (\n let (l, r) = f plst in\n if r < l then\n 0\n else\n List.range l `To r\n |> List.length\n ) |> Printf.printf \"%d\\n\"\n(*\n\nlet slst = List.init m (\n fun _ -> \n Scanf.sscanf (read_line ()) \"%d %d\" (\n fun l r -> \n (l, r)\n )\n) |> List.map (fun (l, r) -> Set.of_list (List.range l `To r))\n\nlet rec f lst =\n match lst with\n [] -> Set.of_list []\n | first :: [] -> \n first\n | first :: rest -> \n Set.intersect first (f rest)\n\nlet () =\n f slst\n |> Set.cardinal\n |> Printf.printf \"%d\\n\"\n\n*)\n", "language": "OCaml", "metadata": {"date": 1590457373, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03037.html", "problem_id": "p03037", "resource_group": "low_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/OCaml/s367944868.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s367944868", "user_id": "u280335093"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "(*\nocamlfind ocamlopt -package batteries -linkpkg main.ml -o a.out\n*)\nopen Batteries\n\nlet n, m = Scanf.sscanf (read_line ()) \"%d %d\" ( fun n m -> n, m)\n\nlet plst = List.init m (\n fun _ -> \n Scanf.sscanf (read_line ()) \"%d %d\" (\n fun l r -> \n (l, r)\n )\n)\n\nlet rec f lst =\n match lst with\n [] -> (1, n)\n | (lf, rf) :: rest -> \n let (lr, rr) = f rest in\n if lf < lr && rf < rr then\n (lr, rf)\n else\n if lf < lr && rf > rr then\n (lr, rr)\n else\n if lf > lr && rf < rr then\n (lf, rf)\n else\n (lf, rr)\n\nlet () =\n (\n let (l, r) = f plst in\n if r < l then\n 0\n else\n List.range l `To r\n |> List.length\n ) |> Printf.printf \"%d\\n\"\n(*\n\nlet slst = List.init m (\n fun _ -> \n Scanf.sscanf (read_line ()) \"%d %d\" (\n fun l r -> \n (l, r)\n )\n) |> List.map (fun (l, r) -> Set.of_list (List.range l `To r))\n\nlet rec f lst =\n match lst with\n [] -> Set.of_list []\n | first :: [] -> \n first\n | first :: rest -> \n Set.intersect first (f rest)\n\nlet () =\n f slst\n |> Set.cardinal\n |> Printf.printf \"%d\\n\"\n\n*)\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nWe have N ID cards, and there are M gates.\n\nWe can pass the i-th gate if we have one of the following ID cards: the L_i-th, (L_i+1)-th, ..., and R_i-th ID cards.\n\nHow many of the ID cards allow us to pass all the gates alone?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n1 \\leq L_i \\leq R_i \\leq N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nL_1 R_1\nL_2 R_2\n\\vdots\nL_M R_M\n\nOutput\n\nPrint the number of ID cards that allow us to pass all the gates alone.\n\nSample Input 1\n\n4 2\n1 3\n2 4\n\nSample Output 1\n\n2\n\nTwo ID cards allow us to pass all the gates alone, as follows:\n\nThe first ID card does not allow us to pass the second gate.\n\nThe second ID card allows us to pass all the gates.\n\nThe third ID card allows us to pass all the gates.\n\nThe fourth ID card does not allow us to pass the first gate.\n\nSample Input 2\n\n10 3\n3 6\n5 7\n6 9\n\nSample Output 2\n\n1\n\nSample Input 3\n\n100000 1\n1 100000\n\nSample Output 3\n\n100000", "sample_input": "4 2\n1 3\n2 4\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03037", "source_text": "Score : 300 points\n\nProblem Statement\n\nWe have N ID cards, and there are M gates.\n\nWe can pass the i-th gate if we have one of the following ID cards: the L_i-th, (L_i+1)-th, ..., and R_i-th ID cards.\n\nHow many of the ID cards allow us to pass all the gates alone?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n1 \\leq L_i \\leq R_i \\leq N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nL_1 R_1\nL_2 R_2\n\\vdots\nL_M R_M\n\nOutput\n\nPrint the number of ID cards that allow us to pass all the gates alone.\n\nSample Input 1\n\n4 2\n1 3\n2 4\n\nSample Output 1\n\n2\n\nTwo ID cards allow us to pass all the gates alone, as follows:\n\nThe first ID card does not allow us to pass the second gate.\n\nThe second ID card allows us to pass all the gates.\n\nThe third ID card allows us to pass all the gates.\n\nThe fourth ID card does not allow us to pass the first gate.\n\nSample Input 2\n\n10 3\n3 6\n5 7\n6 9\n\nSample Output 2\n\n1\n\nSample Input 3\n\n100000 1\n1 100000\n\nSample Output 3\n\n100000", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1854, "cpu_time_ms": 72, "memory_kb": 12800}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s695268075", "group_id": "codeNet:p03037", "input_text": "let () =\n let main () =\n let n, m = Scanf.sscanf (read_line ()) \"%d %d\" (fun a b -> a, b) in\n let rec loop i mmin mmax =\n if i = 0 then max 0 (mmax - mmin + 1) else\n let l, r = Scanf.sscanf (read_line ()) \"%d %d\" (fun l r -> l, r) in\n loop (i - 1) (max mmin l) (min mmax r)\n in\n Printf.printf \"%d\\n\" (loop m 1 n)\n in\n main ()", "language": "OCaml", "metadata": {"date": 1558833387, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03037.html", "problem_id": "p03037", "resource_group": "low_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/OCaml/s695268075.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s695268075", "user_id": "u342443598"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "let () =\n let main () =\n let n, m = Scanf.sscanf (read_line ()) \"%d %d\" (fun a b -> a, b) in\n let rec loop i mmin mmax =\n if i = 0 then max 0 (mmax - mmin + 1) else\n let l, r = Scanf.sscanf (read_line ()) \"%d %d\" (fun l r -> l, r) in\n loop (i - 1) (max mmin l) (min mmax r)\n in\n Printf.printf \"%d\\n\" (loop m 1 n)\n in\n main ()", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 403, "cpu_time_ms": 56, "memory_kb": 2816}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s855494322", "group_id": "codeNet:p03040", "input_text": "\nmodule Set_ii = Set.Make(struct\n type t = int * int\n let compare (a, b) (d, e) =\n if a <> d then a-d else b-e\nend)\nmodule S = Set_ii\n\ntype state = { tl: Set_ii.t; tr: Set_ii.t; sl: int; sr: int; b: int }\n\nlet update {tl; tr; sl; sr; b=tb} n a b =\n let (vl, _ as el), (vr, _ as er) = S.max_elt tl, S.min_elt tr in\n let tl, ((vm, _) as m), tr, sl, sr =\n if a <= vl then\n let tl' = S.remove el tl in\n (S.add (a, n) tl', el, tr, sl-vl+a, sr)\n else if a <= vr then\n (tl, (a, n), tr, sl, sr)\n else\n let tr' = S.remove er tr in\n (tl, er, S.add (a, n) tr', sl, sr-vr+a)\n in\n if S.cardinal tl > S.cardinal tr then\n {tl; tr = S.add m tr; sl = sl; sr = sr+vm; b = tb+b}\n else\n {tl = S.add m tl; tr; sl = sl+vm; sr; b = tb+b}\n\nlet calc {tl; tr; sl; sr; b} =\n let x, _ = S.max_elt tl in\n let _, _ = S.min_elt tr in\n let sum = (S.cardinal tl - S.cardinal tr) * x - sl + sr + b in\n (x, sum)\n\nlet rec loop n st =\n if n = 0 then ()\n else Scanf.scanf \" %d\" @@ function\n | 1 -> Scanf.scanf \" %d %d\" (update st n) |> loop (n-1)\n | _ -> begin\n let x, fx = calc st in Printf.printf \"%d %d\\n\" x fx;\n loop (n-1) st\n end\n\nlet inf = 1000000000000\nlet _ = Scanf.scanf \"%d\" @@ fun q -> loop q {\n tl = S.singleton (-inf, -inf) ; tr = S.singleton (inf, inf);\n sl = 0; sr = 0; b = 0\n}\n", "language": "OCaml", "metadata": {"date": 1571524648, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03040.html", "problem_id": "p03040", "resource_group": "low_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/OCaml/s855494322.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s855494322", "user_id": "u798181098"}, "prompt_components": {"gold_output": "4 2\n1 -3\n", "input_to_evaluate": "\nmodule Set_ii = Set.Make(struct\n type t = int * int\n let compare (a, b) (d, e) =\n if a <> d then a-d else b-e\nend)\nmodule S = Set_ii\n\ntype state = { tl: Set_ii.t; tr: Set_ii.t; sl: int; sr: int; b: int }\n\nlet update {tl; tr; sl; sr; b=tb} n a b =\n let (vl, _ as el), (vr, _ as er) = S.max_elt tl, S.min_elt tr in\n let tl, ((vm, _) as m), tr, sl, sr =\n if a <= vl then\n let tl' = S.remove el tl in\n (S.add (a, n) tl', el, tr, sl-vl+a, sr)\n else if a <= vr then\n (tl, (a, n), tr, sl, sr)\n else\n let tr' = S.remove er tr in\n (tl, er, S.add (a, n) tr', sl, sr-vr+a)\n in\n if S.cardinal tl > S.cardinal tr then\n {tl; tr = S.add m tr; sl = sl; sr = sr+vm; b = tb+b}\n else\n {tl = S.add m tl; tr; sl = sl+vm; sr; b = tb+b}\n\nlet calc {tl; tr; sl; sr; b} =\n let x, _ = S.max_elt tl in\n let _, _ = S.min_elt tr in\n let sum = (S.cardinal tl - S.cardinal tr) * x - sl + sr + b in\n (x, sum)\n\nlet rec loop n st =\n if n = 0 then ()\n else Scanf.scanf \" %d\" @@ function\n | 1 -> Scanf.scanf \" %d %d\" (update st n) |> loop (n-1)\n | _ -> begin\n let x, fx = calc st in Printf.printf \"%d %d\\n\" x fx;\n loop (n-1) st\n end\n\nlet inf = 1000000000000\nlet _ = Scanf.scanf \"%d\" @@ fun q -> loop q {\n tl = S.singleton (-inf, -inf) ; tr = S.singleton (inf, inf);\n sl = 0; sr = 0; b = 0\n}\n", "problem_context": "Score : 600 points\n\nProblem Statement\n\nThere is a function f(x), which is initially a constant function f(x) = 0.\n\nWe will ask you to process Q queries in order. There are two kinds of queries, update queries and evaluation queries, as follows:\n\nAn update query 1 a b: Given two integers a and b, let g(x) = f(x) + |x - a| + b and replace f(x) with g(x).\n\nAn evaluation query 2: Print x that minimizes f(x), and the minimum value of f(x). If there are multiple such values of x, choose the minimum such value.\n\nWe can show that the values to be output in an evaluation query are always integers, so we ask you to print those values as integers without decimal points.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq Q \\leq 2 \\times 10^5\n\n-10^9 \\leq a, b \\leq 10^9\n\nThe first query is an update query.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nQ\nQuery_1\n:\nQuery_Q\n\nSee Sample Input 1 for an example.\n\nOutput\n\nFor each evaluation query, print a line containing the response, in the order in which the queries are given.\n\nThe response to each evaluation query should be the minimum value of x that minimizes f(x), and the minimum value of f(x), in this order, with space in between.\n\nSample Input 1\n\n4\n1 4 2\n2\n1 1 -8\n2\n\nSample Output 1\n\n4 2\n1 -3\n\nIn the first evaluation query, f(x) = |x - 4| + 2, which attains the minimum value of 2 at x = 4.\n\nIn the second evaluation query, f(x) = |x - 1| + |x - 4| - 6, which attains the minimum value of -3 when 1 \\leq x \\leq 4. Among the multiple values of x that minimize f(x), we ask you to print the minimum, that is, 1.\n\nSample Input 2\n\n4\n1 -1000000000 1000000000\n1 -1000000000 1000000000\n1 -1000000000 1000000000\n2\n\nSample Output 2\n\n-1000000000 3000000000", "sample_input": "4\n1 4 2\n2\n1 1 -8\n2\n"}, "reference_outputs": ["4 2\n1 -3\n"], "source_document_id": "p03040", "source_text": "Score : 600 points\n\nProblem Statement\n\nThere is a function f(x), which is initially a constant function f(x) = 0.\n\nWe will ask you to process Q queries in order. There are two kinds of queries, update queries and evaluation queries, as follows:\n\nAn update query 1 a b: Given two integers a and b, let g(x) = f(x) + |x - a| + b and replace f(x) with g(x).\n\nAn evaluation query 2: Print x that minimizes f(x), and the minimum value of f(x). If there are multiple such values of x, choose the minimum such value.\n\nWe can show that the values to be output in an evaluation query are always integers, so we ask you to print those values as integers without decimal points.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq Q \\leq 2 \\times 10^5\n\n-10^9 \\leq a, b \\leq 10^9\n\nThe first query is an update query.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nQ\nQuery_1\n:\nQuery_Q\n\nSee Sample Input 1 for an example.\n\nOutput\n\nFor each evaluation query, print a line containing the response, in the order in which the queries are given.\n\nThe response to each evaluation query should be the minimum value of x that minimizes f(x), and the minimum value of f(x), in this order, with space in between.\n\nSample Input 1\n\n4\n1 4 2\n2\n1 1 -8\n2\n\nSample Output 1\n\n4 2\n1 -3\n\nIn the first evaluation query, f(x) = |x - 4| + 2, which attains the minimum value of 2 at x = 4.\n\nIn the second evaluation query, f(x) = |x - 1| + |x - 4| - 6, which attains the minimum value of -3 when 1 \\leq x \\leq 4. Among the multiple values of x that minimize f(x), we ask you to print the minimum, that is, 1.\n\nSample Input 2\n\n4\n1 -1000000000 1000000000\n1 -1000000000 1000000000\n1 -1000000000 1000000000\n2\n\nSample Output 2\n\n-1000000000 3000000000", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1328, "cpu_time_ms": 2104, "memory_kb": 9472}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s843879987", "group_id": "codeNet:p03040", "input_text": "module IntMap = Map.Make (struct\n type t = int\n let compare = compare\nend)\n\nlet add a s =\n IntMap.add a (1 + try IntMap.find a s with Not_found -> 0) s\n\nlet remove a s =\n match IntMap.find a s with\n | exception Not_found -> s\n | 1 -> IntMap.remove a s\n | n -> IntMap.add a (n - 1) s\n\nlet _ =\n Array.fold_left (fun (odd, acc, (q, q')) ->\n let (m, _) = IntMap.max_binding q in\n function\n | None ->\n Printf.printf \"%d %d\\n\" m acc;\n (odd, acc, (q, q'))\n | Some (a, b) ->\n let (m', _) = IntMap.min_binding q' in\n not odd,\n (acc + b +\n if odd then\n abs (m - a)\n else\n if a <= m then\n m - a\n else if m' <= a then\n a - m'\n else 0),\n if a < m then\n let q = add a q in\n if odd then\n (remove (fst (IntMap.max_binding q)) q, add (fst (IntMap.max_binding q)) q')\n else\n (q, q')\n else\n let q' = add a q' in\n if odd then\n (q, add a q')\n else\n (add (fst (IntMap.min_binding q')) q), remove (fst (IntMap.min_binding q')) q')\n (false, 0, (IntMap.singleton min_int 1, IntMap.singleton max_int 1)) @@\n Scanf.scanf \"%d \" @@ fun q ->\n Array.init q @@ fun _ ->\n Scanf.scanf \"%d \" @@ function\n | 2 -> None\n | 1 -> Scanf.scanf \"%d %d \" @@ fun a b -> Some (a, b)\n", "language": "OCaml", "metadata": {"date": 1569288110, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03040.html", "problem_id": "p03040", "resource_group": "low_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/OCaml/s843879987.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s843879987", "user_id": "u504158101"}, "prompt_components": {"gold_output": "4 2\n1 -3\n", "input_to_evaluate": "module IntMap = Map.Make (struct\n type t = int\n let compare = compare\nend)\n\nlet add a s =\n IntMap.add a (1 + try IntMap.find a s with Not_found -> 0) s\n\nlet remove a s =\n match IntMap.find a s with\n | exception Not_found -> s\n | 1 -> IntMap.remove a s\n | n -> IntMap.add a (n - 1) s\n\nlet _ =\n Array.fold_left (fun (odd, acc, (q, q')) ->\n let (m, _) = IntMap.max_binding q in\n function\n | None ->\n Printf.printf \"%d %d\\n\" m acc;\n (odd, acc, (q, q'))\n | Some (a, b) ->\n let (m', _) = IntMap.min_binding q' in\n not odd,\n (acc + b +\n if odd then\n abs (m - a)\n else\n if a <= m then\n m - a\n else if m' <= a then\n a - m'\n else 0),\n if a < m then\n let q = add a q in\n if odd then\n (remove (fst (IntMap.max_binding q)) q, add (fst (IntMap.max_binding q)) q')\n else\n (q, q')\n else\n let q' = add a q' in\n if odd then\n (q, add a q')\n else\n (add (fst (IntMap.min_binding q')) q), remove (fst (IntMap.min_binding q')) q')\n (false, 0, (IntMap.singleton min_int 1, IntMap.singleton max_int 1)) @@\n Scanf.scanf \"%d \" @@ fun q ->\n Array.init q @@ fun _ ->\n Scanf.scanf \"%d \" @@ function\n | 2 -> None\n | 1 -> Scanf.scanf \"%d %d \" @@ fun a b -> Some (a, b)\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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1416, "cpu_time_ms": 416, "memory_kb": 24064}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s657896029", "group_id": "codeNet:p03040", "input_text": "module IntMap = Map.Make (struct\n type t = int\n let compare = compare\nend)\n\nlet add a s =\n IntMap.add a (1 + try IntMap.find a s with Not_found -> 0) s\n\nlet remove a s =\n match IntMap.find a s with\n | exception Not_found -> s\n | 1 -> IntMap.remove a s\n | n -> IntMap.add a (n - 1) s\n\nlet _ = Scanf.scanf \"%d\\n1 %d %d\\n\" @@ fun q a b ->\n Array.fold_left (fun (acc, (n, n', q, q', sum, sum')) ->\n let (m, _) = IntMap.max_binding q in\n function\n | None ->\n Printf.printf \"%d %d\\n\" m\n (acc + (n * m - sum) + (sum' - n' * m));\n (acc, (n, n', q, q', sum, sum'))\n | Some (a, b) ->\n acc + b,\n if a < m then\n if n <= n'\n then (n + 1, n', add a q, q', sum + a, sum')\n else (n, n' + 1, add a (remove m q), add m q', sum + a - m, sum' + m)\n else\n if n' < n\n then (n, n' + 1, q, add a q', sum, sum' + a)\n else (n + 1, n', add m q, add a (remove m q'), sum + m, sum' + a - m))\n (b, (1, 0, IntMap.singleton a 1, IntMap.empty, a, 0)) @@\n Array.init (q - 1) @@ fun _ ->\n Scanf.scanf \"%d \" @@ function\n | 2 -> None\n | 1 -> Scanf.scanf \"%d %d \" @@ fun a b -> Some (a, b)\n", "language": "OCaml", "metadata": {"date": 1569285424, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03040.html", "problem_id": "p03040", "resource_group": "low_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/OCaml/s657896029.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s657896029", "user_id": "u504158101"}, "prompt_components": {"gold_output": "4 2\n1 -3\n", "input_to_evaluate": "module IntMap = Map.Make (struct\n type t = int\n let compare = compare\nend)\n\nlet add a s =\n IntMap.add a (1 + try IntMap.find a s with Not_found -> 0) s\n\nlet remove a s =\n match IntMap.find a s with\n | exception Not_found -> s\n | 1 -> IntMap.remove a s\n | n -> IntMap.add a (n - 1) s\n\nlet _ = Scanf.scanf \"%d\\n1 %d %d\\n\" @@ fun q a b ->\n Array.fold_left (fun (acc, (n, n', q, q', sum, sum')) ->\n let (m, _) = IntMap.max_binding q in\n function\n | None ->\n Printf.printf \"%d %d\\n\" m\n (acc + (n * m - sum) + (sum' - n' * m));\n (acc, (n, n', q, q', sum, sum'))\n | Some (a, b) ->\n acc + b,\n if a < m then\n if n <= n'\n then (n + 1, n', add a q, q', sum + a, sum')\n else (n, n' + 1, add a (remove m q), add m q', sum + a - m, sum' + m)\n else\n if n' < n\n then (n, n' + 1, q, add a q', sum, sum' + a)\n else (n + 1, n', add m q, add a (remove m q'), sum + m, sum' + a - m))\n (b, (1, 0, IntMap.singleton a 1, IntMap.empty, a, 0)) @@\n Array.init (q - 1) @@ fun _ ->\n Scanf.scanf \"%d \" @@ function\n | 2 -> None\n | 1 -> Scanf.scanf \"%d %d \" @@ fun a b -> Some (a, b)\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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 353, "memory_kb": 24192}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s111049321", "group_id": "codeNet:p03041", "input_text": "let n, k, s = Scanf.scanf \" %d %d %s\" @@ fun a b c -> a, b - 1, Bytes.of_string c\nlet _ = Bytes.set s k @@ Char.lowercase @@ Bytes.get s k; print_endline @@ Bytes.to_string s", "language": "OCaml", "metadata": {"date": 1563844650, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03041.html", "problem_id": "p03041", "resource_group": "low_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/OCaml/s111049321.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s111049321", "user_id": "u732304692"}, "prompt_components": {"gold_output": "aBC\n", "input_to_evaluate": "let n, k, s = Scanf.scanf \" %d %d %s\" @@ fun a b c -> a, b - 1, Bytes.of_string c\nlet _ = Bytes.set s k @@ Char.lowercase @@ Bytes.get s k; print_endline @@ Bytes.to_string s", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s351270684", "group_id": "codeNet:p03041", "input_text": "open Printf open Scanf\nopen Array\n\nlet () = scanf \" %d %d %s\" @@ fun n k s ->\n let a = init n (fun i -> s.[i]) in\n a.(k-1) <- Char.lowercase @@ a.(k-1);\n iter (print_char) a\n\n", "language": "OCaml", "metadata": {"date": 1558325684, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03041.html", "problem_id": "p03041", "resource_group": "low_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/OCaml/s351270684.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s351270684", "user_id": "u481480055"}, "prompt_components": {"gold_output": "aBC\n", "input_to_evaluate": "open Printf open Scanf\nopen Array\n\nlet () = scanf \" %d %d %s\" @@ fun n k s ->\n let a = init n (fun i -> s.[i]) in\n a.(k-1) <- Char.lowercase @@ a.(k-1);\n iter (print_char) a\n\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou are given a string S of length N consisting of A, B and C, and an integer K which is between 1 and N (inclusive).\nPrint the string S after lowercasing the K-th character in it.\n\nConstraints\n\n1 ≤ N ≤ 50\n\n1 ≤ K ≤ N\n\nS is a string of length N consisting of A, B and C.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nS\n\nOutput\n\nPrint the string S after lowercasing the K-th character in it.\n\nSample Input 1\n\n3 1\nABC\n\nSample Output 1\n\naBC\n\nSample Input 2\n\n4 3\nCABA\n\nSample Output 2\n\nCAbA", "sample_input": "3 1\nABC\n"}, "reference_outputs": ["aBC\n"], "source_document_id": "p03041", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou are given a string S of length N consisting of A, B and C, and an integer K which is between 1 and N (inclusive).\nPrint the string S after lowercasing the K-th character in it.\n\nConstraints\n\n1 ≤ N ≤ 50\n\n1 ≤ K ≤ N\n\nS is a string of length N consisting of A, B and C.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nS\n\nOutput\n\nPrint the string S after lowercasing the K-th character in it.\n\nSample Input 1\n\n3 1\nABC\n\nSample Output 1\n\naBC\n\nSample Input 2\n\n4 3\nCABA\n\nSample Output 2\n\nCAbA", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s689645475", "group_id": "codeNet:p03042", "input_text": "let x, y = Scanf.scanf \" %2d%2d\" @@ fun a b -> a, b\nlet f n = n < 1 || n > 12\nlet _ = print_endline @@\n if f x then if f y then \"NA\" else \"YYMM\"\n else if f y then \"MMYY\" else \"AMBIGUOUS\"", "language": "OCaml", "metadata": {"date": 1563847304, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03042.html", "problem_id": "p03042", "resource_group": "low_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/OCaml/s689645475.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s689645475", "user_id": "u732304692"}, "prompt_components": {"gold_output": "YYMM\n", "input_to_evaluate": "let x, y = Scanf.scanf \" %2d%2d\" @@ fun a b -> a, b\nlet f n = n < 1 || n > 12\nlet _ = print_endline @@\n if f x then if f y then \"NA\" else \"YYMM\"\n else if f y then \"MMYY\" else \"AMBIGUOUS\"", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 188, "cpu_time_ms": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s028577855", "group_id": "codeNet:p03042", "input_text": "Scanf.scanf \"%s\" @@ fun s ->\n let n1 = String.sub s 0 2 |> int_of_string in\n let n2 = String.sub s 2 2 |> int_of_string in\n print_endline @@ if n1 > 12 || n1 = 0 then\n if n2 > 12 || n2 = 0 then\n \"NA\"\n else\n \"YYMM\"\n else\n if n2 > 12 || n2 = 0 then\n \"MMYY\"\n else\n \"AMBIGUOUS\"", "language": "OCaml", "metadata": {"date": 1558315278, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03042.html", "problem_id": "p03042", "resource_group": "low_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/OCaml/s028577855.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s028577855", "user_id": "u732304692"}, "prompt_components": {"gold_output": "YYMM\n", "input_to_evaluate": "Scanf.scanf \"%s\" @@ fun s ->\n let n1 = String.sub s 0 2 |> int_of_string in\n let n2 = String.sub s 2 2 |> int_of_string in\n print_endline @@ if n1 > 12 || n1 = 0 then\n if n2 > 12 || n2 = 0 then\n \"NA\"\n else\n \"YYMM\"\n else\n if n2 > 12 || n2 = 0 then\n \"MMYY\"\n else\n \"AMBIGUOUS\"", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 327, "cpu_time_ms": 1, "memory_kb": 2432}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s274708478", "group_id": "codeNet:p03042", "input_text": "let () = Scanf.scanf \"%2d%2d\" @@ fun up low ->\n let yymm = 1 <= low && low <= 12 in\n let mmyy = 1 <= up && up <= 12 in\n print_endline @@\n match yymm, mmyy with\n | true, true -> \"AMBIGUOUS\"\n | false, false -> \"NA\"\n | true, false -> \"YYMM\"\n | false, true -> \"MMYY\"", "language": "OCaml", "metadata": {"date": 1558314571, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03042.html", "problem_id": "p03042", "resource_group": "low_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/OCaml/s274708478.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s274708478", "user_id": "u504158101"}, "prompt_components": {"gold_output": "YYMM\n", "input_to_evaluate": "let () = Scanf.scanf \"%2d%2d\" @@ fun up low ->\n let yymm = 1 <= low && low <= 12 in\n let mmyy = 1 <= up && up <= 12 in\n print_endline @@\n match yymm, mmyy with\n | true, true -> \"AMBIGUOUS\"\n | false, false -> \"NA\"\n | true, false -> \"YYMM\"\n | false, true -> \"MMYY\"", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s373732507", "group_id": "codeNet:p03043", "input_text": "let ceil_exponent i k = \n let rec ceil_exponent' i k res = \n if i * (1 lsl res) >= k then res \n else ceil_exponent' i k (res + 1) in\n ceil_exponent' i k 0\n;;\n\nlet p n = 0.5 ** n;;\n\nlet solve n k = \n let rec sum' n k res = \n if n = 0 then res \n else sum' (n - 1) k (res +. (ceil_exponent n k |> float_of_int |> p)) in\n (sum' n k 0.) /. (float_of_int n)\n;;\n\nlet () = Scanf.scanf \"%d %d\" (fun n k -> print_float (solve n k));;", "language": "OCaml", "metadata": {"date": 1587442327, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03043.html", "problem_id": "p03043", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03043/input.txt", "sample_output_relpath": "derived/input_output/data/p03043/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03043/OCaml/s373732507.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s373732507", "user_id": "u541055501"}, "prompt_components": {"gold_output": "0.145833333333\n", "input_to_evaluate": "let ceil_exponent i k = \n let rec ceil_exponent' i k res = \n if i * (1 lsl res) >= k then res \n else ceil_exponent' i k (res + 1) in\n ceil_exponent' i k 0\n;;\n\nlet p n = 0.5 ** n;;\n\nlet solve n k = \n let rec sum' n k res = \n if n = 0 then res \n else sum' (n - 1) k (res +. (ceil_exponent n k |> float_of_int |> p)) in\n (sum' n k 0.) /. (float_of_int n)\n;;\n\nlet () = Scanf.scanf \"%d %d\" (fun n k -> print_float (solve n k));;", "problem_context": "Score : 300 points\n\nProblem Statement\n\nSnuke has a fair N-sided die that shows the integers from 1 to N with equal probability and a fair coin. He will play the following game with them:\n\nThrow the die. The current score is the result of the die.\n\nAs long as the score is between 1 and K-1 (inclusive), keep flipping the coin. The score is doubled each time the coin lands heads up, and the score becomes 0 if the coin lands tails up.\n\nThe game ends when the score becomes 0 or becomes K or above. Snuke wins if the score is K or above, and loses if the score is 0.\n\nYou are given N and K. Find the probability that Snuke wins the game.\n\nConstraints\n\n1 ≤ N ≤ 10^5\n\n1 ≤ K ≤ 10^5\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\n\nOutput\n\nPrint the probability that Snuke wins the game. The output is considered correct when the absolute or relative error is at most 10^{-9}.\n\nSample Input 1\n\n3 10\n\nSample Output 1\n\n0.145833333333\n\nIf the die shows 1, Snuke needs to get four consecutive heads from four coin flips to obtain a score of 10 or above. The probability of this happening is \\frac{1}{3} \\times (\\frac{1}{2})^4 = \\frac{1}{48}.\n\nIf the die shows 2, Snuke needs to get three consecutive heads from three coin flips to obtain a score of 10 or above. The probability of this happening is \\frac{1}{3} \\times (\\frac{1}{2})^3 = \\frac{1}{24}.\n\nIf the die shows 3, Snuke needs to get two consecutive heads from two coin flips to obtain a score of 10 or above. The probability of this happening is \\frac{1}{3} \\times (\\frac{1}{2})^2 = \\frac{1}{12}.\n\nThus, the probability that Snuke wins is \\frac{1}{48} + \\frac{1}{24} + \\frac{1}{12} = \\frac{7}{48} \\simeq 0.1458333333.\n\nSample Input 2\n\n100000 5\n\nSample Output 2\n\n0.999973749998", "sample_input": "3 10\n"}, "reference_outputs": ["0.145833333333\n"], "source_document_id": "p03043", "source_text": "Score : 300 points\n\nProblem Statement\n\nSnuke has a fair N-sided die that shows the integers from 1 to N with equal probability and a fair coin. He will play the following game with them:\n\nThrow the die. The current score is the result of the die.\n\nAs long as the score is between 1 and K-1 (inclusive), keep flipping the coin. The score is doubled each time the coin lands heads up, and the score becomes 0 if the coin lands tails up.\n\nThe game ends when the score becomes 0 or becomes K or above. Snuke wins if the score is K or above, and loses if the score is 0.\n\nYou are given N and K. Find the probability that Snuke wins the game.\n\nConstraints\n\n1 ≤ N ≤ 10^5\n\n1 ≤ K ≤ 10^5\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\n\nOutput\n\nPrint the probability that Snuke wins the game. The output is considered correct when the absolute or relative error is at most 10^{-9}.\n\nSample Input 1\n\n3 10\n\nSample Output 1\n\n0.145833333333\n\nIf the die shows 1, Snuke needs to get four consecutive heads from four coin flips to obtain a score of 10 or above. The probability of this happening is \\frac{1}{3} \\times (\\frac{1}{2})^4 = \\frac{1}{48}.\n\nIf the die shows 2, Snuke needs to get three consecutive heads from three coin flips to obtain a score of 10 or above. The probability of this happening is \\frac{1}{3} \\times (\\frac{1}{2})^3 = \\frac{1}{24}.\n\nIf the die shows 3, Snuke needs to get two consecutive heads from two coin flips to obtain a score of 10 or above. The probability of this happening is \\frac{1}{3} \\times (\\frac{1}{2})^2 = \\frac{1}{12}.\n\nThus, the probability that Snuke wins is \\frac{1}{48} + \\frac{1}{24} + \\frac{1}{12} = \\frac{7}{48} \\simeq 0.1458333333.\n\nSample Input 2\n\n100000 5\n\nSample Output 2\n\n0.999973749998", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 439, "cpu_time_ms": 4, "memory_kb": 2560}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s994152664", "group_id": "codeNet:p03043", "input_text": "let f i k = \n let res = ref 0 in\n while i * (1 lsl !res) < k do\n res := !res + 1\n done;\n !res\n;;\n\nlet g n = 0.5 ** n;;\n\nlet rec sum n k p = if n = 0 then 0. else sum (n - 1) k (p +. (f n k |> float_of_int |> g));;\n\nlet sum n k = (sum n k 0.) /. (float_of_int n);;\n\nlet () = Scanf.scanf \"%d %d\" (fun n k -> print_float (sum n k));;", "language": "OCaml", "metadata": {"date": 1587441936, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03043.html", "problem_id": "p03043", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03043/input.txt", "sample_output_relpath": "derived/input_output/data/p03043/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03043/OCaml/s994152664.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s994152664", "user_id": "u541055501"}, "prompt_components": {"gold_output": "0.145833333333\n", "input_to_evaluate": "let f i k = \n let res = ref 0 in\n while i * (1 lsl !res) < k do\n res := !res + 1\n done;\n !res\n;;\n\nlet g n = 0.5 ** n;;\n\nlet rec sum n k p = if n = 0 then 0. else sum (n - 1) k (p +. (f n k |> float_of_int |> g));;\n\nlet sum n k = (sum n k 0.) /. (float_of_int n);;\n\nlet () = Scanf.scanf \"%d %d\" (fun n k -> print_float (sum n k));;", "problem_context": "Score : 300 points\n\nProblem Statement\n\nSnuke has a fair N-sided die that shows the integers from 1 to N with equal probability and a fair coin. He will play the following game with them:\n\nThrow the die. The current score is the result of the die.\n\nAs long as the score is between 1 and K-1 (inclusive), keep flipping the coin. The score is doubled each time the coin lands heads up, and the score becomes 0 if the coin lands tails up.\n\nThe game ends when the score becomes 0 or becomes K or above. Snuke wins if the score is K or above, and loses if the score is 0.\n\nYou are given N and K. Find the probability that Snuke wins the game.\n\nConstraints\n\n1 ≤ N ≤ 10^5\n\n1 ≤ K ≤ 10^5\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\n\nOutput\n\nPrint the probability that Snuke wins the game. The output is considered correct when the absolute or relative error is at most 10^{-9}.\n\nSample Input 1\n\n3 10\n\nSample Output 1\n\n0.145833333333\n\nIf the die shows 1, Snuke needs to get four consecutive heads from four coin flips to obtain a score of 10 or above. The probability of this happening is \\frac{1}{3} \\times (\\frac{1}{2})^4 = \\frac{1}{48}.\n\nIf the die shows 2, Snuke needs to get three consecutive heads from three coin flips to obtain a score of 10 or above. The probability of this happening is \\frac{1}{3} \\times (\\frac{1}{2})^3 = \\frac{1}{24}.\n\nIf the die shows 3, Snuke needs to get two consecutive heads from two coin flips to obtain a score of 10 or above. The probability of this happening is \\frac{1}{3} \\times (\\frac{1}{2})^2 = \\frac{1}{12}.\n\nThus, the probability that Snuke wins is \\frac{1}{48} + \\frac{1}{24} + \\frac{1}{12} = \\frac{7}{48} \\simeq 0.1458333333.\n\nSample Input 2\n\n100000 5\n\nSample Output 2\n\n0.999973749998", "sample_input": "3 10\n"}, "reference_outputs": ["0.145833333333\n"], "source_document_id": "p03043", "source_text": "Score : 300 points\n\nProblem Statement\n\nSnuke has a fair N-sided die that shows the integers from 1 to N with equal probability and a fair coin. He will play the following game with them:\n\nThrow the die. The current score is the result of the die.\n\nAs long as the score is between 1 and K-1 (inclusive), keep flipping the coin. The score is doubled each time the coin lands heads up, and the score becomes 0 if the coin lands tails up.\n\nThe game ends when the score becomes 0 or becomes K or above. Snuke wins if the score is K or above, and loses if the score is 0.\n\nYou are given N and K. Find the probability that Snuke wins the game.\n\nConstraints\n\n1 ≤ N ≤ 10^5\n\n1 ≤ K ≤ 10^5\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\n\nOutput\n\nPrint the probability that Snuke wins the game. The output is considered correct when the absolute or relative error is at most 10^{-9}.\n\nSample Input 1\n\n3 10\n\nSample Output 1\n\n0.145833333333\n\nIf the die shows 1, Snuke needs to get four consecutive heads from four coin flips to obtain a score of 10 or above. The probability of this happening is \\frac{1}{3} \\times (\\frac{1}{2})^4 = \\frac{1}{48}.\n\nIf the die shows 2, Snuke needs to get three consecutive heads from three coin flips to obtain a score of 10 or above. The probability of this happening is \\frac{1}{3} \\times (\\frac{1}{2})^3 = \\frac{1}{24}.\n\nIf the die shows 3, Snuke needs to get two consecutive heads from two coin flips to obtain a score of 10 or above. The probability of this happening is \\frac{1}{3} \\times (\\frac{1}{2})^2 = \\frac{1}{12}.\n\nThus, the probability that Snuke wins is \\frac{1}{48} + \\frac{1}{24} + \\frac{1}{12} = \\frac{7}{48} \\simeq 0.1458333333.\n\nSample Input 2\n\n100000 5\n\nSample Output 2\n\n0.999973749998", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 4, "memory_kb": 2560}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s859011017", "group_id": "codeNet:p03043", "input_text": "let () =\n Scanf.scanf \"%d %d\" @@ fun n k ->\n Array.init n (fun i -> \n let rec aux c x = if x >= k then c else aux (c+1) (2*x) in\n 0.5 ** float_of_int (aux 0 (i+1)))\n |> Array.fold_left (+.) 0.\n |> fun p -> Printf.printf \"%.11f\\n\" (p /. float_of_int n)", "language": "OCaml", "metadata": {"date": 1558314970, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03043.html", "problem_id": "p03043", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03043/input.txt", "sample_output_relpath": "derived/input_output/data/p03043/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03043/OCaml/s859011017.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s859011017", "user_id": "u798181098"}, "prompt_components": {"gold_output": "0.145833333333\n", "input_to_evaluate": "let () =\n Scanf.scanf \"%d %d\" @@ fun n k ->\n Array.init n (fun i -> \n let rec aux c x = if x >= k then c else aux (c+1) (2*x) in\n 0.5 ** float_of_int (aux 0 (i+1)))\n |> Array.fold_left (+.) 0.\n |> fun p -> Printf.printf \"%.11f\\n\" (p /. float_of_int n)", "problem_context": "Score : 300 points\n\nProblem Statement\n\nSnuke has a fair N-sided die that shows the integers from 1 to N with equal probability and a fair coin. He will play the following game with them:\n\nThrow the die. The current score is the result of the die.\n\nAs long as the score is between 1 and K-1 (inclusive), keep flipping the coin. The score is doubled each time the coin lands heads up, and the score becomes 0 if the coin lands tails up.\n\nThe game ends when the score becomes 0 or becomes K or above. Snuke wins if the score is K or above, and loses if the score is 0.\n\nYou are given N and K. Find the probability that Snuke wins the game.\n\nConstraints\n\n1 ≤ N ≤ 10^5\n\n1 ≤ K ≤ 10^5\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\n\nOutput\n\nPrint the probability that Snuke wins the game. The output is considered correct when the absolute or relative error is at most 10^{-9}.\n\nSample Input 1\n\n3 10\n\nSample Output 1\n\n0.145833333333\n\nIf the die shows 1, Snuke needs to get four consecutive heads from four coin flips to obtain a score of 10 or above. The probability of this happening is \\frac{1}{3} \\times (\\frac{1}{2})^4 = \\frac{1}{48}.\n\nIf the die shows 2, Snuke needs to get three consecutive heads from three coin flips to obtain a score of 10 or above. The probability of this happening is \\frac{1}{3} \\times (\\frac{1}{2})^3 = \\frac{1}{24}.\n\nIf the die shows 3, Snuke needs to get two consecutive heads from two coin flips to obtain a score of 10 or above. The probability of this happening is \\frac{1}{3} \\times (\\frac{1}{2})^2 = \\frac{1}{12}.\n\nThus, the probability that Snuke wins is \\frac{1}{48} + \\frac{1}{24} + \\frac{1}{12} = \\frac{7}{48} \\simeq 0.1458333333.\n\nSample Input 2\n\n100000 5\n\nSample Output 2\n\n0.999973749998", "sample_input": "3 10\n"}, "reference_outputs": ["0.145833333333\n"], "source_document_id": "p03043", "source_text": "Score : 300 points\n\nProblem Statement\n\nSnuke has a fair N-sided die that shows the integers from 1 to N with equal probability and a fair coin. He will play the following game with them:\n\nThrow the die. The current score is the result of the die.\n\nAs long as the score is between 1 and K-1 (inclusive), keep flipping the coin. The score is doubled each time the coin lands heads up, and the score becomes 0 if the coin lands tails up.\n\nThe game ends when the score becomes 0 or becomes K or above. Snuke wins if the score is K or above, and loses if the score is 0.\n\nYou are given N and K. Find the probability that Snuke wins the game.\n\nConstraints\n\n1 ≤ N ≤ 10^5\n\n1 ≤ K ≤ 10^5\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\n\nOutput\n\nPrint the probability that Snuke wins the game. The output is considered correct when the absolute or relative error is at most 10^{-9}.\n\nSample Input 1\n\n3 10\n\nSample Output 1\n\n0.145833333333\n\nIf the die shows 1, Snuke needs to get four consecutive heads from four coin flips to obtain a score of 10 or above. The probability of this happening is \\frac{1}{3} \\times (\\frac{1}{2})^4 = \\frac{1}{48}.\n\nIf the die shows 2, Snuke needs to get three consecutive heads from three coin flips to obtain a score of 10 or above. The probability of this happening is \\frac{1}{3} \\times (\\frac{1}{2})^3 = \\frac{1}{24}.\n\nIf the die shows 3, Snuke needs to get two consecutive heads from two coin flips to obtain a score of 10 or above. The probability of this happening is \\frac{1}{3} \\times (\\frac{1}{2})^2 = \\frac{1}{12}.\n\nThus, the probability that Snuke wins is \\frac{1}{48} + \\frac{1}{24} + \\frac{1}{12} = \\frac{7}{48} \\simeq 0.1458333333.\n\nSample Input 2\n\n100000 5\n\nSample Output 2\n\n0.999973749998", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 5, "memory_kb": 4736}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s128086223", "group_id": "codeNet:p03044", "input_text": "(* O(n) *)\nScanf.scanf \" %d\" @@ fun n ->\n let g = Array.make n [] in\n for _ = 1 to n - 1 do\n Scanf.scanf \" %d %d %d\" @@ fun u v w ->\n let u, v = u - 1, v - 1 in\n g.(u) <- (v, w mod 2 = 0) :: g.(u);\n g.(v) <- (u, w mod 2 = 0) :: g.(v);\n done;\n let cs = Array.make n 0 in\n let rec dfs v p c =\n cs.(v) <- c;\n let f (v2, w) = if v2 <> p then dfs v2 v @@ if w then c else -c in\n List.iter f g.(v) in\n dfs 0 (-1) 1;\n Array.iter (fun c -> max 0 c |> Printf.printf \"%d\\n\") cs", "language": "OCaml", "metadata": {"date": 1559360150, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03044.html", "problem_id": "p03044", "resource_group": "low_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/OCaml/s128086223.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s128086223", "user_id": "u732304692"}, "prompt_components": {"gold_output": "0\n0\n1\n", "input_to_evaluate": "(* O(n) *)\nScanf.scanf \" %d\" @@ fun n ->\n let g = Array.make n [] in\n for _ = 1 to n - 1 do\n Scanf.scanf \" %d %d %d\" @@ fun u v w ->\n let u, v = u - 1, v - 1 in\n g.(u) <- (v, w mod 2 = 0) :: g.(u);\n g.(v) <- (u, w mod 2 = 0) :: g.(v);\n done;\n let cs = Array.make n 0 in\n let rec dfs v p c =\n cs.(v) <- c;\n let f (v2, w) = if v2 <> p then dfs v2 v @@ if w then c else -c in\n List.iter f g.(v) in\n dfs 0 (-1) 1;\n Array.iter (fun c -> max 0 c |> Printf.printf \"%d\\n\") cs", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 507, "cpu_time_ms": 142, "memory_kb": 20224}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s494462471", "group_id": "codeNet:p03044", "input_text": "\ntype color = Black | White\ntype node = {color: color option; children: (int * int) list}\n\nlet from_white tree =\n let rec inner aux idx =\n match tree.(idx).color with\n | Some _ -> ()\n | None ->\n if aux mod 2 = 0 then\n begin\n tree.(idx) <- {tree.(idx) with color = Some White};\n List.iter (fun (idx', w) -> inner (aux + w) idx') tree.(idx).children\n end\n else \n begin\n tree.(idx) <- {tree.(idx) with color = Some Black};\n List.iter (fun (idx', w) -> inner (aux + w) idx') tree.(idx).children\n end\n in inner 0 0; tree\n\nlet str_of_color = function None -> \"N\" | Some Black -> \"1\" | Some White -> \"0\"\n\nlet tree_to_answer tree =\n Array.iter (fun node -> node.color |> str_of_color |> print_endline) tree\n\nlet () =\n let n = Scanf.scanf \"%d\\n\" (fun n -> n) in\n let tree = Array.make n {color = None; children = []} in\n for i = 1 to n - 1 do \n Scanf.scanf \"%d %d %d\\n\"\n (fun u v w ->\n tree.(u-1) <- {color=None; children = (v-1, w)::tree.(u-1).children};\n tree.(v-1) <- {color=None; children = (u-1, w)::tree.(v-1).children}\n )\n done;\n from_white tree\n |> tree_to_answer\n", "language": "OCaml", "metadata": {"date": 1558319910, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03044.html", "problem_id": "p03044", "resource_group": "low_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/OCaml/s494462471.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s494462471", "user_id": "u387591304"}, "prompt_components": {"gold_output": "0\n0\n1\n", "input_to_evaluate": "\ntype color = Black | White\ntype node = {color: color option; children: (int * int) list}\n\nlet from_white tree =\n let rec inner aux idx =\n match tree.(idx).color with\n | Some _ -> ()\n | None ->\n if aux mod 2 = 0 then\n begin\n tree.(idx) <- {tree.(idx) with color = Some White};\n List.iter (fun (idx', w) -> inner (aux + w) idx') tree.(idx).children\n end\n else \n begin\n tree.(idx) <- {tree.(idx) with color = Some Black};\n List.iter (fun (idx', w) -> inner (aux + w) idx') tree.(idx).children\n end\n in inner 0 0; tree\n\nlet str_of_color = function None -> \"N\" | Some Black -> \"1\" | Some White -> \"0\"\n\nlet tree_to_answer tree =\n Array.iter (fun node -> node.color |> str_of_color |> print_endline) tree\n\nlet () =\n let n = Scanf.scanf \"%d\\n\" (fun n -> n) in\n let tree = Array.make n {color = None; children = []} in\n for i = 1 to n - 1 do \n Scanf.scanf \"%d %d %d\\n\"\n (fun u v w ->\n tree.(u-1) <- {color=None; children = (v-1, w)::tree.(u-1).children};\n tree.(v-1) <- {color=None; children = (u-1, w)::tree.(v-1).children}\n )\n done;\n from_white tree\n |> tree_to_answer\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nWe have a tree with N vertices numbered 1 to N.\nThe i-th edge in the tree connects Vertex u_i and Vertex v_i, and its length is w_i.\nYour objective is to paint each vertex in the tree white or black (it is fine to paint all vertices the same color) so that the following condition is satisfied:\n\nFor any two vertices painted in the same color, the distance between them is an even number.\n\nFind a coloring of the vertices that satisfies the condition and print it. It can be proved that at least one such coloring exists under the constraints of this problem.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\leq u_i < v_i \\leq N\n\n1 \\leq w_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nu_1 v_1 w_1\nu_2 v_2 w_2\n.\n.\n.\nu_{N - 1} v_{N - 1} w_{N - 1}\n\nOutput\n\nPrint a coloring of the vertices that satisfies the condition, in N lines.\nThe i-th line should contain 0 if Vertex i is painted white and 1 if it is painted black.\n\nIf there are multiple colorings that satisfy the condition, any of them will be accepted.\n\nSample Input 1\n\n3\n1 2 2\n2 3 1\n\nSample Output 1\n\n0\n0\n1\n\nSample Input 2\n\n5\n2 5 2\n2 3 10\n1 3 8\n3 4 2\n\nSample Output 2\n\n1\n0\n1\n0\n1", "sample_input": "3\n1 2 2\n2 3 1\n"}, "reference_outputs": ["0\n0\n1\n"], "source_document_id": "p03044", "source_text": "Score : 400 points\n\nProblem Statement\n\nWe have a tree with N vertices numbered 1 to N.\nThe i-th edge in the tree connects Vertex u_i and Vertex v_i, and its length is w_i.\nYour objective is to paint each vertex in the tree white or black (it is fine to paint all vertices the same color) so that the following condition is satisfied:\n\nFor any two vertices painted in the same color, the distance between them is an even number.\n\nFind a coloring of the vertices that satisfies the condition and print it. It can be proved that at least one such coloring exists under the constraints of this problem.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\leq u_i < v_i \\leq N\n\n1 \\leq w_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nu_1 v_1 w_1\nu_2 v_2 w_2\n.\n.\n.\nu_{N - 1} v_{N - 1} w_{N - 1}\n\nOutput\n\nPrint a coloring of the vertices that satisfies the condition, in N lines.\nThe i-th line should contain 0 if Vertex i is painted white and 1 if it is painted black.\n\nIf there are multiple colorings that satisfy the condition, any of them will be accepted.\n\nSample Input 1\n\n3\n1 2 2\n2 3 1\n\nSample Output 1\n\n0\n0\n1\n\nSample Input 2\n\n5\n2 5 2\n2 3 10\n1 3 8\n3 4 2\n\nSample Output 2\n\n1\n0\n1\n0\n1", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1192, "cpu_time_ms": 287, "memory_kb": 23296}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s755495952", "group_id": "codeNet:p03044", "input_text": "let () =\n Scanf.scanf \"%d\" @@ fun n ->\n let g = Array.init n (fun _ -> []) in\n for _ = 2 to n do\n Scanf.scanf \" %d %d %d\" @@ fun u v w ->\n let u, v = u-1, v-1 in\n g.(u) <- (v, w mod 2) :: g.(u);\n g.(v) <- (u, w mod 2) :: g.(v);\n done;\n let cs = Array.make n (-1) in\n let rec dfs u c p =\n cs.(u) <- c;\n g.(u) |> List.iter (fun (v, w) -> if p <> v then dfs v ((c + w) mod 2) u)\n in\n dfs 0 0 (-1);\n Array.iter (Printf.printf \"%d\\n\") cs;\n", "language": "OCaml", "metadata": {"date": 1558315512, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03044.html", "problem_id": "p03044", "resource_group": "low_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/OCaml/s755495952.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s755495952", "user_id": "u798181098"}, "prompt_components": {"gold_output": "0\n0\n1\n", "input_to_evaluate": "let () =\n Scanf.scanf \"%d\" @@ fun n ->\n let g = Array.init n (fun _ -> []) in\n for _ = 2 to n do\n Scanf.scanf \" %d %d %d\" @@ fun u v w ->\n let u, v = u-1, v-1 in\n g.(u) <- (v, w mod 2) :: g.(u);\n g.(v) <- (u, w mod 2) :: g.(v);\n done;\n let cs = Array.make n (-1) in\n let rec dfs u c p =\n cs.(u) <- c;\n g.(u) |> List.iter (fun (v, w) -> if p <> v then dfs v ((c + w) mod 2) u)\n in\n dfs 0 0 (-1);\n Array.iter (Printf.printf \"%d\\n\") cs;\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nWe have a tree with N vertices numbered 1 to N.\nThe i-th edge in the tree connects Vertex u_i and Vertex v_i, and its length is w_i.\nYour objective is to paint each vertex in the tree white or black (it is fine to paint all vertices the same color) so that the following condition is satisfied:\n\nFor any two vertices painted in the same color, the distance between them is an even number.\n\nFind a coloring of the vertices that satisfies the condition and print it. It can be proved that at least one such coloring exists under the constraints of this problem.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\leq u_i < v_i \\leq N\n\n1 \\leq w_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nu_1 v_1 w_1\nu_2 v_2 w_2\n.\n.\n.\nu_{N - 1} v_{N - 1} w_{N - 1}\n\nOutput\n\nPrint a coloring of the vertices that satisfies the condition, in N lines.\nThe i-th line should contain 0 if Vertex i is painted white and 1 if it is painted black.\n\nIf there are multiple colorings that satisfy the condition, any of them will be accepted.\n\nSample Input 1\n\n3\n1 2 2\n2 3 1\n\nSample Output 1\n\n0\n0\n1\n\nSample Input 2\n\n5\n2 5 2\n2 3 10\n1 3 8\n3 4 2\n\nSample Output 2\n\n1\n0\n1\n0\n1", "sample_input": "3\n1 2 2\n2 3 1\n"}, "reference_outputs": ["0\n0\n1\n"], "source_document_id": "p03044", "source_text": "Score : 400 points\n\nProblem Statement\n\nWe have a tree with N vertices numbered 1 to N.\nThe i-th edge in the tree connects Vertex u_i and Vertex v_i, and its length is w_i.\nYour objective is to paint each vertex in the tree white or black (it is fine to paint all vertices the same color) so that the following condition is satisfied:\n\nFor any two vertices painted in the same color, the distance between them is an even number.\n\nFind a coloring of the vertices that satisfies the condition and print it. It can be proved that at least one such coloring exists under the constraints of this problem.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\leq u_i < v_i \\leq N\n\n1 \\leq w_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nu_1 v_1 w_1\nu_2 v_2 w_2\n.\n.\n.\nu_{N - 1} v_{N - 1} w_{N - 1}\n\nOutput\n\nPrint a coloring of the vertices that satisfies the condition, in N lines.\nThe i-th line should contain 0 if Vertex i is painted white and 1 if it is painted black.\n\nIf there are multiple colorings that satisfy the condition, any of them will be accepted.\n\nSample Input 1\n\n3\n1 2 2\n2 3 1\n\nSample Output 1\n\n0\n0\n1\n\nSample Input 2\n\n5\n2 5 2\n2 3 10\n1 3 8\n3 4 2\n\nSample Output 2\n\n1\n0\n1\n0\n1", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 461, "cpu_time_ms": 140, "memory_kb": 20224}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s529134645", "group_id": "codeNet:p03045", "input_text": "(* 配列版素集合データ構造 *)\nmodule UnionFind : sig\n type t\n\n module Class : sig\n type t\n val compare : t -> t -> int\n end\n\n (* n要素の素集合データ構造を作る *)\n val make : int -> t\n (* 要素がどの集合に属するか調べる *)\n (* 要素は0からn-1の整数である必要がある *)\n val find : t -> int -> Class.t\n (* 与えられた集合同士を合併する *)\n (* 破壊的操作であるため注意 *)\n val unite : t -> Class.t -> Class.t -> unit\n (* 与えられた集合に属する要素の数を求める *)\n val cardinal : t -> Class.t -> int\nend = struct\n type t = int array\n\n module Class = struct\n type t = int\n let compare = compare\n end\n\n let make n = Array.make n (-1)\n\n let rec find uf x =\n if uf.(x) < 0 then x\n else begin\n let y = find uf uf.(x) in\n uf.(x) <- y; y\n end\n\n let unite uf x y =\n if x <> y then begin\n let x, y = if uf.(x) <= uf.(y) then x, y else y, x in\n uf.(x) <- uf.(x) + uf.(y);\n uf.(y) <- x\n end\n\n let cardinal uf x = ~- (uf.(x))\nend\n\nmodule ClassSet = Set.Make (UnionFind.Class)\n\nlet () = Scanf.scanf \"%d %d\\n\" @@ fun n m ->\n let uf = UnionFind.make n in\n for i = 0 to m - 1 do\n Scanf.scanf \"%d %d %d\\n\" @@ fun x y _ ->\n UnionFind.unite uf\n (UnionFind.find uf (x - 1))\n (UnionFind.find uf (y - 1))\n done;\n Printf.printf \"%d\\n\" @@\n ClassSet.cardinal @@\n Array.fold_right ClassSet.add (Array.init n @@ UnionFind.find uf) ClassSet.empty", "language": "OCaml", "metadata": {"date": 1558316053, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03045.html", "problem_id": "p03045", "resource_group": "low_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/OCaml/s529134645.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s529134645", "user_id": "u504158101"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "(* 配列版素集合データ構造 *)\nmodule UnionFind : sig\n type t\n\n module Class : sig\n type t\n val compare : t -> t -> int\n end\n\n (* n要素の素集合データ構造を作る *)\n val make : int -> t\n (* 要素がどの集合に属するか調べる *)\n (* 要素は0からn-1の整数である必要がある *)\n val find : t -> int -> Class.t\n (* 与えられた集合同士を合併する *)\n (* 破壊的操作であるため注意 *)\n val unite : t -> Class.t -> Class.t -> unit\n (* 与えられた集合に属する要素の数を求める *)\n val cardinal : t -> Class.t -> int\nend = struct\n type t = int array\n\n module Class = struct\n type t = int\n let compare = compare\n end\n\n let make n = Array.make n (-1)\n\n let rec find uf x =\n if uf.(x) < 0 then x\n else begin\n let y = find uf uf.(x) in\n uf.(x) <- y; y\n end\n\n let unite uf x y =\n if x <> y then begin\n let x, y = if uf.(x) <= uf.(y) then x, y else y, x in\n uf.(x) <- uf.(x) + uf.(y);\n uf.(y) <- x\n end\n\n let cardinal uf x = ~- (uf.(x))\nend\n\nmodule ClassSet = Set.Make (UnionFind.Class)\n\nlet () = Scanf.scanf \"%d %d\\n\" @@ fun n m ->\n let uf = UnionFind.make n in\n for i = 0 to m - 1 do\n Scanf.scanf \"%d %d %d\\n\" @@ fun x y _ ->\n UnionFind.unite uf\n (UnionFind.find uf (x - 1))\n (UnionFind.find uf (y - 1))\n done;\n Printf.printf \"%d\\n\" @@\n ClassSet.cardinal @@\n Array.fold_right ClassSet.add (Array.init n @@ UnionFind.find uf) ClassSet.empty", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1510, "cpu_time_ms": 112, "memory_kb": 7296}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s998392275", "group_id": "codeNet:p03047", "input_text": "(* O(n) *)\nlet solve n k =\n let rec find acc i =\n if i + k - 1 > n then\n acc\n else\n find (acc + 1) (i + 1)\n in\n find 0 1\n\nlet read_ints () = read_line () |> Str.split (Str.regexp \" \") |> List.map int_of_string\n\nlet _ =\n match read_ints () with\n | [n; k] -> solve n k |> string_of_int |> print_endline\n | _ -> ()", "language": "OCaml", "metadata": {"date": 1557696473, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03047.html", "problem_id": "p03047", "resource_group": "low_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/OCaml/s998392275.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s998392275", "user_id": "u732304692"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "(* O(n) *)\nlet solve n k =\n let rec find acc i =\n if i + k - 1 > n then\n acc\n else\n find (acc + 1) (i + 1)\n in\n find 0 1\n\nlet read_ints () = read_line () |> Str.split (Str.regexp \" \") |> List.map int_of_string\n\nlet _ =\n match read_ints () with\n | [n; k] -> solve n k |> string_of_int |> print_endline\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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s269556031", "group_id": "codeNet:p03048", "input_text": "let (r, g, b, n) = Scanf.sscanf (read_line ()) \"%d %d %d %d\" @@ fun r g b n -> (r, g, b, n)\n\nlet () =\n let ans = ref 0 in\n for i = 0 to n / r do\n for j = 0 to n / g do\n let sum = r * i + j * g in\n if sum <= n && (n - sum) mod b = 0 then ans := !ans + 1\n done\n done;\n Printf.printf \"%d\\n\" !ans", "language": "OCaml", "metadata": {"date": 1590209335, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03048.html", "problem_id": "p03048", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03048/input.txt", "sample_output_relpath": "derived/input_output/data/p03048/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03048/OCaml/s269556031.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s269556031", "user_id": "u811309788"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "let (r, g, b, n) = Scanf.sscanf (read_line ()) \"%d %d %d %d\" @@ fun r g b n -> (r, g, b, n)\n\nlet () =\n let ans = ref 0 in\n for i = 0 to n / r do\n for j = 0 to n / g do\n let sum = r * i + j * g in\n if sum <= n && (n - sum) mod b = 0 then ans := !ans + 1\n done\n done;\n Printf.printf \"%d\\n\" !ans", "problem_context": "Score : 200 points\n\nProblem Statement\n\nSnuke has come to a store that sells boxes containing balls. The store sells the following three kinds of boxes:\n\nRed boxes, each containing R red balls\n\nGreen boxes, each containing G green balls\n\nBlue boxes, each containing B blue balls\n\nSnuke wants to get a total of exactly N balls by buying r red boxes, g green boxes and b blue boxes.\nHow many triples of non-negative integers (r,g,b) achieve this?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq R,G,B,N \\leq 3000\n\nInput\n\nInput is given from Standard Input in the following format:\n\nR G B N\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n1 2 3 4\n\nSample Output 1\n\n4\n\nFour triples achieve the objective, as follows:\n\n(4,0,0)\n\n(2,1,0)\n\n(1,0,1)\n\n(0,2,0)\n\nSample Input 2\n\n13 1 4 3000\n\nSample Output 2\n\n87058", "sample_input": "1 2 3 4\n"}, "reference_outputs": ["4\n"], "source_document_id": "p03048", "source_text": "Score : 200 points\n\nProblem Statement\n\nSnuke has come to a store that sells boxes containing balls. The store sells the following three kinds of boxes:\n\nRed boxes, each containing R red balls\n\nGreen boxes, each containing G green balls\n\nBlue boxes, each containing B blue balls\n\nSnuke wants to get a total of exactly N balls by buying r red boxes, g green boxes and b blue boxes.\nHow many triples of non-negative integers (r,g,b) achieve this?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq R,G,B,N \\leq 3000\n\nInput\n\nInput is given from Standard Input in the following format:\n\nR G B N\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n1 2 3 4\n\nSample Output 1\n\n4\n\nFour triples achieve the objective, as follows:\n\n(4,0,0)\n\n(2,1,0)\n\n(1,0,1)\n\n(0,2,0)\n\nSample Input 2\n\n13 1 4 3000\n\nSample Output 2\n\n87058", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 312, "cpu_time_ms": 69, "memory_kb": 4480}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s873650385", "group_id": "codeNet:p03049", "input_text": "open Printf open Scanf\nopen Array\n\nlet print_list f ls = List.iter (fun v -> printf \"%s \" @@ f v) ls; print_newline ()\n\n(* rosetta code *)\nlet count_substring str sub =\n let sub_len = String.length sub in\n let len_diff = (String.length str) - sub_len\n and reg = Str.regexp_string sub in\n let rec aux i n =\n if i > len_diff then n else\n try\n let pos = Str.search_forward reg str i in\n aux (pos + sub_len) (succ n)\n with Not_found -> n\n in\n aux 0 0\n\nlet () = scanf \" %d\" @@ fun n ->\n let arr = init n (fun _ -> scanf \" %s\" @@ fun s -> s)\n in\n let kba,kbx,kxa,krest = fold_left (fun (kba,kbx,kxa,krest) s ->\n let bx = s.[0] = 'B' in\n let xa = s.[String.length s-1] = 'A' in\n let ab = bx && xa in\n let kba = if ab then kba + 1 else kba in\n let kbx = if not ab then (\n if bx then kbx+1 else kbx\n ) else kbx in\n let kxa = if not ab then (\n if xa then kxa+1 else kxa\n ) else kxa in\n let krest = krest + count_substring s \"AB\"\n in\n (kba,kbx,kxa,krest)\n ) (0,0,0,0) arr in\n let hoge =\n if kba >= 1 then (\n let pair_ba = kba - 1 in\n let res = 0 in\n let res,kbx =\n if kbx > 0 then res+1,kbx-1 else res,kbx in\n let res,kxa =\n if kxa > 0 then res+1,kxa-1 else res,kxa in\n pair_ba + res + min kbx kxa\n ) else (\n min kbx kxa\n ) in\n print_int @@ krest + hoge\n\n\n", "language": "OCaml", "metadata": {"date": 1557691761, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03049.html", "problem_id": "p03049", "resource_group": "low_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/OCaml/s873650385.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s873650385", "user_id": "u481480055"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "open Printf open Scanf\nopen Array\n\nlet print_list f ls = List.iter (fun v -> printf \"%s \" @@ f v) ls; print_newline ()\n\n(* rosetta code *)\nlet count_substring str sub =\n let sub_len = String.length sub in\n let len_diff = (String.length str) - sub_len\n and reg = Str.regexp_string sub in\n let rec aux i n =\n if i > len_diff then n else\n try\n let pos = Str.search_forward reg str i in\n aux (pos + sub_len) (succ n)\n with Not_found -> n\n in\n aux 0 0\n\nlet () = scanf \" %d\" @@ fun n ->\n let arr = init n (fun _ -> scanf \" %s\" @@ fun s -> s)\n in\n let kba,kbx,kxa,krest = fold_left (fun (kba,kbx,kxa,krest) s ->\n let bx = s.[0] = 'B' in\n let xa = s.[String.length s-1] = 'A' in\n let ab = bx && xa in\n let kba = if ab then kba + 1 else kba in\n let kbx = if not ab then (\n if bx then kbx+1 else kbx\n ) else kbx in\n let kxa = if not ab then (\n if xa then kxa+1 else kxa\n ) else kxa in\n let krest = krest + count_substring s \"AB\"\n in\n (kba,kbx,kxa,krest)\n ) (0,0,0,0) arr in\n let hoge =\n if kba >= 1 then (\n let pair_ba = kba - 1 in\n let res = 0 in\n let res,kbx =\n if kbx > 0 then res+1,kbx-1 else res,kbx in\n let res,kxa =\n if kxa > 0 then res+1,kxa-1 else res,kxa in\n pair_ba + res + min kbx kxa\n ) else (\n min kbx kxa\n ) in\n print_int @@ krest + hoge\n\n\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nSnuke has N strings. The i-th string is s_i.\n\nLet us concatenate these strings into one string after arranging them in some order.\nFind the maximum possible number of occurrences of AB in the resulting string.\n\nConstraints\n\n1 \\leq N \\leq 10^{4}\n\n2 \\leq |s_i| \\leq 10\n\ns_i consists of uppercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\ns_1\n\\vdots\ns_N\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n3\nABCA\nXBAZ\nBAD\n\nSample Output 1\n\n2\n\nFor example, if we concatenate ABCA, BAD and XBAZ in this order, the resulting string ABCABADXBAZ has two occurrences of AB.\n\nSample Input 2\n\n9\nBEWPVCRWH\nZZNQYIJX\nBAVREA\nPA\nHJMYITEOX\nBCJHMRMNK\nBP\nQVFABZ\nPRGKSPUNA\n\nSample Output 2\n\n4\n\nSample Input 3\n\n7\nRABYBBE\nJOZ\nBMHQUVA\nBPA\nISU\nMCMABAOBHZ\nSZMEHMA\n\nSample Output 3\n\n4", "sample_input": "3\nABCA\nXBAZ\nBAD\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03049", "source_text": "Score : 400 points\n\nProblem Statement\n\nSnuke has N strings. The i-th string is s_i.\n\nLet us concatenate these strings into one string after arranging them in some order.\nFind the maximum possible number of occurrences of AB in the resulting string.\n\nConstraints\n\n1 \\leq N \\leq 10^{4}\n\n2 \\leq |s_i| \\leq 10\n\ns_i consists of uppercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\ns_1\n\\vdots\ns_N\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n3\nABCA\nXBAZ\nBAD\n\nSample Output 1\n\n2\n\nFor example, if we concatenate ABCA, BAD and XBAZ in this order, the resulting string ABCABADXBAZ has two occurrences of AB.\n\nSample Input 2\n\n9\nBEWPVCRWH\nZZNQYIJX\nBAVREA\nPA\nHJMYITEOX\nBCJHMRMNK\nBP\nQVFABZ\nPRGKSPUNA\n\nSample Output 2\n\n4\n\nSample Input 3\n\n7\nRABYBBE\nJOZ\nBMHQUVA\nBPA\nISU\nMCMABAOBHZ\nSZMEHMA\n\nSample Output 3\n\n4", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1380, "cpu_time_ms": 11, "memory_kb": 4864}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s806373872", "group_id": "codeNet:p03049", "input_text": "(* O(|s|) *)\nlet string_count s sub =\n let n = String.length s in\n let sub_len = String.length sub in\n let reg = Str.regexp sub in\n let rec loop acc i =\n try\n if i >= n then\n acc\n else\n let j = Str.search_forward reg s i + sub_len in\n loop (acc + 1) j\n with\n | _ -> acc\n in\n loop 0 0\n\n(* O(n^2) *)\nlet solve n ss =\n let b_start, a_end, both, ab = List.fold_left\n (fun (b_start, a_end, both, ab) s ->\n let count = string_count s \"AB\" in\n let new_ab = ab + count in\n let starts_b = s.[0] = 'B' and ends_a = s.[String.length s - 1] = 'A' in\n let new_b_start = if starts_b then b_start + 1 else b_start in\n let new_a_end = if ends_a then a_end + 1 else a_end in\n if starts_b && ends_a then\n new_b_start - 1, new_a_end - 1, both + 1, new_ab\n else\n new_b_start, new_a_end, both, new_ab)\n (0, 0, 0, 0)\n ss\n in\n let pair = min b_start a_end in\n let need = max b_start a_end - pair in\n let addition = if both <= need then\n pair + both\n else\n pair + need + (both - need + 1) / 2 in\n addition + ab\n\n(* O(n) *)\nlet rec fold_btw f a i n = if i >= n then a else fold_btw f (f a i) (i + 1) n\nlet fold_int f a n = fold_btw f a 0 n\n\nlet _ =\n let n = read_int () in\n fold_int\n (fun acc _ -> read_line () :: acc)\n []\n n |> solve n |> string_of_int |> print_endline", "language": "OCaml", "metadata": {"date": 1557630407, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03049.html", "problem_id": "p03049", "resource_group": "low_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/OCaml/s806373872.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s806373872", "user_id": "u732304692"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "(* O(|s|) *)\nlet string_count s sub =\n let n = String.length s in\n let sub_len = String.length sub in\n let reg = Str.regexp sub in\n let rec loop acc i =\n try\n if i >= n then\n acc\n else\n let j = Str.search_forward reg s i + sub_len in\n loop (acc + 1) j\n with\n | _ -> acc\n in\n loop 0 0\n\n(* O(n^2) *)\nlet solve n ss =\n let b_start, a_end, both, ab = List.fold_left\n (fun (b_start, a_end, both, ab) s ->\n let count = string_count s \"AB\" in\n let new_ab = ab + count in\n let starts_b = s.[0] = 'B' and ends_a = s.[String.length s - 1] = 'A' in\n let new_b_start = if starts_b then b_start + 1 else b_start in\n let new_a_end = if ends_a then a_end + 1 else a_end in\n if starts_b && ends_a then\n new_b_start - 1, new_a_end - 1, both + 1, new_ab\n else\n new_b_start, new_a_end, both, new_ab)\n (0, 0, 0, 0)\n ss\n in\n let pair = min b_start a_end in\n let need = max b_start a_end - pair in\n let addition = if both <= need then\n pair + both\n else\n pair + need + (both - need + 1) / 2 in\n addition + ab\n\n(* O(n) *)\nlet rec fold_btw f a i n = if i >= n then a else fold_btw f (f a i) (i + 1) n\nlet fold_int f a n = fold_btw f a 0 n\n\nlet _ =\n let n = read_int () in\n fold_int\n (fun acc _ -> read_line () :: acc)\n []\n n |> solve n |> string_of_int |> print_endline", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1393, "cpu_time_ms": 12, "memory_kb": 5120}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s701664058", "group_id": "codeNet:p03059", "input_text": "let _ = Scanf.sscanf (read_line ()) \"%d %d %d\" (fun a b t ->\n let rec generate s =\n match s with\n | s when (s * a) > t -> 0\n | _ -> b + generate (s+1)\n in print_endline (string_of_int (generate 1))\n)", "language": "OCaml", "metadata": {"date": 1583969356, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03059.html", "problem_id": "p03059", "resource_group": "low_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/OCaml/s701664058.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s701664058", "user_id": "u511870776"}, "prompt_components": {"gold_output": "10\n", "input_to_evaluate": "let _ = Scanf.sscanf (read_line ()) \"%d %d %d\" (fun a b t ->\n let rec generate s =\n match s with\n | s when (s * a) > t -> 0\n | _ -> b + generate (s+1)\n in print_endline (string_of_int (generate 1))\n)", "problem_context": "Score : 100 points\n\nProblem Statement\n\nA biscuit making machine produces B biscuits at the following moments: A seconds, 2A seconds, 3A seconds and each subsequent multiple of A seconds after activation.\n\nFind the total number of biscuits produced within T + 0.5 seconds after activation.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq A, B, T \\leq 20\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B T\n\nOutput\n\nPrint the total number of biscuits produced within T + 0.5 seconds after activation.\n\nSample Input 1\n\n3 5 7\n\nSample Output 1\n\n10\n\nFive biscuits will be produced three seconds after activation.\n\nAnother five biscuits will be produced six seconds after activation.\n\nThus, a total of ten biscuits will be produced within 7.5 seconds after activation.\n\nSample Input 2\n\n3 2 9\n\nSample Output 2\n\n6\n\nSample Input 3\n\n20 20 19\n\nSample Output 3\n\n0", "sample_input": "3 5 7\n"}, "reference_outputs": ["10\n"], "source_document_id": "p03059", "source_text": "Score : 100 points\n\nProblem Statement\n\nA biscuit making machine produces B biscuits at the following moments: A seconds, 2A seconds, 3A seconds and each subsequent multiple of A seconds after activation.\n\nFind the total number of biscuits produced within T + 0.5 seconds after activation.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq A, B, T \\leq 20\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B T\n\nOutput\n\nPrint the total number of biscuits produced within T + 0.5 seconds after activation.\n\nSample Input 1\n\n3 5 7\n\nSample Output 1\n\n10\n\nFive biscuits will be produced three seconds after activation.\n\nAnother five biscuits will be produced six seconds after activation.\n\nThus, a total of ten biscuits will be produced within 7.5 seconds after activation.\n\nSample Input 2\n\n3 2 9\n\nSample Output 2\n\n6\n\nSample Input 3\n\n20 20 19\n\nSample Output 3\n\n0", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 210, "cpu_time_ms": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s623085370", "group_id": "codeNet:p03059", "input_text": "Scanf.scanf \"%d %d %d\" @@ fun a b t -> Printf.printf \"%d\\n\" @@ t / a * b", "language": "OCaml", "metadata": {"date": 1578064250, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03059.html", "problem_id": "p03059", "resource_group": "low_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/OCaml/s623085370.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s623085370", "user_id": "u732304692"}, "prompt_components": {"gold_output": "10\n", "input_to_evaluate": "Scanf.scanf \"%d %d %d\" @@ fun a b t -> Printf.printf \"%d\\n\" @@ 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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 2432}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s086732046", "group_id": "codeNet:p03060", "input_text": "let () = Scanf.scanf \"%d\\n\" @@ fun n ->\n let vs = Array.init n @@ fun _ -> Scanf.scanf \" %d\" Fun.id in\n let cs = Array.init n @@ fun _ -> Scanf.scanf \" %d\" Fun.id in\n let ans = Array.fold_left (fun res i -> res + max 0 (vs.(i) - cs.(i))) \n 0 @@ Array.init n Fun.id in\n Printf.printf \"%d\\n\" ans", "language": "OCaml", "metadata": {"date": 1598122924, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p03060.html", "problem_id": "p03060", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03060/input.txt", "sample_output_relpath": "derived/input_output/data/p03060/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03060/OCaml/s086732046.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s086732046", "user_id": "u052332717"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "let () = Scanf.scanf \"%d\\n\" @@ fun n ->\n let vs = Array.init n @@ fun _ -> Scanf.scanf \" %d\" Fun.id in\n let cs = Array.init n @@ fun _ -> Scanf.scanf \" %d\" Fun.id in\n let ans = Array.fold_left (fun res i -> res + max 0 (vs.(i) - cs.(i))) \n 0 @@ Array.init n Fun.id in\n Printf.printf \"%d\\n\" ans", "problem_context": "Score : 200 points\n\nProblem Statement\n\nThere are N gems. The value of the i-th gem is V_i.\n\nYou will choose some of these gems, possibly all or none, and get them.\n\nHowever, you need to pay a cost of C_i to get the i-th gem.\n\nLet X be the sum of the values of the gems obtained, and Y be the sum of the costs paid.\n\nFind the maximum possible value of X-Y.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 20\n\n1 \\leq C_i, V_i \\leq 50\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nV_1 V_2 ... V_N\nC_1 C_2 ... C_N\n\nOutput\n\nPrint the maximum possible value of X-Y.\n\nSample Input 1\n\n3\n10 2 5\n6 3 4\n\nSample Output 1\n\n5\n\nIf we choose the first and third gems, X = 10 + 5 = 15 and Y = 6 + 4 = 10.\nWe have X-Y = 5 here, which is the maximum possible value.\n\nSample Input 2\n\n4\n13 21 6 19\n11 30 6 15\n\nSample Output 2\n\n6\n\nSample Input 3\n\n1\n1\n50\n\nSample Output 3\n\n0", "sample_input": "3\n10 2 5\n6 3 4\n"}, "reference_outputs": ["5\n"], "source_document_id": "p03060", "source_text": "Score : 200 points\n\nProblem Statement\n\nThere are N gems. The value of the i-th gem is V_i.\n\nYou will choose some of these gems, possibly all or none, and get them.\n\nHowever, you need to pay a cost of C_i to get the i-th gem.\n\nLet X be the sum of the values of the gems obtained, and Y be the sum of the costs paid.\n\nFind the maximum possible value of X-Y.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 20\n\n1 \\leq C_i, V_i \\leq 50\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nV_1 V_2 ... V_N\nC_1 C_2 ... C_N\n\nOutput\n\nPrint the maximum possible value of X-Y.\n\nSample Input 1\n\n3\n10 2 5\n6 3 4\n\nSample Output 1\n\n5\n\nIf we choose the first and third gems, X = 10 + 5 = 15 and Y = 6 + 4 = 10.\nWe have X-Y = 5 here, which is the maximum possible value.\n\nSample Input 2\n\n4\n13 21 6 19\n11 30 6 15\n\nSample Output 2\n\n6\n\nSample Input 3\n\n1\n1\n50\n\nSample Output 3\n\n0", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 9, "memory_kb": 3852}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s359904957", "group_id": "codeNet:p03062", "input_text": "let () = Scanf.scanf \"%d\\n\" @@ fun n ->\n let as_ = Array.init n @@ fun _ -> Scanf.scanf \"%d \" @@ fun a -> a in\n let dp = Array.make_matrix (n + 1) 2 0 in\n dp.(0).(0) <- 0;\n dp.(0).(1) <- -12345678901234;\n for i = 0 to n - 1 do\n dp.(i + 1).(0) <- max (dp.(i).(0) + as_.(i)) (dp.(i).(1) - as_.(i));\n dp.(i + 1).(1) <- max (dp.(i).(0) - as_.(i)) (dp.(i).(1) + as_.(i))\n done;\n Printf.printf \"%d\\n\" dp.(n).(0)\n", "language": "OCaml", "metadata": {"date": 1556416116, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03062.html", "problem_id": "p03062", "resource_group": "low_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/OCaml/s359904957.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s359904957", "user_id": "u504158101"}, "prompt_components": {"gold_output": "19\n", "input_to_evaluate": "let () = Scanf.scanf \"%d\\n\" @@ fun n ->\n let as_ = Array.init n @@ fun _ -> Scanf.scanf \"%d \" @@ fun a -> a in\n let dp = Array.make_matrix (n + 1) 2 0 in\n dp.(0).(0) <- 0;\n dp.(0).(1) <- -12345678901234;\n for i = 0 to n - 1 do\n dp.(i + 1).(0) <- max (dp.(i).(0) + as_.(i)) (dp.(i).(1) - as_.(i));\n dp.(i + 1).(1) <- max (dp.(i).(0) - as_.(i)) (dp.(i).(1) + as_.(i))\n done;\n Printf.printf \"%d\\n\" dp.(n).(0)\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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 41, "memory_kb": 7808}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s061777151", "group_id": "codeNet:p03068", "input_text": "let solve n s k\t=\nlet change_string x = if s.[k-1] = x then s.[k-1] else '*' in\nString.map change_string s\n\nlet () = Scanf.scanf \"%d %s %d\" solve |> Printf.printf \"%s\\n\"", "language": "OCaml", "metadata": {"date": 1555817779, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03068.html", "problem_id": "p03068", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03068/input.txt", "sample_output_relpath": "derived/input_output/data/p03068/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03068/OCaml/s061777151.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s061777151", "user_id": "u321043950"}, "prompt_components": {"gold_output": "*rr*r\n", "input_to_evaluate": "let solve n s k\t=\nlet change_string x = if s.[k-1] = x then s.[k-1] else '*' in\nString.map change_string s\n\nlet () = Scanf.scanf \"%d %s %d\" solve |> Printf.printf \"%s\\n\"", "problem_context": "Score : 200 points\n\nProblem Statement\n\nYou are given a string S of length N consisting of lowercase English letters, and an integer K.\nPrint the string obtained by replacing every character in S that differs from the K-th character of S, with *.\n\nConstraints\n\n1 \\leq K \\leq N\\leq 10\n\nS is a string of length N consisting of lowercase English letters.\n\nN and K are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS\nK\n\nOutput\n\nPrint the string obtained by replacing every character in S that differs from the K-th character of S, with *.\n\nSample Input 1\n\n5\nerror\n2\n\nSample Output 1\n\n*rr*r\n\nThe second character of S is r. When we replace every character in error that differs from r with *, we get the string *rr*r.\n\nSample Input 2\n\n6\neleven\n5\n\nSample Output 2\n\ne*e*e*\n\nSample Input 3\n\n9\neducation\n7\n\nSample Output 3\n\n******i**", "sample_input": "5\nerror\n2\n"}, "reference_outputs": ["*rr*r\n"], "source_document_id": "p03068", "source_text": "Score : 200 points\n\nProblem Statement\n\nYou are given a string S of length N consisting of lowercase English letters, and an integer K.\nPrint the string obtained by replacing every character in S that differs from the K-th character of S, with *.\n\nConstraints\n\n1 \\leq K \\leq N\\leq 10\n\nS is a string of length N consisting of lowercase English letters.\n\nN and K are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS\nK\n\nOutput\n\nPrint the string obtained by replacing every character in S that differs from the K-th character of S, with *.\n\nSample Input 1\n\n5\nerror\n2\n\nSample Output 1\n\n*rr*r\n\nThe second character of S is r. When we replace every character in error that differs from r with *, we get the string *rr*r.\n\nSample Input 2\n\n6\neleven\n5\n\nSample Output 2\n\ne*e*e*\n\nSample Input 3\n\n9\neducation\n7\n\nSample Output 3\n\n******i**", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s049864731", "group_id": "codeNet:p03069", "input_text": "let solve n = 1\n\ntype mode = CSharp | FSharp\n\nlet _ =\n let n = Scanf.scanf \"%d\\n\" (fun n -> n) in\n let ar = Array.make (n+1) '#' in\n let cnt = ref 0 in\n for i = 0 to n - 1 do\n Scanf.scanf (if i <> n-1 then \"%c\" else \"%c\\n\") (fun c -> ar.(i) <- c)\n done;\n let left_sharp = ref 0 in\n let mode = ref CSharp in\n let tmp = ref 0 in\n for i = 0 to n - 1 do\n match !mode with\n | CSharp ->\n if ar.(i) = '#' && ar.(i + 1) = '.' then (left_sharp := !left_sharp + 1; mode := FSharp)\n else if ar.(i) = '#' then left_sharp := !left_sharp + 1\n | FSharp ->\n begin\n if i = n - 1 && ar.(i) = '.' then (tmp := !tmp + 1; cnt := !cnt + (min !tmp !left_sharp))\n else if i = n - 1 then cnt := !cnt + (min !tmp !left_sharp)\n else if ar.(i) = '.' then tmp := !tmp + 1\n else (cnt := !cnt + (min !tmp !left_sharp); left_sharp := 0; tmp := 0; mode := CSharp)\n end\n done;\n print_int !cnt\n", "language": "OCaml", "metadata": {"date": 1555811691, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03069.html", "problem_id": "p03069", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03069/input.txt", "sample_output_relpath": "derived/input_output/data/p03069/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03069/OCaml/s049864731.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s049864731", "user_id": "u387591304"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "let solve n = 1\n\ntype mode = CSharp | FSharp\n\nlet _ =\n let n = Scanf.scanf \"%d\\n\" (fun n -> n) in\n let ar = Array.make (n+1) '#' in\n let cnt = ref 0 in\n for i = 0 to n - 1 do\n Scanf.scanf (if i <> n-1 then \"%c\" else \"%c\\n\") (fun c -> ar.(i) <- c)\n done;\n let left_sharp = ref 0 in\n let mode = ref CSharp in\n let tmp = ref 0 in\n for i = 0 to n - 1 do\n match !mode with\n | CSharp ->\n if ar.(i) = '#' && ar.(i + 1) = '.' then (left_sharp := !left_sharp + 1; mode := FSharp)\n else if ar.(i) = '#' then left_sharp := !left_sharp + 1\n | FSharp ->\n begin\n if i = n - 1 && ar.(i) = '.' then (tmp := !tmp + 1; cnt := !cnt + (min !tmp !left_sharp))\n else if i = n - 1 then cnt := !cnt + (min !tmp !left_sharp)\n else if ar.(i) = '.' then tmp := !tmp + 1\n else (cnt := !cnt + (min !tmp !left_sharp); left_sharp := 0; tmp := 0; mode := CSharp)\n end\n done;\n print_int !cnt\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere are N stones arranged in a row. Every stone is painted white or black.\nA string S represents the color of the stones. The i-th stone from the left is white if the i-th character of S is ., and the stone is black if the character is #.\n\nTakahashi wants to change the colors of some stones to black or white so that there will be no white stone immediately to the right of a black stone.\nFind the minimum number of stones that needs to be recolored.\n\nConstraints\n\n1 \\leq N \\leq 2\\times 10^5\n\nS is a string of length N consisting of . and #.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS\n\nOutput\n\nPrint the minimum number of stones that needs to be recolored.\n\nSample Input 1\n\n3\n#.#\n\nSample Output 1\n\n1\n\nIt is enough to change the color of the first stone to white.\n\nSample Input 2\n\n5\n#.##.\n\nSample Output 2\n\n2\n\nSample Input 3\n\n9\n.........\n\nSample Output 3\n\n0", "sample_input": "3\n#.#\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03069", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere are N stones arranged in a row. Every stone is painted white or black.\nA string S represents the color of the stones. The i-th stone from the left is white if the i-th character of S is ., and the stone is black if the character is #.\n\nTakahashi wants to change the colors of some stones to black or white so that there will be no white stone immediately to the right of a black stone.\nFind the minimum number of stones that needs to be recolored.\n\nConstraints\n\n1 \\leq N \\leq 2\\times 10^5\n\nS is a string of length N consisting of . and #.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS\n\nOutput\n\nPrint the minimum number of stones that needs to be recolored.\n\nSample Input 1\n\n3\n#.#\n\nSample Output 1\n\n1\n\nIt is enough to change the color of the first stone to white.\n\nSample Input 2\n\n5\n#.##.\n\nSample Output 2\n\n2\n\nSample Input 3\n\n9\n.........\n\nSample Output 3\n\n0", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 938, "cpu_time_ms": 23, "memory_kb": 6144}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s970430217", "group_id": "codeNet:p03071", "input_text": "let _ =\n let a, b = Scanf.scanf \"%d %d\" (fun a b -> a, b) in\n let ans =\n if a > b then\n a + (max (a-1) b)\n else b + (max a (b-1))\n in print_int ans\n", "language": "OCaml", "metadata": {"date": 1555182179, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03071.html", "problem_id": "p03071", "resource_group": "low_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/OCaml/s970430217.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s970430217", "user_id": "u387591304"}, "prompt_components": {"gold_output": "9\n", "input_to_evaluate": "let _ =\n let a, b = Scanf.scanf \"%d %d\" (fun a b -> a, b) in\n let ans =\n if a > b then\n a + (max (a-1) b)\n else b + (max a (b-1))\n in print_int 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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 162, "cpu_time_ms": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s929769571", "group_id": "codeNet:p03072", "input_text": "Scanf.scanf \"%d\" (fun n ->\n let rec loop i acc highest =\n if i = n then acc else\n let h = Scanf.scanf \" %d\" (fun h -> h) in\n if h >= highest then loop (i + 1) (acc + 1) h else loop (i + 1) acc highest\n in\n loop 0 0 0 |> Printf.printf \"%d\\n\"\n)", "language": "OCaml", "metadata": {"date": 1583975289, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03072.html", "problem_id": "p03072", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03072/input.txt", "sample_output_relpath": "derived/input_output/data/p03072/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03072/OCaml/s929769571.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s929769571", "user_id": "u342443598"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "Scanf.scanf \"%d\" (fun n ->\n let rec loop i acc highest =\n if i = n then acc else\n let h = Scanf.scanf \" %d\" (fun h -> h) in\n if h >= highest then loop (i + 1) (acc + 1) h else loop (i + 1) acc highest\n in\n loop 0 0 0 |> Printf.printf \"%d\\n\"\n)", "problem_context": "Score : 200 points\n\nProblem Statement\n\nThere are N mountains ranging from east to west, and an ocean to the west.\n\nAt the top of each mountain, there is an inn. You have decided to choose where to stay from these inns.\n\nThe height of the i-th mountain from the west is H_i.\n\nYou can certainly see the ocean from the inn at the top of the westmost mountain.\n\nFor the inn at the top of the i-th mountain from the west (i = 2, 3, ..., N), you can see the ocean if and only if H_1 \\leq H_i, H_2 \\leq H_i, ..., and H_{i-1} \\leq H_i.\n\nFrom how many of these N inns can you see the ocean?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 20\n\n1 \\leq H_i \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nH_1 H_2 ... H_N\n\nOutput\n\nPrint the number of inns from which you can see the ocean.\n\nSample Input 1\n\n4\n6 5 6 8\n\nSample Output 1\n\n3\n\nYou can see the ocean from the first, third and fourth inns from the west.\n\nSample Input 2\n\n5\n4 5 3 5 4\n\nSample Output 2\n\n3\n\nSample Input 3\n\n5\n9 5 6 8 4\n\nSample Output 3\n\n1", "sample_input": "4\n6 5 6 8\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03072", "source_text": "Score : 200 points\n\nProblem Statement\n\nThere are N mountains ranging from east to west, and an ocean to the west.\n\nAt the top of each mountain, there is an inn. You have decided to choose where to stay from these inns.\n\nThe height of the i-th mountain from the west is H_i.\n\nYou can certainly see the ocean from the inn at the top of the westmost mountain.\n\nFor the inn at the top of the i-th mountain from the west (i = 2, 3, ..., N), you can see the ocean if and only if H_1 \\leq H_i, H_2 \\leq H_i, ..., and H_{i-1} \\leq H_i.\n\nFrom how many of these N inns can you see the ocean?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 20\n\n1 \\leq H_i \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nH_1 H_2 ... H_N\n\nOutput\n\nPrint the number of inns from which you can see the ocean.\n\nSample Input 1\n\n4\n6 5 6 8\n\nSample Output 1\n\n3\n\nYou can see the ocean from the first, third and fourth inns from the west.\n\nSample Input 2\n\n5\n4 5 3 5 4\n\nSample Output 2\n\n3\n\nSample Input 3\n\n5\n9 5 6 8 4\n\nSample Output 3\n\n1", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 280, "cpu_time_ms": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s695429154", "group_id": "codeNet:p03072", "input_text": "(* O(n) (n = length of list) *)\nlet rec list_find_fold_left f a = function\n| [] -> a, false\n| x :: xs ->\n let res, detected = f a x in\n if detected then\n res, detected\n else\n list_find_fold_left f res xs\n\n(* O(n) *)\nlet can_view i h hs =\n list_find_fold_left\n (fun (res, j) h' ->\n if j >= i then\n (true, j), true\n else\n if h' > h then\n (res, j), true\n else\n (res, j + 1), false)\n (false, 0)\n hs |> fst |> fst\n\n(* O(n^2) *)\nlet solve n hs =\n List.fold_left\n (fun (count, i) h ->\n if can_view i h hs then\n count + 1, i + 1\n else\n count, i + 1)\n (0, 0)\n hs |> fst\n\nlet read_ints () = read_line () |> Str.split (Str.regexp \" \") |> List.map int_of_string\n\nlet _ =\n let n = read_int () in\n let hs = read_ints () in\n solve n hs |> string_of_int |> print_endline", "language": "OCaml", "metadata": {"date": 1557316193, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03072.html", "problem_id": "p03072", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03072/input.txt", "sample_output_relpath": "derived/input_output/data/p03072/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03072/OCaml/s695429154.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s695429154", "user_id": "u732304692"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "(* O(n) (n = length of list) *)\nlet rec list_find_fold_left f a = function\n| [] -> a, false\n| x :: xs ->\n let res, detected = f a x in\n if detected then\n res, detected\n else\n list_find_fold_left f res xs\n\n(* O(n) *)\nlet can_view i h hs =\n list_find_fold_left\n (fun (res, j) h' ->\n if j >= i then\n (true, j), true\n else\n if h' > h then\n (res, j), true\n else\n (res, j + 1), false)\n (false, 0)\n hs |> fst |> fst\n\n(* O(n^2) *)\nlet solve n hs =\n List.fold_left\n (fun (count, i) h ->\n if can_view i h hs then\n count + 1, i + 1\n else\n count, i + 1)\n (0, 0)\n hs |> fst\n\nlet read_ints () = read_line () |> Str.split (Str.regexp \" \") |> List.map int_of_string\n\nlet _ =\n let n = read_int () in\n let hs = read_ints () in\n solve n hs |> string_of_int |> print_endline", "problem_context": "Score : 200 points\n\nProblem Statement\n\nThere are N mountains ranging from east to west, and an ocean to the west.\n\nAt the top of each mountain, there is an inn. You have decided to choose where to stay from these inns.\n\nThe height of the i-th mountain from the west is H_i.\n\nYou can certainly see the ocean from the inn at the top of the westmost mountain.\n\nFor the inn at the top of the i-th mountain from the west (i = 2, 3, ..., N), you can see the ocean if and only if H_1 \\leq H_i, H_2 \\leq H_i, ..., and H_{i-1} \\leq H_i.\n\nFrom how many of these N inns can you see the ocean?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 20\n\n1 \\leq H_i \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nH_1 H_2 ... H_N\n\nOutput\n\nPrint the number of inns from which you can see the ocean.\n\nSample Input 1\n\n4\n6 5 6 8\n\nSample Output 1\n\n3\n\nYou can see the ocean from the first, third and fourth inns from the west.\n\nSample Input 2\n\n5\n4 5 3 5 4\n\nSample Output 2\n\n3\n\nSample Input 3\n\n5\n9 5 6 8 4\n\nSample Output 3\n\n1", "sample_input": "4\n6 5 6 8\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03072", "source_text": "Score : 200 points\n\nProblem Statement\n\nThere are N mountains ranging from east to west, and an ocean to the west.\n\nAt the top of each mountain, there is an inn. You have decided to choose where to stay from these inns.\n\nThe height of the i-th mountain from the west is H_i.\n\nYou can certainly see the ocean from the inn at the top of the westmost mountain.\n\nFor the inn at the top of the i-th mountain from the west (i = 2, 3, ..., N), you can see the ocean if and only if H_1 \\leq H_i, H_2 \\leq H_i, ..., and H_{i-1} \\leq H_i.\n\nFrom how many of these N inns can you see the ocean?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 20\n\n1 \\leq H_i \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nH_1 H_2 ... H_N\n\nOutput\n\nPrint the number of inns from which you can see the ocean.\n\nSample Input 1\n\n4\n6 5 6 8\n\nSample Output 1\n\n3\n\nYou can see the ocean from the first, third and fourth inns from the west.\n\nSample Input 2\n\n5\n4 5 3 5 4\n\nSample Output 2\n\n3\n\nSample Input 3\n\n5\n9 5 6 8 4\n\nSample Output 3\n\n1", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s376523045", "group_id": "codeNet:p03072", "input_text": "let _ =\n let n = Scanf.scanf \"%d\\n\" (fun n -> n) in\n let h_max = ref 0 in\n let res = ref 0 in\n for i = 0 to n - 1 do\n let h = \n Scanf.scanf (if i <> n - 1 then \"%d \" else \"%d\\n\") (fun h -> h) in\n if h >= !h_max then (res := !res + 1; h_max := h);\n done;\n Printf.printf \"%d\\n\" !res\n", "language": "OCaml", "metadata": {"date": 1555182852, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03072.html", "problem_id": "p03072", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03072/input.txt", "sample_output_relpath": "derived/input_output/data/p03072/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03072/OCaml/s376523045.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s376523045", "user_id": "u387591304"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "let _ =\n let n = Scanf.scanf \"%d\\n\" (fun n -> n) in\n let h_max = ref 0 in\n let res = ref 0 in\n for i = 0 to n - 1 do\n let h = \n Scanf.scanf (if i <> n - 1 then \"%d \" else \"%d\\n\") (fun h -> h) in\n if h >= !h_max then (res := !res + 1; h_max := h);\n done;\n Printf.printf \"%d\\n\" !res\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nThere are N mountains ranging from east to west, and an ocean to the west.\n\nAt the top of each mountain, there is an inn. You have decided to choose where to stay from these inns.\n\nThe height of the i-th mountain from the west is H_i.\n\nYou can certainly see the ocean from the inn at the top of the westmost mountain.\n\nFor the inn at the top of the i-th mountain from the west (i = 2, 3, ..., N), you can see the ocean if and only if H_1 \\leq H_i, H_2 \\leq H_i, ..., and H_{i-1} \\leq H_i.\n\nFrom how many of these N inns can you see the ocean?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 20\n\n1 \\leq H_i \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nH_1 H_2 ... H_N\n\nOutput\n\nPrint the number of inns from which you can see the ocean.\n\nSample Input 1\n\n4\n6 5 6 8\n\nSample Output 1\n\n3\n\nYou can see the ocean from the first, third and fourth inns from the west.\n\nSample Input 2\n\n5\n4 5 3 5 4\n\nSample Output 2\n\n3\n\nSample Input 3\n\n5\n9 5 6 8 4\n\nSample Output 3\n\n1", "sample_input": "4\n6 5 6 8\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03072", "source_text": "Score : 200 points\n\nProblem Statement\n\nThere are N mountains ranging from east to west, and an ocean to the west.\n\nAt the top of each mountain, there is an inn. You have decided to choose where to stay from these inns.\n\nThe height of the i-th mountain from the west is H_i.\n\nYou can certainly see the ocean from the inn at the top of the westmost mountain.\n\nFor the inn at the top of the i-th mountain from the west (i = 2, 3, ..., N), you can see the ocean if and only if H_1 \\leq H_i, H_2 \\leq H_i, ..., and H_{i-1} \\leq H_i.\n\nFrom how many of these N inns can you see the ocean?\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 20\n\n1 \\leq H_i \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nH_1 H_2 ... H_N\n\nOutput\n\nPrint the number of inns from which you can see the ocean.\n\nSample Input 1\n\n4\n6 5 6 8\n\nSample Output 1\n\n3\n\nYou can see the ocean from the first, third and fourth inns from the west.\n\nSample Input 2\n\n5\n4 5 3 5 4\n\nSample Output 2\n\n3\n\nSample Input 3\n\n5\n9 5 6 8 4\n\nSample Output 3\n\n1", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s232958840", "group_id": "codeNet:p03073", "input_text": "let s = read_line () in\nlet n = String.length s in\nlet rec fill i k acc =\n if i = n then acc else\n fill (i + 1) (1 - k) (acc + if s.[i] = '0' && k = 0 || s.[i] = '1' && k = 1 then 0 else 1)\nin\nmin (fill 0 0 0) (fill 0 1 0) |> Printf.printf \"%d\\n\"", "language": "OCaml", "metadata": {"date": 1583975494, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03073.html", "problem_id": "p03073", "resource_group": "low_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/OCaml/s232958840.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s232958840", "user_id": "u342443598"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "let s = read_line () in\nlet n = String.length s in\nlet rec fill i k acc =\n if i = n then acc else\n fill (i + 1) (1 - k) (acc + if s.[i] = '0' && k = 0 || s.[i] = '1' && k = 1 then 0 else 1)\nin\nmin (fill 0 0 0) (fill 0 1 0) |> Printf.printf \"%d\\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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 3, "memory_kb": 2560}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s017297669", "group_id": "codeNet:p03074", "input_text": "let calc s k =\n if k = 0 then\n Array.fold_left (fun (v, w) (_, x) -> if x = '1' then max v (w+1), w+1 else v, 1) (0, 0) s |> fst else\n let t = Array.make 101010 0 in\n let ans, _, _, _, _ =\n Array.fold_left (fun (ans, cur, cs, ti, p) (i, x) ->\n match p, x with\n | '1', '1' -> (max ans (cur+1), cur+1, cs+1, ti, '1')\n | '0', '0' -> (max ans (cur+1), cur+1, cs+1, ti, '0')\n | '0', '1' -> begin\n t.(ti) <- cs;\n (max ans (cur+1), cur+1, 1, ti+1, '1')\n end\n | _ (* 1, 0 *) -> begin\n if ti < k then\n (max ans (cur+1), cur+1, cs+1, ti, '0')\n else\n (max ans (cur+1-t.(ti-k)), cur+1-t.(ti-k), cs+1, ti, '0')\n end) (0,0,0,0,'1') s\n in\n ans\nlet () =\n Scanf.scanf \"%d %d %s\" @@ fun n k s ->\n let s = Array.init n (fun i -> i, s.[i]) in\n max (calc s k) (calc (Array.map (fun (i, x) -> i, (if x = '0' then '1' else '0')) s) (k-1))\n |> Printf.printf \"%d\\n\"\n", "language": "OCaml", "metadata": {"date": 1555186133, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03074.html", "problem_id": "p03074", "resource_group": "low_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/OCaml/s017297669.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s017297669", "user_id": "u798181098"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "let calc s k =\n if k = 0 then\n Array.fold_left (fun (v, w) (_, x) -> if x = '1' then max v (w+1), w+1 else v, 1) (0, 0) s |> fst else\n let t = Array.make 101010 0 in\n let ans, _, _, _, _ =\n Array.fold_left (fun (ans, cur, cs, ti, p) (i, x) ->\n match p, x with\n | '1', '1' -> (max ans (cur+1), cur+1, cs+1, ti, '1')\n | '0', '0' -> (max ans (cur+1), cur+1, cs+1, ti, '0')\n | '0', '1' -> begin\n t.(ti) <- cs;\n (max ans (cur+1), cur+1, 1, ti+1, '1')\n end\n | _ (* 1, 0 *) -> begin\n if ti < k then\n (max ans (cur+1), cur+1, cs+1, ti, '0')\n else\n (max ans (cur+1-t.(ti-k)), cur+1-t.(ti-k), cs+1, ti, '0')\n end) (0,0,0,0,'1') s\n in\n ans\nlet () =\n Scanf.scanf \"%d %d %s\" @@ fun n k s ->\n let s = Array.init n (fun i -> i, s.[i]) in\n max (calc s k) (calc (Array.map (fun (i, x) -> i, (if x = '0' then '1' else '0')) s) (k-1))\n |> Printf.printf \"%d\\n\"\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nN people are arranged in a row from left to right.\n\nYou are given a string S of length N consisting of 0 and 1, and a positive integer K.\n\nThe i-th person from the left is standing on feet if the i-th character of S is 0, and standing on hands if that character is 1.\n\nYou will give the following direction at most K times (possibly zero):\n\nDirection: Choose integers l and r satisfying 1 \\leq l \\leq r \\leq N, and flip the l-th, (l+1)-th, ..., and r-th persons. That is, for each i = l, l+1, ..., r, the i-th person from the left now stands on hands if he/she was standing on feet, and stands on feet if he/she was standing on hands.\n\nFind the maximum possible number of consecutive people standing on hands after at most K directions.\n\nConstraints\n\nN is an integer satisfying 1 \\leq N \\leq 10^5.\n\nK is an integer satisfying 1 \\leq K \\leq 10^5.\n\nThe length of the string S is N.\n\nEach character of the string S is 0 or 1.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nS\n\nOutput\n\nPrint the maximum possible number of consecutive people standing on hands after at most K directions.\n\nSample Input 1\n\n5 1\n00010\n\nSample Output 1\n\n4\n\nWe can have four consecutive people standing on hands, which is the maximum result, by giving the following direction:\n\nGive the direction with l = 1, r = 3, which flips the first, second and third persons from the left.\n\nSample Input 2\n\n14 2\n11101010110011\n\nSample Output 2\n\n8\n\nSample Input 3\n\n1 1\n1\n\nSample Output 3\n\n1\n\nNo directions are necessary.", "sample_input": "5 1\n00010\n"}, "reference_outputs": ["4\n"], "source_document_id": "p03074", "source_text": "Score : 400 points\n\nProblem Statement\n\nN people are arranged in a row from left to right.\n\nYou are given a string S of length N consisting of 0 and 1, and a positive integer K.\n\nThe i-th person from the left is standing on feet if the i-th character of S is 0, and standing on hands if that character is 1.\n\nYou will give the following direction at most K times (possibly zero):\n\nDirection: Choose integers l and r satisfying 1 \\leq l \\leq r \\leq N, and flip the l-th, (l+1)-th, ..., and r-th persons. That is, for each i = l, l+1, ..., r, the i-th person from the left now stands on hands if he/she was standing on feet, and stands on feet if he/she was standing on hands.\n\nFind the maximum possible number of consecutive people standing on hands after at most K directions.\n\nConstraints\n\nN is an integer satisfying 1 \\leq N \\leq 10^5.\n\nK is an integer satisfying 1 \\leq K \\leq 10^5.\n\nThe length of the string S is N.\n\nEach character of the string S is 0 or 1.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nS\n\nOutput\n\nPrint the maximum possible number of consecutive people standing on hands after at most K directions.\n\nSample Input 1\n\n5 1\n00010\n\nSample Output 1\n\n4\n\nWe can have four consecutive people standing on hands, which is the maximum result, by giving the following direction:\n\nGive the direction with l = 1, r = 3, which flips the first, second and third persons from the left.\n\nSample Input 2\n\n14 2\n11101010110011\n\nSample Output 2\n\n8\n\nSample Input 3\n\n1 1\n1\n\nSample Output 3\n\n1\n\nNo directions are necessary.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 25, "memory_kb": 11776}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s557897185", "group_id": "codeNet:p03074", "input_text": "let () = Scanf.scanf \"%d %d\\n%s\\n\" @@ fun n k s ->\n let seqs =\n Array.of_list @@ List.rev @@\n match\n (* 1111 0000 *)\n Array.fold_left (fun (acc, s) c ->\n match s, c with\n | `Ones n, '1' -> (acc, `Ones (n + 1))\n | `Zeros (n, m), '0' -> (acc, `Zeros (n, m + 1))\n | `Ones n, '0' -> (acc, `Zeros (n, 1))\n | `Zeros (n, m), '1' -> ((n, m) :: acc, `Ones 1)) ([], `Ones 0) @@\n Array.init (String.length s) (String.get s)\n with\n | (acc, `Ones n) -> (n, 0) :: acc\n | (acc, `Zeros (n, m)) -> (n, m) :: acc in\n if Array.length seqs <= k\n then Printf.printf \"%d\\n\" n\n else begin\n let acc = Array.make (Array.length seqs + 1) 0 in\n for i = 0 to Array.length seqs - 1 do\n acc.(i + 1) <- acc.(i) + fst seqs.(i) + snd seqs.(i)\n done;\n Printf.printf \"%d\\n\" @@\n Array.fold_left max (acc.(Array.length seqs) - acc.(Array.length seqs - k)) @@\n Array.init (Array.length seqs - k) @@ fun i ->\n acc.(i + k) - acc.(i) + fst seqs.(i + k)\n end", "language": "OCaml", "metadata": {"date": 1555184996, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03074.html", "problem_id": "p03074", "resource_group": "low_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/OCaml/s557897185.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s557897185", "user_id": "u504158101"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "let () = Scanf.scanf \"%d %d\\n%s\\n\" @@ fun n k s ->\n let seqs =\n Array.of_list @@ List.rev @@\n match\n (* 1111 0000 *)\n Array.fold_left (fun (acc, s) c ->\n match s, c with\n | `Ones n, '1' -> (acc, `Ones (n + 1))\n | `Zeros (n, m), '0' -> (acc, `Zeros (n, m + 1))\n | `Ones n, '0' -> (acc, `Zeros (n, 1))\n | `Zeros (n, m), '1' -> ((n, m) :: acc, `Ones 1)) ([], `Ones 0) @@\n Array.init (String.length s) (String.get s)\n with\n | (acc, `Ones n) -> (n, 0) :: acc\n | (acc, `Zeros (n, m)) -> (n, m) :: acc in\n if Array.length seqs <= k\n then Printf.printf \"%d\\n\" n\n else begin\n let acc = Array.make (Array.length seqs + 1) 0 in\n for i = 0 to Array.length seqs - 1 do\n acc.(i + 1) <- acc.(i) + fst seqs.(i) + snd seqs.(i)\n done;\n Printf.printf \"%d\\n\" @@\n Array.fold_left max (acc.(Array.length seqs) - acc.(Array.length seqs - k)) @@\n Array.init (Array.length seqs - k) @@ fun i ->\n acc.(i + k) - acc.(i) + fst seqs.(i + k)\n end", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1014, "cpu_time_ms": 14, "memory_kb": 8576}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s358829435", "group_id": "codeNet:p03075", "input_text": "let five_antennas a b c d e k = if e - a > k then \":(\" else \"Yay!\"\n\nlet a = read_int()\nlet b = read_int()\nlet c = read_int()\nlet d = read_int()\nlet e = read_int()\nlet k = read_int()\n\nlet () = Printf.printf \"%s\\n\" (five_antennas a b c d e k)", "language": "OCaml", "metadata": {"date": 1595787414, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p03075.html", "problem_id": "p03075", "resource_group": "low_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/OCaml/s358829435.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s358829435", "user_id": "u272377260"}, "prompt_components": {"gold_output": "Yay!\n", "input_to_evaluate": "let five_antennas a b c d e k = if e - a > k then \":(\" else \"Yay!\"\n\nlet a = read_int()\nlet b = read_int()\nlet c = read_int()\nlet d = read_int()\nlet e = read_int()\nlet k = read_int()\n\nlet () = Printf.printf \"%s\\n\" (five_antennas a b c d e k)", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 240, "cpu_time_ms": 9, "memory_kb": 3560}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s025751730", "group_id": "codeNet:p03076", "input_text": "let round_up n = \n let r = n mod 10 in\n if r = 0 then n \n else n + 10 - r\n;;\n\nlet add n = \n let r = n mod 10 in\n if r = 0 then 0\n else 10 - r\n;;\n\nlet r_max a b c d e =\n max (max (max (max (add a) (add b)) (add c)) (add d)) (add e)\n;;\n\n\nlet () = Scanf.scanf \"%d\\n%d\\n%d\\n%d\\n%d\" (fun a b c d e -> (\n (round_up a) + (round_up b) + (round_up c) + (round_up d) + (round_up e) - r_max a b c d e |> print_int\n));;", "language": "OCaml", "metadata": {"date": 1587426143, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03076.html", "problem_id": "p03076", "resource_group": "low_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/OCaml/s025751730.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s025751730", "user_id": "u541055501"}, "prompt_components": {"gold_output": "215\n", "input_to_evaluate": "let round_up n = \n let r = n mod 10 in\n if r = 0 then n \n else n + 10 - r\n;;\n\nlet add n = \n let r = n mod 10 in\n if r = 0 then 0\n else 10 - r\n;;\n\nlet r_max a b c d e =\n max (max (max (max (add a) (add b)) (add c)) (add d)) (add e)\n;;\n\n\nlet () = Scanf.scanf \"%d\\n%d\\n%d\\n%d\\n%d\" (fun a b c d e -> (\n (round_up a) + (round_up b) + (round_up c) + (round_up d) + (round_up e) - r_max a b c d e |> print_int\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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 423, "cpu_time_ms": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s527473406", "group_id": "codeNet:p03076", "input_text": "let xs = Array.init 5 @@ fun _ -> read_int ()\nlet ws = Array.map (fun x -> (10 - x mod 10) mod 10) xs\nlet f = Array.fold_left\nlet _ = f (+) 0 xs + f (+) 0 ws - f max ws.(0) ws |> Printf.printf \"%d\\n\"", "language": "OCaml", "metadata": {"date": 1567848637, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03076.html", "problem_id": "p03076", "resource_group": "low_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/OCaml/s527473406.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s527473406", "user_id": "u732304692"}, "prompt_components": {"gold_output": "215\n", "input_to_evaluate": "let xs = Array.init 5 @@ fun _ -> read_int ()\nlet ws = Array.map (fun x -> (10 - x mod 10) mod 10) xs\nlet f = Array.fold_left\nlet _ = f (+) 0 xs + f (+) 0 ws - f max ws.(0) ws |> Printf.printf \"%d\\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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 199, "cpu_time_ms": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s697782359", "group_id": "codeNet:p03077", "input_text": "let () = Scanf.scanf \"%d %d %d %d %d %d\" @@ fun n a b c d e ->\n let m = List.fold_left min max_int [ a; b; c; d; e ] in\n Printf.printf \"%d\\n\" @@ (n + m - 1) / m + 4\n", "language": "OCaml", "metadata": {"date": 1554586973, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03077.html", "problem_id": "p03077", "resource_group": "low_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/OCaml/s697782359.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s697782359", "user_id": "u504158101"}, "prompt_components": {"gold_output": "7\n", "input_to_evaluate": "let () = Scanf.scanf \"%d %d %d %d %d %d\" @@ fun n a b c d e ->\n let m = List.fold_left min max_int [ a; b; c; d; e ] in\n Printf.printf \"%d\\n\" @@ (n + m - 1) / m + 4\n", "problem_context": "Score: 300 points\n\nProblem Statement\n\nIn 2028 and after a continuous growth, AtCoder Inc. finally built an empire with six cities (City 1, 2, 3, 4, 5, 6)!\n\nThere are five means of transport in this empire:\n\nTrain: travels from City 1 to 2 in one minute. A train can occupy at most A people.\n\nBus: travels from City 2 to 3 in one minute. A bus can occupy at most B people.\n\nTaxi: travels from City 3 to 4 in one minute. A taxi can occupy at most C people.\n\nAirplane: travels from City 4 to 5 in one minute. An airplane can occupy at most D people.\n\nShip: travels from City 5 to 6 in one minute. A ship can occupy at most E people.\n\nFor each of them, one vehicle leaves the city at each integer time (time 0, 1, 2, ...).\n\nThere is a group of N people at City 1, and they all want to go to City 6.\n\nAt least how long does it take for all of them to reach there?\nYou can ignore the time needed to transfer.\n\nConstraints\n\n1 \\leq N, A, B, C, D, E \\leq 10^{15}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA\nB\nC\nD\nE\n\nOutput\n\nPrint the minimum time required for all of the people to reach City 6, in minutes.\n\nSample Input 1\n\n5\n3\n2\n4\n3\n5\n\nSample Output 1\n\n7\n\nOne possible way to travel is as follows.\nFirst, there are N = 5 people at City 1, as shown in the following image:\n\nIn the first minute, three people travels from City 1 to City 2 by train. Note that a train can only occupy at most three people.\n\nIn the second minute, the remaining two people travels from City 1 to City 2 by train, and two of the three people who were already at City 2 travels to City 3 by bus. Note that a bus can only occupy at most two people.\n\nIn the third minute, two people travels from City 2 to City 3 by train, and another two people travels from City 3 to City 4 by taxi.\n\nFrom then on, if they continue traveling without stopping until they reach City 6, all of them can reach there in seven minutes.\n\nThere is no way for them to reach City 6 in 6 minutes or less.\n\nSample Input 2\n\n10\n123\n123\n123\n123\n123\n\nSample Output 2\n\n5\n\nAll kinds of vehicles can occupy N = 10 people at a time.\nThus, if they continue traveling without stopping until they reach City 6, all of them can reach there in five minutes.\n\nSample Input 3\n\n10000000007\n2\n3\n5\n7\n11\n\nSample Output 3\n\n5000000008\n\nNote that the input or output may not fit into a 32-bit integer type.", "sample_input": "5\n3\n2\n4\n3\n5\n"}, "reference_outputs": ["7\n"], "source_document_id": "p03077", "source_text": "Score: 300 points\n\nProblem Statement\n\nIn 2028 and after a continuous growth, AtCoder Inc. finally built an empire with six cities (City 1, 2, 3, 4, 5, 6)!\n\nThere are five means of transport in this empire:\n\nTrain: travels from City 1 to 2 in one minute. A train can occupy at most A people.\n\nBus: travels from City 2 to 3 in one minute. A bus can occupy at most B people.\n\nTaxi: travels from City 3 to 4 in one minute. A taxi can occupy at most C people.\n\nAirplane: travels from City 4 to 5 in one minute. An airplane can occupy at most D people.\n\nShip: travels from City 5 to 6 in one minute. A ship can occupy at most E people.\n\nFor each of them, one vehicle leaves the city at each integer time (time 0, 1, 2, ...).\n\nThere is a group of N people at City 1, and they all want to go to City 6.\n\nAt least how long does it take for all of them to reach there?\nYou can ignore the time needed to transfer.\n\nConstraints\n\n1 \\leq N, A, B, C, D, E \\leq 10^{15}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA\nB\nC\nD\nE\n\nOutput\n\nPrint the minimum time required for all of the people to reach City 6, in minutes.\n\nSample Input 1\n\n5\n3\n2\n4\n3\n5\n\nSample Output 1\n\n7\n\nOne possible way to travel is as follows.\nFirst, there are N = 5 people at City 1, as shown in the following image:\n\nIn the first minute, three people travels from City 1 to City 2 by train. Note that a train can only occupy at most three people.\n\nIn the second minute, the remaining two people travels from City 1 to City 2 by train, and two of the three people who were already at City 2 travels to City 3 by bus. Note that a bus can only occupy at most two people.\n\nIn the third minute, two people travels from City 2 to City 3 by train, and another two people travels from City 3 to City 4 by taxi.\n\nFrom then on, if they continue traveling without stopping until they reach City 6, all of them can reach there in seven minutes.\n\nThere is no way for them to reach City 6 in 6 minutes or less.\n\nSample Input 2\n\n10\n123\n123\n123\n123\n123\n\nSample Output 2\n\n5\n\nAll kinds of vehicles can occupy N = 10 people at a time.\nThus, if they continue traveling without stopping until they reach City 6, all of them can reach there in five minutes.\n\nSample Input 3\n\n10000000007\n2\n3\n5\n7\n11\n\nSample Output 3\n\n5000000008\n\nNote that the input or output may not fit into a 32-bit integer type.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s907217191", "group_id": "codeNet:p03078", "input_text": "let constr x y =\n let ly = Array.length y in\n let z = Array.(init (length x * ly) (fun i -> x.(i / ly) + y.(i mod ly))) in\n Array.sort (fun x y -> y - x) z; z\nlet () =\n Scanf.scanf \"%d %d %d %d\" @@ fun x y z k ->\n let a = Array.init x (fun _ -> Scanf.scanf \" %d\" ((+) 0)) in\n let b = Array.init y (fun _ -> Scanf.scanf \" %d\" ((+) 0)) in\n let c = Array.init z (fun _ -> Scanf.scanf \" %d\" ((+) 0)) in\n let ab = constr a b in\n let abc = constr (Array.sub ab 0 (min (x * y) k)) c in\n Array.sub abc 0 k |> Array.iter (Printf.printf \"%d\\n\");", "language": "OCaml", "metadata": {"date": 1554660326, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03078.html", "problem_id": "p03078", "resource_group": "low_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/OCaml/s907217191.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s907217191", "user_id": "u798181098"}, "prompt_components": {"gold_output": "19\n17\n15\n14\n13\n12\n10\n8\n", "input_to_evaluate": "let constr x y =\n let ly = Array.length y in\n let z = Array.(init (length x * ly) (fun i -> x.(i / ly) + y.(i mod ly))) in\n Array.sort (fun x y -> y - x) z; z\nlet () =\n Scanf.scanf \"%d %d %d %d\" @@ fun x y z k ->\n let a = Array.init x (fun _ -> Scanf.scanf \" %d\" ((+) 0)) in\n let b = Array.init y (fun _ -> Scanf.scanf \" %d\" ((+) 0)) in\n let c = Array.init z (fun _ -> Scanf.scanf \" %d\" ((+) 0)) in\n let ab = constr a b in\n let abc = constr (Array.sub ab 0 (min (x * y) k)) c in\n Array.sub abc 0 k |> Array.iter (Printf.printf \"%d\\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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 545, "cpu_time_ms": 1834, "memory_kb": 38172}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s206489988", "group_id": "codeNet:p03080", "input_text": "let () = Scanf.scanf \"%d\\n%s\" @@ fun n s ->\n print_endline @@\n if\n ( < ) 0\n @@ Array.fold_left (fun acc c ->\n acc + if c = 'R' then 1 else -1) 0\n @@ Array.init n @@ String.get s\n then \"Yes\"\n else \"No\"\n", "language": "OCaml", "metadata": {"date": 1553976481, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03080.html", "problem_id": "p03080", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03080/input.txt", "sample_output_relpath": "derived/input_output/data/p03080/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03080/OCaml/s206489988.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s206489988", "user_id": "u504158101"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "let () = Scanf.scanf \"%d\\n%s\" @@ fun n s ->\n print_endline @@\n if\n ( < ) 0\n @@ Array.fold_left (fun acc c ->\n acc + if c = 'R' then 1 else -1) 0\n @@ Array.init n @@ String.get s\n then \"Yes\"\n else \"No\"\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nThere are N people numbered 1 to N. Each person wears a red hat or a blue hat.\n\nYou are given a string s representing the colors of the people. Person i wears a red hat if s_i is R, and a blue hat if s_i is B.\n\nDetermine if there are more people wearing a red hat than people wearing a blue hat.\n\nConstraints\n\n1 \\leq N \\leq 100\n\n|s| = N\n\ns_i is R or B.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\ns\n\nOutput\n\nIf there are more people wearing a red hat than there are people wearing a blue hat, print Yes; otherwise, print No.\n\nSample Input 1\n\n4\nRRBR\n\nSample Output 1\n\nYes\n\nThere are three people wearing a red hat, and one person wearing a blue hat.\n\nSince there are more people wearing a red hat than people wearing a blue hat, the answer is Yes.\n\nSample Input 2\n\n4\nBRBR\n\nSample Output 2\n\nNo\n\nThere are two people wearing a red hat, and two people wearing a blue hat.\n\nSince there are as many people wearing a red hat as people wearing a blue hat, the answer is No.", "sample_input": "4\nRRBR\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03080", "source_text": "Score : 200 points\n\nProblem Statement\n\nThere are N people numbered 1 to N. Each person wears a red hat or a blue hat.\n\nYou are given a string s representing the colors of the people. Person i wears a red hat if s_i is R, and a blue hat if s_i is B.\n\nDetermine if there are more people wearing a red hat than people wearing a blue hat.\n\nConstraints\n\n1 \\leq N \\leq 100\n\n|s| = N\n\ns_i is R or B.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\ns\n\nOutput\n\nIf there are more people wearing a red hat than there are people wearing a blue hat, print Yes; otherwise, print No.\n\nSample Input 1\n\n4\nRRBR\n\nSample Output 1\n\nYes\n\nThere are three people wearing a red hat, and one person wearing a blue hat.\n\nSince there are more people wearing a red hat than people wearing a blue hat, the answer is Yes.\n\nSample Input 2\n\n4\nBRBR\n\nSample Output 2\n\nNo\n\nThere are two people wearing a red hat, and two people wearing a blue hat.\n\nSince there are as many people wearing a red hat as people wearing a blue hat, the answer is No.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s390857366", "group_id": "codeNet:p03085", "input_text": "let double_helix b =\n if b = \"A\" then \"T\"\n else if b = \"T\" then \"A\"\n else if b = \"G\" then \"C\"\n else \"G\"\n\nlet () = Scanf.scanf \"%s\" double_helix |> Printf.printf \"%s\\n\"", "language": "OCaml", "metadata": {"date": 1595787657, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p03085.html", "problem_id": "p03085", "resource_group": "low_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/OCaml/s390857366.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s390857366", "user_id": "u272377260"}, "prompt_components": {"gold_output": "T\n", "input_to_evaluate": "let double_helix b =\n if b = \"A\" then \"T\"\n else if b = \"T\" then \"A\"\n else if b = \"G\" then \"C\"\n else \"G\"\n\nlet () = Scanf.scanf \"%s\" double_helix |> Printf.printf \"%s\\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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 8, "memory_kb": 3680}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s317600870", "group_id": "codeNet:p03085", "input_text": "let _ = String.(map (fun c -> \"TGCA\".[index \"ACGT\" c]) @@ read_line ()) |> print_endline", "language": "OCaml", "metadata": {"date": 1567754461, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03085.html", "problem_id": "p03085", "resource_group": "low_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/OCaml/s317600870.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s317600870", "user_id": "u732304692"}, "prompt_components": {"gold_output": "T\n", "input_to_evaluate": "let _ = String.(map (fun c -> \"TGCA\".[index \"ACGT\" c]) @@ read_line ()) |> print_endline", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s079605019", "group_id": "codeNet:p03085", "input_text": "let () =\n print_endline @@\n Scanf.scanf \"%c\" @@ fun c ->\n match c with\n | 'A' -> \"T\"\n | 'T' -> \"A\"\n | 'C' -> \"G\"\n | 'G' -> \"C\"\n | _ -> assert false\n", "language": "OCaml", "metadata": {"date": 1553457678, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03085.html", "problem_id": "p03085", "resource_group": "low_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/OCaml/s079605019.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s079605019", "user_id": "u798181098"}, "prompt_components": {"gold_output": "T\n", "input_to_evaluate": "let () =\n print_endline @@\n Scanf.scanf \"%c\" @@ fun c ->\n match c with\n | 'A' -> \"T\"\n | 'T' -> \"A\"\n | 'C' -> \"G\"\n | 'G' -> \"C\"\n | _ -> assert false\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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s252770927", "group_id": "codeNet:p03086", "input_text": "open Batteries\n\nlet scan fmt f =\n Scanf.sscanf (read_line ()) fmt f\n\nlet scan_list cnv =\n read_line ()\n |> String.split_on_char ' '\n |> List.map cnv\n\nlet rec zip xs ys =\n match xs, ys with\n | [], _ -> []\n | _, [] -> []\n | x::xs, y::ys ->\n (x, y) :: zip xs ys\n\nlet s = scan \"%s\" identity\n\nlet () =\n let n = String.length s in\n let length i j =\n let sub = String.slice ~first:i ~last:j s in\n if List.for_all\n (fun c -> c = 'A' || c = 'C' || c = 'G' || c = 'T')\n @@ String.to_list sub then\n String.length sub else 0 in\n let rec aux f i j =\n if j > n then\n if i > n - 1 then []\n else\n aux f (i+1) (i+2)\n else\n (f i j) :: aux f i (j+1)\n in\n Printf.printf \"%d\\n\" @@ List.max @@ aux length 0 1\n", "language": "OCaml", "metadata": {"date": 1586434559, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03086.html", "problem_id": "p03086", "resource_group": "low_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/OCaml/s252770927.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s252770927", "user_id": "u802614675"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "open Batteries\n\nlet scan fmt f =\n Scanf.sscanf (read_line ()) fmt f\n\nlet scan_list cnv =\n read_line ()\n |> String.split_on_char ' '\n |> List.map cnv\n\nlet rec zip xs ys =\n match xs, ys with\n | [], _ -> []\n | _, [] -> []\n | x::xs, y::ys ->\n (x, y) :: zip xs ys\n\nlet s = scan \"%s\" identity\n\nlet () =\n let n = String.length s in\n let length i j =\n let sub = String.slice ~first:i ~last:j s in\n if List.for_all\n (fun c -> c = 'A' || c = 'C' || c = 'G' || c = 'T')\n @@ String.to_list sub then\n String.length sub else 0 in\n let rec aux f i j =\n if j > n then\n if i > n - 1 then []\n else\n aux f (i+1) (i+2)\n else\n (f i j) :: aux f i (j+1)\n in\n Printf.printf \"%d\\n\" @@ List.max @@ aux length 0 1\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nYou are given a string S consisting of uppercase English letters. Find the length of the longest ACGT string that is a substring (see Notes) of S.\n\nHere, a ACGT string is a string that contains no characters other than A, C, G and T.\n\nNotes\n\nA substring of a string T is a string obtained by removing zero or more characters from the beginning and the end of T.\n\nFor example, the substrings of ATCODER include TCO, AT, CODER, ATCODER and (the empty string), but not AC.\n\nConstraints\n\nS is a string of length between 1 and 10 (inclusive).\n\nEach character in S is an uppercase English letter.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the length of the longest ACGT string that is a substring of S.\n\nSample Input 1\n\nATCODER\n\nSample Output 1\n\n3\n\nAmong the ACGT strings that are substrings of ATCODER, the longest one is ATC.\n\nSample Input 2\n\nHATAGAYA\n\nSample Output 2\n\n5\n\nAmong the ACGT strings that are substrings of HATAGAYA, the longest one is ATAGA.\n\nSample Input 3\n\nSHINJUKU\n\nSample Output 3\n\n0\n\nAmong the ACGT strings that are substrings of SHINJUKU, the longest one is (the empty string).", "sample_input": "ATCODER\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03086", "source_text": "Score : 200 points\n\nProblem Statement\n\nYou are given a string S consisting of uppercase English letters. Find the length of the longest ACGT string that is a substring (see Notes) of S.\n\nHere, a ACGT string is a string that contains no characters other than A, C, G and T.\n\nNotes\n\nA substring of a string T is a string obtained by removing zero or more characters from the beginning and the end of T.\n\nFor example, the substrings of ATCODER include TCO, AT, CODER, ATCODER and (the empty string), but not AC.\n\nConstraints\n\nS is a string of length between 1 and 10 (inclusive).\n\nEach character in S is an uppercase English letter.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the length of the longest ACGT string that is a substring of S.\n\nSample Input 1\n\nATCODER\n\nSample Output 1\n\n3\n\nAmong the ACGT strings that are substrings of ATCODER, the longest one is ATC.\n\nSample Input 2\n\nHATAGAYA\n\nSample Output 2\n\n5\n\nAmong the ACGT strings that are substrings of HATAGAYA, the longest one is ATAGA.\n\nSample Input 3\n\nSHINJUKU\n\nSample Output 3\n\n0\n\nAmong the ACGT strings that are substrings of SHINJUKU, the longest one is (the empty string).", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 754, "cpu_time_ms": 2, "memory_kb": 3072}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s155971857", "group_id": "codeNet:p03087", "input_text": "let () =\n Scanf.scanf \"%d %d %s\" @@ fun n q s ->\n let ss = Array.init (n+1) (fun i -> \n if i > 1 && s.[i-2] = 'A' && s.[i-1] = 'C' then 1 else 0) in\n for i = 1 to n do ss.(i) <- ss.(i) + ss.(i-1); done;\n Array.init q (fun _ -> Scanf.scanf \" %d %d\" (fun x y -> x, y))\n |> Array.iter (fun (l,r) ->\n let v = ss.(r) - ss.(l-1) in\n let v = if l > 1 && s.[l-2] = 'A' && s.[l-1] = 'C' then v-1 else v in\n Printf.printf \"%d\\n\" v)\n", "language": "OCaml", "metadata": {"date": 1553458312, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03087.html", "problem_id": "p03087", "resource_group": "low_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/OCaml/s155971857.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s155971857", "user_id": "u798181098"}, "prompt_components": {"gold_output": "2\n0\n3\n", "input_to_evaluate": "let () =\n Scanf.scanf \"%d %d %s\" @@ fun n q s ->\n let ss = Array.init (n+1) (fun i -> \n if i > 1 && s.[i-2] = 'A' && s.[i-1] = 'C' then 1 else 0) in\n for i = 1 to n do ss.(i) <- ss.(i) + ss.(i-1); done;\n Array.init q (fun _ -> Scanf.scanf \" %d %d\" (fun x y -> x, y))\n |> Array.iter (fun (l,r) ->\n let v = ss.(r) - ss.(l-1) in\n let v = if l > 1 && s.[l-2] = 'A' && s.[l-1] = 'C' then v-1 else v in\n Printf.printf \"%d\\n\" v)\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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 445, "cpu_time_ms": 81, "memory_kb": 7936}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s766256189", "group_id": "codeNet:p03089", "input_text": "(* O(n^2) *)\nlet n = Scanf.scanf \" %d\" @@ (+) 0\nlet bs = Array.init n @@ fun _ -> Scanf.scanf \" %d\" @@ (+) 0\nlet search_backi a f =\n let i = ref @@ Array.length a - 1 in\n let found = ref false in\n while not !found && !i >= 0 do if f !i a.(!i) then found := true; decr i done;\n !i + if !found then 1 else 0\nlet remove a i =\n let a' = Array.make (Array.length a - 1) a.(0) in\n Array.iteri (fun j x -> if j < i then a'.(j) <- x else if j > i then a'.(j - 1) <- x) a;\n a'\nlet rec f acc a n =\n if n = 0 then acc\n else\n let i = search_backi a (fun i x -> i + 1 = x) in\n if i = -1 then (print_endline \"-1\"; exit 0)\n else f (a.(i) :: acc) (remove a i) @@ n - 1\nlet ans = f [] bs n\nlet _ = ans |> List.iter @@ Printf.printf \"%d\\n\"", "language": "OCaml", "metadata": {"date": 1561403102, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03089.html", "problem_id": "p03089", "resource_group": "low_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/OCaml/s766256189.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s766256189", "user_id": "u732304692"}, "prompt_components": {"gold_output": "1\n1\n2\n", "input_to_evaluate": "(* O(n^2) *)\nlet n = Scanf.scanf \" %d\" @@ (+) 0\nlet bs = Array.init n @@ fun _ -> Scanf.scanf \" %d\" @@ (+) 0\nlet search_backi a f =\n let i = ref @@ Array.length a - 1 in\n let found = ref false in\n while not !found && !i >= 0 do if f !i a.(!i) then found := true; decr i done;\n !i + if !found then 1 else 0\nlet remove a i =\n let a' = Array.make (Array.length a - 1) a.(0) in\n Array.iteri (fun j x -> if j < i then a'.(j) <- x else if j > i then a'.(j - 1) <- x) a;\n a'\nlet rec f acc a n =\n if n = 0 then acc\n else\n let i = search_backi a (fun i x -> i + 1 = x) in\n if i = -1 then (print_endline \"-1\"; exit 0)\n else f (a.(i) :: acc) (remove a i) @@ n - 1\nlet ans = f [] bs n\nlet _ = ans |> List.iter @@ Printf.printf \"%d\\n\"", "problem_context": "Score : 400 points\n\nProblem Statement\n\nSnuke has an empty sequence a.\n\nHe will perform N operations on this sequence.\n\nIn the i-th operation, he chooses an integer j satisfying 1 \\leq j \\leq i, and insert j at position j in a (the beginning is position 1).\n\nYou are given a sequence b of length N. Determine if it is possible that a is equal to b after N operations. If it is, show one possible sequence of operations that achieves it.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 100\n\n1 \\leq b_i \\leq N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nb_1 \\dots b_N\n\nOutput\n\nIf there is no sequence of N operations after which a would be equal to b, print -1.\nIf there is, print N lines. In the i-th line, the integer chosen in the i-th operation should be printed. If there are multiple solutions, any of them is accepted.\n\nSample Input 1\n\n3\n1 2 1\n\nSample Output 1\n\n1\n1\n2\n\nIn this sequence of operations, the sequence a changes as follows:\n\nAfter the first operation: (1)\n\nAfter the second operation: (1,1)\n\nAfter the third operation: (1,2,1)\n\nSample Input 2\n\n2\n2 2\n\nSample Output 2\n\n-1\n\n2 cannot be inserted at the beginning of the sequence, so this is impossible.\n\nSample Input 3\n\n9\n1 1 1 2 2 1 2 3 2\n\nSample Output 3\n\n1\n2\n2\n3\n1\n2\n2\n1\n1", "sample_input": "3\n1 2 1\n"}, "reference_outputs": ["1\n1\n2\n"], "source_document_id": "p03089", "source_text": "Score : 400 points\n\nProblem Statement\n\nSnuke has an empty sequence a.\n\nHe will perform N operations on this sequence.\n\nIn the i-th operation, he chooses an integer j satisfying 1 \\leq j \\leq i, and insert j at position j in a (the beginning is position 1).\n\nYou are given a sequence b of length N. Determine if it is possible that a is equal to b after N operations. If it is, show one possible sequence of operations that achieves it.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 100\n\n1 \\leq b_i \\leq N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nb_1 \\dots b_N\n\nOutput\n\nIf there is no sequence of N operations after which a would be equal to b, print -1.\nIf there is, print N lines. In the i-th line, the integer chosen in the i-th operation should be printed. If there are multiple solutions, any of them is accepted.\n\nSample Input 1\n\n3\n1 2 1\n\nSample Output 1\n\n1\n1\n2\n\nIn this sequence of operations, the sequence a changes as follows:\n\nAfter the first operation: (1)\n\nAfter the second operation: (1,1)\n\nAfter the third operation: (1,2,1)\n\nSample Input 2\n\n2\n2 2\n\nSample Output 2\n\n-1\n\n2 cannot be inserted at the beginning of the sequence, so this is impossible.\n\nSample Input 3\n\n9\n1 1 1 2 2 1 2 3 2\n\nSample Output 3\n\n1\n2\n2\n3\n1\n2\n2\n1\n1", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 739, "cpu_time_ms": 1, "memory_kb": 512}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s704339601", "group_id": "codeNet:p03089", "input_text": "let rec for_obvious s = function\n | [] -> false\n | b::bs -> if b > s then true else for_obvious (s + 1) bs\n\nlet rec dfs ans left bs s n =\n if bs = [] && left = [] then Some ans\n else if s > n then None\n else\n begin\n match bs with\n | [] -> Some ans\n | b::bs -> \n if b > s then None\n else if b = s then \n begin\n match dfs (b::ans)\n [] (List.fold_left (fun acc l -> l::acc) bs left)\n 1 (n - 1) with\n | None -> dfs ans (b::left) bs (s + 1) n\n | Some ans -> Some ans\n end\n else dfs ans (b::left) bs (s + 1) n\n end\n\nlet _ =\n let n = Scanf.scanf \"%d\\n\" (fun n -> n) in\n let bs = Array.make n 0 in\n for i = 0 to n - 1 do\n Scanf.scanf (if i <> n - 1 then \"%d \" else \"%d\\n\") (fun b -> bs.(i) <- b)\n done;\n let ls = Array.to_list bs in\n if for_obvious 1 ls then print_int (-1)\n else\n dfs [] [] (Array.to_list bs) 1 n \n |> (function | None -> print_int (-1) \n | Some ans -> List.iter (fun n -> print_endline @@ string_of_int n) ans)\n", "language": "OCaml", "metadata": {"date": 1553379453, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03089.html", "problem_id": "p03089", "resource_group": "low_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/OCaml/s704339601.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s704339601", "user_id": "u387591304"}, "prompt_components": {"gold_output": "1\n1\n2\n", "input_to_evaluate": "let rec for_obvious s = function\n | [] -> false\n | b::bs -> if b > s then true else for_obvious (s + 1) bs\n\nlet rec dfs ans left bs s n =\n if bs = [] && left = [] then Some ans\n else if s > n then None\n else\n begin\n match bs with\n | [] -> Some ans\n | b::bs -> \n if b > s then None\n else if b = s then \n begin\n match dfs (b::ans)\n [] (List.fold_left (fun acc l -> l::acc) bs left)\n 1 (n - 1) with\n | None -> dfs ans (b::left) bs (s + 1) n\n | Some ans -> Some ans\n end\n else dfs ans (b::left) bs (s + 1) n\n end\n\nlet _ =\n let n = Scanf.scanf \"%d\\n\" (fun n -> n) in\n let bs = Array.make n 0 in\n for i = 0 to n - 1 do\n Scanf.scanf (if i <> n - 1 then \"%d \" else \"%d\\n\") (fun b -> bs.(i) <- b)\n done;\n let ls = Array.to_list bs in\n if for_obvious 1 ls then print_int (-1)\n else\n dfs [] [] (Array.to_list bs) 1 n \n |> (function | None -> print_int (-1) \n | Some ans -> List.iter (fun n -> print_endline @@ string_of_int n) ans)\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nSnuke has an empty sequence a.\n\nHe will perform N operations on this sequence.\n\nIn the i-th operation, he chooses an integer j satisfying 1 \\leq j \\leq i, and insert j at position j in a (the beginning is position 1).\n\nYou are given a sequence b of length N. Determine if it is possible that a is equal to b after N operations. If it is, show one possible sequence of operations that achieves it.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 100\n\n1 \\leq b_i \\leq N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nb_1 \\dots b_N\n\nOutput\n\nIf there is no sequence of N operations after which a would be equal to b, print -1.\nIf there is, print N lines. In the i-th line, the integer chosen in the i-th operation should be printed. If there are multiple solutions, any of them is accepted.\n\nSample Input 1\n\n3\n1 2 1\n\nSample Output 1\n\n1\n1\n2\n\nIn this sequence of operations, the sequence a changes as follows:\n\nAfter the first operation: (1)\n\nAfter the second operation: (1,1)\n\nAfter the third operation: (1,2,1)\n\nSample Input 2\n\n2\n2 2\n\nSample Output 2\n\n-1\n\n2 cannot be inserted at the beginning of the sequence, so this is impossible.\n\nSample Input 3\n\n9\n1 1 1 2 2 1 2 3 2\n\nSample Output 3\n\n1\n2\n2\n3\n1\n2\n2\n1\n1", "sample_input": "3\n1 2 1\n"}, "reference_outputs": ["1\n1\n2\n"], "source_document_id": "p03089", "source_text": "Score : 400 points\n\nProblem Statement\n\nSnuke has an empty sequence a.\n\nHe will perform N operations on this sequence.\n\nIn the i-th operation, he chooses an integer j satisfying 1 \\leq j \\leq i, and insert j at position j in a (the beginning is position 1).\n\nYou are given a sequence b of length N. Determine if it is possible that a is equal to b after N operations. If it is, show one possible sequence of operations that achieves it.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 100\n\n1 \\leq b_i \\leq N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nb_1 \\dots b_N\n\nOutput\n\nIf there is no sequence of N operations after which a would be equal to b, print -1.\nIf there is, print N lines. In the i-th line, the integer chosen in the i-th operation should be printed. If there are multiple solutions, any of them is accepted.\n\nSample Input 1\n\n3\n1 2 1\n\nSample Output 1\n\n1\n1\n2\n\nIn this sequence of operations, the sequence a changes as follows:\n\nAfter the first operation: (1)\n\nAfter the second operation: (1,1)\n\nAfter the third operation: (1,2,1)\n\nSample Input 2\n\n2\n2 2\n\nSample Output 2\n\n-1\n\n2 cannot be inserted at the beginning of the sequence, so this is impossible.\n\nSample Input 3\n\n9\n1 1 1 2 2 1 2 3 2\n\nSample Output 3\n\n1\n2\n2\n3\n1\n2\n2\n1\n1", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1099, "cpu_time_ms": 2103, "memory_kb": 2988}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s527368384", "group_id": "codeNet:p03095", "input_text": "let split_string ?(pattern=\"\") = Str.split @@ Str.regexp pattern\nlet n = Scanf.sscanf (read_line ()) \"%d\" @@ fun n -> n\nlet s = read_line () |> split_string |> List.sort compare\n\nlet m_1e9 = int_of_float 1e9 + 7\nlet ( +^ ) x y = (x + y) mod m_1e9\nlet ( -^ ) x y = x - y + if x < y then m_1e9 else 0\nlet ( *^ ) x y = ((x mod m_1e9) * (y mod m_1e9)) mod m_1e9\n\nlet ss = List.fold_left (fun acc n ->\n match acc with\n | [] -> [(n, 1)]\n | (v, cnt) as t :: xs -> if v = n then (v, cnt + 1) :: xs else (n, 1) :: t :: xs\n) [] s\n\nlet () = \n Printf.printf \"%d\\n\" @@ List.fold_left (fun sum (_, i) -> sum *^ (i + 1)) 1 ss -^ 1", "language": "OCaml", "metadata": {"date": 1592852670, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p03095.html", "problem_id": "p03095", "resource_group": "low_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/OCaml/s527368384.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s527368384", "user_id": "u811309788"}, "prompt_components": {"gold_output": "15\n", "input_to_evaluate": "let split_string ?(pattern=\"\") = Str.split @@ Str.regexp pattern\nlet n = Scanf.sscanf (read_line ()) \"%d\" @@ fun n -> n\nlet s = read_line () |> split_string |> List.sort compare\n\nlet m_1e9 = int_of_float 1e9 + 7\nlet ( +^ ) x y = (x + y) mod m_1e9\nlet ( -^ ) x y = x - y + if x < y then m_1e9 else 0\nlet ( *^ ) x y = ((x mod m_1e9) * (y mod m_1e9)) mod m_1e9\n\nlet ss = List.fold_left (fun acc n ->\n match acc with\n | [] -> [(n, 1)]\n | (v, cnt) as t :: xs -> if v = n then (v, cnt + 1) :: xs else (n, 1) :: t :: xs\n) [] s\n\nlet () = \n Printf.printf \"%d\\n\" @@ List.fold_left (fun sum (_, i) -> sum *^ (i + 1)) 1 ss -^ 1", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 625, "cpu_time_ms": 88, "memory_kb": 17052}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s344338037", "group_id": "codeNet:p03095", "input_text": "let rec pow acc n m =\n if m = 0 then acc else pow (acc * n) n (m - 1)\n\nlet pow = pow 1\n\nlet solve n s =\n let p10_9_7 = (pow 10 9) + 7 in\n let counter = Array.make 26 0 in\n let inc c = \n let i = Char.code c - Char.code 'a' in counter.(i) <- counter.(i) + 1 in\n for ic = 0 to (String.length s) - 1 do\n String.get s ic |> inc\n done;\n let result = ref 1 in\n for i = 0 to 25 do\n if counter.(i) > 0 then \n result := (!result * (counter.(i) + 1)) mod p10_9_7\n done;\n (!result - 1)\n\nlet _ =\n let n = Scanf.scanf \"%d\\n\" (fun n -> n) in\n let s = Scanf.scanf \"%s\\n\" (fun s -> s) in\n print_int @@ solve n s", "language": "OCaml", "metadata": {"date": 1552815685, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03095.html", "problem_id": "p03095", "resource_group": "low_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/OCaml/s344338037.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s344338037", "user_id": "u387591304"}, "prompt_components": {"gold_output": "15\n", "input_to_evaluate": "let rec pow acc n m =\n if m = 0 then acc else pow (acc * n) n (m - 1)\n\nlet pow = pow 1\n\nlet solve n s =\n let p10_9_7 = (pow 10 9) + 7 in\n let counter = Array.make 26 0 in\n let inc c = \n let i = Char.code c - Char.code 'a' in counter.(i) <- counter.(i) + 1 in\n for ic = 0 to (String.length s) - 1 do\n String.get s ic |> inc\n done;\n let result = ref 1 in\n for i = 0 to 25 do\n if counter.(i) > 0 then \n result := (!result * (counter.(i) + 1)) mod p10_9_7\n done;\n (!result - 1)\n\nlet _ =\n let n = Scanf.scanf \"%d\\n\" (fun n -> n) in\n let s = Scanf.scanf \"%s\\n\" (fun s -> s) in\n print_int @@ solve n s", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 4, "memory_kb": 2816}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s817799862", "group_id": "codeNet:p03096", "input_text": "let m = 1000000007\nlet ( +^ ) x y = (x + y) mod m\n\nmodule IntMap = Map.Make (struct\n type t = int\n let compare = compare\nend)\n\nlet () = Scanf.scanf \"%d\\n\" @@ fun n ->\n let cs = Array.make (n + 2) 0 in\n for i = 1 to n do\n Scanf.scanf \"%d\\n\" @@ Array.set cs i\n done;\n let dp = Array.make (n + 2) 1 in\n let acc = Array.make (n + 2) IntMap.empty in\n for i = 1 to n do\n dp.(i) <- dp.(i - 1) +^\n if cs.(i) = cs.(i - 1)\n then 0\n else (try IntMap.find cs.(i) acc.(i - 1) with Not_found -> 0);\n acc.(i) <-\n if cs.(i) = cs.(i + 1)\n then acc.(i)\n else IntMap.add cs.(i) (dp.(i - 1) +^ try IntMap.find cs.(i) acc.(i - 1) with Not_found -> 0) acc.(i - 1)\n done;\n Printf.printf \"%d\\n\" dp.(n)\n", "language": "OCaml", "metadata": {"date": 1552773644, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03096.html", "problem_id": "p03096", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03096/input.txt", "sample_output_relpath": "derived/input_output/data/p03096/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03096/OCaml/s817799862.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s817799862", "user_id": "u504158101"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "let m = 1000000007\nlet ( +^ ) x y = (x + y) mod m\n\nmodule IntMap = Map.Make (struct\n type t = int\n let compare = compare\nend)\n\nlet () = Scanf.scanf \"%d\\n\" @@ fun n ->\n let cs = Array.make (n + 2) 0 in\n for i = 1 to n do\n Scanf.scanf \"%d\\n\" @@ Array.set cs i\n done;\n let dp = Array.make (n + 2) 1 in\n let acc = Array.make (n + 2) IntMap.empty in\n for i = 1 to n do\n dp.(i) <- dp.(i - 1) +^\n if cs.(i) = cs.(i - 1)\n then 0\n else (try IntMap.find cs.(i) acc.(i - 1) with Not_found -> 0);\n acc.(i) <-\n if cs.(i) = cs.(i + 1)\n then acc.(i)\n else IntMap.add cs.(i) (dp.(i - 1) +^ try IntMap.find cs.(i) acc.(i - 1) with Not_found -> 0) acc.(i - 1)\n done;\n Printf.printf \"%d\\n\" dp.(n)\n", "problem_context": "Score : 700 points\n\nProblem Statement\n\nThere are N stones arranged in a row. The i-th stone from the left is painted in the color C_i.\n\nSnuke will perform the following operation zero or more times:\n\nChoose two stones painted in the same color. Repaint all the stones between them, with the color of the chosen stones.\n\nFind the number of possible final sequences of colors of the stones, modulo 10^9+7.\n\nConstraints\n\n1 \\leq N \\leq 2\\times 10^5\n\n1 \\leq C_i \\leq 2\\times 10^5(1\\leq i\\leq N)\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nC_1\n:\nC_N\n\nOutput\n\nPrint the number of possible final sequences of colors of the stones, modulo 10^9+7.\n\nSample Input 1\n\n5\n1\n2\n1\n2\n2\n\nSample Output 1\n\n3\n\nWe can make three sequences of colors of stones, as follows:\n\n(1,2,1,2,2), by doing nothing.\n\n(1,1,1,2,2), by choosing the first and third stones to perform the operation.\n\n(1,2,2,2,2), by choosing the second and fourth stones to perform the operation.\n\nSample Input 2\n\n6\n4\n2\n5\n4\n2\n4\n\nSample Output 2\n\n5\n\nSample Input 3\n\n7\n1\n3\n1\n2\n3\n3\n2\n\nSample Output 3\n\n5", "sample_input": "5\n1\n2\n1\n2\n2\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03096", "source_text": "Score : 700 points\n\nProblem Statement\n\nThere are N stones arranged in a row. The i-th stone from the left is painted in the color C_i.\n\nSnuke will perform the following operation zero or more times:\n\nChoose two stones painted in the same color. Repaint all the stones between them, with the color of the chosen stones.\n\nFind the number of possible final sequences of colors of the stones, modulo 10^9+7.\n\nConstraints\n\n1 \\leq N \\leq 2\\times 10^5\n\n1 \\leq C_i \\leq 2\\times 10^5(1\\leq i\\leq N)\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nC_1\n:\nC_N\n\nOutput\n\nPrint the number of possible final sequences of colors of the stones, modulo 10^9+7.\n\nSample Input 1\n\n5\n1\n2\n1\n2\n2\n\nSample Output 1\n\n3\n\nWe can make three sequences of colors of stones, as follows:\n\n(1,2,1,2,2), by doing nothing.\n\n(1,1,1,2,2), by choosing the first and third stones to perform the operation.\n\n(1,2,2,2,2), by choosing the second and fourth stones to perform the operation.\n\nSample Input 2\n\n6\n4\n2\n5\n4\n2\n4\n\nSample Output 2\n\n5\n\nSample Input 3\n\n7\n1\n3\n1\n2\n3\n3\n2\n\nSample Output 3\n\n5", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 727, "cpu_time_ms": 786, "memory_kb": 176052}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s983445459", "group_id": "codeNet:p03102", "input_text": "let () = Scanf.scanf \" %d %d %d\" @@ fun n m c ->\n let bs = List.init m @@ fun _ -> Scanf.scanf \" %d\" Fun.id in\n let ass = List.init n @@ fun _ ->\n List.init m @@ fun _ -> Scanf.scanf \" %d\" Fun.id in\n let ans = List.length @@\n List.filter (( < ) 0) @@\n List.map (List.fold_left2 (fun acc b a -> acc + b * a) c bs) ass in\n Printf.printf \"%d\\n\" ans\n", "language": "OCaml", "metadata": {"date": 1598728138, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p03102.html", "problem_id": "p03102", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03102/input.txt", "sample_output_relpath": "derived/input_output/data/p03102/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03102/OCaml/s983445459.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s983445459", "user_id": "u052332717"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "let () = Scanf.scanf \" %d %d %d\" @@ fun n m c ->\n let bs = List.init m @@ fun _ -> Scanf.scanf \" %d\" Fun.id in\n let ass = List.init n @@ fun _ ->\n List.init m @@ fun _ -> Scanf.scanf \" %d\" Fun.id in\n let ans = List.length @@\n List.filter (( < ) 0) @@\n List.map (List.fold_left2 (fun acc b a -> acc + b * a) c bs) ass in\n Printf.printf \"%d\\n\" ans\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nThere are N pieces of source code. The characteristics of the i-th code is represented by M integers A_{i1}, A_{i2}, ..., A_{iM}.\n\nAdditionally, you are given integers B_1, B_2, ..., B_M and C.\n\nThe i-th code correctly solves this problem if and only if A_{i1} B_1 + A_{i2} B_2 + ... + A_{iM} B_M + C > 0.\n\nAmong the N codes, find the number of codes that correctly solve this problem.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N, M \\leq 20\n\n-100 \\leq A_{ij} \\leq 100\n\n-100 \\leq B_i \\leq 100\n\n-100 \\leq C \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M C\nB_1 B_2 ... B_M\nA_{11} A_{12} ... A_{1M}\nA_{21} A_{22} ... A_{2M}\n\\vdots\nA_{N1} A_{N2} ... A_{NM}\n\nOutput\n\nPrint the number of codes among the given N codes that correctly solve this problem.\n\nSample Input 1\n\n2 3 -10\n1 2 3\n3 2 1\n1 2 2\n\nSample Output 1\n\n1\n\nOnly the second code correctly solves this problem, as follows:\n\nSince 3 \\times 1 + 2 \\times 2 + 1 \\times 3 + (-10) = 0 \\leq 0, the first code does not solve this problem.\n\n1 \\times 1 + 2 \\times 2 + 2 \\times 3 + (-10) = 1 > 0, the second code solves this problem.\n\nSample Input 2\n\n5 2 -4\n-2 5\n100 41\n100 40\n-3 0\n-6 -2\n18 -13\n\nSample Output 2\n\n2\n\nSample Input 3\n\n3 3 0\n100 -100 0\n0 100 100\n100 100 100\n-100 100 100\n\nSample Output 3\n\n0\n\nAll of them are Wrong Answer. Except yours.", "sample_input": "2 3 -10\n1 2 3\n3 2 1\n1 2 2\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03102", "source_text": "Score : 200 points\n\nProblem Statement\n\nThere are N pieces of source code. The characteristics of the i-th code is represented by M integers A_{i1}, A_{i2}, ..., A_{iM}.\n\nAdditionally, you are given integers B_1, B_2, ..., B_M and C.\n\nThe i-th code correctly solves this problem if and only if A_{i1} B_1 + A_{i2} B_2 + ... + A_{iM} B_M + C > 0.\n\nAmong the N codes, find the number of codes that correctly solve this problem.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N, M \\leq 20\n\n-100 \\leq A_{ij} \\leq 100\n\n-100 \\leq B_i \\leq 100\n\n-100 \\leq C \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M C\nB_1 B_2 ... B_M\nA_{11} A_{12} ... A_{1M}\nA_{21} A_{22} ... A_{2M}\n\\vdots\nA_{N1} A_{N2} ... A_{NM}\n\nOutput\n\nPrint the number of codes among the given N codes that correctly solve this problem.\n\nSample Input 1\n\n2 3 -10\n1 2 3\n3 2 1\n1 2 2\n\nSample Output 1\n\n1\n\nOnly the second code correctly solves this problem, as follows:\n\nSince 3 \\times 1 + 2 \\times 2 + 1 \\times 3 + (-10) = 0 \\leq 0, the first code does not solve this problem.\n\n1 \\times 1 + 2 \\times 2 + 2 \\times 3 + (-10) = 1 > 0, the second code solves this problem.\n\nSample Input 2\n\n5 2 -4\n-2 5\n100 41\n100 40\n-3 0\n-6 -2\n18 -13\n\nSample Output 2\n\n2\n\nSample Input 3\n\n3 3 0\n100 -100 0\n0 100 100\n100 100 100\n-100 100 100\n\nSample Output 3\n\n0\n\nAll of them are Wrong Answer. Except yours.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 9, "memory_kb": 3968}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s508191694", "group_id": "codeNet:p03103", "input_text": "\nlet rec aux m cash drinks shops =\n if drinks >= m then cash\n else\n let a, b = List.hd shops in\n let shops = List.tl shops in\n if m - drinks >= b then aux m (cash + a * b) (drinks + b) shops\n else if m - drinks < b then aux m (cash + a * (m - drinks)) m shops\n else assert false \n\nlet _ =\n let n, m = Scanf.scanf \"%d %d\\n\" (fun n m -> (n, m)) in\n let pairs = ref [] in\n for i=1 to n do\n Scanf.scanf \"%d %d\\n\" (fun a b -> pairs := (a, b)::!pairs)\n done;\n !pairs\n |> List.fast_sort (fun (a, _) (a', _) -> if a > a' then 1 else if a < a' then -1 else 0)\n |> aux m 0 0\n |> print_int\n", "language": "OCaml", "metadata": {"date": 1552165461, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03103.html", "problem_id": "p03103", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03103/input.txt", "sample_output_relpath": "derived/input_output/data/p03103/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03103/OCaml/s508191694.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s508191694", "user_id": "u387591304"}, "prompt_components": {"gold_output": "12\n", "input_to_evaluate": "\nlet rec aux m cash drinks shops =\n if drinks >= m then cash\n else\n let a, b = List.hd shops in\n let shops = List.tl shops in\n if m - drinks >= b then aux m (cash + a * b) (drinks + b) shops\n else if m - drinks < b then aux m (cash + a * (m - drinks)) m shops\n else assert false \n\nlet _ =\n let n, m = Scanf.scanf \"%d %d\\n\" (fun n m -> (n, m)) in\n let pairs = ref [] in\n for i=1 to n do\n Scanf.scanf \"%d %d\\n\" (fun a b -> pairs := (a, b)::!pairs)\n done;\n !pairs\n |> List.fast_sort (fun (a, _) (a', _) -> if a > a' then 1 else if a < a' then -1 else 0)\n |> aux m 0 0\n |> print_int\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nHearing that energy drinks increase rating in those sites, Takahashi decides to buy up M cans of energy drinks.\n\nThere are N stores that sell energy drinks. In the i-th store, he can buy at most B_i cans of energy drinks for A_i yen (the currency of Japan) each.\n\nWhat is the minimum amount of money with which he can buy M cans of energy drinks?\n\nIt is guaranteed that, in the given inputs, a sufficient amount of money can always buy M cans of energy drinks.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N, M \\leq 10^5\n\n1 \\leq A_i \\leq 10^9\n\n1 \\leq B_i \\leq 10^5\n\nB_1 + ... + B_N \\geq M\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 B_1\nA_2 B_2\n\\vdots\nA_N B_N\n\nOutput\n\nPrint the minimum amount of money with which Takahashi can buy M cans of energy drinks.\n\nSample Input 1\n\n2 5\n4 9\n2 4\n\nSample Output 1\n\n12\n\nWith 12 yen, we can buy one drink at the first store and four drinks at the second store, for the total of five drinks. However, we cannot buy 5 drinks with 11 yen or less.\n\nSample Input 2\n\n4 30\n6 18\n2 5\n3 10\n7 9\n\nSample Output 2\n\n130\n\nSample Input 3\n\n1 100000\n1000000000 100000\n\nSample Output 3\n\n100000000000000\n\nThe output may not fit into a 32-bit integer type.", "sample_input": "2 5\n4 9\n2 4\n"}, "reference_outputs": ["12\n"], "source_document_id": "p03103", "source_text": "Score : 300 points\n\nProblem Statement\n\nHearing that energy drinks increase rating in those sites, Takahashi decides to buy up M cans of energy drinks.\n\nThere are N stores that sell energy drinks. In the i-th store, he can buy at most B_i cans of energy drinks for A_i yen (the currency of Japan) each.\n\nWhat is the minimum amount of money with which he can buy M cans of energy drinks?\n\nIt is guaranteed that, in the given inputs, a sufficient amount of money can always buy M cans of energy drinks.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N, M \\leq 10^5\n\n1 \\leq A_i \\leq 10^9\n\n1 \\leq B_i \\leq 10^5\n\nB_1 + ... + B_N \\geq M\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 B_1\nA_2 B_2\n\\vdots\nA_N B_N\n\nOutput\n\nPrint the minimum amount of money with which Takahashi can buy M cans of energy drinks.\n\nSample Input 1\n\n2 5\n4 9\n2 4\n\nSample Output 1\n\n12\n\nWith 12 yen, we can buy one drink at the first store and four drinks at the second store, for the total of five drinks. However, we cannot buy 5 drinks with 11 yen or less.\n\nSample Input 2\n\n4 30\n6 18\n2 5\n3 10\n7 9\n\nSample Output 2\n\n130\n\nSample Input 3\n\n1 100000\n1000000000 100000\n\nSample Output 3\n\n100000000000000\n\nThe output may not fit into a 32-bit integer type.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 607, "cpu_time_ms": 123, "memory_kb": 15232}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s933704428", "group_id": "codeNet:p03106", "input_text": "Scanf.scanf \"%d %d %d\" (fun a b k ->\n let rec loop i l =\n if i = 0 then l else\n let l = if a mod i = 0 && b mod i = 0 then i :: l else l in\n loop (i - 1) l\n in\n let l = loop (max a b) [] in\n Printf.printf \"%d\\n\" (Array.of_list (List.rev l)).(k - 1)\n)", "language": "OCaml", "metadata": {"date": 1592516136, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p03106.html", "problem_id": "p03106", "resource_group": "low_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/OCaml/s933704428.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s933704428", "user_id": "u342443598"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "Scanf.scanf \"%d %d %d\" (fun a b k ->\n let rec loop i l =\n if i = 0 then l else\n let l = if a mod i = 0 && b mod i = 0 then i :: l else l in\n loop (i - 1) l\n in\n let l = loop (max a b) [] in\n Printf.printf \"%d\\n\" (Array.of_list (List.rev l)).(k - 1)\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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 8, "memory_kb": 3816}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s014920705", "group_id": "codeNet:p03106", "input_text": "let () =\n Scanf.scanf \"%d %d %d\" @@ fun a b k ->\n let rec f c i =\n if c = k then i+1\n else if a mod i = 0 && b mod i = 0 then f (c+1) (i-1)\n else f c (i-1)\n in f 0 (min a b) |> Printf.printf \"%d\\n\"\n", "language": "OCaml", "metadata": {"date": 1551643473, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03106.html", "problem_id": "p03106", "resource_group": "low_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/OCaml/s014920705.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s014920705", "user_id": "u798181098"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "let () =\n Scanf.scanf \"%d %d %d\" @@ fun a b k ->\n let rec f c i =\n if c = k then i+1\n else if a mod i = 0 && b mod i = 0 then f (c+1) (i-1)\n else f c (i-1)\n in f 0 (min a b) |> Printf.printf \"%d\\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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 210, "cpu_time_ms": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s390530583", "group_id": "codeNet:p03108", "input_text": "(* O(m α(n)) *)\nlet n, m = Scanf.scanf \" %d %d\" @@ fun a b -> a, b\nlet ab_s = Array.init m @@ fun _ -> Scanf.scanf \" %d %d\" @@ fun a b -> a - 1, b - 1\nlet ab_s = Array.init m (fun i -> ab_s.(m - 1 - i))\nlet ps = Array.make n @@ -1\nlet rec find x =\n if ps.(x) < 0 then x\n else let y = find ps.(x) in ps.(x) <- y; y\nlet unite x y =\n let x = find x in\n let y = find y in\n if x = y then false\n else\n (if ps.(x) < ps.(y) then (ps.(x) <- ps.(x) + ps.(y); ps.(y) <- x)\n else (ps.(y) <- ps.(y) + ps.(x); ps.(x) <- y);\n true)\nlet size x = -ps.(find x)\nlet v = ref @@ n * (n - 1) / 2\nlet vs = ref []\nlet _ =\n let f (a, b) =\n vs := !v :: !vs;\n let x, y = size a, size b in\n if unite a b then v := !v - x * y in\n Array.iter f ab_s;\n List.iter (fun v -> Printf.printf \"%d\\n\" v) !vs", "language": "OCaml", "metadata": {"date": 1560783674, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03108.html", "problem_id": "p03108", "resource_group": "low_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/OCaml/s390530583.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s390530583", "user_id": "u732304692"}, "prompt_components": {"gold_output": "0\n0\n4\n5\n6\n", "input_to_evaluate": "(* O(m α(n)) *)\nlet n, m = Scanf.scanf \" %d %d\" @@ fun a b -> a, b\nlet ab_s = Array.init m @@ fun _ -> Scanf.scanf \" %d %d\" @@ fun a b -> a - 1, b - 1\nlet ab_s = Array.init m (fun i -> ab_s.(m - 1 - i))\nlet ps = Array.make n @@ -1\nlet rec find x =\n if ps.(x) < 0 then x\n else let y = find ps.(x) in ps.(x) <- y; y\nlet unite x y =\n let x = find x in\n let y = find y in\n if x = y then false\n else\n (if ps.(x) < ps.(y) then (ps.(x) <- ps.(x) + ps.(y); ps.(y) <- x)\n else (ps.(y) <- ps.(y) + ps.(x); ps.(x) <- y);\n true)\nlet size x = -ps.(find x)\nlet v = ref @@ n * (n - 1) / 2\nlet vs = ref []\nlet _ =\n let f (a, b) =\n vs := !v :: !vs;\n let x, y = size a, size b in\n if unite a b then v := !v - x * y in\n Array.iter f ab_s;\n List.iter (fun v -> Printf.printf \"%d\\n\" v) !vs", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 796, "cpu_time_ms": 86, "memory_kb": 11392}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s542816027", "group_id": "codeNet:p03108", "input_text": "(* 素集合データ構造 *)\nmodule UnionFind : sig\n type t\n\n module Class : sig\n type t\n val to_int : t -> int\n val compare : t -> t -> int\n end\n\n (* n要素の素集合データ構造を作る *)\n val make : int -> t\n (* 要素がどの集合に属するか調べる *)\n (* 要素は0からn-1の整数である必要がある *)\n val find : t -> int -> Class.t\n (* 与えられた要素が属する集合同士を合併する *)\n val unite : t -> int -> int -> unit\nend = struct\n type t = { rank : int array; parent : int array }\n\n module Class = struct\n type t = int\n let to_int c = c\n let compare = compare\n end\n\n let make n =\n { rank = Array.make n 0;\n parent = Array.init n @@ fun c -> c }\n\n let rec find uf x =\n if x = uf.parent.(x) then x\n else begin\n let y = find uf uf.parent.(x) in\n uf.parent.(x) <- y; y\n end\n\n let unite uf i j =\n let x = find uf i in\n let y = find uf j in\n if x <> y then begin\n if uf.rank.(x) < uf.rank.(y) then uf.parent.(x) <- y\n else begin\n uf.parent.(y) <- x;\n if uf.rank.(x) = uf.rank.(y) then\n uf.rank.(x) <- 1 + uf.rank.(x)\n end\n end\nend\n\n\nlet () = Scanf.scanf \"%d %d\\n\" @@ fun n m ->\n let abs = Array.init m @@ fun _ -> Scanf.scanf \"%d %d\\n\" @@ fun a b -> a, b in\n let uf = UnionFind.make n in\n let cnt = Array.make n 1 in\n let ans = Array.make (m + 1) (n * (n - 1) / 2) in\n for i = m - 1 downto 0 do\n let ca = UnionFind.find uf (fst abs.(i) - 1) in\n let cb = UnionFind.find uf (snd abs.(i) - 1) in\n if UnionFind.Class.compare ca cb = 0\n then ans.(i) <- ans.(i + 1)\n else begin\n let cnta = cnt.(UnionFind.Class.to_int ca) in\n let cntb = cnt.(UnionFind.Class.to_int cb) in\n ans.(i) <- ans.(i + 1) - cnta * cntb;\n cnt.(UnionFind.Class.to_int ca) <- cnta + cntb;\n cnt.(UnionFind.Class.to_int cb) <- cnta + cntb;\n UnionFind.unite uf (fst abs.(i) - 1) (snd abs.(i) - 1)\n end\n done;\n for i = 1 to m do\n Printf.printf \"%d\\n\" ans.(i)\n done\n\n", "language": "OCaml", "metadata": {"date": 1551645652, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03108.html", "problem_id": "p03108", "resource_group": "low_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/OCaml/s542816027.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s542816027", "user_id": "u504158101"}, "prompt_components": {"gold_output": "0\n0\n4\n5\n6\n", "input_to_evaluate": "(* 素集合データ構造 *)\nmodule UnionFind : sig\n type t\n\n module Class : sig\n type t\n val to_int : t -> int\n val compare : t -> t -> int\n end\n\n (* n要素の素集合データ構造を作る *)\n val make : int -> t\n (* 要素がどの集合に属するか調べる *)\n (* 要素は0からn-1の整数である必要がある *)\n val find : t -> int -> Class.t\n (* 与えられた要素が属する集合同士を合併する *)\n val unite : t -> int -> int -> unit\nend = struct\n type t = { rank : int array; parent : int array }\n\n module Class = struct\n type t = int\n let to_int c = c\n let compare = compare\n end\n\n let make n =\n { rank = Array.make n 0;\n parent = Array.init n @@ fun c -> c }\n\n let rec find uf x =\n if x = uf.parent.(x) then x\n else begin\n let y = find uf uf.parent.(x) in\n uf.parent.(x) <- y; y\n end\n\n let unite uf i j =\n let x = find uf i in\n let y = find uf j in\n if x <> y then begin\n if uf.rank.(x) < uf.rank.(y) then uf.parent.(x) <- y\n else begin\n uf.parent.(y) <- x;\n if uf.rank.(x) = uf.rank.(y) then\n uf.rank.(x) <- 1 + uf.rank.(x)\n end\n end\nend\n\n\nlet () = Scanf.scanf \"%d %d\\n\" @@ fun n m ->\n let abs = Array.init m @@ fun _ -> Scanf.scanf \"%d %d\\n\" @@ fun a b -> a, b in\n let uf = UnionFind.make n in\n let cnt = Array.make n 1 in\n let ans = Array.make (m + 1) (n * (n - 1) / 2) in\n for i = m - 1 downto 0 do\n let ca = UnionFind.find uf (fst abs.(i) - 1) in\n let cb = UnionFind.find uf (snd abs.(i) - 1) in\n if UnionFind.Class.compare ca cb = 0\n then ans.(i) <- ans.(i + 1)\n else begin\n let cnta = cnt.(UnionFind.Class.to_int ca) in\n let cntb = cnt.(UnionFind.Class.to_int cb) in\n ans.(i) <- ans.(i + 1) - cnta * cntb;\n cnt.(UnionFind.Class.to_int ca) <- cnta + cntb;\n cnt.(UnionFind.Class.to_int cb) <- cnta + cntb;\n UnionFind.unite uf (fst abs.(i) - 1) (snd abs.(i) - 1)\n end\n done;\n for i = 1 to m do\n Printf.printf \"%d\\n\" ans.(i)\n done\n\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nThere are N islands and M bridges.\n\nThe i-th bridge connects the A_i-th and B_i-th islands bidirectionally.\n\nInitially, we can travel between any two islands using some of these bridges.\n\nHowever, the results of a survey show that these bridges will all collapse because of aging, in the order from the first bridge to the M-th bridge.\n\nLet the inconvenience be the number of pairs of islands (a, b) (a < b) such that we are no longer able to travel between the a-th and b-th islands using some of the bridges remaining.\n\nFor each i (1 \\leq i \\leq M), find the inconvenience just after the i-th bridge collapses.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n1 \\leq A_i < B_i \\leq N\n\nAll pairs (A_i, B_i) are distinct.\n\nThe inconvenience is initially 0.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 B_1\nA_2 B_2\n\\vdots\nA_M B_M\n\nOutput\n\nIn the order i = 1, 2, ..., M, print the inconvenience just after the i-th bridge collapses.\nNote that the answer may not fit into a 32-bit integer type.\n\nSample Input 1\n\n4 5\n1 2\n3 4\n1 3\n2 3\n1 4\n\nSample Output 1\n\n0\n0\n4\n5\n6\n\nFor example, when the first to third bridges have collapsed, the inconvenience is 4 since we can no longer travel between the pairs (1, 2), (1, 3), (2, 4) and (3, 4).\n\nSample Input 2\n\n6 5\n2 3\n1 2\n5 6\n3 4\n4 5\n\nSample Output 2\n\n8\n9\n12\n14\n15\n\nSample Input 3\n\n2 1\n1 2\n\nSample Output 3\n\n1", "sample_input": "4 5\n1 2\n3 4\n1 3\n2 3\n1 4\n"}, "reference_outputs": ["0\n0\n4\n5\n6\n"], "source_document_id": "p03108", "source_text": "Score : 400 points\n\nProblem Statement\n\nThere are N islands and M bridges.\n\nThe i-th bridge connects the A_i-th and B_i-th islands bidirectionally.\n\nInitially, we can travel between any two islands using some of these bridges.\n\nHowever, the results of a survey show that these bridges will all collapse because of aging, in the order from the first bridge to the M-th bridge.\n\nLet the inconvenience be the number of pairs of islands (a, b) (a < b) such that we are no longer able to travel between the a-th and b-th islands using some of the bridges remaining.\n\nFor each i (1 \\leq i \\leq M), find the inconvenience just after the i-th bridge collapses.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n1 \\leq A_i < B_i \\leq N\n\nAll pairs (A_i, B_i) are distinct.\n\nThe inconvenience is initially 0.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 B_1\nA_2 B_2\n\\vdots\nA_M B_M\n\nOutput\n\nIn the order i = 1, 2, ..., M, print the inconvenience just after the i-th bridge collapses.\nNote that the answer may not fit into a 32-bit integer type.\n\nSample Input 1\n\n4 5\n1 2\n3 4\n1 3\n2 3\n1 4\n\nSample Output 1\n\n0\n0\n4\n5\n6\n\nFor example, when the first to third bridges have collapsed, the inconvenience is 4 since we can no longer travel between the pairs (1, 2), (1, 3), (2, 4) and (3, 4).\n\nSample Input 2\n\n6 5\n2 3\n1 2\n5 6\n3 4\n4 5\n\nSample Output 2\n\n8\n9\n12\n14\n15\n\nSample Input 3\n\n2 1\n1 2\n\nSample Output 3\n\n1", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2045, "cpu_time_ms": 82, "memory_kb": 10496}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s942543522", "group_id": "codeNet:p03109", "input_text": "let () = Scanf.scanf \"%d/%d/%d\" @@ fun yyyy mm dd -> \n Printf.printf \"%s\\n\" @@\n if mm <= 4 then \"Heisei\" else \"TBD\"", "language": "OCaml", "metadata": {"date": 1599172704, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p03109.html", "problem_id": "p03109", "resource_group": "low_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/OCaml/s942543522.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s942543522", "user_id": "u052332717"}, "prompt_components": {"gold_output": "Heisei\n", "input_to_evaluate": "let () = Scanf.scanf \"%d/%d/%d\" @@ fun yyyy mm dd -> \n Printf.printf \"%s\\n\" @@\n if mm <= 4 then \"Heisei\" else \"TBD\"", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 4, "memory_kb": 3700}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s735030986", "group_id": "codeNet:p03109", "input_text": "print_string(if String.compare(read_line())\"2019/04/30\">0 then\"TBD\"else\"Heisei\")", "language": "OCaml", "metadata": {"date": 1587466599, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03109.html", "problem_id": "p03109", "resource_group": "low_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/OCaml/s735030986.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s735030986", "user_id": "u541055501"}, "prompt_components": {"gold_output": "Heisei\n", "input_to_evaluate": "print_string(if String.compare(read_line())\"2019/04/30\">0 then\"TBD\"else\"Heisei\")", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s778073691", "group_id": "codeNet:p03111", "input_text": "let n, a, b, c = Scanf.scanf \" %d %d %d %d\" @@ fun n a b c -> n, a, b, c\nlet ls = Array.init n @@ fun _ -> Scanf.scanf \" %d\" @@ (+) 0\nlet f m l =\n let len = ref 0 in\n let c = ref 0 in\n for i = 0 to n - 1 do\n if m lsr i land 1 = 1 then\n (len := !len + ls.(i); incr c)\n done;\n max 0 (!c - 1) * 10 + (abs @@ l - !len)\nlet g i j k = f i a + f j b + f k c\nlet ans = ref max_int\nlet _ =\n for i = 1 to 255 do\n for j = 1 to 255 do\n if i land j = 0 then\n for k = 1 to 255 do\n if i land k = 0 && j land k = 0 then\n ans := min !ans @@ g i j k\n done\n done\n done;\n Printf.printf \"%d\\n\" !ans", "language": "OCaml", "metadata": {"date": 1559961803, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03111.html", "problem_id": "p03111", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03111/input.txt", "sample_output_relpath": "derived/input_output/data/p03111/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03111/OCaml/s778073691.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s778073691", "user_id": "u732304692"}, "prompt_components": {"gold_output": "23\n", "input_to_evaluate": "let n, a, b, c = Scanf.scanf \" %d %d %d %d\" @@ fun n a b c -> n, a, b, c\nlet ls = Array.init n @@ fun _ -> Scanf.scanf \" %d\" @@ (+) 0\nlet f m l =\n let len = ref 0 in\n let c = ref 0 in\n for i = 0 to n - 1 do\n if m lsr i land 1 = 1 then\n (len := !len + ls.(i); incr c)\n done;\n max 0 (!c - 1) * 10 + (abs @@ l - !len)\nlet g i j k = f i a + f j b + f k c\nlet ans = ref max_int\nlet _ =\n for i = 1 to 255 do\n for j = 1 to 255 do\n if i land j = 0 then\n for k = 1 to 255 do\n if i land k = 0 && j land k = 0 then\n ans := min !ans @@ g i j k\n done\n done\n done;\n Printf.printf \"%d\\n\" !ans", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou have N bamboos. The lengths (in centimeters) of these are l_1, l_2, ..., l_N, respectively.\n\nYour objective is to use some of these bamboos (possibly all) to obtain three bamboos of length A, B, C. For that, you can use the following three kinds of magics any number:\n\nExtension Magic: Consumes 1 MP (magic point). Choose one bamboo and increase its length by 1.\n\nShortening Magic: Consumes 1 MP. Choose one bamboo of length at least 2 and decrease its length by 1.\n\nComposition Magic: Consumes 10 MP. Choose two bamboos and combine them into one bamboo. The length of this new bamboo is equal to the sum of the lengths of the two bamboos combined. (Afterwards, further magics can be used on this bamboo.)\n\nAt least how much MP is needed to achieve the objective?\n\nConstraints\n\n3 \\leq N \\leq 8\n\n1 \\leq C < B < A \\leq 1000\n\n1 \\leq l_i \\leq 1000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN A B C\nl_1\nl_2\n:\nl_N\n\nOutput\n\nPrint the minimum amount of MP needed to achieve the objective.\n\nSample Input 1\n\n5 100 90 80\n98\n40\n30\n21\n80\n\nSample Output 1\n\n23\n\nWe are obtaining three bamboos of lengths 100, 90, 80 from five bamboos 98, 40, 30, 21, 80. We already have a bamboo of length 80, and we can obtain bamboos of lengths 100, 90 by using the magics as follows at the total cost of 23 MP, which is optimal.\n\nUse Extension Magic twice on the bamboo of length 98 to obtain a bamboo of length 100. (MP consumed: 2)\n\nUse Composition Magic on the bamboos of lengths 40, 30 to obtain a bamboo of length 70. (MP consumed: 10)\n\nUse Shortening Magic once on the bamboo of length 21 to obtain a bamboo of length 20. (MP consumed: 1)\n\nUse Composition Magic on the bamboo of length 70 obtained in step 2 and the bamboo of length 20 obtained in step 3 to obtain a bamboo of length 90. (MP consumed: 10)\n\nSample Input 2\n\n8 100 90 80\n100\n100\n90\n90\n90\n80\n80\n80\n\nSample Output 2\n\n0\n\nIf we already have all bamboos of the desired lengths, the amount of MP needed is 0. As seen here, we do not necessarily need to use all the bamboos.\n\nSample Input 3\n\n8 1000 800 100\n300\n333\n400\n444\n500\n555\n600\n666\n\nSample Output 3\n\n243", "sample_input": "5 100 90 80\n98\n40\n30\n21\n80\n"}, "reference_outputs": ["23\n"], "source_document_id": "p03111", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou have N bamboos. The lengths (in centimeters) of these are l_1, l_2, ..., l_N, respectively.\n\nYour objective is to use some of these bamboos (possibly all) to obtain three bamboos of length A, B, C. For that, you can use the following three kinds of magics any number:\n\nExtension Magic: Consumes 1 MP (magic point). Choose one bamboo and increase its length by 1.\n\nShortening Magic: Consumes 1 MP. Choose one bamboo of length at least 2 and decrease its length by 1.\n\nComposition Magic: Consumes 10 MP. Choose two bamboos and combine them into one bamboo. The length of this new bamboo is equal to the sum of the lengths of the two bamboos combined. (Afterwards, further magics can be used on this bamboo.)\n\nAt least how much MP is needed to achieve the objective?\n\nConstraints\n\n3 \\leq N \\leq 8\n\n1 \\leq C < B < A \\leq 1000\n\n1 \\leq l_i \\leq 1000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN A B C\nl_1\nl_2\n:\nl_N\n\nOutput\n\nPrint the minimum amount of MP needed to achieve the objective.\n\nSample Input 1\n\n5 100 90 80\n98\n40\n30\n21\n80\n\nSample Output 1\n\n23\n\nWe are obtaining three bamboos of lengths 100, 90, 80 from five bamboos 98, 40, 30, 21, 80. We already have a bamboo of length 80, and we can obtain bamboos of lengths 100, 90 by using the magics as follows at the total cost of 23 MP, which is optimal.\n\nUse Extension Magic twice on the bamboo of length 98 to obtain a bamboo of length 100. (MP consumed: 2)\n\nUse Composition Magic on the bamboos of lengths 40, 30 to obtain a bamboo of length 70. (MP consumed: 10)\n\nUse Shortening Magic once on the bamboo of length 21 to obtain a bamboo of length 20. (MP consumed: 1)\n\nUse Composition Magic on the bamboo of length 70 obtained in step 2 and the bamboo of length 20 obtained in step 3 to obtain a bamboo of length 90. (MP consumed: 10)\n\nSample Input 2\n\n8 100 90 80\n100\n100\n90\n90\n90\n80\n80\n80\n\nSample Output 2\n\n0\n\nIf we already have all bamboos of the desired lengths, the amount of MP needed is 0. As seen here, we do not necessarily need to use all the bamboos.\n\nSample Input 3\n\n8 1000 800 100\n300\n333\n400\n444\n500\n555\n600\n666\n\nSample Output 3\n\n243", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 638, "cpu_time_ms": 10, "memory_kb": 512}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s463424578", "group_id": "codeNet:p03112", "input_text": "(* q log(max a b) *)\nlet kInf = 20202020202\nlet a, b, q = Scanf.scanf \" %d %d %d\" @@ fun a b c -> a, b, c\nlet ns = [|a; b|]\nlet sts = Array.init 2 @@ fun i ->\n let ds = Array.make (ns.(i) + 2) 0 in\n ds.(0) <- -kInf + i; ds.(ns.(i) + 1) <- kInf + i;\n for j = 1 to ns.(i) do ds.(j) <- Scanf.scanf \" %d\" @@ (+) 0 done;\n ds\nlet xs = Array.init q @@ fun _ -> Scanf.scanf \" %d\" @@ (+) 0\nlet is_ok i key a = a.(i) >= key\nlet binary_search key a =\n let left, right = ref @@ -1, ref @@ Array.length a in\n while !right - !left > 1 do\n let mid = !left + (!right - !left) / 2 in\n if is_ok mid key a then right := mid\n else left := mid done;\n !right\nlet g x i =\n let ps = sts.(i) in\n let yi1 = binary_search x ps in\n min (x - ps.(yi1 - 1)) @@ ps.(yi1) - x\nlet f x =\n let si1, ti1 = binary_search x sts.(0), binary_search x sts.(1) in\n let s0, s1, t0, t1 = sts.(0).(si1 - 1), sts.(0).(si1), sts.(1).(ti1 - 1), sts.(1).(ti1) in\n let ans = ref kInf in\n ans := min !ans @@ if s0 < t0 then x - t0 + g t0 0 else x - s0 + g s0 1;\n ans := min !ans @@ if s1 < t1 then s1 - x + g s1 1 else t1 - x + g t1 0;\n Printf.printf \"%d\\n\" !ans\nlet _ = Array.iter f xs", "language": "OCaml", "metadata": {"date": 1561391368, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03112.html", "problem_id": "p03112", "resource_group": "low_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/OCaml/s463424578.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s463424578", "user_id": "u732304692"}, "prompt_components": {"gold_output": "350\n1400\n301\n399\n", "input_to_evaluate": "(* q log(max a b) *)\nlet kInf = 20202020202\nlet a, b, q = Scanf.scanf \" %d %d %d\" @@ fun a b c -> a, b, c\nlet ns = [|a; b|]\nlet sts = Array.init 2 @@ fun i ->\n let ds = Array.make (ns.(i) + 2) 0 in\n ds.(0) <- -kInf + i; ds.(ns.(i) + 1) <- kInf + i;\n for j = 1 to ns.(i) do ds.(j) <- Scanf.scanf \" %d\" @@ (+) 0 done;\n ds\nlet xs = Array.init q @@ fun _ -> Scanf.scanf \" %d\" @@ (+) 0\nlet is_ok i key a = a.(i) >= key\nlet binary_search key a =\n let left, right = ref @@ -1, ref @@ Array.length a in\n while !right - !left > 1 do\n let mid = !left + (!right - !left) / 2 in\n if is_ok mid key a then right := mid\n else left := mid done;\n !right\nlet g x i =\n let ps = sts.(i) in\n let yi1 = binary_search x ps in\n min (x - ps.(yi1 - 1)) @@ ps.(yi1) - x\nlet f x =\n let si1, ti1 = binary_search x sts.(0), binary_search x sts.(1) in\n let s0, s1, t0, t1 = sts.(0).(si1 - 1), sts.(0).(si1), sts.(1).(ti1 - 1), sts.(1).(ti1) in\n let ans = ref kInf in\n ans := min !ans @@ if s0 < t0 then x - t0 + g t0 0 else x - s0 + g s0 1;\n ans := min !ans @@ if s1 < t1 then s1 - x + g s1 1 else t1 - x + g t1 0;\n Printf.printf \"%d\\n\" !ans\nlet _ = Array.iter f xs", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1159, "cpu_time_ms": 237, "memory_kb": 7296}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s590526826", "group_id": "codeNet:p03112", "input_text": "let (>>=) xs f = List.map f xs |> List.concat\nlet lower_bound p arr =\n let len = Array.length arr in\n let rec f l r =\n if l+1 >= r then r\n else\n let m = (l+r) / 2 in\n if p arr.(m) then f l m else f m r\n in f (-1) len\nlet lower_bound' p arr =\n let idx = lower_bound p arr in\n if idx >= Array.length arr then [] else [arr.(idx)]\nlet sign = compare 0\nlet () =\n Scanf.scanf \"%d %d %d\" @@ fun a b q ->\n let s = Array.init a (fun _ -> Scanf.scanf \" %d\" ((+) 0)) in\n let t = Array.init b (fun _ -> Scanf.scanf \" %d\" ((+) 0)) in\n let s' = Array.init a (fun i -> s.(a-1-i)) in\n let t' = Array.init b (fun i -> t.(b-1-i)) in\n let xs = Array.init q (fun _ -> Scanf.scanf \" %d\" ((+) 0)) in\n xs |> Array.iter @@ fun x ->\n ((lower_bound' ((<=) x) s @ lower_bound' ((>=) x) s') >>= fun sh ->\n (lower_bound' ((<=) x) t @ lower_bound' ((>=) x) t') >>= fun tp ->\n let v, w = min (abs (sh-x)) (abs (tp-x)), max (abs (sh-x)) (abs (tp-x)) in\n if sign (sh-x) * sign (tp-x) >= 0 then [w] else [2*v + w])\n |> List.fold_left min 10101010101010 |> Printf.printf \"%d\\n\"\n", "language": "OCaml", "metadata": {"date": 1551051358, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03112.html", "problem_id": "p03112", "resource_group": "low_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/OCaml/s590526826.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s590526826", "user_id": "u798181098"}, "prompt_components": {"gold_output": "350\n1400\n301\n399\n", "input_to_evaluate": "let (>>=) xs f = List.map f xs |> List.concat\nlet lower_bound p arr =\n let len = Array.length arr in\n let rec f l r =\n if l+1 >= r then r\n else\n let m = (l+r) / 2 in\n if p arr.(m) then f l m else f m r\n in f (-1) len\nlet lower_bound' p arr =\n let idx = lower_bound p arr in\n if idx >= Array.length arr then [] else [arr.(idx)]\nlet sign = compare 0\nlet () =\n Scanf.scanf \"%d %d %d\" @@ fun a b q ->\n let s = Array.init a (fun _ -> Scanf.scanf \" %d\" ((+) 0)) in\n let t = Array.init b (fun _ -> Scanf.scanf \" %d\" ((+) 0)) in\n let s' = Array.init a (fun i -> s.(a-1-i)) in\n let t' = Array.init b (fun i -> t.(b-1-i)) in\n let xs = Array.init q (fun _ -> Scanf.scanf \" %d\" ((+) 0)) in\n xs |> Array.iter @@ fun x ->\n ((lower_bound' ((<=) x) s @ lower_bound' ((>=) x) s') >>= fun sh ->\n (lower_bound' ((<=) x) t @ lower_bound' ((>=) x) t') >>= fun tp ->\n let v, w = min (abs (sh-x)) (abs (tp-x)), max (abs (sh-x)) (abs (tp-x)) in\n if sign (sh-x) * sign (tp-x) >= 0 then [w] else [2*v + w])\n |> List.fold_left min 10101010101010 |> Printf.printf \"%d\\n\"\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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1093, "cpu_time_ms": 339, "memory_kb": 8320}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s265876352", "group_id": "codeNet:p03125", "input_text": "Scanf.scanf \" %d %d\" @@ fun a b ->\n print_int @@\n if b mod a = 0 then a+b else b-a", "language": "OCaml", "metadata": {"date": 1550565910, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03125.html", "problem_id": "p03125", "resource_group": "low_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/OCaml/s265876352.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s265876352", "user_id": "u481480055"}, "prompt_components": {"gold_output": "16\n", "input_to_evaluate": "Scanf.scanf \" %d %d\" @@ fun a b ->\n print_int @@\n if b mod a = 0 then a+b else b-a", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 2432}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s992872734", "group_id": "codeNet:p03126", "input_text": "(*\nocamlfind ocamlopt -package batteries -linkpkg main.ml -o a.out\n*)\nopen Batteries\n\nlet n, m = Scanf.sscanf (read_line ()) \"%d %d\" ( fun n m -> n, m)\n\nlet lst = List.init n ( fun _ -> \n List.tl (Str.split (Str.regexp \" \") (read_line ()))\n |> List.map int_of_string \n |> Set.of_list\n)\n\nlet () =\n Set.cardinal (List.fold_left (fun a b -> Set.intersect a b) (List.hd lst) (List.tl lst)) \n |> Printf.printf \"%d\\n\"\n", "language": "OCaml", "metadata": {"date": 1590709190, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03126.html", "problem_id": "p03126", "resource_group": "low_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/OCaml/s992872734.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s992872734", "user_id": "u280335093"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "(*\nocamlfind ocamlopt -package batteries -linkpkg main.ml -o a.out\n*)\nopen Batteries\n\nlet n, m = Scanf.sscanf (read_line ()) \"%d %d\" ( fun n m -> n, m)\n\nlet lst = List.init n ( fun _ -> \n List.tl (Str.split (Str.regexp \" \") (read_line ()))\n |> List.map int_of_string \n |> Set.of_list\n)\n\nlet () =\n Set.cardinal (List.fold_left (fun a b -> Set.intersect a b) (List.hd lst) (List.tl lst)) \n |> Printf.printf \"%d\\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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 3, "memory_kb": 3584}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s608241075", "group_id": "codeNet:p03127", "input_text": "let solve monsters =\n let min_hp = List.hd monsters in\n let monsters = List.tl monsters in\n let rec inner cur_min =\n let ls = List.filter (fun e -> e mod cur_min <> 0) monsters in\n match ls with\n | [] -> cur_min\n | ls -> \n List.fold_left (fun me e -> min me (e mod cur_min)) max_int ls |> inner\n in inner min_hp\n\nlet _ =\n let n = Scanf.scanf \"%d\\n\" (fun n -> n) in\n let monsters = ref [] in\n for i = 0 to n - 1 do\n Scanf.scanf (if i <> n - 1 then \"%d \" else \"%d\\n\") \n (fun m -> monsters := m::!monsters)\n done;\n List.sort (compare) !monsters\n |> solve |> print_int\n", "language": "OCaml", "metadata": {"date": 1552852247, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03127.html", "problem_id": "p03127", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03127/input.txt", "sample_output_relpath": "derived/input_output/data/p03127/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03127/OCaml/s608241075.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s608241075", "user_id": "u387591304"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "let solve monsters =\n let min_hp = List.hd monsters in\n let monsters = List.tl monsters in\n let rec inner cur_min =\n let ls = List.filter (fun e -> e mod cur_min <> 0) monsters in\n match ls with\n | [] -> cur_min\n | ls -> \n List.fold_left (fun me e -> min me (e mod cur_min)) max_int ls |> inner\n in inner min_hp\n\nlet _ =\n let n = Scanf.scanf \"%d\\n\" (fun n -> n) in\n let monsters = ref [] in\n for i = 0 to n - 1 do\n Scanf.scanf (if i <> n - 1 then \"%d \" else \"%d\\n\") \n (fun m -> monsters := m::!monsters)\n done;\n List.sort (compare) !monsters\n |> solve |> print_int\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere are N monsters, numbered 1, 2, ..., N.\n\nInitially, the health of Monster i is A_i.\n\nBelow, a monster with at least 1 health is called alive.\n\nUntil there is only one alive monster, the following is repeated:\n\nA random alive monster attacks another random alive monster.\n\nAs a result, the health of the monster attacked is reduced by the amount equal to the current health of the monster attacking.\n\nFind the minimum possible final health of the last monster alive.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10^5\n\n1 \\leq A_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the minimum possible final health of the last monster alive.\n\nSample Input 1\n\n4\n2 10 8 40\n\nSample Output 1\n\n2\n\nWhen only the first monster keeps on attacking, the final health of the last monster will be 2, which is minimum.\n\nSample Input 2\n\n4\n5 13 8 1000000000\n\nSample Output 2\n\n1\n\nSample Input 3\n\n3\n1000000000 1000000000 1000000000\n\nSample Output 3\n\n1000000000", "sample_input": "4\n2 10 8 40\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03127", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere are N monsters, numbered 1, 2, ..., N.\n\nInitially, the health of Monster i is A_i.\n\nBelow, a monster with at least 1 health is called alive.\n\nUntil there is only one alive monster, the following is repeated:\n\nA random alive monster attacks another random alive monster.\n\nAs a result, the health of the monster attacked is reduced by the amount equal to the current health of the monster attacking.\n\nFind the minimum possible final health of the last monster alive.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 10^5\n\n1 \\leq A_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the minimum possible final health of the last monster alive.\n\nSample Input 1\n\n4\n2 10 8 40\n\nSample Output 1\n\n2\n\nWhen only the first monster keeps on attacking, the final health of the last monster will be 2, which is minimum.\n\nSample Input 2\n\n4\n5 13 8 1000000000\n\nSample Output 2\n\n1\n\nSample Input 3\n\n3\n1000000000 1000000000 1000000000\n\nSample Output 3\n\n1000000000", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 601, "cpu_time_ms": 100, "memory_kb": 11648}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s825520888", "group_id": "codeNet:p03128", "input_text": "let cost = Array.get [| 2; 5; 5; 4; 5; 6; 3; 7; 6 |]\n\nlet () = Scanf.scanf \"%d %d\" @@ fun n m ->\n let as_ = Array.init m @@ fun m -> Scanf.scanf \"%c%d\" @@ fun _ a -> a in\n let dp = Array.make (n + 10) (-1, []) in\n dp.(0) <- (0, []);\n for i = 0 to n - 1 do\n Array.iter (fun a ->\n if 0 <= fst dp.(i) then\n dp.(i + cost (a - 1)) <-\n max dp.(i + cost (a - 1)) @@ (fst dp.(i) + 1, a :: snd dp.(i))) as_\n done;\n List.iter print_int (snd dp.(n));\n print_newline ()\n", "language": "OCaml", "metadata": {"date": 1550400517, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03128.html", "problem_id": "p03128", "resource_group": "low_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/OCaml/s825520888.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s825520888", "user_id": "u504158101"}, "prompt_components": {"gold_output": "777773\n", "input_to_evaluate": "let cost = Array.get [| 2; 5; 5; 4; 5; 6; 3; 7; 6 |]\n\nlet () = Scanf.scanf \"%d %d\" @@ fun n m ->\n let as_ = Array.init m @@ fun m -> Scanf.scanf \"%c%d\" @@ fun _ a -> a in\n let dp = Array.make (n + 10) (-1, []) in\n dp.(0) <- (0, []);\n for i = 0 to n - 1 do\n Array.iter (fun a ->\n if 0 <= fst dp.(i) then\n dp.(i + cost (a - 1)) <-\n max dp.(i + cost (a - 1)) @@ (fst dp.(i) + 1, a :: snd dp.(i))) as_\n done;\n List.iter print_int (snd dp.(n));\n print_newline ()\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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 489, "cpu_time_ms": 8, "memory_kb": 5120}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s616149419", "group_id": "codeNet:p03129", "input_text": "Scanf.scanf \" %d %d\" @@ fun n k ->\n print_string @@ if 2*k - 1 > n then \"NO\" else \"YES\"", "language": "OCaml", "metadata": {"date": 1549811895, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03129.html", "problem_id": "p03129", "resource_group": "low_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/OCaml/s616149419.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s616149419", "user_id": "u481480055"}, "prompt_components": {"gold_output": "YES\n", "input_to_evaluate": "Scanf.scanf \" %d %d\" @@ fun n k ->\n print_string @@ if 2*k - 1 > n then \"NO\" else \"YES\"", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 2432}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s115120208", "group_id": "codeNet:p03130", "input_text": "let ab_s = Array.init 3 @@ fun _ -> Scanf.scanf \" %d %d\" @@ fun a b -> a, b\nlet cs = Array.make 5 0\nlet _ = Array.iter (fun (a, b) -> cs.(a) <- cs.(a) + 1; cs.(b) <- cs.(b) + 1) ab_s;\n for i = 1 to 4 do if cs.(i) = 0 || cs.(i) >= 3 then (print_endline \"NO\"; exit 0) done;\n print_endline \"YES\"", "language": "OCaml", "metadata": {"date": 1563740103, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03130.html", "problem_id": "p03130", "resource_group": "low_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/OCaml/s115120208.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s115120208", "user_id": "u732304692"}, "prompt_components": {"gold_output": "YES\n", "input_to_evaluate": "let ab_s = Array.init 3 @@ fun _ -> Scanf.scanf \" %d %d\" @@ fun a b -> a, b\nlet cs = Array.make 5 0\nlet _ = Array.iter (fun (a, b) -> cs.(a) <- cs.(a) + 1; cs.(b) <- cs.(b) + 1) ab_s;\n for i = 1 to 4 do if cs.(i) = 0 || cs.(i) >= 3 then (print_endline \"NO\"; exit 0) done;\n print_endline \"YES\"", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 294, "cpu_time_ms": 1, "memory_kb": 2432}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s488345848", "group_id": "codeNet:p03131", "input_text": "Scanf.scanf \"%d %d %d\" (fun k a b ->\n if k < a-1 || b-a < 2 then k+1\n else a + (k-a+1) / 2 * (b-a) + (k-a+1) mod 2)\n|> Printf.printf \"%d\\n\"", "language": "OCaml", "metadata": {"date": 1549781965, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03131.html", "problem_id": "p03131", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03131/input.txt", "sample_output_relpath": "derived/input_output/data/p03131/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03131/OCaml/s488345848.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s488345848", "user_id": "u798181098"}, "prompt_components": {"gold_output": "7\n", "input_to_evaluate": "Scanf.scanf \"%d %d %d\" (fun k a b ->\n if k < a-1 || b-a < 2 then k+1\n else a + (k-a+1) / 2 * (b-a) + (k-a+1) mod 2)\n|> Printf.printf \"%d\\n\"", "problem_context": "Score : 400 points\n\nProblem Statement\n\nSnuke has one biscuit and zero Japanese yen (the currency) in his pocket.\nHe will perform the following operations exactly K times in total, in the order he likes:\n\nHit his pocket, which magically increases the number of biscuits by one.\n\nExchange A biscuits to 1 yen.\n\nExchange 1 yen to B biscuits.\n\nFind the maximum possible number of biscuits in Snuke's pocket after K operations.\n\nConstraints\n\n1 \\leq K,A,B \\leq 10^9\n\nK,A and B are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK A B\n\nOutput\n\nPrint the maximum possible number of biscuits in Snuke's pocket after K operations.\n\nSample Input 1\n\n4 2 6\n\nSample Output 1\n\n7\n\nThe number of biscuits in Snuke's pocket after K operations is maximized as follows:\n\nHit his pocket. Now he has 2 biscuits and 0 yen.\n\nExchange 2 biscuits to 1 yen. his pocket. Now he has 0 biscuits and 1 yen.\n\nHit his pocket. Now he has 1 biscuits and 1 yen.\n\nExchange 1 yen to 6 biscuits. his pocket. Now he has 7 biscuits and 0 yen.\n\nSample Input 2\n\n7 3 4\n\nSample Output 2\n\n8\n\nSample Input 3\n\n314159265 35897932 384626433\n\nSample Output 3\n\n48518828981938099", "sample_input": "4 2 6\n"}, "reference_outputs": ["7\n"], "source_document_id": "p03131", "source_text": "Score : 400 points\n\nProblem Statement\n\nSnuke has one biscuit and zero Japanese yen (the currency) in his pocket.\nHe will perform the following operations exactly K times in total, in the order he likes:\n\nHit his pocket, which magically increases the number of biscuits by one.\n\nExchange A biscuits to 1 yen.\n\nExchange 1 yen to B biscuits.\n\nFind the maximum possible number of biscuits in Snuke's pocket after K operations.\n\nConstraints\n\n1 \\leq K,A,B \\leq 10^9\n\nK,A and B are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK A B\n\nOutput\n\nPrint the maximum possible number of biscuits in Snuke's pocket after K operations.\n\nSample Input 1\n\n4 2 6\n\nSample Output 1\n\n7\n\nThe number of biscuits in Snuke's pocket after K operations is maximized as follows:\n\nHit his pocket. Now he has 2 biscuits and 0 yen.\n\nExchange 2 biscuits to 1 yen. his pocket. Now he has 0 biscuits and 1 yen.\n\nHit his pocket. Now he has 1 biscuits and 1 yen.\n\nExchange 1 yen to 6 biscuits. his pocket. Now he has 7 biscuits and 0 yen.\n\nSample Input 2\n\n7 3 4\n\nSample Output 2\n\n8\n\nSample Input 3\n\n314159265 35897932 384626433\n\nSample Output 3\n\n48518828981938099", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s561082422", "group_id": "codeNet:p03131", "input_text": "let () = Scanf.scanf \"%d %d %d\" @@ fun k a b ->\n Printf.printf \"%d\" @@ max (a + (k - a + 1) * (b - a) / 2 - if (k - a + 1) mod 2 = 1 then 1 else 0) (k + 1)\n", "language": "OCaml", "metadata": {"date": 1549770972, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03131.html", "problem_id": "p03131", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03131/input.txt", "sample_output_relpath": "derived/input_output/data/p03131/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03131/OCaml/s561082422.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s561082422", "user_id": "u604818425"}, "prompt_components": {"gold_output": "7\n", "input_to_evaluate": "let () = Scanf.scanf \"%d %d %d\" @@ fun k a b ->\n Printf.printf \"%d\" @@ max (a + (k - a + 1) * (b - a) / 2 - if (k - a + 1) mod 2 = 1 then 1 else 0) (k + 1)\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nSnuke has one biscuit and zero Japanese yen (the currency) in his pocket.\nHe will perform the following operations exactly K times in total, in the order he likes:\n\nHit his pocket, which magically increases the number of biscuits by one.\n\nExchange A biscuits to 1 yen.\n\nExchange 1 yen to B biscuits.\n\nFind the maximum possible number of biscuits in Snuke's pocket after K operations.\n\nConstraints\n\n1 \\leq K,A,B \\leq 10^9\n\nK,A and B are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK A B\n\nOutput\n\nPrint the maximum possible number of biscuits in Snuke's pocket after K operations.\n\nSample Input 1\n\n4 2 6\n\nSample Output 1\n\n7\n\nThe number of biscuits in Snuke's pocket after K operations is maximized as follows:\n\nHit his pocket. Now he has 2 biscuits and 0 yen.\n\nExchange 2 biscuits to 1 yen. his pocket. Now he has 0 biscuits and 1 yen.\n\nHit his pocket. Now he has 1 biscuits and 1 yen.\n\nExchange 1 yen to 6 biscuits. his pocket. Now he has 7 biscuits and 0 yen.\n\nSample Input 2\n\n7 3 4\n\nSample Output 2\n\n8\n\nSample Input 3\n\n314159265 35897932 384626433\n\nSample Output 3\n\n48518828981938099", "sample_input": "4 2 6\n"}, "reference_outputs": ["7\n"], "source_document_id": "p03131", "source_text": "Score : 400 points\n\nProblem Statement\n\nSnuke has one biscuit and zero Japanese yen (the currency) in his pocket.\nHe will perform the following operations exactly K times in total, in the order he likes:\n\nHit his pocket, which magically increases the number of biscuits by one.\n\nExchange A biscuits to 1 yen.\n\nExchange 1 yen to B biscuits.\n\nFind the maximum possible number of biscuits in Snuke's pocket after K operations.\n\nConstraints\n\n1 \\leq K,A,B \\leq 10^9\n\nK,A and B are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK A B\n\nOutput\n\nPrint the maximum possible number of biscuits in Snuke's pocket after K operations.\n\nSample Input 1\n\n4 2 6\n\nSample Output 1\n\n7\n\nThe number of biscuits in Snuke's pocket after K operations is maximized as follows:\n\nHit his pocket. Now he has 2 biscuits and 0 yen.\n\nExchange 2 biscuits to 1 yen. his pocket. Now he has 0 biscuits and 1 yen.\n\nHit his pocket. Now he has 1 biscuits and 1 yen.\n\nExchange 1 yen to 6 biscuits. his pocket. Now he has 7 biscuits and 0 yen.\n\nSample Input 2\n\n7 3 4\n\nSample Output 2\n\n8\n\nSample Input 3\n\n314159265 35897932 384626433\n\nSample Output 3\n\n48518828981938099", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s548704332", "group_id": "codeNet:p03132", "input_text": "open Scanf\nopen Printf\nopen Array\n\nlet max_i64,(++),i64 = Int64.(max_int,add,of_int)\n\nlet () = scanf \" %d\" @@ fun l ->\n let a = init l (fun _ -> scanf \" %d\" @@ fun v -> v) in\n let dp = make_matrix (l+1) 5 max_i64 in\n let f typ v = i64 @@\n match typ with\n | 0 | 4 -> (* zero *)\n v\n | 1 | 3 -> (* even >= 2 *)\n if v=0 then 2\n else if v mod 2 = 0 then 0 else 1\n | 2 | _ -> (* odd *)\n if v mod 2 = 1 then 0 else 1\n in\n let update i j v =\n dp.(i).(j) <- min dp.(i).(j) v\n in\n for k=0 to 4 do\n dp.(0).(k) <- 0L;\n done;\n let to_ = [|\n [0;1;2];\n [1;2;4];\n [2;3;4];\n [3;4];\n [4]\n |] in\n for i=1 to l do\n for k=0 to 4 do\n List.iter (fun j ->\n update i j @@ dp.(i-1).(k) ++ f j a.(i-1)\n ) to_.(k)\n done\n done;\n (* iter (fun b ->\n iter (printf \"%2Ld \") b;\n print_newline ()\n ) dp; *)\n printf \"%Ld\" @@ fold_left min max_i64 dp.(l)", "language": "OCaml", "metadata": {"date": 1550301653, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03132.html", "problem_id": "p03132", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03132/input.txt", "sample_output_relpath": "derived/input_output/data/p03132/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03132/OCaml/s548704332.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s548704332", "user_id": "u481480055"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "open Scanf\nopen Printf\nopen Array\n\nlet max_i64,(++),i64 = Int64.(max_int,add,of_int)\n\nlet () = scanf \" %d\" @@ fun l ->\n let a = init l (fun _ -> scanf \" %d\" @@ fun v -> v) in\n let dp = make_matrix (l+1) 5 max_i64 in\n let f typ v = i64 @@\n match typ with\n | 0 | 4 -> (* zero *)\n v\n | 1 | 3 -> (* even >= 2 *)\n if v=0 then 2\n else if v mod 2 = 0 then 0 else 1\n | 2 | _ -> (* odd *)\n if v mod 2 = 1 then 0 else 1\n in\n let update i j v =\n dp.(i).(j) <- min dp.(i).(j) v\n in\n for k=0 to 4 do\n dp.(0).(k) <- 0L;\n done;\n let to_ = [|\n [0;1;2];\n [1;2;4];\n [2;3;4];\n [3;4];\n [4]\n |] in\n for i=1 to l do\n for k=0 to 4 do\n List.iter (fun j ->\n update i j @@ dp.(i-1).(k) ++ f j a.(i-1)\n ) to_.(k)\n done\n done;\n (* iter (fun b ->\n iter (printf \"%2Ld \") b;\n print_newline ()\n ) dp; *)\n printf \"%Ld\" @@ fold_left min max_i64 dp.(l)", "problem_context": "Score : 600 points\n\nProblem Statement\n\nSnuke stands on a number line. He has L ears, and he will walk along the line continuously under the following conditions:\n\nHe never visits a point with coordinate less than 0, or a point with coordinate greater than L.\n\nHe starts walking at a point with integer coordinate, and also finishes walking at a point with integer coordinate.\n\nHe only changes direction at a point with integer coordinate.\n\nEach time when Snuke passes a point with coordinate i-0.5, where i is an integer, he put a stone in his i-th ear.\n\nAfter Snuke finishes walking, Ringo will repeat the following operations in some order so that, for each i, Snuke's i-th ear contains A_i stones:\n\nPut a stone in one of Snuke's ears.\n\nRemove a stone from one of Snuke's ears.\n\nFind the minimum number of operations required when Ringo can freely decide how Snuke walks.\n\nConstraints\n\n1 \\leq L \\leq 2\\times 10^5\n\n0 \\leq A_i \\leq 10^9(1\\leq i\\leq L)\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nL\nA_1\n:\nA_L\n\nOutput\n\nPrint the minimum number of operations required when Ringo can freely decide how Snuke walks.\n\nSample Input 1\n\n4\n1\n0\n2\n3\n\nSample Output 1\n\n1\n\nAssume that Snuke walks as follows:\n\nHe starts walking at coordinate 3 and finishes walking at coordinate 4, visiting coordinates 3,4,3,2,3,4 in this order.\n\nThen, Snuke's four ears will contain 0,0,2,3 stones, respectively.\nRingo can satisfy the requirement by putting one stone in the first ear.\n\nSample Input 2\n\n8\n2\n0\n0\n2\n1\n3\n4\n1\n\nSample Output 2\n\n3\n\nSample Input 3\n\n7\n314159265\n358979323\n846264338\n327950288\n419716939\n937510582\n0\n\nSample Output 3\n\n1", "sample_input": "4\n1\n0\n2\n3\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03132", "source_text": "Score : 600 points\n\nProblem Statement\n\nSnuke stands on a number line. He has L ears, and he will walk along the line continuously under the following conditions:\n\nHe never visits a point with coordinate less than 0, or a point with coordinate greater than L.\n\nHe starts walking at a point with integer coordinate, and also finishes walking at a point with integer coordinate.\n\nHe only changes direction at a point with integer coordinate.\n\nEach time when Snuke passes a point with coordinate i-0.5, where i is an integer, he put a stone in his i-th ear.\n\nAfter Snuke finishes walking, Ringo will repeat the following operations in some order so that, for each i, Snuke's i-th ear contains A_i stones:\n\nPut a stone in one of Snuke's ears.\n\nRemove a stone from one of Snuke's ears.\n\nFind the minimum number of operations required when Ringo can freely decide how Snuke walks.\n\nConstraints\n\n1 \\leq L \\leq 2\\times 10^5\n\n0 \\leq A_i \\leq 10^9(1\\leq i\\leq L)\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nL\nA_1\n:\nA_L\n\nOutput\n\nPrint the minimum number of operations required when Ringo can freely decide how Snuke walks.\n\nSample Input 1\n\n4\n1\n0\n2\n3\n\nSample Output 1\n\n1\n\nAssume that Snuke walks as follows:\n\nHe starts walking at coordinate 3 and finishes walking at coordinate 4, visiting coordinates 3,4,3,2,3,4 in this order.\n\nThen, Snuke's four ears will contain 0,0,2,3 stones, respectively.\nRingo can satisfy the requirement by putting one stone in the first ear.\n\nSample Input 2\n\n8\n2\n0\n0\n2\n1\n3\n4\n1\n\nSample Output 2\n\n3\n\nSample Input 3\n\n7\n314159265\n358979323\n846264338\n327950288\n419716939\n937510582\n0\n\nSample Output 3\n\n1", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 251, "memory_kb": 40896}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s721184893", "group_id": "codeNet:p03132", "input_text": "open Scanf\nopen Printf\nopen Array\n\nlet max_i64,(++),i64 = Int64.(max_int,add,of_int)\n\nlet () = scanf \" %d\" @@ fun l ->\n let a = init l (fun _ -> scanf \" %d\" @@ fun v -> v) in\n let dp = make_matrix (l+1) 5 max_i64 in\n let f typ v = i64 @@\n match typ with\n | 0 | 4 -> (* zero *)\n v\n | 1 | 3 -> (* even >= 2 *)\n if v=0 then 2\n else if v mod 2 = 0 then 0 else 1\n | 2 | _ -> (* odd *)\n if v mod 2 = 1 then 0 else 1\n in\n let update i j v =\n dp.(i).(j) <- min dp.(i).(j) v\n in\n for k=0 to 4 do\n dp.(0).(k) <- 0L;\n done;\n for i=1 to l do\n for k=0 to 4 do\n for j=k to 4 do\n if k=0 && j=4 || k=1 && j=3 then ()\n else update i j @@ dp.(i-1).(k) ++ f j a.(i-1)\n done\n done\n done;\n (* iter (fun b ->\n iter (printf \"%2Ld \") b;\n print_newline ()\n ) dp; *)\n printf \"%Ld\" @@ fold_left min max_i64 dp.(l)", "language": "OCaml", "metadata": {"date": 1550301234, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03132.html", "problem_id": "p03132", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03132/input.txt", "sample_output_relpath": "derived/input_output/data/p03132/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03132/OCaml/s721184893.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s721184893", "user_id": "u481480055"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "open Scanf\nopen Printf\nopen Array\n\nlet max_i64,(++),i64 = Int64.(max_int,add,of_int)\n\nlet () = scanf \" %d\" @@ fun l ->\n let a = init l (fun _ -> scanf \" %d\" @@ fun v -> v) in\n let dp = make_matrix (l+1) 5 max_i64 in\n let f typ v = i64 @@\n match typ with\n | 0 | 4 -> (* zero *)\n v\n | 1 | 3 -> (* even >= 2 *)\n if v=0 then 2\n else if v mod 2 = 0 then 0 else 1\n | 2 | _ -> (* odd *)\n if v mod 2 = 1 then 0 else 1\n in\n let update i j v =\n dp.(i).(j) <- min dp.(i).(j) v\n in\n for k=0 to 4 do\n dp.(0).(k) <- 0L;\n done;\n for i=1 to l do\n for k=0 to 4 do\n for j=k to 4 do\n if k=0 && j=4 || k=1 && j=3 then ()\n else update i j @@ dp.(i-1).(k) ++ f j a.(i-1)\n done\n done\n done;\n (* iter (fun b ->\n iter (printf \"%2Ld \") b;\n print_newline ()\n ) dp; *)\n printf \"%Ld\" @@ fold_left min max_i64 dp.(l)", "problem_context": "Score : 600 points\n\nProblem Statement\n\nSnuke stands on a number line. He has L ears, and he will walk along the line continuously under the following conditions:\n\nHe never visits a point with coordinate less than 0, or a point with coordinate greater than L.\n\nHe starts walking at a point with integer coordinate, and also finishes walking at a point with integer coordinate.\n\nHe only changes direction at a point with integer coordinate.\n\nEach time when Snuke passes a point with coordinate i-0.5, where i is an integer, he put a stone in his i-th ear.\n\nAfter Snuke finishes walking, Ringo will repeat the following operations in some order so that, for each i, Snuke's i-th ear contains A_i stones:\n\nPut a stone in one of Snuke's ears.\n\nRemove a stone from one of Snuke's ears.\n\nFind the minimum number of operations required when Ringo can freely decide how Snuke walks.\n\nConstraints\n\n1 \\leq L \\leq 2\\times 10^5\n\n0 \\leq A_i \\leq 10^9(1\\leq i\\leq L)\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nL\nA_1\n:\nA_L\n\nOutput\n\nPrint the minimum number of operations required when Ringo can freely decide how Snuke walks.\n\nSample Input 1\n\n4\n1\n0\n2\n3\n\nSample Output 1\n\n1\n\nAssume that Snuke walks as follows:\n\nHe starts walking at coordinate 3 and finishes walking at coordinate 4, visiting coordinates 3,4,3,2,3,4 in this order.\n\nThen, Snuke's four ears will contain 0,0,2,3 stones, respectively.\nRingo can satisfy the requirement by putting one stone in the first ear.\n\nSample Input 2\n\n8\n2\n0\n0\n2\n1\n3\n4\n1\n\nSample Output 2\n\n3\n\nSample Input 3\n\n7\n314159265\n358979323\n846264338\n327950288\n419716939\n937510582\n0\n\nSample Output 3\n\n1", "sample_input": "4\n1\n0\n2\n3\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03132", "source_text": "Score : 600 points\n\nProblem Statement\n\nSnuke stands on a number line. He has L ears, and he will walk along the line continuously under the following conditions:\n\nHe never visits a point with coordinate less than 0, or a point with coordinate greater than L.\n\nHe starts walking at a point with integer coordinate, and also finishes walking at a point with integer coordinate.\n\nHe only changes direction at a point with integer coordinate.\n\nEach time when Snuke passes a point with coordinate i-0.5, where i is an integer, he put a stone in his i-th ear.\n\nAfter Snuke finishes walking, Ringo will repeat the following operations in some order so that, for each i, Snuke's i-th ear contains A_i stones:\n\nPut a stone in one of Snuke's ears.\n\nRemove a stone from one of Snuke's ears.\n\nFind the minimum number of operations required when Ringo can freely decide how Snuke walks.\n\nConstraints\n\n1 \\leq L \\leq 2\\times 10^5\n\n0 \\leq A_i \\leq 10^9(1\\leq i\\leq L)\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nL\nA_1\n:\nA_L\n\nOutput\n\nPrint the minimum number of operations required when Ringo can freely decide how Snuke walks.\n\nSample Input 1\n\n4\n1\n0\n2\n3\n\nSample Output 1\n\n1\n\nAssume that Snuke walks as follows:\n\nHe starts walking at coordinate 3 and finishes walking at coordinate 4, visiting coordinates 3,4,3,2,3,4 in this order.\n\nThen, Snuke's four ears will contain 0,0,2,3 stones, respectively.\nRingo can satisfy the requirement by putting one stone in the first ear.\n\nSample Input 2\n\n8\n2\n0\n0\n2\n1\n3\n4\n1\n\nSample Output 2\n\n3\n\nSample Input 3\n\n7\n314159265\n358979323\n846264338\n327950288\n419716939\n937510582\n0\n\nSample Output 3\n\n1", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 873, "cpu_time_ms": 262, "memory_kb": 41024}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s739835657", "group_id": "codeNet:p03132", "input_text": "let () = Scanf.scanf \"%d\\n\" @@ fun l ->\n let as_ = Array.init l @@ fun _ -> Scanf.scanf \"%d\\n\" @@ fun a -> a in\n let ans, dp1, dp2, dp3 =\n Array.fold_left (fun (ans, dp1, dp2, dp3) a ->\n max ans (max dp1 (max dp2 dp3)),\n (if a < 2 then 0 else a - a mod 2 + dp1),\n (if a < 1 then 0 else a - (a + 1) mod 2 + max dp1 dp2),\n (if a < 2 then 0 else a - a mod 2 + max dp2 dp3))\n (min_int, 0, 0, 0) as_ in\n Printf.printf \"%d\\n\" @@ Array.fold_left ( + ) (( ~- ) @@ max ans @@ max dp1 @@ max dp2 dp3) as_\n\n", "language": "OCaml", "metadata": {"date": 1549767105, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03132.html", "problem_id": "p03132", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03132/input.txt", "sample_output_relpath": "derived/input_output/data/p03132/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03132/OCaml/s739835657.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s739835657", "user_id": "u504158101"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "let () = Scanf.scanf \"%d\\n\" @@ fun l ->\n let as_ = Array.init l @@ fun _ -> Scanf.scanf \"%d\\n\" @@ fun a -> a in\n let ans, dp1, dp2, dp3 =\n Array.fold_left (fun (ans, dp1, dp2, dp3) a ->\n max ans (max dp1 (max dp2 dp3)),\n (if a < 2 then 0 else a - a mod 2 + dp1),\n (if a < 1 then 0 else a - (a + 1) mod 2 + max dp1 dp2),\n (if a < 2 then 0 else a - a mod 2 + max dp2 dp3))\n (min_int, 0, 0, 0) as_ in\n Printf.printf \"%d\\n\" @@ Array.fold_left ( + ) (( ~- ) @@ max ans @@ max dp1 @@ max dp2 dp3) as_\n\n", "problem_context": "Score : 600 points\n\nProblem Statement\n\nSnuke stands on a number line. He has L ears, and he will walk along the line continuously under the following conditions:\n\nHe never visits a point with coordinate less than 0, or a point with coordinate greater than L.\n\nHe starts walking at a point with integer coordinate, and also finishes walking at a point with integer coordinate.\n\nHe only changes direction at a point with integer coordinate.\n\nEach time when Snuke passes a point with coordinate i-0.5, where i is an integer, he put a stone in his i-th ear.\n\nAfter Snuke finishes walking, Ringo will repeat the following operations in some order so that, for each i, Snuke's i-th ear contains A_i stones:\n\nPut a stone in one of Snuke's ears.\n\nRemove a stone from one of Snuke's ears.\n\nFind the minimum number of operations required when Ringo can freely decide how Snuke walks.\n\nConstraints\n\n1 \\leq L \\leq 2\\times 10^5\n\n0 \\leq A_i \\leq 10^9(1\\leq i\\leq L)\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nL\nA_1\n:\nA_L\n\nOutput\n\nPrint the minimum number of operations required when Ringo can freely decide how Snuke walks.\n\nSample Input 1\n\n4\n1\n0\n2\n3\n\nSample Output 1\n\n1\n\nAssume that Snuke walks as follows:\n\nHe starts walking at coordinate 3 and finishes walking at coordinate 4, visiting coordinates 3,4,3,2,3,4 in this order.\n\nThen, Snuke's four ears will contain 0,0,2,3 stones, respectively.\nRingo can satisfy the requirement by putting one stone in the first ear.\n\nSample Input 2\n\n8\n2\n0\n0\n2\n1\n3\n4\n1\n\nSample Output 2\n\n3\n\nSample Input 3\n\n7\n314159265\n358979323\n846264338\n327950288\n419716939\n937510582\n0\n\nSample Output 3\n\n1", "sample_input": "4\n1\n0\n2\n3\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03132", "source_text": "Score : 600 points\n\nProblem Statement\n\nSnuke stands on a number line. He has L ears, and he will walk along the line continuously under the following conditions:\n\nHe never visits a point with coordinate less than 0, or a point with coordinate greater than L.\n\nHe starts walking at a point with integer coordinate, and also finishes walking at a point with integer coordinate.\n\nHe only changes direction at a point with integer coordinate.\n\nEach time when Snuke passes a point with coordinate i-0.5, where i is an integer, he put a stone in his i-th ear.\n\nAfter Snuke finishes walking, Ringo will repeat the following operations in some order so that, for each i, Snuke's i-th ear contains A_i stones:\n\nPut a stone in one of Snuke's ears.\n\nRemove a stone from one of Snuke's ears.\n\nFind the minimum number of operations required when Ringo can freely decide how Snuke walks.\n\nConstraints\n\n1 \\leq L \\leq 2\\times 10^5\n\n0 \\leq A_i \\leq 10^9(1\\leq i\\leq L)\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nL\nA_1\n:\nA_L\n\nOutput\n\nPrint the minimum number of operations required when Ringo can freely decide how Snuke walks.\n\nSample Input 1\n\n4\n1\n0\n2\n3\n\nSample Output 1\n\n1\n\nAssume that Snuke walks as follows:\n\nHe starts walking at coordinate 3 and finishes walking at coordinate 4, visiting coordinates 3,4,3,2,3,4 in this order.\n\nThen, Snuke's four ears will contain 0,0,2,3 stones, respectively.\nRingo can satisfy the requirement by putting one stone in the first ear.\n\nSample Input 2\n\n8\n2\n0\n0\n2\n1\n3\n4\n1\n\nSample Output 2\n\n3\n\nSample Input 3\n\n7\n314159265\n358979323\n846264338\n327950288\n419716939\n937510582\n0\n\nSample Output 3\n\n1", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 525, "cpu_time_ms": 72, "memory_kb": 6144}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s830917352", "group_id": "codeNet:p03135", "input_text": "Scanf.scanf \"%f %f\" (/.) |> Printf.printf \"%f\\n\"", "language": "OCaml", "metadata": {"date": 1558194621, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03135.html", "problem_id": "p03135", "resource_group": "low_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/OCaml/s830917352.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s830917352", "user_id": "u732304692"}, "prompt_components": {"gold_output": "2.6666666667\n", "input_to_evaluate": "Scanf.scanf \"%f %f\" (/.) |> Printf.printf \"%f\\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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 2432}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s830117963", "group_id": "codeNet:p03135", "input_text": "let _ = Scanf.scanf \"%f %f\" @@ fun t x ->\n t /. x |> Printf.printf \"%.10f\\n\"", "language": "OCaml", "metadata": {"date": 1558191521, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03135.html", "problem_id": "p03135", "resource_group": "low_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/OCaml/s830117963.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s830117963", "user_id": "u732304692"}, "prompt_components": {"gold_output": "2.6666666667\n", "input_to_evaluate": "let _ = Scanf.scanf \"%f %f\" @@ fun t x ->\n t /. x |> Printf.printf \"%.10f\\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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s875634029", "group_id": "codeNet:p03136", "input_text": "let rec f maxN others lst =\n match lst with\n | [] -> (maxN, others)\n | x :: xs ->\n if x > maxN then f x (maxN :: others) xs\n else f maxN (x :: others) xs\nlet rec sum lst = match lst with\n | [] -> 0\n | x :: xs -> x + sum xs\nlet () = Scanf.scanf \"%d\\n\"\n (fun n -> Array.init n (fun _ -> Scanf.scanf \" %d\" (fun x -> x)))\n |> Array.to_list\n |> f 0 []\n |> (fun (maxN, otherlst) -> if maxN < sum otherlst then \"Yes\" else \"No\")\n |> print_string", "language": "OCaml", "metadata": {"date": 1554562306, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03136.html", "problem_id": "p03136", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03136/input.txt", "sample_output_relpath": "derived/input_output/data/p03136/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03136/OCaml/s875634029.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s875634029", "user_id": "u307426615"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "let rec f maxN others lst =\n match lst with\n | [] -> (maxN, others)\n | x :: xs ->\n if x > maxN then f x (maxN :: others) xs\n else f maxN (x :: others) xs\nlet rec sum lst = match lst with\n | [] -> 0\n | x :: xs -> x + sum xs\nlet () = Scanf.scanf \"%d\\n\"\n (fun n -> Array.init n (fun _ -> Scanf.scanf \" %d\" (fun x -> x)))\n |> Array.to_list\n |> f 0 []\n |> (fun (maxN, otherlst) -> if maxN < sum otherlst then \"Yes\" else \"No\")\n |> print_string", "problem_context": "Score : 200 points\n\nProblem Statement\n\nDetermine if an N-sided polygon (not necessarily convex) with sides of length L_1, L_2, ..., L_N can be drawn in a two-dimensional plane.\n\nYou can use the following theorem:\n\nTheorem: an N-sided polygon satisfying the condition can be drawn if and only if the longest side is strictly shorter than the sum of the lengths of the other N-1 sides.\n\nConstraints\n\nAll values in input are integers.\n\n3 \\leq N \\leq 10\n\n1 \\leq L_i \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nL_1 L_2 ... L_N\n\nOutput\n\nIf an N-sided polygon satisfying the condition can be drawn, print Yes; otherwise, print No.\n\nSample Input 1\n\n4\n3 8 5 1\n\nSample Output 1\n\nYes\n\nSince 8 < 9 = 3 + 5 + 1, it follows from the theorem that such a polygon can be drawn on a plane.\n\nSample Input 2\n\n4\n3 8 4 1\n\nSample Output 2\n\nNo\n\nSince 8 \\geq 8 = 3 + 4 + 1, it follows from the theorem that such a polygon cannot be drawn on a plane.\n\nSample Input 3\n\n10\n1 8 10 5 8 12 34 100 11 3\n\nSample Output 3\n\nNo", "sample_input": "4\n3 8 5 1\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03136", "source_text": "Score : 200 points\n\nProblem Statement\n\nDetermine if an N-sided polygon (not necessarily convex) with sides of length L_1, L_2, ..., L_N can be drawn in a two-dimensional plane.\n\nYou can use the following theorem:\n\nTheorem: an N-sided polygon satisfying the condition can be drawn if and only if the longest side is strictly shorter than the sum of the lengths of the other N-1 sides.\n\nConstraints\n\nAll values in input are integers.\n\n3 \\leq N \\leq 10\n\n1 \\leq L_i \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nL_1 L_2 ... L_N\n\nOutput\n\nIf an N-sided polygon satisfying the condition can be drawn, print Yes; otherwise, print No.\n\nSample Input 1\n\n4\n3 8 5 1\n\nSample Output 1\n\nYes\n\nSince 8 < 9 = 3 + 5 + 1, it follows from the theorem that such a polygon can be drawn on a plane.\n\nSample Input 2\n\n4\n3 8 4 1\n\nSample Output 2\n\nNo\n\nSince 8 \\geq 8 = 3 + 4 + 1, it follows from the theorem that such a polygon cannot be drawn on a plane.\n\nSample Input 3\n\n10\n1 8 10 5 8 12 34 100 11 3\n\nSample Output 3\n\nNo", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s876042715", "group_id": "codeNet:p03137", "input_text": "let n, m = Scanf.scanf \" %d %d\" @@ fun a b -> a, b\nlet xs = Array.init m @@ fun _ -> Scanf.scanf \" %d\" (+) 0\nlet ds = if n >= m then (print_endline \"0\"; exit 0); Array.(sort (-) xs; init (m - 1) @@ fun i -> xs.(i + 1) - xs.(i))\nlet _ = Array.(sort (fun x y -> y - x) ds; sub ds 0 @@ n - 1 |> fold_left (+) 0 |> (-) @@ xs.(m - 1) - xs.(0) |> Printf.printf \"%d\\n\")", "language": "OCaml", "metadata": {"date": 1566683677, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03137.html", "problem_id": "p03137", "resource_group": "low_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/OCaml/s876042715.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s876042715", "user_id": "u732304692"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "let n, m = Scanf.scanf \" %d %d\" @@ fun a b -> a, b\nlet xs = Array.init m @@ fun _ -> Scanf.scanf \" %d\" (+) 0\nlet ds = if n >= m then (print_endline \"0\"; exit 0); Array.(sort (-) xs; init (m - 1) @@ fun i -> xs.(i + 1) - xs.(i))\nlet _ = Array.(sort (fun x y -> y - x) ds; sub ds 0 @@ n - 1 |> fold_left (+) 0 |> (-) @@ xs.(m - 1) - xs.(0) |> Printf.printf \"%d\\n\")", "problem_context": "Score : 300 points\n\nProblem Statement\n\nWe will play a one-player game using a number line and N pieces.\n\nFirst, we place each of these pieces at some integer coordinate.\n\nHere, multiple pieces can be placed at the same coordinate.\n\nOur objective is to visit all of the M coordinates X_1, X_2, ..., X_M with these pieces, by repeating the following move:\n\nMove: Choose a piece and let x be its coordinate. Put that piece at coordinate x+1 or x-1.\n\nNote that the coordinates where we initially place the pieces are already regarded as visited.\n\nFind the minimum number of moves required to achieve the objective.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n-10^5 \\leq X_i \\leq 10^5\n\nX_1, X_2, ..., X_M are all different.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nX_1 X_2 ... X_M\n\nOutput\n\nFind the minimum number of moves required to achieve the objective.\n\nSample Input 1\n\n2 5\n10 12 1 2 14\n\nSample Output 1\n\n5\n\nThe objective can be achieved in five moves as follows, and this is the minimum number of moves required.\n\nInitially, put the two pieces at coordinates 1 and 10.\n\nMove the piece at coordinate 1 to 2.\n\nMove the piece at coordinate 10 to 11.\n\nMove the piece at coordinate 11 to 12.\n\nMove the piece at coordinate 12 to 13.\n\nMove the piece at coordinate 13 to 14.\n\nSample Input 2\n\n3 7\n-10 -3 0 9 -100 2 17\n\nSample Output 2\n\n19\n\nSample Input 3\n\n100 1\n-100000\n\nSample Output 3\n\n0", "sample_input": "2 5\n10 12 1 2 14\n"}, "reference_outputs": ["5\n"], "source_document_id": "p03137", "source_text": "Score : 300 points\n\nProblem Statement\n\nWe will play a one-player game using a number line and N pieces.\n\nFirst, we place each of these pieces at some integer coordinate.\n\nHere, multiple pieces can be placed at the same coordinate.\n\nOur objective is to visit all of the M coordinates X_1, X_2, ..., X_M with these pieces, by repeating the following move:\n\nMove: Choose a piece and let x be its coordinate. Put that piece at coordinate x+1 or x-1.\n\nNote that the coordinates where we initially place the pieces are already regarded as visited.\n\nFind the minimum number of moves required to achieve the objective.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n-10^5 \\leq X_i \\leq 10^5\n\nX_1, X_2, ..., X_M are all different.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nX_1 X_2 ... X_M\n\nOutput\n\nFind the minimum number of moves required to achieve the objective.\n\nSample Input 1\n\n2 5\n10 12 1 2 14\n\nSample Output 1\n\n5\n\nThe objective can be achieved in five moves as follows, and this is the minimum number of moves required.\n\nInitially, put the two pieces at coordinates 1 and 10.\n\nMove the piece at coordinate 1 to 2.\n\nMove the piece at coordinate 10 to 11.\n\nMove the piece at coordinate 11 to 12.\n\nMove the piece at coordinate 12 to 13.\n\nMove the piece at coordinate 13 to 14.\n\nSample Input 2\n\n3 7\n-10 -3 0 9 -100 2 17\n\nSample Output 2\n\n19\n\nSample Input 3\n\n100 1\n-100000\n\nSample Output 3\n\n0", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 88, "memory_kb": 5120}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s978595778", "group_id": "codeNet:p03137", "input_text": "let rec sum_k acc k ls =\n match k, ls with\n | 0, _ -> acc\n | _, [] -> acc\n | k, l::ls -> sum_k (l + acc) (k - 1) ls\n\nlet right (_, r) = r\n\nlet _ =\n let n, m = Scanf.scanf \"%d %d\\n\" (fun n m -> n, m) in\n let xs = ref [] in\n let max_m, min_m = ref min_int, ref max_int in\n for i = 0 to m - 1 do\n Scanf.scanf (if i <> m - 1 then \"%d \" else \"%d\\n\") (fun x -> xs := x::!xs);\n max_m := max !max_m (List.hd !xs);\n min_m := min !min_m (List.hd !xs)\n done;\n !xs\n |> List.sort compare\n |> (fun xs -> List.fold_left (fun (prev, acc) x -> (x, (x - prev)::acc)) \n (List.hd xs, []) @@ List.tl xs)\n |> right\n |> List.sort (fun x y -> 1 - (compare x y))\n |> sum_k 0 (n - 1)\n |> (fun ls -> (!max_m - !min_m) - ls)\n |> print_int", "language": "OCaml", "metadata": {"date": 1553270111, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03137.html", "problem_id": "p03137", "resource_group": "low_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/OCaml/s978595778.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s978595778", "user_id": "u387591304"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "let rec sum_k acc k ls =\n match k, ls with\n | 0, _ -> acc\n | _, [] -> acc\n | k, l::ls -> sum_k (l + acc) (k - 1) ls\n\nlet right (_, r) = r\n\nlet _ =\n let n, m = Scanf.scanf \"%d %d\\n\" (fun n m -> n, m) in\n let xs = ref [] in\n let max_m, min_m = ref min_int, ref max_int in\n for i = 0 to m - 1 do\n Scanf.scanf (if i <> m - 1 then \"%d \" else \"%d\\n\") (fun x -> xs := x::!xs);\n max_m := max !max_m (List.hd !xs);\n min_m := min !min_m (List.hd !xs)\n done;\n !xs\n |> List.sort compare\n |> (fun xs -> List.fold_left (fun (prev, acc) x -> (x, (x - prev)::acc)) \n (List.hd xs, []) @@ List.tl xs)\n |> right\n |> List.sort (fun x y -> 1 - (compare x y))\n |> sum_k 0 (n - 1)\n |> (fun ls -> (!max_m - !min_m) - ls)\n |> print_int", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 753, "cpu_time_ms": 123, "memory_kb": 10784}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s177315735", "group_id": "codeNet:p03139", "input_text": "Scanf.scanf \" %d %d %d\" @@ fun n a b ->\n Printf.printf \"%d %d\" (max (a+b-n) 0) (min a b)", "language": "OCaml", "metadata": {"date": 1548668784, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03139.html", "problem_id": "p03139", "resource_group": "low_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/OCaml/s177315735.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s177315735", "user_id": "u481480055"}, "prompt_components": {"gold_output": "3 0\n", "input_to_evaluate": "Scanf.scanf \" %d %d %d\" @@ fun n a b ->\n Printf.printf \"%d %d\" (max (a+b-n) 0) (min a b)", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s176061259", "group_id": "codeNet:p03141", "input_text": "let rv f p q = f q p;;\nScanf.(Array.(scanf \" %d\" @@ fun n ->\n let a,b = make n 0,make n 0 in\n init n (fun i -> scanf \" %d %d\" @@ fun u v -> a.(i) <- u; b.(i) <- v);\n let c = init n (fun i -> a.(i)+b.(i),i) in\n sort (rv compare) c;\n print_int @@ fst @@\n fold_left (fun (sum,j) (_,i) ->\n (sum + if j mod 2 = 0 then a.(i) else -b.(i)),j+1\n ) (0,0) c))", "language": "OCaml", "metadata": {"date": 1548668804, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03141.html", "problem_id": "p03141", "resource_group": "low_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/OCaml/s176061259.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s176061259", "user_id": "u481480055"}, "prompt_components": {"gold_output": "20\n", "input_to_evaluate": "let rv f p q = f q p;;\nScanf.(Array.(scanf \" %d\" @@ fun n ->\n let a,b = make n 0,make n 0 in\n init n (fun i -> scanf \" %d %d\" @@ fun u v -> a.(i) <- u; b.(i) <- v);\n let c = init n (fun i -> a.(i)+b.(i),i) in\n sort (rv compare) c;\n print_int @@ fst @@\n fold_left (fun (sum,j) (_,i) ->\n (sum + if j mod 2 = 0 then a.(i) else -b.(i)),j+1\n ) (0,0) c))", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 177, "memory_kb": 8960}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s941635201", "group_id": "codeNet:p03142", "input_text": "Scanf.scanf \"%d %d\" (fun n m ->\n let nei = Array.make n [] in\n let rev = Array.make n 0 in\n for i = 1 to n - 1 + m do\n Scanf.scanf \" %d %d\" (fun a b ->\n let a = a - 1 in\n let b = b - 1 in\n nei.(a) <- b :: nei.(a);\n rev.(b) <- rev.(b) + 1\n )\n done;\n let rec loop i =\n if rev.(i) = 0 then i else loop (i + 1)\n in\n let root = loop 0 in\n let par = Array.make n 0 in\n\n let rec loop next = function\n | [] -> if next <> [] then loop [] next\n | hd :: tl ->\n let rec loop2 next = function\n | [] -> loop next tl\n | x :: xs ->\n par.(x) <- hd + 1; loop2 (x :: next) xs\n in\n loop2 next nei.(hd)\n in\n loop [] [ root ];\n Array.iter (Printf.printf \"%d\\n\") par\n)", "language": "OCaml", "metadata": {"date": 1592027544, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03142.html", "problem_id": "p03142", "resource_group": "low_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/OCaml/s941635201.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s941635201", "user_id": "u342443598"}, "prompt_components": {"gold_output": "0\n1\n2\n", "input_to_evaluate": "Scanf.scanf \"%d %d\" (fun n m ->\n let nei = Array.make n [] in\n let rev = Array.make n 0 in\n for i = 1 to n - 1 + m do\n Scanf.scanf \" %d %d\" (fun a b ->\n let a = a - 1 in\n let b = b - 1 in\n nei.(a) <- b :: nei.(a);\n rev.(b) <- rev.(b) + 1\n )\n done;\n let rec loop i =\n if rev.(i) = 0 then i else loop (i + 1)\n in\n let root = loop 0 in\n let par = Array.make n 0 in\n\n let rec loop next = function\n | [] -> if next <> [] then loop [] next\n | hd :: tl ->\n let rec loop2 next = function\n | [] -> loop next tl\n | x :: xs ->\n par.(x) <- hd + 1; loop2 (x :: next) xs\n in\n loop2 next nei.(hd)\n in\n loop [] [ root ];\n Array.iter (Printf.printf \"%d\\n\") par\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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 2110, "memory_kb": 709612}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s837852362", "group_id": "codeNet:p03142", "input_text": "let rec fix f x = f (fix f) x;;\nScanf.(Array.(scanf \" %d %d\" @@ fun n m ->\n let e = make n [] in\n let e_rev = make n [] in\n init (n-1+m) (fun i -> scanf \" %d %d\" @@ fun u v ->\n let u,v = u-1,v-1 in\n e.(u) <- v :: e.(u);\n e_rev.(v) <- u :: e_rev.(v)\n ) |> ignore;\n let root = fst @@ fold_left (fun (root,i) ls ->\n (if List.length ls = 0 then i else root),i+1\n ) (0,0) e_rev in\n let dep = make n 0 in\n fix (fun f i d ->\n dep.(i) <- max dep.(i) d;\n List.iter (fun j ->\n f j (d+1)\n ) e.(i)\n ) root 0;\n (* iteri (fun i d -> Printf.printf \"%d: %d\\n\" i d) dep; *)\n let res = make n 0 in\n fix (fun f i d ->\n List.iter (fun j ->\n if dep.(j) = d+1 then res.(j) <- i + 1;\n f j (d+1)\n ) e.(i)\n ) root 0;\n res.(root) <- 0;\n iter (fun d -> Printf.printf \"%d\\n\" d) res;\n))", "language": "OCaml", "metadata": {"date": 1548670256, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03142.html", "problem_id": "p03142", "resource_group": "low_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/OCaml/s837852362.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s837852362", "user_id": "u481480055"}, "prompt_components": {"gold_output": "0\n1\n2\n", "input_to_evaluate": "let rec fix f x = f (fix f) x;;\nScanf.(Array.(scanf \" %d %d\" @@ fun n m ->\n let e = make n [] in\n let e_rev = make n [] in\n init (n-1+m) (fun i -> scanf \" %d %d\" @@ fun u v ->\n let u,v = u-1,v-1 in\n e.(u) <- v :: e.(u);\n e_rev.(v) <- u :: e_rev.(v)\n ) |> ignore;\n let root = fst @@ fold_left (fun (root,i) ls ->\n (if List.length ls = 0 then i else root),i+1\n ) (0,0) e_rev in\n let dep = make n 0 in\n fix (fun f i d ->\n dep.(i) <- max dep.(i) d;\n List.iter (fun j ->\n f j (d+1)\n ) e.(i)\n ) root 0;\n (* iteri (fun i d -> Printf.printf \"%d: %d\\n\" i d) dep; *)\n let res = make n 0 in\n fix (fun f i d ->\n List.iter (fun j ->\n if dep.(j) = d+1 then res.(j) <- i + 1;\n f j (d+1)\n ) e.(i)\n ) root 0;\n res.(root) <- 0;\n iter (fun d -> Printf.printf \"%d\\n\" d) res;\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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 814, "cpu_time_ms": 2104, "memory_kb": 29184}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s266276295", "group_id": "codeNet:p03145", "input_text": "open Printf\nopen Scanf\n\nlet solve a b = a * b / 2\n\nlet () =\n scanf \"%d %d \" solve |> printf \"%d\\n\"\n", "language": "OCaml", "metadata": {"date": 1582060633, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03145.html", "problem_id": "p03145", "resource_group": "low_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/OCaml/s266276295.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s266276295", "user_id": "u388783188"}, "prompt_components": {"gold_output": "6\n", "input_to_evaluate": "open Printf\nopen Scanf\n\nlet solve a b = a * b / 2\n\nlet () =\n scanf \"%d %d \" solve |> printf \"%d\\n\"\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nThere is a right triangle ABC with ∠ABC=90°.\n\nGiven the lengths of the three sides, |AB|,|BC| and |CA|, find the area of the right triangle ABC.\n\nIt is guaranteed that the area of the triangle ABC is an integer.\n\nConstraints\n\n1 \\leq |AB|,|BC|,|CA| \\leq 100\n\nAll values in input are integers.\n\nThe area of the triangle ABC is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\n|AB| |BC| |CA|\n\nOutput\n\nPrint the area of the triangle ABC.\n\nSample Input 1\n\n3 4 5\n\nSample Output 1\n\n6\n\nThis triangle has an area of 6.\n\nSample Input 2\n\n5 12 13\n\nSample Output 2\n\n30\n\nThis triangle has an area of 30.\n\nSample Input 3\n\n45 28 53\n\nSample Output 3\n\n630\n\nThis triangle has an area of 630.", "sample_input": "3 4 5\n"}, "reference_outputs": ["6\n"], "source_document_id": "p03145", "source_text": "Score : 100 points\n\nProblem Statement\n\nThere is a right triangle ABC with ∠ABC=90°.\n\nGiven the lengths of the three sides, |AB|,|BC| and |CA|, find the area of the right triangle ABC.\n\nIt is guaranteed that the area of the triangle ABC is an integer.\n\nConstraints\n\n1 \\leq |AB|,|BC|,|CA| \\leq 100\n\nAll values in input are integers.\n\nThe area of the triangle ABC is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\n|AB| |BC| |CA|\n\nOutput\n\nPrint the area of the triangle ABC.\n\nSample Input 1\n\n3 4 5\n\nSample Output 1\n\n6\n\nThis triangle has an area of 6.\n\nSample Input 2\n\n5 12 13\n\nSample Output 2\n\n30\n\nThis triangle has an area of 30.\n\nSample Input 3\n\n45 28 53\n\nSample Output 3\n\n630\n\nThis triangle has an area of 630.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s353973609", "group_id": "codeNet:p03145", "input_text": "let () = Scanf.scanf \"%d %d %d\" @@ fun ab bc _ ->\n Printf.printf \"%d\" (ab * bc / 2)", "language": "OCaml", "metadata": {"date": 1548037558, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03145.html", "problem_id": "p03145", "resource_group": "low_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/OCaml/s353973609.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s353973609", "user_id": "u604818425"}, "prompt_components": {"gold_output": "6\n", "input_to_evaluate": "let () = Scanf.scanf \"%d %d %d\" @@ fun ab bc _ ->\n Printf.printf \"%d\" (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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s797827085", "group_id": "codeNet:p03146", "input_text": "module IntSet = Set.Make (struct type t = int let compare = (-) end)\nlet _ =\n let s = read_int () in\n let rec find i set n =\n if IntSet.mem n set then\n i\n else\n find (i + 1) (IntSet.add n set) @@ if n mod 2 = 0 then n / 2 else 3 * n + 1\n in\n find 1 IntSet.empty s |> Printf.printf \"%d\\n\"", "language": "OCaml", "metadata": {"date": 1558203121, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03146.html", "problem_id": "p03146", "resource_group": "low_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/OCaml/s797827085.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s797827085", "user_id": "u732304692"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "module IntSet = Set.Make (struct type t = int let compare = (-) end)\nlet _ =\n let s = read_int () in\n let rec find i set n =\n if IntSet.mem n set then\n i\n else\n find (i + 1) (IntSet.add n set) @@ if n mod 2 = 0 then n / 2 else 3 * n + 1\n in\n find 1 IntSet.empty s |> Printf.printf \"%d\\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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s221394508", "group_id": "codeNet:p03147", "input_text": "let rec f hs =\n let (_, l) = Array.fold_left (fun (st, cnt) h ->\n h > 0, if h > 0 && not st then cnt + 1 else cnt)\n (false, 0)\n hs in\n if l > 0\n then l + f (Array.map (fun n -> n - 1) hs)\n else l\n\nlet id x = x\n\nlet () = Scanf.scanf \"%d\\n\" @@ fun n ->\n Array.init n (fun _ -> Scanf.scanf \" %d\" id)\n |> f |> Printf.printf \"%d\\n\"\n", "language": "OCaml", "metadata": {"date": 1548017648, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03147.html", "problem_id": "p03147", "resource_group": "low_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/OCaml/s221394508.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s221394508", "user_id": "u604818425"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "let rec f hs =\n let (_, l) = Array.fold_left (fun (st, cnt) h ->\n h > 0, if h > 0 && not st then cnt + 1 else cnt)\n (false, 0)\n hs in\n if l > 0\n then l + f (Array.map (fun n -> n - 1) hs)\n else l\n\nlet id x = x\n\nlet () = Scanf.scanf \"%d\\n\" @@ fun n ->\n Array.init n (fun _ -> Scanf.scanf \" %d\" id)\n |> f |> Printf.printf \"%d\\n\"\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nIn a flower bed, there are N flowers, numbered 1,2,......,N. Initially, the heights of all flowers are 0.\nYou are given a sequence h=\\{h_1,h_2,h_3,......\\} as input. You would like to change the height of Flower k to h_k for all k (1 \\leq k \\leq N), by repeating the following \"watering\" operation:\n\nSpecify integers l and r. Increase the height of Flower x by 1 for all x such that l \\leq x \\leq r.\n\nFind the minimum number of watering operations required to satisfy the condition.\n\nConstraints\n\n1 \\leq N \\leq 100\n\n0 \\leq h_i \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nh_1 h_2 h_3 ...... h_N\n\nOutput\n\nPrint the minimum number of watering operations required to satisfy the condition.\n\nSample Input 1\n\n4\n1 2 2 1\n\nSample Output 1\n\n2\n\nThe minimum number of watering operations required is 2.\nOne way to achieve it is:\n\nPerform the operation with (l,r)=(1,3).\n\nPerform the operation with (l,r)=(2,4).\n\nSample Input 2\n\n5\n3 1 2 3 1\n\nSample Output 2\n\n5\n\nSample Input 3\n\n8\n4 23 75 0 23 96 50 100\n\nSample Output 3\n\n221", "sample_input": "4\n1 2 2 1\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03147", "source_text": "Score : 300 points\n\nProblem Statement\n\nIn a flower bed, there are N flowers, numbered 1,2,......,N. Initially, the heights of all flowers are 0.\nYou are given a sequence h=\\{h_1,h_2,h_3,......\\} as input. You would like to change the height of Flower k to h_k for all k (1 \\leq k \\leq N), by repeating the following \"watering\" operation:\n\nSpecify integers l and r. Increase the height of Flower x by 1 for all x such that l \\leq x \\leq r.\n\nFind the minimum number of watering operations required to satisfy the condition.\n\nConstraints\n\n1 \\leq N \\leq 100\n\n0 \\leq h_i \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nh_1 h_2 h_3 ...... h_N\n\nOutput\n\nPrint the minimum number of watering operations required to satisfy the condition.\n\nSample Input 1\n\n4\n1 2 2 1\n\nSample Output 1\n\n2\n\nThe minimum number of watering operations required is 2.\nOne way to achieve it is:\n\nPerform the operation with (l,r)=(1,3).\n\nPerform the operation with (l,r)=(2,4).\n\nSample Input 2\n\n5\n3 1 2 3 1\n\nSample Output 2\n\n5\n\nSample Input 3\n\n8\n4 23 75 0 23 96 50 100\n\nSample Output 3\n\n221", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 2560}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s976807189", "group_id": "codeNet:p03148", "input_text": "let rv f p q = f q p\nmodule MultiSet_test = struct\n module Make (X:Map.OrderedType) = struct\n include Map.Make(X)\n let count v set =\n try find v set with Not_found -> 0\n let remove_each v set =\n let k = count v set in\n if k<=0 then raise Not_found\n else if k=1 then remove v set\n else add v (k-1) set\n let add_each v set =\n let k = count v set in\n if k=0 then add v 1 set\n else add v (k+1) set\n let iter_each f set =\n let rec f0 k = function\n | 0 -> ()\n | i -> let () = f k in f0 k (i-1)\n in iter f0 set\n let fold_each f set ac =\n let rec f0 k i ac = match i with\n | 0 -> ac\n | i -> f0 k (i-1) (f k ac)\n in fold f0 set ac\n let bindings_each set =\n fold_each (fun v ls -> v::ls) set []\n |> List.rev\n let min_binding_each set = fst @@ min_binding set\n let max_binding_each set = fst @@ max_binding set\n let exists_each f = exists (fun k _ -> f k)\n let cardinal_each set = (* slow *)\n fold (fun _ v sum -> sum + v) set 0\n end\nend\nmodule IRSet = MultiSet_test.Make (struct type t = int let compare = rv compare end);;\nScanf.(Array.(scanf \" %d %d\" @@ fun n k ->\n let t,d = make n 0,make n 0 in\n let repr = make n 0 in\n init n (fun i -> scanf \" %d %d\" @@ fun u v ->\n t.(i) <- u-1; d.(i) <- v;\n repr.(t.(i)) <- max v repr.(t.(i))\n ) |> ignore;\n let rest = init n (fun _ -> IRSet.empty) in\n init n (fun i ->\n (* if repr.(t.(i)) <> d.(i) then *)\n rest.(t.(i)) <- IRSet.add_each d.(i) rest.(t.(i))\n ) |> ignore;\n iteri (fun i v ->\n if v>0 then rest.(i) <- IRSet.remove_each v rest.(i)\n ) repr;\n (* iteri (fun i set ->\n Printf.printf \"%d: \" @@ i+1; IRSet.iter_each (Printf.printf \"%2d \") set;\n print_newline ()\n ) rest; *)\n let repr = to_list repr |> List.filter ((<>) 0)\n |> List.mapi (fun i v -> v,t.(i))\n |> List.sort (rv compare)\n in\n (* List.iter (fun (v,i) -> Printf.printf \"%d:%d; \" v @@ i+1) repr; print_newline (); *)\n let _,_,_,res,_ = init n (fun w -> w+1)\n |> fold_left (fun ((best,sum_best,repr,res,car_best) as u) w -> match repr with\n | [] -> u\n | (v,i)::t -> (\n let best = IRSet.merge (fun i p q -> match p,q with\n | Some p,Some q -> Some (p+q)\n | Some p,_ | _,Some p -> Some p\n | None,None -> None\n ) best rest.(i) in\n let car_best = car_best + IRSet.cardinal_each rest.(i) in\n (* Printf.printf \"%d :: \" (k-w);\n IRSet.iter_each (Printf.printf \"%d \") best; print_newline (); *)\n if k - w < 0 || car_best < k - w then (\n (best,sum_best+v,t,res,car_best)\n ) else\n let best,sum = init (k-w) (fun i -> i)\n |> fold_left (fun (set,sum) _ ->\n let v = IRSet.max_binding_each set in\n (* (IRSet.remove v set,sum) *)\n (set,sum+v)\n ) (best,0)\n in\n (* Printf.printf \" %6d v. %6d :: %2d + %2d + %2d\\n\" res (w*w + sum + sum_best + v) (w*w) sum (sum_best + v); *)\n (best,sum_best+v,t,max res (w*w + sum + sum_best + v),car_best)\n )\n ) (IRSet.empty,0,repr,0,0) in\n print_int res\n));;\n", "language": "OCaml", "metadata": {"date": 1549261824, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03148.html", "problem_id": "p03148", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03148/input.txt", "sample_output_relpath": "derived/input_output/data/p03148/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03148/OCaml/s976807189.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s976807189", "user_id": "u481480055"}, "prompt_components": {"gold_output": "26\n", "input_to_evaluate": "let rv f p q = f q p\nmodule MultiSet_test = struct\n module Make (X:Map.OrderedType) = struct\n include Map.Make(X)\n let count v set =\n try find v set with Not_found -> 0\n let remove_each v set =\n let k = count v set in\n if k<=0 then raise Not_found\n else if k=1 then remove v set\n else add v (k-1) set\n let add_each v set =\n let k = count v set in\n if k=0 then add v 1 set\n else add v (k+1) set\n let iter_each f set =\n let rec f0 k = function\n | 0 -> ()\n | i -> let () = f k in f0 k (i-1)\n in iter f0 set\n let fold_each f set ac =\n let rec f0 k i ac = match i with\n | 0 -> ac\n | i -> f0 k (i-1) (f k ac)\n in fold f0 set ac\n let bindings_each set =\n fold_each (fun v ls -> v::ls) set []\n |> List.rev\n let min_binding_each set = fst @@ min_binding set\n let max_binding_each set = fst @@ max_binding set\n let exists_each f = exists (fun k _ -> f k)\n let cardinal_each set = (* slow *)\n fold (fun _ v sum -> sum + v) set 0\n end\nend\nmodule IRSet = MultiSet_test.Make (struct type t = int let compare = rv compare end);;\nScanf.(Array.(scanf \" %d %d\" @@ fun n k ->\n let t,d = make n 0,make n 0 in\n let repr = make n 0 in\n init n (fun i -> scanf \" %d %d\" @@ fun u v ->\n t.(i) <- u-1; d.(i) <- v;\n repr.(t.(i)) <- max v repr.(t.(i))\n ) |> ignore;\n let rest = init n (fun _ -> IRSet.empty) in\n init n (fun i ->\n (* if repr.(t.(i)) <> d.(i) then *)\n rest.(t.(i)) <- IRSet.add_each d.(i) rest.(t.(i))\n ) |> ignore;\n iteri (fun i v ->\n if v>0 then rest.(i) <- IRSet.remove_each v rest.(i)\n ) repr;\n (* iteri (fun i set ->\n Printf.printf \"%d: \" @@ i+1; IRSet.iter_each (Printf.printf \"%2d \") set;\n print_newline ()\n ) rest; *)\n let repr = to_list repr |> List.filter ((<>) 0)\n |> List.mapi (fun i v -> v,t.(i))\n |> List.sort (rv compare)\n in\n (* List.iter (fun (v,i) -> Printf.printf \"%d:%d; \" v @@ i+1) repr; print_newline (); *)\n let _,_,_,res,_ = init n (fun w -> w+1)\n |> fold_left (fun ((best,sum_best,repr,res,car_best) as u) w -> match repr with\n | [] -> u\n | (v,i)::t -> (\n let best = IRSet.merge (fun i p q -> match p,q with\n | Some p,Some q -> Some (p+q)\n | Some p,_ | _,Some p -> Some p\n | None,None -> None\n ) best rest.(i) in\n let car_best = car_best + IRSet.cardinal_each rest.(i) in\n (* Printf.printf \"%d :: \" (k-w);\n IRSet.iter_each (Printf.printf \"%d \") best; print_newline (); *)\n if k - w < 0 || car_best < k - w then (\n (best,sum_best+v,t,res,car_best)\n ) else\n let best,sum = init (k-w) (fun i -> i)\n |> fold_left (fun (set,sum) _ ->\n let v = IRSet.max_binding_each set in\n (* (IRSet.remove v set,sum) *)\n (set,sum+v)\n ) (best,0)\n in\n (* Printf.printf \" %6d v. %6d :: %2d + %2d + %2d\\n\" res (w*w + sum + sum_best + v) (w*w) sum (sum_best + v); *)\n (best,sum_best+v,t,max res (w*w + sum + sum_best + v),car_best)\n )\n ) (IRSet.empty,0,repr,0,0) in\n print_int res\n));;\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nThere are N pieces of sushi. Each piece has two parameters: \"kind of topping\" t_i and \"deliciousness\" d_i.\nYou are choosing K among these N pieces to eat.\nYour \"satisfaction\" here will be calculated as follows:\n\nThe satisfaction is the sum of the \"base total deliciousness\" and the \"variety bonus\".\n\nThe base total deliciousness is the sum of the deliciousness of the pieces you eat.\n\nThe variety bonus is x*x, where x is the number of different kinds of toppings of the pieces you eat.\n\nYou want to have as much satisfaction as possible.\nFind this maximum satisfaction.\n\nConstraints\n\n1 \\leq K \\leq N \\leq 10^5\n\n1 \\leq t_i \\leq N\n\n1 \\leq d_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nt_1 d_1\nt_2 d_2\n.\n.\n.\nt_N d_N\n\nOutput\n\nPrint the maximum satisfaction that you can obtain.\n\nSample Input 1\n\n5 3\n1 9\n1 7\n2 6\n2 5\n3 1\n\nSample Output 1\n\n26\n\nIf you eat Sushi 1,2 and 3:\n\nThe base total deliciousness is 9+7+6=22.\n\nThe variety bonus is 2*2=4.\n\nThus, your satisfaction will be 26, which is optimal.\n\nSample Input 2\n\n7 4\n1 1\n2 1\n3 1\n4 6\n4 5\n4 5\n4 5\n\nSample Output 2\n\n25\n\nIt is optimal to eat Sushi 1,2,3 and 4.\n\nSample Input 3\n\n6 5\n5 1000000000\n2 990000000\n3 980000000\n6 970000000\n6 960000000\n4 950000000\n\nSample Output 3\n\n4900000016\n\nNote that the output may not fit into a 32-bit integer type.", "sample_input": "5 3\n1 9\n1 7\n2 6\n2 5\n3 1\n"}, "reference_outputs": ["26\n"], "source_document_id": "p03148", "source_text": "Score : 400 points\n\nProblem Statement\n\nThere are N pieces of sushi. Each piece has two parameters: \"kind of topping\" t_i and \"deliciousness\" d_i.\nYou are choosing K among these N pieces to eat.\nYour \"satisfaction\" here will be calculated as follows:\n\nThe satisfaction is the sum of the \"base total deliciousness\" and the \"variety bonus\".\n\nThe base total deliciousness is the sum of the deliciousness of the pieces you eat.\n\nThe variety bonus is x*x, where x is the number of different kinds of toppings of the pieces you eat.\n\nYou want to have as much satisfaction as possible.\nFind this maximum satisfaction.\n\nConstraints\n\n1 \\leq K \\leq N \\leq 10^5\n\n1 \\leq t_i \\leq N\n\n1 \\leq d_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nt_1 d_1\nt_2 d_2\n.\n.\n.\nt_N d_N\n\nOutput\n\nPrint the maximum satisfaction that you can obtain.\n\nSample Input 1\n\n5 3\n1 9\n1 7\n2 6\n2 5\n3 1\n\nSample Output 1\n\n26\n\nIf you eat Sushi 1,2 and 3:\n\nThe base total deliciousness is 9+7+6=22.\n\nThe variety bonus is 2*2=4.\n\nThus, your satisfaction will be 26, which is optimal.\n\nSample Input 2\n\n7 4\n1 1\n2 1\n3 1\n4 6\n4 5\n4 5\n4 5\n\nSample Output 2\n\n25\n\nIt is optimal to eat Sushi 1,2,3 and 4.\n\nSample Input 3\n\n6 5\n5 1000000000\n2 990000000\n3 980000000\n6 970000000\n6 960000000\n4 950000000\n\nSample Output 3\n\n4900000016\n\nNote that the output may not fit into a 32-bit integer type.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3063, "cpu_time_ms": 2105, "memory_kb": 23936}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s762184916", "group_id": "codeNet:p03149", "input_text": "Scanf.(List.(scanf \" %d %d %d %d\" @@ fun p q r s ->\n print_endline @@\n if [1;4;7;9] = sort compare [p;q;r;s] then \"YES\"\n else \"NO\"))", "language": "OCaml", "metadata": {"date": 1549155636, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03149.html", "problem_id": "p03149", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03149/input.txt", "sample_output_relpath": "derived/input_output/data/p03149/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03149/OCaml/s762184916.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s762184916", "user_id": "u481480055"}, "prompt_components": {"gold_output": "YES\n", "input_to_evaluate": "Scanf.(List.(scanf \" %d %d %d %d\" @@ fun p q r s ->\n print_endline @@\n if [1;4;7;9] = sort compare [p;q;r;s] then \"YES\"\n else \"NO\"))", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou are given four digits N_1, N_2, N_3 and N_4. Determine if these can be arranged into the sequence of digits \"1974\".\n\nConstraints\n\n0 \\leq N_1, N_2, N_3, N_4 \\leq 9\n\nN_1, N_2, N_3 and N_4 are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN_1 N_2 N_3 N_4\n\nOutput\n\nIf N_1, N_2, N_3 and N_4 can be arranged into the sequence of digits \"1974\", print YES; if they cannot, print NO.\n\nSample Input 1\n\n1 7 9 4\n\nSample Output 1\n\nYES\n\nWe can get 1974 by swapping N_2 and N_3.\n\nSample Input 2\n\n1 9 7 4\n\nSample Output 2\n\nYES\n\nWe already have 1974 before doing anything.\n\nSample Input 3\n\n1 2 9 1\n\nSample Output 3\n\nNO\n\nSample Input 4\n\n4 9 0 8\n\nSample Output 4\n\nNO", "sample_input": "1 7 9 4\n"}, "reference_outputs": ["YES\n"], "source_document_id": "p03149", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou are given four digits N_1, N_2, N_3 and N_4. Determine if these can be arranged into the sequence of digits \"1974\".\n\nConstraints\n\n0 \\leq N_1, N_2, N_3, N_4 \\leq 9\n\nN_1, N_2, N_3 and N_4 are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN_1 N_2 N_3 N_4\n\nOutput\n\nIf N_1, N_2, N_3 and N_4 can be arranged into the sequence of digits \"1974\", print YES; if they cannot, print NO.\n\nSample Input 1\n\n1 7 9 4\n\nSample Output 1\n\nYES\n\nWe can get 1974 by swapping N_2 and N_3.\n\nSample Input 2\n\n1 9 7 4\n\nSample Output 2\n\nYES\n\nWe already have 1974 before doing anything.\n\nSample Input 3\n\n1 2 9 1\n\nSample Output 3\n\nNO\n\nSample Input 4\n\n4 9 0 8\n\nSample Output 4\n\nNO", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s377005655", "group_id": "codeNet:p03150", "input_text": "let s = read_line ()\n\nlet k = \"keyence\"\n\nlet s_len = String.length s\n\nlet rec loop si ki r =\n if si = s_len then\n print_string @@ if ki = 7 then \"YES\" else \"NO\"\n else if ki = 7 then\n print_string @@ if si = s_len then \"YES\" else \"NO\"\n else\n if s.[si] = k.[ki] then\n loop (si + 1) (ki + 1) r\n else if r = 0 then print_string \"NO\"\n else\n let rec f i = if i = s_len then -1 else if s.[i] = k.[ki] then i else f (i + 1) in\n let ni = f si in\n if ni = -1 then print_string \"NO\"\n else loop (ni + 1) (ki + 1) 0\n\nlet () = loop 0 0 1", "language": "OCaml", "metadata": {"date": 1588714134, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03150.html", "problem_id": "p03150", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03150/input.txt", "sample_output_relpath": "derived/input_output/data/p03150/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03150/OCaml/s377005655.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s377005655", "user_id": "u811309788"}, "prompt_components": {"gold_output": "YES\n", "input_to_evaluate": "let s = read_line ()\n\nlet k = \"keyence\"\n\nlet s_len = String.length s\n\nlet rec loop si ki r =\n if si = s_len then\n print_string @@ if ki = 7 then \"YES\" else \"NO\"\n else if ki = 7 then\n print_string @@ if si = s_len then \"YES\" else \"NO\"\n else\n if s.[si] = k.[ki] then\n loop (si + 1) (ki + 1) r\n else if r = 0 then print_string \"NO\"\n else\n let rec f i = if i = s_len then -1 else if s.[i] = k.[ki] then i else f (i + 1) in\n let ni = f si in\n if ni = -1 then print_string \"NO\"\n else loop (ni + 1) (ki + 1) 0\n\nlet () = loop 0 0 1", "problem_context": "Score : 200 points\n\nProblem Statement\n\nA string is called a KEYENCE string when it can be changed to keyence by removing its contiguous substring (possibly empty) only once.\n\nGiven a string S consisting of lowercase English letters, determine if S is a KEYENCE string.\n\nConstraints\n\nThe length of S is between 7 and 100 (inclusive).\n\nS consists of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nIf S is a KEYENCE string, print YES; otherwise, print NO.\n\nSample Input 1\n\nkeyofscience\n\nSample Output 1\n\nYES\n\nkeyence is an abbreviation of key of science.\n\nSample Input 2\n\nmpyszsbznf\n\nSample Output 2\n\nNO\n\nSample Input 3\n\nashlfyha\n\nSample Output 3\n\nNO\n\nSample Input 4\n\nkeyence\n\nSample Output 4\n\nYES", "sample_input": "keyofscience\n"}, "reference_outputs": ["YES\n"], "source_document_id": "p03150", "source_text": "Score : 200 points\n\nProblem Statement\n\nA string is called a KEYENCE string when it can be changed to keyence by removing its contiguous substring (possibly empty) only once.\n\nGiven a string S consisting of lowercase English letters, determine if S is a KEYENCE string.\n\nConstraints\n\nThe length of S is between 7 and 100 (inclusive).\n\nS consists of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nIf S is a KEYENCE string, print YES; otherwise, print NO.\n\nSample Input 1\n\nkeyofscience\n\nSample Output 1\n\nYES\n\nkeyence is an abbreviation of key of science.\n\nSample Input 2\n\nmpyszsbznf\n\nSample Output 2\n\nNO\n\nSample Input 3\n\nashlfyha\n\nSample Output 3\n\nNO\n\nSample Input 4\n\nkeyence\n\nSample Output 4\n\nYES", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 564, "cpu_time_ms": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s649585787", "group_id": "codeNet:p03152", "input_text": "Scanf.scanf \"%d %d\" (fun n m ->\n let a = Array.init n (fun _ -> Scanf.scanf \" %d\" (fun a -> a)) in\n let b = Array.init m (fun _ -> Scanf.scanf \" %d\" (fun b -> b)) in\n Array.sort compare a;\n Array.sort compare b;\n\n let ( *@) a b = (a * b) mod 1_000_000_007 in\n\n let dup x =\n let n = Array.length x in\n let rec loop i =\n if i = n then false else\n if x.(i) = x.(i - 1) then true else loop (i + 1)\n in\n loop 1\n in\n\n let upper_bound arr v =\n let n = Array.length arr in\n let rec loop l r =\n if l = r then l else\n let m = (l + r) / 2 in\n if arr.(m) < v then loop (m + 1) r else loop l m\n in\n loop 0 n\n in\n\n let rec loop i acc =\n if i = 0 then acc else\n let r = upper_bound a i in\n let c = upper_bound b i in\n let mr = r < n && a.(r) = i in\n let mc = c < m && b.(c) = i in\n match mr, mc with\n | true, true -> loop (i - 1) acc\n | true, false -> loop (i - 1) (acc *@ (m - c))\n | false, true -> loop (i - 1) (acc *@ (n - r))\n | false, false -> loop (i - 1) (acc *@ ((m - c) * (n - r) - (n * m - i)))\n in\n Printf.printf \"%d\\n\" @@ if dup a || dup b then 0 else loop (n * m) 1\n)", "language": "OCaml", "metadata": {"date": 1592339045, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03152.html", "problem_id": "p03152", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03152/input.txt", "sample_output_relpath": "derived/input_output/data/p03152/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03152/OCaml/s649585787.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s649585787", "user_id": "u342443598"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "Scanf.scanf \"%d %d\" (fun n m ->\n let a = Array.init n (fun _ -> Scanf.scanf \" %d\" (fun a -> a)) in\n let b = Array.init m (fun _ -> Scanf.scanf \" %d\" (fun b -> b)) in\n Array.sort compare a;\n Array.sort compare b;\n\n let ( *@) a b = (a * b) mod 1_000_000_007 in\n\n let dup x =\n let n = Array.length x in\n let rec loop i =\n if i = n then false else\n if x.(i) = x.(i - 1) then true else loop (i + 1)\n in\n loop 1\n in\n\n let upper_bound arr v =\n let n = Array.length arr in\n let rec loop l r =\n if l = r then l else\n let m = (l + r) / 2 in\n if arr.(m) < v then loop (m + 1) r else loop l m\n in\n loop 0 n\n in\n\n let rec loop i acc =\n if i = 0 then acc else\n let r = upper_bound a i in\n let c = upper_bound b i in\n let mr = r < n && a.(r) = i in\n let mc = c < m && b.(c) = i in\n match mr, mc with\n | true, true -> loop (i - 1) acc\n | true, false -> loop (i - 1) (acc *@ (m - c))\n | false, true -> loop (i - 1) (acc *@ (n - r))\n | false, false -> loop (i - 1) (acc *@ ((m - c) * (n - r) - (n * m - i)))\n in\n Printf.printf \"%d\\n\" @@ if dup a || dup b then 0 else loop (n * m) 1\n)", "problem_context": "Score : 500 points\n\nProblem Statement\n\nConsider writing each of the integers from 1 to N \\times M in a grid with N rows and M columns, without duplicates.\nTakahashi thinks it is not fun enough, and he will write the numbers under the following conditions:\n\nThe largest among the values in the i-th row (1 \\leq i \\leq N) is A_i.\n\nThe largest among the values in the j-th column (1 \\leq j \\leq M) is B_j.\n\nFor him, find the number of ways to write the numbers under these conditions, modulo 10^9 + 7.\n\nConstraints\n\n1 \\leq N \\leq 1000\n\n1 \\leq M \\leq 1000\n\n1 \\leq A_i \\leq N \\times M\n\n1 \\leq B_j \\leq N \\times M\n\nA_i and B_j are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 A_2 ... A_{N}\nB_1 B_2 ... B_{M}\n\nOutput\n\nPrint the number of ways to write the numbers under the conditions, modulo 10^9 + 7.\n\nSample Input 1\n\n2 2\n4 3\n3 4\n\nSample Output 1\n\n2\n\n(A_1, A_2) = (4, 3) and (B_1, B_2) = (3, 4). In this case, there are two ways to write the numbers, as follows:\n\n1 in (1, 1), 4 in (1, 2), 3 in (2, 1) and 2 in (2, 2).\n\n2 in (1, 1), 4 in (1, 2), 3 in (2, 1) and 1 in (2, 2).\n\nHere, (i, j) denotes the square at the i-th row and the j-th column.\n\nSample Input 2\n\n3 3\n5 9 7\n3 6 9\n\nSample Output 2\n\n0\n\nSince there is no way to write the numbers under the condition, 0 should be printed.\n\nSample Input 3\n\n2 2\n4 4\n4 4\n\nSample Output 3\n\n0\n\nSample Input 4\n\n14 13\n158 167 181 147 178 151 179 182 176 169 180 129 175 168\n181 150 178 179 167 180 176 169 182 177 175 159 173\n\nSample Output 4\n\n343772227", "sample_input": "2 2\n4 3\n3 4\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03152", "source_text": "Score : 500 points\n\nProblem Statement\n\nConsider writing each of the integers from 1 to N \\times M in a grid with N rows and M columns, without duplicates.\nTakahashi thinks it is not fun enough, and he will write the numbers under the following conditions:\n\nThe largest among the values in the i-th row (1 \\leq i \\leq N) is A_i.\n\nThe largest among the values in the j-th column (1 \\leq j \\leq M) is B_j.\n\nFor him, find the number of ways to write the numbers under these conditions, modulo 10^9 + 7.\n\nConstraints\n\n1 \\leq N \\leq 1000\n\n1 \\leq M \\leq 1000\n\n1 \\leq A_i \\leq N \\times M\n\n1 \\leq B_j \\leq N \\times M\n\nA_i and B_j are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nA_1 A_2 ... A_{N}\nB_1 B_2 ... B_{M}\n\nOutput\n\nPrint the number of ways to write the numbers under the conditions, modulo 10^9 + 7.\n\nSample Input 1\n\n2 2\n4 3\n3 4\n\nSample Output 1\n\n2\n\n(A_1, A_2) = (4, 3) and (B_1, B_2) = (3, 4). In this case, there are two ways to write the numbers, as follows:\n\n1 in (1, 1), 4 in (1, 2), 3 in (2, 1) and 2 in (2, 2).\n\n2 in (1, 1), 4 in (1, 2), 3 in (2, 1) and 1 in (2, 2).\n\nHere, (i, j) denotes the square at the i-th row and the j-th column.\n\nSample Input 2\n\n3 3\n5 9 7\n3 6 9\n\nSample Output 2\n\n0\n\nSince there is no way to write the numbers under the condition, 0 should be printed.\n\nSample Input 3\n\n2 2\n4 4\n4 4\n\nSample Output 3\n\n0\n\nSample Input 4\n\n14 13\n158 167 181 147 178 151 179 182 176 169 180 129 175 168\n181 150 178 179 167 180 176 169 182 177 175 159 173\n\nSample Output 4\n\n343772227", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1334, "cpu_time_ms": 260, "memory_kb": 2560}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s429163000", "group_id": "codeNet:p03155", "input_text": "let n, h, w = Scanf.scanf \" %d %d %d\" @@ fun a b c -> a, b, c\nlet _ = Printf.printf \"%d\\n\" @@ (n - h + 1) * (n - w + 1)", "language": "OCaml", "metadata": {"date": 1566930707, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03155.html", "problem_id": "p03155", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03155/input.txt", "sample_output_relpath": "derived/input_output/data/p03155/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03155/OCaml/s429163000.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s429163000", "user_id": "u732304692"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "let n, h, w = Scanf.scanf \" %d %d %d\" @@ fun a b c -> a, b, c\nlet _ = Printf.printf \"%d\\n\" @@ (n - h + 1) * (n - w + 1)", "problem_context": "Score : 100 points\n\nProblem Statement\n\nIt has been decided that a programming contest sponsored by company A will be held, so we will post the notice on a bulletin board.\n\nThe bulletin board is in the form of a grid with N rows and N columns, and the notice will occupy a rectangular region with H rows and W columns.\n\nHow many ways are there to choose where to put the notice so that it completely covers exactly HW squares?\n\nConstraints\n\n1 \\leq H, W \\leq N \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nH\nW\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n3\n2\n3\n\nSample Output 1\n\n2\n\nThere are two ways to put the notice, as follows:\n\n### ...\n### ###\n... ###\n\nHere, # represents a square covered by the notice, and . represents a square not covered.\n\nSample Input 2\n\n100\n1\n1\n\nSample Output 2\n\n10000\n\nSample Input 3\n\n5\n4\n2\n\nSample Output 3\n\n8", "sample_input": "3\n2\n3\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03155", "source_text": "Score : 100 points\n\nProblem Statement\n\nIt has been decided that a programming contest sponsored by company A will be held, so we will post the notice on a bulletin board.\n\nThe bulletin board is in the form of a grid with N rows and N columns, and the notice will occupy a rectangular region with H rows and W columns.\n\nHow many ways are there to choose where to put the notice so that it completely covers exactly HW squares?\n\nConstraints\n\n1 \\leq H, W \\leq N \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nH\nW\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n3\n2\n3\n\nSample Output 1\n\n2\n\nThere are two ways to put the notice, as follows:\n\n### ...\n### ###\n... ###\n\nHere, # represents a square covered by the notice, and . represents a square not covered.\n\nSample Input 2\n\n100\n1\n1\n\nSample Output 2\n\n10000\n\nSample Input 3\n\n5\n4\n2\n\nSample Output 3\n\n8", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 2432}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s820840371", "group_id": "codeNet:p03156", "input_text": "let n, a, b = Scanf.scanf \" %d %d %d\" @@ fun a b c -> a, b, c\nlet ps = Array.init n @@ fun _ -> Scanf.scanf \" %d\" (+) 0\nlet cs = Array.make 3 0\nlet f i = cs.(i) <- cs.(i) + 1\nlet _ = Array.(iter (fun p -> if p <= a then f 0 else if p <= b then f 1 else f 2) ps; fold_left min cs.(0) cs) |> Printf.printf \"%d\\n\"", "language": "OCaml", "metadata": {"date": 1568207212, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03156.html", "problem_id": "p03156", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03156/input.txt", "sample_output_relpath": "derived/input_output/data/p03156/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03156/OCaml/s820840371.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s820840371", "user_id": "u732304692"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "let n, a, b = Scanf.scanf \" %d %d %d\" @@ fun a b c -> a, b, c\nlet ps = Array.init n @@ fun _ -> Scanf.scanf \" %d\" (+) 0\nlet cs = Array.make 3 0\nlet f i = cs.(i) <- cs.(i) + 1\nlet _ = Array.(iter (fun p -> if p <= a then f 0 else if p <= b then f 1 else f 2) ps; fold_left min cs.(0) cs) |> Printf.printf \"%d\\n\"", "problem_context": "Score : 200 points\n\nProblem Statement\n\nYou have written N problems to hold programming contests.\nThe i-th problem will have a score of P_i points if used in a contest.\n\nWith these problems, you would like to hold as many contests as possible under the following condition:\n\nA contest has three problems. The first problem has a score not greater than A points, the second has a score between A + 1 and B points (inclusive), and the third has a score not less than B + 1 points.\n\nThe same problem should not be used in multiple contests.\nAt most how many contests can be held?\n\nConstraints\n\n3 \\leq N \\leq 100\n\n1 \\leq P_i \\leq 20 (1 \\leq i \\leq N)\n\n1 \\leq A < B < 20\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA B\nP_1 P_2 ... P_N\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n7\n5 15\n1 10 16 2 7 20 12\n\nSample Output 1\n\n2\n\nTwo contests can be held by putting the first, second, third problems and the fourth, fifth, sixth problems together.\n\nSample Input 2\n\n8\n3 8\n5 5 5 10 10 10 15 20\n\nSample Output 2\n\n0\n\nNo contest can be held, because there is no problem with a score of A = 3 or less.\n\nSample Input 3\n\n3\n5 6\n5 6 10\n\nSample Output 3\n\n1", "sample_input": "7\n5 15\n1 10 16 2 7 20 12\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03156", "source_text": "Score : 200 points\n\nProblem Statement\n\nYou have written N problems to hold programming contests.\nThe i-th problem will have a score of P_i points if used in a contest.\n\nWith these problems, you would like to hold as many contests as possible under the following condition:\n\nA contest has three problems. The first problem has a score not greater than A points, the second has a score between A + 1 and B points (inclusive), and the third has a score not less than B + 1 points.\n\nThe same problem should not be used in multiple contests.\nAt most how many contests can be held?\n\nConstraints\n\n3 \\leq N \\leq 100\n\n1 \\leq P_i \\leq 20 (1 \\leq i \\leq N)\n\n1 \\leq A < B < 20\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA B\nP_1 P_2 ... P_N\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n7\n5 15\n1 10 16 2 7 20 12\n\nSample Output 1\n\n2\n\nTwo contests can be held by putting the first, second, third problems and the fourth, fifth, sixth problems together.\n\nSample Input 2\n\n8\n3 8\n5 5 5 10 10 10 15 20\n\nSample Output 2\n\n0\n\nNo contest can be held, because there is no problem with a score of A = 3 or less.\n\nSample Input 3\n\n3\n5 6\n5 6 10\n\nSample Output 3\n\n1", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s974167984", "group_id": "codeNet:p03167", "input_text": "\nlet memoize n f =\n let dp = Hashtbl.create n in\n let rec get x =\n try Hashtbl.find dp x with\n | Not_found ->\n let result = f get x in\n Hashtbl.add dp x result;\n result in get\n\nlet () = Scanf.scanf \"%d %d\\n\" @@ fun h w ->\n let ass = Array.init h @@ fun _ -> Scanf.scanf \"%s\\n\" @@ fun s -> s in\n let dp = memoize (h * w) @@ fun dp -> function\n | (0, 0) -> 1\n | (i, 0) -> if ass.(i).[0] = '.' then dp (i - 1, 0) else 0\n | (0, j) -> if ass.(0).[j] = '.' then dp (0, j - 1) else 0\n | (i, j) -> if ass.(i).[j] = '.' then (dp (i - 1, j) + dp (i, j - 1)) mod 1000000007 else 0 in\n Printf.printf \"%d\\n\" @@ dp (h - 1, w - 1)\n \n\n", "language": "OCaml", "metadata": {"date": 1546807108, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03167.html", "problem_id": "p03167", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03167/input.txt", "sample_output_relpath": "derived/input_output/data/p03167/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03167/OCaml/s974167984.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s974167984", "user_id": "u504158101"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "\nlet memoize n f =\n let dp = Hashtbl.create n in\n let rec get x =\n try Hashtbl.find dp x with\n | Not_found ->\n let result = f get x in\n Hashtbl.add dp x result;\n result in get\n\nlet () = Scanf.scanf \"%d %d\\n\" @@ fun h w ->\n let ass = Array.init h @@ fun _ -> Scanf.scanf \"%s\\n\" @@ fun s -> s in\n let dp = memoize (h * w) @@ fun dp -> function\n | (0, 0) -> 1\n | (i, 0) -> if ass.(i).[0] = '.' then dp (i - 1, 0) else 0\n | (0, j) -> if ass.(0).[j] = '.' then dp (0, j - 1) else 0\n | (i, j) -> if ass.(i).[j] = '.' then (dp (i - 1, j) + dp (i, j - 1)) mod 1000000007 else 0 in\n Printf.printf \"%d\\n\" @@ dp (h - 1, w - 1)\n \n\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nThere is a grid with H horizontal rows and W vertical columns.\nLet (i, j) denote the square at the i-th row from the top and the j-th column from the left.\n\nFor each i and j (1 \\leq i \\leq H, 1 \\leq j \\leq W), Square (i, j) is described by a character a_{i, j}.\nIf a_{i, j} is ., Square (i, j) is an empty square; if a_{i, j} is #, Square (i, j) is a wall square.\nIt is guaranteed that Squares (1, 1) and (H, W) are empty squares.\n\nTaro will start from Square (1, 1) and reach (H, W) by repeatedly moving right or down to an adjacent empty square.\n\nFind the number of Taro's paths from Square (1, 1) to (H, W).\nAs the answer can be extremely large, find the count modulo 10^9 + 7.\n\nConstraints\n\nH and W are integers.\n\n2 \\leq H, W \\leq 1000\n\na_{i, j} is . or #.\n\nSquares (1, 1) and (H, W) are empty squares.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\na_{1, 1}\\ldotsa_{1, W}\n:\na_{H, 1}\\ldotsa_{H, W}\n\nOutput\n\nPrint the number of Taro's paths from Square (1, 1) to (H, W), modulo 10^9 + 7.\n\nSample Input 1\n\n3 4\n...#\n.#..\n....\n\nSample Output 1\n\n3\n\nThere are three paths as follows:\n\nSample Input 2\n\n5 2\n..\n#.\n..\n.#\n..\n\nSample Output 2\n\n0\n\nThere may be no paths.\n\nSample Input 3\n\n5 5\n..#..\n.....\n#...#\n.....\n..#..\n\nSample Output 3\n\n24\n\nSample Input 4\n\n20 20\n....................\n....................\n....................\n....................\n....................\n....................\n....................\n....................\n....................\n....................\n....................\n....................\n....................\n....................\n....................\n....................\n....................\n....................\n....................\n....................\n\nSample Output 4\n\n345263555\n\nBe sure to print the count modulo 10^9 + 7.", "sample_input": "3 4\n...#\n.#..\n....\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03167", "source_text": "Score : 100 points\n\nProblem Statement\n\nThere is a grid with H horizontal rows and W vertical columns.\nLet (i, j) denote the square at the i-th row from the top and the j-th column from the left.\n\nFor each i and j (1 \\leq i \\leq H, 1 \\leq j \\leq W), Square (i, j) is described by a character a_{i, j}.\nIf a_{i, j} is ., Square (i, j) is an empty square; if a_{i, j} is #, Square (i, j) is a wall square.\nIt is guaranteed that Squares (1, 1) and (H, W) are empty squares.\n\nTaro will start from Square (1, 1) and reach (H, W) by repeatedly moving right or down to an adjacent empty square.\n\nFind the number of Taro's paths from Square (1, 1) to (H, W).\nAs the answer can be extremely large, find the count modulo 10^9 + 7.\n\nConstraints\n\nH and W are integers.\n\n2 \\leq H, W \\leq 1000\n\na_{i, j} is . or #.\n\nSquares (1, 1) and (H, W) are empty squares.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\na_{1, 1}\\ldotsa_{1, W}\n:\na_{H, 1}\\ldotsa_{H, W}\n\nOutput\n\nPrint the number of Taro's paths from Square (1, 1) to (H, W), modulo 10^9 + 7.\n\nSample Input 1\n\n3 4\n...#\n.#..\n....\n\nSample Output 1\n\n3\n\nThere are three paths as follows:\n\nSample Input 2\n\n5 2\n..\n#.\n..\n.#\n..\n\nSample Output 2\n\n0\n\nThere may be no paths.\n\nSample Input 3\n\n5 5\n..#..\n.....\n#...#\n.....\n..#..\n\nSample Output 3\n\n24\n\nSample Input 4\n\n20 20\n....................\n....................\n....................\n....................\n....................\n....................\n....................\n....................\n....................\n....................\n....................\n....................\n....................\n....................\n....................\n....................\n....................\n....................\n....................\n....................\n\nSample Output 4\n\n345263555\n\nBe sure to print the count modulo 10^9 + 7.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 666, "cpu_time_ms": 509, "memory_kb": 72440}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s635001574", "group_id": "codeNet:p03170", "input_text": "open Batteries\nopen Tuple\nmodule EnumL = Enum.Labels\nmodule ListL = List.Labels\nmodule ArrayL = Array.Labels\n\nlet dbg0 x = Printf.eprintf \"[debug]%s\\n\" @@ dump x\nlet dbg1 x = dbg0 x; x\n\nlet id = identity\n\nlet (++) n m = List.range n `To m\nlet (++^) n m = if n < m then List.range n `To (pred m) else []\n\nlet scan fmt = Scanf.sscanf (read_line ()) fmt\n\nlet scan_lines n fmt f =\n if n = 0 then []\n else List.map (fun _ -> scan fmt f) (1 ++ n)\n\nlet scan_list sep cnv =\n let line = read_line () in\n (match sep with\n | None -> List.map String.of_char @@ String.to_list line\n | Some sep -> String.split_on_char sep line)\n |> List.map cnv\n\nlet scan_array ?sep cnv = Array.of_list @@ scan_list sep cnv\n\nlet scan_matrix n m e ?sep conv =\n let arr = Array.make_matrix n m e in\n ListL.iter (0 ++^ n)\n ~f:(fun i -> arr.(i) <- Array.of_list @@ scan_list sep conv);\n arr\n\nlet rec powerset e =\n match Enum.get e with\n | None -> Enum.singleton @@ Enum.empty ()\n | Some v ->\n let f = powerset e in\n let g = Enum.clone f in\n EnumL.map f ~f:(fun x -> let y = Enum.clone x in push y v; y)\n |> Enum.append g\n\nlet permutations l =\n let rec aux l =\n let rec interleave x = function\n | [] -> [[x]]\n | (hd::tl) as lst ->\n (x::lst) ::\n (ListL.map ~f:(List.cons hd) @@ interleave x tl)\n in\n match l with\n | [] -> [[]]\n | hd::tl -> List.concat @@ List.map (interleave hd) @@ aux tl in\n let l = List.sort (List.compare Int.compare) @@ aux @@ List.of_enum l in\n List.enum % ListL.map ~f:List.enum @@ l\n\nlet intersection l =\n EnumL.filter ~f:(fun x -> EnumL.exists ~f:((=) x) @@ Enum.clone l)\n\nlet lower_bound n f =\n let rec aux l u =\n if u - l > 1 then\n let m = (l + u) / 2 in\n if f m then aux l m\n else aux m u\n else u in aux (-1) n\n\nlet between n x m = n <= x && x < m\n\nlet (n,k) = scan \"%d %d\" Tuple2.make\nlet arr = scan_array ~sep:' ' Int.of_string\n\nlet memo = Array.make_matrix (succ k) 2 None\n\nlet rec solve k t =\n match memo.(k).(if t then 1 else 0) with\n | Some v -> v\n | None ->\n let v = if t then\n if k < arr.(0) then false\n else ArrayL.exists arr ~f:(fun a ->\n if k - a >= 0 then solve (k-a) false else false)\n else\n if k < arr.(0) then true\n else not @@ ArrayL.exists arr ~f:(fun a ->\n if k - a >= 0 then solve (k-a) true = false else false) in\n memo.(k).(if t then 1 else 0) <- Some v; v\n\nlet () =\n solve k true\n |> (fun b -> Printf.printf \"%s\\n\" (if b then \"First\" else \"Second\"))\n", "language": "OCaml", "metadata": {"date": 1588713840, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03170.html", "problem_id": "p03170", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03170/input.txt", "sample_output_relpath": "derived/input_output/data/p03170/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03170/OCaml/s635001574.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s635001574", "user_id": "u802614675"}, "prompt_components": {"gold_output": "First\n", "input_to_evaluate": "open Batteries\nopen Tuple\nmodule EnumL = Enum.Labels\nmodule ListL = List.Labels\nmodule ArrayL = Array.Labels\n\nlet dbg0 x = Printf.eprintf \"[debug]%s\\n\" @@ dump x\nlet dbg1 x = dbg0 x; x\n\nlet id = identity\n\nlet (++) n m = List.range n `To m\nlet (++^) n m = if n < m then List.range n `To (pred m) else []\n\nlet scan fmt = Scanf.sscanf (read_line ()) fmt\n\nlet scan_lines n fmt f =\n if n = 0 then []\n else List.map (fun _ -> scan fmt f) (1 ++ n)\n\nlet scan_list sep cnv =\n let line = read_line () in\n (match sep with\n | None -> List.map String.of_char @@ String.to_list line\n | Some sep -> String.split_on_char sep line)\n |> List.map cnv\n\nlet scan_array ?sep cnv = Array.of_list @@ scan_list sep cnv\n\nlet scan_matrix n m e ?sep conv =\n let arr = Array.make_matrix n m e in\n ListL.iter (0 ++^ n)\n ~f:(fun i -> arr.(i) <- Array.of_list @@ scan_list sep conv);\n arr\n\nlet rec powerset e =\n match Enum.get e with\n | None -> Enum.singleton @@ Enum.empty ()\n | Some v ->\n let f = powerset e in\n let g = Enum.clone f in\n EnumL.map f ~f:(fun x -> let y = Enum.clone x in push y v; y)\n |> Enum.append g\n\nlet permutations l =\n let rec aux l =\n let rec interleave x = function\n | [] -> [[x]]\n | (hd::tl) as lst ->\n (x::lst) ::\n (ListL.map ~f:(List.cons hd) @@ interleave x tl)\n in\n match l with\n | [] -> [[]]\n | hd::tl -> List.concat @@ List.map (interleave hd) @@ aux tl in\n let l = List.sort (List.compare Int.compare) @@ aux @@ List.of_enum l in\n List.enum % ListL.map ~f:List.enum @@ l\n\nlet intersection l =\n EnumL.filter ~f:(fun x -> EnumL.exists ~f:((=) x) @@ Enum.clone l)\n\nlet lower_bound n f =\n let rec aux l u =\n if u - l > 1 then\n let m = (l + u) / 2 in\n if f m then aux l m\n else aux m u\n else u in aux (-1) n\n\nlet between n x m = n <= x && x < m\n\nlet (n,k) = scan \"%d %d\" Tuple2.make\nlet arr = scan_array ~sep:' ' Int.of_string\n\nlet memo = Array.make_matrix (succ k) 2 None\n\nlet rec solve k t =\n match memo.(k).(if t then 1 else 0) with\n | Some v -> v\n | None ->\n let v = if t then\n if k < arr.(0) then false\n else ArrayL.exists arr ~f:(fun a ->\n if k - a >= 0 then solve (k-a) false else false)\n else\n if k < arr.(0) then true\n else not @@ ArrayL.exists arr ~f:(fun a ->\n if k - a >= 0 then solve (k-a) true = false else false) in\n memo.(k).(if t then 1 else 0) <- Some v; v\n\nlet () =\n solve k true\n |> (fun b -> Printf.printf \"%s\\n\" (if b then \"First\" else \"Second\"))\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nThere is a set A = \\{ a_1, a_2, \\ldots, a_N \\} consisting of N positive integers.\nTaro and Jiro will play the following game against each other.\n\nInitially, we have a pile consisting of K stones.\nThe two players perform the following operation alternately, starting from Taro:\n\nChoose an element x in A, and remove exactly x stones from the pile.\n\nA player loses when he becomes unable to play.\nAssuming that both players play optimally, determine the winner.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 100\n\n1 \\leq K \\leq 10^5\n\n1 \\leq a_1 < a_2 < \\cdots < a_N \\leq K\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\na_1 a_2 \\ldots a_N\n\nOutput\n\nIf Taro will win, print First; if Jiro will win, print Second.\n\nSample Input 1\n\n2 4\n2 3\n\nSample Output 1\n\nFirst\n\nIf Taro removes three stones, Jiro cannot make a move.\nThus, Taro wins.\n\nSample Input 2\n\n2 5\n2 3\n\nSample Output 2\n\nSecond\n\nWhatever Taro does in his operation, Jiro wins, as follows:\n\nIf Taro removes two stones, Jiro can remove three stones to make Taro unable to make a move.\n\nIf Taro removes three stones, Jiro can remove two stones to make Taro unable to make a move.\n\nSample Input 3\n\n2 7\n2 3\n\nSample Output 3\n\nFirst\n\nTaro should remove two stones. Then, whatever Jiro does in his operation, Taro wins, as follows:\n\nIf Jiro removes two stones, Taro can remove three stones to make Jiro unable to make a move.\n\nIf Jiro removes three stones, Taro can remove two stones to make Jiro unable to make a move.\n\nSample Input 4\n\n3 20\n1 2 3\n\nSample Output 4\n\nSecond\n\nSample Input 5\n\n3 21\n1 2 3\n\nSample Output 5\n\nFirst\n\nSample Input 6\n\n1 100000\n1\n\nSample Output 6\n\nSecond", "sample_input": "2 4\n2 3\n"}, "reference_outputs": ["First\n"], "source_document_id": "p03170", "source_text": "Score : 100 points\n\nProblem Statement\n\nThere is a set A = \\{ a_1, a_2, \\ldots, a_N \\} consisting of N positive integers.\nTaro and Jiro will play the following game against each other.\n\nInitially, we have a pile consisting of K stones.\nThe two players perform the following operation alternately, starting from Taro:\n\nChoose an element x in A, and remove exactly x stones from the pile.\n\nA player loses when he becomes unable to play.\nAssuming that both players play optimally, determine the winner.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 100\n\n1 \\leq K \\leq 10^5\n\n1 \\leq a_1 < a_2 < \\cdots < a_N \\leq K\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\na_1 a_2 \\ldots a_N\n\nOutput\n\nIf Taro will win, print First; if Jiro will win, print Second.\n\nSample Input 1\n\n2 4\n2 3\n\nSample Output 1\n\nFirst\n\nIf Taro removes three stones, Jiro cannot make a move.\nThus, Taro wins.\n\nSample Input 2\n\n2 5\n2 3\n\nSample Output 2\n\nSecond\n\nWhatever Taro does in his operation, Jiro wins, as follows:\n\nIf Taro removes two stones, Jiro can remove three stones to make Taro unable to make a move.\n\nIf Taro removes three stones, Jiro can remove two stones to make Taro unable to make a move.\n\nSample Input 3\n\n2 7\n2 3\n\nSample Output 3\n\nFirst\n\nTaro should remove two stones. Then, whatever Jiro does in his operation, Taro wins, as follows:\n\nIf Jiro removes two stones, Taro can remove three stones to make Jiro unable to make a move.\n\nIf Jiro removes three stones, Taro can remove two stones to make Jiro unable to make a move.\n\nSample Input 4\n\n3 20\n1 2 3\n\nSample Output 4\n\nSecond\n\nSample Input 5\n\n3 21\n1 2 3\n\nSample Output 5\n\nFirst\n\nSample Input 6\n\n1 100000\n1\n\nSample Output 6\n\nSecond", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2523, "cpu_time_ms": 144, "memory_kb": 25856}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s941271800", "group_id": "codeNet:p03171", "input_text": "Scanf.scanf \"%d\" @@ fun n ->\nlet a = Array.init n (fun _ -> Scanf.scanf \" %d\" ((+) 0)) in\nlet dp = Array.init (n+1) (fun _ -> Array.make (n+1) 0) in\nfor w = 1 to n do\n for i = 0 to n-w do\n dp.(i).(i+w) <-\n max (a.(i) - dp.(i+1).(i+w)) (a.(i+w-1) - dp.(i).(i+w-1))\n done;\ndone;\nPrintf.printf \"%d\\n\" dp.(0).(n)", "language": "OCaml", "metadata": {"date": 1546833609, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03171.html", "problem_id": "p03171", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03171/input.txt", "sample_output_relpath": "derived/input_output/data/p03171/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03171/OCaml/s941271800.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s941271800", "user_id": "u798181098"}, "prompt_components": {"gold_output": "10\n", "input_to_evaluate": "Scanf.scanf \"%d\" @@ fun n ->\nlet a = Array.init n (fun _ -> Scanf.scanf \" %d\" ((+) 0)) in\nlet dp = Array.init (n+1) (fun _ -> Array.make (n+1) 0) in\nfor w = 1 to n do\n for i = 0 to n-w do\n dp.(i).(i+w) <-\n max (a.(i) - dp.(i+1).(i+w)) (a.(i+w-1) - dp.(i).(i+w-1))\n done;\ndone;\nPrintf.printf \"%d\\n\" dp.(0).(n)", "problem_context": "Score : 100 points\n\nProblem Statement\n\nTaro and Jiro will play the following game against each other.\n\nInitially, they are given a sequence a = (a_1, a_2, \\ldots, a_N).\nUntil a becomes empty, the two players perform the following operation alternately, starting from Taro:\n\nRemove the element at the beginning or the end of a. The player earns x points, where x is the removed element.\n\nLet X and Y be Taro's and Jiro's total score at the end of the game, respectively.\nTaro tries to maximize X - Y, while Jiro tries to minimize X - Y.\n\nAssuming that the two players play optimally, find the resulting value of X - Y.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 3000\n\n1 \\leq a_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 \\ldots a_N\n\nOutput\n\nPrint the resulting value of X - Y, assuming that the two players play optimally.\n\nSample Input 1\n\n4\n10 80 90 30\n\nSample Output 1\n\n10\n\nThe game proceeds as follows when the two players play optimally (the element being removed is written bold):\n\nTaro: (10, 80, 90, 30) → (10, 80, 90)\n\nJiro: (10, 80, 90) → (10, 80)\n\nTaro: (10, 80) → (10)\n\nJiro: (10) → ()\n\nHere, X = 30 + 80 = 110 and Y = 90 + 10 = 100.\n\nSample Input 2\n\n3\n10 100 10\n\nSample Output 2\n\n-80\n\nThe game proceeds, for example, as follows when the two players play optimally:\n\nTaro: (10, 100, 10) → (100, 10)\n\nJiro: (100, 10) → (10)\n\nTaro: (10) → ()\n\nHere, X = 10 + 10 = 20 and Y = 100.\n\nSample Input 3\n\n1\n10\n\nSample Output 3\n\n10\n\nSample Input 4\n\n10\n1000000000 1 1000000000 1 1000000000 1 1000000000 1 1000000000 1\n\nSample Output 4\n\n4999999995\n\nThe answer may not fit into a 32-bit integer type.\n\nSample Input 5\n\n6\n4 2 9 7 1 5\n\nSample Output 5\n\n2\n\nThe game proceeds, for example, as follows when the two players play optimally:\n\nTaro: (4, 2, 9, 7, 1, 5) → (4, 2, 9, 7, 1)\n\nJiro: (4, 2, 9, 7, 1) → (2, 9, 7, 1)\n\nTaro: (2, 9, 7, 1) → (2, 9, 7)\n\nJiro: (2, 9, 7) → (2, 9)\n\nTaro: (2, 9) → (2)\n\nJiro: (2) → ()\n\nHere, X = 5 + 1 + 9 = 15 and Y = 4 + 7 + 2 = 13.", "sample_input": "4\n10 80 90 30\n"}, "reference_outputs": ["10\n"], "source_document_id": "p03171", "source_text": "Score : 100 points\n\nProblem Statement\n\nTaro and Jiro will play the following game against each other.\n\nInitially, they are given a sequence a = (a_1, a_2, \\ldots, a_N).\nUntil a becomes empty, the two players perform the following operation alternately, starting from Taro:\n\nRemove the element at the beginning or the end of a. The player earns x points, where x is the removed element.\n\nLet X and Y be Taro's and Jiro's total score at the end of the game, respectively.\nTaro tries to maximize X - Y, while Jiro tries to minimize X - Y.\n\nAssuming that the two players play optimally, find the resulting value of X - Y.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 3000\n\n1 \\leq a_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 \\ldots a_N\n\nOutput\n\nPrint the resulting value of X - Y, assuming that the two players play optimally.\n\nSample Input 1\n\n4\n10 80 90 30\n\nSample Output 1\n\n10\n\nThe game proceeds as follows when the two players play optimally (the element being removed is written bold):\n\nTaro: (10, 80, 90, 30) → (10, 80, 90)\n\nJiro: (10, 80, 90) → (10, 80)\n\nTaro: (10, 80) → (10)\n\nJiro: (10) → ()\n\nHere, X = 30 + 80 = 110 and Y = 90 + 10 = 100.\n\nSample Input 2\n\n3\n10 100 10\n\nSample Output 2\n\n-80\n\nThe game proceeds, for example, as follows when the two players play optimally:\n\nTaro: (10, 100, 10) → (100, 10)\n\nJiro: (100, 10) → (10)\n\nTaro: (10) → ()\n\nHere, X = 10 + 10 = 20 and Y = 100.\n\nSample Input 3\n\n1\n10\n\nSample Output 3\n\n10\n\nSample Input 4\n\n10\n1000000000 1 1000000000 1 1000000000 1 1000000000 1 1000000000 1\n\nSample Output 4\n\n4999999995\n\nThe answer may not fit into a 32-bit integer type.\n\nSample Input 5\n\n6\n4 2 9 7 1 5\n\nSample Output 5\n\n2\n\nThe game proceeds, for example, as follows when the two players play optimally:\n\nTaro: (4, 2, 9, 7, 1, 5) → (4, 2, 9, 7, 1)\n\nJiro: (4, 2, 9, 7, 1) → (2, 9, 7, 1)\n\nTaro: (2, 9, 7, 1) → (2, 9, 7)\n\nJiro: (2, 9, 7) → (2, 9)\n\nTaro: (2, 9) → (2)\n\nJiro: (2) → ()\n\nHere, X = 5 + 1 + 9 = 15 and Y = 4 + 7 + 2 = 13.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 242, "memory_kb": 74232}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s830122562", "group_id": "codeNet:p03176", "input_text": "module SegTree = struct\n module type Monoid = sig\n type t\n val e : t\n val op : t -> t -> t\n end\n\n module Make (S : Monoid) : sig\n type t\n type elt\n (* n要素の単位元からなるセグ木を作る *)\n val make : int -> t\n (* \n * update i f t\n * i番目の要素にfを適用したセグ木を作る\n *)\n val update : int -> (elt -> elt) -> t -> t\n (*\n * update_range l r f t\n * [l, r)の要素に自己準同型写像fを適用したセグ木を作る\n *)\n val update_range : int -> int -> (elt -> elt) -> t -> t\n (*\n * query l r t\n * [l, r)の要素の積を求める\n *)\n val query : int -> int -> t -> elt\n end with type elt = S.t = struct\n type elt = S.t\n (* sizeがセグ木の要素数,dataは要素すべてをモノイドの演算で畳み込んだもの *)\n type t = { size : int; data : elt; body : body lazy_t }\n and body = Leaf | Node of t * t\n\n let make_node left right =\n { size = left.size + right.size;\n data = S.op left.data right.data;\n body = lazy (Node (left, right)) }\n\n let rec make n = \n assert (1 <= n);\n { size = n;\n data = S.e;\n body = lazy\n begin match n with\n | 1 -> Leaf\n | n -> Node (make (n / 2), make ((n + 1) / 2))\n end }\n\n let rec update i f t =\n assert (0 <= i && i < t.size);\n match t with\n | { body = lazy Leaf } -> { t with data = f t.data }\n | { body = lazy (Node (left, right)) } ->\n if i < left.size then make_node (update i f left) right\n else make_node left (update (i - left.size) f right)\n\n let rec update_range l r f t =\n assert (0 <= l && l < r && r <= t.size);\n match t with\n | { body = lazy Leaf } -> { t with data = f t.data }\n | { body = lazy (Node (left, right)) } ->\n if l <= 0 && t.size <= r then\n { t with\n data = f t.data;\n body = lazy\n (Node\n (update_range 0 left.size f left,\n update_range 0 right.size f right)) }\n else if r <= left.size then\n make_node (update_range l r f left) right\n else if left.size <= l then\n make_node left (update_range (l - left.size) (r - left.size) f right)\n else\n make_node\n (update_range l left.size f left)\n (update_range 0 (r - left.size) f right)\n\n let rec query l r t =\n assert (0 <= l && l < r && r <= t.size);\n match t with\n | { body = lazy Leaf } -> t.data\n | { body = lazy (Node (left, right)) } ->\n if l <= 0 && t.size <= r then t.data\n else if r <= left.size then query l r left\n else if left.size <= l then query (l - left.size) (r - left.size) right\n else S.op (query l left.size left) (query 0 (r - left.size) right)\n end\nend\n\nmodule MaxSegTree = SegTree.Make (struct\n type t = int\n let e = min_int\n let op = max\nend)\n\nlet () = Scanf.scanf \"%d\\n\" @@ fun n ->\n let hs = Array.init n @@ fun _ -> Scanf.scanf \"%d \" @@ fun h -> h in\n let as_ = Array.init n @@ fun _ -> Scanf.scanf \"%d \" @@ fun a -> a in\n Printf.printf \"%d\\n\" @@\n MaxSegTree.query 0 (n + 1) @@\n Array.fold_left (fun st (h, a) ->\n MaxSegTree.update h (fun _ ->\n a + MaxSegTree.query 0 h st) st) (MaxSegTree.update 0 (fun _ -> 0) @@ MaxSegTree.make (n + 1)) @@\n Array.init n @@ fun i -> hs.(i), as_.(i)\n", "language": "OCaml", "metadata": {"date": 1546840298, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03176.html", "problem_id": "p03176", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03176/input.txt", "sample_output_relpath": "derived/input_output/data/p03176/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03176/OCaml/s830122562.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s830122562", "user_id": "u504158101"}, "prompt_components": {"gold_output": "60\n", "input_to_evaluate": "module SegTree = struct\n module type Monoid = sig\n type t\n val e : t\n val op : t -> t -> t\n end\n\n module Make (S : Monoid) : sig\n type t\n type elt\n (* n要素の単位元からなるセグ木を作る *)\n val make : int -> t\n (* \n * update i f t\n * i番目の要素にfを適用したセグ木を作る\n *)\n val update : int -> (elt -> elt) -> t -> t\n (*\n * update_range l r f t\n * [l, r)の要素に自己準同型写像fを適用したセグ木を作る\n *)\n val update_range : int -> int -> (elt -> elt) -> t -> t\n (*\n * query l r t\n * [l, r)の要素の積を求める\n *)\n val query : int -> int -> t -> elt\n end with type elt = S.t = struct\n type elt = S.t\n (* sizeがセグ木の要素数,dataは要素すべてをモノイドの演算で畳み込んだもの *)\n type t = { size : int; data : elt; body : body lazy_t }\n and body = Leaf | Node of t * t\n\n let make_node left right =\n { size = left.size + right.size;\n data = S.op left.data right.data;\n body = lazy (Node (left, right)) }\n\n let rec make n = \n assert (1 <= n);\n { size = n;\n data = S.e;\n body = lazy\n begin match n with\n | 1 -> Leaf\n | n -> Node (make (n / 2), make ((n + 1) / 2))\n end }\n\n let rec update i f t =\n assert (0 <= i && i < t.size);\n match t with\n | { body = lazy Leaf } -> { t with data = f t.data }\n | { body = lazy (Node (left, right)) } ->\n if i < left.size then make_node (update i f left) right\n else make_node left (update (i - left.size) f right)\n\n let rec update_range l r f t =\n assert (0 <= l && l < r && r <= t.size);\n match t with\n | { body = lazy Leaf } -> { t with data = f t.data }\n | { body = lazy (Node (left, right)) } ->\n if l <= 0 && t.size <= r then\n { t with\n data = f t.data;\n body = lazy\n (Node\n (update_range 0 left.size f left,\n update_range 0 right.size f right)) }\n else if r <= left.size then\n make_node (update_range l r f left) right\n else if left.size <= l then\n make_node left (update_range (l - left.size) (r - left.size) f right)\n else\n make_node\n (update_range l left.size f left)\n (update_range 0 (r - left.size) f right)\n\n let rec query l r t =\n assert (0 <= l && l < r && r <= t.size);\n match t with\n | { body = lazy Leaf } -> t.data\n | { body = lazy (Node (left, right)) } ->\n if l <= 0 && t.size <= r then t.data\n else if r <= left.size then query l r left\n else if left.size <= l then query (l - left.size) (r - left.size) right\n else S.op (query l left.size left) (query 0 (r - left.size) right)\n end\nend\n\nmodule MaxSegTree = SegTree.Make (struct\n type t = int\n let e = min_int\n let op = max\nend)\n\nlet () = Scanf.scanf \"%d\\n\" @@ fun n ->\n let hs = Array.init n @@ fun _ -> Scanf.scanf \"%d \" @@ fun h -> h in\n let as_ = Array.init n @@ fun _ -> Scanf.scanf \"%d \" @@ fun a -> a in\n Printf.printf \"%d\\n\" @@\n MaxSegTree.query 0 (n + 1) @@\n Array.fold_left (fun st (h, a) ->\n MaxSegTree.update h (fun _ ->\n a + MaxSegTree.query 0 h st) st) (MaxSegTree.update 0 (fun _ -> 0) @@ MaxSegTree.make (n + 1)) @@\n Array.init n @@ fun i -> hs.(i), as_.(i)\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nThere are N flowers arranged in a row.\nFor each i (1 \\leq i \\leq N), the height and the beauty of the i-th flower from the left is h_i and a_i, respectively.\nHere, h_1, h_2, \\ldots, h_N are all distinct.\n\nTaro is pulling out some flowers so that the following condition is met:\n\nThe heights of the remaining flowers are monotonically increasing from left to right.\n\nFind the maximum possible sum of the beauties of the remaining flowers.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 2 × 10^5\n\n1 \\leq h_i \\leq N\n\nh_1, h_2, \\ldots, h_N are all distinct.\n\n1 \\leq a_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nh_1 h_2 \\ldots h_N\na_1 a_2 \\ldots a_N\n\nOutput\n\nPrint the maximum possible sum of the beauties of the remaining flowers.\n\nSample Input 1\n\n4\n3 1 4 2\n10 20 30 40\n\nSample Output 1\n\n60\n\nWe should keep the second and fourth flowers from the left.\nThen, the heights would be 1, 2 from left to right, which is monotonically increasing, and the sum of the beauties would be 20 + 40 = 60.\n\nSample Input 2\n\n1\n1\n10\n\nSample Output 2\n\n10\n\nThe condition is met already at the beginning.\n\nSample Input 3\n\n5\n1 2 3 4 5\n1000000000 1000000000 1000000000 1000000000 1000000000\n\nSample Output 3\n\n5000000000\n\nThe answer may not fit into a 32-bit integer type.\n\nSample Input 4\n\n9\n4 2 5 8 3 6 1 7 9\n6 8 8 4 6 3 5 7 5\n\nSample Output 4\n\n31\n\nWe should keep the second, third, sixth, eighth and ninth flowers from the left.", "sample_input": "4\n3 1 4 2\n10 20 30 40\n"}, "reference_outputs": ["60\n"], "source_document_id": "p03176", "source_text": "Score : 100 points\n\nProblem Statement\n\nThere are N flowers arranged in a row.\nFor each i (1 \\leq i \\leq N), the height and the beauty of the i-th flower from the left is h_i and a_i, respectively.\nHere, h_1, h_2, \\ldots, h_N are all distinct.\n\nTaro is pulling out some flowers so that the following condition is met:\n\nThe heights of the remaining flowers are monotonically increasing from left to right.\n\nFind the maximum possible sum of the beauties of the remaining flowers.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 2 × 10^5\n\n1 \\leq h_i \\leq N\n\nh_1, h_2, \\ldots, h_N are all distinct.\n\n1 \\leq a_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nh_1 h_2 \\ldots h_N\na_1 a_2 \\ldots a_N\n\nOutput\n\nPrint the maximum possible sum of the beauties of the remaining flowers.\n\nSample Input 1\n\n4\n3 1 4 2\n10 20 30 40\n\nSample Output 1\n\n60\n\nWe should keep the second and fourth flowers from the left.\nThen, the heights would be 1, 2 from left to right, which is monotonically increasing, and the sum of the beauties would be 20 + 40 = 60.\n\nSample Input 2\n\n1\n1\n10\n\nSample Output 2\n\n10\n\nThe condition is met already at the beginning.\n\nSample Input 3\n\n5\n1 2 3 4 5\n1000000000 1000000000 1000000000 1000000000 1000000000\n\nSample Output 3\n\n5000000000\n\nThe answer may not fit into a 32-bit integer type.\n\nSample Input 4\n\n9\n4 2 5 8 3 6 1 7 9\n6 8 8 4 6 3 5 7 5\n\nSample Output 4\n\n31\n\nWe should keep the second, third, sixth, eighth and ninth flowers from the left.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3470, "cpu_time_ms": 1425, "memory_kb": 67268}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s765391640", "group_id": "codeNet:p03186", "input_text": "let a, b, c = Scanf.scanf \" %d %d %d\" @@ fun a b c -> a, b, c\nlet _ = Printf.printf \"%d\\n\" @@ if c >= 1 then min (c - 1) (a + b) + 1 + b else b", "language": "OCaml", "metadata": {"date": 1563484833, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03186.html", "problem_id": "p03186", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03186/input.txt", "sample_output_relpath": "derived/input_output/data/p03186/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03186/OCaml/s765391640.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s765391640", "user_id": "u732304692"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "let a, b, c = Scanf.scanf \" %d %d %d\" @@ fun a b c -> a, b, c\nlet _ = Printf.printf \"%d\\n\" @@ if c >= 1 then min (c - 1) (a + b) + 1 + b else b", "problem_context": "Score : 200 points\n\nProblem Statement\n\nTakahashi has A untasty cookies containing antidotes, B tasty cookies containing antidotes and C tasty cookies containing poison.\n\nEating a cookie containing poison results in a stomachache, and eating a cookie containing poison while having a stomachache results in a death.\nAs he wants to live, he cannot eat one in such a situation.\nEating a cookie containing antidotes while having a stomachache cures it, and there is no other way to cure stomachaches.\n\nFind the maximum number of tasty cookies that Takahashi can eat.\n\nConstraints\n\n0 \\leq A,B,C \\leq 10^9\n\nA,B and C are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C\n\nOutput\n\nPrint the maximum number of tasty cookies that Takahashi can eat.\n\nSample Input 1\n\n3 1 4\n\nSample Output 1\n\n5\n\nWe can eat all tasty cookies, in the following order:\n\nA tasty cookie containing poison\n\nAn untasty cookie containing antidotes\n\nA tasty cookie containing poison\n\nA tasty cookie containing antidotes\n\nA tasty cookie containing poison\n\nAn untasty cookie containing antidotes\n\nA tasty cookie containing poison\n\nSample Input 2\n\n5 2 9\n\nSample Output 2\n\n10\n\nSample Input 3\n\n8 8 1\n\nSample Output 3\n\n9", "sample_input": "3 1 4\n"}, "reference_outputs": ["5\n"], "source_document_id": "p03186", "source_text": "Score : 200 points\n\nProblem Statement\n\nTakahashi has A untasty cookies containing antidotes, B tasty cookies containing antidotes and C tasty cookies containing poison.\n\nEating a cookie containing poison results in a stomachache, and eating a cookie containing poison while having a stomachache results in a death.\nAs he wants to live, he cannot eat one in such a situation.\nEating a cookie containing antidotes while having a stomachache cures it, and there is no other way to cure stomachaches.\n\nFind the maximum number of tasty cookies that Takahashi can eat.\n\nConstraints\n\n0 \\leq A,B,C \\leq 10^9\n\nA,B and C are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C\n\nOutput\n\nPrint the maximum number of tasty cookies that Takahashi can eat.\n\nSample Input 1\n\n3 1 4\n\nSample Output 1\n\n5\n\nWe can eat all tasty cookies, in the following order:\n\nA tasty cookie containing poison\n\nAn untasty cookie containing antidotes\n\nA tasty cookie containing poison\n\nA tasty cookie containing antidotes\n\nA tasty cookie containing poison\n\nAn untasty cookie containing antidotes\n\nA tasty cookie containing poison\n\nSample Input 2\n\n5 2 9\n\nSample Output 2\n\n10\n\nSample Input 3\n\n8 8 1\n\nSample Output 3\n\n9", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s212640364", "group_id": "codeNet:p03192", "input_text": "let s = Scanf.scanf \" %s\" @@ fun v -> v in\nprint_int @@\n Array.(\n init (String.length s) (fun i -> if s.[i]='2' then 1 else 0)\n |> fold_left (+) 0)\n\n", "language": "OCaml", "metadata": {"date": 1545694797, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03192.html", "problem_id": "p03192", "resource_group": "low_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/OCaml/s212640364.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s212640364", "user_id": "u481480055"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "let s = Scanf.scanf \" %s\" @@ fun v -> v in\nprint_int @@\n Array.(\n init (String.length s) (fun i -> if s.[i]='2' then 1 else 0)\n |> fold_left (+) 0)\n\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou are given an integer N that has exactly four digits in base ten.\nHow many times does 2 occur in the base-ten representation of N?\n\nConstraints\n\n1000 \\leq N \\leq 9999\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n1222\n\nSample Output 1\n\n3\n\n2 occurs three times in 1222. By the way, this contest is held on December 22 (JST).\n\nSample Input 2\n\n3456\n\nSample Output 2\n\n0\n\nSample Input 3\n\n9592\n\nSample Output 3\n\n1", "sample_input": "1222\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03192", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou are given an integer N that has exactly four digits in base ten.\nHow many times does 2 occur in the base-ten representation of N?\n\nConstraints\n\n1000 \\leq N \\leq 9999\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n1222\n\nSample Output 1\n\n3\n\n2 occurs three times in 1222. By the way, this contest is held on December 22 (JST).\n\nSample Input 2\n\n3456\n\nSample Output 2\n\n0\n\nSample Input 3\n\n9592\n\nSample Output 3\n\n1", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 2432}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s368269684", "group_id": "codeNet:p03194", "input_text": "let rec fix f x = f (fix f) x\nlet factors n = (* O(sqrt n) *)\n let m,r = ref n,ref [] in\n for i=2 to (2+int_of_float (sqrt @@ float_of_int n)) do\n if !m mod i = 0 then (\n let k = ref 0 in\n while !m mod i = 0 do\n k := !k + 1; m := !m / i;\n done;\n r := (i,!k) :: !r\n )\n done;\n if !m>1 then (!m,1)::!r else !r\nlet pow n k =\n let rec f a n = function\n | 0 -> a | 1 -> n*a | k when k mod 2 = 0 -> f a (n*n) (k/2) | k -> f (a*n) (n*n) (k/2)\n in f 1 n k\nlet n,p = Scanf.scanf \" %d %d\" @@ fun u v -> u,v\nlet () = print_int (factors p |> List.fold_left (fun u (m,k) ->\n u * (if k>=n then pow m (k/n) else 1)) 1)\n\n\n", "language": "OCaml", "metadata": {"date": 1545695767, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03194.html", "problem_id": "p03194", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03194/input.txt", "sample_output_relpath": "derived/input_output/data/p03194/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03194/OCaml/s368269684.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s368269684", "user_id": "u481480055"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "let rec fix f x = f (fix f) x\nlet factors n = (* O(sqrt n) *)\n let m,r = ref n,ref [] in\n for i=2 to (2+int_of_float (sqrt @@ float_of_int n)) do\n if !m mod i = 0 then (\n let k = ref 0 in\n while !m mod i = 0 do\n k := !k + 1; m := !m / i;\n done;\n r := (i,!k) :: !r\n )\n done;\n if !m>1 then (!m,1)::!r else !r\nlet pow n k =\n let rec f a n = function\n | 0 -> a | 1 -> n*a | k when k mod 2 = 0 -> f a (n*n) (k/2) | k -> f (a*n) (n*n) (k/2)\n in f 1 n k\nlet n,p = Scanf.scanf \" %d %d\" @@ fun u v -> u,v\nlet () = print_int (factors p |> List.fold_left (fun u (m,k) ->\n u * (if k>=n then pow m (k/n) else 1)) 1)\n\n\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere are N integers a_1, a_2, ..., a_N not less than 1.\nThe values of a_1, a_2, ..., a_N are not known, but it is known that a_1 \\times a_2 \\times ... \\times a_N = P.\n\nFind the maximum possible greatest common divisor of a_1, a_2, ..., a_N.\n\nConstraints\n\n1 \\leq N \\leq 10^{12}\n\n1 \\leq P \\leq 10^{12}\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN P\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n3 24\n\nSample Output 1\n\n2\n\nThe greatest common divisor would be 2 when, for example, a_1=2, a_2=6 and a_3=2.\n\nSample Input 2\n\n5 1\n\nSample Output 2\n\n1\n\nAs a_i are positive integers, the only possible case is a_1 = a_2 = a_3 = a_4 = a_5 = 1.\n\nSample Input 3\n\n1 111\n\nSample Output 3\n\n111\n\nSample Input 4\n\n4 972439611840\n\nSample Output 4\n\n206", "sample_input": "3 24\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03194", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 646, "cpu_time_ms": 12, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s540196313", "group_id": "codeNet:p03196", "input_text": "let (n, p) = Scanf.sscanf (read_line ()) \"%d %d\" @@ fun n p -> (n, p)\n\nlet rec prime_fact acc i n =\n if n = 0 then acc\n else if n < i * i then n :: acc\n else if n mod i = 0 then prime_fact (i :: acc) i (n / i)\n else prime_fact acc (i + 1) n\n\nlet prime_fact n =\n List.fold_left (fun acc i ->\n match acc with\n | [] -> [(i, 1)]\n | (v, cnt) :: xs -> if v = i then (v, cnt + 1) :: xs else (i, 1) :: (v, cnt) :: xs\n ) [] @@ prime_fact [] 2 n\n\nlet ps = prime_fact p\n\nlet rec pow n = function\n | 0 -> 1\n | i -> n * pow n (i - 1)\n\n\nlet () = \n let ans = List.fold_left (fun ans (v, cnt) ->\n ans * (pow v (cnt / n))\n ) 1 ps in\n Printf.printf \"%d\\n\" ans", "language": "OCaml", "metadata": {"date": 1592683572, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p03196.html", "problem_id": "p03196", "resource_group": "low_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/OCaml/s540196313.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s540196313", "user_id": "u811309788"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "let (n, p) = Scanf.sscanf (read_line ()) \"%d %d\" @@ fun n p -> (n, p)\n\nlet rec prime_fact acc i n =\n if n = 0 then acc\n else if n < i * i then n :: acc\n else if n mod i = 0 then prime_fact (i :: acc) i (n / i)\n else prime_fact acc (i + 1) n\n\nlet prime_fact n =\n List.fold_left (fun acc i ->\n match acc with\n | [] -> [(i, 1)]\n | (v, cnt) :: xs -> if v = i then (v, cnt + 1) :: xs else (i, 1) :: (v, cnt) :: xs\n ) [] @@ prime_fact [] 2 n\n\nlet ps = prime_fact p\n\nlet rec pow n = function\n | 0 -> 1\n | i -> n * pow n (i - 1)\n\n\nlet () = \n let ans = List.fold_left (fun ans (v, cnt) ->\n ans * (pow v (cnt / n))\n ) 1 ps in\n Printf.printf \"%d\\n\" ans", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 668, "cpu_time_ms": 12, "memory_kb": 3772}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s252659562", "group_id": "codeNet:p03197", "input_text": "let n = Scanf.sscanf (read_line ()) \"%d\" @@ fun n -> n\nlet a = Array.init n @@ fun _ -> Scanf.sscanf (read_line ()) \"%d\" @@ fun a -> a\n\nlet () = print_endline @@ if Array.for_all (fun i -> i mod 2 = 0) a then \"second\" else \"first\"", "language": "OCaml", "metadata": {"date": 1593125544, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p03197.html", "problem_id": "p03197", "resource_group": "low_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/OCaml/s252659562.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s252659562", "user_id": "u811309788"}, "prompt_components": {"gold_output": "first\n", "input_to_evaluate": "let n = Scanf.sscanf (read_line ()) \"%d\" @@ fun n -> n\nlet a = Array.init n @@ fun _ -> Scanf.sscanf (read_line ()) \"%d\" @@ fun a -> a\n\nlet () = print_endline @@ if Array.for_all (fun i -> i mod 2 = 0) a then \"second\" else \"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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 230, "cpu_time_ms": 55, "memory_kb": 6628}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s670692412", "group_id": "codeNet:p03197", "input_text": "let () = print_endline @@ Scanf.scanf \"%d\\n\" @@ function\n | 1 -> Scanf.scanf \"%d\\n\" @@ fun a ->\n if a mod 2 = 0 then \"second\" else \"first\"\n | n ->\n let as_ = Array.init n @@ fun _ -> Scanf.scanf \"%d\\n\" @@ fun a -> a in\n Array.sort (fun i j -> compare j i) as_;\n if (as_.(0) - as_.(1)) mod 2 = 0 then \"second\" else \"first\"\n", "language": "OCaml", "metadata": {"date": 1545532200, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03197.html", "problem_id": "p03197", "resource_group": "low_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/OCaml/s670692412.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s670692412", "user_id": "u504158101"}, "prompt_components": {"gold_output": "first\n", "input_to_evaluate": "let () = print_endline @@ Scanf.scanf \"%d\\n\" @@ function\n | 1 -> Scanf.scanf \"%d\\n\" @@ fun a ->\n if a mod 2 = 0 then \"second\" else \"first\"\n | n ->\n let as_ = Array.init n @@ fun _ -> Scanf.scanf \"%d\\n\" @@ fun a -> a in\n Array.sort (fun i j -> compare j i) as_;\n if (as_.(0) - as_.(1)) mod 2 = 0 then \"second\" else \"first\"\n", "problem_context": "Score : 500 points\n\nProblem Statement\n\nThere is an apple tree that bears apples of N colors. The N colors of these apples are numbered 1 to N, and there are a_i apples of Color i.\n\nYou and Lunlun the dachshund alternately perform the following operation (starting from you):\n\nChoose one or more apples from the tree and eat them. Here, the apples chosen at the same time must all have different colors.\n\nThe one who eats the last apple from the tree will be declared winner. If both you and Lunlun play optimally, which will win?\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq a_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1\na_2\n:\na_N\n\nOutput\n\nIf you will win, print first; if Lunlun will win, print second.\n\nSample Input 1\n\n2\n1\n2\n\nSample Output 1\n\nfirst\n\nLet Color 1 be red, and Color 2 be blue. In this case, the tree bears one red apple and two blue apples.\n\nYou should eat the red apple in your first turn. Lunlun is then forced to eat one of the blue apples, and you can win by eating the other in your next turn.\n\nNote that you are also allowed to eat two apples in your first turn, one red and one blue (not a winning move, though).\n\nSample Input 2\n\n3\n100000\n30000\n20000\n\nSample Output 2\n\nsecond", "sample_input": "2\n1\n2\n"}, "reference_outputs": ["first\n"], "source_document_id": "p03197", "source_text": "Score : 500 points\n\nProblem Statement\n\nThere is an apple tree that bears apples of N colors. The N colors of these apples are numbered 1 to N, and there are a_i apples of Color i.\n\nYou and Lunlun the dachshund alternately perform the following operation (starting from you):\n\nChoose one or more apples from the tree and eat them. Here, the apples chosen at the same time must all have different colors.\n\nThe one who eats the last apple from the tree will be declared winner. If both you and Lunlun play optimally, which will win?\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq a_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1\na_2\n:\na_N\n\nOutput\n\nIf you will win, print first; if Lunlun will win, print second.\n\nSample Input 1\n\n2\n1\n2\n\nSample Output 1\n\nfirst\n\nLet Color 1 be red, and Color 2 be blue. In this case, the tree bears one red apple and two blue apples.\n\nYou should eat the red apple in your first turn. Lunlun is then forced to eat one of the blue apples, and you can win by eating the other in your next turn.\n\nNote that you are also allowed to eat two apples in your first turn, one red and one blue (not a winning move, though).\n\nSample Input 2\n\n3\n100000\n30000\n20000\n\nSample Output 2\n\nsecond", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 344, "cpu_time_ms": 67, "memory_kb": 5120}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s816016344", "group_id": "codeNet:p03200", "input_text": "let k, ans = ref 0, ref 0\nlet _ = String.iter (function 'B' -> incr k | _ -> ans := !ans + !k) @@ read_line (); Printf.printf \"%d\\n\" !ans", "language": "OCaml", "metadata": {"date": 1572460114, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03200.html", "problem_id": "p03200", "resource_group": "low_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/OCaml/s816016344.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s816016344", "user_id": "u732304692"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "let k, ans = ref 0, ref 0\nlet _ = String.iter (function 'B' -> incr k | _ -> ans := !ans + !k) @@ read_line (); Printf.printf \"%d\\n\" !ans", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 3, "memory_kb": 2816}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s189265217", "group_id": "codeNet:p03201", "input_text": "open Printf open Scanf\nmodule Lib = struct\n let i32,i64,ist = Int64.(to_int,of_int,to_string)\n let (+$) = (+) let (-$) = (-) let (/$) = (/) let ( *$) = ( * ) let (%$) = (mod)\n let labs = Int64.abs\n let (+),(-),( * ),(/),(mod),(%) = Int64.(add,sub,mul,div,rem,rem)\n let (+=) r v = r := !r + v\n let (-=) r v = r := !r - v\n let ( *= ) r v = r := !r * v\n let (/=) r v = r := !r / v\n let (%=) r v = r := !r % v\n let max_i64,min_i64 = Int64.(max_int,min_int)\n (* math *)\n let ceildiv p q = (p+q-1L) / q\n let rec gcd m n = match m,n with | m,0L -> m | m,n -> gcd n (m mod n)\n let lcm m n = m / gcd m n * n\n module Int64_infix = struct\n let (land),(lor),(lxor),lnot,(lsl),(lsr),(asr) =\n let open Int64 in\n (logand),(logor),(logxor),lognot,\n (fun u v -> shift_left u (i32 v)),\n (fun u v -> shift_right u (i32 v)),\n (fun u v -> shift_right_logical u (i32 v))\n end\n let pow n k =\n let rec f a n = function\n | 0L -> a | 1L -> n*a | k when k mod 2L = 0L -> f a (n*n) (k/2L) | k -> f (a*n) (n*n) (k/2L)\n in f 1L n k\n (* input *)\n let input_i64_array n = Array.init (i32 n) (fun _ -> Scanf.scanf \" %Ld\" (fun v -> v)) let iia = input_i64_array\n let get_i64 _ = Scanf.scanf \" %Ld\" (fun v -> v) let gi = get_i64\n let get_2_i64 _ = Scanf.scanf \" %Ld %Ld\" (fun u v -> u,v) let g2 = get_2_i64\n let get_3_i64 _ = Scanf.scanf \" %Ld %Ld %Ld\" (fun u v w -> u,v,w) let g3 = get_3_i64\n let get_4_i64 _ = Scanf.scanf \" %Ld %Ld %Ld %Ld\" (fun u v w x -> u,v,w,x) let g4 = get_4_i64\n let get_5_i64 _ = Scanf.scanf \" %Ld %Ld %Ld %Ld %Ld\" (fun u v w x y -> u,v,w,x,y) let g5 = get_5_i64\n let i32_get_int _ = Scanf.scanf \" %d\" (fun v -> v) let i32_get_2_ints _ = Scanf.scanf \" %d %d\" (fun u v -> u,v) let i32_get_3_ints _ = Scanf.scanf \" %d %d %d\" (fun u v w -> u,v,w) let i32_get_4_ints _ = Scanf.scanf \" %d %d %d %d\" (fun u v w x -> u,v,w,x) let i32_get_5_ints _ = Scanf.scanf \" %d %d %d %d %d\" (fun u v w x y -> u,v,w,x,y)\n (* utils *)\n external id : 'a -> 'a = \"%identity\"\n let ( *< ) f g x = f (g x)\n let ( *> ) f g x = g (f x)\n let rv f p q = f q p (* ex. 24 |> rv (/) 6 *)\n let alen a = i64 @@ Array.length a\n let llen l = i64 @@ List.length l\n let string_of_list ?(separator=\" \") f ls = ls |> List.map f |> String.concat separator\n let string_of_array ?(separator=\" \") f a = a |> Array.to_list |> string_of_list ~separator f\n let char_list_of_string str = let rec f0 i a = if i<0 then a else f0 (i-$1) (str.[i]::a) in f0 (String.length str -$ 1) []\n let string_of_char_list ls = List.fold_left (fun u v -> u ^ (String.make 1 v)) \"\" ls\n let fail _ = failwith \"fail\"\n let dx,dy = [|1;0;-1;0|],[|0;1;0;-1|]\n let range l r = let ls = ref [] in for i=i32 l to i32 r do ls := i :: !ls done;!ls |> List.rev\n let cartesian_product u v = u |> List.map (fun p -> List.map (fun q -> p,q) v) |> List.flatten\n let shuffle a = Array.sort (fun _ _ -> (Random.int 3) -$ 1) a\n let binary_search ng ok f = let d = if ng < ok then 1L else -1L in\n let rec f0 ng ok =\n if labs (ok - ng) <= 1L then ok\n else let mid = ng + (ok - ng) / 2L in if f mid then f0 ng mid else f0 mid ok\n in f0 (ng-1L*d) (ok+1L*d)\n let lower_bound a v = binary_search 0L (alen a - 1L) (fun i -> a.(i32 i) >= v)\n let upper_bound a v = binary_search 0L (alen a - 1L) (fun i -> a.(i32 i) > v)\n let equal_range a v = lower_bound a v, upper_bound a v (* #=snd-fst *)\n let rec fix f x = f (fix f) x\n let fix_memo ?(size=10000) f x =\n let tb = Hashtbl.create ~random:true size in\n let rec f0 x =\n try Hashtbl.find tb x with\n | Not_found -> (let v = f f0 x in Hashtbl.add tb x v; v)\n in f0 x\n (* imperative *)\n let rep f t ?(stride=1L) fbod = let i = ref f in while !i <= t do fbod !i; i := !i + stride done\n let repb f t ?(stride=1L) fbod = let i,c = ref f,ref true in while !i <= t && !c do\n match fbod !i with | `Break -> c := false | `Ok -> i := !i + stride done\n let repm f t ?(stride=1L) m0 fbod =\n let i,c,m = ref f,ref true,ref m0 in\n while !i<=t && !c do match fbod !m !i with\n | `Break -> c := false | `Break_m m' -> (c := false; m := m') | `Ok m' -> m := m'; i := !i + stride done; !m\n let repi f t ?(stride=1) fbod = let i = ref f in while !i <= t do fbod !i; i := !i +$ stride done\n let repib f t ?(stride=1) fbod = let i,c = ref f,ref true in while !i <= t && !c do\n match fbod !i with | `Break -> c := false | `Ok -> i := !i +$ stride done\n let repim f t ?(stride=1) m0 fbod =\n let i,c,m = ref f,ref true,ref m0 in\n while !i<=t && !c do match fbod !m !i with\n | `Break -> c := false | `Break_m m' -> (c := false; m := m') | `Ok m' -> m := m'; i := !i +$ stride done; !m\n let rep_rev f t ?(stride=1L) fbod = rep t f ~stride @@ fun v -> fbod @@ f + t - v\n let repb_rev f t ?(stride=1L) fbod = repb t f ~stride @@ fun v -> fbod @@ f + t - v\n let repm_rev f t ?(stride=1L) m0 fbod = repm f t ~stride m0 @@ fun u v -> fbod u @@ f + t - v\n let repi_rev f t ?(stride=1) fbod = repi t f ~stride @@ fun v -> fbod @@ f +$ t -$ v\n let repib_rev f t ?(stride=1) fbod = repib t f ~stride @@ fun v -> fbod @@ f +$ t -$ v\n let repim_rev f t ?(stride=1) m0 fbod = repim f t ~stride m0 @@ fun u v -> fbod u @@ f +$ t -$ v\n (* output *)\n let print_list_mle f ls = string_of_list f ls |> print_endline\n let print_array_mle f a = string_of_array f a |> print_endline\n let print_list f ls = ls |> List.iter (fun v -> printf \"%s \" @@ f v); print_newline ()\n let print_array f a = a |> Array.iter (fun v -> printf \"%s \" @@ f v); print_newline ()\n (* debug *)\n let dump_2darr f a = a |> Array.iter (fun b -> print_array f b)\n let dump_i64_list ls = print_list ist ls\n let dump_i64_array a = print_array ist a\nend open Lib open Array\nlet powers n limit =\n let rec f0 i r =\n if i>limit then r\n else f0 (i*n) (i::r)\n in f0 1L []\nlet upper_bound a v = binary_search 0L (alen a - 1L) (fun i -> a.(i32 i) > v)\nlet equal_range a v = lower_bound a v, upper_bound a v (* #=snd-fst *)\nmodule IMap = Map.Make(Int64)\nmodule HT = Hashtbl\nlet () =\n let n = gi 0 in let a = iia n in\n sort compare a;\n (* print_array ist a; *)\n let used = make (i32 n) false in\n let mx = a.(0) + a.(i32 n-$1) in\n (* printf \"%Ld\\n\" mx; *)\n let pows = powers 2L mx in\n let res = ref 0L in\n let mp = HT.create ~random:true 100000 in\n iter (fun v ->\n HT.add mp v (1L + try HT.find mp v with _ -> 0L)\n ) a;\n List.iter (fun pw ->\n (* printf \"%Ld: \\n\" pw; *)\n HT.iter (fun v cv ->\n (* (fun i v -> *)\n (* let j = equal_range 0L (alen a-1L) (fun i ->\n v + a.(i32 i) = pw\n ) in *)\n try\n let w = pw-v in\n (* let cv,cw = HT.find mp v,HT.find mp w in *)\n let cw = HT.find mp w in\n (* printf \"%Ld: %Ld; %Ld: %Ld\\n\" v cv w cw; *)\n if v<>w && cv > 0L && cw > 0L then (\n if cv=1L then HT.remove mp v\n else HT.add mp v (HT.find mp v - 1L);\n if cw=1L then HT.remove mp (pw-v)\n else HT.add mp v (HT.find mp (pw-v) - 1L);\n res += 1L;\n ) else if v=w && cv>=2L then (\n if cv=2L then HT.remove mp v\n else HT.add mp v (HT.find mp v - 2L);\n res += 1L\n )\n with Not_found -> ();\n\n (* let jf,jt = equal_range a (pw-v) in\n let f = ref true in\n rep jf jt (fun j ->\n if !f && i<>i32 j && 0L <= j && j <= alen a-1L\n && not used.(i) && not used.(i32 j)\n && v + a.(i32 j) = pw then (\n used.(i) <- true;\n used.(i32 j) <- true;\n res += 1L;\n (* printf \" %d,%d\\n\" i @@ i32 j; *)\n f := false\n )\n ); *)\n (* print_array string_of_bool used; *)\n ) mp\n ) pows;\n printf \"%Ld\\n\" !res\n\n\n\n\n\n\n\n\n\n", "language": "OCaml", "metadata": {"date": 1544934702, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03201.html", "problem_id": "p03201", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03201/input.txt", "sample_output_relpath": "derived/input_output/data/p03201/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03201/OCaml/s189265217.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s189265217", "user_id": "u481480055"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "open Printf open Scanf\nmodule Lib = struct\n let i32,i64,ist = Int64.(to_int,of_int,to_string)\n let (+$) = (+) let (-$) = (-) let (/$) = (/) let ( *$) = ( * ) let (%$) = (mod)\n let labs = Int64.abs\n let (+),(-),( * ),(/),(mod),(%) = Int64.(add,sub,mul,div,rem,rem)\n let (+=) r v = r := !r + v\n let (-=) r v = r := !r - v\n let ( *= ) r v = r := !r * v\n let (/=) r v = r := !r / v\n let (%=) r v = r := !r % v\n let max_i64,min_i64 = Int64.(max_int,min_int)\n (* math *)\n let ceildiv p q = (p+q-1L) / q\n let rec gcd m n = match m,n with | m,0L -> m | m,n -> gcd n (m mod n)\n let lcm m n = m / gcd m n * n\n module Int64_infix = struct\n let (land),(lor),(lxor),lnot,(lsl),(lsr),(asr) =\n let open Int64 in\n (logand),(logor),(logxor),lognot,\n (fun u v -> shift_left u (i32 v)),\n (fun u v -> shift_right u (i32 v)),\n (fun u v -> shift_right_logical u (i32 v))\n end\n let pow n k =\n let rec f a n = function\n | 0L -> a | 1L -> n*a | k when k mod 2L = 0L -> f a (n*n) (k/2L) | k -> f (a*n) (n*n) (k/2L)\n in f 1L n k\n (* input *)\n let input_i64_array n = Array.init (i32 n) (fun _ -> Scanf.scanf \" %Ld\" (fun v -> v)) let iia = input_i64_array\n let get_i64 _ = Scanf.scanf \" %Ld\" (fun v -> v) let gi = get_i64\n let get_2_i64 _ = Scanf.scanf \" %Ld %Ld\" (fun u v -> u,v) let g2 = get_2_i64\n let get_3_i64 _ = Scanf.scanf \" %Ld %Ld %Ld\" (fun u v w -> u,v,w) let g3 = get_3_i64\n let get_4_i64 _ = Scanf.scanf \" %Ld %Ld %Ld %Ld\" (fun u v w x -> u,v,w,x) let g4 = get_4_i64\n let get_5_i64 _ = Scanf.scanf \" %Ld %Ld %Ld %Ld %Ld\" (fun u v w x y -> u,v,w,x,y) let g5 = get_5_i64\n let i32_get_int _ = Scanf.scanf \" %d\" (fun v -> v) let i32_get_2_ints _ = Scanf.scanf \" %d %d\" (fun u v -> u,v) let i32_get_3_ints _ = Scanf.scanf \" %d %d %d\" (fun u v w -> u,v,w) let i32_get_4_ints _ = Scanf.scanf \" %d %d %d %d\" (fun u v w x -> u,v,w,x) let i32_get_5_ints _ = Scanf.scanf \" %d %d %d %d %d\" (fun u v w x y -> u,v,w,x,y)\n (* utils *)\n external id : 'a -> 'a = \"%identity\"\n let ( *< ) f g x = f (g x)\n let ( *> ) f g x = g (f x)\n let rv f p q = f q p (* ex. 24 |> rv (/) 6 *)\n let alen a = i64 @@ Array.length a\n let llen l = i64 @@ List.length l\n let string_of_list ?(separator=\" \") f ls = ls |> List.map f |> String.concat separator\n let string_of_array ?(separator=\" \") f a = a |> Array.to_list |> string_of_list ~separator f\n let char_list_of_string str = let rec f0 i a = if i<0 then a else f0 (i-$1) (str.[i]::a) in f0 (String.length str -$ 1) []\n let string_of_char_list ls = List.fold_left (fun u v -> u ^ (String.make 1 v)) \"\" ls\n let fail _ = failwith \"fail\"\n let dx,dy = [|1;0;-1;0|],[|0;1;0;-1|]\n let range l r = let ls = ref [] in for i=i32 l to i32 r do ls := i :: !ls done;!ls |> List.rev\n let cartesian_product u v = u |> List.map (fun p -> List.map (fun q -> p,q) v) |> List.flatten\n let shuffle a = Array.sort (fun _ _ -> (Random.int 3) -$ 1) a\n let binary_search ng ok f = let d = if ng < ok then 1L else -1L in\n let rec f0 ng ok =\n if labs (ok - ng) <= 1L then ok\n else let mid = ng + (ok - ng) / 2L in if f mid then f0 ng mid else f0 mid ok\n in f0 (ng-1L*d) (ok+1L*d)\n let lower_bound a v = binary_search 0L (alen a - 1L) (fun i -> a.(i32 i) >= v)\n let upper_bound a v = binary_search 0L (alen a - 1L) (fun i -> a.(i32 i) > v)\n let equal_range a v = lower_bound a v, upper_bound a v (* #=snd-fst *)\n let rec fix f x = f (fix f) x\n let fix_memo ?(size=10000) f x =\n let tb = Hashtbl.create ~random:true size in\n let rec f0 x =\n try Hashtbl.find tb x with\n | Not_found -> (let v = f f0 x in Hashtbl.add tb x v; v)\n in f0 x\n (* imperative *)\n let rep f t ?(stride=1L) fbod = let i = ref f in while !i <= t do fbod !i; i := !i + stride done\n let repb f t ?(stride=1L) fbod = let i,c = ref f,ref true in while !i <= t && !c do\n match fbod !i with | `Break -> c := false | `Ok -> i := !i + stride done\n let repm f t ?(stride=1L) m0 fbod =\n let i,c,m = ref f,ref true,ref m0 in\n while !i<=t && !c do match fbod !m !i with\n | `Break -> c := false | `Break_m m' -> (c := false; m := m') | `Ok m' -> m := m'; i := !i + stride done; !m\n let repi f t ?(stride=1) fbod = let i = ref f in while !i <= t do fbod !i; i := !i +$ stride done\n let repib f t ?(stride=1) fbod = let i,c = ref f,ref true in while !i <= t && !c do\n match fbod !i with | `Break -> c := false | `Ok -> i := !i +$ stride done\n let repim f t ?(stride=1) m0 fbod =\n let i,c,m = ref f,ref true,ref m0 in\n while !i<=t && !c do match fbod !m !i with\n | `Break -> c := false | `Break_m m' -> (c := false; m := m') | `Ok m' -> m := m'; i := !i +$ stride done; !m\n let rep_rev f t ?(stride=1L) fbod = rep t f ~stride @@ fun v -> fbod @@ f + t - v\n let repb_rev f t ?(stride=1L) fbod = repb t f ~stride @@ fun v -> fbod @@ f + t - v\n let repm_rev f t ?(stride=1L) m0 fbod = repm f t ~stride m0 @@ fun u v -> fbod u @@ f + t - v\n let repi_rev f t ?(stride=1) fbod = repi t f ~stride @@ fun v -> fbod @@ f +$ t -$ v\n let repib_rev f t ?(stride=1) fbod = repib t f ~stride @@ fun v -> fbod @@ f +$ t -$ v\n let repim_rev f t ?(stride=1) m0 fbod = repim f t ~stride m0 @@ fun u v -> fbod u @@ f +$ t -$ v\n (* output *)\n let print_list_mle f ls = string_of_list f ls |> print_endline\n let print_array_mle f a = string_of_array f a |> print_endline\n let print_list f ls = ls |> List.iter (fun v -> printf \"%s \" @@ f v); print_newline ()\n let print_array f a = a |> Array.iter (fun v -> printf \"%s \" @@ f v); print_newline ()\n (* debug *)\n let dump_2darr f a = a |> Array.iter (fun b -> print_array f b)\n let dump_i64_list ls = print_list ist ls\n let dump_i64_array a = print_array ist a\nend open Lib open Array\nlet powers n limit =\n let rec f0 i r =\n if i>limit then r\n else f0 (i*n) (i::r)\n in f0 1L []\nlet upper_bound a v = binary_search 0L (alen a - 1L) (fun i -> a.(i32 i) > v)\nlet equal_range a v = lower_bound a v, upper_bound a v (* #=snd-fst *)\nmodule IMap = Map.Make(Int64)\nmodule HT = Hashtbl\nlet () =\n let n = gi 0 in let a = iia n in\n sort compare a;\n (* print_array ist a; *)\n let used = make (i32 n) false in\n let mx = a.(0) + a.(i32 n-$1) in\n (* printf \"%Ld\\n\" mx; *)\n let pows = powers 2L mx in\n let res = ref 0L in\n let mp = HT.create ~random:true 100000 in\n iter (fun v ->\n HT.add mp v (1L + try HT.find mp v with _ -> 0L)\n ) a;\n List.iter (fun pw ->\n (* printf \"%Ld: \\n\" pw; *)\n HT.iter (fun v cv ->\n (* (fun i v -> *)\n (* let j = equal_range 0L (alen a-1L) (fun i ->\n v + a.(i32 i) = pw\n ) in *)\n try\n let w = pw-v in\n (* let cv,cw = HT.find mp v,HT.find mp w in *)\n let cw = HT.find mp w in\n (* printf \"%Ld: %Ld; %Ld: %Ld\\n\" v cv w cw; *)\n if v<>w && cv > 0L && cw > 0L then (\n if cv=1L then HT.remove mp v\n else HT.add mp v (HT.find mp v - 1L);\n if cw=1L then HT.remove mp (pw-v)\n else HT.add mp v (HT.find mp (pw-v) - 1L);\n res += 1L;\n ) else if v=w && cv>=2L then (\n if cv=2L then HT.remove mp v\n else HT.add mp v (HT.find mp v - 2L);\n res += 1L\n )\n with Not_found -> ();\n\n (* let jf,jt = equal_range a (pw-v) in\n let f = ref true in\n rep jf jt (fun j ->\n if !f && i<>i32 j && 0L <= j && j <= alen a-1L\n && not used.(i) && not used.(i32 j)\n && v + a.(i32 j) = pw then (\n used.(i) <- true;\n used.(i32 j) <- true;\n res += 1L;\n (* printf \" %d,%d\\n\" i @@ i32 j; *)\n f := false\n )\n ); *)\n (* print_array string_of_bool used; *)\n ) mp\n ) pows;\n printf \"%Ld\\n\" !res\n\n\n\n\n\n\n\n\n\n", "problem_context": "Score : 600 points\n\nProblem Statement\n\nTakahashi has N balls with positive integers written on them. The integer written on the i-th ball is A_i.\nHe would like to form some number of pairs such that the sum of the integers written on each pair of balls is a power of 2.\nNote that a ball cannot belong to multiple pairs.\nFind the maximum possible number of pairs that can be formed.\n\nHere, a positive integer is said to be a power of 2 when it can be written as 2^t using some non-negative integer t.\n\nConstraints\n\n1 \\leq N \\leq 2\\times 10^5\n\n1 \\leq A_i \\leq 10^9\n\nA_i is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the maximum possible number of pairs such that the sum of the integers written on each pair of balls is a power of 2.\n\nSample Input 1\n\n3\n1 2 3\n\nSample Output 1\n\n1\n\nWe can form one pair whose sum of the written numbers is 4 by pairing the first and third balls.\nNote that we cannot pair the second ball with itself.\n\nSample Input 2\n\n5\n3 11 14 5 13\n\nSample Output 2\n\n2", "sample_input": "3\n1 2 3\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03201", "source_text": "Score : 600 points\n\nProblem Statement\n\nTakahashi has N balls with positive integers written on them. The integer written on the i-th ball is A_i.\nHe would like to form some number of pairs such that the sum of the integers written on each pair of balls is a power of 2.\nNote that a ball cannot belong to multiple pairs.\nFind the maximum possible number of pairs that can be formed.\n\nHere, a positive integer is said to be a power of 2 when it can be written as 2^t using some non-negative integer t.\n\nConstraints\n\n1 \\leq N \\leq 2\\times 10^5\n\n1 \\leq A_i \\leq 10^9\n\nA_i is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the maximum possible number of pairs such that the sum of the integers written on each pair of balls is a power of 2.\n\nSample Input 1\n\n3\n1 2 3\n\nSample Output 1\n\n1\n\nWe can form one pair whose sum of the written numbers is 4 by pairing the first and third balls.\nNote that we cannot pair the second ball with itself.\n\nSample Input 2\n\n5\n3 11 14 5 13\n\nSample Output 2\n\n2", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 7677, "cpu_time_ms": 2108, "memory_kb": 346096}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s221354891", "group_id": "codeNet:p03201", "input_text": "open Printf open Scanf\nmodule Lib = struct\n let i32,i64,ist = Int64.(to_int,of_int,to_string)\n let (+$) = (+) let (-$) = (-) let (/$) = (/) let ( *$) = ( * ) let (%$) = (mod)\n let labs = Int64.abs\n let (+),(-),( * ),(/),(mod),(%) = Int64.(add,sub,mul,div,rem,rem)\n let (+=) r v = r := !r + v\n let (-=) r v = r := !r - v\n let ( *= ) r v = r := !r * v\n let (/=) r v = r := !r / v\n let (%=) r v = r := !r % v\n let max_i64,min_i64 = Int64.(max_int,min_int)\n (* math *)\n let ceildiv p q = (p+q-1L) / q\n let rec gcd m n = match m,n with | m,0L -> m | m,n -> gcd n (m mod n)\n let lcm m n = m / gcd m n * n\n module Int64_infix = struct\n let (land),(lor),(lxor),lnot,(lsl),(lsr),(asr) =\n let open Int64 in\n (logand),(logor),(logxor),lognot,\n (fun u v -> shift_left u (i32 v)),\n (fun u v -> shift_right u (i32 v)),\n (fun u v -> shift_right_logical u (i32 v))\n end\n let pow n k =\n let rec f a n = function\n | 0L -> a | 1L -> n*a | k when k mod 2L = 0L -> f a (n*n) (k/2L) | k -> f (a*n) (n*n) (k/2L)\n in f 1L n k\n (* input *)\n let input_i64_array n = Array.init (i32 n) (fun _ -> Scanf.scanf \" %Ld\" (fun v -> v)) let iia = input_i64_array\n let get_i64 _ = Scanf.scanf \" %Ld\" (fun v -> v) let gi = get_i64\n let get_2_i64 _ = Scanf.scanf \" %Ld %Ld\" (fun u v -> u,v) let g2 = get_2_i64\n let get_3_i64 _ = Scanf.scanf \" %Ld %Ld %Ld\" (fun u v w -> u,v,w) let g3 = get_3_i64\n let get_4_i64 _ = Scanf.scanf \" %Ld %Ld %Ld %Ld\" (fun u v w x -> u,v,w,x) let g4 = get_4_i64\n let get_5_i64 _ = Scanf.scanf \" %Ld %Ld %Ld %Ld %Ld\" (fun u v w x y -> u,v,w,x,y) let g5 = get_5_i64\n let i32_get_int _ = Scanf.scanf \" %d\" (fun v -> v) let i32_get_2_ints _ = Scanf.scanf \" %d %d\" (fun u v -> u,v) let i32_get_3_ints _ = Scanf.scanf \" %d %d %d\" (fun u v w -> u,v,w) let i32_get_4_ints _ = Scanf.scanf \" %d %d %d %d\" (fun u v w x -> u,v,w,x) let i32_get_5_ints _ = Scanf.scanf \" %d %d %d %d %d\" (fun u v w x y -> u,v,w,x,y)\n (* utils *)\n external id : 'a -> 'a = \"%identity\"\n let ( *< ) f g x = f (g x)\n let ( *> ) f g x = g (f x)\n let rv f p q = f q p (* ex. 24 |> rv (/) 6 *)\n let alen a = i64 @@ Array.length a\n let llen l = i64 @@ List.length l\n let string_of_list ?(separator=\" \") f ls = ls |> List.map f |> String.concat separator\n let string_of_array ?(separator=\" \") f a = a |> Array.to_list |> string_of_list ~separator f\n let char_list_of_string str = let rec f0 i a = if i<0 then a else f0 (i-$1) (str.[i]::a) in f0 (String.length str -$ 1) []\n let string_of_char_list ls = List.fold_left (fun u v -> u ^ (String.make 1 v)) \"\" ls\n let fail _ = failwith \"fail\"\n let dx,dy = [|1;0;-1;0|],[|0;1;0;-1|]\n let range l r = let ls = ref [] in for i=i32 l to i32 r do ls := i :: !ls done;!ls |> List.rev\n let cartesian_product u v = u |> List.map (fun p -> List.map (fun q -> p,q) v) |> List.flatten\n let shuffle a = Array.sort (fun _ _ -> (Random.int 3) -$ 1) a\n let binary_search ng ok f = let d = if ng < ok then 1L else -1L in\n let rec f0 ng ok =\n if labs (ok - ng) <= 1L then ok\n else let mid = ng + (ok - ng) / 2L in if f mid then f0 ng mid else f0 mid ok\n in f0 (ng-1L*d) (ok+1L*d)\n let lower_bound a v = binary_search 0L (alen a - 1L) (fun i -> a.(i32 i) >= v)\n let upper_bound a v = binary_search 0L (alen a - 1L) (fun i -> a.(i32 i) > v)\n let equal_range a v = lower_bound a v, upper_bound a v (* #=snd-fst *)\n let rec fix f x = f (fix f) x\n let fix_memo ?(size=10000) f x =\n let tb = Hashtbl.create ~random:true size in\n let rec f0 x =\n try Hashtbl.find tb x with\n | Not_found -> (let v = f f0 x in Hashtbl.add tb x v; v)\n in f0 x\n (* imperative *)\n let rep f t ?(stride=1L) fbod = let i = ref f in while !i <= t do fbod !i; i := !i + stride done\n let repb f t ?(stride=1L) fbod = let i,c = ref f,ref true in while !i <= t && !c do\n match fbod !i with | `Break -> c := false | `Ok -> i := !i + stride done\n let repm f t ?(stride=1L) m0 fbod =\n let i,c,m = ref f,ref true,ref m0 in\n while !i<=t && !c do match fbod !m !i with\n | `Break -> c := false | `Break_m m' -> (c := false; m := m') | `Ok m' -> m := m'; i := !i + stride done; !m\n let repi f t ?(stride=1) fbod = let i = ref f in while !i <= t do fbod !i; i := !i +$ stride done\n let repib f t ?(stride=1) fbod = let i,c = ref f,ref true in while !i <= t && !c do\n match fbod !i with | `Break -> c := false | `Ok -> i := !i +$ stride done\n let repim f t ?(stride=1) m0 fbod =\n let i,c,m = ref f,ref true,ref m0 in\n while !i<=t && !c do match fbod !m !i with\n | `Break -> c := false | `Break_m m' -> (c := false; m := m') | `Ok m' -> m := m'; i := !i +$ stride done; !m\n let rep_rev f t ?(stride=1L) fbod = rep t f ~stride @@ fun v -> fbod @@ f + t - v\n let repb_rev f t ?(stride=1L) fbod = repb t f ~stride @@ fun v -> fbod @@ f + t - v\n let repm_rev f t ?(stride=1L) m0 fbod = repm f t ~stride m0 @@ fun u v -> fbod u @@ f + t - v\n let repi_rev f t ?(stride=1) fbod = repi t f ~stride @@ fun v -> fbod @@ f +$ t -$ v\n let repib_rev f t ?(stride=1) fbod = repib t f ~stride @@ fun v -> fbod @@ f +$ t -$ v\n let repim_rev f t ?(stride=1) m0 fbod = repim f t ~stride m0 @@ fun u v -> fbod u @@ f +$ t -$ v\n (* output *)\n let print_list_mle f ls = string_of_list f ls |> print_endline\n let print_array_mle f a = string_of_array f a |> print_endline\n let print_list f ls = ls |> List.iter (fun v -> printf \"%s \" @@ f v); print_newline ()\n let print_array f a = a |> Array.iter (fun v -> printf \"%s \" @@ f v); print_newline ()\n (* debug *)\n let dump_2darr f a = a |> Array.iter (fun b -> print_array f b)\n let dump_i64_list ls = print_list ist ls\n let dump_i64_array a = print_array ist a\nend open Lib open Array\nlet powers n limit =\n let rec f0 i r =\n if i>limit then r\n else f0 (i*n) (i::r)\n in f0 1L []\nlet upper_bound a v = binary_search 0L (alen a - 1L) (fun i -> a.(i32 i) > v)\nlet equal_range a v = lower_bound a v, upper_bound a v (* #=snd-fst *)\nmodule IMap = Map.Make(Int64)\nmodule HT = Hashtbl\nlet () =\n let n = gi 0 in let a = iia n in\n sort compare a;\n (* print_array ist a; *)\n let used = make (i32 n) false in\n let mx = a.(0) + a.(i32 n-$1) in\n (* printf \"%Ld\\n\" mx; *)\n let pows = powers 2L mx in\n let res = ref 0L in\n let mp = HT.create ~random:true 100000 in\n iter (fun v ->\n HT.add mp v (1L + try HT.find mp v with _ -> 0L)\n ) a;\n List.iter (fun pw ->\n (* printf \"%Ld: \\n\" pw; *)\n iteri (fun i v ->\n (* let j = equal_range 0L (alen a-1L) (fun i ->\n v + a.(i32 i) = pw\n ) in *)\n try\n let w = pw-v in\n let cv,cw = HT.find mp v,HT.find mp w in\n (* printf \"%Ld: %Ld; %Ld: %Ld\\n\" v cv w cw; *)\n if v<>w && cv > 0L && cw > 0L then (\n if cv=1L then HT.remove mp v\n else HT.add mp v (HT.find mp v - 1L);\n if cw=1L then HT.remove mp (pw-v)\n else HT.add mp v (HT.find mp (pw-v) - 1L);\n res += 1L;\n ) else if v=w && cv>=2L then (\n if cv=2L then HT.remove mp v\n else HT.add mp v (HT.find mp v - 2L);\n res += 1L\n )\n with Not_found -> ();\n\n (* let jf,jt = equal_range a (pw-v) in\n let f = ref true in\n rep jf jt (fun j ->\n if !f && i<>i32 j && 0L <= j && j <= alen a-1L\n && not used.(i) && not used.(i32 j)\n && v + a.(i32 j) = pw then (\n used.(i) <- true;\n used.(i32 j) <- true;\n res += 1L;\n (* printf \" %d,%d\\n\" i @@ i32 j; *)\n f := false\n )\n ); *)\n (* print_array string_of_bool used; *)\n ) a\n ) pows;\n printf \"%Ld\\n\" !res\n\n\n\n\n\n\n\n\n\n", "language": "OCaml", "metadata": {"date": 1544934565, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03201.html", "problem_id": "p03201", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03201/input.txt", "sample_output_relpath": "derived/input_output/data/p03201/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03201/OCaml/s221354891.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s221354891", "user_id": "u481480055"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "open Printf open Scanf\nmodule Lib = struct\n let i32,i64,ist = Int64.(to_int,of_int,to_string)\n let (+$) = (+) let (-$) = (-) let (/$) = (/) let ( *$) = ( * ) let (%$) = (mod)\n let labs = Int64.abs\n let (+),(-),( * ),(/),(mod),(%) = Int64.(add,sub,mul,div,rem,rem)\n let (+=) r v = r := !r + v\n let (-=) r v = r := !r - v\n let ( *= ) r v = r := !r * v\n let (/=) r v = r := !r / v\n let (%=) r v = r := !r % v\n let max_i64,min_i64 = Int64.(max_int,min_int)\n (* math *)\n let ceildiv p q = (p+q-1L) / q\n let rec gcd m n = match m,n with | m,0L -> m | m,n -> gcd n (m mod n)\n let lcm m n = m / gcd m n * n\n module Int64_infix = struct\n let (land),(lor),(lxor),lnot,(lsl),(lsr),(asr) =\n let open Int64 in\n (logand),(logor),(logxor),lognot,\n (fun u v -> shift_left u (i32 v)),\n (fun u v -> shift_right u (i32 v)),\n (fun u v -> shift_right_logical u (i32 v))\n end\n let pow n k =\n let rec f a n = function\n | 0L -> a | 1L -> n*a | k when k mod 2L = 0L -> f a (n*n) (k/2L) | k -> f (a*n) (n*n) (k/2L)\n in f 1L n k\n (* input *)\n let input_i64_array n = Array.init (i32 n) (fun _ -> Scanf.scanf \" %Ld\" (fun v -> v)) let iia = input_i64_array\n let get_i64 _ = Scanf.scanf \" %Ld\" (fun v -> v) let gi = get_i64\n let get_2_i64 _ = Scanf.scanf \" %Ld %Ld\" (fun u v -> u,v) let g2 = get_2_i64\n let get_3_i64 _ = Scanf.scanf \" %Ld %Ld %Ld\" (fun u v w -> u,v,w) let g3 = get_3_i64\n let get_4_i64 _ = Scanf.scanf \" %Ld %Ld %Ld %Ld\" (fun u v w x -> u,v,w,x) let g4 = get_4_i64\n let get_5_i64 _ = Scanf.scanf \" %Ld %Ld %Ld %Ld %Ld\" (fun u v w x y -> u,v,w,x,y) let g5 = get_5_i64\n let i32_get_int _ = Scanf.scanf \" %d\" (fun v -> v) let i32_get_2_ints _ = Scanf.scanf \" %d %d\" (fun u v -> u,v) let i32_get_3_ints _ = Scanf.scanf \" %d %d %d\" (fun u v w -> u,v,w) let i32_get_4_ints _ = Scanf.scanf \" %d %d %d %d\" (fun u v w x -> u,v,w,x) let i32_get_5_ints _ = Scanf.scanf \" %d %d %d %d %d\" (fun u v w x y -> u,v,w,x,y)\n (* utils *)\n external id : 'a -> 'a = \"%identity\"\n let ( *< ) f g x = f (g x)\n let ( *> ) f g x = g (f x)\n let rv f p q = f q p (* ex. 24 |> rv (/) 6 *)\n let alen a = i64 @@ Array.length a\n let llen l = i64 @@ List.length l\n let string_of_list ?(separator=\" \") f ls = ls |> List.map f |> String.concat separator\n let string_of_array ?(separator=\" \") f a = a |> Array.to_list |> string_of_list ~separator f\n let char_list_of_string str = let rec f0 i a = if i<0 then a else f0 (i-$1) (str.[i]::a) in f0 (String.length str -$ 1) []\n let string_of_char_list ls = List.fold_left (fun u v -> u ^ (String.make 1 v)) \"\" ls\n let fail _ = failwith \"fail\"\n let dx,dy = [|1;0;-1;0|],[|0;1;0;-1|]\n let range l r = let ls = ref [] in for i=i32 l to i32 r do ls := i :: !ls done;!ls |> List.rev\n let cartesian_product u v = u |> List.map (fun p -> List.map (fun q -> p,q) v) |> List.flatten\n let shuffle a = Array.sort (fun _ _ -> (Random.int 3) -$ 1) a\n let binary_search ng ok f = let d = if ng < ok then 1L else -1L in\n let rec f0 ng ok =\n if labs (ok - ng) <= 1L then ok\n else let mid = ng + (ok - ng) / 2L in if f mid then f0 ng mid else f0 mid ok\n in f0 (ng-1L*d) (ok+1L*d)\n let lower_bound a v = binary_search 0L (alen a - 1L) (fun i -> a.(i32 i) >= v)\n let upper_bound a v = binary_search 0L (alen a - 1L) (fun i -> a.(i32 i) > v)\n let equal_range a v = lower_bound a v, upper_bound a v (* #=snd-fst *)\n let rec fix f x = f (fix f) x\n let fix_memo ?(size=10000) f x =\n let tb = Hashtbl.create ~random:true size in\n let rec f0 x =\n try Hashtbl.find tb x with\n | Not_found -> (let v = f f0 x in Hashtbl.add tb x v; v)\n in f0 x\n (* imperative *)\n let rep f t ?(stride=1L) fbod = let i = ref f in while !i <= t do fbod !i; i := !i + stride done\n let repb f t ?(stride=1L) fbod = let i,c = ref f,ref true in while !i <= t && !c do\n match fbod !i with | `Break -> c := false | `Ok -> i := !i + stride done\n let repm f t ?(stride=1L) m0 fbod =\n let i,c,m = ref f,ref true,ref m0 in\n while !i<=t && !c do match fbod !m !i with\n | `Break -> c := false | `Break_m m' -> (c := false; m := m') | `Ok m' -> m := m'; i := !i + stride done; !m\n let repi f t ?(stride=1) fbod = let i = ref f in while !i <= t do fbod !i; i := !i +$ stride done\n let repib f t ?(stride=1) fbod = let i,c = ref f,ref true in while !i <= t && !c do\n match fbod !i with | `Break -> c := false | `Ok -> i := !i +$ stride done\n let repim f t ?(stride=1) m0 fbod =\n let i,c,m = ref f,ref true,ref m0 in\n while !i<=t && !c do match fbod !m !i with\n | `Break -> c := false | `Break_m m' -> (c := false; m := m') | `Ok m' -> m := m'; i := !i +$ stride done; !m\n let rep_rev f t ?(stride=1L) fbod = rep t f ~stride @@ fun v -> fbod @@ f + t - v\n let repb_rev f t ?(stride=1L) fbod = repb t f ~stride @@ fun v -> fbod @@ f + t - v\n let repm_rev f t ?(stride=1L) m0 fbod = repm f t ~stride m0 @@ fun u v -> fbod u @@ f + t - v\n let repi_rev f t ?(stride=1) fbod = repi t f ~stride @@ fun v -> fbod @@ f +$ t -$ v\n let repib_rev f t ?(stride=1) fbod = repib t f ~stride @@ fun v -> fbod @@ f +$ t -$ v\n let repim_rev f t ?(stride=1) m0 fbod = repim f t ~stride m0 @@ fun u v -> fbod u @@ f +$ t -$ v\n (* output *)\n let print_list_mle f ls = string_of_list f ls |> print_endline\n let print_array_mle f a = string_of_array f a |> print_endline\n let print_list f ls = ls |> List.iter (fun v -> printf \"%s \" @@ f v); print_newline ()\n let print_array f a = a |> Array.iter (fun v -> printf \"%s \" @@ f v); print_newline ()\n (* debug *)\n let dump_2darr f a = a |> Array.iter (fun b -> print_array f b)\n let dump_i64_list ls = print_list ist ls\n let dump_i64_array a = print_array ist a\nend open Lib open Array\nlet powers n limit =\n let rec f0 i r =\n if i>limit then r\n else f0 (i*n) (i::r)\n in f0 1L []\nlet upper_bound a v = binary_search 0L (alen a - 1L) (fun i -> a.(i32 i) > v)\nlet equal_range a v = lower_bound a v, upper_bound a v (* #=snd-fst *)\nmodule IMap = Map.Make(Int64)\nmodule HT = Hashtbl\nlet () =\n let n = gi 0 in let a = iia n in\n sort compare a;\n (* print_array ist a; *)\n let used = make (i32 n) false in\n let mx = a.(0) + a.(i32 n-$1) in\n (* printf \"%Ld\\n\" mx; *)\n let pows = powers 2L mx in\n let res = ref 0L in\n let mp = HT.create ~random:true 100000 in\n iter (fun v ->\n HT.add mp v (1L + try HT.find mp v with _ -> 0L)\n ) a;\n List.iter (fun pw ->\n (* printf \"%Ld: \\n\" pw; *)\n iteri (fun i v ->\n (* let j = equal_range 0L (alen a-1L) (fun i ->\n v + a.(i32 i) = pw\n ) in *)\n try\n let w = pw-v in\n let cv,cw = HT.find mp v,HT.find mp w in\n (* printf \"%Ld: %Ld; %Ld: %Ld\\n\" v cv w cw; *)\n if v<>w && cv > 0L && cw > 0L then (\n if cv=1L then HT.remove mp v\n else HT.add mp v (HT.find mp v - 1L);\n if cw=1L then HT.remove mp (pw-v)\n else HT.add mp v (HT.find mp (pw-v) - 1L);\n res += 1L;\n ) else if v=w && cv>=2L then (\n if cv=2L then HT.remove mp v\n else HT.add mp v (HT.find mp v - 2L);\n res += 1L\n )\n with Not_found -> ();\n\n (* let jf,jt = equal_range a (pw-v) in\n let f = ref true in\n rep jf jt (fun j ->\n if !f && i<>i32 j && 0L <= j && j <= alen a-1L\n && not used.(i) && not used.(i32 j)\n && v + a.(i32 j) = pw then (\n used.(i) <- true;\n used.(i32 j) <- true;\n res += 1L;\n (* printf \" %d,%d\\n\" i @@ i32 j; *)\n f := false\n )\n ); *)\n (* print_array string_of_bool used; *)\n ) a\n ) pows;\n printf \"%Ld\\n\" !res\n\n\n\n\n\n\n\n\n\n", "problem_context": "Score : 600 points\n\nProblem Statement\n\nTakahashi has N balls with positive integers written on them. The integer written on the i-th ball is A_i.\nHe would like to form some number of pairs such that the sum of the integers written on each pair of balls is a power of 2.\nNote that a ball cannot belong to multiple pairs.\nFind the maximum possible number of pairs that can be formed.\n\nHere, a positive integer is said to be a power of 2 when it can be written as 2^t using some non-negative integer t.\n\nConstraints\n\n1 \\leq N \\leq 2\\times 10^5\n\n1 \\leq A_i \\leq 10^9\n\nA_i is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the maximum possible number of pairs such that the sum of the integers written on each pair of balls is a power of 2.\n\nSample Input 1\n\n3\n1 2 3\n\nSample Output 1\n\n1\n\nWe can form one pair whose sum of the written numbers is 4 by pairing the first and third balls.\nNote that we cannot pair the second ball with itself.\n\nSample Input 2\n\n5\n3 11 14 5 13\n\nSample Output 2\n\n2", "sample_input": "3\n1 2 3\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03201", "source_text": "Score : 600 points\n\nProblem Statement\n\nTakahashi has N balls with positive integers written on them. The integer written on the i-th ball is A_i.\nHe would like to form some number of pairs such that the sum of the integers written on each pair of balls is a power of 2.\nNote that a ball cannot belong to multiple pairs.\nFind the maximum possible number of pairs that can be formed.\n\nHere, a positive integer is said to be a power of 2 when it can be written as 2^t using some non-negative integer t.\n\nConstraints\n\n1 \\leq N \\leq 2\\times 10^5\n\n1 \\leq A_i \\leq 10^9\n\nA_i is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the maximum possible number of pairs such that the sum of the integers written on each pair of balls is a power of 2.\n\nSample Input 1\n\n3\n1 2 3\n\nSample Output 1\n\n1\n\nWe can form one pair whose sum of the written numbers is 4 by pairing the first and third balls.\nNote that we cannot pair the second ball with itself.\n\nSample Input 2\n\n5\n3 11 14 5 13\n\nSample Output 2\n\n2", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 7612, "cpu_time_ms": 2107, "memory_kb": 145528}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s327874051", "group_id": "codeNet:p03207", "input_text": "open Printf\nopen Scanf\n\nlet (++) = Int64.add\nlet (--) = Int64.sub\nlet ( ** ) = Int64.mul\nlet (//) = Int64.div\nlet (%%) = Int64.rem\nlet landl = Int64.logand\nlet lorl = Int64.logor\nlet lnotl = Int64.lognot\nlet lxorl = Int64.logxor\nlet lsll = Int64.shift_left\nlet lsrl = Int64.shift_right_logical\nlet long = Int64.of_int\nlet succl = Int64.succ\nlet predl = Int64.pred\n\nlet read_int _ = scanf \" %d \" (fun x -> x)\nlet read_long _ = scanf \" %Ld \" (fun x -> x)\nlet read_str _ = scanf \" %s \" (fun x -> x)\nlet read_double _ = scanf \" %f \" (fun x -> x)\n\nlet m = 1_000_000_007L\n\nlet rec gcd a b = if b = 0L then a else gcd b (a %% b)\n\nlet rec mod_pow a = function\n | 0L -> 1L\n | b -> (if b %% 2L = 0L then 1L else a) ** mod_pow (a ** a %% m) (b//2L) %% m\n\n\nlet () =\n let n = read_int () in\n let p = Array.init n read_int in\n Array.sort compare p;\n p.(n-1) <- p.(n-1) / 2;\n let total = Array.fold_left ( + ) 0 p in\n printf \"%d\\n\" total\n", "language": "OCaml", "metadata": {"date": 1558752594, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03207.html", "problem_id": "p03207", "resource_group": "low_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/OCaml/s327874051.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s327874051", "user_id": "u806601169"}, "prompt_components": {"gold_output": "15950\n", "input_to_evaluate": "open Printf\nopen Scanf\n\nlet (++) = Int64.add\nlet (--) = Int64.sub\nlet ( ** ) = Int64.mul\nlet (//) = Int64.div\nlet (%%) = Int64.rem\nlet landl = Int64.logand\nlet lorl = Int64.logor\nlet lnotl = Int64.lognot\nlet lxorl = Int64.logxor\nlet lsll = Int64.shift_left\nlet lsrl = Int64.shift_right_logical\nlet long = Int64.of_int\nlet succl = Int64.succ\nlet predl = Int64.pred\n\nlet read_int _ = scanf \" %d \" (fun x -> x)\nlet read_long _ = scanf \" %Ld \" (fun x -> x)\nlet read_str _ = scanf \" %s \" (fun x -> x)\nlet read_double _ = scanf \" %f \" (fun x -> x)\n\nlet m = 1_000_000_007L\n\nlet rec gcd a b = if b = 0L then a else gcd b (a %% b)\n\nlet rec mod_pow a = function\n | 0L -> 1L\n | b -> (if b %% 2L = 0L then 1L else a) ** mod_pow (a ** a %% m) (b//2L) %% m\n\n\nlet () =\n let n = read_int () in\n let p = Array.init n read_int in\n Array.sort compare p;\n p.(n-1) <- p.(n-1) / 2;\n let total = Array.fold_left ( + ) 0 p in\n printf \"%d\\n\" total\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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 931, "cpu_time_ms": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s845304463", "group_id": "codeNet:p03207", "input_text": "let () = Scanf.scanf \"%d\\n\" @@ fun n ->\n let ps = Array.init n @@ fun _ -> Scanf.scanf \"%d\\n\" @@ fun p -> p in\n Printf.printf \"%d\\n\" @@\n Array.fold_left ( + ) 0 ps - (Array.fold_left max min_int ps + 1) / 2\n", "language": "OCaml", "metadata": {"date": 1544321686, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03207.html", "problem_id": "p03207", "resource_group": "low_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/OCaml/s845304463.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s845304463", "user_id": "u504158101"}, "prompt_components": {"gold_output": "15950\n", "input_to_evaluate": "let () = Scanf.scanf \"%d\\n\" @@ fun n ->\n let ps = Array.init n @@ fun _ -> Scanf.scanf \"%d\\n\" @@ fun p -> p in\n Printf.printf \"%d\\n\" @@\n Array.fold_left ( + ) 0 ps - (Array.fold_left max min_int ps + 1) / 2\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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 210, "cpu_time_ms": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s697188779", "group_id": "codeNet:p03208", "input_text": "Scanf.scanf \"%d %d\" (fun n k ->\n let h = Array.init n (fun _ -> Scanf.scanf \" %d\" (fun a -> a)) in\n Array.sort compare h;\n\n let rec loop i acc =\n if i + k > n then acc else\n loop (i + 1) (min acc (h.(i + k - 1) - h.(i)))\n in\n loop 0 max_int |> Printf.printf \"%d\\n\"\n)", "language": "OCaml", "metadata": {"date": 1595217106, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p03208.html", "problem_id": "p03208", "resource_group": "low_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/OCaml/s697188779.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s697188779", "user_id": "u342443598"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "Scanf.scanf \"%d %d\" (fun n k ->\n let h = Array.init n (fun _ -> Scanf.scanf \" %d\" (fun a -> a)) in\n Array.sort compare h;\n\n let rec loop i acc =\n if i + k > n then acc else\n loop (i + 1) (min acc (h.(i + k - 1) - h.(i)))\n in\n loop 0 max_int |> Printf.printf \"%d\\n\"\n)", "problem_context": "Score : 300 points\n\nProblem Statement\n\nIn some other world, today is Christmas Eve.\n\nThere are N trees planted in Mr. Takaha's garden. The height of the i-th tree (1 \\leq i \\leq N) is h_i meters.\n\nHe decides to choose K trees from these trees and decorate them with electric lights. To make the scenery more beautiful, the heights of the decorated trees should be as close to each other as possible.\n\nMore specifically, let the height of the tallest decorated tree be h_{max} meters, and the height of the shortest decorated tree be h_{min} meters. The smaller the value h_{max} - h_{min} is, the better. What is the minimum possible value of h_{max} - h_{min}?\n\nConstraints\n\n2 \\leq K < N \\leq 10^5\n\n1 \\leq h_i \\leq 10^9\n\nh_i is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nh_1\nh_2\n:\nh_N\n\nOutput\n\nPrint the minimum possible value of h_{max} - h_{min}.\n\nSample Input 1\n\n5 3\n10\n15\n11\n14\n12\n\nSample Output 1\n\n2\n\nIf we decorate the first, third and fifth trees, h_{max} = 12, h_{min} = 10 so h_{max} - h_{min} = 2. This is optimal.\n\nSample Input 2\n\n5 3\n5\n7\n5\n7\n7\n\nSample Output 2\n\n0\n\nIf we decorate the second, fourth and fifth trees, h_{max} = 7, h_{min} = 7 so h_{max} - h_{min} = 0. This is optimal.\n\nThere are not too many trees in these sample inputs, but note that there can be at most one hundred thousand trees (we just can't put a sample with a hundred thousand lines here).", "sample_input": "5 3\n10\n15\n11\n14\n12\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03208", "source_text": "Score : 300 points\n\nProblem Statement\n\nIn some other world, today is Christmas Eve.\n\nThere are N trees planted in Mr. Takaha's garden. The height of the i-th tree (1 \\leq i \\leq N) is h_i meters.\n\nHe decides to choose K trees from these trees and decorate them with electric lights. To make the scenery more beautiful, the heights of the decorated trees should be as close to each other as possible.\n\nMore specifically, let the height of the tallest decorated tree be h_{max} meters, and the height of the shortest decorated tree be h_{min} meters. The smaller the value h_{max} - h_{min} is, the better. What is the minimum possible value of h_{max} - h_{min}?\n\nConstraints\n\n2 \\leq K < N \\leq 10^5\n\n1 \\leq h_i \\leq 10^9\n\nh_i is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nh_1\nh_2\n:\nh_N\n\nOutput\n\nPrint the minimum possible value of h_{max} - h_{min}.\n\nSample Input 1\n\n5 3\n10\n15\n11\n14\n12\n\nSample Output 1\n\n2\n\nIf we decorate the first, third and fifth trees, h_{max} = 12, h_{min} = 10 so h_{max} - h_{min} = 2. This is optimal.\n\nSample Input 2\n\n5 3\n5\n7\n5\n7\n7\n\nSample Output 2\n\n0\n\nIf we decorate the second, fourth and fifth trees, h_{max} = 7, h_{min} = 7 so h_{max} - h_{min} = 0. This is optimal.\n\nThere are not too many trees in these sample inputs, but note that there can be at most one hundred thousand trees (we just can't put a sample with a hundred thousand lines here).", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 6736}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s422854801", "group_id": "codeNet:p03208", "input_text": "open Printf open Scanf\nmodule Lib = struct\n let i32,i64,ist = Int64.(to_int,of_int,to_string)\n let (+$) = (+) let (-$) = (-) let (/$) = (/) let ( *$) = ( * ) let (%$) = (mod)\n let labs = Int64.abs\n let (+),(-),( * ),(/),(mod),(%) = Int64.(add,sub,mul,div,rem,rem)\n let (+=) r v = r := !r + v\n let (-=) r v = r := !r - v\n let ( *= ) r v = r := !r * v\n let (/=) r v = r := !r / v\n let (%=) r v = r := !r % v\n let max_i64,min_i64 = Int64.(max_int,min_int)\n (* math *)\n let ceildiv p q = (p+q-1L) / q\n let rec gcd m n = match m,n with | m,0L -> m | m,n -> gcd n (m mod n)\n let lcm m n = m / gcd m n * n\n module Int64_infix = struct\n let (land),(lor),(lxor),lnot,(lsl),(lsr),(asr) =\n let open Int64 in\n (logand),(logor),(logxor),lognot,\n (fun u v -> shift_left u (i32 v)),\n (fun u v -> shift_right u (i32 v)),\n (fun u v -> shift_right_logical u (i32 v))\n end\n let pow n k =\n let rec f a n = function\n | 0L -> a | 1L -> n*a | k when k mod 2L = 0L -> f a (n*n) (k/2L) | k -> f (a*n) (n*n) (k/2L)\n in f 1L n k\n (* input *)\n let input_i64_array n = Array.init (i32 n) (fun _ -> Scanf.scanf \" %Ld\" (fun v -> v))\n let get_i64 _ = Scanf.scanf \" %Ld\" (fun v -> v)\n let get_2_i64 _ = Scanf.scanf \" %Ld %Ld\" (fun u v -> u,v)\n let get_3_i64 _ = Scanf.scanf \" %Ld %Ld %Ld\" (fun u v w -> u,v,w)\n let get_4_i64 _ = Scanf.scanf \" %Ld %Ld %Ld %Ld\" (fun u v w x -> u,v,w,x)\n let get_5_i64 _ = Scanf.scanf \" %Ld %Ld %Ld %Ld %Ld\" (fun u v w x y -> u,v,w,x,y)\n let i32_get_int _ = Scanf.scanf \" %d\" (fun v -> v) let i32_get_2_ints _ = Scanf.scanf \" %d %d\" (fun u v -> u,v) let i32_get_3_ints _ = Scanf.scanf \" %d %d %d\" (fun u v w -> u,v,w) let i32_get_4_ints _ = Scanf.scanf \" %d %d %d %d\" (fun u v w x -> u,v,w,x) let i32_get_5_ints _ = Scanf.scanf \" %d %d %d %d %d\" (fun u v w x y -> u,v,w,x,y)\n (* utils *)\n external id : 'a -> 'a = \"%identity\"\n let ( *< ) f g x = f (g x)\n let ( *> ) f g x = g (f x)\n let rv f p q = f q p (* ex. 24 |> rv (/) 6 *)\n let alen a = i64 @@ Array.length a\n let llen l = i64 @@ List.length l\n let string_of_list ?(separator=\" \") f ls = ls |> List.map f |> String.concat separator\n let string_of_array ?(separator=\" \") f a = a |> Array.to_list |> string_of_list ~separator f\n let char_list_of_string str = let rec f0 i a = if i<0 then a else f0 (i-$1) (str.[i]::a) in f0 (String.length str -$ 1) []\n let string_of_char_list ls = List.fold_left (fun u v -> u ^ (String.make 1 v)) \"\" ls\n let fail _ = failwith \"fail\"\n let dx,dy = [|1;0;-1;0|],[|0;1;0;-1|]\n let range l r = let ls = ref [] in for i=i32 l to i32 r do ls := i :: !ls done;!ls |> List.rev\n let cartesian_product u v = u |> List.map (fun p -> List.map (fun q -> p,q) v) |> List.flatten\n let shuffle a = Array.sort (fun _ _ -> (Random.int 3) -$ 1) a\n let binary_search ng ok f = let d = if ng < ok then 1L else -1L in\n let rec f0 ng ok =\n if labs (ok - ng) <= 1L then ok\n else let mid = ng + (ok - ng) / 2L in if f mid then f0 ng mid else f0 mid ok\n in f0 (ng-1L*d) (ok+1L*d)\n let lower_bound a v = binary_search 0L (alen a - 1L) (fun i -> a.(i32 i) >= v)\n let upper_bound a v = binary_search 0L (alen a - 1L) (fun i -> a.(i32 i) > v)\n let equal_range a v = lower_bound a v, upper_bound a v (* #=snd-fst *)\n let rec fix f x = f (fix f) x\n let fix_memo ?(size=10000) f x =\n let tb = Hashtbl.create ~random:true size in\n let rec f0 x =\n try Hashtbl.find tb x with\n | Not_found -> (let v = f f0 x in Hashtbl.add tb x v; v)\n in f0 x\n (* imperative *)\n let rep f t ?(stride=1L) fbod = let i = ref f in while !i <= t do fbod !i; i := !i + stride done\n let repb f t ?(stride=1L) fbod = let i,c = ref f,ref true in while !i <= t && !c do\n match fbod !i with | `Break -> c := false | `Ok -> i := !i + stride done\n let repm f t ?(stride=1L) m0 fbod =\n let i,c,m = ref f,ref true,ref m0 in\n while !i<=t && !c do match fbod !m !i with\n | `Break -> c := false | `Break_m m' -> (c := false; m := m') | `Ok m' -> m := m'; i := !i + stride done; !m\n let repi f t ?(stride=1) fbod = let i = ref f in while !i <= t do fbod !i; i := !i +$ stride done\n let repib f t ?(stride=1) fbod = let i,c = ref f,ref true in while !i <= t && !c do\n match fbod !i with | `Break -> c := false | `Ok -> i := !i +$ stride done\n let repim f t ?(stride=1) m0 fbod =\n let i,c,m = ref f,ref true,ref m0 in\n while !i<=t && !c do match fbod !m !i with\n | `Break -> c := false | `Break_m m' -> (c := false; m := m') | `Ok m' -> m := m'; i := !i +$ stride done; !m\n let rep_rev f t ?(stride=1L) fbod = rep t f ~stride @@ fun v -> fbod @@ f + t - v\n let repb_rev f t ?(stride=1L) fbod = repb t f ~stride @@ fun v -> fbod @@ f + t - v\n let repm_rev f t ?(stride=1L) m0 fbod = repm f t ~stride m0 @@ fun u v -> fbod u @@ f + t - v\n let repi_rev f t ?(stride=1) fbod = repi t f ~stride @@ fun v -> fbod @@ f +$ t -$ v\n let repib_rev f t ?(stride=1) fbod = repib t f ~stride @@ fun v -> fbod @@ f +$ t -$ v\n let repim_rev f t ?(stride=1) m0 fbod = repim f t ~stride m0 @@ fun u v -> fbod u @@ f +$ t -$ v\n (* output *)\n let print_list_mle f ls = string_of_list f ls |> print_endline\n let print_array_mle f a = string_of_array f a |> print_endline\n let print_list f ls = ls |> List.iter (fun v -> printf \"%s \" @@ f v); print_newline ()\n let print_array f a = a |> Array.iter (fun v -> printf \"%s \" @@ f v); print_newline ()\n (* debug *)\n let dump_2darr f a = a |> Array.iter (fun b -> print_array f b)\n let dump_i64_list ls = print_list ist ls\n let dump_i64_array a = print_array ist a\nend open Lib open Array\n\nlet () =\n let n,k = get_2_i64 0 in\n let h = input_i64_array n in\n sort compare h;\n let n,k = i32 n,i32 k in\n let res = ref Int64.max_int in\n repi 0 (n-$k-$0) (fun i ->\n let l,r = h.(i),h.(i+$k-$1) in\n (* printf \" %Ld,%Ld\\n\" l r; *)\n if r-l < !res then res := r-l;\n );\n printf \"%Ld\\n\" @@ !res\n\n\n\n\n\n\n\n\n", "language": "OCaml", "metadata": {"date": 1544321967, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03208.html", "problem_id": "p03208", "resource_group": "low_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/OCaml/s422854801.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s422854801", "user_id": "u481480055"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "open Printf open Scanf\nmodule Lib = struct\n let i32,i64,ist = Int64.(to_int,of_int,to_string)\n let (+$) = (+) let (-$) = (-) let (/$) = (/) let ( *$) = ( * ) let (%$) = (mod)\n let labs = Int64.abs\n let (+),(-),( * ),(/),(mod),(%) = Int64.(add,sub,mul,div,rem,rem)\n let (+=) r v = r := !r + v\n let (-=) r v = r := !r - v\n let ( *= ) r v = r := !r * v\n let (/=) r v = r := !r / v\n let (%=) r v = r := !r % v\n let max_i64,min_i64 = Int64.(max_int,min_int)\n (* math *)\n let ceildiv p q = (p+q-1L) / q\n let rec gcd m n = match m,n with | m,0L -> m | m,n -> gcd n (m mod n)\n let lcm m n = m / gcd m n * n\n module Int64_infix = struct\n let (land),(lor),(lxor),lnot,(lsl),(lsr),(asr) =\n let open Int64 in\n (logand),(logor),(logxor),lognot,\n (fun u v -> shift_left u (i32 v)),\n (fun u v -> shift_right u (i32 v)),\n (fun u v -> shift_right_logical u (i32 v))\n end\n let pow n k =\n let rec f a n = function\n | 0L -> a | 1L -> n*a | k when k mod 2L = 0L -> f a (n*n) (k/2L) | k -> f (a*n) (n*n) (k/2L)\n in f 1L n k\n (* input *)\n let input_i64_array n = Array.init (i32 n) (fun _ -> Scanf.scanf \" %Ld\" (fun v -> v))\n let get_i64 _ = Scanf.scanf \" %Ld\" (fun v -> v)\n let get_2_i64 _ = Scanf.scanf \" %Ld %Ld\" (fun u v -> u,v)\n let get_3_i64 _ = Scanf.scanf \" %Ld %Ld %Ld\" (fun u v w -> u,v,w)\n let get_4_i64 _ = Scanf.scanf \" %Ld %Ld %Ld %Ld\" (fun u v w x -> u,v,w,x)\n let get_5_i64 _ = Scanf.scanf \" %Ld %Ld %Ld %Ld %Ld\" (fun u v w x y -> u,v,w,x,y)\n let i32_get_int _ = Scanf.scanf \" %d\" (fun v -> v) let i32_get_2_ints _ = Scanf.scanf \" %d %d\" (fun u v -> u,v) let i32_get_3_ints _ = Scanf.scanf \" %d %d %d\" (fun u v w -> u,v,w) let i32_get_4_ints _ = Scanf.scanf \" %d %d %d %d\" (fun u v w x -> u,v,w,x) let i32_get_5_ints _ = Scanf.scanf \" %d %d %d %d %d\" (fun u v w x y -> u,v,w,x,y)\n (* utils *)\n external id : 'a -> 'a = \"%identity\"\n let ( *< ) f g x = f (g x)\n let ( *> ) f g x = g (f x)\n let rv f p q = f q p (* ex. 24 |> rv (/) 6 *)\n let alen a = i64 @@ Array.length a\n let llen l = i64 @@ List.length l\n let string_of_list ?(separator=\" \") f ls = ls |> List.map f |> String.concat separator\n let string_of_array ?(separator=\" \") f a = a |> Array.to_list |> string_of_list ~separator f\n let char_list_of_string str = let rec f0 i a = if i<0 then a else f0 (i-$1) (str.[i]::a) in f0 (String.length str -$ 1) []\n let string_of_char_list ls = List.fold_left (fun u v -> u ^ (String.make 1 v)) \"\" ls\n let fail _ = failwith \"fail\"\n let dx,dy = [|1;0;-1;0|],[|0;1;0;-1|]\n let range l r = let ls = ref [] in for i=i32 l to i32 r do ls := i :: !ls done;!ls |> List.rev\n let cartesian_product u v = u |> List.map (fun p -> List.map (fun q -> p,q) v) |> List.flatten\n let shuffle a = Array.sort (fun _ _ -> (Random.int 3) -$ 1) a\n let binary_search ng ok f = let d = if ng < ok then 1L else -1L in\n let rec f0 ng ok =\n if labs (ok - ng) <= 1L then ok\n else let mid = ng + (ok - ng) / 2L in if f mid then f0 ng mid else f0 mid ok\n in f0 (ng-1L*d) (ok+1L*d)\n let lower_bound a v = binary_search 0L (alen a - 1L) (fun i -> a.(i32 i) >= v)\n let upper_bound a v = binary_search 0L (alen a - 1L) (fun i -> a.(i32 i) > v)\n let equal_range a v = lower_bound a v, upper_bound a v (* #=snd-fst *)\n let rec fix f x = f (fix f) x\n let fix_memo ?(size=10000) f x =\n let tb = Hashtbl.create ~random:true size in\n let rec f0 x =\n try Hashtbl.find tb x with\n | Not_found -> (let v = f f0 x in Hashtbl.add tb x v; v)\n in f0 x\n (* imperative *)\n let rep f t ?(stride=1L) fbod = let i = ref f in while !i <= t do fbod !i; i := !i + stride done\n let repb f t ?(stride=1L) fbod = let i,c = ref f,ref true in while !i <= t && !c do\n match fbod !i with | `Break -> c := false | `Ok -> i := !i + stride done\n let repm f t ?(stride=1L) m0 fbod =\n let i,c,m = ref f,ref true,ref m0 in\n while !i<=t && !c do match fbod !m !i with\n | `Break -> c := false | `Break_m m' -> (c := false; m := m') | `Ok m' -> m := m'; i := !i + stride done; !m\n let repi f t ?(stride=1) fbod = let i = ref f in while !i <= t do fbod !i; i := !i +$ stride done\n let repib f t ?(stride=1) fbod = let i,c = ref f,ref true in while !i <= t && !c do\n match fbod !i with | `Break -> c := false | `Ok -> i := !i +$ stride done\n let repim f t ?(stride=1) m0 fbod =\n let i,c,m = ref f,ref true,ref m0 in\n while !i<=t && !c do match fbod !m !i with\n | `Break -> c := false | `Break_m m' -> (c := false; m := m') | `Ok m' -> m := m'; i := !i +$ stride done; !m\n let rep_rev f t ?(stride=1L) fbod = rep t f ~stride @@ fun v -> fbod @@ f + t - v\n let repb_rev f t ?(stride=1L) fbod = repb t f ~stride @@ fun v -> fbod @@ f + t - v\n let repm_rev f t ?(stride=1L) m0 fbod = repm f t ~stride m0 @@ fun u v -> fbod u @@ f + t - v\n let repi_rev f t ?(stride=1) fbod = repi t f ~stride @@ fun v -> fbod @@ f +$ t -$ v\n let repib_rev f t ?(stride=1) fbod = repib t f ~stride @@ fun v -> fbod @@ f +$ t -$ v\n let repim_rev f t ?(stride=1) m0 fbod = repim f t ~stride m0 @@ fun u v -> fbod u @@ f +$ t -$ v\n (* output *)\n let print_list_mle f ls = string_of_list f ls |> print_endline\n let print_array_mle f a = string_of_array f a |> print_endline\n let print_list f ls = ls |> List.iter (fun v -> printf \"%s \" @@ f v); print_newline ()\n let print_array f a = a |> Array.iter (fun v -> printf \"%s \" @@ f v); print_newline ()\n (* debug *)\n let dump_2darr f a = a |> Array.iter (fun b -> print_array f b)\n let dump_i64_list ls = print_list ist ls\n let dump_i64_array a = print_array ist a\nend open Lib open Array\n\nlet () =\n let n,k = get_2_i64 0 in\n let h = input_i64_array n in\n sort compare h;\n let n,k = i32 n,i32 k in\n let res = ref Int64.max_int in\n repi 0 (n-$k-$0) (fun i ->\n let l,r = h.(i),h.(i+$k-$1) in\n (* printf \" %Ld,%Ld\\n\" l r; *)\n if r-l < !res then res := r-l;\n );\n printf \"%Ld\\n\" @@ !res\n\n\n\n\n\n\n\n\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nIn some other world, today is Christmas Eve.\n\nThere are N trees planted in Mr. Takaha's garden. The height of the i-th tree (1 \\leq i \\leq N) is h_i meters.\n\nHe decides to choose K trees from these trees and decorate them with electric lights. To make the scenery more beautiful, the heights of the decorated trees should be as close to each other as possible.\n\nMore specifically, let the height of the tallest decorated tree be h_{max} meters, and the height of the shortest decorated tree be h_{min} meters. The smaller the value h_{max} - h_{min} is, the better. What is the minimum possible value of h_{max} - h_{min}?\n\nConstraints\n\n2 \\leq K < N \\leq 10^5\n\n1 \\leq h_i \\leq 10^9\n\nh_i is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nh_1\nh_2\n:\nh_N\n\nOutput\n\nPrint the minimum possible value of h_{max} - h_{min}.\n\nSample Input 1\n\n5 3\n10\n15\n11\n14\n12\n\nSample Output 1\n\n2\n\nIf we decorate the first, third and fifth trees, h_{max} = 12, h_{min} = 10 so h_{max} - h_{min} = 2. This is optimal.\n\nSample Input 2\n\n5 3\n5\n7\n5\n7\n7\n\nSample Output 2\n\n0\n\nIf we decorate the second, fourth and fifth trees, h_{max} = 7, h_{min} = 7 so h_{max} - h_{min} = 0. This is optimal.\n\nThere are not too many trees in these sample inputs, but note that there can be at most one hundred thousand trees (we just can't put a sample with a hundred thousand lines here).", "sample_input": "5 3\n10\n15\n11\n14\n12\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03208", "source_text": "Score : 300 points\n\nProblem Statement\n\nIn some other world, today is Christmas Eve.\n\nThere are N trees planted in Mr. Takaha's garden. The height of the i-th tree (1 \\leq i \\leq N) is h_i meters.\n\nHe decides to choose K trees from these trees and decorate them with electric lights. To make the scenery more beautiful, the heights of the decorated trees should be as close to each other as possible.\n\nMore specifically, let the height of the tallest decorated tree be h_{max} meters, and the height of the shortest decorated tree be h_{min} meters. The smaller the value h_{max} - h_{min} is, the better. What is the minimum possible value of h_{max} - h_{min}?\n\nConstraints\n\n2 \\leq K < N \\leq 10^5\n\n1 \\leq h_i \\leq 10^9\n\nh_i is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nh_1\nh_2\n:\nh_N\n\nOutput\n\nPrint the minimum possible value of h_{max} - h_{min}.\n\nSample Input 1\n\n5 3\n10\n15\n11\n14\n12\n\nSample Output 1\n\n2\n\nIf we decorate the first, third and fifth trees, h_{max} = 12, h_{min} = 10 so h_{max} - h_{min} = 2. This is optimal.\n\nSample Input 2\n\n5 3\n5\n7\n5\n7\n7\n\nSample Output 2\n\n0\n\nIf we decorate the second, fourth and fifth trees, h_{max} = 7, h_{min} = 7 so h_{max} - h_{min} = 0. This is optimal.\n\nThere are not too many trees in these sample inputs, but note that there can be at most one hundred thousand trees (we just can't put a sample with a hundred thousand lines here).", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 5912, "cpu_time_ms": 124, "memory_kb": 6528}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s931739989", "group_id": "codeNet:p03209", "input_text": "Scanf.(Array.(\n let n,x=scanf\" %d %d\"@@fun u v->u,v in\n let s,p=make 50 1,make 50 1 in\n init 49 (fun i->\n s.(i+1)<-2*s.(i)+3;\n p.(i+1)<-2*p.(i)+1) |> ignore;\n let rec f lv ofs =\n assert (lv-1>=0);\n let r=s.(lv-1) in\n if ofs=1 then 0\n else if ofs<=1+r then f (lv-1) (ofs-1)\n else if ofs =2+r then 1 + p.(lv-1)\n else if ofs<=2+r+r then 1 + p.(lv-1) + f (lv-1) (ofs-2-r)\n else if ofs =3+r+r then 1 + 2 * p.(lv-1)\n else failwith \"\"\n in print_int @@ f n x\n));;", "language": "OCaml", "metadata": {"date": 1544399148, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03209.html", "problem_id": "p03209", "resource_group": "low_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/OCaml/s931739989.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s931739989", "user_id": "u481480055"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "Scanf.(Array.(\n let n,x=scanf\" %d %d\"@@fun u v->u,v in\n let s,p=make 50 1,make 50 1 in\n init 49 (fun i->\n s.(i+1)<-2*s.(i)+3;\n p.(i+1)<-2*p.(i)+1) |> ignore;\n let rec f lv ofs =\n assert (lv-1>=0);\n let r=s.(lv-1) in\n if ofs=1 then 0\n else if ofs<=1+r then f (lv-1) (ofs-1)\n else if ofs =2+r then 1 + p.(lv-1)\n else if ofs<=2+r+r then 1 + p.(lv-1) + f (lv-1) (ofs-2-r)\n else if ofs =3+r+r then 1 + 2 * p.(lv-1)\n else failwith \"\"\n in print_int @@ f n x\n));;", "problem_context": "Score : 400 points\n\nProblem Statement\n\nIn some other world, today is Christmas.\n\nMr. Takaha decides to make a multi-dimensional burger in his party. A level-L burger (L is an integer greater than or equal to 0) is the following thing:\n\nA level-0 burger is a patty.\n\nA level-L burger (L \\geq 1) is a bun, a level-(L-1) burger, a patty, another level-(L-1) burger and another bun, stacked vertically in this order from the bottom.\n\nFor example, a level-1 burger and a level-2 burger look like BPPPB and BBPPPBPBPPPBB (rotated 90 degrees), where B and P stands for a bun and a patty.\n\nThe burger Mr. Takaha will make is a level-N burger. Lunlun the Dachshund will eat X layers from the bottom of this burger (a layer is a patty or a bun). How many patties will she eat?\n\nConstraints\n\n1 \\leq N \\leq 50\n\n1 \\leq X \\leq ( the total number of layers in a level-N burger )\n\nN and X are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN X\n\nOutput\n\nPrint the number of patties in the bottom-most X layers from the bottom of a level-N burger.\n\nSample Input 1\n\n2 7\n\nSample Output 1\n\n4\n\nThere are 4 patties in the bottom-most 7 layers of a level-2 burger (BBPPPBPBPPPBB).\n\nSample Input 2\n\n1 1\n\nSample Output 2\n\n0\n\nThe bottom-most layer of a level-1 burger is a bun.\n\nSample Input 3\n\n50 4321098765432109\n\nSample Output 3\n\n2160549382716056\n\nA level-50 burger is rather thick, to the extent that the number of its layers does not fit into a 32-bit integer.", "sample_input": "2 7\n"}, "reference_outputs": ["4\n"], "source_document_id": "p03209", "source_text": "Score : 400 points\n\nProblem Statement\n\nIn some other world, today is Christmas.\n\nMr. Takaha decides to make a multi-dimensional burger in his party. A level-L burger (L is an integer greater than or equal to 0) is the following thing:\n\nA level-0 burger is a patty.\n\nA level-L burger (L \\geq 1) is a bun, a level-(L-1) burger, a patty, another level-(L-1) burger and another bun, stacked vertically in this order from the bottom.\n\nFor example, a level-1 burger and a level-2 burger look like BPPPB and BBPPPBPBPPPBB (rotated 90 degrees), where B and P stands for a bun and a patty.\n\nThe burger Mr. Takaha will make is a level-N burger. Lunlun the Dachshund will eat X layers from the bottom of this burger (a layer is a patty or a bun). How many patties will she eat?\n\nConstraints\n\n1 \\leq N \\leq 50\n\n1 \\leq X \\leq ( the total number of layers in a level-N burger )\n\nN and X are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN X\n\nOutput\n\nPrint the number of patties in the bottom-most X layers from the bottom of a level-N burger.\n\nSample Input 1\n\n2 7\n\nSample Output 1\n\n4\n\nThere are 4 patties in the bottom-most 7 layers of a level-2 burger (BBPPPBPBPPPBB).\n\nSample Input 2\n\n1 1\n\nSample Output 2\n\n0\n\nThe bottom-most layer of a level-1 burger is a bun.\n\nSample Input 3\n\n50 4321098765432109\n\nSample Output 3\n\n2160549382716056\n\nA level-50 burger is rather thick, to the extent that the number of its layers does not fit into a 32-bit integer.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 494, "cpu_time_ms": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s423338897", "group_id": "codeNet:p03210", "input_text": "open Printf open Scanf\nmodule Lib = struct\n let i32,i64,ist = Int64.(to_int,of_int,to_string)\n let (+$) = (+) let (-$) = (-) let (/$) = (/) let ( *$) = ( * ) let (%$) = (mod)\n let labs = Int64.abs\n let (+),(-),( * ),(/),(mod),(%) = Int64.(add,sub,mul,div,rem,rem)\n let (+=) r v = r := !r + v\n let (-=) r v = r := !r - v\n let ( *= ) r v = r := !r * v\n let (/=) r v = r := !r / v\n let (%=) r v = r := !r % v\n let max_i64,min_i64 = Int64.(max_int,min_int)\n (* math *)\n let ceildiv p q = (p+q-1L) / q\n let rec gcd m n = match m,n with | m,0L -> m | m,n -> gcd n (m mod n)\n let lcm m n = m / gcd m n * n\n module I64_infix = struct\n let (land),(lor),(lxor),lnot,(lsl),(lsr),(asr) =\n let open Int64 in\n (logand),(logor),(logxor),lognot,\n (fun u v -> shift_left u (i32 v)),\n (fun u v -> shift_right u (i32 v)),\n (fun u v -> shift_right_logical u (i32 v))\n end\n (* input *)\n let input_i64_array n = Array.init (i32 n) (fun _ -> Scanf.scanf \" %Ld\" (fun v -> v))\n let get_i64 _ = Scanf.scanf \" %Ld\" (fun v -> v)\n let get_2_i64 _ = Scanf.scanf \" %Ld %Ld\" (fun u v -> u,v)\n let get_3_i64 _ = Scanf.scanf \" %Ld %Ld %Ld\" (fun u v w -> u,v,w)\n let get_4_i64 _ = Scanf.scanf \" %Ld %Ld %Ld %Ld\" (fun u v w x -> u,v,w,x)\n let get_5_i64 _ = Scanf.scanf \" %Ld %Ld %Ld %Ld %Ld\" (fun u v w x y -> u,v,w,x,y)\n let i32_get_int _ = Scanf.scanf \" %d\" (fun v -> v) let i32_get_2_ints _ = Scanf.scanf \" %d %d\" (fun u v -> u,v) let i32_get_3_ints _ = Scanf.scanf \" %d %d %d\" (fun u v w -> u,v,w) let i32_get_4_ints _ = Scanf.scanf \" %d %d %d %d\" (fun u v w x -> u,v,w,x) let i32_get_5_ints _ = Scanf.scanf \" %d %d %d %d %d\" (fun u v w x y -> u,v,w,x,y)\n (* utils *)\n external id : 'a -> 'a = \"%identity\"\n let ( *< ) f g x = f (g x)\n let ( *> ) f g x = g (f x)\n let rv f p q = f q p (* ex. 24 |> rv (/) 6 *)\n let alen a = i64 @@ Array.length a\n let llen l = i64 @@ List.length l\n let string_of_list ?(separator=\" \") f ls = ls |> List.map f |> String.concat separator\n let string_of_array ?(separator=\" \") f a = a |> Array.to_list |> string_of_list ~separator f\n let char_list_of_string str = let rec f0 i a = if i<0 then a else f0 (i-$1) (str.[i]::a) in f0 (String.length str -$ 1) []\n let string_of_char_list ls = List.fold_left (fun u v -> u ^ (String.make 1 v)) \"\" ls\n let fail _ = failwith \"fail\"\n let dx,dy = [|1;0;-1;0|],[|0;1;0;-1|]\n let range l r = let ls = ref [] in for i=i32 l to i32 r do ls := i :: !ls done;!ls |> List.rev\n let cartesian_product u v = u |> List.map (fun p -> List.map (fun q -> p,q) v) |> List.flatten\n let shuffle a = Array.sort (fun _ _ -> (Random.int 3) -$ 1) a\n let binary_search ng ok f = let d = if ng < ok then 1L else -1L in\n let rec f0 ng ok =\n if labs (ok - ng) <= 1L then ok\n else let mid = ng + (ok - ng) / 2L in if f mid then f0 ng mid else f0 mid ok\n in f0 (ng-1L*d) (ok+1L*d)\n let lower_bound a v = binary_search 0L (alen a - 1L) (fun i -> a.(i32 i) >= v)\n let upper_bound a v = binary_search 0L (alen a - 1L) (fun i -> a.(i32 i) > v)\n let equal_range a v = lower_bound a v, upper_bound a v (* #=snd-fst *)\n let rec fix f x = f (fix f) x\n let fix_memo ?(size=10000) f x =\n let tb = Hashtbl.create ~random:true size in\n let rec f0 x =\n try Hashtbl.find tb x with\n | Not_found -> (let v = f f0 x in Hashtbl.add tb x v; v)\n in f0 x\n (* imperative *)\n let rep f t ?(stride=1L) fbod = let i = ref f in while !i <= t do fbod !i; i := !i + stride done\n let repb f t ?(stride=1L) fbod = let i,c = ref f,ref true in while !i <= t && !c do\n match fbod !i with | `Break -> c := false | `Ok -> i := !i + stride done\n let repm f t ?(stride=1L) m0 fbod =\n let i,c,m = ref f,ref true,ref m0 in\n while !i<=t && !c do match fbod !m !i with\n | `Break -> c := false | `Break_m m' -> (c := false; m := m') | `Ok m' -> m := m'; i := !i + stride done; !m\n let repi f t ?(stride=1) fbod = let i = ref f in while !i <= t do fbod !i; i := !i +$ stride done\n let repib f t ?(stride=1) fbod = let i,c = ref f,ref true in while !i <= t && !c do\n match fbod !i with | `Break -> c := false | `Ok -> i := !i +$ stride done\n let repim f t ?(stride=1) m0 fbod =\n let i,c,m = ref f,ref true,ref m0 in\n while !i<=t && !c do match fbod !m !i with\n | `Break -> c := false | `Break_m m' -> (c := false; m := m') | `Ok m' -> m := m'; i := !i +$ stride done; !m\n let rep_rev f t ?(stride=1L) fbod = rep t f ~stride @@ fun v -> fbod @@ f + t - v\n let repb_rev f t ?(stride=1L) fbod = repb t f ~stride @@ fun v -> fbod @@ f + t - v\n let repm_rev f t ?(stride=1L) m0 fbod = repm f t ~stride m0 @@ fun u v -> fbod u @@ f + t - v\n let repi_rev f t ?(stride=1) fbod = repi t f ~stride @@ fun v -> fbod @@ f +$ t -$ v\n let repib_rev f t ?(stride=1) fbod = repib t f ~stride @@ fun v -> fbod @@ f +$ t -$ v\n let repim_rev f t ?(stride=1) m0 fbod = repim f t ~stride m0 @@ fun u v -> fbod u @@ f +$ t -$ v\n (* output *)\n let print_list_mle f ls = string_of_list f ls |> print_endline\n let print_array_mle f a = string_of_array f a |> print_endline\n let print_list f ls = ls |> List.iter (fun v -> printf \"%s \" @@ f v); print_newline ()\n let print_array f a = a |> Array.iter (fun v -> printf \"%s \" @@ f v); print_newline ()\n (* debug *)\n let dump_2darr f a = a |> Array.iter (fun b -> print_array f b)\n let dump_i64_list ls = print_list ist ls\n let dump_i64_array a = print_array ist a\nend open Lib open Array\n\nlet () =\n let n = get_i64 0 in\n printf @@ if n=3L || n=5L || n=7L then \"YES\" else \"NO\"\n\n\n\n\n\n\n\n\n", "language": "OCaml", "metadata": {"date": 1543805603, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03210.html", "problem_id": "p03210", "resource_group": "low_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/OCaml/s423338897.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s423338897", "user_id": "u481480055"}, "prompt_components": {"gold_output": "YES\n", "input_to_evaluate": "open Printf open Scanf\nmodule Lib = struct\n let i32,i64,ist = Int64.(to_int,of_int,to_string)\n let (+$) = (+) let (-$) = (-) let (/$) = (/) let ( *$) = ( * ) let (%$) = (mod)\n let labs = Int64.abs\n let (+),(-),( * ),(/),(mod),(%) = Int64.(add,sub,mul,div,rem,rem)\n let (+=) r v = r := !r + v\n let (-=) r v = r := !r - v\n let ( *= ) r v = r := !r * v\n let (/=) r v = r := !r / v\n let (%=) r v = r := !r % v\n let max_i64,min_i64 = Int64.(max_int,min_int)\n (* math *)\n let ceildiv p q = (p+q-1L) / q\n let rec gcd m n = match m,n with | m,0L -> m | m,n -> gcd n (m mod n)\n let lcm m n = m / gcd m n * n\n module I64_infix = struct\n let (land),(lor),(lxor),lnot,(lsl),(lsr),(asr) =\n let open Int64 in\n (logand),(logor),(logxor),lognot,\n (fun u v -> shift_left u (i32 v)),\n (fun u v -> shift_right u (i32 v)),\n (fun u v -> shift_right_logical u (i32 v))\n end\n (* input *)\n let input_i64_array n = Array.init (i32 n) (fun _ -> Scanf.scanf \" %Ld\" (fun v -> v))\n let get_i64 _ = Scanf.scanf \" %Ld\" (fun v -> v)\n let get_2_i64 _ = Scanf.scanf \" %Ld %Ld\" (fun u v -> u,v)\n let get_3_i64 _ = Scanf.scanf \" %Ld %Ld %Ld\" (fun u v w -> u,v,w)\n let get_4_i64 _ = Scanf.scanf \" %Ld %Ld %Ld %Ld\" (fun u v w x -> u,v,w,x)\n let get_5_i64 _ = Scanf.scanf \" %Ld %Ld %Ld %Ld %Ld\" (fun u v w x y -> u,v,w,x,y)\n let i32_get_int _ = Scanf.scanf \" %d\" (fun v -> v) let i32_get_2_ints _ = Scanf.scanf \" %d %d\" (fun u v -> u,v) let i32_get_3_ints _ = Scanf.scanf \" %d %d %d\" (fun u v w -> u,v,w) let i32_get_4_ints _ = Scanf.scanf \" %d %d %d %d\" (fun u v w x -> u,v,w,x) let i32_get_5_ints _ = Scanf.scanf \" %d %d %d %d %d\" (fun u v w x y -> u,v,w,x,y)\n (* utils *)\n external id : 'a -> 'a = \"%identity\"\n let ( *< ) f g x = f (g x)\n let ( *> ) f g x = g (f x)\n let rv f p q = f q p (* ex. 24 |> rv (/) 6 *)\n let alen a = i64 @@ Array.length a\n let llen l = i64 @@ List.length l\n let string_of_list ?(separator=\" \") f ls = ls |> List.map f |> String.concat separator\n let string_of_array ?(separator=\" \") f a = a |> Array.to_list |> string_of_list ~separator f\n let char_list_of_string str = let rec f0 i a = if i<0 then a else f0 (i-$1) (str.[i]::a) in f0 (String.length str -$ 1) []\n let string_of_char_list ls = List.fold_left (fun u v -> u ^ (String.make 1 v)) \"\" ls\n let fail _ = failwith \"fail\"\n let dx,dy = [|1;0;-1;0|],[|0;1;0;-1|]\n let range l r = let ls = ref [] in for i=i32 l to i32 r do ls := i :: !ls done;!ls |> List.rev\n let cartesian_product u v = u |> List.map (fun p -> List.map (fun q -> p,q) v) |> List.flatten\n let shuffle a = Array.sort (fun _ _ -> (Random.int 3) -$ 1) a\n let binary_search ng ok f = let d = if ng < ok then 1L else -1L in\n let rec f0 ng ok =\n if labs (ok - ng) <= 1L then ok\n else let mid = ng + (ok - ng) / 2L in if f mid then f0 ng mid else f0 mid ok\n in f0 (ng-1L*d) (ok+1L*d)\n let lower_bound a v = binary_search 0L (alen a - 1L) (fun i -> a.(i32 i) >= v)\n let upper_bound a v = binary_search 0L (alen a - 1L) (fun i -> a.(i32 i) > v)\n let equal_range a v = lower_bound a v, upper_bound a v (* #=snd-fst *)\n let rec fix f x = f (fix f) x\n let fix_memo ?(size=10000) f x =\n let tb = Hashtbl.create ~random:true size in\n let rec f0 x =\n try Hashtbl.find tb x with\n | Not_found -> (let v = f f0 x in Hashtbl.add tb x v; v)\n in f0 x\n (* imperative *)\n let rep f t ?(stride=1L) fbod = let i = ref f in while !i <= t do fbod !i; i := !i + stride done\n let repb f t ?(stride=1L) fbod = let i,c = ref f,ref true in while !i <= t && !c do\n match fbod !i with | `Break -> c := false | `Ok -> i := !i + stride done\n let repm f t ?(stride=1L) m0 fbod =\n let i,c,m = ref f,ref true,ref m0 in\n while !i<=t && !c do match fbod !m !i with\n | `Break -> c := false | `Break_m m' -> (c := false; m := m') | `Ok m' -> m := m'; i := !i + stride done; !m\n let repi f t ?(stride=1) fbod = let i = ref f in while !i <= t do fbod !i; i := !i +$ stride done\n let repib f t ?(stride=1) fbod = let i,c = ref f,ref true in while !i <= t && !c do\n match fbod !i with | `Break -> c := false | `Ok -> i := !i +$ stride done\n let repim f t ?(stride=1) m0 fbod =\n let i,c,m = ref f,ref true,ref m0 in\n while !i<=t && !c do match fbod !m !i with\n | `Break -> c := false | `Break_m m' -> (c := false; m := m') | `Ok m' -> m := m'; i := !i +$ stride done; !m\n let rep_rev f t ?(stride=1L) fbod = rep t f ~stride @@ fun v -> fbod @@ f + t - v\n let repb_rev f t ?(stride=1L) fbod = repb t f ~stride @@ fun v -> fbod @@ f + t - v\n let repm_rev f t ?(stride=1L) m0 fbod = repm f t ~stride m0 @@ fun u v -> fbod u @@ f + t - v\n let repi_rev f t ?(stride=1) fbod = repi t f ~stride @@ fun v -> fbod @@ f +$ t -$ v\n let repib_rev f t ?(stride=1) fbod = repib t f ~stride @@ fun v -> fbod @@ f +$ t -$ v\n let repim_rev f t ?(stride=1) m0 fbod = repim f t ~stride m0 @@ fun u v -> fbod u @@ f +$ t -$ v\n (* output *)\n let print_list_mle f ls = string_of_list f ls |> print_endline\n let print_array_mle f a = string_of_array f a |> print_endline\n let print_list f ls = ls |> List.iter (fun v -> printf \"%s \" @@ f v); print_newline ()\n let print_array f a = a |> Array.iter (fun v -> printf \"%s \" @@ f v); print_newline ()\n (* debug *)\n let dump_2darr f a = a |> Array.iter (fun b -> print_array f b)\n let dump_i64_list ls = print_list ist ls\n let dump_i64_array a = print_array ist a\nend open Lib open Array\n\nlet () =\n let n = get_i64 0 in\n printf @@ if n=3L || n=5L || n=7L then \"YES\" else \"NO\"\n\n\n\n\n\n\n\n\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nShichi-Go-San (literally \"Seven-Five-Three\") is a traditional event in a certain country to celebrate the growth of seven-, five- and three-year-old children.\n\nTakahashi is now X years old. Will his growth be celebrated in Shichi-Go-San this time?\n\nConstraints\n\n1 ≤ X ≤ 9\n\nX is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX\n\nOutput\n\nIf Takahashi's growth will be celebrated, print YES; if it will not, print NO.\n\nSample Input 1\n\n5\n\nSample Output 1\n\nYES\n\nThe growth of a five-year-old child will be celebrated.\n\nSample Input 2\n\n6\n\nSample Output 2\n\nNO\n\nSee you next year.", "sample_input": "5\n"}, "reference_outputs": ["YES\n"], "source_document_id": "p03210", "source_text": "Score : 100 points\n\nProblem Statement\n\nShichi-Go-San (literally \"Seven-Five-Three\") is a traditional event in a certain country to celebrate the growth of seven-, five- and three-year-old children.\n\nTakahashi is now X years old. Will his growth be celebrated in Shichi-Go-San this time?\n\nConstraints\n\n1 ≤ X ≤ 9\n\nX is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX\n\nOutput\n\nIf Takahashi's growth will be celebrated, print YES; if it will not, print NO.\n\nSample Input 1\n\n5\n\nSample Output 1\n\nYES\n\nThe growth of a five-year-old child will be celebrated.\n\nSample Input 2\n\n6\n\nSample Output 2\n\nNO\n\nSee you next year.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 5530, "cpu_time_ms": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s215205507", "group_id": "codeNet:p03210", "input_text": "open Printf open Scanf\nmodule Lib = struct\n let i32,i64,ist = Int64.(to_int,of_int,to_string)\n let (+$) = (+) let (-$) = (-) let (/$) = (/) let ( *$) = ( * ) let (%$) = (mod)\n let labs = Int64.abs\n let (+),(-),( * ),(/),(mod),(%) = Int64.(add,sub,mul,div,rem,rem)\n let (+=) r v = r := !r + v\n let (-=) r v = r := !r - v\n let ( *= ) r v = r := !r * v\n let (/=) r v = r := !r / v\n let (%=) r v = r := !r % v\n let max_i64,min_i64 = Int64.(max_int,min_int)\n (* math *)\n let ceildiv p q = (p+q-1L) / q\n let rec gcd m n = match m,n with | m,0L -> m | m,n -> gcd n (m mod n)\n let lcm m n = m / gcd m n * n\n module I64_infix = struct\n let (land),(lor),(lxor),lnot,(lsl),(lsr),(asr) =\n let open Int64 in\n (logand),(logor),(logxor),lognot,\n (fun u v -> shift_left u (i32 v)),\n (fun u v -> shift_right u (i32 v)),\n (fun u v -> shift_right_logical u (i32 v))\n end\n (* input *)\n let input_i64_array n = Array.init (i32 n) (fun _ -> Scanf.scanf \" %Ld\" (fun v -> v))\n let get_i64 _ = Scanf.scanf \" %Ld\" (fun v -> v)\n let get_2_i64 _ = Scanf.scanf \" %Ld %Ld\" (fun u v -> u,v)\n let get_3_i64 _ = Scanf.scanf \" %Ld %Ld %Ld\" (fun u v w -> u,v,w)\n let get_4_i64 _ = Scanf.scanf \" %Ld %Ld %Ld %Ld\" (fun u v w x -> u,v,w,x)\n let get_5_i64 _ = Scanf.scanf \" %Ld %Ld %Ld %Ld %Ld\" (fun u v w x y -> u,v,w,x,y)\n let i32_get_int _ = Scanf.scanf \" %d\" (fun v -> v) let i32_get_2_ints _ = Scanf.scanf \" %d %d\" (fun u v -> u,v) let i32_get_3_ints _ = Scanf.scanf \" %d %d %d\" (fun u v w -> u,v,w) let i32_get_4_ints _ = Scanf.scanf \" %d %d %d %d\" (fun u v w x -> u,v,w,x) let i32_get_5_ints _ = Scanf.scanf \" %d %d %d %d %d\" (fun u v w x y -> u,v,w,x,y)\n (* utils *)\n external id : 'a -> 'a = \"%identity\"\n let ( *< ) f g x = f (g x)\n let ( *> ) f g x = g (f x)\n let rv f p q = f q p (* ex. 24 |> rv (/) 6 *)\n let alen a = i64 @@ Array.length a\n let llen l = i64 @@ List.length l\n let string_of_list ?(separator=\" \") f ls = ls |> List.map f |> String.concat separator\n let string_of_array ?(separator=\" \") f a = a |> Array.to_list |> string_of_list ~separator f\n let char_list_of_string str = let rec f0 i a = if i<0 then a else f0 (i-$1) (str.[i]::a) in f0 (String.length str -$ 1) []\n let string_of_char_list ls = List.fold_left (fun u v -> u ^ (String.make 1 v)) \"\" ls\n let fail _ = failwith \"fail\"\n let dx,dy = [|1;0;-1;0|],[|0;1;0;-1|]\n let range l r = let ls = ref [] in for i=i32 l to i32 r do ls := i :: !ls done;!ls |> List.rev\n let cartesian_product u v = u |> List.map (fun p -> List.map (fun q -> p,q) v) |> List.flatten\n let shuffle a = Array.sort (fun _ _ -> (Random.int 3) -$ 1) a\n let binary_search ng ok f = let d = if ng < ok then 1L else -1L in\n let rec f0 ng ok =\n if labs (ok - ng) <= 1L then ok\n else let mid = ng + (ok - ng) / 2L in if f mid then f0 ng mid else f0 mid ok\n in f0 (ng-1L*d) (ok+1L*d)\n let lower_bound a v = binary_search 0L (alen a - 1L) (fun i -> a.(i32 i) >= v)\n let upper_bound a v = binary_search 0L (alen a - 1L) (fun i -> a.(i32 i) > v)\n let equal_range a v = lower_bound a v, upper_bound a v (* #=snd-fst *)\n let rec fix f x = f (fix f) x\n let fix_memo ?(size=10000) f x =\n let tb = Hashtbl.create ~random:true size in\n let rec f0 x =\n try Hashtbl.find tb x with\n | Not_found -> (let v = f f0 x in Hashtbl.add tb x v; v)\n in f0 x\n (* imperative *)\n let rep f t ?(stride=1L) fbod = let i = ref f in while !i <= t do fbod !i; i := !i + stride done\n let repb f t ?(stride=1L) fbod = let i,c = ref f,ref true in while !i <= t && !c do\n match fbod !i with | `Break -> c := false | `Ok -> i := !i + stride done\n let repm f t ?(stride=1L) m0 fbod =\n let i,c,m = ref f,ref true,ref m0 in\n while !i<=t && !c do match fbod !m !i with\n | `Break -> c := false | `Break_m m' -> (c := false; m := m') | `Ok m' -> m := m'; i := !i + stride done; !m\n let repi f t ?(stride=1) fbod = let i = ref f in while !i <= t do fbod !i; i := !i +$ stride done\n let repib f t ?(stride=1) fbod = let i,c = ref f,ref true in while !i <= t && !c do\n match fbod !i with | `Break -> c := false | `Ok -> i := !i +$ stride done\n let repim f t ?(stride=1) m0 fbod =\n let i,c,m = ref f,ref true,ref m0 in\n while !i<=t && !c do match fbod !m !i with\n | `Break -> c := false | `Break_m m' -> (c := false; m := m') | `Ok m' -> m := m'; i := !i +$ stride done; !m\n let rep_rev f t ?(stride=1L) fbod = rep t f ~stride @@ fun v -> fbod @@ f + t - v\n let repb_rev f t ?(stride=1L) fbod = repb t f ~stride @@ fun v -> fbod @@ f + t - v\n let repm_rev f t ?(stride=1L) m0 fbod = repm f t ~stride m0 @@ fun u v -> fbod u @@ f + t - v\n let repi_rev f t ?(stride=1) fbod = repi t f ~stride @@ fun v -> fbod @@ f +$ t -$ v\n let repib_rev f t ?(stride=1) fbod = repib t f ~stride @@ fun v -> fbod @@ f +$ t -$ v\n let repim_rev f t ?(stride=1) m0 fbod = repim f t ~stride m0 @@ fun u v -> fbod u @@ f +$ t -$ v\n (* output *)\n let print_list_mle f ls = string_of_list f ls |> print_endline\n let print_array_mle f a = string_of_array f a |> print_endline\n let print_list f ls = ls |> List.iter (fun v -> printf \"%s \" @@ f v); print_newline ()\n let print_array f a = a |> Array.iter (fun v -> printf \"%s \" @@ f v); print_newline ()\n (* debug *)\n let dump_2darr f a = a |> Array.iter (fun b -> print_array f b)\n let dump_i64_list ls = print_list ist ls\n let dump_i64_array a = print_array ist a\nend open Lib open Array\n\nlet () =\n let n = get_i64 0 in\n printf @@ if n=3L || n=5L || n=11L then \"YES\" else \"NO\"\n\n\n\n\n\n\n\n\n", "language": "OCaml", "metadata": {"date": 1543805142, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03210.html", "problem_id": "p03210", "resource_group": "low_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/OCaml/s215205507.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s215205507", "user_id": "u481480055"}, "prompt_components": {"gold_output": "YES\n", "input_to_evaluate": "open Printf open Scanf\nmodule Lib = struct\n let i32,i64,ist = Int64.(to_int,of_int,to_string)\n let (+$) = (+) let (-$) = (-) let (/$) = (/) let ( *$) = ( * ) let (%$) = (mod)\n let labs = Int64.abs\n let (+),(-),( * ),(/),(mod),(%) = Int64.(add,sub,mul,div,rem,rem)\n let (+=) r v = r := !r + v\n let (-=) r v = r := !r - v\n let ( *= ) r v = r := !r * v\n let (/=) r v = r := !r / v\n let (%=) r v = r := !r % v\n let max_i64,min_i64 = Int64.(max_int,min_int)\n (* math *)\n let ceildiv p q = (p+q-1L) / q\n let rec gcd m n = match m,n with | m,0L -> m | m,n -> gcd n (m mod n)\n let lcm m n = m / gcd m n * n\n module I64_infix = struct\n let (land),(lor),(lxor),lnot,(lsl),(lsr),(asr) =\n let open Int64 in\n (logand),(logor),(logxor),lognot,\n (fun u v -> shift_left u (i32 v)),\n (fun u v -> shift_right u (i32 v)),\n (fun u v -> shift_right_logical u (i32 v))\n end\n (* input *)\n let input_i64_array n = Array.init (i32 n) (fun _ -> Scanf.scanf \" %Ld\" (fun v -> v))\n let get_i64 _ = Scanf.scanf \" %Ld\" (fun v -> v)\n let get_2_i64 _ = Scanf.scanf \" %Ld %Ld\" (fun u v -> u,v)\n let get_3_i64 _ = Scanf.scanf \" %Ld %Ld %Ld\" (fun u v w -> u,v,w)\n let get_4_i64 _ = Scanf.scanf \" %Ld %Ld %Ld %Ld\" (fun u v w x -> u,v,w,x)\n let get_5_i64 _ = Scanf.scanf \" %Ld %Ld %Ld %Ld %Ld\" (fun u v w x y -> u,v,w,x,y)\n let i32_get_int _ = Scanf.scanf \" %d\" (fun v -> v) let i32_get_2_ints _ = Scanf.scanf \" %d %d\" (fun u v -> u,v) let i32_get_3_ints _ = Scanf.scanf \" %d %d %d\" (fun u v w -> u,v,w) let i32_get_4_ints _ = Scanf.scanf \" %d %d %d %d\" (fun u v w x -> u,v,w,x) let i32_get_5_ints _ = Scanf.scanf \" %d %d %d %d %d\" (fun u v w x y -> u,v,w,x,y)\n (* utils *)\n external id : 'a -> 'a = \"%identity\"\n let ( *< ) f g x = f (g x)\n let ( *> ) f g x = g (f x)\n let rv f p q = f q p (* ex. 24 |> rv (/) 6 *)\n let alen a = i64 @@ Array.length a\n let llen l = i64 @@ List.length l\n let string_of_list ?(separator=\" \") f ls = ls |> List.map f |> String.concat separator\n let string_of_array ?(separator=\" \") f a = a |> Array.to_list |> string_of_list ~separator f\n let char_list_of_string str = let rec f0 i a = if i<0 then a else f0 (i-$1) (str.[i]::a) in f0 (String.length str -$ 1) []\n let string_of_char_list ls = List.fold_left (fun u v -> u ^ (String.make 1 v)) \"\" ls\n let fail _ = failwith \"fail\"\n let dx,dy = [|1;0;-1;0|],[|0;1;0;-1|]\n let range l r = let ls = ref [] in for i=i32 l to i32 r do ls := i :: !ls done;!ls |> List.rev\n let cartesian_product u v = u |> List.map (fun p -> List.map (fun q -> p,q) v) |> List.flatten\n let shuffle a = Array.sort (fun _ _ -> (Random.int 3) -$ 1) a\n let binary_search ng ok f = let d = if ng < ok then 1L else -1L in\n let rec f0 ng ok =\n if labs (ok - ng) <= 1L then ok\n else let mid = ng + (ok - ng) / 2L in if f mid then f0 ng mid else f0 mid ok\n in f0 (ng-1L*d) (ok+1L*d)\n let lower_bound a v = binary_search 0L (alen a - 1L) (fun i -> a.(i32 i) >= v)\n let upper_bound a v = binary_search 0L (alen a - 1L) (fun i -> a.(i32 i) > v)\n let equal_range a v = lower_bound a v, upper_bound a v (* #=snd-fst *)\n let rec fix f x = f (fix f) x\n let fix_memo ?(size=10000) f x =\n let tb = Hashtbl.create ~random:true size in\n let rec f0 x =\n try Hashtbl.find tb x with\n | Not_found -> (let v = f f0 x in Hashtbl.add tb x v; v)\n in f0 x\n (* imperative *)\n let rep f t ?(stride=1L) fbod = let i = ref f in while !i <= t do fbod !i; i := !i + stride done\n let repb f t ?(stride=1L) fbod = let i,c = ref f,ref true in while !i <= t && !c do\n match fbod !i with | `Break -> c := false | `Ok -> i := !i + stride done\n let repm f t ?(stride=1L) m0 fbod =\n let i,c,m = ref f,ref true,ref m0 in\n while !i<=t && !c do match fbod !m !i with\n | `Break -> c := false | `Break_m m' -> (c := false; m := m') | `Ok m' -> m := m'; i := !i + stride done; !m\n let repi f t ?(stride=1) fbod = let i = ref f in while !i <= t do fbod !i; i := !i +$ stride done\n let repib f t ?(stride=1) fbod = let i,c = ref f,ref true in while !i <= t && !c do\n match fbod !i with | `Break -> c := false | `Ok -> i := !i +$ stride done\n let repim f t ?(stride=1) m0 fbod =\n let i,c,m = ref f,ref true,ref m0 in\n while !i<=t && !c do match fbod !m !i with\n | `Break -> c := false | `Break_m m' -> (c := false; m := m') | `Ok m' -> m := m'; i := !i +$ stride done; !m\n let rep_rev f t ?(stride=1L) fbod = rep t f ~stride @@ fun v -> fbod @@ f + t - v\n let repb_rev f t ?(stride=1L) fbod = repb t f ~stride @@ fun v -> fbod @@ f + t - v\n let repm_rev f t ?(stride=1L) m0 fbod = repm f t ~stride m0 @@ fun u v -> fbod u @@ f + t - v\n let repi_rev f t ?(stride=1) fbod = repi t f ~stride @@ fun v -> fbod @@ f +$ t -$ v\n let repib_rev f t ?(stride=1) fbod = repib t f ~stride @@ fun v -> fbod @@ f +$ t -$ v\n let repim_rev f t ?(stride=1) m0 fbod = repim f t ~stride m0 @@ fun u v -> fbod u @@ f +$ t -$ v\n (* output *)\n let print_list_mle f ls = string_of_list f ls |> print_endline\n let print_array_mle f a = string_of_array f a |> print_endline\n let print_list f ls = ls |> List.iter (fun v -> printf \"%s \" @@ f v); print_newline ()\n let print_array f a = a |> Array.iter (fun v -> printf \"%s \" @@ f v); print_newline ()\n (* debug *)\n let dump_2darr f a = a |> Array.iter (fun b -> print_array f b)\n let dump_i64_list ls = print_list ist ls\n let dump_i64_array a = print_array ist a\nend open Lib open Array\n\nlet () =\n let n = get_i64 0 in\n printf @@ if n=3L || n=5L || n=11L then \"YES\" else \"NO\"\n\n\n\n\n\n\n\n\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nShichi-Go-San (literally \"Seven-Five-Three\") is a traditional event in a certain country to celebrate the growth of seven-, five- and three-year-old children.\n\nTakahashi is now X years old. Will his growth be celebrated in Shichi-Go-San this time?\n\nConstraints\n\n1 ≤ X ≤ 9\n\nX is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX\n\nOutput\n\nIf Takahashi's growth will be celebrated, print YES; if it will not, print NO.\n\nSample Input 1\n\n5\n\nSample Output 1\n\nYES\n\nThe growth of a five-year-old child will be celebrated.\n\nSample Input 2\n\n6\n\nSample Output 2\n\nNO\n\nSee you next year.", "sample_input": "5\n"}, "reference_outputs": ["YES\n"], "source_document_id": "p03210", "source_text": "Score : 100 points\n\nProblem Statement\n\nShichi-Go-San (literally \"Seven-Five-Three\") is a traditional event in a certain country to celebrate the growth of seven-, five- and three-year-old children.\n\nTakahashi is now X years old. Will his growth be celebrated in Shichi-Go-San this time?\n\nConstraints\n\n1 ≤ X ≤ 9\n\nX is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX\n\nOutput\n\nIf Takahashi's growth will be celebrated, print YES; if it will not, print NO.\n\nSample Input 1\n\n5\n\nSample Output 1\n\nYES\n\nThe growth of a five-year-old child will be celebrated.\n\nSample Input 2\n\n6\n\nSample Output 2\n\nNO\n\nSee you next year.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 5531, "cpu_time_ms": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s602953865", "group_id": "codeNet:p03211", "input_text": "open Batteries\n\nmodule IntSet = Set.Make (struct\n let compare = Pervasives.compare\n\n type t = int\nend)\n\nlet read_two () = Scanf.sscanf (read_line ()) \"%d %d\" (fun a b -> (a, b))\n\nlet read_three () =\n Scanf.sscanf (read_line ()) \"%d %d %d\" (fun a b c -> (a, b, c))\n\nlet read_four () =\n Scanf.sscanf (read_line ()) \"%d %d %d\" (fun a b c d -> (a, b, c, d))\n\nlet read_list () =\n read_line () |> String.split_on_char ' '\n |> List.map (fun s -> int_of_string s)\n\nlet rec read_list_nl n =\n if n = 0 then [] else (read_line () |> int_of_string) :: read_list_nl (n - 1)\n\n(* a**x *)\nlet pow a x =\n let rec aux acc = function 0 -> acc | n -> aux (acc * a) (n - 1) in\n aux 1 x\n\nlet rec pow2 n = if n mod 2 = 0 then 1 + pow2 (n / 2) else 0\n\nlet rec total acc = function [] -> acc | x :: rest -> total (acc + x) rest\n\nlet make_num s i = (s.(i) * 100) + (s.(i + 1) * 10) + s.(i + 2)\n\nlet () =\n let s =\n read_line () |> String.explode\n |> List.map (fun x -> int_of_char x - int_of_char '0')\n |> Array.of_list\n in\n let n = Array.length s in\n let ans = ref 1000 in\n for i = 0 to n - 3 do\n let x = make_num s i in\n ans := min (abs (753 - x)) !ans\n done;\n print_int !ans;\n print_newline ()\n", "language": "OCaml", "metadata": {"date": 1587175413, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03211.html", "problem_id": "p03211", "resource_group": "low_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/OCaml/s602953865.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s602953865", "user_id": "u395620499"}, "prompt_components": {"gold_output": "34\n", "input_to_evaluate": "open Batteries\n\nmodule IntSet = Set.Make (struct\n let compare = Pervasives.compare\n\n type t = int\nend)\n\nlet read_two () = Scanf.sscanf (read_line ()) \"%d %d\" (fun a b -> (a, b))\n\nlet read_three () =\n Scanf.sscanf (read_line ()) \"%d %d %d\" (fun a b c -> (a, b, c))\n\nlet read_four () =\n Scanf.sscanf (read_line ()) \"%d %d %d\" (fun a b c d -> (a, b, c, d))\n\nlet read_list () =\n read_line () |> String.split_on_char ' '\n |> List.map (fun s -> int_of_string s)\n\nlet rec read_list_nl n =\n if n = 0 then [] else (read_line () |> int_of_string) :: read_list_nl (n - 1)\n\n(* a**x *)\nlet pow a x =\n let rec aux acc = function 0 -> acc | n -> aux (acc * a) (n - 1) in\n aux 1 x\n\nlet rec pow2 n = if n mod 2 = 0 then 1 + pow2 (n / 2) else 0\n\nlet rec total acc = function [] -> acc | x :: rest -> total (acc + x) rest\n\nlet make_num s i = (s.(i) * 100) + (s.(i + 1) * 10) + s.(i + 2)\n\nlet () =\n let s =\n read_line () |> String.explode\n |> List.map (fun x -> int_of_char x - int_of_char '0')\n |> Array.of_list\n in\n let n = Array.length s in\n let ans = ref 1000 in\n for i = 0 to n - 3 do\n let x = make_num s i in\n ans := min (abs (753 - x)) !ans\n done;\n print_int !ans;\n print_newline ()\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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1202, "cpu_time_ms": 2, "memory_kb": 3072}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s372116059", "group_id": "codeNet:p03211", "input_text": "let s = read_line ();;\n\nlet rec f i min_diff =\n let min_diff = min min_diff (abs ((int_of_string (String.sub s i 3)) - 753)) in\n if (String.length s) = (i + 3) then\n min_diff\n else (\n let min_diff = min min_diff (abs ((int_of_string (String.sub s i 4)) - 753)) in\n f (i+1) min_diff\n )\n;;\n\nprint_endline (string_of_int (f 0 999999))\n", "language": "OCaml", "metadata": {"date": 1544286565, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03211.html", "problem_id": "p03211", "resource_group": "low_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/OCaml/s372116059.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s372116059", "user_id": "u981708764"}, "prompt_components": {"gold_output": "34\n", "input_to_evaluate": "let s = read_line ();;\n\nlet rec f i min_diff =\n let min_diff = min min_diff (abs ((int_of_string (String.sub s i 3)) - 753)) in\n if (String.length s) = (i + 3) then\n min_diff\n else (\n let min_diff = min min_diff (abs ((int_of_string (String.sub s i 4)) - 753)) in\n f (i+1) min_diff\n )\n;;\n\nprint_endline (string_of_int (f 0 999999))\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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 2, "memory_kb": 4480}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s200527913", "group_id": "codeNet:p03212", "input_text": "let n = read_int ()\nlet f m = let cs = Array.make 8 0 in let rec f n =\n if n = 0 then cs.(3) + cs.(5) + cs.(7) = 3 else (cs.(n mod 10) <- 1; f (n / 10)) in m <= n && f m\nlet rec g m = if m > n then 0 else List.fold_left (fun c k -> c + g (10 * m + k) + if f @@ 10 * m + k then 1 else 0) 0 [3; 5; 7]\nlet _ = g 0 |> Printf.printf \"%d\\n\"", "language": "OCaml", "metadata": {"date": 1567057552, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03212.html", "problem_id": "p03212", "resource_group": "low_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/OCaml/s200527913.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s200527913", "user_id": "u732304692"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "let n = read_int ()\nlet f m = let cs = Array.make 8 0 in let rec f n =\n if n = 0 then cs.(3) + cs.(5) + cs.(7) = 3 else (cs.(n mod 10) <- 1; f (n / 10)) in m <= n && f m\nlet rec g m = if m > n then 0 else List.fold_left (fun c k -> c + g (10 * m + k) + if f @@ 10 * m + k then 1 else 0) 0 [3; 5; 7]\nlet _ = g 0 |> Printf.printf \"%d\\n\"", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou are given an integer N. Among the integers between 1 and N (inclusive), how many Shichi-Go-San numbers (literally \"Seven-Five-Three numbers\") are there?\n\nHere, a Shichi-Go-San number is a positive integer that satisfies the following condition:\n\nWhen the number is written in base ten, each of the digits 7, 5 and 3 appears at least once, and the other digits never appear.\n\nConstraints\n\n1 \\leq N < 10^9\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the number of the Shichi-Go-San numbers between 1 and N (inclusive).\n\nSample Input 1\n\n575\n\nSample Output 1\n\n4\n\nThere are four Shichi-Go-San numbers not greater than 575: 357, 375, 537 and 573.\n\nSample Input 2\n\n3600\n\nSample Output 2\n\n13\n\nThere are 13 Shichi-Go-San numbers not greater than 3600: the above four numbers, 735, 753, 3357, 3375, 3537, 3557, 3573, 3575 and 3577.\n\nSample Input 3\n\n999999999\n\nSample Output 3\n\n26484", "sample_input": "575\n"}, "reference_outputs": ["4\n"], "source_document_id": "p03212", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou are given an integer N. Among the integers between 1 and N (inclusive), how many Shichi-Go-San numbers (literally \"Seven-Five-Three numbers\") are there?\n\nHere, a Shichi-Go-San number is a positive integer that satisfies the following condition:\n\nWhen the number is written in base ten, each of the digits 7, 5 and 3 appears at least once, and the other digits never appear.\n\nConstraints\n\n1 \\leq N < 10^9\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the number of the Shichi-Go-San numbers between 1 and N (inclusive).\n\nSample Input 1\n\n575\n\nSample Output 1\n\n4\n\nThere are four Shichi-Go-San numbers not greater than 575: 357, 375, 537 and 573.\n\nSample Input 2\n\n3600\n\nSample Output 2\n\n13\n\nThere are 13 Shichi-Go-San numbers not greater than 3600: the above four numbers, 735, 753, 3357, 3375, 3537, 3557, 3573, 3575 and 3577.\n\nSample Input 3\n\n999999999\n\nSample Output 3\n\n26484", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 6, "memory_kb": 2560}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s761751486", "group_id": "codeNet:p03212", "input_text": "open Printf open Scanf\nmodule Lib = struct\n let i32,i64,ist = Int64.(to_int,of_int,to_string)\n let (+$) = (+) let (-$) = (-) let (/$) = (/) let ( *$) = ( * ) let (%$) = (mod)\n let labs = Int64.abs\n let (+),(-),( * ),(/),(mod),(%) = Int64.(add,sub,mul,div,rem,rem)\n let (+=) r v = r := !r + v\n let (-=) r v = r := !r - v\n let ( *= ) r v = r := !r * v\n let (/=) r v = r := !r / v\n let (%=) r v = r := !r % v\n let max_i64,min_i64 = Int64.(max_int,min_int)\n (* math *)\n let ceildiv p q = (p+q-1L) / q\n let rec gcd m n = match m,n with | m,0L -> m | m,n -> gcd n (m mod n)\n let lcm m n = m / gcd m n * n\n module I64_infix = struct\n let (land),(lor),(lxor),lnot,(lsl),(lsr),(asr) =\n let open Int64 in\n (logand),(logor),(logxor),lognot,\n (fun u v -> shift_left u (i32 v)),\n (fun u v -> shift_right u (i32 v)),\n (fun u v -> shift_right_logical u (i32 v))\n end\n (* input *)\n let input_i64_array n = Array.init (i32 n) (fun _ -> Scanf.scanf \" %Ld\" (fun v -> v))\n let get_i64 _ = Scanf.scanf \" %Ld\" (fun v -> v)\n let get_2_i64 _ = Scanf.scanf \" %Ld %Ld\" (fun u v -> u,v)\n let get_3_i64 _ = Scanf.scanf \" %Ld %Ld %Ld\" (fun u v w -> u,v,w)\n let get_4_i64 _ = Scanf.scanf \" %Ld %Ld %Ld %Ld\" (fun u v w x -> u,v,w,x)\n let get_5_i64 _ = Scanf.scanf \" %Ld %Ld %Ld %Ld %Ld\" (fun u v w x y -> u,v,w,x,y)\n let i32_get_int _ = Scanf.scanf \" %d\" (fun v -> v) let i32_get_2_ints _ = Scanf.scanf \" %d %d\" (fun u v -> u,v) let i32_get_3_ints _ = Scanf.scanf \" %d %d %d\" (fun u v w -> u,v,w) let i32_get_4_ints _ = Scanf.scanf \" %d %d %d %d\" (fun u v w x -> u,v,w,x) let i32_get_5_ints _ = Scanf.scanf \" %d %d %d %d %d\" (fun u v w x y -> u,v,w,x,y)\n (* utils *)\n external id : 'a -> 'a = \"%identity\"\n let ( *< ) f g x = f (g x)\n let ( *> ) f g x = g (f x)\n let rv f p q = f q p (* ex. 24 |> rv (/) 6 *)\n let alen a = i64 @@ Array.length a\n let llen l = i64 @@ List.length l\n let string_of_list ?(separator=\" \") f ls = ls |> List.map f |> String.concat separator\n let string_of_array ?(separator=\" \") f a = a |> Array.to_list |> string_of_list ~separator f\n let char_list_of_string str = let rec f0 i a = if i<0 then a else f0 (i-$1) (str.[i]::a) in f0 (String.length str -$ 1) []\n let string_of_char_list ls = List.fold_left (fun u v -> u ^ (String.make 1 v)) \"\" ls\n let fail _ = failwith \"fail\"\n let dx,dy = [|1;0;-1;0|],[|0;1;0;-1|]\n let range l r = let ls = ref [] in for i=i32 l to i32 r do ls := i :: !ls done;!ls |> List.rev\n let cartesian_product u v = u |> List.map (fun p -> List.map (fun q -> p,q) v) |> List.flatten\n let shuffle a = Array.sort (fun _ _ -> (Random.int 3) -$ 1) a\n let binary_search ng ok f = let d = if ng < ok then 1L else -1L in\n let rec f0 ng ok =\n if labs (ok - ng) <= 1L then ok\n else let mid = ng + (ok - ng) / 2L in if f mid then f0 ng mid else f0 mid ok\n in f0 (ng-1L*d) (ok+1L*d)\n let lower_bound a v = binary_search 0L (alen a - 1L) (fun i -> a.(i32 i) >= v)\n let upper_bound a v = binary_search 0L (alen a - 1L) (fun i -> a.(i32 i) > v)\n let equal_range a v = lower_bound a v, upper_bound a v (* #=snd-fst *)\n let rec fix f x = f (fix f) x\n let fix_memo ?(size=10000) f x =\n let tb = Hashtbl.create ~random:true size in\n let rec f0 x =\n try Hashtbl.find tb x with\n | Not_found -> (let v = f f0 x in Hashtbl.add tb x v; v)\n in f0 x\n (* imperative *)\n let rep f t ?(stride=1L) fbod = let i = ref f in while !i <= t do fbod !i; i := !i + stride done\n let repb f t ?(stride=1L) fbod = let i,c = ref f,ref true in while !i <= t && !c do\n match fbod !i with | `Break -> c := false | `Ok -> i := !i + stride done\n let repm f t ?(stride=1L) m0 fbod =\n let i,c,m = ref f,ref true,ref m0 in\n while !i<=t && !c do match fbod !m !i with\n | `Break -> c := false | `Break_m m' -> (c := false; m := m') | `Ok m' -> m := m'; i := !i + stride done; !m\n let repi f t ?(stride=1) fbod = let i = ref f in while !i <= t do fbod !i; i := !i +$ stride done\n let repib f t ?(stride=1) fbod = let i,c = ref f,ref true in while !i <= t && !c do\n match fbod !i with | `Break -> c := false | `Ok -> i := !i +$ stride done\n let repim f t ?(stride=1) m0 fbod =\n let i,c,m = ref f,ref true,ref m0 in\n while !i<=t && !c do match fbod !m !i with\n | `Break -> c := false | `Break_m m' -> (c := false; m := m') | `Ok m' -> m := m'; i := !i +$ stride done; !m\n let rep_rev f t ?(stride=1L) fbod = rep t f ~stride @@ fun v -> fbod @@ f + t - v\n let repb_rev f t ?(stride=1L) fbod = repb t f ~stride @@ fun v -> fbod @@ f + t - v\n let repm_rev f t ?(stride=1L) m0 fbod = repm f t ~stride m0 @@ fun u v -> fbod u @@ f + t - v\n let repi_rev f t ?(stride=1) fbod = repi t f ~stride @@ fun v -> fbod @@ f +$ t -$ v\n let repib_rev f t ?(stride=1) fbod = repib t f ~stride @@ fun v -> fbod @@ f +$ t -$ v\n let repim_rev f t ?(stride=1) m0 fbod = repim f t ~stride m0 @@ fun u v -> fbod u @@ f +$ t -$ v\n (* output *)\n let print_list_mle f ls = string_of_list f ls |> print_endline\n let print_array_mle f a = string_of_array f a |> print_endline\n let print_list f ls = ls |> List.iter (fun v -> printf \"%s \" @@ f v); print_newline ()\n let print_array f a = a |> Array.iter (fun v -> printf \"%s \" @@ f v); print_newline ()\n (* debug *)\n let dump_2darr f a = a |> Array.iter (fun b -> print_array f b)\n let dump_i64_list ls = print_list ist ls\n let dump_i64_array a = print_array ist a\nend open Lib open Array\n\nlet () =\n let n = get_i64 0 in\n let res = ref 0L in\n let rec f d a mask =\n if a<=n then (\n if mask=7 then res += 1L;\n f (d+1L) (a*10L+3L) (mask lor 1);\n f (d+1L) (a*10L+5L) (mask lor 2);\n f (d+1L) (a*10L+7L) (mask lor 4);\n )\n in f 0L 0L 0;\n printf \"%Ld\\n\" !res\n", "language": "OCaml", "metadata": {"date": 1543823694, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03212.html", "problem_id": "p03212", "resource_group": "low_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/OCaml/s761751486.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s761751486", "user_id": "u481480055"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "open Printf open Scanf\nmodule Lib = struct\n let i32,i64,ist = Int64.(to_int,of_int,to_string)\n let (+$) = (+) let (-$) = (-) let (/$) = (/) let ( *$) = ( * ) let (%$) = (mod)\n let labs = Int64.abs\n let (+),(-),( * ),(/),(mod),(%) = Int64.(add,sub,mul,div,rem,rem)\n let (+=) r v = r := !r + v\n let (-=) r v = r := !r - v\n let ( *= ) r v = r := !r * v\n let (/=) r v = r := !r / v\n let (%=) r v = r := !r % v\n let max_i64,min_i64 = Int64.(max_int,min_int)\n (* math *)\n let ceildiv p q = (p+q-1L) / q\n let rec gcd m n = match m,n with | m,0L -> m | m,n -> gcd n (m mod n)\n let lcm m n = m / gcd m n * n\n module I64_infix = struct\n let (land),(lor),(lxor),lnot,(lsl),(lsr),(asr) =\n let open Int64 in\n (logand),(logor),(logxor),lognot,\n (fun u v -> shift_left u (i32 v)),\n (fun u v -> shift_right u (i32 v)),\n (fun u v -> shift_right_logical u (i32 v))\n end\n (* input *)\n let input_i64_array n = Array.init (i32 n) (fun _ -> Scanf.scanf \" %Ld\" (fun v -> v))\n let get_i64 _ = Scanf.scanf \" %Ld\" (fun v -> v)\n let get_2_i64 _ = Scanf.scanf \" %Ld %Ld\" (fun u v -> u,v)\n let get_3_i64 _ = Scanf.scanf \" %Ld %Ld %Ld\" (fun u v w -> u,v,w)\n let get_4_i64 _ = Scanf.scanf \" %Ld %Ld %Ld %Ld\" (fun u v w x -> u,v,w,x)\n let get_5_i64 _ = Scanf.scanf \" %Ld %Ld %Ld %Ld %Ld\" (fun u v w x y -> u,v,w,x,y)\n let i32_get_int _ = Scanf.scanf \" %d\" (fun v -> v) let i32_get_2_ints _ = Scanf.scanf \" %d %d\" (fun u v -> u,v) let i32_get_3_ints _ = Scanf.scanf \" %d %d %d\" (fun u v w -> u,v,w) let i32_get_4_ints _ = Scanf.scanf \" %d %d %d %d\" (fun u v w x -> u,v,w,x) let i32_get_5_ints _ = Scanf.scanf \" %d %d %d %d %d\" (fun u v w x y -> u,v,w,x,y)\n (* utils *)\n external id : 'a -> 'a = \"%identity\"\n let ( *< ) f g x = f (g x)\n let ( *> ) f g x = g (f x)\n let rv f p q = f q p (* ex. 24 |> rv (/) 6 *)\n let alen a = i64 @@ Array.length a\n let llen l = i64 @@ List.length l\n let string_of_list ?(separator=\" \") f ls = ls |> List.map f |> String.concat separator\n let string_of_array ?(separator=\" \") f a = a |> Array.to_list |> string_of_list ~separator f\n let char_list_of_string str = let rec f0 i a = if i<0 then a else f0 (i-$1) (str.[i]::a) in f0 (String.length str -$ 1) []\n let string_of_char_list ls = List.fold_left (fun u v -> u ^ (String.make 1 v)) \"\" ls\n let fail _ = failwith \"fail\"\n let dx,dy = [|1;0;-1;0|],[|0;1;0;-1|]\n let range l r = let ls = ref [] in for i=i32 l to i32 r do ls := i :: !ls done;!ls |> List.rev\n let cartesian_product u v = u |> List.map (fun p -> List.map (fun q -> p,q) v) |> List.flatten\n let shuffle a = Array.sort (fun _ _ -> (Random.int 3) -$ 1) a\n let binary_search ng ok f = let d = if ng < ok then 1L else -1L in\n let rec f0 ng ok =\n if labs (ok - ng) <= 1L then ok\n else let mid = ng + (ok - ng) / 2L in if f mid then f0 ng mid else f0 mid ok\n in f0 (ng-1L*d) (ok+1L*d)\n let lower_bound a v = binary_search 0L (alen a - 1L) (fun i -> a.(i32 i) >= v)\n let upper_bound a v = binary_search 0L (alen a - 1L) (fun i -> a.(i32 i) > v)\n let equal_range a v = lower_bound a v, upper_bound a v (* #=snd-fst *)\n let rec fix f x = f (fix f) x\n let fix_memo ?(size=10000) f x =\n let tb = Hashtbl.create ~random:true size in\n let rec f0 x =\n try Hashtbl.find tb x with\n | Not_found -> (let v = f f0 x in Hashtbl.add tb x v; v)\n in f0 x\n (* imperative *)\n let rep f t ?(stride=1L) fbod = let i = ref f in while !i <= t do fbod !i; i := !i + stride done\n let repb f t ?(stride=1L) fbod = let i,c = ref f,ref true in while !i <= t && !c do\n match fbod !i with | `Break -> c := false | `Ok -> i := !i + stride done\n let repm f t ?(stride=1L) m0 fbod =\n let i,c,m = ref f,ref true,ref m0 in\n while !i<=t && !c do match fbod !m !i with\n | `Break -> c := false | `Break_m m' -> (c := false; m := m') | `Ok m' -> m := m'; i := !i + stride done; !m\n let repi f t ?(stride=1) fbod = let i = ref f in while !i <= t do fbod !i; i := !i +$ stride done\n let repib f t ?(stride=1) fbod = let i,c = ref f,ref true in while !i <= t && !c do\n match fbod !i with | `Break -> c := false | `Ok -> i := !i +$ stride done\n let repim f t ?(stride=1) m0 fbod =\n let i,c,m = ref f,ref true,ref m0 in\n while !i<=t && !c do match fbod !m !i with\n | `Break -> c := false | `Break_m m' -> (c := false; m := m') | `Ok m' -> m := m'; i := !i +$ stride done; !m\n let rep_rev f t ?(stride=1L) fbod = rep t f ~stride @@ fun v -> fbod @@ f + t - v\n let repb_rev f t ?(stride=1L) fbod = repb t f ~stride @@ fun v -> fbod @@ f + t - v\n let repm_rev f t ?(stride=1L) m0 fbod = repm f t ~stride m0 @@ fun u v -> fbod u @@ f + t - v\n let repi_rev f t ?(stride=1) fbod = repi t f ~stride @@ fun v -> fbod @@ f +$ t -$ v\n let repib_rev f t ?(stride=1) fbod = repib t f ~stride @@ fun v -> fbod @@ f +$ t -$ v\n let repim_rev f t ?(stride=1) m0 fbod = repim f t ~stride m0 @@ fun u v -> fbod u @@ f +$ t -$ v\n (* output *)\n let print_list_mle f ls = string_of_list f ls |> print_endline\n let print_array_mle f a = string_of_array f a |> print_endline\n let print_list f ls = ls |> List.iter (fun v -> printf \"%s \" @@ f v); print_newline ()\n let print_array f a = a |> Array.iter (fun v -> printf \"%s \" @@ f v); print_newline ()\n (* debug *)\n let dump_2darr f a = a |> Array.iter (fun b -> print_array f b)\n let dump_i64_list ls = print_list ist ls\n let dump_i64_array a = print_array ist a\nend open Lib open Array\n\nlet () =\n let n = get_i64 0 in\n let res = ref 0L in\n let rec f d a mask =\n if a<=n then (\n if mask=7 then res += 1L;\n f (d+1L) (a*10L+3L) (mask lor 1);\n f (d+1L) (a*10L+5L) (mask lor 2);\n f (d+1L) (a*10L+7L) (mask lor 4);\n )\n in f 0L 0L 0;\n printf \"%Ld\\n\" !res\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou are given an integer N. Among the integers between 1 and N (inclusive), how many Shichi-Go-San numbers (literally \"Seven-Five-Three numbers\") are there?\n\nHere, a Shichi-Go-San number is a positive integer that satisfies the following condition:\n\nWhen the number is written in base ten, each of the digits 7, 5 and 3 appears at least once, and the other digits never appear.\n\nConstraints\n\n1 \\leq N < 10^9\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the number of the Shichi-Go-San numbers between 1 and N (inclusive).\n\nSample Input 1\n\n575\n\nSample Output 1\n\n4\n\nThere are four Shichi-Go-San numbers not greater than 575: 357, 375, 537 and 573.\n\nSample Input 2\n\n3600\n\nSample Output 2\n\n13\n\nThere are 13 Shichi-Go-San numbers not greater than 3600: the above four numbers, 735, 753, 3357, 3375, 3537, 3557, 3573, 3575 and 3577.\n\nSample Input 3\n\n999999999\n\nSample Output 3\n\n26484", "sample_input": "575\n"}, "reference_outputs": ["4\n"], "source_document_id": "p03212", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou are given an integer N. Among the integers between 1 and N (inclusive), how many Shichi-Go-San numbers (literally \"Seven-Five-Three numbers\") are there?\n\nHere, a Shichi-Go-San number is a positive integer that satisfies the following condition:\n\nWhen the number is written in base ten, each of the digits 7, 5 and 3 appears at least once, and the other digits never appear.\n\nConstraints\n\n1 \\leq N < 10^9\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the number of the Shichi-Go-San numbers between 1 and N (inclusive).\n\nSample Input 1\n\n575\n\nSample Output 1\n\n4\n\nThere are four Shichi-Go-San numbers not greater than 575: 357, 375, 537 and 573.\n\nSample Input 2\n\n3600\n\nSample Output 2\n\n13\n\nThere are 13 Shichi-Go-San numbers not greater than 3600: the above four numbers, 735, 753, 3357, 3375, 3537, 3557, 3573, 3575 and 3577.\n\nSample Input 3\n\n999999999\n\nSample Output 3\n\n26484", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 5725, "cpu_time_ms": 3, "memory_kb": 2560}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s258463767", "group_id": "codeNet:p03213", "input_text": "module M = Map.Make (struct type t = int let compare = compare end) ;;\n\nlet n = read_int () in\nlet add key v map = M.add key (v + try M.find key map with _ -> 0) map in\nlet rec loop0 i map =\n if i = 1 then map else\n let rec loop c cur map =\n if cur * cur > c then (if c = 1 then map else add c 1 map) else\n if c mod cur = 0 then (\n let rec loop2 c count =\n if c mod cur = 0 then loop2 (c / cur) (count + 1)\n else loop c (cur + 1) (add cur count map)\n in\n loop2 c 0\n ) else loop c (cur + 1) map\n in\n loop0 (i - 1) (loop i 2 map)\nin\nlet map = loop0 n M.empty in\nlet l = M.fold (fun _ v acc -> v :: acc) map [] in\nlet count target =\n let rec loop acc list = function\n | [] -> acc + 1\n | hd :: tl -> (\n let rec loop2 acc = function\n | [] -> acc\n | hh :: tt when hh >= hd - 1 ->\n let acc = loop acc tt tl in\n loop2 acc tt\n | hh :: tt -> loop2 acc tt\n in\n loop2 acc list\n )\n in\n loop 0 l target\nin\nlet result =\n count [ 75 ] +\n count [ 3; 25 ] +\n count [ 5; 15 ] +\n count [ 15; 5 ] +\n count [ 25; 3 ] +\n count [ 3; 5; 5 ] +\n count [ 5; 3; 5 ] +\n count [ 5; 5; 3 ]\nin\nPrintf.printf \"%d\\n\" result", "language": "OCaml", "metadata": {"date": 1584082517, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03213.html", "problem_id": "p03213", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03213/input.txt", "sample_output_relpath": "derived/input_output/data/p03213/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03213/OCaml/s258463767.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s258463767", "user_id": "u342443598"}, "prompt_components": {"gold_output": "0\n", "input_to_evaluate": "module M = Map.Make (struct type t = int let compare = compare end) ;;\n\nlet n = read_int () in\nlet add key v map = M.add key (v + try M.find key map with _ -> 0) map in\nlet rec loop0 i map =\n if i = 1 then map else\n let rec loop c cur map =\n if cur * cur > c then (if c = 1 then map else add c 1 map) else\n if c mod cur = 0 then (\n let rec loop2 c count =\n if c mod cur = 0 then loop2 (c / cur) (count + 1)\n else loop c (cur + 1) (add cur count map)\n in\n loop2 c 0\n ) else loop c (cur + 1) map\n in\n loop0 (i - 1) (loop i 2 map)\nin\nlet map = loop0 n M.empty in\nlet l = M.fold (fun _ v acc -> v :: acc) map [] in\nlet count target =\n let rec loop acc list = function\n | [] -> acc + 1\n | hd :: tl -> (\n let rec loop2 acc = function\n | [] -> acc\n | hh :: tt when hh >= hd - 1 ->\n let acc = loop acc tt tl in\n loop2 acc tt\n | hh :: tt -> loop2 acc tt\n in\n loop2 acc list\n )\n in\n loop 0 l target\nin\nlet result =\n count [ 75 ] +\n count [ 3; 25 ] +\n count [ 5; 15 ] +\n count [ 15; 5 ] +\n count [ 25; 3 ] +\n count [ 3; 5; 5 ] +\n count [ 5; 3; 5 ] +\n count [ 5; 5; 3 ]\nin\nPrintf.printf \"%d\\n\" result", "problem_context": "Score : 400 points\n\nProblem Statement\n\nYou are given an integer N. Among the divisors of N! (= 1 \\times 2 \\times ... \\times N), how many Shichi-Go numbers (literally \"Seven-Five numbers\") are there?\n\nHere, a Shichi-Go number is a positive integer that has exactly 75 divisors.\n\nNote\n\nWhen a positive integer A divides a positive integer B, A is said to a divisor of B.\nFor example, 6 has four divisors: 1, 2, 3 and 6.\n\nConstraints\n\n1 \\leq N \\leq 100\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the number of the Shichi-Go numbers that are divisors of N!.\n\nSample Input 1\n\n9\n\nSample Output 1\n\n0\n\nThere are no Shichi-Go numbers among the divisors of 9! = 1 \\times 2 \\times ... \\times 9 = 362880.\n\nSample Input 2\n\n10\n\nSample Output 2\n\n1\n\nThere is one Shichi-Go number among the divisors of 10! = 3628800: 32400.\n\nSample Input 3\n\n100\n\nSample Output 3\n\n543", "sample_input": "9\n"}, "reference_outputs": ["0\n"], "source_document_id": "p03213", "source_text": "Score : 400 points\n\nProblem Statement\n\nYou are given an integer N. Among the divisors of N! (= 1 \\times 2 \\times ... \\times N), how many Shichi-Go numbers (literally \"Seven-Five numbers\") are there?\n\nHere, a Shichi-Go number is a positive integer that has exactly 75 divisors.\n\nNote\n\nWhen a positive integer A divides a positive integer B, A is said to a divisor of B.\nFor example, 6 has four divisors: 1, 2, 3 and 6.\n\nConstraints\n\n1 \\leq N \\leq 100\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the number of the Shichi-Go numbers that are divisors of N!.\n\nSample Input 1\n\n9\n\nSample Output 1\n\n0\n\nThere are no Shichi-Go numbers among the divisors of 9! = 1 \\times 2 \\times ... \\times 9 = 362880.\n\nSample Input 2\n\n10\n\nSample Output 2\n\n1\n\nThere is one Shichi-Go number among the divisors of 10! = 3628800: 32400.\n\nSample Input 3\n\n100\n\nSample Output 3\n\n543", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1434, "cpu_time_ms": 1, "memory_kb": 512}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s915090309", "group_id": "codeNet:p03213", "input_text": "module IntMap = Map.Make (struct\n type t = int\n let compare = compare\nend)\n\nlet rec factorize acc i n =\n if n <= 1 then acc\n else if n < i * i then n :: acc\n else if n mod i = 0 then factorize (i :: acc) i (n / i)\n else factorize acc (i + 1) n\nlet factorize = factorize [] 2\n\nlet rec solve x = function\n | [] -> if x = 1 then 1 else 0\n | n :: rest ->\n Array.fold_left ( + ) 0 @@\n Array.init (n + 1) @@ fun i ->\n if x mod (i + 1) <> 0 then 0\n else solve (x / (i + 1)) rest\nlet solve = solve 75\n\nlet () = Scanf.scanf \"%d\" @@ fun n ->\n Printf.printf \"%d\\n\" @@\n solve @@\n List.map snd @@\n IntMap.bindings @@\n Array.fold_left (List.fold_left (fun pf p ->\n IntMap.add p (1 + try IntMap.find p pf with Not_found -> 0) pf)) IntMap.empty @@\n Array.init n @@ fun i -> factorize @@ i + 1\n", "language": "OCaml", "metadata": {"date": 1543887785, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03213.html", "problem_id": "p03213", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03213/input.txt", "sample_output_relpath": "derived/input_output/data/p03213/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03213/OCaml/s915090309.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s915090309", "user_id": "u504158101"}, "prompt_components": {"gold_output": "0\n", "input_to_evaluate": "module IntMap = Map.Make (struct\n type t = int\n let compare = compare\nend)\n\nlet rec factorize acc i n =\n if n <= 1 then acc\n else if n < i * i then n :: acc\n else if n mod i = 0 then factorize (i :: acc) i (n / i)\n else factorize acc (i + 1) n\nlet factorize = factorize [] 2\n\nlet rec solve x = function\n | [] -> if x = 1 then 1 else 0\n | n :: rest ->\n Array.fold_left ( + ) 0 @@\n Array.init (n + 1) @@ fun i ->\n if x mod (i + 1) <> 0 then 0\n else solve (x / (i + 1)) rest\nlet solve = solve 75\n\nlet () = Scanf.scanf \"%d\" @@ fun n ->\n Printf.printf \"%d\\n\" @@\n solve @@\n List.map snd @@\n IntMap.bindings @@\n Array.fold_left (List.fold_left (fun pf p ->\n IntMap.add p (1 + try IntMap.find p pf with Not_found -> 0) pf)) IntMap.empty @@\n Array.init n @@ fun i -> factorize @@ i + 1\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nYou are given an integer N. Among the divisors of N! (= 1 \\times 2 \\times ... \\times N), how many Shichi-Go numbers (literally \"Seven-Five numbers\") are there?\n\nHere, a Shichi-Go number is a positive integer that has exactly 75 divisors.\n\nNote\n\nWhen a positive integer A divides a positive integer B, A is said to a divisor of B.\nFor example, 6 has four divisors: 1, 2, 3 and 6.\n\nConstraints\n\n1 \\leq N \\leq 100\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the number of the Shichi-Go numbers that are divisors of N!.\n\nSample Input 1\n\n9\n\nSample Output 1\n\n0\n\nThere are no Shichi-Go numbers among the divisors of 9! = 1 \\times 2 \\times ... \\times 9 = 362880.\n\nSample Input 2\n\n10\n\nSample Output 2\n\n1\n\nThere is one Shichi-Go number among the divisors of 10! = 3628800: 32400.\n\nSample Input 3\n\n100\n\nSample Output 3\n\n543", "sample_input": "9\n"}, "reference_outputs": ["0\n"], "source_document_id": "p03213", "source_text": "Score : 400 points\n\nProblem Statement\n\nYou are given an integer N. Among the divisors of N! (= 1 \\times 2 \\times ... \\times N), how many Shichi-Go numbers (literally \"Seven-Five numbers\") are there?\n\nHere, a Shichi-Go number is a positive integer that has exactly 75 divisors.\n\nNote\n\nWhen a positive integer A divides a positive integer B, A is said to a divisor of B.\nFor example, 6 has four divisors: 1, 2, 3 and 6.\n\nConstraints\n\n1 \\leq N \\leq 100\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the number of the Shichi-Go numbers that are divisors of N!.\n\nSample Input 1\n\n9\n\nSample Output 1\n\n0\n\nThere are no Shichi-Go numbers among the divisors of 9! = 1 \\times 2 \\times ... \\times 9 = 362880.\n\nSample Input 2\n\n10\n\nSample Output 2\n\n1\n\nThere is one Shichi-Go number among the divisors of 10! = 3628800: 32400.\n\nSample Input 3\n\n100\n\nSample Output 3\n\n543", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 3, "memory_kb": 2432}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s537329042", "group_id": "codeNet:p03214", "input_text": "let n = Scanf.scanf \" %d\" (+) 0\nlet a_s = Array.init n @@ fun _ -> Scanf.scanf \" %d\" (+) 0\nlet s = Array.fold_left (+) 0 a_s\nlet ans, m = ref 0, ref max_int\nlet _ = Array.iteri (fun i a -> let d = abs @@ s - n * a in if d < !m then (ans := i; m := d)) a_s; Printf.printf \"%d\\n\" !ans", "language": "OCaml", "metadata": {"date": 1565362793, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03214.html", "problem_id": "p03214", "resource_group": "low_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/OCaml/s537329042.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s537329042", "user_id": "u732304692"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "let n = Scanf.scanf \" %d\" (+) 0\nlet a_s = Array.init n @@ fun _ -> Scanf.scanf \" %d\" (+) 0\nlet s = Array.fold_left (+) 0 a_s\nlet ans, m = ref 0, ref max_int\nlet _ = Array.iteri (fun i a -> let d = abs @@ s - n * a in if d < !m then (ans := i; m := d)) a_s; Printf.printf \"%d\\n\" !ans", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 282, "cpu_time_ms": 1, "memory_kb": 2432}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s994188161", "group_id": "codeNet:p03219", "input_text": "let _ = Scanf.sscanf (read_line ()) \"%d %d\" (fun x y ->\n print_int (x + (y / 2))\n)", "language": "OCaml", "metadata": {"date": 1583974494, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03219.html", "problem_id": "p03219", "resource_group": "low_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/OCaml/s994188161.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s994188161", "user_id": "u511870776"}, "prompt_components": {"gold_output": "110\n", "input_to_evaluate": "let _ = Scanf.sscanf (read_line ()) \"%d %d\" (fun x y ->\n print_int (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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s277756091", "group_id": "codeNet:p03219", "input_text": "open Printf\nopen Scanf\n\nlet solve a b = a + b / 2\n\nlet () =\n scanf \"%d %d \" solve |> printf \"%d\\n\"\n", "language": "OCaml", "metadata": {"date": 1582079475, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03219.html", "problem_id": "p03219", "resource_group": "low_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/OCaml/s277756091.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s277756091", "user_id": "u388783188"}, "prompt_components": {"gold_output": "110\n", "input_to_evaluate": "open Printf\nopen Scanf\n\nlet solve a b = a + b / 2\n\nlet () =\n scanf \"%d %d \" solve |> printf \"%d\\n\"\n", "problem_context": "Score: 100 points\n\nProblem Statement\n\nThere is a train going from Station A to Station B that costs X yen (the currency of Japan).\n\nAlso, there is a bus going from Station B to Station C that costs Y yen.\n\nJoisino got a special ticket. With this ticket, she can take the bus for half the fare if she travels from Station A to Station B by train and then travels from Station B to Station C by bus.\n\nHow much does it cost to travel from Station A to Station C if she uses this ticket?\n\nConstraints\n\n1 \\leq X,Y \\leq 100\n\nY is an even number.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX Y\n\nOutput\n\nIf it costs x yen to travel from Station A to Station C, print x.\n\nSample Input 1\n\n81 58\n\nSample Output 1\n\n110\n\nThe train fare is 81 yen.\n\nThe train fare is 58 ⁄ 2=29 yen with the 50% discount.\n\nThus, it costs 110 yen to travel from Station A to Station C.\n\nSample Input 2\n\n4 54\n\nSample Output 2\n\n31", "sample_input": "81 58\n"}, "reference_outputs": ["110\n"], "source_document_id": "p03219", "source_text": "Score: 100 points\n\nProblem Statement\n\nThere is a train going from Station A to Station B that costs X yen (the currency of Japan).\n\nAlso, there is a bus going from Station B to Station C that costs Y yen.\n\nJoisino got a special ticket. With this ticket, she can take the bus for half the fare if she travels from Station A to Station B by train and then travels from Station B to Station C by bus.\n\nHow much does it cost to travel from Station A to Station C if she uses this ticket?\n\nConstraints\n\n1 \\leq X,Y \\leq 100\n\nY is an even number.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX Y\n\nOutput\n\nIf it costs x yen to travel from Station A to Station C, print x.\n\nSample Input 1\n\n81 58\n\nSample Output 1\n\n110\n\nThe train fare is 81 yen.\n\nThe train fare is 58 ⁄ 2=29 yen with the 50% discount.\n\nThus, it costs 110 yen to travel from Station A to Station C.\n\nSample Input 2\n\n4 54\n\nSample Output 2\n\n31", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s520905036", "group_id": "codeNet:p03220", "input_text": "let rec f n t a ans lst =\n match n with\n | 0 -> ans\n | _ ->\n let buf = float_of_int (t) -. float_of_int (List.nth lst n) *. 0.006 in\n let ansT = float_of_int (t) -. float_of_int (List.nth lst ans) *. 0.006 in\n if abs_float (float_of_int (a) -. buf) < abs_float (float_of_int (a) -. ansT)\n then f (n-1) t a n lst\n else f (n-1) t a ans lst\nlet () =\n Scanf.scanf \"%d\\n\"\n (fun n -> Scanf.scanf \"%d %d\\n\"\n (fun t a ->\n Array.init n (fun _ -> Scanf.scanf \" %d\" (fun x -> x))\n |> Array.to_list\n |> f (n-1) t a 0\n |> (+) 1))\n |> print_int", "language": "OCaml", "metadata": {"date": 1554766028, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03220.html", "problem_id": "p03220", "resource_group": "low_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/OCaml/s520905036.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s520905036", "user_id": "u307426615"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "let rec f n t a ans lst =\n match n with\n | 0 -> ans\n | _ ->\n let buf = float_of_int (t) -. float_of_int (List.nth lst n) *. 0.006 in\n let ansT = float_of_int (t) -. float_of_int (List.nth lst ans) *. 0.006 in\n if abs_float (float_of_int (a) -. buf) < abs_float (float_of_int (a) -. ansT)\n then f (n-1) t a n lst\n else f (n-1) t a ans lst\nlet () =\n Scanf.scanf \"%d\\n\"\n (fun n -> Scanf.scanf \"%d %d\\n\"\n (fun t a ->\n Array.init n (fun _ -> Scanf.scanf \" %d\" (fun x -> x))\n |> Array.to_list\n |> f (n-1) t a 0\n |> (+) 1))\n |> print_int", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 600, "cpu_time_ms": 4, "memory_kb": 640}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s642182438", "group_id": "codeNet:p03220", "input_text": "let _ = read_line()\nlet (t,a) = match read_line() |> Str.split (Str.regexp \" \") with\n| [t;a]->(int_of_string t,int_of_string a)\n| _ -> assert false\nlet hs = read_line() |> Str.split (Str.regexp \" \") |> List.map int_of_string\n\nlet _ =\n let (v,p,_) = List.fold_left (fun (v,p,i) h ->\n let t = t*1000 - h*6 in\n let v1 = abs (t - a*1000) in\n (*Printf.printf \"i=%d v1=%d v=%d\\n\" i v1 v;*)\n if v1 <= v then (v1,i,i+1) else (v,p,i+1)\n ) (50000000000,-1,1) hs in\n Printf.printf \"%d\\n\" p\n", "language": "OCaml", "metadata": {"date": 1541386000, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03220.html", "problem_id": "p03220", "resource_group": "low_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/OCaml/s642182438.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s642182438", "user_id": "u472975241"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "let _ = read_line()\nlet (t,a) = match read_line() |> Str.split (Str.regexp \" \") with\n| [t;a]->(int_of_string t,int_of_string a)\n| _ -> assert false\nlet hs = read_line() |> Str.split (Str.regexp \" \") |> List.map int_of_string\n\nlet _ =\n let (v,p,_) = List.fold_left (fun (v,p,i) h ->\n let t = t*1000 - h*6 in\n let v1 = abs (t - a*1000) in\n (*Printf.printf \"i=%d v1=%d v=%d\\n\" i v1 v;*)\n if v1 <= v then (v1,i,i+1) else (v,p,i+1)\n ) (50000000000,-1,1) hs in\n Printf.printf \"%d\\n\" p\n", "problem_context": "Score: 200 points\n\nProblem Statement\n\nA country decides to build a palace.\n\nIn this country, the average temperature of a point at an elevation of x meters is T-x \\times 0.006 degrees Celsius.\n\nThere are N places proposed for the place. The elevation of Place i is H_i meters.\n\nAmong them, Princess Joisino orders you to select the place whose average temperature is the closest to A degrees Celsius, and build the palace there.\n\nPrint the index of the place where the palace should be built.\n\nIt is guaranteed that the solution is unique.\n\nConstraints\n\n1 \\leq N \\leq 1000\n\n0 \\leq T \\leq 50\n\n-60 \\leq A \\leq T\n\n0 \\leq H_i \\leq 10^5\n\nAll values in input are integers.\n\nThe solution is unique.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nT A\nH_1 H_2 ... H_N\n\nOutput\n\nPrint the index of the place where the palace should be built.\n\nSample Input 1\n\n2\n12 5\n1000 2000\n\nSample Output 1\n\n1\n\nThe average temperature of Place 1 is 12-1000 \\times 0.006=6 degrees Celsius.\n\nThe average temperature of Place 2 is 12-2000 \\times 0.006=0 degrees Celsius.\n\nThus, the palace should be built at Place 1.\n\nSample Input 2\n\n3\n21 -11\n81234 94124 52141\n\nSample Output 2\n\n3", "sample_input": "2\n12 5\n1000 2000\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03220", "source_text": "Score: 200 points\n\nProblem Statement\n\nA country decides to build a palace.\n\nIn this country, the average temperature of a point at an elevation of x meters is T-x \\times 0.006 degrees Celsius.\n\nThere are N places proposed for the place. The elevation of Place i is H_i meters.\n\nAmong them, Princess Joisino orders you to select the place whose average temperature is the closest to A degrees Celsius, and build the palace there.\n\nPrint the index of the place where the palace should be built.\n\nIt is guaranteed that the solution is unique.\n\nConstraints\n\n1 \\leq N \\leq 1000\n\n0 \\leq T \\leq 50\n\n-60 \\leq A \\leq T\n\n0 \\leq H_i \\leq 10^5\n\nAll values in input are integers.\n\nThe solution is unique.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nT A\nH_1 H_2 ... H_N\n\nOutput\n\nPrint the index of the place where the palace should be built.\n\nSample Input 1\n\n2\n12 5\n1000 2000\n\nSample Output 1\n\n1\n\nThe average temperature of Place 1 is 12-1000 \\times 0.006=6 degrees Celsius.\n\nThe average temperature of Place 2 is 12-2000 \\times 0.006=0 degrees Celsius.\n\nThus, the palace should be built at Place 1.\n\nSample Input 2\n\n3\n21 -11\n81234 94124 52141\n\nSample Output 2\n\n3", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 495, "cpu_time_ms": 1, "memory_kb": 2688}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s355981853", "group_id": "codeNet:p03220", "input_text": "let _ = read_line()\nlet (t,a) = match read_line() |> Str.split (Str.regexp \" \") with\n| [t;a]->(int_of_string t,int_of_string a)\n| _ -> assert false\nlet hs = read_line() |> Str.split (Str.regexp \" \") |> List.map int_of_string\n\nlet _ =\n let (v,p,_) = List.fold_left (fun (v,p,i) h ->\n let t = t*1000 - h*6 in\n let v1 = abs (t - a) in\n if v1 <= v then (v1,i,i+1) else (v,p,i+1)\n ) (500000000,-1,1) hs in\n Printf.printf \"%d\\n\" p\n", "language": "OCaml", "metadata": {"date": 1541384551, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03220.html", "problem_id": "p03220", "resource_group": "low_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/OCaml/s355981853.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s355981853", "user_id": "u472975241"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "let _ = read_line()\nlet (t,a) = match read_line() |> Str.split (Str.regexp \" \") with\n| [t;a]->(int_of_string t,int_of_string a)\n| _ -> assert false\nlet hs = read_line() |> Str.split (Str.regexp \" \") |> List.map int_of_string\n\nlet _ =\n let (v,p,_) = List.fold_left (fun (v,p,i) h ->\n let t = t*1000 - h*6 in\n let v1 = abs (t - a) in\n if v1 <= v then (v1,i,i+1) else (v,p,i+1)\n ) (500000000,-1,1) hs in\n Printf.printf \"%d\\n\" p\n", "problem_context": "Score: 200 points\n\nProblem Statement\n\nA country decides to build a palace.\n\nIn this country, the average temperature of a point at an elevation of x meters is T-x \\times 0.006 degrees Celsius.\n\nThere are N places proposed for the place. The elevation of Place i is H_i meters.\n\nAmong them, Princess Joisino orders you to select the place whose average temperature is the closest to A degrees Celsius, and build the palace there.\n\nPrint the index of the place where the palace should be built.\n\nIt is guaranteed that the solution is unique.\n\nConstraints\n\n1 \\leq N \\leq 1000\n\n0 \\leq T \\leq 50\n\n-60 \\leq A \\leq T\n\n0 \\leq H_i \\leq 10^5\n\nAll values in input are integers.\n\nThe solution is unique.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nT A\nH_1 H_2 ... H_N\n\nOutput\n\nPrint the index of the place where the palace should be built.\n\nSample Input 1\n\n2\n12 5\n1000 2000\n\nSample Output 1\n\n1\n\nThe average temperature of Place 1 is 12-1000 \\times 0.006=6 degrees Celsius.\n\nThe average temperature of Place 2 is 12-2000 \\times 0.006=0 degrees Celsius.\n\nThus, the palace should be built at Place 1.\n\nSample Input 2\n\n3\n21 -11\n81234 94124 52141\n\nSample Output 2\n\n3", "sample_input": "2\n12 5\n1000 2000\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03220", "source_text": "Score: 200 points\n\nProblem Statement\n\nA country decides to build a palace.\n\nIn this country, the average temperature of a point at an elevation of x meters is T-x \\times 0.006 degrees Celsius.\n\nThere are N places proposed for the place. The elevation of Place i is H_i meters.\n\nAmong them, Princess Joisino orders you to select the place whose average temperature is the closest to A degrees Celsius, and build the palace there.\n\nPrint the index of the place where the palace should be built.\n\nIt is guaranteed that the solution is unique.\n\nConstraints\n\n1 \\leq N \\leq 1000\n\n0 \\leq T \\leq 50\n\n-60 \\leq A \\leq T\n\n0 \\leq H_i \\leq 10^5\n\nAll values in input are integers.\n\nThe solution is unique.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nT A\nH_1 H_2 ... H_N\n\nOutput\n\nPrint the index of the place where the palace should be built.\n\nSample Input 1\n\n2\n12 5\n1000 2000\n\nSample Output 1\n\n1\n\nThe average temperature of Place 1 is 12-1000 \\times 0.006=6 degrees Celsius.\n\nThe average temperature of Place 2 is 12-2000 \\times 0.006=0 degrees Celsius.\n\nThus, the palace should be built at Place 1.\n\nSample Input 2\n\n3\n21 -11\n81234 94124 52141\n\nSample Output 2\n\n3", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 2, "memory_kb": 4480}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s768197183", "group_id": "codeNet:p03221", "input_text": "Scanf.scanf \"%d %d\" (fun n m ->\n let pref = Array.make n 0 in\n let py = Array.init m (fun i -> Scanf.scanf \" %d %d\" (fun p y -> p, y, i)) in\n let id = Array.make m \"\" in\n Array.sort compare py;\n Array.iter (fun (p, y, i) ->\n pref.(p - 1) <- pref.(p - 1) + 1;\n id.(i) <- Printf.sprintf \"%06d%06d\" p pref.(p - 1)\n ) py;\n Array.iter print_endline id\n)", "language": "OCaml", "metadata": {"date": 1588724868, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03221.html", "problem_id": "p03221", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03221/input.txt", "sample_output_relpath": "derived/input_output/data/p03221/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03221/OCaml/s768197183.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s768197183", "user_id": "u342443598"}, "prompt_components": {"gold_output": "000001000002\n000002000001\n000001000001\n", "input_to_evaluate": "Scanf.scanf \"%d %d\" (fun n m ->\n let pref = Array.make n 0 in\n let py = Array.init m (fun i -> Scanf.scanf \" %d %d\" (fun p y -> p, y, i)) in\n let id = Array.make m \"\" in\n Array.sort compare py;\n Array.iter (fun (p, y, i) ->\n pref.(p - 1) <- pref.(p - 1) + 1;\n id.(i) <- Printf.sprintf \"%06d%06d\" p pref.(p - 1)\n ) py;\n Array.iter print_endline id\n)", "problem_context": "Score: 300 points\n\nProblem Statement\n\nIn Republic of Atcoder, there are N prefectures, and a total of M cities that belong to those prefectures.\n\nCity i is established in year Y_i and belongs to Prefecture P_i.\n\nYou can assume that there are no multiple cities that are established in the same year.\n\nIt is decided to allocate a 12-digit ID number to each city.\n\nIf City i is the x-th established city among the cities that belong to Prefecture i, the first six digits of the ID number of City i is P_i, and the last six digits of the ID number is x.\n\nHere, if P_i or x (or both) has less than six digits, zeros are added to the left until it has six digits.\n\nFind the ID numbers for all the cities.\n\nNote that there can be a prefecture with no cities.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n1 \\leq P_i \\leq N\n\n1 \\leq Y_i \\leq 10^9\n\nY_i are all different.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nP_1 Y_1\n:\nP_M Y_M\n\nOutput\n\nPrint the ID numbers for all the cities, in ascending order of indices (City 1, City 2, ...).\n\nSample Input 1\n\n2 3\n1 32\n2 63\n1 12\n\nSample Output 1\n\n000001000002\n000002000001\n000001000001\n\nAs City 1 is the second established city among the cities that belong to Prefecture 1, its ID number is 000001000002.\n\nAs City 2 is the first established city among the cities that belong to Prefecture 2, its ID number is 000002000001.\n\nAs City 3 is the first established city among the cities that belong to Prefecture 1, its ID number is 000001000001.\n\nSample Input 2\n\n2 3\n2 55\n2 77\n2 99\n\nSample Output 2\n\n000002000001\n000002000002\n000002000003", "sample_input": "2 3\n1 32\n2 63\n1 12\n"}, "reference_outputs": ["000001000002\n000002000001\n000001000001\n"], "source_document_id": "p03221", "source_text": "Score: 300 points\n\nProblem Statement\n\nIn Republic of Atcoder, there are N prefectures, and a total of M cities that belong to those prefectures.\n\nCity i is established in year Y_i and belongs to Prefecture P_i.\n\nYou can assume that there are no multiple cities that are established in the same year.\n\nIt is decided to allocate a 12-digit ID number to each city.\n\nIf City i is the x-th established city among the cities that belong to Prefecture i, the first six digits of the ID number of City i is P_i, and the last six digits of the ID number is x.\n\nHere, if P_i or x (or both) has less than six digits, zeros are added to the left until it has six digits.\n\nFind the ID numbers for all the cities.\n\nNote that there can be a prefecture with no cities.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq M \\leq 10^5\n\n1 \\leq P_i \\leq N\n\n1 \\leq Y_i \\leq 10^9\n\nY_i are all different.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\nP_1 Y_1\n:\nP_M Y_M\n\nOutput\n\nPrint the ID numbers for all the cities, in ascending order of indices (City 1, City 2, ...).\n\nSample Input 1\n\n2 3\n1 32\n2 63\n1 12\n\nSample Output 1\n\n000001000002\n000002000001\n000001000001\n\nAs City 1 is the second established city among the cities that belong to Prefecture 1, its ID number is 000001000002.\n\nAs City 2 is the first established city among the cities that belong to Prefecture 2, its ID number is 000002000001.\n\nAs City 3 is the first established city among the cities that belong to Prefecture 1, its ID number is 000001000001.\n\nSample Input 2\n\n2 3\n2 55\n2 77\n2 99\n\nSample Output 2\n\n000002000001\n000002000002\n000002000003", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 356, "memory_kb": 12416}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s380148845", "group_id": "codeNet:p03224", "input_text": "let rec upper_bound l r p =\n if r <= 1 + l\n then l\n else let m = (l + r) / 2 in\n if p m \n then upper_bound m r p\n else upper_bound l m p\n\nlet () = Scanf.scanf \"%d\\n\" @@ fun n ->\n let k = upper_bound 0 (n + 2) @@ fun k -> k * (k - 1) / 2 <= n in\n if k * (k - 1) / 2 <> n then\n print_endline \"No\"\n else begin\n Printf.printf \"Yes\\n%d\\n\" k;\n for i = 0 to k - 1 do\n Printf.printf \"%d\" (k - 1);\n for j = 0 to k - 1 do\n if i + j <> k - 1 then\n let i, j =\n if i + j < k - 1\n then i, j\n else k - j - 1, k - i - 1 in\n Printf.printf \" %d\" @@ succ @@ (2 * (k - 1) - i + 1) * i / 2 + j\n done;\n print_newline ()\n done\n end\n", "language": "OCaml", "metadata": {"date": 1540692615, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03224.html", "problem_id": "p03224", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03224/input.txt", "sample_output_relpath": "derived/input_output/data/p03224/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03224/OCaml/s380148845.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s380148845", "user_id": "u504158101"}, "prompt_components": {"gold_output": "Yes\n3\n2 1 2\n2 3 1\n2 2 3\n", "input_to_evaluate": "let rec upper_bound l r p =\n if r <= 1 + l\n then l\n else let m = (l + r) / 2 in\n if p m \n then upper_bound m r p\n else upper_bound l m p\n\nlet () = Scanf.scanf \"%d\\n\" @@ fun n ->\n let k = upper_bound 0 (n + 2) @@ fun k -> k * (k - 1) / 2 <= n in\n if k * (k - 1) / 2 <> n then\n print_endline \"No\"\n else begin\n Printf.printf \"Yes\\n%d\\n\" k;\n for i = 0 to k - 1 do\n Printf.printf \"%d\" (k - 1);\n for j = 0 to k - 1 do\n if i + j <> k - 1 then\n let i, j =\n if i + j < k - 1\n then i, j\n else k - j - 1, k - i - 1 in\n Printf.printf \" %d\" @@ succ @@ (2 * (k - 1) - i + 1) * i / 2 + j\n done;\n print_newline ()\n done\n end\n", "problem_context": "Score : 500 points\n\nProblem Statement\n\nYou are given an integer N. Determine if there exists a tuple of subsets of \\{1,2,...N\\}, (S_1,S_2,...,S_k), that satisfies the following conditions:\n\nEach of the integers 1,2,...,N is contained in exactly two of the sets S_1,S_2,...,S_k.\n\nAny two of the sets S_1,S_2,...,S_k have exactly one element in common.\n\nIf such a tuple exists, construct one such tuple.\n\nConstraints\n\n1 \\leq N \\leq 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\nIf a tuple of subsets of \\{1,2,...N\\} that satisfies the conditions does not exist, print No.\nIf such a tuple exists, print Yes first, then print such subsets in the following format:\n\nk\n|S_1| S_{1,1} S_{1,2} ... S_{1,|S_1|}\n:\n|S_k| S_{k,1} S_{k,2} ... S_{k,|S_k|}\n\nwhere S_i={S_{i,1},S_{i,2},...,S_{i,|S_i|}}.\n\nIf there are multiple such tuples, any of them will be accepted.\n\nSample Input 1\n\n3\n\nSample Output 1\n\nYes\n3\n2 1 2\n2 3 1\n2 2 3\n\nIt can be seen that (S_1,S_2,S_3)=(\\{1,2\\},\\{3,1\\},\\{2,3\\}) satisfies the conditions.\n\nSample Input 2\n\n4\n\nSample Output 2\n\nNo", "sample_input": "3\n"}, "reference_outputs": ["Yes\n3\n2 1 2\n2 3 1\n2 2 3\n"], "source_document_id": "p03224", "source_text": "Score : 500 points\n\nProblem Statement\n\nYou are given an integer N. Determine if there exists a tuple of subsets of \\{1,2,...N\\}, (S_1,S_2,...,S_k), that satisfies the following conditions:\n\nEach of the integers 1,2,...,N is contained in exactly two of the sets S_1,S_2,...,S_k.\n\nAny two of the sets S_1,S_2,...,S_k have exactly one element in common.\n\nIf such a tuple exists, construct one such tuple.\n\nConstraints\n\n1 \\leq N \\leq 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\nIf a tuple of subsets of \\{1,2,...N\\} that satisfies the conditions does not exist, print No.\nIf such a tuple exists, print Yes first, then print such subsets in the following format:\n\nk\n|S_1| S_{1,1} S_{1,2} ... S_{1,|S_1|}\n:\n|S_k| S_{k,1} S_{k,2} ... S_{k,|S_k|}\n\nwhere S_i={S_{i,1},S_{i,2},...,S_{i,|S_i|}}.\n\nIf there are multiple such tuples, any of them will be accepted.\n\nSample Input 1\n\n3\n\nSample Output 1\n\nYes\n3\n2 1 2\n2 3 1\n2 2 3\n\nIt can be seen that (S_1,S_2,S_3)=(\\{1,2\\},\\{3,1\\},\\{2,3\\}) satisfies the conditions.\n\nSample Input 2\n\n4\n\nSample Output 2\n\nNo", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 722, "cpu_time_ms": 44, "memory_kb": 3712}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s469544855", "group_id": "codeNet:p03227", "input_text": "Scanf.scanf\" %s\"@@fun s->\n\tmatch String.length s with\n\t| 2->print_endline s\n\t| 3->List.iter print_char [s.[2];s.[1];s.[0]]", "language": "OCaml", "metadata": {"date": 1540724800, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03227.html", "problem_id": "p03227", "resource_group": "low_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/OCaml/s469544855.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s469544855", "user_id": "u481480055"}, "prompt_components": {"gold_output": "cba\n", "input_to_evaluate": "Scanf.scanf\" %s\"@@fun s->\n\tmatch String.length s with\n\t| 2->print_endline s\n\t| 3->List.iter print_char [s.[2];s.[1];s.[0]]", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s474732159", "group_id": "codeNet:p03228", "input_text": "let rec fold_n n f a = if n <= 0 then a else fold_n (n-1) f (f a)\nlet f (a, b) = (b + a/2, a/2)\nlet _ = Scanf.scanf \"%d %d %d\" @@ fun a b n ->\n let x, y = fold_n n f (a, b) in\n let x, y = if n mod 2 = 0 then x, y else y, x in\n Printf.printf \"%d %d\\n\" x y", "language": "OCaml", "metadata": {"date": 1540740015, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03228.html", "problem_id": "p03228", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03228/input.txt", "sample_output_relpath": "derived/input_output/data/p03228/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03228/OCaml/s474732159.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s474732159", "user_id": "u798181098"}, "prompt_components": {"gold_output": "5 3\n", "input_to_evaluate": "let rec fold_n n f a = if n <= 0 then a else fold_n (n-1) f (f a)\nlet f (a, b) = (b + a/2, a/2)\nlet _ = Scanf.scanf \"%d %d %d\" @@ fun a b n ->\n let x, y = fold_n n f (a, b) in\n let x, y = if n mod 2 = 0 then x, y else y, x in\n Printf.printf \"%d %d\\n\" x y", "problem_context": "Score : 200 points\n\nProblem Statement\n\nIn the beginning, Takahashi has A cookies, and Aoki has B cookies.\nThey will perform the following operation alternately, starting from Takahashi:\n\nIf the number of cookies in his hand is odd, eat one of those cookies; if the number is even, do nothing. Then, give one-half of the cookies in his hand to the other person.\n\nFind the numbers of cookies Takahashi and Aoki respectively have after performing K operations in total.\n\nConstraints\n\n1 \\leq A,B \\leq 10^9\n\n1 \\leq K \\leq 100\n\nA,B and K are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B K\n\nOutput\n\nPrint the number of cookies Takahashi has, and the number of cookies Aoki has, in this order, after performing K operations in total.\n\nSample Input 1\n\n5 4 2\n\nSample Output 1\n\n5 3\n\nThe process will go as follows:\n\nIn the beginning, Takahashi and Aoki have 5 and 4 cookies, respectively.\n\nTakahashi eats one cookie and gives two cookies to Aoki. They now have 2 and 6 cookies, respectively.\n\nAoki gives three cookies to Takahashi. They now have 5 and 3 cookies, respectively.\n\nSample Input 2\n\n3 3 3\n\nSample Output 2\n\n1 3\n\nSample Input 3\n\n314159265 358979323 84\n\nSample Output 3\n\n448759046 224379523", "sample_input": "5 4 2\n"}, "reference_outputs": ["5 3\n"], "source_document_id": "p03228", "source_text": "Score : 200 points\n\nProblem Statement\n\nIn the beginning, Takahashi has A cookies, and Aoki has B cookies.\nThey will perform the following operation alternately, starting from Takahashi:\n\nIf the number of cookies in his hand is odd, eat one of those cookies; if the number is even, do nothing. Then, give one-half of the cookies in his hand to the other person.\n\nFind the numbers of cookies Takahashi and Aoki respectively have after performing K operations in total.\n\nConstraints\n\n1 \\leq A,B \\leq 10^9\n\n1 \\leq K \\leq 100\n\nA,B and K are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B K\n\nOutput\n\nPrint the number of cookies Takahashi has, and the number of cookies Aoki has, in this order, after performing K operations in total.\n\nSample Input 1\n\n5 4 2\n\nSample Output 1\n\n5 3\n\nThe process will go as follows:\n\nIn the beginning, Takahashi and Aoki have 5 and 4 cookies, respectively.\n\nTakahashi eats one cookie and gives two cookies to Aoki. They now have 2 and 6 cookies, respectively.\n\nAoki gives three cookies to Takahashi. They now have 5 and 3 cookies, respectively.\n\nSample Input 2\n\n3 3 3\n\nSample Output 2\n\n1 3\n\nSample Input 3\n\n314159265 358979323 84\n\nSample Output 3\n\n448759046 224379523", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s039610395", "group_id": "codeNet:p03228", "input_text": "let rec solve a b = function\n | 0 -> (a, b)\n | k -> solve (b + a / 2) (a / 2) (k - 1)\n\nlet () = Scanf.scanf \"%d %d %d\" @@ fun a b k ->\n let (a, b) = solve a b k in\n if k mod 2 = 0\n then Printf.printf \"%d %d\\n\" a b\n else Printf.printf \"%d %d\\n\" b a\n\n", "language": "OCaml", "metadata": {"date": 1540695391, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03228.html", "problem_id": "p03228", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03228/input.txt", "sample_output_relpath": "derived/input_output/data/p03228/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03228/OCaml/s039610395.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s039610395", "user_id": "u504158101"}, "prompt_components": {"gold_output": "5 3\n", "input_to_evaluate": "let rec solve a b = function\n | 0 -> (a, b)\n | k -> solve (b + a / 2) (a / 2) (k - 1)\n\nlet () = Scanf.scanf \"%d %d %d\" @@ fun a b k ->\n let (a, b) = solve a b k in\n if k mod 2 = 0\n then Printf.printf \"%d %d\\n\" a b\n else Printf.printf \"%d %d\\n\" b a\n\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nIn the beginning, Takahashi has A cookies, and Aoki has B cookies.\nThey will perform the following operation alternately, starting from Takahashi:\n\nIf the number of cookies in his hand is odd, eat one of those cookies; if the number is even, do nothing. Then, give one-half of the cookies in his hand to the other person.\n\nFind the numbers of cookies Takahashi and Aoki respectively have after performing K operations in total.\n\nConstraints\n\n1 \\leq A,B \\leq 10^9\n\n1 \\leq K \\leq 100\n\nA,B and K are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B K\n\nOutput\n\nPrint the number of cookies Takahashi has, and the number of cookies Aoki has, in this order, after performing K operations in total.\n\nSample Input 1\n\n5 4 2\n\nSample Output 1\n\n5 3\n\nThe process will go as follows:\n\nIn the beginning, Takahashi and Aoki have 5 and 4 cookies, respectively.\n\nTakahashi eats one cookie and gives two cookies to Aoki. They now have 2 and 6 cookies, respectively.\n\nAoki gives three cookies to Takahashi. They now have 5 and 3 cookies, respectively.\n\nSample Input 2\n\n3 3 3\n\nSample Output 2\n\n1 3\n\nSample Input 3\n\n314159265 358979323 84\n\nSample Output 3\n\n448759046 224379523", "sample_input": "5 4 2\n"}, "reference_outputs": ["5 3\n"], "source_document_id": "p03228", "source_text": "Score : 200 points\n\nProblem Statement\n\nIn the beginning, Takahashi has A cookies, and Aoki has B cookies.\nThey will perform the following operation alternately, starting from Takahashi:\n\nIf the number of cookies in his hand is odd, eat one of those cookies; if the number is even, do nothing. Then, give one-half of the cookies in his hand to the other person.\n\nFind the numbers of cookies Takahashi and Aoki respectively have after performing K operations in total.\n\nConstraints\n\n1 \\leq A,B \\leq 10^9\n\n1 \\leq K \\leq 100\n\nA,B and K are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B K\n\nOutput\n\nPrint the number of cookies Takahashi has, and the number of cookies Aoki has, in this order, after performing K operations in total.\n\nSample Input 1\n\n5 4 2\n\nSample Output 1\n\n5 3\n\nThe process will go as follows:\n\nIn the beginning, Takahashi and Aoki have 5 and 4 cookies, respectively.\n\nTakahashi eats one cookie and gives two cookies to Aoki. They now have 2 and 6 cookies, respectively.\n\nAoki gives three cookies to Takahashi. They now have 5 and 3 cookies, respectively.\n\nSample Input 2\n\n3 3 3\n\nSample Output 2\n\n1 3\n\nSample Input 3\n\n314159265 358979323 84\n\nSample Output 3\n\n448759046 224379523", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s960683773", "group_id": "codeNet:p03229", "input_text": "Scanf.scanf \"%d\" (fun n ->\n let a = Array.init n (fun _ -> Scanf.scanf \" %d\" (fun a -> a)) in\n Array.sort compare a;\n\n let rec check v1 v2 lp rp sum =\n if lp > rp then sum else\n let q = [| abs (v1 - a.(lp)), 0;\n abs (v2 - a.(lp)), 1;\n abs (v1 - a.(rp)), 2;\n abs (v2 - a.(rp)), 3 |]\n in\n Array.sort compare q;\n match q.(3) with\n | v, 0 -> check a.(lp) v2 (lp + 1) rp (sum + v)\n | v, 1 -> check v1 a.(lp) (lp + 1) rp (sum + v)\n | v, 2 -> check a.(rp) v2 lp (rp - 1) (sum + v)\n | v, _ -> check v1 a.(rp) lp (rp - 1) (sum + v)\n in\n max (check a.(0) a.(0) 1 (n - 1) 0) (check a.(n - 1) a.(n - 1) 0 (n - 2) 0) |> Printf.printf \"%d\\n\"\n)", "language": "OCaml", "metadata": {"date": 1595475984, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p03229.html", "problem_id": "p03229", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03229/input.txt", "sample_output_relpath": "derived/input_output/data/p03229/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03229/OCaml/s960683773.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s960683773", "user_id": "u342443598"}, "prompt_components": {"gold_output": "21\n", "input_to_evaluate": "Scanf.scanf \"%d\" (fun n ->\n let a = Array.init n (fun _ -> Scanf.scanf \" %d\" (fun a -> a)) in\n Array.sort compare a;\n\n let rec check v1 v2 lp rp sum =\n if lp > rp then sum else\n let q = [| abs (v1 - a.(lp)), 0;\n abs (v2 - a.(lp)), 1;\n abs (v1 - a.(rp)), 2;\n abs (v2 - a.(rp)), 3 |]\n in\n Array.sort compare q;\n match q.(3) with\n | v, 0 -> check a.(lp) v2 (lp + 1) rp (sum + v)\n | v, 1 -> check v1 a.(lp) (lp + 1) rp (sum + v)\n | v, 2 -> check a.(rp) v2 lp (rp - 1) (sum + v)\n | v, _ -> check v1 a.(rp) lp (rp - 1) (sum + v)\n in\n max (check a.(0) a.(0) 1 (n - 1) 0) (check a.(n - 1) a.(n - 1) 0 (n - 2) 0) |> Printf.printf \"%d\\n\"\n)", "problem_context": "Score : 400 points\n\nProblem Statement\n\nYou are given N integers; the i-th of them is A_i.\nFind the maximum possible sum of the absolute differences between the adjacent elements after arranging these integers in a row in any order you like.\n\nConstraints\n\n2 \\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\n:\nA_N\n\nOutput\n\nPrint the maximum possible sum of the absolute differences between the adjacent elements after arranging the given integers in a row in any order you like.\n\nSample Input 1\n\n5\n6\n8\n1\n2\n3\n\nSample Output 1\n\n21\n\nWhen the integers are arranged as 3,8,1,6,2, the sum of the absolute differences between the adjacent elements is |3 - 8| + |8 - 1| + |1 - 6| + |6 - 2| = 21. This is the maximum possible sum.\n\nSample Input 2\n\n6\n3\n1\n4\n1\n5\n9\n\nSample Output 2\n\n25\n\nSample Input 3\n\n3\n5\n5\n1\n\nSample Output 3\n\n8", "sample_input": "5\n6\n8\n1\n2\n3\n"}, "reference_outputs": ["21\n"], "source_document_id": "p03229", "source_text": "Score : 400 points\n\nProblem Statement\n\nYou are given N integers; the i-th of them is A_i.\nFind the maximum possible sum of the absolute differences between the adjacent elements after arranging these integers in a row in any order you like.\n\nConstraints\n\n2 \\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\n:\nA_N\n\nOutput\n\nPrint the maximum possible sum of the absolute differences between the adjacent elements after arranging the given integers in a row in any order you like.\n\nSample Input 1\n\n5\n6\n8\n1\n2\n3\n\nSample Output 1\n\n21\n\nWhen the integers are arranged as 3,8,1,6,2, the sum of the absolute differences between the adjacent elements is |3 - 8| + |8 - 1| + |1 - 6| + |6 - 2| = 21. This is the maximum possible sum.\n\nSample Input 2\n\n6\n3\n1\n4\n1\n5\n9\n\nSample Output 2\n\n25\n\nSample Input 3\n\n3\n5\n5\n1\n\nSample Output 3\n\n8", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 845, "cpu_time_ms": 109, "memory_kb": 6720}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s948478879", "group_id": "codeNet:p03232", "input_text": "let rec power ( * ) e m n =\n if n <= 0 then e\n else power ( * ) (if n land 1 = 0 then e else m * e) (m * m) (n lsr 1)\n\nlet m = 1000000007\nlet ( +^ ) x y = (x + y) mod m\nlet ( *^ ) x y = (x * y) mod m\n\nlet inv x = power ( *^ ) 1 x (m - 2)\nlet perm n k =\n Array.fold_left ( *^ ) 1 @@\n Array.init k @@ ( + ) @@ n - k + 1\n\nlet () = Scanf.scanf \"%d\\n\" @@ fun n ->\n let ps = Array.make n 0 in\n for i = 0 to n - 1 do\n ps.(0) <- inv (1 + i) + ps.(0)\n done;\n for i = 1 to n - 1 do\n ps.(i) <- ps.(i - 1) + inv (1 + i) - inv (1 + n - i)\n done;\n Printf.printf \"%d\\n\" @@\n ( *^ ) (perm n n) @@\n Array.fold_left ( +^ ) 0 @@\n Array.init n @@ fun i ->\n Scanf.scanf \"%d \" @@ fun a -> a *^ ps.(i)\n", "language": "OCaml", "metadata": {"date": 1539606656, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03232.html", "problem_id": "p03232", "resource_group": "low_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/OCaml/s948478879.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s948478879", "user_id": "u504158101"}, "prompt_components": {"gold_output": "9\n", "input_to_evaluate": "let rec power ( * ) e m n =\n if n <= 0 then e\n else power ( * ) (if n land 1 = 0 then e else m * e) (m * m) (n lsr 1)\n\nlet m = 1000000007\nlet ( +^ ) x y = (x + y) mod m\nlet ( *^ ) x y = (x * y) mod m\n\nlet inv x = power ( *^ ) 1 x (m - 2)\nlet perm n k =\n Array.fold_left ( *^ ) 1 @@\n Array.init k @@ ( + ) @@ n - k + 1\n\nlet () = Scanf.scanf \"%d\\n\" @@ fun n ->\n let ps = Array.make n 0 in\n for i = 0 to n - 1 do\n ps.(0) <- inv (1 + i) + ps.(0)\n done;\n for i = 1 to n - 1 do\n ps.(i) <- ps.(i - 1) + inv (1 + i) - inv (1 + n - i)\n done;\n Printf.printf \"%d\\n\" @@\n ( *^ ) (perm n n) @@\n Array.fold_left ( +^ ) 0 @@\n Array.init n @@ fun i ->\n Scanf.scanf \"%d \" @@ fun a -> a *^ ps.(i)\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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 718, "cpu_time_ms": 112, "memory_kb": 6016}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s382833873", "group_id": "codeNet:p03238", "input_text": "open Printf open Scanf\nmodule MyInt = struct let (+) = (+) let (-) = (-) let (/) = (/) let ( * ) = ( * ) let (mod) = (mod) let (%) = (mod) let (+=) r v = r := !r + v let (-=) r v = r := !r - v let ( *=) r v= r := !r * v let (/=) r v = r := !r / v let abs v = abs v let (land),(lor),(lxor),lnot,(lsl),(lsr),(asr) = (land),(lor),(lxor),lnot,(lsl),(lsr),(asr) let min_int,max_int = min_int,max_int end\nmodule MyInt64 = struct\n\tlet (+$) = (+) let (-$) = (-) let (/$) = (/) let ( *$) = ( * ) let (+) p q = Int64.add p q let (-) p q = Int64.sub p q let ( * ) p q = Int64.mul p q let (/) p q = Int64.div p q let (+=) r v = r := !r + v let (-=) r v = r := !r - v let ( *=) r v= r := !r * v let (/=) r v = r := !r / v let labs p = if p < 0L then -1L*p else p let (~|) p = Int64.to_int p let (~~|) p = Int64.of_int p let input_i64_array n = Array.init (~| n) (fun _ -> Scanf.scanf \" %Ld\" (fun v -> v)) let get_i64 _ = Scanf.scanf \" %Ld\" (fun v -> v) let get_2_i64 _ = Scanf.scanf \" %Ld %Ld\" (fun u v -> u,v) let get_3_i64 _ = Scanf.scanf \" %Ld %Ld %Ld\" (fun u v w -> u,v,w) let get_4_i64 _ = Scanf.scanf \" %Ld %Ld %Ld %Ld\" (fun u v w x -> u,v,w,x) let get_5_i64 _ = Scanf.scanf \" %Ld %Ld %Ld %Ld %Ld\" (fun u v w x y -> u,v,w,x,y) let print_i64_endline n = n |> Int64.to_string |> print_endline let (mod) m n = m - (m/n) * n let (%) = (mod) let rec gcd m n = match m,n with | m,0L -> m | m,n -> gcd n (m mod n) let lcm m n = (m*n) / gcd m n let rep from_ to_ fbod = let i,f = ref ~|from_,ref true in while !i <= ~|to_ && !f do match fbod ~~| !i with | `Break -> f := false | _ -> i := !i +$ 1; done let repb from_ to_ fbod = let i,f = ref ~|from_,ref true in while !i <= ~|to_ && !f do match fbod (~~| !i) with | `Break -> f := false | _ -> i := !i +$ 1 done; !f let repm from_ to_ m_init fbod = let i,f,m = ref ~|from_,ref true,ref m_init in while !i <= ~|to_ && !f do match fbod !m (~~| !i) with | `Break -> f := false | `Break_m m' -> (f := false; m := m') | `Ok m' -> (i := !i +$ 1; m := m') done; !m let repmb from_ to_ m_init fbod = let i,f,m = ref ~|from_,ref true,ref m_init in while !i <= ~|to_ && !f do match fbod (~~| !i) !m with | `Break -> f := false | `Break_m m' -> (f := false; m := m') | `Ok m' -> (i := !i +$ 1; m := m') done; (!m,!f) let string_of_list ?(separator=\" \") f ls = let rec f0 a s = match a with | [] -> s | [h] -> s ^ (f h) ^ separator | h::t -> f0 t (s ^ (f h) ^ separator) in f0 ls \"\" let char_list_of_string str = let rec f0 i a = if i<0 then a else f0 (i-$1) (str.[i]::a) in f0 (String.length str -$ 1) [] let string_of_char_list ls = List.fold_left (fun u v -> u ^ (String.make 1 v)) \"\" ls\n\tlet (@@@) = (@) let (@) a i = a.(~|i) let (<@) a (i,v) = a.(~|i) <- v\n\tlet ceildiv m n = (m+n-1L) / n\n\tlet abs v = Int64.abs v let (land),(lor),(lxor),lnot,(lsl),(lsr),(asr) = let open Int64 in (logand),(logor),(logxor),lognot,(fun u v -> shift_left u (~|v)),(fun u v -> shift_right u (~|v)),(fun u v -> shift_right_logical u (~|v)) let min_int,max_int = Int64.min_int,Int64.max_int let get_string _ = scanf \" %s\" (fun v -> v)\n\tlet i32,i64 = Int64.to_int,Int64.of_int let alen a = i64 @@ Array.length a\n\tlet dump_array a = a |> Array.to_list |> string_of_list Int64.to_string |> print_endline let i32_get_int _ = Scanf.scanf \" %d\" (fun v -> v) let i32_get_2_ints _ = Scanf.scanf \" %d %d\" (fun u v -> u,v) let i32_get_3_ints _ = Scanf.scanf \" %d %d %d\" (fun u v w -> u,v,w) let i32_get_4_ints _ = Scanf.scanf \" %d %d %d %d\" (fun u v w x -> u,v,w,x) let i32_get_5_ints _ = Scanf.scanf \" %d %d %d %d %d\" (fun u v w x y -> u,v,w,x,y) let repi from_ to_ fbod = let i,f = ref from_,ref true in while !i <= to_ && !f do match fbod !i with | `Break -> f := false | _ -> i := !i +$ 1 done\nend open MyInt64\n\nlet () =\n\tlet n = get_i64 0 in\n\tif n = 1L then (\n\t\tprint_endline \"Hello World\"\n\t) else (\n\t\tlet a,b = get_2_i64 0 in printf \"%Ld\\n\" (a+b)\n\t)", "language": "OCaml", "metadata": {"date": 1538874068, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03238.html", "problem_id": "p03238", "resource_group": "low_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/OCaml/s382833873.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s382833873", "user_id": "u481480055"}, "prompt_components": {"gold_output": "Hello World\n", "input_to_evaluate": "open Printf open Scanf\nmodule MyInt = struct let (+) = (+) let (-) = (-) let (/) = (/) let ( * ) = ( * ) let (mod) = (mod) let (%) = (mod) let (+=) r v = r := !r + v let (-=) r v = r := !r - v let ( *=) r v= r := !r * v let (/=) r v = r := !r / v let abs v = abs v let (land),(lor),(lxor),lnot,(lsl),(lsr),(asr) = (land),(lor),(lxor),lnot,(lsl),(lsr),(asr) let min_int,max_int = min_int,max_int end\nmodule MyInt64 = struct\n\tlet (+$) = (+) let (-$) = (-) let (/$) = (/) let ( *$) = ( * ) let (+) p q = Int64.add p q let (-) p q = Int64.sub p q let ( * ) p q = Int64.mul p q let (/) p q = Int64.div p q let (+=) r v = r := !r + v let (-=) r v = r := !r - v let ( *=) r v= r := !r * v let (/=) r v = r := !r / v let labs p = if p < 0L then -1L*p else p let (~|) p = Int64.to_int p let (~~|) p = Int64.of_int p let input_i64_array n = Array.init (~| n) (fun _ -> Scanf.scanf \" %Ld\" (fun v -> v)) let get_i64 _ = Scanf.scanf \" %Ld\" (fun v -> v) let get_2_i64 _ = Scanf.scanf \" %Ld %Ld\" (fun u v -> u,v) let get_3_i64 _ = Scanf.scanf \" %Ld %Ld %Ld\" (fun u v w -> u,v,w) let get_4_i64 _ = Scanf.scanf \" %Ld %Ld %Ld %Ld\" (fun u v w x -> u,v,w,x) let get_5_i64 _ = Scanf.scanf \" %Ld %Ld %Ld %Ld %Ld\" (fun u v w x y -> u,v,w,x,y) let print_i64_endline n = n |> Int64.to_string |> print_endline let (mod) m n = m - (m/n) * n let (%) = (mod) let rec gcd m n = match m,n with | m,0L -> m | m,n -> gcd n (m mod n) let lcm m n = (m*n) / gcd m n let rep from_ to_ fbod = let i,f = ref ~|from_,ref true in while !i <= ~|to_ && !f do match fbod ~~| !i with | `Break -> f := false | _ -> i := !i +$ 1; done let repb from_ to_ fbod = let i,f = ref ~|from_,ref true in while !i <= ~|to_ && !f do match fbod (~~| !i) with | `Break -> f := false | _ -> i := !i +$ 1 done; !f let repm from_ to_ m_init fbod = let i,f,m = ref ~|from_,ref true,ref m_init in while !i <= ~|to_ && !f do match fbod !m (~~| !i) with | `Break -> f := false | `Break_m m' -> (f := false; m := m') | `Ok m' -> (i := !i +$ 1; m := m') done; !m let repmb from_ to_ m_init fbod = let i,f,m = ref ~|from_,ref true,ref m_init in while !i <= ~|to_ && !f do match fbod (~~| !i) !m with | `Break -> f := false | `Break_m m' -> (f := false; m := m') | `Ok m' -> (i := !i +$ 1; m := m') done; (!m,!f) let string_of_list ?(separator=\" \") f ls = let rec f0 a s = match a with | [] -> s | [h] -> s ^ (f h) ^ separator | h::t -> f0 t (s ^ (f h) ^ separator) in f0 ls \"\" let char_list_of_string str = let rec f0 i a = if i<0 then a else f0 (i-$1) (str.[i]::a) in f0 (String.length str -$ 1) [] let string_of_char_list ls = List.fold_left (fun u v -> u ^ (String.make 1 v)) \"\" ls\n\tlet (@@@) = (@) let (@) a i = a.(~|i) let (<@) a (i,v) = a.(~|i) <- v\n\tlet ceildiv m n = (m+n-1L) / n\n\tlet abs v = Int64.abs v let (land),(lor),(lxor),lnot,(lsl),(lsr),(asr) = let open Int64 in (logand),(logor),(logxor),lognot,(fun u v -> shift_left u (~|v)),(fun u v -> shift_right u (~|v)),(fun u v -> shift_right_logical u (~|v)) let min_int,max_int = Int64.min_int,Int64.max_int let get_string _ = scanf \" %s\" (fun v -> v)\n\tlet i32,i64 = Int64.to_int,Int64.of_int let alen a = i64 @@ Array.length a\n\tlet dump_array a = a |> Array.to_list |> string_of_list Int64.to_string |> print_endline let i32_get_int _ = Scanf.scanf \" %d\" (fun v -> v) let i32_get_2_ints _ = Scanf.scanf \" %d %d\" (fun u v -> u,v) let i32_get_3_ints _ = Scanf.scanf \" %d %d %d\" (fun u v w -> u,v,w) let i32_get_4_ints _ = Scanf.scanf \" %d %d %d %d\" (fun u v w x -> u,v,w,x) let i32_get_5_ints _ = Scanf.scanf \" %d %d %d %d %d\" (fun u v w x y -> u,v,w,x,y) let repi from_ to_ fbod = let i,f = ref from_,ref true in while !i <= to_ && !f do match fbod !i with | `Break -> f := false | _ -> i := !i +$ 1 done\nend open MyInt64\n\nlet () =\n\tlet n = get_i64 0 in\n\tif n = 1L then (\n\t\tprint_endline \"Hello World\"\n\t) else (\n\t\tlet a,b = get_2_i64 0 in printf \"%Ld\\n\" (a+b)\n\t)", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3853, "cpu_time_ms": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s854470946", "group_id": "codeNet:p03239", "input_text": "let n, t = Scanf.scanf \" %d %d\" @@ fun a b -> a, b\nlet cts = Array.to_list @@ Array.init n @@ fun _ -> Scanf.scanf \" %d %d\" @@ fun a b -> a, b\nlet _ = match List.filter (fun (_, t0) -> t0 <= t) cts |> List.sort compare with\n | [] -> print_endline \"TLE\"\n | (c, _) :: _ -> Printf.printf \"%d\\n\" c", "language": "OCaml", "metadata": {"date": 1563233641, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03239.html", "problem_id": "p03239", "resource_group": "low_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/OCaml/s854470946.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s854470946", "user_id": "u732304692"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "let n, t = Scanf.scanf \" %d %d\" @@ fun a b -> a, b\nlet cts = Array.to_list @@ Array.init n @@ fun _ -> Scanf.scanf \" %d %d\" @@ fun a b -> a, b\nlet _ = match List.filter (fun (_, t0) -> t0 <= t) cts |> List.sort compare with\n | [] -> print_endline \"TLE\"\n | (c, _) :: _ -> Printf.printf \"%d\\n\" c", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 295, "cpu_time_ms": 1, "memory_kb": 512}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s928721482", "group_id": "codeNet:p03239", "input_text": "let n, t0 = Scanf.scanf \" %d %d\" @@ fun a b -> a, b\nlet cts = Array.init n @@ fun _ -> Scanf.scanf \" %d %d\" @@ fun a b -> a, b\nlet _ =\n let cts1 = cts |> Array.to_list |> List.filter (fun (c, t) -> t <= t0) in\n if cts1 = [] then print_endline \"TLE\"\n else List.fold_left min cts.(0) cts1 |> fst |> Printf.printf \"%d\\n\"", "language": "OCaml", "metadata": {"date": 1560058590, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03239.html", "problem_id": "p03239", "resource_group": "low_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/OCaml/s928721482.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s928721482", "user_id": "u732304692"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "let n, t0 = Scanf.scanf \" %d %d\" @@ fun a b -> a, b\nlet cts = Array.init n @@ fun _ -> Scanf.scanf \" %d %d\" @@ fun a b -> a, b\nlet _ =\n let cts1 = cts |> Array.to_list |> List.filter (fun (c, t) -> t <= t0) in\n if cts1 = [] then print_endline \"TLE\"\n else List.fold_left min cts.(0) cts1 |> fst |> Printf.printf \"%d\\n\"", "problem_context": "Score : 200 points\n\nProblem Statement\n\nWhen Mr. X is away from home, he has decided to use his smartwatch to search the best route to go back home, to participate in ABC.\n\nYou, the smartwatch, has found N routes to his home.\n\nIf Mr. X uses the i-th of these routes, he will get home in time t_i at cost c_i.\n\nFind the smallest cost of a route that takes not longer than time T.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 100\n\n1 \\leq T \\leq 1000\n\n1 \\leq c_i \\leq 1000\n\n1 \\leq t_i \\leq 1000\n\nThe pairs (c_i, t_i) are distinct.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN T\nc_1 t_1\nc_2 t_2\n:\nc_N t_N\n\nOutput\n\nPrint the smallest cost of a route that takes not longer than time T.\n\nIf there is no route that takes not longer than time T, print TLE instead.\n\nSample Input 1\n\n3 70\n7 60\n1 80\n4 50\n\nSample Output 1\n\n4\n\nThe first route gets him home at cost 7.\n\nThe second route takes longer than time T = 70.\n\nThe third route gets him home at cost 4.\n\nThus, the cost 4 of the third route is the minimum.\n\nSample Input 2\n\n4 3\n1 1000\n2 4\n3 1000\n4 500\n\nSample Output 2\n\nTLE\n\nThere is no route that takes not longer than time T = 3.\n\nSample Input 3\n\n5 9\n25 8\n5 9\n4 10\n1000 1000\n6 1\n\nSample Output 3\n\n5", "sample_input": "3 70\n7 60\n1 80\n4 50\n"}, "reference_outputs": ["4\n"], "source_document_id": "p03239", "source_text": "Score : 200 points\n\nProblem Statement\n\nWhen Mr. X is away from home, he has decided to use his smartwatch to search the best route to go back home, to participate in ABC.\n\nYou, the smartwatch, has found N routes to his home.\n\nIf Mr. X uses the i-th of these routes, he will get home in time t_i at cost c_i.\n\nFind the smallest cost of a route that takes not longer than time T.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 100\n\n1 \\leq T \\leq 1000\n\n1 \\leq c_i \\leq 1000\n\n1 \\leq t_i \\leq 1000\n\nThe pairs (c_i, t_i) are distinct.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN T\nc_1 t_1\nc_2 t_2\n:\nc_N t_N\n\nOutput\n\nPrint the smallest cost of a route that takes not longer than time T.\n\nIf there is no route that takes not longer than time T, print TLE instead.\n\nSample Input 1\n\n3 70\n7 60\n1 80\n4 50\n\nSample Output 1\n\n4\n\nThe first route gets him home at cost 7.\n\nThe second route takes longer than time T = 70.\n\nThe third route gets him home at cost 4.\n\nThus, the cost 4 of the third route is the minimum.\n\nSample Input 2\n\n4 3\n1 1000\n2 4\n3 1000\n4 500\n\nSample Output 2\n\nTLE\n\nThere is no route that takes not longer than time T = 3.\n\nSample Input 3\n\n5 9\n25 8\n5 9\n4 10\n1000 1000\n6 1\n\nSample Output 3\n\n5", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 512}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s288720267", "group_id": "codeNet:p03239", "input_text": "Scanf.scanf \"%d %d\\n\" (fun n t->\n let rec loop i m=\n if i=n then m else\n let m = Scanf.scanf \"%d %d\\n\" (fun c1 t1 ->\n if t1\n let rec loop i m=\n if i=n then m else\n let m = Scanf.scanf \"%d %d\\n\" (fun c1 t1 ->\n if t1 scanf \" %d %d\" pair)\n\nlet f x = if x <= t then x else 2000\n\nlet () =\n Array.sort (fun (_, a) (_, b) -> f a - f b) vs;\n let (a, b) = vs.(0) in\n if b <= t then printf \"%d\\n\" a else printf \"LTE\\n\"\n", "language": "OCaml", "metadata": {"date": 1538874697, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03239.html", "problem_id": "p03239", "resource_group": "low_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/OCaml/s764501917.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s764501917", "user_id": "u450300828"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "open Printf\nopen Scanf\n\nlet id x = x\nlet pair x y = x, y\n\nlet n, t = scanf \"%d %d\" pair\n\nlet vs = Array.init n (fun _ -> scanf \" %d %d\" pair)\n\nlet f x = if x <= t then x else 2000\n\nlet () =\n Array.sort (fun (_, a) (_, b) -> f a - f b) vs;\n let (a, b) = vs.(0) in\n if b <= t then printf \"%d\\n\" a else printf \"LTE\\n\"\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nWhen Mr. X is away from home, he has decided to use his smartwatch to search the best route to go back home, to participate in ABC.\n\nYou, the smartwatch, has found N routes to his home.\n\nIf Mr. X uses the i-th of these routes, he will get home in time t_i at cost c_i.\n\nFind the smallest cost of a route that takes not longer than time T.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 100\n\n1 \\leq T \\leq 1000\n\n1 \\leq c_i \\leq 1000\n\n1 \\leq t_i \\leq 1000\n\nThe pairs (c_i, t_i) are distinct.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN T\nc_1 t_1\nc_2 t_2\n:\nc_N t_N\n\nOutput\n\nPrint the smallest cost of a route that takes not longer than time T.\n\nIf there is no route that takes not longer than time T, print TLE instead.\n\nSample Input 1\n\n3 70\n7 60\n1 80\n4 50\n\nSample Output 1\n\n4\n\nThe first route gets him home at cost 7.\n\nThe second route takes longer than time T = 70.\n\nThe third route gets him home at cost 4.\n\nThus, the cost 4 of the third route is the minimum.\n\nSample Input 2\n\n4 3\n1 1000\n2 4\n3 1000\n4 500\n\nSample Output 2\n\nTLE\n\nThere is no route that takes not longer than time T = 3.\n\nSample Input 3\n\n5 9\n25 8\n5 9\n4 10\n1000 1000\n6 1\n\nSample Output 3\n\n5", "sample_input": "3 70\n7 60\n1 80\n4 50\n"}, "reference_outputs": ["4\n"], "source_document_id": "p03239", "source_text": "Score : 200 points\n\nProblem Statement\n\nWhen Mr. X is away from home, he has decided to use his smartwatch to search the best route to go back home, to participate in ABC.\n\nYou, the smartwatch, has found N routes to his home.\n\nIf Mr. X uses the i-th of these routes, he will get home in time t_i at cost c_i.\n\nFind the smallest cost of a route that takes not longer than time T.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 100\n\n1 \\leq T \\leq 1000\n\n1 \\leq c_i \\leq 1000\n\n1 \\leq t_i \\leq 1000\n\nThe pairs (c_i, t_i) are distinct.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN T\nc_1 t_1\nc_2 t_2\n:\nc_N t_N\n\nOutput\n\nPrint the smallest cost of a route that takes not longer than time T.\n\nIf there is no route that takes not longer than time T, print TLE instead.\n\nSample Input 1\n\n3 70\n7 60\n1 80\n4 50\n\nSample Output 1\n\n4\n\nThe first route gets him home at cost 7.\n\nThe second route takes longer than time T = 70.\n\nThe third route gets him home at cost 4.\n\nThus, the cost 4 of the third route is the minimum.\n\nSample Input 2\n\n4 3\n1 1000\n2 4\n3 1000\n4 500\n\nSample Output 2\n\nTLE\n\nThere is no route that takes not longer than time T = 3.\n\nSample Input 3\n\n5 9\n25 8\n5 9\n4 10\n1000 1000\n6 1\n\nSample Output 3\n\n5", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s465078344", "group_id": "codeNet:p03241", "input_text": "let n, m, ans = Scanf.scanf \"%d %d\" @@ fun a b -> a, b, ref 0\nlet f g n = let rec f i = if i * i <= n then (if n mod i = 0 then (g i; if i <> n / i then g (n / i)); f (i + 1)) in f 1\nlet g d = if m / d >= n then ans := max !ans d\nlet _ = f g m; Printf.printf \"%d\\n\" !ans", "language": "OCaml", "metadata": {"date": 1580501961, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03241.html", "problem_id": "p03241", "resource_group": "low_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/OCaml/s465078344.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s465078344", "user_id": "u732304692"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "let n, m, ans = Scanf.scanf \"%d %d\" @@ fun a b -> a, b, ref 0\nlet f g n = let rec f i = if i * i <= n then (if n mod i = 0 then (g i; if i <> n / i then g (n / i)); f (i + 1)) in f 1\nlet g d = if m / d >= n then ans := max !ans d\nlet _ = f g m; Printf.printf \"%d\\n\" !ans", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 2, "memory_kb": 4480}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s563167644", "group_id": "codeNet:p03241", "input_text": "let rec floor_sqrt acc acc_x_2_x_r sq_acc_minus_z r sq_r =\n if r = 0 then acc\n else\n let sq_acc_minus_z' = sq_acc_minus_z + acc_x_2_x_r + sq_r in\n ( if sq_acc_minus_z' <= 0 then\n floor_sqrt (acc + r) ((acc_x_2_x_r lsr 1) + sq_r) sq_acc_minus_z'\n else\n floor_sqrt acc (acc_x_2_x_r lsr 1) sq_acc_minus_z) (r lsr 1) (sq_r lsr 2)\nlet floor_sqrt z = floor_sqrt 0 0 (~-z) (1 lsl 30) (1 lsl 60)\n\nlet () = Scanf.scanf \"%d %d\" @@ fun n m ->\n Printf.printf \"%d\\n\" @@\n if n = 1 then m\n else Array.fold_left (List.fold_left max) 1 @@\n Array.init (floor_sqrt m) @@ fun i ->\n if 0 < m mod (i + 1)\n then []\n else (if m / (i + 1) < n then [] else [i + 1]) @ (if (i + 1) < n then [] else [m / (i + 1)])\n\n", "language": "OCaml", "metadata": {"date": 1538878920, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03241.html", "problem_id": "p03241", "resource_group": "low_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/OCaml/s563167644.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s563167644", "user_id": "u504158101"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "let rec floor_sqrt acc acc_x_2_x_r sq_acc_minus_z r sq_r =\n if r = 0 then acc\n else\n let sq_acc_minus_z' = sq_acc_minus_z + acc_x_2_x_r + sq_r in\n ( if sq_acc_minus_z' <= 0 then\n floor_sqrt (acc + r) ((acc_x_2_x_r lsr 1) + sq_r) sq_acc_minus_z'\n else\n floor_sqrt acc (acc_x_2_x_r lsr 1) sq_acc_minus_z) (r lsr 1) (sq_r lsr 2)\nlet floor_sqrt z = floor_sqrt 0 0 (~-z) (1 lsl 30) (1 lsl 60)\n\nlet () = Scanf.scanf \"%d %d\" @@ fun n m ->\n Printf.printf \"%d\\n\" @@\n if n = 1 then m\n else Array.fold_left (List.fold_left max) 1 @@\n Array.init (floor_sqrt m) @@ fun i ->\n if 0 < m mod (i + 1)\n then []\n else (if m / (i + 1) < n then [] else [i + 1]) @ (if (i + 1) < n then [] else [m / (i + 1)])\n\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nYou are given integers N and M.\n\nConsider a sequence a of length N consisting of positive integers such that a_1 + a_2 + ... + a_N = M. Find the maximum possible value of the greatest common divisor of a_1, a_2, ..., a_N.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\nN \\leq M \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\n\nOutput\n\nPrint the maximum possible value of the greatest common divisor of a sequence a_1, a_2, ..., a_N that satisfies the condition.\n\nSample Input 1\n\n3 14\n\nSample Output 1\n\n2\n\nConsider the sequence (a_1, a_2, a_3) = (2, 4, 8). Their greatest common divisor is 2, and this is the maximum value.\n\nSample Input 2\n\n10 123\n\nSample Output 2\n\n3\n\nSample Input 3\n\n100000 1000000000\n\nSample Output 3\n\n10000", "sample_input": "3 14\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03241", "source_text": "Score : 400 points\n\nProblem Statement\n\nYou are given integers N and M.\n\nConsider a sequence a of length N consisting of positive integers such that a_1 + a_2 + ... + a_N = M. Find the maximum possible value of the greatest common divisor of a_1, a_2, ..., a_N.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 10^5\n\nN \\leq M \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\n\nOutput\n\nPrint the maximum possible value of the greatest common divisor of a sequence a_1, a_2, ..., a_N that satisfies the condition.\n\nSample Input 1\n\n3 14\n\nSample Output 1\n\n2\n\nConsider the sequence (a_1, a_2, a_3) = (2, 4, 8). Their greatest common divisor is 2, and this is the maximum value.\n\nSample Input 2\n\n10 123\n\nSample Output 2\n\n3\n\nSample Input 3\n\n100000 1000000000\n\nSample Output 3\n\n10000", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 735, "cpu_time_ms": 3, "memory_kb": 4608}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s492424566", "group_id": "codeNet:p03242", "input_text": "open Printf\nopen Scanf\n\nlet solve n = 1110 - n\n\nlet () =\n scanf \"%d \" solve |> printf \"%d\\n\"\n", "language": "OCaml", "metadata": {"date": 1582082123, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03242.html", "problem_id": "p03242", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03242/input.txt", "sample_output_relpath": "derived/input_output/data/p03242/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03242/OCaml/s492424566.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s492424566", "user_id": "u388783188"}, "prompt_components": {"gold_output": "991\n", "input_to_evaluate": "open Printf\nopen Scanf\n\nlet solve n = 1110 - n\n\nlet () =\n scanf \"%d \" solve |> printf \"%d\\n\"\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nCat Snuke is learning to write characters.\nToday, he practiced writing digits 1 and 9, but he did it the other way around.\n\nYou are given a three-digit integer n written by Snuke.\nPrint the integer obtained by replacing each digit 1 with 9 and each digit 9 with 1 in n.\n\nConstraints\n\n111 \\leq n \\leq 999\n\nn is an integer consisting of digits 1 and 9.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nn\n\nOutput\n\nPrint the integer obtained by replacing each occurrence of 1 with 9 and each occurrence of 9 with 1 in n.\n\nSample Input 1\n\n119\n\nSample Output 1\n\n991\n\nReplace the 9 in the ones place with 1, the 1 in the tens place with 9 and the 1 in the hundreds place with 9. The answer is 991.\n\nSample Input 2\n\n999\n\nSample Output 2\n\n111", "sample_input": "119\n"}, "reference_outputs": ["991\n"], "source_document_id": "p03242", "source_text": "Score : 100 points\n\nProblem Statement\n\nCat Snuke is learning to write characters.\nToday, he practiced writing digits 1 and 9, but he did it the other way around.\n\nYou are given a three-digit integer n written by Snuke.\nPrint the integer obtained by replacing each digit 1 with 9 and each digit 9 with 1 in n.\n\nConstraints\n\n111 \\leq n \\leq 999\n\nn is an integer consisting of digits 1 and 9.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nn\n\nOutput\n\nPrint the integer obtained by replacing each occurrence of 1 with 9 and each occurrence of 9 with 1 in n.\n\nSample Input 1\n\n119\n\nSample Output 1\n\n991\n\nReplace the 9 in the ones place with 1, the 1 in the tens place with 9 and the 1 in the hundreds place with 9. The answer is 991.\n\nSample Input 2\n\n999\n\nSample Output 2\n\n111", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s307593313", "group_id": "codeNet:p03243", "input_text": "let n = read_int ()\nlet _ = for i = 1 to 9 do if 111 * i >= n then (Printf.printf \"%d\\n\" @@ 111 * i; exit 0) done", "language": "OCaml", "metadata": {"date": 1561673950, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03243.html", "problem_id": "p03243", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03243/input.txt", "sample_output_relpath": "derived/input_output/data/p03243/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03243/OCaml/s307593313.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s307593313", "user_id": "u732304692"}, "prompt_components": {"gold_output": "111\n", "input_to_evaluate": "let n = read_int ()\nlet _ = for i = 1 to 9 do if 111 * i >= n then (Printf.printf \"%d\\n\" @@ 111 * i; exit 0) done", "problem_context": "Score : 200 points\n\nProblem Statement\n\nKurohashi has never participated in AtCoder Beginner Contest (ABC).\n\nThe next ABC to be held is ABC N (the N-th ABC ever held).\nKurohashi wants to make his debut in some ABC x such that all the digits of x in base ten are the same.\n\nWhat is the earliest ABC where Kurohashi can make his debut?\n\nConstraints\n\n100 \\leq N \\leq 999\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nIf the earliest ABC where Kurohashi can make his debut is ABC n, print n.\n\nSample Input 1\n\n111\n\nSample Output 1\n\n111\n\nThe next ABC to be held is ABC 111, where Kurohashi can make his debut.\n\nSample Input 2\n\n112\n\nSample Output 2\n\n222\n\nThe next ABC to be held is ABC 112, which means Kurohashi can no longer participate in ABC 111.\nAmong the ABCs where Kurohashi can make his debut, the earliest one is ABC 222.\n\nSample Input 3\n\n750\n\nSample Output 3\n\n777", "sample_input": "111\n"}, "reference_outputs": ["111\n"], "source_document_id": "p03243", "source_text": "Score : 200 points\n\nProblem Statement\n\nKurohashi has never participated in AtCoder Beginner Contest (ABC).\n\nThe next ABC to be held is ABC N (the N-th ABC ever held).\nKurohashi wants to make his debut in some ABC x such that all the digits of x in base ten are the same.\n\nWhat is the earliest ABC where Kurohashi can make his debut?\n\nConstraints\n\n100 \\leq N \\leq 999\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nIf the earliest ABC where Kurohashi can make his debut is ABC n, print n.\n\nSample Input 1\n\n111\n\nSample Output 1\n\n111\n\nThe next ABC to be held is ABC 111, where Kurohashi can make his debut.\n\nSample Input 2\n\n112\n\nSample Output 2\n\n222\n\nThe next ABC to be held is ABC 112, which means Kurohashi can no longer participate in ABC 111.\nAmong the ABCs where Kurohashi can make his debut, the earliest one is ABC 222.\n\nSample Input 3\n\n750\n\nSample Output 3\n\n777", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s359106940", "group_id": "codeNet:p03243", "input_text": "let () =\n Scanf.scanf \"%1d %1d %1d\\n\"\n (fun a b c ->\n if a = b && b = c then a*100+b*10+c\n else if a > b || (a = b && b > c) then a*100+a*10+a\n else (a+1)*100+(a+1)*10+(a+1))\n |> print_int", "language": "OCaml", "metadata": {"date": 1555936215, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03243.html", "problem_id": "p03243", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03243/input.txt", "sample_output_relpath": "derived/input_output/data/p03243/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03243/OCaml/s359106940.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s359106940", "user_id": "u307426615"}, "prompt_components": {"gold_output": "111\n", "input_to_evaluate": "let () =\n Scanf.scanf \"%1d %1d %1d\\n\"\n (fun a b c ->\n if a = b && b = c then a*100+b*10+c\n else if a > b || (a = b && b > c) then a*100+a*10+a\n else (a+1)*100+(a+1)*10+(a+1))\n |> print_int", "problem_context": "Score : 200 points\n\nProblem Statement\n\nKurohashi has never participated in AtCoder Beginner Contest (ABC).\n\nThe next ABC to be held is ABC N (the N-th ABC ever held).\nKurohashi wants to make his debut in some ABC x such that all the digits of x in base ten are the same.\n\nWhat is the earliest ABC where Kurohashi can make his debut?\n\nConstraints\n\n100 \\leq N \\leq 999\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nIf the earliest ABC where Kurohashi can make his debut is ABC n, print n.\n\nSample Input 1\n\n111\n\nSample Output 1\n\n111\n\nThe next ABC to be held is ABC 111, where Kurohashi can make his debut.\n\nSample Input 2\n\n112\n\nSample Output 2\n\n222\n\nThe next ABC to be held is ABC 112, which means Kurohashi can no longer participate in ABC 111.\nAmong the ABCs where Kurohashi can make his debut, the earliest one is ABC 222.\n\nSample Input 3\n\n750\n\nSample Output 3\n\n777", "sample_input": "111\n"}, "reference_outputs": ["111\n"], "source_document_id": "p03243", "source_text": "Score : 200 points\n\nProblem Statement\n\nKurohashi has never participated in AtCoder Beginner Contest (ABC).\n\nThe next ABC to be held is ABC N (the N-th ABC ever held).\nKurohashi wants to make his debut in some ABC x such that all the digits of x in base ten are the same.\n\nWhat is the earliest ABC where Kurohashi can make his debut?\n\nConstraints\n\n100 \\leq N \\leq 999\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nIf the earliest ABC where Kurohashi can make his debut is ABC n, print n.\n\nSample Input 1\n\n111\n\nSample Output 1\n\n111\n\nThe next ABC to be held is ABC 111, where Kurohashi can make his debut.\n\nSample Input 2\n\n112\n\nSample Output 2\n\n222\n\nThe next ABC to be held is ABC 112, which means Kurohashi can no longer participate in ABC 111.\nAmong the ABCs where Kurohashi can make his debut, the earliest one is ABC 222.\n\nSample Input 3\n\n750\n\nSample Output 3\n\n777", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s129008137", "group_id": "codeNet:p03244", "input_text": "let n = Scanf.scanf \" %d\" (+) 0\nlet vs = Array.init n @@ fun _ -> Scanf.scanf \" %d\" (+) 0\nlet css = Array.make_matrix 2 100001 0\nlet _ = Array.iteri (fun i v -> css.(i mod 2).(v) <- css.(i mod 2).(v) + 1) vs\nlet cssi = Array.map (fun cs -> Array.mapi (fun i c -> c, i) cs) css\nlet (e0, em), e1, (o0, om), o1 = List.iter (fun i -> Array.sort (fun x y -> compare y x) cssi.(i)) [0; 1];\n cssi.(0).(0), fst cssi.(0).(1), cssi.(1).(0), fst cssi.(1).(1)\nlet _ = Printf.printf \"%d\\n\" @@ if em = om then n - max (e0 + o1) (e1 + o0) else n - e0 - o0", "language": "OCaml", "metadata": {"date": 1563489340, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03244.html", "problem_id": "p03244", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03244/input.txt", "sample_output_relpath": "derived/input_output/data/p03244/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03244/OCaml/s129008137.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s129008137", "user_id": "u732304692"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "let n = Scanf.scanf \" %d\" (+) 0\nlet vs = Array.init n @@ fun _ -> Scanf.scanf \" %d\" (+) 0\nlet css = Array.make_matrix 2 100001 0\nlet _ = Array.iteri (fun i v -> css.(i mod 2).(v) <- css.(i mod 2).(v) + 1) vs\nlet cssi = Array.map (fun cs -> Array.mapi (fun i c -> c, i) cs) css\nlet (e0, em), e1, (o0, om), o1 = List.iter (fun i -> Array.sort (fun x y -> compare y x) cssi.(i)) [0; 1];\n cssi.(0).(0), fst cssi.(0).(1), cssi.(1).(0), fst cssi.(1).(1)\nlet _ = Printf.printf \"%d\\n\" @@ if em = om then n - max (e0 + o1) (e1 + o0) else n - e0 - o0", "problem_context": "Score : 300 points\n\nProblem Statement\n\nA sequence a_1,a_2,... ,a_n is said to be /\\/\\/\\/ when the following conditions are satisfied:\n\nFor each i = 1,2,..., n-2, a_i = a_{i+2}.\n\nExactly two different numbers appear in the sequence.\n\nYou are given a sequence v_1,v_2,...,v_n whose length is even.\nWe would like to make this sequence /\\/\\/\\/ by replacing some of its elements.\nFind the minimum number of elements that needs to be replaced.\n\nConstraints\n\n2 \\leq n \\leq 10^5\n\nn is even.\n\n1 \\leq v_i \\leq 10^5\n\nv_i is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nn\nv_1 v_2 ... v_n\n\nOutput\n\nPrint the minimum number of elements that needs to be replaced.\n\nSample Input 1\n\n4\n3 1 3 2\n\nSample Output 1\n\n1\n\nThe sequence 3,1,3,2 is not /\\/\\/\\/, but we can make it /\\/\\/\\/ by replacing one of its elements: for example, replace the fourth element to make it 3,1,3,1.\n\nSample Input 2\n\n6\n105 119 105 119 105 119\n\nSample Output 2\n\n0\n\nThe sequence 105,119,105,119,105,119 is /\\/\\/\\/.\n\nSample Input 3\n\n4\n1 1 1 1\n\nSample Output 3\n\n2\n\nThe elements of the sequence 1,1,1,1 are all the same, so it is not /\\/\\/\\/.", "sample_input": "4\n3 1 3 2\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03244", "source_text": "Score : 300 points\n\nProblem Statement\n\nA sequence a_1,a_2,... ,a_n is said to be /\\/\\/\\/ when the following conditions are satisfied:\n\nFor each i = 1,2,..., n-2, a_i = a_{i+2}.\n\nExactly two different numbers appear in the sequence.\n\nYou are given a sequence v_1,v_2,...,v_n whose length is even.\nWe would like to make this sequence /\\/\\/\\/ by replacing some of its elements.\nFind the minimum number of elements that needs to be replaced.\n\nConstraints\n\n2 \\leq n \\leq 10^5\n\nn is even.\n\n1 \\leq v_i \\leq 10^5\n\nv_i is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nn\nv_1 v_2 ... v_n\n\nOutput\n\nPrint the minimum number of elements that needs to be replaced.\n\nSample Input 1\n\n4\n3 1 3 2\n\nSample Output 1\n\n1\n\nThe sequence 3,1,3,2 is not /\\/\\/\\/, but we can make it /\\/\\/\\/ by replacing one of its elements: for example, replace the fourth element to make it 3,1,3,1.\n\nSample Input 2\n\n6\n105 119 105 119 105 119\n\nSample Output 2\n\n0\n\nThe sequence 105,119,105,119,105,119 is /\\/\\/\\/.\n\nSample Input 3\n\n4\n1 1 1 1\n\nSample Output 3\n\n2\n\nThe elements of the sequence 1,1,1,1 are all the same, so it is not /\\/\\/\\/.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 219, "memory_kb": 12672}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s193652906", "group_id": "codeNet:p03245", "input_text": "open Printf open Scanf\nmodule Lib = struct\n\tlet i32,i64,ist = Int64.(to_int,of_int,to_string)\n\tlet (+$) = (+) let (-$) = (-) let (/$) = (/) let ( *$) = ( * ) let (%$) = (mod)\n\tlet labs = Int64.abs\n\tlet (+),(-),( * ),(/),(mod),(%) = Int64.(add,sub,mul,div,rem,rem)\n\tlet (+=) r v = r := !r + v\n\tlet (-=) r v = r := !r - v\n\tlet ( *= ) r v = r := !r * v\n\tlet (/=) r v = r := !r / v\n\tlet (%=) r v = r := !r % v\n\tlet max_i64,min_i64 = Int64.(max_int,min_int)\n\t(* math *)\n\tlet ceildiv p q = (p+q-1L) / q\n\tlet rec gcd m n = match m,n with | m,0L -> m | m,n -> gcd n (m mod n)\n\tlet lcm m n = m / gcd m n * n \n\tmodule I64_infix = struct\n\t\tlet (land),(lor),(lxor),lnot,(lsl),(lsr),(asr) =\n\t\t\tlet open Int64 in\n\t\t\t(logand),(logor),(logxor),lognot,\n\t\t\t(fun u v -> shift_left u (i32 v)),\n\t\t\t(fun u v -> shift_right u (i32 v)),\n\t\t\t(fun u v -> shift_right_logical u (i32 v))\n\tend\n\t(* input *)\n\tlet input_i64_array n = Array.init (i32 n) (fun _ -> Scanf.scanf \" %Ld\" (fun v -> v))\n\tlet get_i64 _ = Scanf.scanf \" %Ld\" (fun v -> v)\n\tlet get_2_i64 _ = Scanf.scanf \" %Ld %Ld\" (fun u v -> u,v)\n\tlet get_3_i64 _ = Scanf.scanf \" %Ld %Ld %Ld\" (fun u v w -> u,v,w)\n\tlet get_4_i64 _ = Scanf.scanf \" %Ld %Ld %Ld %Ld\" (fun u v w x -> u,v,w,x)\n\tlet get_5_i64 _ = Scanf.scanf \" %Ld %Ld %Ld %Ld %Ld\" (fun u v w x y -> u,v,w,x,y)\n\tlet i32_get_int _ = Scanf.scanf \" %d\" (fun v -> v) let i32_get_2_ints _ = Scanf.scanf \" %d %d\" (fun u v -> u,v) let i32_get_3_ints _ = Scanf.scanf \" %d %d %d\" (fun u v w -> u,v,w) let i32_get_4_ints _ = Scanf.scanf \" %d %d %d %d\" (fun u v w x -> u,v,w,x) let i32_get_5_ints _ = Scanf.scanf \" %d %d %d %d %d\" (fun u v w x y -> u,v,w,x,y)\n\t(* utils *)\n\texternal id : 'a -> 'a = \"%identity\"\n\tlet ( *< ) f g x = f (g x)\n\tlet ( *> ) f g x = g (f x)\n\tlet rv f p q = f q p (* ex. 24 |> rv (/) 6 *)\n\tlet alen a = i64 @@ Array.length a\n\tlet llen l = i64 @@ List.length l\n\tlet string_of_list ?(separator=\" \") f ls = ls |> List.map f |> String.concat separator\n\tlet string_of_array ?(separator=\" \") f a = a |> Array.to_list |> string_of_list ~separator f\n\tlet char_list_of_string str = let rec f0 i a = if i<0 then a else f0 (i-$1) (str.[i]::a) in f0 (String.length str -$ 1) []\n\tlet string_of_char_list ls = List.fold_left (fun u v -> u ^ (String.make 1 v)) \"\" ls\n\tlet fail _ = failwith \"fail\"\n\tlet dx,dy = [|1;0;-1;0|],[|0;1;0;-1|]\n\tlet range l r = let ls = ref [] in for i=i32 l to i32 r do ls := i :: !ls done;!ls |> List.rev\n\tlet cartesian_product u v = u |> List.map (fun p -> List.map (fun q -> p,q) v) |> List.flatten\n\tlet shuffle a = Array.sort (fun _ _ -> (Random.int 3) -$ 1) a\n\tlet binary_search ng ok f = let d = if ng < ok then 1L else -1L in\n\t\tlet rec f0 ng ok =\n\t\t\tif labs (ok - ng) <= 1L then ok\n\t\t\telse let mid = ng + (ok - ng) / 2L in if f mid then f0 ng mid else f0 mid ok\n\t\tin f0 (ng-1L*d) (ok+1L*d)\n\tlet lower_bound a v = binary_search 0L (alen a - 1L) (fun i -> a.(i32 i) >= v)\n\tlet upper_bound a v = binary_search 0L (alen a - 1L) (fun i -> a.(i32 i) > v)\n\tlet equal_range a v = lower_bound a v, upper_bound a v (* #=snd-fst *)\n\tlet rec fix f x = f (fix f) x\n\tlet rec fix_memo ?(size=10000) f x =\n\t\tlet tb = Hashtbl.create ~random:true size in\n\t\tlet rec f0 x =\n\t\t\ttry Hashtbl.find tb x with\n\t\t\t| Not_found -> (let v = f f0 x in Hashtbl.add tb x v; v)\n\t\tin f0 x\n\t(* imperative *)\n\tlet rep f t ?(stride=1L) fbod = let i = ref f in while !i <= t do fbod !i; i := !i + stride done\n\tlet repb f t ?(stride=1L) fbod = let i,c = ref f,ref true in while !i <= t && !c do\n\t\tmatch fbod !i with | `Break -> c := false | `Ok -> i := !i + stride done\n\tlet repm f t ?(stride=1L) m0 fbod =\n\t\tlet i,c,m = ref f,ref true,ref m0 in\n\t\twhile !i<=t && !c do match fbod !m !i with\n\t\t| `Break -> c := false | `Break_m m' -> (c := false; m := m') | `Ok m' -> m := m'; i := !i + stride done; !m\n\tlet repi f t ?(stride=1) fbod = let i = ref f in while !i <= t do fbod !i; i := !i +$ stride done\n\tlet repib f t ?(stride=1) fbod = let i,c = ref f,ref true in while !i <= t && !c do\n\t\tmatch fbod !i with | `Break -> c := false | `Ok -> i := !i +$ stride done\n\tlet repim f t ?(stride=1) m0 fbod =\n\t\tlet i,c,m = ref f,ref true,ref m0 in\n\t\twhile !i<=t && !c do match fbod !m !i with\n\t\t| `Break -> c := false | `Break_m m' -> (c := false; m := m') | `Ok m' -> m := m'; i := !i +$ stride done; !m\n\tlet rep_rev f t ?(stride=1L) fbod = rep t f ~stride @@ fun v -> fbod @@ f + t - v\n\tlet repb_rev f t ?(stride=1L) fbod = repb t f ~stride @@ fun v -> fbod @@ f + t - v\n\tlet repm_rev f t ?(stride=1L) m0 fbod = repm f t ~stride m0 @@ fun u v -> fbod u @@ f + t - v\n\tlet repi_rev f t ?(stride=1) fbod = repi t f ~stride @@ fun v -> fbod @@ f +$ t -$ v\n\tlet repib_rev f t ?(stride=1) fbod = repib t f ~stride @@ fun v -> fbod @@ f +$ t -$ v\n\tlet repim_rev f t ?(stride=1) m0 fbod = repim f t ~stride m0 @@ fun u v -> fbod u @@ f +$ t -$ v\n\t(* output *)\n\tlet print_list_mle f ls = string_of_list f ls |> print_endline\n\tlet print_array_mle f a = string_of_array f a |> print_endline\n\tlet print_list f ls = ls |> List.iter (fun v -> printf \"%s \" @@ f v); print_newline ()\n\tlet print_array f a = a |> Array.iter (fun v -> printf \"%s \" @@ f v); print_newline ()\n\t(* debug *)\n\tlet dump_2darr f a = a |> Array.iter (fun b -> print_array f b)\n\tlet dump_i64_list ls = print_list ist ls\n\tlet dump_i64_array a = print_array ist a\nend open Lib open Array\n\nlet () =\n\tlet n = get_i64 0 in\n\tlet a = init (i32 n) (fun _ ->\n\t\tlet x,y = get_2_i64 0 in x,y\n\t) in\n\tlet m = fold_left (fun (u,mx) (x,y) ->\n\t\tif (labs (x+y)) mod 2L <> u then (\n\t\t\tprintf \"-1\\n\"; exit 0\n\t\t) else if labs x > 10L || labs y > 10L then (\n\t\t\texit 0\n\t\t) else (u, max mx (labs x+labs y))\n\t) ((labs (fst a.(0)+snd a.(0))) mod 2L,0L) a |> snd\n\tin\n\tprintf \"%Ld\\n\" m;\n\trep 1L m (fun _ -> printf \"1 \");\n\tprint_newline ();\n\titer (fun (x,y) ->\n\t\tlet p,q = labs x,labs y in\n\t\trep 1L p (fun _ -> printf \"%c\" @@ if x > 0L then 'R' else 'L');\n\t\trep 1L q (fun _ -> printf \"%c\" @@ if y > 0L then 'U' else 'D');\n\t\trep (p+q+1L) m (fun i -> if i mod 2L = 0L then printf \"LR\");\n\t\tprint_newline ();\n\t) a", "language": "OCaml", "metadata": {"date": 1541744903, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03245.html", "problem_id": "p03245", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03245/input.txt", "sample_output_relpath": "derived/input_output/data/p03245/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03245/OCaml/s193652906.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s193652906", "user_id": "u481480055"}, "prompt_components": {"gold_output": "2\n1 2\nRL\nUU\nDR\n", "input_to_evaluate": "open Printf open Scanf\nmodule Lib = struct\n\tlet i32,i64,ist = Int64.(to_int,of_int,to_string)\n\tlet (+$) = (+) let (-$) = (-) let (/$) = (/) let ( *$) = ( * ) let (%$) = (mod)\n\tlet labs = Int64.abs\n\tlet (+),(-),( * ),(/),(mod),(%) = Int64.(add,sub,mul,div,rem,rem)\n\tlet (+=) r v = r := !r + v\n\tlet (-=) r v = r := !r - v\n\tlet ( *= ) r v = r := !r * v\n\tlet (/=) r v = r := !r / v\n\tlet (%=) r v = r := !r % v\n\tlet max_i64,min_i64 = Int64.(max_int,min_int)\n\t(* math *)\n\tlet ceildiv p q = (p+q-1L) / q\n\tlet rec gcd m n = match m,n with | m,0L -> m | m,n -> gcd n (m mod n)\n\tlet lcm m n = m / gcd m n * n \n\tmodule I64_infix = struct\n\t\tlet (land),(lor),(lxor),lnot,(lsl),(lsr),(asr) =\n\t\t\tlet open Int64 in\n\t\t\t(logand),(logor),(logxor),lognot,\n\t\t\t(fun u v -> shift_left u (i32 v)),\n\t\t\t(fun u v -> shift_right u (i32 v)),\n\t\t\t(fun u v -> shift_right_logical u (i32 v))\n\tend\n\t(* input *)\n\tlet input_i64_array n = Array.init (i32 n) (fun _ -> Scanf.scanf \" %Ld\" (fun v -> v))\n\tlet get_i64 _ = Scanf.scanf \" %Ld\" (fun v -> v)\n\tlet get_2_i64 _ = Scanf.scanf \" %Ld %Ld\" (fun u v -> u,v)\n\tlet get_3_i64 _ = Scanf.scanf \" %Ld %Ld %Ld\" (fun u v w -> u,v,w)\n\tlet get_4_i64 _ = Scanf.scanf \" %Ld %Ld %Ld %Ld\" (fun u v w x -> u,v,w,x)\n\tlet get_5_i64 _ = Scanf.scanf \" %Ld %Ld %Ld %Ld %Ld\" (fun u v w x y -> u,v,w,x,y)\n\tlet i32_get_int _ = Scanf.scanf \" %d\" (fun v -> v) let i32_get_2_ints _ = Scanf.scanf \" %d %d\" (fun u v -> u,v) let i32_get_3_ints _ = Scanf.scanf \" %d %d %d\" (fun u v w -> u,v,w) let i32_get_4_ints _ = Scanf.scanf \" %d %d %d %d\" (fun u v w x -> u,v,w,x) let i32_get_5_ints _ = Scanf.scanf \" %d %d %d %d %d\" (fun u v w x y -> u,v,w,x,y)\n\t(* utils *)\n\texternal id : 'a -> 'a = \"%identity\"\n\tlet ( *< ) f g x = f (g x)\n\tlet ( *> ) f g x = g (f x)\n\tlet rv f p q = f q p (* ex. 24 |> rv (/) 6 *)\n\tlet alen a = i64 @@ Array.length a\n\tlet llen l = i64 @@ List.length l\n\tlet string_of_list ?(separator=\" \") f ls = ls |> List.map f |> String.concat separator\n\tlet string_of_array ?(separator=\" \") f a = a |> Array.to_list |> string_of_list ~separator f\n\tlet char_list_of_string str = let rec f0 i a = if i<0 then a else f0 (i-$1) (str.[i]::a) in f0 (String.length str -$ 1) []\n\tlet string_of_char_list ls = List.fold_left (fun u v -> u ^ (String.make 1 v)) \"\" ls\n\tlet fail _ = failwith \"fail\"\n\tlet dx,dy = [|1;0;-1;0|],[|0;1;0;-1|]\n\tlet range l r = let ls = ref [] in for i=i32 l to i32 r do ls := i :: !ls done;!ls |> List.rev\n\tlet cartesian_product u v = u |> List.map (fun p -> List.map (fun q -> p,q) v) |> List.flatten\n\tlet shuffle a = Array.sort (fun _ _ -> (Random.int 3) -$ 1) a\n\tlet binary_search ng ok f = let d = if ng < ok then 1L else -1L in\n\t\tlet rec f0 ng ok =\n\t\t\tif labs (ok - ng) <= 1L then ok\n\t\t\telse let mid = ng + (ok - ng) / 2L in if f mid then f0 ng mid else f0 mid ok\n\t\tin f0 (ng-1L*d) (ok+1L*d)\n\tlet lower_bound a v = binary_search 0L (alen a - 1L) (fun i -> a.(i32 i) >= v)\n\tlet upper_bound a v = binary_search 0L (alen a - 1L) (fun i -> a.(i32 i) > v)\n\tlet equal_range a v = lower_bound a v, upper_bound a v (* #=snd-fst *)\n\tlet rec fix f x = f (fix f) x\n\tlet rec fix_memo ?(size=10000) f x =\n\t\tlet tb = Hashtbl.create ~random:true size in\n\t\tlet rec f0 x =\n\t\t\ttry Hashtbl.find tb x with\n\t\t\t| Not_found -> (let v = f f0 x in Hashtbl.add tb x v; v)\n\t\tin f0 x\n\t(* imperative *)\n\tlet rep f t ?(stride=1L) fbod = let i = ref f in while !i <= t do fbod !i; i := !i + stride done\n\tlet repb f t ?(stride=1L) fbod = let i,c = ref f,ref true in while !i <= t && !c do\n\t\tmatch fbod !i with | `Break -> c := false | `Ok -> i := !i + stride done\n\tlet repm f t ?(stride=1L) m0 fbod =\n\t\tlet i,c,m = ref f,ref true,ref m0 in\n\t\twhile !i<=t && !c do match fbod !m !i with\n\t\t| `Break -> c := false | `Break_m m' -> (c := false; m := m') | `Ok m' -> m := m'; i := !i + stride done; !m\n\tlet repi f t ?(stride=1) fbod = let i = ref f in while !i <= t do fbod !i; i := !i +$ stride done\n\tlet repib f t ?(stride=1) fbod = let i,c = ref f,ref true in while !i <= t && !c do\n\t\tmatch fbod !i with | `Break -> c := false | `Ok -> i := !i +$ stride done\n\tlet repim f t ?(stride=1) m0 fbod =\n\t\tlet i,c,m = ref f,ref true,ref m0 in\n\t\twhile !i<=t && !c do match fbod !m !i with\n\t\t| `Break -> c := false | `Break_m m' -> (c := false; m := m') | `Ok m' -> m := m'; i := !i +$ stride done; !m\n\tlet rep_rev f t ?(stride=1L) fbod = rep t f ~stride @@ fun v -> fbod @@ f + t - v\n\tlet repb_rev f t ?(stride=1L) fbod = repb t f ~stride @@ fun v -> fbod @@ f + t - v\n\tlet repm_rev f t ?(stride=1L) m0 fbod = repm f t ~stride m0 @@ fun u v -> fbod u @@ f + t - v\n\tlet repi_rev f t ?(stride=1) fbod = repi t f ~stride @@ fun v -> fbod @@ f +$ t -$ v\n\tlet repib_rev f t ?(stride=1) fbod = repib t f ~stride @@ fun v -> fbod @@ f +$ t -$ v\n\tlet repim_rev f t ?(stride=1) m0 fbod = repim f t ~stride m0 @@ fun u v -> fbod u @@ f +$ t -$ v\n\t(* output *)\n\tlet print_list_mle f ls = string_of_list f ls |> print_endline\n\tlet print_array_mle f a = string_of_array f a |> print_endline\n\tlet print_list f ls = ls |> List.iter (fun v -> printf \"%s \" @@ f v); print_newline ()\n\tlet print_array f a = a |> Array.iter (fun v -> printf \"%s \" @@ f v); print_newline ()\n\t(* debug *)\n\tlet dump_2darr f a = a |> Array.iter (fun b -> print_array f b)\n\tlet dump_i64_list ls = print_list ist ls\n\tlet dump_i64_array a = print_array ist a\nend open Lib open Array\n\nlet () =\n\tlet n = get_i64 0 in\n\tlet a = init (i32 n) (fun _ ->\n\t\tlet x,y = get_2_i64 0 in x,y\n\t) in\n\tlet m = fold_left (fun (u,mx) (x,y) ->\n\t\tif (labs (x+y)) mod 2L <> u then (\n\t\t\tprintf \"-1\\n\"; exit 0\n\t\t) else if labs x > 10L || labs y > 10L then (\n\t\t\texit 0\n\t\t) else (u, max mx (labs x+labs y))\n\t) ((labs (fst a.(0)+snd a.(0))) mod 2L,0L) a |> snd\n\tin\n\tprintf \"%Ld\\n\" m;\n\trep 1L m (fun _ -> printf \"1 \");\n\tprint_newline ();\n\titer (fun (x,y) ->\n\t\tlet p,q = labs x,labs y in\n\t\trep 1L p (fun _ -> printf \"%c\" @@ if x > 0L then 'R' else 'L');\n\t\trep 1L q (fun _ -> printf \"%c\" @@ if y > 0L then 'U' else 'D');\n\t\trep (p+q+1L) m (fun i -> if i mod 2L = 0L then printf \"LR\");\n\t\tprint_newline ();\n\t) a", "problem_context": "Score : 600 points\n\nProblem Statement\n\nSnuke is introducing a robot arm with the following properties to his factory:\n\nThe robot arm consists of m sections and m+1 joints. The sections are numbered 1, 2, ..., m, and the joints are numbered 0, 1, ..., m. Section i connects Joint i-1 and Joint i. The length of Section i is d_i.\n\nFor each section, its mode can be specified individually. There are four modes: L, R, D and U. The mode of a section decides the direction of that section. If we consider the factory as a coordinate plane, the position of Joint i will be determined as follows (we denote its coordinates as (x_i, y_i)):\n\n(x_0, y_0) = (0, 0).\n\nIf the mode of Section i is L, (x_{i}, y_{i}) = (x_{i-1} - d_{i}, y_{i-1}).\n\nIf the mode of Section i is R, (x_{i}, y_{i}) = (x_{i-1} + d_{i}, y_{i-1}).\n\nIf the mode of Section i is D, (x_{i}, y_{i}) = (x_{i-1}, y_{i-1} - d_{i}).\n\nIf the mode of Section i is U, (x_{i}, y_{i}) = (x_{i-1}, y_{i-1} + d_{i}).\n\nSnuke would like to introduce a robot arm so that the position of Joint m can be matched with all of the N points (X_1, Y_1), (X_2, Y_2), ..., (X_N, Y_N) by properly specifying the modes of the sections.\nIs this possible?\nIf so, find such a robot arm and how to bring Joint m to each point (X_j, Y_j).\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 1000\n\n-10^9 \\leq X_i \\leq 10^9\n\n-10^9 \\leq Y_i \\leq 10^9\n\nPartial Score\n\nIn the test cases worth 300 points, -10 \\leq X_i \\leq 10 and -10 \\leq Y_i \\leq 10 hold.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nX_1 Y_1\nX_2 Y_2\n:\nX_N Y_N\n\nOutput\n\nIf the condition can be satisfied, follow the following format. If the condition cannot be satisfied, print -1.\n\nm\nd_1 d_2 ... d_m\nw_1\nw_2\n:\nw_N\n\nm and d_i are the configurations of the robot arm. Refer to the problem statement for what each of them means.\nHere, 1 \\leq m \\leq 40 and 1 \\leq d_i \\leq 10^{12} must hold. Also, m and d_i must all be integers.\n\nw_j is a string of length m that represents the way to bring Joint m of the robot arm to point (X_j, Y_j).\nThe i-th character of w_j should be one of the letters L, R, D and U, representing the mode of Section i.\n\nSample Input 1\n\n3\n-1 0\n0 3\n2 -1\n\nSample Output 1\n\n2\n1 2\nRL\nUU\nDR\n\nIn the given way to bring Joint m of the robot arm to each (X_j, Y_j), the positions of the joints will be as follows:\n\nTo (X_1, Y_1) = (-1, 0): First, the position of Joint 0 is (x_0, y_0) = (0, 0). As the mode of Section 1 is R, the position of Joint 1 is (x_1, y_1) = (1, 0). Then, as the mode of Section 2 is L, the position of Joint 2 is (x_2, y_2) = (-1, 0).\n\nTo (X_2, Y_2) = (0, 3): (x_0, y_0) = (0, 0), (x_1, y_1) = (0, 1), (x_2, y_2) = (0, 3).\n\nTo (X_3, Y_3) = (2, -1): (x_0, y_0) = (0, 0), (x_1, y_1) = (0, -1), (x_2, y_2) = (2, -1).\n\nSample Input 2\n\n5\n0 0\n1 0\n2 0\n3 0\n4 0\n\nSample Output 2\n\n-1\n\nSample Input 3\n\n2\n1 1\n1 1\n\nSample Output 3\n\n2\n1 1\nRU\nUR\n\nThere may be duplicated points among (X_j, Y_j).\n\nSample Input 4\n\n3\n-7 -3\n7 3\n-3 -7\n\nSample Output 4\n\n5\n3 1 4 1 5\nLRDUL\nRDULR\nDULRD", "sample_input": "3\n-1 0\n0 3\n2 -1\n"}, "reference_outputs": ["2\n1 2\nRL\nUU\nDR\n"], "source_document_id": "p03245", "source_text": "Score : 600 points\n\nProblem Statement\n\nSnuke is introducing a robot arm with the following properties to his factory:\n\nThe robot arm consists of m sections and m+1 joints. The sections are numbered 1, 2, ..., m, and the joints are numbered 0, 1, ..., m. Section i connects Joint i-1 and Joint i. The length of Section i is d_i.\n\nFor each section, its mode can be specified individually. There are four modes: L, R, D and U. The mode of a section decides the direction of that section. If we consider the factory as a coordinate plane, the position of Joint i will be determined as follows (we denote its coordinates as (x_i, y_i)):\n\n(x_0, y_0) = (0, 0).\n\nIf the mode of Section i is L, (x_{i}, y_{i}) = (x_{i-1} - d_{i}, y_{i-1}).\n\nIf the mode of Section i is R, (x_{i}, y_{i}) = (x_{i-1} + d_{i}, y_{i-1}).\n\nIf the mode of Section i is D, (x_{i}, y_{i}) = (x_{i-1}, y_{i-1} - d_{i}).\n\nIf the mode of Section i is U, (x_{i}, y_{i}) = (x_{i-1}, y_{i-1} + d_{i}).\n\nSnuke would like to introduce a robot arm so that the position of Joint m can be matched with all of the N points (X_1, Y_1), (X_2, Y_2), ..., (X_N, Y_N) by properly specifying the modes of the sections.\nIs this possible?\nIf so, find such a robot arm and how to bring Joint m to each point (X_j, Y_j).\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 1000\n\n-10^9 \\leq X_i \\leq 10^9\n\n-10^9 \\leq Y_i \\leq 10^9\n\nPartial Score\n\nIn the test cases worth 300 points, -10 \\leq X_i \\leq 10 and -10 \\leq Y_i \\leq 10 hold.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nX_1 Y_1\nX_2 Y_2\n:\nX_N Y_N\n\nOutput\n\nIf the condition can be satisfied, follow the following format. If the condition cannot be satisfied, print -1.\n\nm\nd_1 d_2 ... d_m\nw_1\nw_2\n:\nw_N\n\nm and d_i are the configurations of the robot arm. Refer to the problem statement for what each of them means.\nHere, 1 \\leq m \\leq 40 and 1 \\leq d_i \\leq 10^{12} must hold. Also, m and d_i must all be integers.\n\nw_j is a string of length m that represents the way to bring Joint m of the robot arm to point (X_j, Y_j).\nThe i-th character of w_j should be one of the letters L, R, D and U, representing the mode of Section i.\n\nSample Input 1\n\n3\n-1 0\n0 3\n2 -1\n\nSample Output 1\n\n2\n1 2\nRL\nUU\nDR\n\nIn the given way to bring Joint m of the robot arm to each (X_j, Y_j), the positions of the joints will be as follows:\n\nTo (X_1, Y_1) = (-1, 0): First, the position of Joint 0 is (x_0, y_0) = (0, 0). As the mode of Section 1 is R, the position of Joint 1 is (x_1, y_1) = (1, 0). Then, as the mode of Section 2 is L, the position of Joint 2 is (x_2, y_2) = (-1, 0).\n\nTo (X_2, Y_2) = (0, 3): (x_0, y_0) = (0, 0), (x_1, y_1) = (0, 1), (x_2, y_2) = (0, 3).\n\nTo (X_3, Y_3) = (2, -1): (x_0, y_0) = (0, 0), (x_1, y_1) = (0, -1), (x_2, y_2) = (2, -1).\n\nSample Input 2\n\n5\n0 0\n1 0\n2 0\n3 0\n4 0\n\nSample Output 2\n\n-1\n\nSample Input 3\n\n2\n1 1\n1 1\n\nSample Output 3\n\n2\n1 1\nRU\nUR\n\nThere may be duplicated points among (X_j, Y_j).\n\nSample Input 4\n\n3\n-7 -3\n7 3\n-3 -7\n\nSample Output 4\n\n5\n3 1 4 1 5\nLRDUL\nRDULR\nDULRD", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 6009, "cpu_time_ms": 5, "memory_kb": 4608}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s805011529", "group_id": "codeNet:p03246", "input_text": "let split_string ?(pattern=\"\") = Str.split @@ Str.regexp pattern\nlet n = Scanf.sscanf (read_line ()) \"%d\" @@ fun n -> n\nlet v = read_line () |> split_string ~pattern:\" \" |> List.map int_of_string\n\nlet rec take res n acc = match (n, acc) with\n | (_, []) | (0, _) -> List.rev res\n | (i, x :: xs) -> take (x :: res) (n - 1) xs\nlet take = take []\n\nlet rec split a b t = function\n | [] -> (a, b)\n | x :: xs -> if t then split (x :: a) b false xs else split a (x :: b) true xs\n\nmodule IntMap = Map.Make(struct type t = int let compare = compare end)\nlet top acc =\n let map = List.fold_left (fun map n ->\n let i = 1 + try IntMap.find n map with Not_found -> 0 in\n IntMap.add n i map\n ) IntMap.empty acc in\n IntMap.bindings map |> List.sort (fun (_, a) (_, b) -> b - a) |> take 2 |> List.map fst\n\nlet solve a ta b tb =\n let cnt acc v = List.filter ((<>) v) acc |> List.length in\n List.map (fun x -> List.map (fun y -> (x, y)) tb) ta\n |> List.concat\n |> List.map (fun (x, y) -> if x = y then max_int else cnt a x + cnt b y)\n |> List.fold_left min max_int\n\nlet () =\n let a, b = split [] [] true v in\n let ta, tb = top a, top b in\n Printf.printf \"%d\\n\" @@\n if List.length ta = 1 && List.length tb = 1 && List.hd ta = List.hd tb \n then n / 2 else solve a ta b tb", "language": "OCaml", "metadata": {"date": 1593658921, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p03246.html", "problem_id": "p03246", "resource_group": "low_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/OCaml/s805011529.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s805011529", "user_id": "u811309788"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "let split_string ?(pattern=\"\") = Str.split @@ Str.regexp pattern\nlet n = Scanf.sscanf (read_line ()) \"%d\" @@ fun n -> n\nlet v = read_line () |> split_string ~pattern:\" \" |> List.map int_of_string\n\nlet rec take res n acc = match (n, acc) with\n | (_, []) | (0, _) -> List.rev res\n | (i, x :: xs) -> take (x :: res) (n - 1) xs\nlet take = take []\n\nlet rec split a b t = function\n | [] -> (a, b)\n | x :: xs -> if t then split (x :: a) b false xs else split a (x :: b) true xs\n\nmodule IntMap = Map.Make(struct type t = int let compare = compare end)\nlet top acc =\n let map = List.fold_left (fun map n ->\n let i = 1 + try IntMap.find n map with Not_found -> 0 in\n IntMap.add n i map\n ) IntMap.empty acc in\n IntMap.bindings map |> List.sort (fun (_, a) (_, b) -> b - a) |> take 2 |> List.map fst\n\nlet solve a ta b tb =\n let cnt acc v = List.filter ((<>) v) acc |> List.length in\n List.map (fun x -> List.map (fun y -> (x, y)) tb) ta\n |> List.concat\n |> List.map (fun (x, y) -> if x = y then max_int else cnt a x + cnt b y)\n |> List.fold_left min max_int\n\nlet () =\n let a, b = split [] [] true v in\n let ta, tb = top a, top b in\n Printf.printf \"%d\\n\" @@\n if List.length ta = 1 && List.length tb = 1 && List.hd ta = List.hd tb \n then n / 2 else solve a ta b tb", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1279, "cpu_time_ms": 189, "memory_kb": 28292}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s692482900", "group_id": "codeNet:p03246", "input_text": "open Printf\nopen Scanf\n\nlet id x = x\nlet pair x y = x, y\n\nlet n = scanf \"%d\" id\nlet vs = Array.init n @@ fun _ -> scanf \" %d\" id\n\nmodule IMap = Map.Make(struct type t = int let compare = Pervasives.compare end)\n\nlet odd = ref IMap.empty\nlet even = ref IMap.empty\n\nlet incrmap mapr key =\n if IMap.mem key !mapr then\n mapr := IMap.add key (IMap.find key !mapr + 1) !mapr\n else\n mapr := IMap.add key 1 !mapr\n\nlet maxi mapr =\n let lis = IMap.bindings !mapr in\n let lis = List.sort (fun (k1,v1) (k1,v2) -> v2 - v1) lis in\n match lis with\n | [] -> failwith \"\"\n | (v, n) :: rest -> (v, n, rest)\n\nlet () =\n for i = 0 to n - 1 do\n if i mod 2 == 0 then begin\n incrmap odd vs.(i)\n end else begin\n incrmap even vs.(i)\n end\n done;\n let (k1, v1, rest1) = maxi odd in\n let (k2, v2, rest2) = maxi even in\n let run k1 k2 v1 v2 rest1 rest2 =\n if k1 <> k2 then begin\n let n1 = List.fold_left (fun acc (v, n) -> acc + n) 0 rest1 in\n let n2 = List.fold_left (fun acc (v, n) -> acc + n) 0 rest2 in\n n1 + n2\n end else if v1 > v2 then begin\n let n1 = List.fold_left (fun acc (v, n) -> acc + n) 0 rest1 in\n match rest2 with\n | [] -> n1 + n / 2\n | (k, v) :: _ -> n1 + n / 2 - v\n end else if v1 < v2 then begin\n let n2 = List.fold_left (fun acc (v, n) -> acc + n) 0 rest2 in\n match rest1 with\n | [] -> n2 + n / 2\n | (k, v) :: _ -> n2 + n / 2 - v \n end else begin\n (* k1 = k2, v1 = v2 *)\n let rec loop rest1 rest2 =\n match rest1, rest2 with\n | [], [] -> 0\n | [], (k', v') :: rest' -> v'\n | (k', v') :: rest', [] -> v'\n | (k1', v1') :: rest1', (k2', v2') :: rest2' ->\n if k1 <> k2 then begin\n if v1' < v2' then\n let n1 = List.fold_left (fun acc (v, n) -> acc + n) 0 rest1' in\n let n2 = List.fold_left (fun acc (v, n) -> acc + n) 0 rest2' in\n n1 + n2 + v2'\n else if v1' > v2' then\n let n1 = List.fold_left (fun acc (v, n) -> acc + n) 0 rest1' in\n let n2 = List.fold_left (fun acc (v, n) -> acc + n) 0 rest2' in\n n1 + n2 + v1'\n else n / 0 (* loop rest1' rest2' *)\n end else n / 0\n in\n v1 + loop rest1 rest2\n end\n in\n let result = run k1 k2 v1 v2 rest1 rest2 in\n printf \"%d\\n\" result\n", "language": "OCaml", "metadata": {"date": 1538274781, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03246.html", "problem_id": "p03246", "resource_group": "low_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/OCaml/s692482900.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s692482900", "user_id": "u450300828"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "open Printf\nopen Scanf\n\nlet id x = x\nlet pair x y = x, y\n\nlet n = scanf \"%d\" id\nlet vs = Array.init n @@ fun _ -> scanf \" %d\" id\n\nmodule IMap = Map.Make(struct type t = int let compare = Pervasives.compare end)\n\nlet odd = ref IMap.empty\nlet even = ref IMap.empty\n\nlet incrmap mapr key =\n if IMap.mem key !mapr then\n mapr := IMap.add key (IMap.find key !mapr + 1) !mapr\n else\n mapr := IMap.add key 1 !mapr\n\nlet maxi mapr =\n let lis = IMap.bindings !mapr in\n let lis = List.sort (fun (k1,v1) (k1,v2) -> v2 - v1) lis in\n match lis with\n | [] -> failwith \"\"\n | (v, n) :: rest -> (v, n, rest)\n\nlet () =\n for i = 0 to n - 1 do\n if i mod 2 == 0 then begin\n incrmap odd vs.(i)\n end else begin\n incrmap even vs.(i)\n end\n done;\n let (k1, v1, rest1) = maxi odd in\n let (k2, v2, rest2) = maxi even in\n let run k1 k2 v1 v2 rest1 rest2 =\n if k1 <> k2 then begin\n let n1 = List.fold_left (fun acc (v, n) -> acc + n) 0 rest1 in\n let n2 = List.fold_left (fun acc (v, n) -> acc + n) 0 rest2 in\n n1 + n2\n end else if v1 > v2 then begin\n let n1 = List.fold_left (fun acc (v, n) -> acc + n) 0 rest1 in\n match rest2 with\n | [] -> n1 + n / 2\n | (k, v) :: _ -> n1 + n / 2 - v\n end else if v1 < v2 then begin\n let n2 = List.fold_left (fun acc (v, n) -> acc + n) 0 rest2 in\n match rest1 with\n | [] -> n2 + n / 2\n | (k, v) :: _ -> n2 + n / 2 - v \n end else begin\n (* k1 = k2, v1 = v2 *)\n let rec loop rest1 rest2 =\n match rest1, rest2 with\n | [], [] -> 0\n | [], (k', v') :: rest' -> v'\n | (k', v') :: rest', [] -> v'\n | (k1', v1') :: rest1', (k2', v2') :: rest2' ->\n if k1 <> k2 then begin\n if v1' < v2' then\n let n1 = List.fold_left (fun acc (v, n) -> acc + n) 0 rest1' in\n let n2 = List.fold_left (fun acc (v, n) -> acc + n) 0 rest2' in\n n1 + n2 + v2'\n else if v1' > v2' then\n let n1 = List.fold_left (fun acc (v, n) -> acc + n) 0 rest1' in\n let n2 = List.fold_left (fun acc (v, n) -> acc + n) 0 rest2' in\n n1 + n2 + v1'\n else n / 0 (* loop rest1' rest2' *)\n end else n / 0\n in\n v1 + loop rest1 rest2\n end\n in\n let result = run k1 k2 v1 v2 rest1 rest2 in\n printf \"%d\\n\" result\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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2346, "cpu_time_ms": 176, "memory_kb": 18816}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s013089552", "group_id": "codeNet:p03246", "input_text": "open Printf\nopen Scanf\n\nlet id x = x\nlet pair x y = x, y\n\nlet n = scanf \"%d\" id\nlet vs = Array.init n @@ fun _ -> scanf \" %d\" id\n\nmodule IMap = Map.Make(struct type t = int let compare = Pervasives.compare end)\n\nlet odd = ref IMap.empty\nlet even = ref IMap.empty\n\nlet incrmap mapr key =\n if IMap.mem key !mapr then\n mapr := IMap.add key (IMap.find key !mapr + 1) !mapr\n else\n mapr := IMap.add key 1 !mapr\n\nlet maxi mapr =\n let lis = IMap.bindings !mapr in\n let lis = List.sort (fun (k1,v1) (k1,v2) -> v2 - v1) lis in\n match lis with\n | [] -> failwith \"\"\n | (v, n) :: rest -> (v, n, rest)\n\nlet () =\n for i = 0 to n - 1 do\n if i mod 2 == 0 then begin\n incrmap odd vs.(i)\n end else begin\n incrmap even vs.(i)\n end\n done;\n let (k1, v1, rest1) = maxi odd in\n let (k2, v2, rest2) = maxi even in\n let rec loop k1 k2 v1 v2 rest1 rest2 =\n if k1 <> k2 then begin\n let n1 = List.fold_left (fun acc (v, n) -> acc + n) 0 rest1 in\n let n2 = List.fold_left (fun acc (v, n) -> acc + n) 0 rest2 in\n n1 + n2\n end else begin\n if v1 > v2 then begin\n let n1 = List.fold_left (fun acc (v, n) -> acc + n) 0 rest1 in\n match rest2 with\n | [] -> n1 + n / 2\n | (k, v) :: _ -> n1 + n / 2 - v\n end else if v1 < v2 then begin\n let n2 = List.fold_left (fun acc (v, n) -> acc + n) 0 rest2 in\n match rest1 with\n | [] -> n2 + n / 2\n | (k, v) :: _ -> n2 + n / 2 - v\n end else begin\n match rest1, rest2 with\n | (k1', v1') :: rest1', (k2', v2') :: rest2' ->\n v1 + v2 + loop k1' k2' v1' v2' rest1' rest2'\n | (k1', v1') :: rest1', [] ->\n v1 + v1' + List.fold_left (fun acc (v, n) -> acc + n) 0 rest1'\n | [], (k2', v2') :: rest2' ->\n v1 + v2' + List.fold_left (fun acc (v, n) -> acc + n) 0 rest2'\n | [], [] ->\n v1\n end\n end\n in\n let result = loop k1 k2 v1 v2 rest1 rest2 in\n printf \"%d\\n\" result\n", "language": "OCaml", "metadata": {"date": 1538272554, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03246.html", "problem_id": "p03246", "resource_group": "low_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/OCaml/s013089552.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s013089552", "user_id": "u450300828"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "open Printf\nopen Scanf\n\nlet id x = x\nlet pair x y = x, y\n\nlet n = scanf \"%d\" id\nlet vs = Array.init n @@ fun _ -> scanf \" %d\" id\n\nmodule IMap = Map.Make(struct type t = int let compare = Pervasives.compare end)\n\nlet odd = ref IMap.empty\nlet even = ref IMap.empty\n\nlet incrmap mapr key =\n if IMap.mem key !mapr then\n mapr := IMap.add key (IMap.find key !mapr + 1) !mapr\n else\n mapr := IMap.add key 1 !mapr\n\nlet maxi mapr =\n let lis = IMap.bindings !mapr in\n let lis = List.sort (fun (k1,v1) (k1,v2) -> v2 - v1) lis in\n match lis with\n | [] -> failwith \"\"\n | (v, n) :: rest -> (v, n, rest)\n\nlet () =\n for i = 0 to n - 1 do\n if i mod 2 == 0 then begin\n incrmap odd vs.(i)\n end else begin\n incrmap even vs.(i)\n end\n done;\n let (k1, v1, rest1) = maxi odd in\n let (k2, v2, rest2) = maxi even in\n let rec loop k1 k2 v1 v2 rest1 rest2 =\n if k1 <> k2 then begin\n let n1 = List.fold_left (fun acc (v, n) -> acc + n) 0 rest1 in\n let n2 = List.fold_left (fun acc (v, n) -> acc + n) 0 rest2 in\n n1 + n2\n end else begin\n if v1 > v2 then begin\n let n1 = List.fold_left (fun acc (v, n) -> acc + n) 0 rest1 in\n match rest2 with\n | [] -> n1 + n / 2\n | (k, v) :: _ -> n1 + n / 2 - v\n end else if v1 < v2 then begin\n let n2 = List.fold_left (fun acc (v, n) -> acc + n) 0 rest2 in\n match rest1 with\n | [] -> n2 + n / 2\n | (k, v) :: _ -> n2 + n / 2 - v\n end else begin\n match rest1, rest2 with\n | (k1', v1') :: rest1', (k2', v2') :: rest2' ->\n v1 + v2 + loop k1' k2' v1' v2' rest1' rest2'\n | (k1', v1') :: rest1', [] ->\n v1 + v1' + List.fold_left (fun acc (v, n) -> acc + n) 0 rest1'\n | [], (k2', v2') :: rest2' ->\n v1 + v2' + List.fold_left (fun acc (v, n) -> acc + n) 0 rest2'\n | [], [] ->\n v1\n end\n end\n in\n let result = loop k1 k2 v1 v2 rest1 rest2 in\n printf \"%d\\n\" result\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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1967, "cpu_time_ms": 174, "memory_kb": 21120}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s679952707", "group_id": "codeNet:p03246", "input_text": "open Printf\nopen Scanf\n\nlet id x = x\nlet pair x y = x, y\n\nlet n = scanf \"%d\" id\nlet vs = Array.init n @@ fun _ -> scanf \" %d\" id\n\nmodule IMap = Map.Make(struct type t = int let compare = Pervasives.compare end)\n\nlet odd = ref IMap.empty\nlet even = ref IMap.empty\n\nlet incrmap mapr key =\n if IMap.mem key !mapr then\n mapr := IMap.add key (IMap.find key !mapr + 1) !mapr\n else\n mapr := IMap.add key 1 !mapr\n\nlet maxi mapr =\n let lis = IMap.bindings !mapr in\n let lis = List.sort (fun (k1,v1) (k1,v2) -> v2 - v1) lis in\n match lis with\n | [] -> failwith \"\"\n | (v, n) :: rest -> (v, n, rest)\n\nlet () =\n for i = 0 to n - 1 do\n if i mod 2 == 0 then begin\n incrmap odd vs.(i)\n end else begin\n incrmap even vs.(i)\n end\n done;\n let (k1, v1, rest1) = maxi odd in\n let (k2, v2, rest2) = maxi even in\n let rec loop k1 k2 v1 v2 rest1 rest2 =\n if k1 <> k2 then begin\n let n1 = List.fold_left (fun acc (v, n) -> acc + n) 0 rest1 in\n let n2 = List.fold_left (fun acc (v, n) -> acc + n) 0 rest2 in\n n1 + n2\n end else begin\n match rest1, rest2 with\n | (k1', v1') :: rest1', (k2', v2') :: rest2' when v1 < v2 ->\n v1 + loop k1' k2' v1' v2' rest1' rest2'\n | (k1', v1') :: rest1', (k2', v2') :: rest2' ->\n v2 + loop k1' k2' v1' v2' rest1' rest2'\n | _ -> v1\n end\n in\n let result = loop k1 k2 v1 v2 rest1 rest2 in\n printf \"%d\\n\" result\n", "language": "OCaml", "metadata": {"date": 1538271394, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03246.html", "problem_id": "p03246", "resource_group": "low_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/OCaml/s679952707.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s679952707", "user_id": "u450300828"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "open Printf\nopen Scanf\n\nlet id x = x\nlet pair x y = x, y\n\nlet n = scanf \"%d\" id\nlet vs = Array.init n @@ fun _ -> scanf \" %d\" id\n\nmodule IMap = Map.Make(struct type t = int let compare = Pervasives.compare end)\n\nlet odd = ref IMap.empty\nlet even = ref IMap.empty\n\nlet incrmap mapr key =\n if IMap.mem key !mapr then\n mapr := IMap.add key (IMap.find key !mapr + 1) !mapr\n else\n mapr := IMap.add key 1 !mapr\n\nlet maxi mapr =\n let lis = IMap.bindings !mapr in\n let lis = List.sort (fun (k1,v1) (k1,v2) -> v2 - v1) lis in\n match lis with\n | [] -> failwith \"\"\n | (v, n) :: rest -> (v, n, rest)\n\nlet () =\n for i = 0 to n - 1 do\n if i mod 2 == 0 then begin\n incrmap odd vs.(i)\n end else begin\n incrmap even vs.(i)\n end\n done;\n let (k1, v1, rest1) = maxi odd in\n let (k2, v2, rest2) = maxi even in\n let rec loop k1 k2 v1 v2 rest1 rest2 =\n if k1 <> k2 then begin\n let n1 = List.fold_left (fun acc (v, n) -> acc + n) 0 rest1 in\n let n2 = List.fold_left (fun acc (v, n) -> acc + n) 0 rest2 in\n n1 + n2\n end else begin\n match rest1, rest2 with\n | (k1', v1') :: rest1', (k2', v2') :: rest2' when v1 < v2 ->\n v1 + loop k1' k2' v1' v2' rest1' rest2'\n | (k1', v1') :: rest1', (k2', v2') :: rest2' ->\n v2 + loop k1' k2' v1' v2' rest1' rest2'\n | _ -> v1\n end\n in\n let result = loop k1 k2 v1 v2 rest1 rest2 in\n printf \"%d\\n\" result\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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1410, "cpu_time_ms": 176, "memory_kb": 21120}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s470110743", "group_id": "codeNet:p03246", "input_text": "module IntMap = Map.Make (struct\n type t = int\n let compare = compare\nend)\n\nlet () = Scanf.scanf \"%d\\n\" @@ fun n ->\n let vs = Array.init n @@ fun _ -> Scanf.scanf \"%d \" @@ fun v -> v in\n let odds =\n List.sort (fun (_, x) (_, y) -> compare y x) @@\n IntMap.bindings @@\n Array.fold_left (fun m v ->\n IntMap.add v (1 + try IntMap.find v m with Not_found -> 0) m) IntMap.empty @@\n Array.init (n / 2) @@ fun i -> vs.(2 * i + 1) in\n let evens =\n List.sort (fun (_, x) (_, y) -> compare y x) @@\n IntMap.bindings @@\n Array.fold_left (fun m v ->\n IntMap.add v (1 + try IntMap.find v m with Not_found -> 0) m) IntMap.empty @@\n Array.init (n / 2) @@ fun i -> vs.(2 * i) in\n let v, m, m' =\n match odds with\n | [(v, n)] -> v, n, 0\n | (v, n) :: (_, n') :: _ -> v, n, n' in\n let v_, m_, m_' =\n match evens with\n | [(v, n)] -> v, n, 0\n | (v, n) :: (_, n') :: _ -> v, n, n' in\n Printf.printf \"%d\\n\" @@ n - (if v = v_ then max (m + m_') (m' + m_) else m + m_)\n", "language": "OCaml", "metadata": {"date": 1538270129, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03246.html", "problem_id": "p03246", "resource_group": "low_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/OCaml/s470110743.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s470110743", "user_id": "u504158101"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "module IntMap = Map.Make (struct\n type t = int\n let compare = compare\nend)\n\nlet () = Scanf.scanf \"%d\\n\" @@ fun n ->\n let vs = Array.init n @@ fun _ -> Scanf.scanf \"%d \" @@ fun v -> v in\n let odds =\n List.sort (fun (_, x) (_, y) -> compare y x) @@\n IntMap.bindings @@\n Array.fold_left (fun m v ->\n IntMap.add v (1 + try IntMap.find v m with Not_found -> 0) m) IntMap.empty @@\n Array.init (n / 2) @@ fun i -> vs.(2 * i + 1) in\n let evens =\n List.sort (fun (_, x) (_, y) -> compare y x) @@\n IntMap.bindings @@\n Array.fold_left (fun m v ->\n IntMap.add v (1 + try IntMap.find v m with Not_found -> 0) m) IntMap.empty @@\n Array.init (n / 2) @@ fun i -> vs.(2 * i) in\n let v, m, m' =\n match odds with\n | [(v, n)] -> v, n, 0\n | (v, n) :: (_, n') :: _ -> v, n, n' in\n let v_, m_, m_' =\n match evens with\n | [(v, n)] -> v, n, 0\n | (v, n) :: (_, n') :: _ -> v, n, n' in\n Printf.printf \"%d\\n\" @@ n - (if v = v_ then max (m + m_') (m' + m_) else m + m_)\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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 172, "memory_kb": 13344}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s692748023", "group_id": "codeNet:p03247", "input_text": "open Printf open Scanf\nmodule Lib = struct\n\tlet i32,i64,ist = Int64.(to_int,of_int,to_string)\n\tlet (+$) = (+) let (-$) = (-) let (/$) = (/) let ( *$) = ( * ) let (%$) = (mod)\n\tlet labs = Int64.abs\n\tlet (+),(-),( * ),(/),(mod),(%) = Int64.(add,sub,mul,div,rem,rem)\n\tlet (+=) r v = r := !r + v\n\tlet (-=) r v = r := !r - v\n\tlet ( *= ) r v = r := !r * v\n\tlet (/=) r v = r := !r / v\n\tlet (%=) r v = r := !r % v\n\tlet max_i64,min_i64 = Int64.(max_int,min_int)\n\t(* math *)\n\tlet ceildiv p q = (p+q-1L) / q\n\tlet rec gcd m n = match m,n with | m,0L -> m | m,n -> gcd n (m mod n)\n\tlet lcm m n = m / gcd m n * n \n\tmodule I64_infix = struct\n\t\tlet (land),(lor),(lxor),lnot,(lsl),(lsr),(asr) =\n\t\t\tlet open Int64 in\n\t\t\t(logand),(logor),(logxor),lognot,\n\t\t\t(fun u v -> shift_left u (i32 v)),\n\t\t\t(fun u v -> shift_right u (i32 v)),\n\t\t\t(fun u v -> shift_right_logical u (i32 v))\n\tend\n\t(* input *)\n\tlet input_i64_array n = Array.init (i32 n) (fun _ -> Scanf.scanf \" %Ld\" (fun v -> v))\n\tlet get_i64 _ = Scanf.scanf \" %Ld\" (fun v -> v)\n\tlet get_2_i64 _ = Scanf.scanf \" %Ld %Ld\" (fun u v -> u,v)\n\tlet get_3_i64 _ = Scanf.scanf \" %Ld %Ld %Ld\" (fun u v w -> u,v,w)\n\tlet get_4_i64 _ = Scanf.scanf \" %Ld %Ld %Ld %Ld\" (fun u v w x -> u,v,w,x)\n\tlet get_5_i64 _ = Scanf.scanf \" %Ld %Ld %Ld %Ld %Ld\" (fun u v w x y -> u,v,w,x,y)\n\tlet i32_get_int _ = Scanf.scanf \" %d\" (fun v -> v) let i32_get_2_ints _ = Scanf.scanf \" %d %d\" (fun u v -> u,v) let i32_get_3_ints _ = Scanf.scanf \" %d %d %d\" (fun u v w -> u,v,w) let i32_get_4_ints _ = Scanf.scanf \" %d %d %d %d\" (fun u v w x -> u,v,w,x) let i32_get_5_ints _ = Scanf.scanf \" %d %d %d %d %d\" (fun u v w x y -> u,v,w,x,y)\n\t(* utils *)\n\texternal id : 'a -> 'a = \"%identity\"\n\tlet ( *< ) f g x = f (g x)\n\tlet ( *> ) f g x = g (f x)\n\tlet rv f p q = f q p (* ex. 24 |> rv (/) 6 *)\n\tlet alen a = i64 @@ Array.length a\n\tlet llen l = i64 @@ List.length l\n\tlet string_of_list ?(separator=\" \") f ls = ls |> List.map f |> String.concat separator\n\tlet string_of_array ?(separator=\" \") f a = a |> Array.to_list |> string_of_list ~separator f\n\tlet char_list_of_string str = let rec f0 i a = if i<0 then a else f0 (i-$1) (str.[i]::a) in f0 (String.length str -$ 1) []\n\tlet string_of_char_list ls = List.fold_left (fun u v -> u ^ (String.make 1 v)) \"\" ls\n\tlet fail _ = failwith \"fail\"\n\tlet dx,dy = [|1;0;-1;0|],[|0;1;0;-1|]\n\tlet range l r = let ls = ref [] in for i=i32 l to i32 r do ls := i :: !ls done;!ls |> List.rev\n\tlet cartesian_product u v = u |> List.map (fun p -> List.map (fun q -> p,q) v) |> List.flatten\n\tlet shuffle a = Array.sort (fun _ _ -> (Random.int 3) -$ 1) a\n\tlet binary_search ng ok f = let d = if ng < ok then 1L else -1L in\n\t\tlet rec f0 ng ok =\n\t\t\tif labs (ok - ng) <= 1L then ok\n\t\t\telse let mid = ng + (ok - ng) / 2L in if f mid then f0 ng mid else f0 mid ok\n\t\tin f0 (ng-1L*d) (ok+1L*d)\n\tlet lower_bound a v = binary_search 0L (alen a - 1L) (fun i -> a.(i32 i) >= v)\n\tlet upper_bound a v = binary_search 0L (alen a - 1L) (fun i -> a.(i32 i) > v)\n\tlet equal_range a v = lower_bound a v, upper_bound a v (* #=snd-fst *)\n\tlet rec fix f x = f (fix f) x\n\tlet rec fix_memo ?(size=10000) f x =\n\t\tlet tb = Hashtbl.create ~random:true size in\n\t\tlet rec f0 x =\n\t\t\ttry Hashtbl.find tb x with\n\t\t\t| Not_found -> (let v = f f0 x in Hashtbl.add tb x v; v)\n\t\tin f0 x\n\t(* imperative *)\n\tlet rep f t ?(stride=1L) fbod = let i = ref f in while !i <= t do fbod !i; i := !i + stride done\n\tlet repb f t ?(stride=1L) fbod = let i,c = ref f,ref true in while !i <= t && !c do\n\t\tmatch fbod !i with | `Break -> c := false | `Ok -> i := !i + stride done\n\tlet repm f t ?(stride=1L) m0 fbod =\n\t\tlet i,c,m = ref f,ref true,ref m0 in\n\t\twhile !i<=t && !c do match fbod !m !i with\n\t\t| `Break -> c := false | `Break_m m' -> (c := false; m := m') | `Ok m' -> m := m'; i := !i + stride done; !m\n\tlet repi f t ?(stride=1) fbod = let i = ref f in while !i <= t do fbod !i; i := !i +$ stride done\n\tlet repib f t ?(stride=1) fbod = let i,c = ref f,ref true in while !i <= t && !c do\n\t\tmatch fbod !i with | `Break -> c := false | `Ok -> i := !i +$ stride done\n\tlet repim f t ?(stride=1) m0 fbod =\n\t\tlet i,c,m = ref f,ref true,ref m0 in\n\t\twhile !i<=t && !c do match fbod !m !i with\n\t\t| `Break -> c := false | `Break_m m' -> (c := false; m := m') | `Ok m' -> m := m'; i := !i +$ stride done; !m\n\tlet rep_rev f t ?(stride=1L) fbod = rep t f ~stride @@ fun v -> fbod @@ f + t - v\n\tlet repb_rev f t ?(stride=1L) fbod = repb t f ~stride @@ fun v -> fbod @@ f + t - v\n\tlet repm_rev f t ?(stride=1L) m0 fbod = repm f t ~stride m0 @@ fun u v -> fbod u @@ f + t - v\n\tlet repi_rev f t ?(stride=1) fbod = repi t f ~stride @@ fun v -> fbod @@ f +$ t -$ v\n\tlet repib_rev f t ?(stride=1) fbod = repib t f ~stride @@ fun v -> fbod @@ f +$ t -$ v\n\tlet repim_rev f t ?(stride=1) m0 fbod = repim f t ~stride m0 @@ fun u v -> fbod u @@ f +$ t -$ v\n\t(* output *)\n\tlet print_list_mle f ls = string_of_list f ls |> print_endline\n\tlet print_array_mle f a = string_of_array f a |> print_endline\n\tlet print_list f ls = ls |> List.iter (fun v -> printf \"%s \" @@ f v); print_newline ()\n\tlet print_array f a = a |> Array.iter (fun v -> printf \"%s \" @@ f v); print_newline ()\n\t(* debug *)\n\tlet dump_2darr f a = a |> Array.iter (fun b -> print_array f b)\n\tlet dump_i64_list ls = print_list ist ls\n\tlet dump_i64_array a = print_array ist a\nend open Lib open Array\n\nlet () =\n\tlet n = get_i64 0 in\n\tlet a = init (i32 n) (fun _ -> get_2_i64 0) in\n\tlet par,m = fold_left (fun (u,mx) (x,y) ->\n\t\tif (labs (x+y)) mod 2L <> u then (\n\t\t\tprintf \"-1\\n\"; exit 0\n\t\t) else (u, max mx (labs x+labs y))\n\t) ((labs (fst a.(0)+snd a.(0))) mod 2L,0L) a\n\tin\n\tlet pow =\n\t\tlet pow = init 35 (fun i -> Int64.shift_left 1L (35-$i-$1))\n\t\t|> to_list\n\t\tin of_list @@\n\t\t\tif par=0L then 1L::(pow |> List.rev) |> List.rev\n\t\t\telse pow\n\tin\n\tprintf \"%Ld\\n\" @@ alen pow;\n\tprint_array ist pow;\n\titer (fun (x,y) ->\n\t\tlet u,v = fold_left (fun (u,v) p -> \n\t\t\tif labs (x - u) >= labs (y - v) then (\n\t\t\t\tif x > u then (\n\t\t\t\t\tprint_char 'R'; (u+p,v)\n\t\t\t\t) else (\n\t\t\t\t\tprint_char 'L'; (u-p,v)\n\t\t\t\t)\n\t\t\t) else (\n\t\t\t\tif y > v then (\n\t\t\t\t\tprint_char 'U'; (u,v+p)\n\t\t\t\t) else (\n\t\t\t\t\tprint_char 'D'; (u,v-p)\n\t\t\t\t)\n\t\t\t)\n\t\t) (0L,0L) pow in\n\t\tassert (u=x && v=y);\n\t\tprint_newline ()\n\t) a", "language": "OCaml", "metadata": {"date": 1541760789, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03247.html", "problem_id": "p03247", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03247/input.txt", "sample_output_relpath": "derived/input_output/data/p03247/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03247/OCaml/s692748023.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s692748023", "user_id": "u481480055"}, "prompt_components": {"gold_output": "2\n1 2\nRL\nUU\nDR\n", "input_to_evaluate": "open Printf open Scanf\nmodule Lib = struct\n\tlet i32,i64,ist = Int64.(to_int,of_int,to_string)\n\tlet (+$) = (+) let (-$) = (-) let (/$) = (/) let ( *$) = ( * ) let (%$) = (mod)\n\tlet labs = Int64.abs\n\tlet (+),(-),( * ),(/),(mod),(%) = Int64.(add,sub,mul,div,rem,rem)\n\tlet (+=) r v = r := !r + v\n\tlet (-=) r v = r := !r - v\n\tlet ( *= ) r v = r := !r * v\n\tlet (/=) r v = r := !r / v\n\tlet (%=) r v = r := !r % v\n\tlet max_i64,min_i64 = Int64.(max_int,min_int)\n\t(* math *)\n\tlet ceildiv p q = (p+q-1L) / q\n\tlet rec gcd m n = match m,n with | m,0L -> m | m,n -> gcd n (m mod n)\n\tlet lcm m n = m / gcd m n * n \n\tmodule I64_infix = struct\n\t\tlet (land),(lor),(lxor),lnot,(lsl),(lsr),(asr) =\n\t\t\tlet open Int64 in\n\t\t\t(logand),(logor),(logxor),lognot,\n\t\t\t(fun u v -> shift_left u (i32 v)),\n\t\t\t(fun u v -> shift_right u (i32 v)),\n\t\t\t(fun u v -> shift_right_logical u (i32 v))\n\tend\n\t(* input *)\n\tlet input_i64_array n = Array.init (i32 n) (fun _ -> Scanf.scanf \" %Ld\" (fun v -> v))\n\tlet get_i64 _ = Scanf.scanf \" %Ld\" (fun v -> v)\n\tlet get_2_i64 _ = Scanf.scanf \" %Ld %Ld\" (fun u v -> u,v)\n\tlet get_3_i64 _ = Scanf.scanf \" %Ld %Ld %Ld\" (fun u v w -> u,v,w)\n\tlet get_4_i64 _ = Scanf.scanf \" %Ld %Ld %Ld %Ld\" (fun u v w x -> u,v,w,x)\n\tlet get_5_i64 _ = Scanf.scanf \" %Ld %Ld %Ld %Ld %Ld\" (fun u v w x y -> u,v,w,x,y)\n\tlet i32_get_int _ = Scanf.scanf \" %d\" (fun v -> v) let i32_get_2_ints _ = Scanf.scanf \" %d %d\" (fun u v -> u,v) let i32_get_3_ints _ = Scanf.scanf \" %d %d %d\" (fun u v w -> u,v,w) let i32_get_4_ints _ = Scanf.scanf \" %d %d %d %d\" (fun u v w x -> u,v,w,x) let i32_get_5_ints _ = Scanf.scanf \" %d %d %d %d %d\" (fun u v w x y -> u,v,w,x,y)\n\t(* utils *)\n\texternal id : 'a -> 'a = \"%identity\"\n\tlet ( *< ) f g x = f (g x)\n\tlet ( *> ) f g x = g (f x)\n\tlet rv f p q = f q p (* ex. 24 |> rv (/) 6 *)\n\tlet alen a = i64 @@ Array.length a\n\tlet llen l = i64 @@ List.length l\n\tlet string_of_list ?(separator=\" \") f ls = ls |> List.map f |> String.concat separator\n\tlet string_of_array ?(separator=\" \") f a = a |> Array.to_list |> string_of_list ~separator f\n\tlet char_list_of_string str = let rec f0 i a = if i<0 then a else f0 (i-$1) (str.[i]::a) in f0 (String.length str -$ 1) []\n\tlet string_of_char_list ls = List.fold_left (fun u v -> u ^ (String.make 1 v)) \"\" ls\n\tlet fail _ = failwith \"fail\"\n\tlet dx,dy = [|1;0;-1;0|],[|0;1;0;-1|]\n\tlet range l r = let ls = ref [] in for i=i32 l to i32 r do ls := i :: !ls done;!ls |> List.rev\n\tlet cartesian_product u v = u |> List.map (fun p -> List.map (fun q -> p,q) v) |> List.flatten\n\tlet shuffle a = Array.sort (fun _ _ -> (Random.int 3) -$ 1) a\n\tlet binary_search ng ok f = let d = if ng < ok then 1L else -1L in\n\t\tlet rec f0 ng ok =\n\t\t\tif labs (ok - ng) <= 1L then ok\n\t\t\telse let mid = ng + (ok - ng) / 2L in if f mid then f0 ng mid else f0 mid ok\n\t\tin f0 (ng-1L*d) (ok+1L*d)\n\tlet lower_bound a v = binary_search 0L (alen a - 1L) (fun i -> a.(i32 i) >= v)\n\tlet upper_bound a v = binary_search 0L (alen a - 1L) (fun i -> a.(i32 i) > v)\n\tlet equal_range a v = lower_bound a v, upper_bound a v (* #=snd-fst *)\n\tlet rec fix f x = f (fix f) x\n\tlet rec fix_memo ?(size=10000) f x =\n\t\tlet tb = Hashtbl.create ~random:true size in\n\t\tlet rec f0 x =\n\t\t\ttry Hashtbl.find tb x with\n\t\t\t| Not_found -> (let v = f f0 x in Hashtbl.add tb x v; v)\n\t\tin f0 x\n\t(* imperative *)\n\tlet rep f t ?(stride=1L) fbod = let i = ref f in while !i <= t do fbod !i; i := !i + stride done\n\tlet repb f t ?(stride=1L) fbod = let i,c = ref f,ref true in while !i <= t && !c do\n\t\tmatch fbod !i with | `Break -> c := false | `Ok -> i := !i + stride done\n\tlet repm f t ?(stride=1L) m0 fbod =\n\t\tlet i,c,m = ref f,ref true,ref m0 in\n\t\twhile !i<=t && !c do match fbod !m !i with\n\t\t| `Break -> c := false | `Break_m m' -> (c := false; m := m') | `Ok m' -> m := m'; i := !i + stride done; !m\n\tlet repi f t ?(stride=1) fbod = let i = ref f in while !i <= t do fbod !i; i := !i +$ stride done\n\tlet repib f t ?(stride=1) fbod = let i,c = ref f,ref true in while !i <= t && !c do\n\t\tmatch fbod !i with | `Break -> c := false | `Ok -> i := !i +$ stride done\n\tlet repim f t ?(stride=1) m0 fbod =\n\t\tlet i,c,m = ref f,ref true,ref m0 in\n\t\twhile !i<=t && !c do match fbod !m !i with\n\t\t| `Break -> c := false | `Break_m m' -> (c := false; m := m') | `Ok m' -> m := m'; i := !i +$ stride done; !m\n\tlet rep_rev f t ?(stride=1L) fbod = rep t f ~stride @@ fun v -> fbod @@ f + t - v\n\tlet repb_rev f t ?(stride=1L) fbod = repb t f ~stride @@ fun v -> fbod @@ f + t - v\n\tlet repm_rev f t ?(stride=1L) m0 fbod = repm f t ~stride m0 @@ fun u v -> fbod u @@ f + t - v\n\tlet repi_rev f t ?(stride=1) fbod = repi t f ~stride @@ fun v -> fbod @@ f +$ t -$ v\n\tlet repib_rev f t ?(stride=1) fbod = repib t f ~stride @@ fun v -> fbod @@ f +$ t -$ v\n\tlet repim_rev f t ?(stride=1) m0 fbod = repim f t ~stride m0 @@ fun u v -> fbod u @@ f +$ t -$ v\n\t(* output *)\n\tlet print_list_mle f ls = string_of_list f ls |> print_endline\n\tlet print_array_mle f a = string_of_array f a |> print_endline\n\tlet print_list f ls = ls |> List.iter (fun v -> printf \"%s \" @@ f v); print_newline ()\n\tlet print_array f a = a |> Array.iter (fun v -> printf \"%s \" @@ f v); print_newline ()\n\t(* debug *)\n\tlet dump_2darr f a = a |> Array.iter (fun b -> print_array f b)\n\tlet dump_i64_list ls = print_list ist ls\n\tlet dump_i64_array a = print_array ist a\nend open Lib open Array\n\nlet () =\n\tlet n = get_i64 0 in\n\tlet a = init (i32 n) (fun _ -> get_2_i64 0) in\n\tlet par,m = fold_left (fun (u,mx) (x,y) ->\n\t\tif (labs (x+y)) mod 2L <> u then (\n\t\t\tprintf \"-1\\n\"; exit 0\n\t\t) else (u, max mx (labs x+labs y))\n\t) ((labs (fst a.(0)+snd a.(0))) mod 2L,0L) a\n\tin\n\tlet pow =\n\t\tlet pow = init 35 (fun i -> Int64.shift_left 1L (35-$i-$1))\n\t\t|> to_list\n\t\tin of_list @@\n\t\t\tif par=0L then 1L::(pow |> List.rev) |> List.rev\n\t\t\telse pow\n\tin\n\tprintf \"%Ld\\n\" @@ alen pow;\n\tprint_array ist pow;\n\titer (fun (x,y) ->\n\t\tlet u,v = fold_left (fun (u,v) p -> \n\t\t\tif labs (x - u) >= labs (y - v) then (\n\t\t\t\tif x > u then (\n\t\t\t\t\tprint_char 'R'; (u+p,v)\n\t\t\t\t) else (\n\t\t\t\t\tprint_char 'L'; (u-p,v)\n\t\t\t\t)\n\t\t\t) else (\n\t\t\t\tif y > v then (\n\t\t\t\t\tprint_char 'U'; (u,v+p)\n\t\t\t\t) else (\n\t\t\t\t\tprint_char 'D'; (u,v-p)\n\t\t\t\t)\n\t\t\t)\n\t\t) (0L,0L) pow in\n\t\tassert (u=x && v=y);\n\t\tprint_newline ()\n\t) a", "problem_context": "Score : 600 points\n\nProblem Statement\n\nSnuke is introducing a robot arm with the following properties to his factory:\n\nThe robot arm consists of m sections and m+1 joints. The sections are numbered 1, 2, ..., m, and the joints are numbered 0, 1, ..., m. Section i connects Joint i-1 and Joint i. The length of Section i is d_i.\n\nFor each section, its mode can be specified individually. There are four modes: L, R, D and U. The mode of a section decides the direction of that section. If we consider the factory as a coordinate plane, the position of Joint i will be determined as follows (we denote its coordinates as (x_i, y_i)):\n\n(x_0, y_0) = (0, 0).\n\nIf the mode of Section i is L, (x_{i}, y_{i}) = (x_{i-1} - d_{i}, y_{i-1}).\n\nIf the mode of Section i is R, (x_{i}, y_{i}) = (x_{i-1} + d_{i}, y_{i-1}).\n\nIf the mode of Section i is D, (x_{i}, y_{i}) = (x_{i-1}, y_{i-1} - d_{i}).\n\nIf the mode of Section i is U, (x_{i}, y_{i}) = (x_{i-1}, y_{i-1} + d_{i}).\n\nSnuke would like to introduce a robot arm so that the position of Joint m can be matched with all of the N points (X_1, Y_1), (X_2, Y_2), ..., (X_N, Y_N) by properly specifying the modes of the sections.\nIs this possible?\nIf so, find such a robot arm and how to bring Joint m to each point (X_j, Y_j).\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 1000\n\n-10^9 \\leq X_i \\leq 10^9\n\n-10^9 \\leq Y_i \\leq 10^9\n\nPartial Score\n\nIn the test cases worth 300 points, -10 \\leq X_i \\leq 10 and -10 \\leq Y_i \\leq 10 hold.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nX_1 Y_1\nX_2 Y_2\n:\nX_N Y_N\n\nOutput\n\nIf the condition can be satisfied, follow the following format. If the condition cannot be satisfied, print -1.\n\nm\nd_1 d_2 ... d_m\nw_1\nw_2\n:\nw_N\n\nm and d_i are the configurations of the robot arm. Refer to the problem statement for what each of them means.\nHere, 1 \\leq m \\leq 40 and 1 \\leq d_i \\leq 10^{12} must hold. Also, m and d_i must all be integers.\n\nw_j is a string of length m that represents the way to bring Joint m of the robot arm to point (X_j, Y_j).\nThe i-th character of w_j should be one of the letters L, R, D and U, representing the mode of Section i.\n\nSample Input 1\n\n3\n-1 0\n0 3\n2 -1\n\nSample Output 1\n\n2\n1 2\nRL\nUU\nDR\n\nIn the given way to bring Joint m of the robot arm to each (X_j, Y_j), the positions of the joints will be as follows:\n\nTo (X_1, Y_1) = (-1, 0): First, the position of Joint 0 is (x_0, y_0) = (0, 0). As the mode of Section 1 is R, the position of Joint 1 is (x_1, y_1) = (1, 0). Then, as the mode of Section 2 is L, the position of Joint 2 is (x_2, y_2) = (-1, 0).\n\nTo (X_2, Y_2) = (0, 3): (x_0, y_0) = (0, 0), (x_1, y_1) = (0, 1), (x_2, y_2) = (0, 3).\n\nTo (X_3, Y_3) = (2, -1): (x_0, y_0) = (0, 0), (x_1, y_1) = (0, -1), (x_2, y_2) = (2, -1).\n\nSample Input 2\n\n5\n0 0\n1 0\n2 0\n3 0\n4 0\n\nSample Output 2\n\n-1\n\nSample Input 3\n\n2\n1 1\n1 1\n\nSample Output 3\n\n2\n1 1\nRU\nUR\n\nThere may be duplicated points among (X_j, Y_j).\n\nSample Input 4\n\n3\n-7 -3\n7 3\n-3 -7\n\nSample Output 4\n\n5\n3 1 4 1 5\nLRDUL\nRDULR\nDULRD", "sample_input": "3\n-1 0\n0 3\n2 -1\n"}, "reference_outputs": ["2\n1 2\nRL\nUU\nDR\n"], "source_document_id": "p03247", "source_text": "Score : 600 points\n\nProblem Statement\n\nSnuke is introducing a robot arm with the following properties to his factory:\n\nThe robot arm consists of m sections and m+1 joints. The sections are numbered 1, 2, ..., m, and the joints are numbered 0, 1, ..., m. Section i connects Joint i-1 and Joint i. The length of Section i is d_i.\n\nFor each section, its mode can be specified individually. There are four modes: L, R, D and U. The mode of a section decides the direction of that section. If we consider the factory as a coordinate plane, the position of Joint i will be determined as follows (we denote its coordinates as (x_i, y_i)):\n\n(x_0, y_0) = (0, 0).\n\nIf the mode of Section i is L, (x_{i}, y_{i}) = (x_{i-1} - d_{i}, y_{i-1}).\n\nIf the mode of Section i is R, (x_{i}, y_{i}) = (x_{i-1} + d_{i}, y_{i-1}).\n\nIf the mode of Section i is D, (x_{i}, y_{i}) = (x_{i-1}, y_{i-1} - d_{i}).\n\nIf the mode of Section i is U, (x_{i}, y_{i}) = (x_{i-1}, y_{i-1} + d_{i}).\n\nSnuke would like to introduce a robot arm so that the position of Joint m can be matched with all of the N points (X_1, Y_1), (X_2, Y_2), ..., (X_N, Y_N) by properly specifying the modes of the sections.\nIs this possible?\nIf so, find such a robot arm and how to bring Joint m to each point (X_j, Y_j).\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq N \\leq 1000\n\n-10^9 \\leq X_i \\leq 10^9\n\n-10^9 \\leq Y_i \\leq 10^9\n\nPartial Score\n\nIn the test cases worth 300 points, -10 \\leq X_i \\leq 10 and -10 \\leq Y_i \\leq 10 hold.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nX_1 Y_1\nX_2 Y_2\n:\nX_N Y_N\n\nOutput\n\nIf the condition can be satisfied, follow the following format. If the condition cannot be satisfied, print -1.\n\nm\nd_1 d_2 ... d_m\nw_1\nw_2\n:\nw_N\n\nm and d_i are the configurations of the robot arm. Refer to the problem statement for what each of them means.\nHere, 1 \\leq m \\leq 40 and 1 \\leq d_i \\leq 10^{12} must hold. Also, m and d_i must all be integers.\n\nw_j is a string of length m that represents the way to bring Joint m of the robot arm to point (X_j, Y_j).\nThe i-th character of w_j should be one of the letters L, R, D and U, representing the mode of Section i.\n\nSample Input 1\n\n3\n-1 0\n0 3\n2 -1\n\nSample Output 1\n\n2\n1 2\nRL\nUU\nDR\n\nIn the given way to bring Joint m of the robot arm to each (X_j, Y_j), the positions of the joints will be as follows:\n\nTo (X_1, Y_1) = (-1, 0): First, the position of Joint 0 is (x_0, y_0) = (0, 0). As the mode of Section 1 is R, the position of Joint 1 is (x_1, y_1) = (1, 0). Then, as the mode of Section 2 is L, the position of Joint 2 is (x_2, y_2) = (-1, 0).\n\nTo (X_2, Y_2) = (0, 3): (x_0, y_0) = (0, 0), (x_1, y_1) = (0, 1), (x_2, y_2) = (0, 3).\n\nTo (X_3, Y_3) = (2, -1): (x_0, y_0) = (0, 0), (x_1, y_1) = (0, -1), (x_2, y_2) = (2, -1).\n\nSample Input 2\n\n5\n0 0\n1 0\n2 0\n3 0\n4 0\n\nSample Output 2\n\n-1\n\nSample Input 3\n\n2\n1 1\n1 1\n\nSample Output 3\n\n2\n1 1\nRU\nUR\n\nThere may be duplicated points among (X_j, Y_j).\n\nSample Input 4\n\n3\n-7 -3\n7 3\n-3 -7\n\nSample Output 4\n\n5\n3 1 4 1 5\nLRDUL\nRDULR\nDULRD", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 6185, "cpu_time_ms": 5, "memory_kb": 4736}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s634352600", "group_id": "codeNet:p03248", "input_text": "Scanf.scanf \"%s\" (fun s ->\n let n = String.length s in\n let proc () =\n let rec loop i prev acc =\n if i = n - 1 then prev, acc else \n let acc = (prev, i + 2) :: acc in\n if i >= n / 2 then loop (i + 1) prev acc else\n if s.[i] <> s.[n - 2 - i] then prev, [] else\n if s.[i] = '1' then loop (i + 1) (i + 2) acc\n else loop (i + 1) prev acc\n in\n let prev, acc = loop 0 1 [] in\n if acc = [] then print_endline \"-1\" else\n List.iter (fun (a, b) -> Printf.printf \"%d %d\\n\" a b) acc\n in\n if s.[n - 1] = '1' || s.[0] = '0' || s.[n - 2] = '0' then print_endline \"-1\" else proc ()\n)", "language": "OCaml", "metadata": {"date": 1599547190, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p03248.html", "problem_id": "p03248", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03248/input.txt", "sample_output_relpath": "derived/input_output/data/p03248/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03248/OCaml/s634352600.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s634352600", "user_id": "u342443598"}, "prompt_components": {"gold_output": "-1\n", "input_to_evaluate": "Scanf.scanf \"%s\" (fun s ->\n let n = String.length s in\n let proc () =\n let rec loop i prev acc =\n if i = n - 1 then prev, acc else \n let acc = (prev, i + 2) :: acc in\n if i >= n / 2 then loop (i + 1) prev acc else\n if s.[i] <> s.[n - 2 - i] then prev, [] else\n if s.[i] = '1' then loop (i + 1) (i + 2) acc\n else loop (i + 1) prev acc\n in\n let prev, acc = loop 0 1 [] in\n if acc = [] then print_endline \"-1\" else\n List.iter (fun (a, b) -> Printf.printf \"%d %d\\n\" a b) acc\n in\n if s.[n - 1] = '1' || s.[0] = '0' || s.[n - 2] = '0' then print_endline \"-1\" else proc ()\n)", "problem_context": "Score : 700 points\n\nProblem Statement\n\nYou are given a string s of length n.\nDoes a tree with n vertices that satisfies the following conditions exist?\n\nThe vertices are numbered 1,2,..., n.\n\nThe edges are numbered 1,2,..., n-1, and Edge i connects Vertex u_i and v_i.\n\nIf the i-th character in s is 1, we can have a connected component of size i by removing one edge from the tree.\n\nIf the i-th character in s is 0, we cannot have a connected component of size i by removing any one edge from the tree.\n\nIf such a tree exists, construct one such tree.\n\nConstraints\n\n2 \\leq n \\leq 10^5\n\ns is a string of length n consisting of 0 and 1.\n\nInput\n\nInput is given from Standard Input in the following format:\n\ns\n\nOutput\n\nIf a tree with n vertices that satisfies the conditions does not exist, print -1.\n\nIf a tree with n vertices that satisfies the conditions exist, print n-1 lines.\nThe i-th line should contain u_i and v_i with a space in between.\nIf there are multiple trees that satisfy the conditions, any such tree will be accepted.\n\nSample Input 1\n\n1111\n\nSample Output 1\n\n-1\n\nIt is impossible to have a connected component of size n after removing one edge from a tree with n vertices.\n\nSample Input 2\n\n1110\n\nSample Output 2\n\n1 2\n2 3\n3 4\n\nIf Edge 1 or Edge 3 is removed, we will have a connected component of size 1 and another of size 3. If Edge 2 is removed, we will have two connected components, each of size 2.\n\nSample Input 3\n\n1010\n\nSample Output 3\n\n1 2\n1 3\n1 4\n\nRemoving any edge will result in a connected component of size 1 and another of size 3.", "sample_input": "1111\n"}, "reference_outputs": ["-1\n"], "source_document_id": "p03248", "source_text": "Score : 700 points\n\nProblem Statement\n\nYou are given a string s of length n.\nDoes a tree with n vertices that satisfies the following conditions exist?\n\nThe vertices are numbered 1,2,..., n.\n\nThe edges are numbered 1,2,..., n-1, and Edge i connects Vertex u_i and v_i.\n\nIf the i-th character in s is 1, we can have a connected component of size i by removing one edge from the tree.\n\nIf the i-th character in s is 0, we cannot have a connected component of size i by removing any one edge from the tree.\n\nIf such a tree exists, construct one such tree.\n\nConstraints\n\n2 \\leq n \\leq 10^5\n\ns is a string of length n consisting of 0 and 1.\n\nInput\n\nInput is given from Standard Input in the following format:\n\ns\n\nOutput\n\nIf a tree with n vertices that satisfies the conditions does not exist, print -1.\n\nIf a tree with n vertices that satisfies the conditions exist, print n-1 lines.\nThe i-th line should contain u_i and v_i with a space in between.\nIf there are multiple trees that satisfy the conditions, any such tree will be accepted.\n\nSample Input 1\n\n1111\n\nSample Output 1\n\n-1\n\nIt is impossible to have a connected component of size n after removing one edge from a tree with n vertices.\n\nSample Input 2\n\n1110\n\nSample Output 2\n\n1 2\n2 3\n3 4\n\nIf Edge 1 or Edge 3 is removed, we will have a connected component of size 1 and another of size 3. If Edge 2 is removed, we will have two connected components, each of size 2.\n\nSample Input 3\n\n1010\n\nSample Output 3\n\n1 2\n1 3\n1 4\n\nRemoving any edge will result in a connected component of size 1 and another of size 3.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 734, "cpu_time_ms": 69, "memory_kb": 11252}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s383556476", "group_id": "codeNet:p03254", "input_text": "(*\nocamlfind ocamlopt -package batteries -linkpkg main.ml -o a.out\n*)\nopen Batteries\n\nlet rec solver lst x =\n match lst with\n [] -> 0\n | first :: [] -> \n if (x - first) = 0 then\n 1\n else\n 0\n | first :: rest -> \n if (x - first) = 0 then\n 1\n else\n if (x - first) < 0 then\n 0\n else\n let tmax = solver rest (x - first) in\n let fmax = solver rest x in\n if (tmax + 1) < fmax then\n fmax\n else\n tmax + 1\n\nlet n, x = Scanf.sscanf (read_line ()) \"%d %d\" ( fun n x -> n, x)\nlet lst = Str.split (Str.regexp \" \") (read_line ())\n |> List.map int_of_string \n |> List.sort compare\n\nlet () =\n solver lst x\n |> Printf.printf \"%d\\n\"\n", "language": "OCaml", "metadata": {"date": 1590259296, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03254.html", "problem_id": "p03254", "resource_group": "low_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/OCaml/s383556476.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s383556476", "user_id": "u280335093"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "(*\nocamlfind ocamlopt -package batteries -linkpkg main.ml -o a.out\n*)\nopen Batteries\n\nlet rec solver lst x =\n match lst with\n [] -> 0\n | first :: [] -> \n if (x - first) = 0 then\n 1\n else\n 0\n | first :: rest -> \n if (x - first) = 0 then\n 1\n else\n if (x - first) < 0 then\n 0\n else\n let tmax = solver rest (x - first) in\n let fmax = solver rest x in\n if (tmax + 1) < fmax then\n fmax\n else\n tmax + 1\n\nlet n, x = Scanf.sscanf (read_line ()) \"%d %d\" ( fun n x -> n, x)\nlet lst = Str.split (Str.regexp \" \") (read_line ())\n |> List.map int_of_string \n |> List.sort compare\n\nlet () =\n solver lst x\n |> Printf.printf \"%d\\n\"\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nThere are N children, numbered 1, 2, ..., N.\n\nSnuke has decided to distribute x sweets among them.\nHe needs to give out all the x sweets, but some of the children may get zero sweets.\n\nFor each i (1 \\leq i \\leq N), Child i will be happy if he/she gets exactly a_i sweets.\nSnuke is trying to maximize the number of happy children by optimally distributing the sweets.\nFind the maximum possible number of happy children.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 100\n\n1 \\leq x \\leq 10^9\n\n1 \\leq a_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN x\na_1 a_2 ... a_N\n\nOutput\n\nPrint the maximum possible number of happy children.\n\nSample Input 1\n\n3 70\n20 30 10\n\nSample Output 1\n\n2\n\nOne optimal way to distribute sweets is (20, 30, 20).\n\nSample Input 2\n\n3 10\n20 30 10\n\nSample Output 2\n\n1\n\nThe optimal way to distribute sweets is (0, 0, 10).\n\nSample Input 3\n\n4 1111\n1 10 100 1000\n\nSample Output 3\n\n4\n\nThe optimal way to distribute sweets is (1, 10, 100, 1000).\n\nSample Input 4\n\n2 10\n20 20\n\nSample Output 4\n\n0\n\nNo children will be happy, no matter how the sweets are distributed.", "sample_input": "3 70\n20 30 10\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03254", "source_text": "Score : 200 points\n\nProblem Statement\n\nThere are N children, numbered 1, 2, ..., N.\n\nSnuke has decided to distribute x sweets among them.\nHe needs to give out all the x sweets, but some of the children may get zero sweets.\n\nFor each i (1 \\leq i \\leq N), Child i will be happy if he/she gets exactly a_i sweets.\nSnuke is trying to maximize the number of happy children by optimally distributing the sweets.\nFind the maximum possible number of happy children.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 100\n\n1 \\leq x \\leq 10^9\n\n1 \\leq a_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN x\na_1 a_2 ... a_N\n\nOutput\n\nPrint the maximum possible number of happy children.\n\nSample Input 1\n\n3 70\n20 30 10\n\nSample Output 1\n\n2\n\nOne optimal way to distribute sweets is (20, 30, 20).\n\nSample Input 2\n\n3 10\n20 30 10\n\nSample Output 2\n\n1\n\nThe optimal way to distribute sweets is (0, 0, 10).\n\nSample Input 3\n\n4 1111\n1 10 100 1000\n\nSample Output 3\n\n4\n\nThe optimal way to distribute sweets is (1, 10, 100, 1000).\n\nSample Input 4\n\n2 10\n20 20\n\nSample Output 4\n\n0\n\nNo children will be happy, no matter how the sweets are distributed.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1196, "cpu_time_ms": 2103, "memory_kb": 3200}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s114367656", "group_id": "codeNet:p03254", "input_text": "let n, x = Scanf.scanf \" %d %d\" @@ fun a b -> a, b\nlet a_s = Array.init n @@ fun _ -> Scanf.scanf \" %d\" @@ (+) 0\nlet _ =\n Array.sort (-) a_s;\n let c, r = Array.fold_left (fun (c, r) a -> (if a > r then c else c + 1), r - a) (0, x) a_s in\n Printf.printf \"%d\\n\" @@ if r > 0 then n - 1 else c", "language": "OCaml", "metadata": {"date": 1561698407, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03254.html", "problem_id": "p03254", "resource_group": "low_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/OCaml/s114367656.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s114367656", "user_id": "u732304692"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "let n, x = Scanf.scanf \" %d %d\" @@ fun a b -> a, b\nlet a_s = Array.init n @@ fun _ -> Scanf.scanf \" %d\" @@ (+) 0\nlet _ =\n Array.sort (-) a_s;\n let c, r = Array.fold_left (fun (c, r) a -> (if a > r then c else c + 1), r - a) (0, x) a_s in\n Printf.printf \"%d\\n\" @@ if r > 0 then n - 1 else 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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s716106817", "group_id": "codeNet:p03263", "input_text": "let (h, w) = Scanf.scanf \"%d %d\" (fun x y -> (x, y)) in\nlet a = Array.init h (fun _ -> Array.make w 0) in\nfor i = 0 to h - 1 do\n for j = 0 to w - 1 do\n a.(i).(j) <- Scanf.scanf (if j = 0 then \"\\n%d\" else \" %d\") (fun x -> x)\n done\ndone;\nlet ans = ref [] in\nfor i = 0 to h - 2 do\n for j = 0 to w - 1 do\n if a.(i).(j) mod 2 = 1 then begin\n a.(i).(j) <- a.(i).(j) - 1;\n a.(i + 1).(j) <- a.(i + 1).(j) + 1;\n ans := (i, j, i + 1, j)::!ans\n end\n done\ndone;\nfor j = 0 to w - 2 do\n if a.(h - 1).(j) mod 2 = 1 then begin\n a.(h - 1).(j) <- a.(h - 1).(j) - 1;\n a.(h - 1).(j + 1) <- a.(h - 1).(j + 1) + 1;\n ans := (h - 1, j, h - 1, j + 1)::!ans\n end\ndone;\nlet ans = List.rev !ans in\nprint_int (List.length ans);\nprint_newline ();\nans |> List.iter (fun (y1, x1, y2, x2) -> Printf.printf \"%d %d %d %d\\n\" (y1 + 1) (x1 + 1) (y2 + 1) (x2 + 1));;\n\n", "language": "OCaml", "metadata": {"date": 1536463967, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03263.html", "problem_id": "p03263", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03263/input.txt", "sample_output_relpath": "derived/input_output/data/p03263/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03263/OCaml/s716106817.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s716106817", "user_id": "u006493569"}, "prompt_components": {"gold_output": "3\n2 2 2 3\n1 1 1 2\n1 3 1 2\n", "input_to_evaluate": "let (h, w) = Scanf.scanf \"%d %d\" (fun x y -> (x, y)) in\nlet a = Array.init h (fun _ -> Array.make w 0) in\nfor i = 0 to h - 1 do\n for j = 0 to w - 1 do\n a.(i).(j) <- Scanf.scanf (if j = 0 then \"\\n%d\" else \" %d\") (fun x -> x)\n done\ndone;\nlet ans = ref [] in\nfor i = 0 to h - 2 do\n for j = 0 to w - 1 do\n if a.(i).(j) mod 2 = 1 then begin\n a.(i).(j) <- a.(i).(j) - 1;\n a.(i + 1).(j) <- a.(i + 1).(j) + 1;\n ans := (i, j, i + 1, j)::!ans\n end\n done\ndone;\nfor j = 0 to w - 2 do\n if a.(h - 1).(j) mod 2 = 1 then begin\n a.(h - 1).(j) <- a.(h - 1).(j) - 1;\n a.(h - 1).(j + 1) <- a.(h - 1).(j + 1) + 1;\n ans := (h - 1, j, h - 1, j + 1)::!ans\n end\ndone;\nlet ans = List.rev !ans in\nprint_int (List.length ans);\nprint_newline ();\nans |> List.iter (fun (y1, x1, y2, x2) -> Printf.printf \"%d %d %d %d\\n\" (y1 + 1) (x1 + 1) (y2 + 1) (x2 + 1));;\n\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nThere is a grid of square cells with H horizontal rows and W vertical columns. The cell at the i-th row and the j-th column will be denoted as Cell (i, j).\n\nIn Cell (i, j), a_{ij} coins are placed.\n\nYou can perform the following operation any number of times:\n\nOperation: Choose a cell that was not chosen before and contains one or more coins, then move one of those coins to a vertically or horizontally adjacent cell.\n\nMaximize the number of cells containing an even number of coins.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq H, W \\leq 500\n\n0 \\leq a_{ij} \\leq 9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\na_{11} a_{12} ... a_{1W}\na_{21} a_{22} ... a_{2W}\n:\na_{H1} a_{H2} ... a_{HW}\n\nOutput\n\nPrint a sequence of operations that maximizes the number of cells containing an even number of coins, in the following format:\n\nN\ny_1 x_1 y_1' x_1'\ny_2 x_2 y_2' x_2'\n:\ny_N x_N y_N' x_N'\n\nThat is, in the first line, print an integer N between 0 and H \\times W (inclusive), representing the number of operations.\n\nIn the (i+1)-th line (1 \\leq i \\leq N), print four integers y_i, x_i, y_i' and x_i' (1 \\leq y_i, y_i' \\leq H and 1 \\leq x_i, x_i' \\leq W), representing the i-th operation. These four integers represents the operation of moving one of the coins placed in Cell (y_i, x_i) to a vertically or horizontally adjacent cell, (y_i', x_i').\n\nNote that if the specified operation violates the specification in the problem statement or the output format is invalid, it will result in Wrong Answer.\n\nSample Input 1\n\n2 3\n1 2 3\n0 1 1\n\nSample Output 1\n\n3\n2 2 2 3\n1 1 1 2\n1 3 1 2\n\nEvery cell contains an even number of coins after the following sequence of operations:\n\nMove the coin in Cell (2, 2) to Cell (2, 3).\n\nMove the coin in Cell (1, 1) to Cell (1, 2).\n\nMove one of the coins in Cell (1, 3) to Cell (1, 2).\n\nSample Input 2\n\n3 2\n1 0\n2 1\n1 0\n\nSample Output 2\n\n3\n1 1 1 2\n1 2 2 2\n3 1 3 2\n\nSample Input 3\n\n1 5\n9 9 9 9 9\n\nSample Output 3\n\n2\n1 1 1 2\n1 3 1 4", "sample_input": "2 3\n1 2 3\n0 1 1\n"}, "reference_outputs": ["3\n2 2 2 3\n1 1 1 2\n1 3 1 2\n"], "source_document_id": "p03263", "source_text": "Score : 400 points\n\nProblem Statement\n\nThere is a grid of square cells with H horizontal rows and W vertical columns. The cell at the i-th row and the j-th column will be denoted as Cell (i, j).\n\nIn Cell (i, j), a_{ij} coins are placed.\n\nYou can perform the following operation any number of times:\n\nOperation: Choose a cell that was not chosen before and contains one or more coins, then move one of those coins to a vertically or horizontally adjacent cell.\n\nMaximize the number of cells containing an even number of coins.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq H, W \\leq 500\n\n0 \\leq a_{ij} \\leq 9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\na_{11} a_{12} ... a_{1W}\na_{21} a_{22} ... a_{2W}\n:\na_{H1} a_{H2} ... a_{HW}\n\nOutput\n\nPrint a sequence of operations that maximizes the number of cells containing an even number of coins, in the following format:\n\nN\ny_1 x_1 y_1' x_1'\ny_2 x_2 y_2' x_2'\n:\ny_N x_N y_N' x_N'\n\nThat is, in the first line, print an integer N between 0 and H \\times W (inclusive), representing the number of operations.\n\nIn the (i+1)-th line (1 \\leq i \\leq N), print four integers y_i, x_i, y_i' and x_i' (1 \\leq y_i, y_i' \\leq H and 1 \\leq x_i, x_i' \\leq W), representing the i-th operation. These four integers represents the operation of moving one of the coins placed in Cell (y_i, x_i) to a vertically or horizontally adjacent cell, (y_i', x_i').\n\nNote that if the specified operation violates the specification in the problem statement or the output format is invalid, it will result in Wrong Answer.\n\nSample Input 1\n\n2 3\n1 2 3\n0 1 1\n\nSample Output 1\n\n3\n2 2 2 3\n1 1 1 2\n1 3 1 2\n\nEvery cell contains an even number of coins after the following sequence of operations:\n\nMove the coin in Cell (2, 2) to Cell (2, 3).\n\nMove the coin in Cell (1, 1) to Cell (1, 2).\n\nMove one of the coins in Cell (1, 3) to Cell (1, 2).\n\nSample Input 2\n\n3 2\n1 0\n2 1\n1 0\n\nSample Output 2\n\n3\n1 1 1 2\n1 2 2 2\n3 1 3 2\n\nSample Input 3\n\n1 5\n9 9 9 9 9\n\nSample Output 3\n\n2\n1 1 1 2\n1 3 1 4", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 166, "memory_kb": 17920}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s331789169", "group_id": "codeNet:p03263", "input_text": "open Printf\nopen Scanf\n\nlet id x = x\n\nlet h, w = scanf \"%d %d\" (fun h w -> h, w)\nlet vs = Array.init (h * w) (fun i -> scanf \" %d\" id)\n\nlet nth n =\n let y = n / w in\n let x = n mod w in\n let x' = if y mod 2 = 0 then x else w - 1 - x in\n y * w + x'\n\nlet decode n =\n let y = n / w in\n let x = n mod w in\n (y + 1, x + 1)\n\nlet () =\n let out = ref [] in\n let moving = ref false in\n for n = 0 to h * w - 1 do\n let i = nth n in\n if !moving then begin\n out := (i, n) :: !out;\n if vs.(i) mod 2 = 1 then moving := false\n end else begin\n if vs.(i) mod 2 = 1 then moving := true\n end\n done;\n out := List.rev !out;\n printf \"%d\\n\" (List.length !out);\n List.iter (fun (v, n) ->\n let y0, x0 = decode (nth (n - 1)) in\n let y1, x1 = decode v in\n printf \"%d %d %d %d\\n\" y0 x0 y1 x1\n ) !out;\n", "language": "OCaml", "metadata": {"date": 1536459263, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03263.html", "problem_id": "p03263", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03263/input.txt", "sample_output_relpath": "derived/input_output/data/p03263/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03263/OCaml/s331789169.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s331789169", "user_id": "u450300828"}, "prompt_components": {"gold_output": "3\n2 2 2 3\n1 1 1 2\n1 3 1 2\n", "input_to_evaluate": "open Printf\nopen Scanf\n\nlet id x = x\n\nlet h, w = scanf \"%d %d\" (fun h w -> h, w)\nlet vs = Array.init (h * w) (fun i -> scanf \" %d\" id)\n\nlet nth n =\n let y = n / w in\n let x = n mod w in\n let x' = if y mod 2 = 0 then x else w - 1 - x in\n y * w + x'\n\nlet decode n =\n let y = n / w in\n let x = n mod w in\n (y + 1, x + 1)\n\nlet () =\n let out = ref [] in\n let moving = ref false in\n for n = 0 to h * w - 1 do\n let i = nth n in\n if !moving then begin\n out := (i, n) :: !out;\n if vs.(i) mod 2 = 1 then moving := false\n end else begin\n if vs.(i) mod 2 = 1 then moving := true\n end\n done;\n out := List.rev !out;\n printf \"%d\\n\" (List.length !out);\n List.iter (fun (v, n) ->\n let y0, x0 = decode (nth (n - 1)) in\n let y1, x1 = decode v in\n printf \"%d %d %d %d\\n\" y0 x0 y1 x1\n ) !out;\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nThere is a grid of square cells with H horizontal rows and W vertical columns. The cell at the i-th row and the j-th column will be denoted as Cell (i, j).\n\nIn Cell (i, j), a_{ij} coins are placed.\n\nYou can perform the following operation any number of times:\n\nOperation: Choose a cell that was not chosen before and contains one or more coins, then move one of those coins to a vertically or horizontally adjacent cell.\n\nMaximize the number of cells containing an even number of coins.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq H, W \\leq 500\n\n0 \\leq a_{ij} \\leq 9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\na_{11} a_{12} ... a_{1W}\na_{21} a_{22} ... a_{2W}\n:\na_{H1} a_{H2} ... a_{HW}\n\nOutput\n\nPrint a sequence of operations that maximizes the number of cells containing an even number of coins, in the following format:\n\nN\ny_1 x_1 y_1' x_1'\ny_2 x_2 y_2' x_2'\n:\ny_N x_N y_N' x_N'\n\nThat is, in the first line, print an integer N between 0 and H \\times W (inclusive), representing the number of operations.\n\nIn the (i+1)-th line (1 \\leq i \\leq N), print four integers y_i, x_i, y_i' and x_i' (1 \\leq y_i, y_i' \\leq H and 1 \\leq x_i, x_i' \\leq W), representing the i-th operation. These four integers represents the operation of moving one of the coins placed in Cell (y_i, x_i) to a vertically or horizontally adjacent cell, (y_i', x_i').\n\nNote that if the specified operation violates the specification in the problem statement or the output format is invalid, it will result in Wrong Answer.\n\nSample Input 1\n\n2 3\n1 2 3\n0 1 1\n\nSample Output 1\n\n3\n2 2 2 3\n1 1 1 2\n1 3 1 2\n\nEvery cell contains an even number of coins after the following sequence of operations:\n\nMove the coin in Cell (2, 2) to Cell (2, 3).\n\nMove the coin in Cell (1, 1) to Cell (1, 2).\n\nMove one of the coins in Cell (1, 3) to Cell (1, 2).\n\nSample Input 2\n\n3 2\n1 0\n2 1\n1 0\n\nSample Output 2\n\n3\n1 1 1 2\n1 2 2 2\n3 1 3 2\n\nSample Input 3\n\n1 5\n9 9 9 9 9\n\nSample Output 3\n\n2\n1 1 1 2\n1 3 1 4", "sample_input": "2 3\n1 2 3\n0 1 1\n"}, "reference_outputs": ["3\n2 2 2 3\n1 1 1 2\n1 3 1 2\n"], "source_document_id": "p03263", "source_text": "Score : 400 points\n\nProblem Statement\n\nThere is a grid of square cells with H horizontal rows and W vertical columns. The cell at the i-th row and the j-th column will be denoted as Cell (i, j).\n\nIn Cell (i, j), a_{ij} coins are placed.\n\nYou can perform the following operation any number of times:\n\nOperation: Choose a cell that was not chosen before and contains one or more coins, then move one of those coins to a vertically or horizontally adjacent cell.\n\nMaximize the number of cells containing an even number of coins.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq H, W \\leq 500\n\n0 \\leq a_{ij} \\leq 9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\na_{11} a_{12} ... a_{1W}\na_{21} a_{22} ... a_{2W}\n:\na_{H1} a_{H2} ... a_{HW}\n\nOutput\n\nPrint a sequence of operations that maximizes the number of cells containing an even number of coins, in the following format:\n\nN\ny_1 x_1 y_1' x_1'\ny_2 x_2 y_2' x_2'\n:\ny_N x_N y_N' x_N'\n\nThat is, in the first line, print an integer N between 0 and H \\times W (inclusive), representing the number of operations.\n\nIn the (i+1)-th line (1 \\leq i \\leq N), print four integers y_i, x_i, y_i' and x_i' (1 \\leq y_i, y_i' \\leq H and 1 \\leq x_i, x_i' \\leq W), representing the i-th operation. These four integers represents the operation of moving one of the coins placed in Cell (y_i, x_i) to a vertically or horizontally adjacent cell, (y_i', x_i').\n\nNote that if the specified operation violates the specification in the problem statement or the output format is invalid, it will result in Wrong Answer.\n\nSample Input 1\n\n2 3\n1 2 3\n0 1 1\n\nSample Output 1\n\n3\n2 2 2 3\n1 1 1 2\n1 3 1 2\n\nEvery cell contains an even number of coins after the following sequence of operations:\n\nMove the coin in Cell (2, 2) to Cell (2, 3).\n\nMove the coin in Cell (1, 1) to Cell (1, 2).\n\nMove one of the coins in Cell (1, 3) to Cell (1, 2).\n\nSample Input 2\n\n3 2\n1 0\n2 1\n1 0\n\nSample Output 2\n\n3\n1 1 1 2\n1 2 2 2\n3 1 3 2\n\nSample Input 3\n\n1 5\n9 9 9 9 9\n\nSample Output 3\n\n2\n1 1 1 2\n1 3 1 4", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 823, "cpu_time_ms": 177, "memory_kb": 15616}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s079582430", "group_id": "codeNet:p03264", "input_text": "let () =\n Scanf.scanf \"%d\\n\"\n (fun k ->\n if k mod 2 = 0 then (k / 2) * (k / 2)\n else (k / 2) * (k / 2 + 1))\n |> print_int", "language": "OCaml", "metadata": {"date": 1555883111, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03264.html", "problem_id": "p03264", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03264/input.txt", "sample_output_relpath": "derived/input_output/data/p03264/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03264/OCaml/s079582430.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s079582430", "user_id": "u307426615"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "let () =\n Scanf.scanf \"%d\\n\"\n (fun k ->\n if k mod 2 = 0 then (k / 2) * (k / 2)\n else (k / 2) * (k / 2 + 1))\n |> print_int", "problem_context": "Score : 100 points\n\nProblem Statement\n\nFind the number of ways to choose a pair of an even number and an odd number from the positive integers between 1 and K (inclusive). The order does not matter.\n\nConstraints\n\n2\\leq K\\leq 100\n\nK is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK\n\nOutput\n\nPrint the number of ways to choose a pair of an even number and an odd number from the positive integers between 1 and K (inclusive).\n\nSample Input 1\n\n3\n\nSample Output 1\n\n2\n\nTwo pairs can be chosen: (2,1) and (2,3).\n\nSample Input 2\n\n6\n\nSample Output 2\n\n9\n\nSample Input 3\n\n11\n\nSample Output 3\n\n30\n\nSample Input 4\n\n50\n\nSample Output 4\n\n625", "sample_input": "3\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03264", "source_text": "Score : 100 points\n\nProblem Statement\n\nFind the number of ways to choose a pair of an even number and an odd number from the positive integers between 1 and K (inclusive). The order does not matter.\n\nConstraints\n\n2\\leq K\\leq 100\n\nK is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK\n\nOutput\n\nPrint the number of ways to choose a pair of an even number and an odd number from the positive integers between 1 and K (inclusive).\n\nSample Input 1\n\n3\n\nSample Output 1\n\n2\n\nTwo pairs can be chosen: (2,1) and (2,3).\n\nSample Input 2\n\n6\n\nSample Output 2\n\n9\n\nSample Input 3\n\n11\n\nSample Output 3\n\n30\n\nSample Input 4\n\n50\n\nSample Output 4\n\n625", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s048459633", "group_id": "codeNet:p03265", "input_text": "let x1, y1, x2, y2 = Scanf.scanf \" %d %d %d %d\" @@ fun a b c d -> a, b, c, d\nlet dx, dy = x2 - x1, y2 - y1\nlet x3, y3 = x2 - dy, y2 + dx\nlet _ = Printf.printf \"%d %d %d %d\\n\" x3 y3 (x3 - dx) (y3 - dy)", "language": "OCaml", "metadata": {"date": 1564218011, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03265.html", "problem_id": "p03265", "resource_group": "low_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/OCaml/s048459633.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s048459633", "user_id": "u732304692"}, "prompt_components": {"gold_output": "-1 1 -1 0\n", "input_to_evaluate": "let x1, y1, x2, y2 = Scanf.scanf \" %d %d %d %d\" @@ fun a b c d -> a, b, c, d\nlet dx, dy = x2 - x1, y2 - y1\nlet x3, y3 = x2 - dy, y2 + dx\nlet _ = Printf.printf \"%d %d %d %d\\n\" x3 y3 (x3 - dx) (y3 - dy)", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s039149330", "group_id": "codeNet:p03266", "input_text": "let c x = x*x*x\nlet () = Printf.printf \"%d\\n\" @@\n Scanf.scanf \"%d %d\" @@ fun n k ->\n if k mod 2 = 1 then c (n/k)\n else c (n/k) + c ((n+k/2)/k)", "language": "OCaml", "metadata": {"date": 1535858914, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03266.html", "problem_id": "p03266", "resource_group": "low_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/OCaml/s039149330.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s039149330", "user_id": "u798181098"}, "prompt_components": {"gold_output": "9\n", "input_to_evaluate": "let c x = x*x*x\nlet () = Printf.printf \"%d\\n\" @@\n Scanf.scanf \"%d %d\" @@ fun n k ->\n if k mod 2 = 1 then c (n/k)\n else c (n/k) + c ((n+k/2)/k)", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s931015300", "group_id": "codeNet:p03268", "input_text": "let n, k = Scanf.sscanf (read_line ()) \"%d %d\" @@ fun n k -> (n, k)\n\nlet rec pow x n = if n = 1 then x else x * pow x (n - 1)\n\nlet () =\n let a = n / k in\n let b = (n - k / 2) / k + 1 in\n Printf.printf \"%d\\n\" @@ pow a 3 + if k mod 2 = 0 then pow b 3 else 0", "language": "OCaml", "metadata": {"date": 1593660222, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p03268.html", "problem_id": "p03268", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03268/input.txt", "sample_output_relpath": "derived/input_output/data/p03268/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03268/OCaml/s931015300.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s931015300", "user_id": "u811309788"}, "prompt_components": {"gold_output": "9\n", "input_to_evaluate": "let n, k = Scanf.sscanf (read_line ()) \"%d %d\" @@ fun n k -> (n, k)\n\nlet rec pow x n = if n = 1 then x else x * pow x (n - 1)\n\nlet () =\n let a = n / k in\n let b = (n - k / 2) / k + 1 in\n Printf.printf \"%d\\n\" @@ pow a 3 + if k mod 2 = 0 then pow b 3 else 0", "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": "p03268", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 4, "memory_kb": 3808}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s755511232", "group_id": "codeNet:p03269", "input_text": "let popcnt x =\n let x = (x land 0x5555555555555555) + ((x lsr 1) land 0x5555555555555555) in\n let x = (x land 0x3333333333333333) + ((x lsr 2) land 0x3333333333333333) in\n let x = (x land 0x0f0f0f0f0f0f0f0f) + ((x lsr 4) land 0x0f0f0f0f0f0f0f0f) in\n let x = (x land 0x00ff00ff00ff00ff) + ((x lsr 8) land 0x00ff00ff00ff00ff) in\n let x = (x land 0x0000ffff0000ffff) + ((x lsr 16) land 0x0000ffff0000ffff) in\n (x land 0x00000000ffffffff) + ((x lsr 32) land 0x00000000ffffffff)\n\nlet log2 x =\n let x = x lor (x lsr 1) in\n let x = x lor (x lsr 2) in\n let x = x lor (x lsr 4) in\n let x = x lor (x lsr 8) in\n let x = x lor (x lsr 16) in\n let x = x lor (x lsr 32) in\n popcnt x\n\nlet () = Scanf.scanf \"%d\\n\" @@ fun l ->\n let n = log2 l in\n let es = List.concat @@ List.concat @@\n [ Array.to_list (Array.init (n - 1) @@ fun i -> [(i + 1, i + 2, 0); (i + 1, i + 2, 1 lsl i)]);\n Array.to_list (Array.init n (fun i ->\n if l land (1 lsl i) = 0 then []\n else [(i + 1, n + 1, l lxor (l land ((1 lsl (i + 1)) - 1)))])) ] in\n Printf.printf \"%d %d\\n\" (n + 1) (List.length es);\n List.iter (fun (u, v, w) -> Printf.printf \"%d %d %d\\n\" u v w) es\n\n", "language": "OCaml", "metadata": {"date": 1535862015, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03269.html", "problem_id": "p03269", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03269/input.txt", "sample_output_relpath": "derived/input_output/data/p03269/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03269/OCaml/s755511232.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s755511232", "user_id": "u504158101"}, "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": "let popcnt x =\n let x = (x land 0x5555555555555555) + ((x lsr 1) land 0x5555555555555555) in\n let x = (x land 0x3333333333333333) + ((x lsr 2) land 0x3333333333333333) in\n let x = (x land 0x0f0f0f0f0f0f0f0f) + ((x lsr 4) land 0x0f0f0f0f0f0f0f0f) in\n let x = (x land 0x00ff00ff00ff00ff) + ((x lsr 8) land 0x00ff00ff00ff00ff) in\n let x = (x land 0x0000ffff0000ffff) + ((x lsr 16) land 0x0000ffff0000ffff) in\n (x land 0x00000000ffffffff) + ((x lsr 32) land 0x00000000ffffffff)\n\nlet log2 x =\n let x = x lor (x lsr 1) in\n let x = x lor (x lsr 2) in\n let x = x lor (x lsr 4) in\n let x = x lor (x lsr 8) in\n let x = x lor (x lsr 16) in\n let x = x lor (x lsr 32) in\n popcnt x\n\nlet () = Scanf.scanf \"%d\\n\" @@ fun l ->\n let n = log2 l in\n let es = List.concat @@ List.concat @@\n [ Array.to_list (Array.init (n - 1) @@ fun i -> [(i + 1, i + 2, 0); (i + 1, i + 2, 1 lsl i)]);\n Array.to_list (Array.init n (fun i ->\n if l land (1 lsl i) = 0 then []\n else [(i + 1, n + 1, l lxor (l land ((1 lsl (i + 1)) - 1)))])) ] in\n Printf.printf \"%d %d\\n\" (n + 1) (List.length es);\n List.iter (fun (u, v, w) -> Printf.printf \"%d %d %d\\n\" u v w) es\n\n", "problem_context": "Score : 700 points\n\nProblem Statement\n\nYou are given an integer L. Construct a directed graph that satisfies the conditions below. The graph may contain multiple edges between the same pair of vertices. It can be proved that such a graph always exists.\n\nThe number of vertices, N, is at most 20. The vertices are given ID numbers from 1 to N.\n\nThe number of edges, M, is at most 60. Each edge has an integer length between 0 and 10^6 (inclusive).\n\nEvery edge is directed from the vertex with the smaller ID to the vertex with the larger ID. That is, 1,2,...,N is one possible topological order of the vertices.\n\nThere are exactly L different paths from Vertex 1 to Vertex N. The lengths of these paths are all different, and they are integers between 0 and L-1.\n\nHere, the length of a path is the sum of the lengths of the edges contained in that path, and two paths are considered different when the sets of the edges contained in those paths are different.\n\nConstraints\n\n2 \\leq L \\leq 10^6\n\nL is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nL\n\nOutput\n\nIn the first line, print N and M, the number of the vertices and edges in your graph.\nIn the i-th of the following M lines, print three integers u_i,v_i and w_i, representing the starting vertex, the ending vertex and the length of the i-th edge.\nIf there are multiple solutions, any of them will be accepted.\n\nSample Input 1\n\n4\n\nSample Output 1\n\n8 10\n1 2 0\n2 3 0\n3 4 0\n1 5 0\n2 6 0\n3 7 0\n4 8 0\n5 6 1\n6 7 1\n7 8 1\n\nIn the graph represented by the sample output, there are four paths from Vertex 1 to N=8:\n\n1 → 2 → 3 → 4 → 8 with length 0\n\n1 → 2 → 3 → 7 → 8 with length 1\n\n1 → 2 → 6 → 7 → 8 with length 2\n\n1 → 5 → 6 → 7 → 8 with length 3\n\nThere are other possible solutions.\n\nSample Input 2\n\n5\n\nSample Output 2\n\n5 7\n1 2 0\n2 3 1\n3 4 0\n4 5 0\n2 4 0\n1 3 3\n3 5 1", "sample_input": "4\n"}, "reference_outputs": ["8 10\n1 2 0\n2 3 0\n3 4 0\n1 5 0\n2 6 0\n3 7 0\n4 8 0\n5 6 1\n6 7 1\n7 8 1\n"], "source_document_id": "p03269", "source_text": "Score : 700 points\n\nProblem Statement\n\nYou are given an integer L. Construct a directed graph that satisfies the conditions below. The graph may contain multiple edges between the same pair of vertices. It can be proved that such a graph always exists.\n\nThe number of vertices, N, is at most 20. The vertices are given ID numbers from 1 to N.\n\nThe number of edges, M, is at most 60. Each edge has an integer length between 0 and 10^6 (inclusive).\n\nEvery edge is directed from the vertex with the smaller ID to the vertex with the larger ID. That is, 1,2,...,N is one possible topological order of the vertices.\n\nThere are exactly L different paths from Vertex 1 to Vertex N. The lengths of these paths are all different, and they are integers between 0 and L-1.\n\nHere, the length of a path is the sum of the lengths of the edges contained in that path, and two paths are considered different when the sets of the edges contained in those paths are different.\n\nConstraints\n\n2 \\leq L \\leq 10^6\n\nL is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nL\n\nOutput\n\nIn the first line, print N and M, the number of the vertices and edges in your graph.\nIn the i-th of the following M lines, print three integers u_i,v_i and w_i, representing the starting vertex, the ending vertex and the length of the i-th edge.\nIf there are multiple solutions, any of them will be accepted.\n\nSample Input 1\n\n4\n\nSample Output 1\n\n8 10\n1 2 0\n2 3 0\n3 4 0\n1 5 0\n2 6 0\n3 7 0\n4 8 0\n5 6 1\n6 7 1\n7 8 1\n\nIn the graph represented by the sample output, there are four paths from Vertex 1 to N=8:\n\n1 → 2 → 3 → 4 → 8 with length 0\n\n1 → 2 → 3 → 7 → 8 with length 1\n\n1 → 2 → 6 → 7 → 8 with length 2\n\n1 → 5 → 6 → 7 → 8 with length 3\n\nThere are other possible solutions.\n\nSample Input 2\n\n5\n\nSample Output 2\n\n5 7\n1 2 0\n2 3 1\n3 4 0\n4 5 0\n2 4 0\n1 3 3\n3 5 1", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1162, "cpu_time_ms": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s273095875", "group_id": "codeNet:p03272", "input_text": "let () =\n let (n, i) = Scanf.scanf \"%d %d\" (fun n i -> (n, i)) in\n print_string @@ string_of_int @@ n - i + 1\n", "language": "OCaml", "metadata": {"date": 1559248691, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03272.html", "problem_id": "p03272", "resource_group": "low_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/OCaml/s273095875.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s273095875", "user_id": "u262569757"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "let () =\n let (n, i) = Scanf.scanf \"%d %d\" (fun n i -> (n, i)) in\n print_string @@ string_of_int @@ n - i + 1\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nThere is an N-car train.\n\nYou are given an integer i. Find the value of j such that the following statement is true: \"the i-th car from the front of the train is the j-th car from the back.\"\n\nConstraints\n\n1 \\leq N \\leq 100\n\n1 \\leq i \\leq N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN i\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n4 2\n\nSample Output 1\n\n3\n\nThe second car from the front of a 4-car train is the third car from the back.\n\nSample Input 2\n\n1 1\n\nSample Output 2\n\n1\n\nSample Input 3\n\n15 11\n\nSample Output 3\n\n5", "sample_input": "4 2\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03272", "source_text": "Score : 100 points\n\nProblem Statement\n\nThere is an N-car train.\n\nYou are given an integer i. Find the value of j such that the following statement is true: \"the i-th car from the front of the train is the j-th car from the back.\"\n\nConstraints\n\n1 \\leq N \\leq 100\n\n1 \\leq i \\leq N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN i\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n4 2\n\nSample Output 1\n\n3\n\nThe second car from the front of a 4-car train is the third car from the back.\n\nSample Input 2\n\n1 1\n\nSample Output 2\n\n1\n\nSample Input 3\n\n15 11\n\nSample Output 3\n\n5", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s224504162", "group_id": "codeNet:p03276", "input_text": "let () = Scanf.scanf \"%d %d\\n\" @@ fun n k ->\n let xs = Array.init n @@ fun _ -> Scanf.scanf \"%d \" @@ fun x -> x in\n Printf.printf \"%d\\n\" @@ Array.fold_left min max_int @@ \n Array.init (n - k + 1) @@ fun i ->\n if (xs.(i) <= 0) = (xs.(i + k - 1) <= 0) then\n max (abs xs.(i)) (abs xs.(i + k - 1))\n else\n min (2 * abs xs.(i) + abs xs.(i + k - 1)) (abs xs.(i) + 2 * abs xs.(i + k - 1))\n\n", "language": "OCaml", "metadata": {"date": 1535251227, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03276.html", "problem_id": "p03276", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03276/input.txt", "sample_output_relpath": "derived/input_output/data/p03276/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03276/OCaml/s224504162.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s224504162", "user_id": "u504158101"}, "prompt_components": {"gold_output": "40\n", "input_to_evaluate": "let () = Scanf.scanf \"%d %d\\n\" @@ fun n k ->\n let xs = Array.init n @@ fun _ -> Scanf.scanf \"%d \" @@ fun x -> x in\n Printf.printf \"%d\\n\" @@ Array.fold_left min max_int @@ \n Array.init (n - k + 1) @@ fun i ->\n if (xs.(i) <= 0) = (xs.(i + k - 1) <= 0) then\n max (abs xs.(i)) (abs xs.(i + k - 1))\n else\n min (2 * abs xs.(i) + abs xs.(i + k - 1)) (abs xs.(i) + 2 * abs xs.(i + k - 1))\n\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere are N candles placed on a number line.\nThe i-th candle from the left is placed on coordinate x_i.\nHere, x_1 < x_2 < ... < x_N holds.\n\nInitially, no candles are burning.\nSnuke decides to light K of the N candles.\n\nNow, he is at coordinate 0.\nHe can move left and right along the line with speed 1.\nHe can also light a candle when he is at the same position as the candle, in negligible time.\n\nFind the minimum time required to light K candles.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq K \\leq N\n\nx_i is an integer.\n\n|x_i| \\leq 10^8\n\nx_1 < x_2 < ... < x_N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nx_1 x_2 ... x_N\n\nOutput\n\nPrint the minimum time required to light K candles.\n\nSample Input 1\n\n5 3\n-30 -10 10 20 50\n\nSample Output 1\n\n40\n\nHe should move and light candles as follows:\n\nMove from coordinate 0 to -10.\n\nLight the second candle from the left.\n\nMove from coordinate -10 to 10.\n\nLight the third candle from the left.\n\nMove from coordinate 10 to 20.\n\nLight the fourth candle from the left.\n\nSample Input 2\n\n3 2\n10 20 30\n\nSample Output 2\n\n20\n\nSample Input 3\n\n1 1\n0\n\nSample Output 3\n\n0\n\nThere may be a candle placed at coordinate 0.\n\nSample Input 4\n\n8 5\n-9 -7 -4 -3 1 2 3 4\n\nSample Output 4\n\n10", "sample_input": "5 3\n-30 -10 10 20 50\n"}, "reference_outputs": ["40\n"], "source_document_id": "p03276", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere are N candles placed on a number line.\nThe i-th candle from the left is placed on coordinate x_i.\nHere, x_1 < x_2 < ... < x_N holds.\n\nInitially, no candles are burning.\nSnuke decides to light K of the N candles.\n\nNow, he is at coordinate 0.\nHe can move left and right along the line with speed 1.\nHe can also light a candle when he is at the same position as the candle, in negligible time.\n\nFind the minimum time required to light K candles.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq K \\leq N\n\nx_i is an integer.\n\n|x_i| \\leq 10^8\n\nx_1 < x_2 < ... < x_N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nx_1 x_2 ... x_N\n\nOutput\n\nPrint the minimum time required to light K candles.\n\nSample Input 1\n\n5 3\n-30 -10 10 20 50\n\nSample Output 1\n\n40\n\nHe should move and light candles as follows:\n\nMove from coordinate 0 to -10.\n\nLight the second candle from the left.\n\nMove from coordinate -10 to 10.\n\nLight the third candle from the left.\n\nMove from coordinate 10 to 20.\n\nLight the fourth candle from the left.\n\nSample Input 2\n\n3 2\n10 20 30\n\nSample Output 2\n\n20\n\nSample Input 3\n\n1 1\n0\n\nSample Output 3\n\n0\n\nThere may be a candle placed at coordinate 0.\n\nSample Input 4\n\n8 5\n-9 -7 -4 -3 1 2 3 4\n\nSample Output 4\n\n10", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 401, "cpu_time_ms": 33, "memory_kb": 5632}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s582745618", "group_id": "codeNet:p03280", "input_text": "let () =\n Scanf.scanf \"%d %d\" @@ fun a b ->\n print_endline (string_of_int ((a - 1) * (b - 1)))", "language": "OCaml", "metadata": {"date": 1537651485, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03280.html", "problem_id": "p03280", "resource_group": "low_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/OCaml/s582745618.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s582745618", "user_id": "u900768135"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "let () =\n Scanf.scanf \"%d %d\" @@ fun a b ->\n print_endline (string_of_int ((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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s736603544", "group_id": "codeNet:p03281", "input_text": "let n, ans = read_int (), ref 0\nlet _ = for i = 1 to n do if i mod 2 = 1 then let c = ref 0 in for j = 1 to i do if i mod j = 0 then incr c done; if !c = 8 then incr ans done; Printf.printf \"%d\\n\" !ans", "language": "OCaml", "metadata": {"date": 1572363724, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03281.html", "problem_id": "p03281", "resource_group": "low_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/OCaml/s736603544.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s736603544", "user_id": "u732304692"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "let n, ans = read_int (), ref 0\nlet _ = for i = 1 to n do if i mod 2 = 1 then let c = ref 0 in for j = 1 to i do if i mod j = 0 then incr c done; if !c = 8 then incr ans done; Printf.printf \"%d\\n\" !ans", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s827459634", "group_id": "codeNet:p03282", "input_text": "open Batteries\nlet explode s = List.init (String.length s) (String.get s)\nlet s = explode (read_line ())\nlet k = read_int ()\nlet rec ans lst = \n match lst with\n [] -> print_endline \"1\"\n | first :: rest -> if first = '1' then ans rest else print_char first\n\nlet _ = ans s", "language": "OCaml", "metadata": {"date": 1583856187, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03282.html", "problem_id": "p03282", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03282/input.txt", "sample_output_relpath": "derived/input_output/data/p03282/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03282/OCaml/s827459634.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s827459634", "user_id": "u511870776"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "open Batteries\nlet explode s = List.init (String.length s) (String.get s)\nlet s = explode (read_line ())\nlet k = read_int ()\nlet rec ans lst = \n match lst with\n [] -> print_endline \"1\"\n | first :: rest -> if first = '1' then ans rest else print_char first\n\nlet _ = ans s", "problem_context": "Score: 300 points\n\nProblem Statement\n\nMr. Infinity has a string S consisting of digits from 1 to 9. Each time the date changes, this string changes as follows:\n\nEach occurrence of 2 in S is replaced with 22. Similarly, each 3 becomes 333, 4 becomes 4444, 5 becomes 55555, 6 becomes 666666, 7 becomes 7777777, 8 becomes 88888888 and 9 becomes 999999999. 1 remains as 1.\n\nFor example, if S is 1324, it becomes 1333224444 the next day, and it becomes 133333333322224444444444444444 the day after next.\nYou are interested in what the string looks like after 5 \\times 10^{15} days. What is the K-th character from the left in the string after 5 \\times 10^{15} days?\n\nConstraints\n\nS is a string of length between 1 and 100 (inclusive).\n\nK is an integer between 1 and 10^{18} (inclusive).\n\nThe length of the string after 5 \\times 10^{15} days is at least K.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\nK\n\nOutput\n\nPrint the K-th character from the left in Mr. Infinity's string after 5 \\times 10^{15} days.\n\nSample Input 1\n\n1214\n4\n\nSample Output 1\n\n2\n\nThe string S changes as follows:\n\nNow: 1214\n\nAfter one day: 12214444\n\nAfter two days: 1222214444444444444444\n\nAfter three days: 12222222214444444444444444444444444444444444444444444444444444444444444444\n\nThe first five characters in the string after 5 \\times 10^{15} days is 12222. As K=4, we should print the fourth character, 2.\n\nSample Input 2\n\n3\n157\n\nSample Output 2\n\n3\n\nThe initial string is 3. The string after 5 \\times 10^{15} days consists only of 3.\n\nSample Input 3\n\n299792458\n9460730472580800\n\nSample Output 3\n\n2", "sample_input": "1214\n4\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03282", "source_text": "Score: 300 points\n\nProblem Statement\n\nMr. Infinity has a string S consisting of digits from 1 to 9. Each time the date changes, this string changes as follows:\n\nEach occurrence of 2 in S is replaced with 22. Similarly, each 3 becomes 333, 4 becomes 4444, 5 becomes 55555, 6 becomes 666666, 7 becomes 7777777, 8 becomes 88888888 and 9 becomes 999999999. 1 remains as 1.\n\nFor example, if S is 1324, it becomes 1333224444 the next day, and it becomes 133333333322224444444444444444 the day after next.\nYou are interested in what the string looks like after 5 \\times 10^{15} days. What is the K-th character from the left in the string after 5 \\times 10^{15} days?\n\nConstraints\n\nS is a string of length between 1 and 100 (inclusive).\n\nK is an integer between 1 and 10^{18} (inclusive).\n\nThe length of the string after 5 \\times 10^{15} days is at least K.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\nK\n\nOutput\n\nPrint the K-th character from the left in Mr. Infinity's string after 5 \\times 10^{15} days.\n\nSample Input 1\n\n1214\n4\n\nSample Output 1\n\n2\n\nThe string S changes as follows:\n\nNow: 1214\n\nAfter one day: 12214444\n\nAfter two days: 1222214444444444444444\n\nAfter three days: 12222222214444444444444444444444444444444444444444444444444444444444444444\n\nThe first five characters in the string after 5 \\times 10^{15} days is 12222. As K=4, we should print the fourth character, 2.\n\nSample Input 2\n\n3\n157\n\nSample Output 2\n\n3\n\nThe initial string is 3. The string after 5 \\times 10^{15} days consists only of 3.\n\nSample Input 3\n\n299792458\n9460730472580800\n\nSample Output 3\n\n2", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 274, "cpu_time_ms": 2, "memory_kb": 1152}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s083011804", "group_id": "codeNet:p03284", "input_text": "Scanf.scanf \"%d %d\" (fun n k ->\n Printf.printf \"%d\\n\" @@ if n mod k = 0 then 0 else 1\n)", "language": "OCaml", "metadata": {"date": 1586828962, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03284.html", "problem_id": "p03284", "resource_group": "low_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/OCaml/s083011804.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s083011804", "user_id": "u342443598"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "Scanf.scanf \"%d %d\" (fun n k ->\n Printf.printf \"%d\\n\" @@ if n mod k = 0 then 0 else 1\n)", "problem_context": "Score : 100 points\n\nProblem Statement\n\nTakahashi has decided to distribute N AtCoder Crackers to K users of as evenly as possible.\nWhen all the crackers are distributed, find the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user.\n\nConstraints\n\n1 \\leq N,K \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\n\nOutput\n\nPrint the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user.\n\nSample Input 1\n\n7 3\n\nSample Output 1\n\n1\n\nWhen the users receive two, two and three crackers, respectively, the (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user, is 1.\n\nSample Input 2\n\n100 10\n\nSample Output 2\n\n0\n\nThe crackers can be distributed evenly.\n\nSample Input 3\n\n1 1\n\nSample Output 3\n\n0", "sample_input": "7 3\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03284", "source_text": "Score : 100 points\n\nProblem Statement\n\nTakahashi has decided to distribute N AtCoder Crackers to K users of as evenly as possible.\nWhen all the crackers are distributed, find the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user.\n\nConstraints\n\n1 \\leq N,K \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\n\nOutput\n\nPrint the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user.\n\nSample Input 1\n\n7 3\n\nSample Output 1\n\n1\n\nWhen the users receive two, two and three crackers, respectively, the (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user, is 1.\n\nSample Input 2\n\n100 10\n\nSample Output 2\n\n0\n\nThe crackers can be distributed evenly.\n\nSample Input 3\n\n1 1\n\nSample Output 3\n\n0", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s051897365", "group_id": "codeNet:p03284", "input_text": "Scanf.scanf \"%d %d\" @@ fun n k ->\n Printf.printf \"%d\\n\" @@ if n mod k = 0 then 0 else 1", "language": "OCaml", "metadata": {"date": 1558283642, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03284.html", "problem_id": "p03284", "resource_group": "low_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/OCaml/s051897365.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s051897365", "user_id": "u732304692"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "Scanf.scanf \"%d %d\" @@ fun n k ->\n Printf.printf \"%d\\n\" @@ if n mod k = 0 then 0 else 1", "problem_context": "Score : 100 points\n\nProblem Statement\n\nTakahashi has decided to distribute N AtCoder Crackers to K users of as evenly as possible.\nWhen all the crackers are distributed, find the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user.\n\nConstraints\n\n1 \\leq N,K \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\n\nOutput\n\nPrint the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user.\n\nSample Input 1\n\n7 3\n\nSample Output 1\n\n1\n\nWhen the users receive two, two and three crackers, respectively, the (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user, is 1.\n\nSample Input 2\n\n100 10\n\nSample Output 2\n\n0\n\nThe crackers can be distributed evenly.\n\nSample Input 3\n\n1 1\n\nSample Output 3\n\n0", "sample_input": "7 3\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03284", "source_text": "Score : 100 points\n\nProblem Statement\n\nTakahashi has decided to distribute N AtCoder Crackers to K users of as evenly as possible.\nWhen all the crackers are distributed, find the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user.\n\nConstraints\n\n1 \\leq N,K \\leq 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\n\nOutput\n\nPrint the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user.\n\nSample Input 1\n\n7 3\n\nSample Output 1\n\n1\n\nWhen the users receive two, two and three crackers, respectively, the (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user, is 1.\n\nSample Input 2\n\n100 10\n\nSample Output 2\n\n0\n\nThe crackers can be distributed evenly.\n\nSample Input 3\n\n1 1\n\nSample Output 3\n\n0", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s514845948", "group_id": "codeNet:p03284", "input_text": "let _ =\n\tlet n, k = Scanf.scanf \"%d %d\\n\" (fun n k -> n, k) in\n (if n mod k = 0 then 0 else (n / k) - (n mod k))\n |> print_int", "language": "OCaml", "metadata": {"date": 1555223461, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03284.html", "problem_id": "p03284", "resource_group": "low_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/OCaml/s514845948.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s514845948", "user_id": "u387591304"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "let _ =\n\tlet n, k = Scanf.scanf \"%d %d\\n\" (fun n k -> n, k) in\n (if n mod k = 0 then 0 else (n / k) - (n mod k))\n |> print_int", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s294251833", "group_id": "codeNet:p03284", "input_text": "let () =\n Scanf.scanf \"%d %d\" (fun n k ->\n match (n mod k = 0) with\n | true -> print_endline \"0\"\n | false -> print_endline \"1\")", "language": "OCaml", "metadata": {"date": 1537651387, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03284.html", "problem_id": "p03284", "resource_group": "low_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/OCaml/s294251833.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s294251833", "user_id": "u900768135"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "let () =\n Scanf.scanf \"%d %d\" (fun n k ->\n match (n mod k = 0) with\n | true -> print_endline \"0\"\n | false -> print_endline \"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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s487391398", "group_id": "codeNet:p03285", "input_text": "let n,p=read_int(),print_string in Array.init(400)(fun i->if(i/15)*4=n-7*(i mod 15)then(p\"Yes\";exit 0));p\"No\"", "language": "OCaml", "metadata": {"date": 1540277564, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03285.html", "problem_id": "p03285", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03285/input.txt", "sample_output_relpath": "derived/input_output/data/p03285/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03285/OCaml/s487391398.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s487391398", "user_id": "u481480055"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "let n,p=read_int(),print_string in Array.init(400)(fun i->if(i/15)*4=n-7*(i mod 15)then(p\"Yes\";exit 0));p\"No\"", "problem_context": "Score : 200 points\n\nProblem Statement\n\nLa Confiserie d'ABC sells cakes at 4 dollars each and doughnuts at 7 dollars each.\nDetermine if there is a way to buy some of them for exactly N dollars. You can buy two or more doughnuts and two or more cakes, and you can also choose to buy zero doughnuts or zero cakes.\n\nConstraints\n\nN is an integer between 1 and 100, inclusive.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nIf there is a way to buy some cakes and some doughnuts for exactly N dollars, print Yes; otherwise, print No.\n\nSample Input 1\n\n11\n\nSample Output 1\n\nYes\n\nIf you buy one cake and one doughnut, the total will be 4 + 7 = 11 dollars.\n\nSample Input 2\n\n40\n\nSample Output 2\n\nYes\n\nIf you buy ten cakes, the total will be 4 \\times 10 = 40 dollars.\n\nSample Input 3\n\n3\n\nSample Output 3\n\nNo\n\nThe prices of cakes (4 dollars) and doughnuts (7 dollars) are both higher than 3 dollars, so there is no such way.", "sample_input": "11\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03285", "source_text": "Score : 200 points\n\nProblem Statement\n\nLa Confiserie d'ABC sells cakes at 4 dollars each and doughnuts at 7 dollars each.\nDetermine if there is a way to buy some of them for exactly N dollars. You can buy two or more doughnuts and two or more cakes, and you can also choose to buy zero doughnuts or zero cakes.\n\nConstraints\n\nN is an integer between 1 and 100, inclusive.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nIf there is a way to buy some cakes and some doughnuts for exactly N dollars, print Yes; otherwise, print No.\n\nSample Input 1\n\n11\n\nSample Output 1\n\nYes\n\nIf you buy one cake and one doughnut, the total will be 4 + 7 = 11 dollars.\n\nSample Input 2\n\n40\n\nSample Output 2\n\nYes\n\nIf you buy ten cakes, the total will be 4 \\times 10 = 40 dollars.\n\nSample Input 3\n\n3\n\nSample Output 3\n\nNo\n\nThe prices of cakes (4 dollars) and doughnuts (7 dollars) are both higher than 3 dollars, so there is no such way.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s469377215", "group_id": "codeNet:p03288", "input_text": "open Scanf\nopen Printf\n\nlet rate r =\n if r < 1200 then \"ABC\"\n else if r < 2800 then \"ARC\"\n else \"AGC\"\n\nlet () = scanf \"%d\" rate |> printf \"%s\\n\"", "language": "OCaml", "metadata": {"date": 1595873195, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p03288.html", "problem_id": "p03288", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03288/input.txt", "sample_output_relpath": "derived/input_output/data/p03288/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03288/OCaml/s469377215.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s469377215", "user_id": "u272377260"}, "prompt_components": {"gold_output": "ABC\n", "input_to_evaluate": "open Scanf\nopen Printf\n\nlet rate r =\n if r < 1200 then \"ABC\"\n else if r < 2800 then \"ARC\"\n else \"AGC\"\n\nlet () = scanf \"%d\" rate |> printf \"%s\\n\"", "problem_context": "Score : 100 points\n\nProblem Statement\n\nA programming competition site AtCode regularly holds programming contests.\n\nThe next contest on AtCode is called ABC, which is rated for contestants with ratings less than 1200.\n\nThe contest after the ABC is called ARC, which is rated for contestants with ratings less than 2800.\n\nThe contest after the ARC is called AGC, which is rated for all contestants.\n\nTakahashi's rating on AtCode is R. What is the next contest rated for him?\n\nConstraints\n\n0 ≤ R ≤ 4208\n\nR is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nR\n\nOutput\n\nPrint the name of the next contest rated for Takahashi (ABC, ARC or AGC).\n\nSample Input 1\n\n1199\n\nSample Output 1\n\nABC\n\n1199 is less than 1200, so ABC will be rated.\n\nSample Input 2\n\n1200\n\nSample Output 2\n\nARC\n\n1200 is not less than 1200 and ABC will be unrated, but it is less than 2800 and ARC will be rated.\n\nSample Input 3\n\n4208\n\nSample Output 3\n\nAGC", "sample_input": "1199\n"}, "reference_outputs": ["ABC\n"], "source_document_id": "p03288", "source_text": "Score : 100 points\n\nProblem Statement\n\nA programming competition site AtCode regularly holds programming contests.\n\nThe next contest on AtCode is called ABC, which is rated for contestants with ratings less than 1200.\n\nThe contest after the ABC is called ARC, which is rated for contestants with ratings less than 2800.\n\nThe contest after the ARC is called AGC, which is rated for all contestants.\n\nTakahashi's rating on AtCode is R. What is the next contest rated for him?\n\nConstraints\n\n0 ≤ R ≤ 4208\n\nR is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nR\n\nOutput\n\nPrint the name of the next contest rated for Takahashi (ABC, ARC or AGC).\n\nSample Input 1\n\n1199\n\nSample Output 1\n\nABC\n\n1199 is less than 1200, so ABC will be rated.\n\nSample Input 2\n\n1200\n\nSample Output 2\n\nARC\n\n1200 is not less than 1200 and ABC will be unrated, but it is less than 2800 and ARC will be rated.\n\nSample Input 3\n\n4208\n\nSample Output 3\n\nAGC", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 3692}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s531152001", "group_id": "codeNet:p03288", "input_text": "let r = read_int ()\nlet _ = print_endline @@ if r < 1200 then \"ABC\" else if r < 2800 then \"ARC\" else \"AGC\"", "language": "OCaml", "metadata": {"date": 1565011090, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03288.html", "problem_id": "p03288", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03288/input.txt", "sample_output_relpath": "derived/input_output/data/p03288/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03288/OCaml/s531152001.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s531152001", "user_id": "u732304692"}, "prompt_components": {"gold_output": "ABC\n", "input_to_evaluate": "let r = read_int ()\nlet _ = print_endline @@ if r < 1200 then \"ABC\" else if r < 2800 then \"ARC\" else \"AGC\"", "problem_context": "Score : 100 points\n\nProblem Statement\n\nA programming competition site AtCode regularly holds programming contests.\n\nThe next contest on AtCode is called ABC, which is rated for contestants with ratings less than 1200.\n\nThe contest after the ABC is called ARC, which is rated for contestants with ratings less than 2800.\n\nThe contest after the ARC is called AGC, which is rated for all contestants.\n\nTakahashi's rating on AtCode is R. What is the next contest rated for him?\n\nConstraints\n\n0 ≤ R ≤ 4208\n\nR is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nR\n\nOutput\n\nPrint the name of the next contest rated for Takahashi (ABC, ARC or AGC).\n\nSample Input 1\n\n1199\n\nSample Output 1\n\nABC\n\n1199 is less than 1200, so ABC will be rated.\n\nSample Input 2\n\n1200\n\nSample Output 2\n\nARC\n\n1200 is not less than 1200 and ABC will be unrated, but it is less than 2800 and ARC will be rated.\n\nSample Input 3\n\n4208\n\nSample Output 3\n\nAGC", "sample_input": "1199\n"}, "reference_outputs": ["ABC\n"], "source_document_id": "p03288", "source_text": "Score : 100 points\n\nProblem Statement\n\nA programming competition site AtCode regularly holds programming contests.\n\nThe next contest on AtCode is called ABC, which is rated for contestants with ratings less than 1200.\n\nThe contest after the ABC is called ARC, which is rated for contestants with ratings less than 2800.\n\nThe contest after the ARC is called AGC, which is rated for all contestants.\n\nTakahashi's rating on AtCode is R. What is the next contest rated for him?\n\nConstraints\n\n0 ≤ R ≤ 4208\n\nR is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nR\n\nOutput\n\nPrint the name of the next contest rated for Takahashi (ABC, ARC or AGC).\n\nSample Input 1\n\n1199\n\nSample Output 1\n\nABC\n\n1199 is less than 1200, so ABC will be rated.\n\nSample Input 2\n\n1200\n\nSample Output 2\n\nARC\n\n1200 is not less than 1200 and ABC will be unrated, but it is less than 2800 and ARC will be rated.\n\nSample Input 3\n\n4208\n\nSample Output 3\n\nAGC", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s669560994", "group_id": "codeNet:p03289", "input_text": "open Batteries\nopen Printf\nlet () =\n let s = Scanf.scanf \"%s \" (fun a -> a) in\n let s1 = String.slice ~last:1 s in\n let s2 = String.slice ~first:2 ~last:(String.length s - 1) s in\n\n Printf.printf \"%s\\n\" @@\n if s1 = \"A\" && (\n let l = List.of_enum (\n String.find_all s2 \"C\"\n )\n in\n List.length l = 1\n )\n then \"AC\" else \"WA\"\n", "language": "OCaml", "metadata": {"date": 1533946985, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03289.html", "problem_id": "p03289", "resource_group": "low_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/OCaml/s669560994.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s669560994", "user_id": "u139013163"}, "prompt_components": {"gold_output": "AC\n", "input_to_evaluate": "open Batteries\nopen Printf\nlet () =\n let s = Scanf.scanf \"%s \" (fun a -> a) in\n let s1 = String.slice ~last:1 s in\n let s2 = String.slice ~first:2 ~last:(String.length s - 1) s in\n\n Printf.printf \"%s\\n\" @@\n if s1 = \"A\" && (\n let l = List.of_enum (\n String.find_all s2 \"C\"\n )\n in\n List.length l = 1\n )\n then \"AC\" else \"WA\"\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nYou are given a string S. Each character of S is uppercase or lowercase English letter.\nDetermine if S satisfies all of the following conditions:\n\nThe initial character of S is an uppercase A.\n\nThere is exactly one occurrence of C between the third character from the beginning and the second to last character (inclusive).\n\nAll letters except the A and C mentioned above are lowercase.\n\nConstraints\n\n4 ≤ |S| ≤ 10 (|S| is the length of the string S.)\n\nEach character of S is uppercase or lowercase English letter.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nIf S satisfies all of the conditions in the problem statement, print AC; otherwise, print WA.\n\nSample Input 1\n\nAtCoder\n\nSample Output 1\n\nAC\n\nThe first letter is A, the third letter is C and the remaining letters are all lowercase, so all the conditions are satisfied.\n\nSample Input 2\n\nACoder\n\nSample Output 2\n\nWA\n\nThe second letter should not be C.\n\nSample Input 3\n\nAcycliC\n\nSample Output 3\n\nWA\n\nThe last letter should not be C, either.\n\nSample Input 4\n\nAtCoCo\n\nSample Output 4\n\nWA\n\nThere should not be two or more occurrences of C.\n\nSample Input 5\n\nAtcoder\n\nSample Output 5\n\nWA\n\nThe number of C should not be zero, either.", "sample_input": "AtCoder\n"}, "reference_outputs": ["AC\n"], "source_document_id": "p03289", "source_text": "Score : 200 points\n\nProblem Statement\n\nYou are given a string S. Each character of S is uppercase or lowercase English letter.\nDetermine if S satisfies all of the following conditions:\n\nThe initial character of S is an uppercase A.\n\nThere is exactly one occurrence of C between the third character from the beginning and the second to last character (inclusive).\n\nAll letters except the A and C mentioned above are lowercase.\n\nConstraints\n\n4 ≤ |S| ≤ 10 (|S| is the length of the string S.)\n\nEach character of S is uppercase or lowercase English letter.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nIf S satisfies all of the conditions in the problem statement, print AC; otherwise, print WA.\n\nSample Input 1\n\nAtCoder\n\nSample Output 1\n\nAC\n\nThe first letter is A, the third letter is C and the remaining letters are all lowercase, so all the conditions are satisfied.\n\nSample Input 2\n\nACoder\n\nSample Output 2\n\nWA\n\nThe second letter should not be C.\n\nSample Input 3\n\nAcycliC\n\nSample Output 3\n\nWA\n\nThe last letter should not be C, either.\n\nSample Input 4\n\nAtCoCo\n\nSample Output 4\n\nWA\n\nThere should not be two or more occurrences of C.\n\nSample Input 5\n\nAtcoder\n\nSample Output 5\n\nWA\n\nThe number of C should not be zero, either.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 2, "memory_kb": 1024}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s718525260", "group_id": "codeNet:p03289", "input_text": "let list_of_str s = let rec f i = if i >= String.length s then [] else s.[i] :: f (i+1) in f 0\nlet () =\n Scanf.scanf \"%s\" (fun s ->\n s.[0] = 'A' &&\n 1 = List.length (List.filter ((=) 'C') @@ list_of_str (String.sub s 2 (String.length s - 3))) &&\n 2 = List.length (List.filter (fun x -> 'A' <= x && x <= 'Z') (list_of_str s))\n ) |> fun b -> print_endline @@ if b then \"AC\" else \"WA\"", "language": "OCaml", "metadata": {"date": 1533517688, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03289.html", "problem_id": "p03289", "resource_group": "low_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/OCaml/s718525260.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s718525260", "user_id": "u798181098"}, "prompt_components": {"gold_output": "AC\n", "input_to_evaluate": "let list_of_str s = let rec f i = if i >= String.length s then [] else s.[i] :: f (i+1) in f 0\nlet () =\n Scanf.scanf \"%s\" (fun s ->\n s.[0] = 'A' &&\n 1 = List.length (List.filter ((=) 'C') @@ list_of_str (String.sub s 2 (String.length s - 3))) &&\n 2 = List.length (List.filter (fun x -> 'A' <= x && x <= 'Z') (list_of_str s))\n ) |> fun b -> print_endline @@ if b then \"AC\" else \"WA\"", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s980629040", "group_id": "codeNet:p03290", "input_text": "open Printf\nopen Scanf\n\nlet (d,g) = sscanf (read_line ()) \"%d %d\" (fun d g -> (d,g));;\nlet rec input_list num l =\nif num = 0 then l\nelse \n let (p,c) = sscanf (read_line ()) \"%d %d\" (fun d g -> (d,g)) in\n input_list (num-1) ((100 * (d-num+1), p, c) :: l);;\n\nlet list = input_list d [];;\nlet inf = 10000000000;;\n\nlet solve list g =\n let rec loop l q_num sum tl =\n match l with\n | [] -> \n (match tl with\n | [] -> if sum >= g then q_num else inf\n | x::rest -> \n let diff = g - sum in\n if diff <= 0 then q_num \n else \n let (i1,p1,c1) = List.hd (List.rev tl) in\n if i1*(p1-1)+sum < g then inf\n else q_num + truncate ((float_of_int diff) /. (float_of_int i1))\n )\n | (i1,p1,c1)::rest -> \n let used_value = loop rest (q_num + p1) (sum + p1*i1 + c1) tl in\n let non_used_value = loop rest q_num sum ((i1,p1,c1) :: tl) in\n min used_value non_used_value\n in loop list 0 0 [];;\n\nlet ans = solve list g;;\n\nlet _ = printf \"%d\\n\" ans;;", "language": "OCaml", "metadata": {"date": 1564772781, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03290.html", "problem_id": "p03290", "resource_group": "low_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/OCaml/s980629040.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s980629040", "user_id": "u947517859"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "open Printf\nopen Scanf\n\nlet (d,g) = sscanf (read_line ()) \"%d %d\" (fun d g -> (d,g));;\nlet rec input_list num l =\nif num = 0 then l\nelse \n let (p,c) = sscanf (read_line ()) \"%d %d\" (fun d g -> (d,g)) in\n input_list (num-1) ((100 * (d-num+1), p, c) :: l);;\n\nlet list = input_list d [];;\nlet inf = 10000000000;;\n\nlet solve list g =\n let rec loop l q_num sum tl =\n match l with\n | [] -> \n (match tl with\n | [] -> if sum >= g then q_num else inf\n | x::rest -> \n let diff = g - sum in\n if diff <= 0 then q_num \n else \n let (i1,p1,c1) = List.hd (List.rev tl) in\n if i1*(p1-1)+sum < g then inf\n else q_num + truncate ((float_of_int diff) /. (float_of_int i1))\n )\n | (i1,p1,c1)::rest -> \n let used_value = loop rest (q_num + p1) (sum + p1*i1 + c1) tl in\n let non_used_value = loop rest q_num sum ((i1,p1,c1) :: tl) in\n min used_value non_used_value\n in loop list 0 0 [];;\n\nlet ans = solve list g;;\n\nlet _ = printf \"%d\\n\" 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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1067, "cpu_time_ms": 1, "memory_kb": 640}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s114092574", "group_id": "codeNet:p03290", "input_text": "Scanf.scanf \"%d %d\" @@ fun d g ->\n let a = Array.init d (fun i ->\n Scanf.scanf \" %d %d\" (fun p c->((i+1)*100,p,c))) in\n let ls = a |> Array.fold_left (fun l (i,p,c) ->\n List.fold_left (fun l (isum,psum)->\n ((Array.init (p+1) (fun pi -> isum+pi,psum+pi*i+if pi=p then c else 0)) |> Array.to_list) @ l\n ) [] l\n ) [0,0] in\n let ls = List.filter(fun (i,p) -> p>= g) ls in\n let ls = List.sort compare ls in\n ls |> List.iter (fun (i,p)->Printf.printf \"%d\\n\" i;exit 0)\n", "language": "OCaml", "metadata": {"date": 1541676259, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03290.html", "problem_id": "p03290", "resource_group": "low_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/OCaml/s114092574.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s114092574", "user_id": "u472975241"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "Scanf.scanf \"%d %d\" @@ fun d g ->\n let a = Array.init d (fun i ->\n Scanf.scanf \" %d %d\" (fun p c->((i+1)*100,p,c))) in\n let ls = a |> Array.fold_left (fun l (i,p,c) ->\n List.fold_left (fun l (isum,psum)->\n ((Array.init (p+1) (fun pi -> isum+pi,psum+pi*i+if pi=p then c else 0)) |> Array.to_list) @ l\n ) [] l\n ) [0,0] in\n let ls = List.filter(fun (i,p) -> p>= g) ls in\n let ls = List.sort compare ls in\n ls |> List.iter (fun (i,p)->Printf.printf \"%d\\n\" i;exit 0)\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nA programming competition site AtCode provides algorithmic problems.\nEach problem is allocated a score based on its difficulty.\nCurrently, for each integer i between 1 and D (inclusive), there are p_i problems with a score of 100i points.\nThese p_1 + … + p_D problems are all of the problems available on AtCode.\n\nA user of AtCode has a value called total score.\nThe total score of a user is the sum of the following two elements:\n\nBase score: the sum of the scores of all problems solved by the user.\n\nPerfect bonuses: when a user solves all problems with a score of 100i points, he/she earns the perfect bonus of c_i points, aside from the base score (1 ≤ i ≤ D).\n\nTakahashi, who is the new user of AtCode, has not solved any problem.\nHis objective is to have a total score of G or more points.\nAt least how many problems does he need to solve for this objective?\n\nConstraints\n\n1 ≤ D ≤ 10\n\n1 ≤ p_i ≤ 100\n\n100 ≤ c_i ≤ 10^6\n\n100 ≤ G\n\nAll values in input are integers.\n\nc_i and G are all multiples of 100.\n\nIt is possible to have a total score of G or more points.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nD G\np_1 c_1\n:\np_D c_D\n\nOutput\n\nPrint the minimum number of problems that needs to be solved in order to have a total score of G or more points. Note that this objective is always achievable (see Constraints).\n\nSample Input 1\n\n2 700\n3 500\n5 800\n\nSample Output 1\n\n3\n\nIn this case, there are three problems each with 100 points and five problems each with 200 points. The perfect bonus for solving all the 100-point problems is 500 points, and the perfect bonus for solving all the 200-point problems is 800 points. Takahashi's objective is to have a total score of 700 points or more.\n\nOne way to achieve this objective is to solve four 200-point problems and earn a base score of 800 points. However, if we solve three 100-point problems, we can earn the perfect bonus of 500 points in addition to the base score of 300 points, for a total score of 800 points, and we can achieve the objective with fewer problems.\n\nSample Input 2\n\n2 2000\n3 500\n5 800\n\nSample Output 2\n\n7\n\nThis case is similar to Sample Input 1, but the Takahashi's objective this time is 2000 points or more. In this case, we inevitably need to solve all five 200-point problems, and by solving two 100-point problems additionally we have the total score of 2000 points.\n\nSample Input 3\n\n2 400\n3 500\n5 800\n\nSample Output 3\n\n2\n\nThis case is again similar to Sample Input 1, but the Takahashi's objective this time is 400 points or more. In this case, we only need to solve two 200-point problems to achieve the objective.\n\nSample Input 4\n\n5 25000\n20 1000\n40 1000\n50 1000\n30 1000\n1 1000\n\nSample Output 4\n\n66\n\nThere is only one 500-point problem, but the perfect bonus can be earned even in such a case.", "sample_input": "2 700\n3 500\n5 800\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03290", "source_text": "Score : 300 points\n\nProblem Statement\n\nA programming competition site AtCode provides algorithmic problems.\nEach problem is allocated a score based on its difficulty.\nCurrently, for each integer i between 1 and D (inclusive), there are p_i problems with a score of 100i points.\nThese p_1 + … + p_D problems are all of the problems available on AtCode.\n\nA user of AtCode has a value called total score.\nThe total score of a user is the sum of the following two elements:\n\nBase score: the sum of the scores of all problems solved by the user.\n\nPerfect bonuses: when a user solves all problems with a score of 100i points, he/she earns the perfect bonus of c_i points, aside from the base score (1 ≤ i ≤ D).\n\nTakahashi, who is the new user of AtCode, has not solved any problem.\nHis objective is to have a total score of G or more points.\nAt least how many problems does he need to solve for this objective?\n\nConstraints\n\n1 ≤ D ≤ 10\n\n1 ≤ p_i ≤ 100\n\n100 ≤ c_i ≤ 10^6\n\n100 ≤ G\n\nAll values in input are integers.\n\nc_i and G are all multiples of 100.\n\nIt is possible to have a total score of G or more points.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nD G\np_1 c_1\n:\np_D c_D\n\nOutput\n\nPrint the minimum number of problems that needs to be solved in order to have a total score of G or more points. Note that this objective is always achievable (see Constraints).\n\nSample Input 1\n\n2 700\n3 500\n5 800\n\nSample Output 1\n\n3\n\nIn this case, there are three problems each with 100 points and five problems each with 200 points. The perfect bonus for solving all the 100-point problems is 500 points, and the perfect bonus for solving all the 200-point problems is 800 points. Takahashi's objective is to have a total score of 700 points or more.\n\nOne way to achieve this objective is to solve four 200-point problems and earn a base score of 800 points. However, if we solve three 100-point problems, we can earn the perfect bonus of 500 points in addition to the base score of 300 points, for a total score of 800 points, and we can achieve the objective with fewer problems.\n\nSample Input 2\n\n2 2000\n3 500\n5 800\n\nSample Output 2\n\n7\n\nThis case is similar to Sample Input 1, but the Takahashi's objective this time is 2000 points or more. In this case, we inevitably need to solve all five 200-point problems, and by solving two 100-point problems additionally we have the total score of 2000 points.\n\nSample Input 3\n\n2 400\n3 500\n5 800\n\nSample Output 3\n\n2\n\nThis case is again similar to Sample Input 1, but the Takahashi's objective this time is 400 points or more. In this case, we only need to solve two 200-point problems to achieve the objective.\n\nSample Input 4\n\n5 25000\n20 1000\n40 1000\n50 1000\n30 1000\n1 1000\n\nSample Output 4\n\n66\n\nThere is only one 500-point problem, but the perfect bonus can be earned even in such a case.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 482, "cpu_time_ms": 2112, "memory_kb": 661872}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s551100551", "group_id": "codeNet:p03292", "input_text": "open Printf\nopen Scanf\n\nlet solve a1 a2 a3 = max a1 (max a2 a3) - min a1 (min a2 a3)\n\nlet () =\n scanf \"%d %d %d \" solve |> printf \"%d\\n\"\n", "language": "OCaml", "metadata": {"date": 1582257838, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03292.html", "problem_id": "p03292", "resource_group": "low_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/OCaml/s551100551.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s551100551", "user_id": "u388783188"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "open Printf\nopen Scanf\n\nlet solve a1 a2 a3 = max a1 (max a2 a3) - min a1 (min a2 a3)\n\nlet () =\n scanf \"%d %d %d \" solve |> printf \"%d\\n\"\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou have three tasks, all of which need to be completed.\n\nFirst, you can complete any one task at cost 0.\n\nThen, just after completing the i-th task, you can complete the j-th task at cost |A_j - A_i|.\n\nHere, |x| denotes the absolute value of x.\n\nFind the minimum total cost required to complete all the task.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq A_1, A_2, A_3 \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA_1 A_2 A_3\n\nOutput\n\nPrint the minimum total cost required to complete all the task.\n\nSample Input 1\n\n1 6 3\n\nSample Output 1\n\n5\n\nWhen the tasks are completed in the following order, the total cost will be 5, which is the minimum:\n\nComplete the first task at cost 0.\n\nComplete the third task at cost 2.\n\nComplete the second task at cost 3.\n\nSample Input 2\n\n11 5 5\n\nSample Output 2\n\n6\n\nSample Input 3\n\n100 100 100\n\nSample Output 3\n\n0", "sample_input": "1 6 3\n"}, "reference_outputs": ["5\n"], "source_document_id": "p03292", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou have three tasks, all of which need to be completed.\n\nFirst, you can complete any one task at cost 0.\n\nThen, just after completing the i-th task, you can complete the j-th task at cost |A_j - A_i|.\n\nHere, |x| denotes the absolute value of x.\n\nFind the minimum total cost required to complete all the task.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq A_1, A_2, A_3 \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA_1 A_2 A_3\n\nOutput\n\nPrint the minimum total cost required to complete all the task.\n\nSample Input 1\n\n1 6 3\n\nSample Output 1\n\n5\n\nWhen the tasks are completed in the following order, the total cost will be 5, which is the minimum:\n\nComplete the first task at cost 0.\n\nComplete the third task at cost 2.\n\nComplete the second task at cost 3.\n\nSample Input 2\n\n11 5 5\n\nSample Output 2\n\n6\n\nSample Input 3\n\n100 100 100\n\nSample Output 3\n\n0", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s240310900", "group_id": "codeNet:p03292", "input_text": "let a, b, c = Scanf.scanf \" %d %d %d\" @@ fun a b c -> a, b, c\nlet f a b c = abs (b - a) + abs (c - b)\nlet _ = List.fold_left min max_int [f a b c; f a c b; f b a c; f b c a; f c a b; f c b a] |> Printf.printf \"%d\\n\"", "language": "OCaml", "metadata": {"date": 1565011611, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03292.html", "problem_id": "p03292", "resource_group": "low_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/OCaml/s240310900.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s240310900", "user_id": "u732304692"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "let a, b, c = Scanf.scanf \" %d %d %d\" @@ fun a b c -> a, b, c\nlet f a b c = abs (b - a) + abs (c - b)\nlet _ = List.fold_left min max_int [f a b c; f a c b; f b a c; f b c a; f c a b; f c b a] |> Printf.printf \"%d\\n\"", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou have three tasks, all of which need to be completed.\n\nFirst, you can complete any one task at cost 0.\n\nThen, just after completing the i-th task, you can complete the j-th task at cost |A_j - A_i|.\n\nHere, |x| denotes the absolute value of x.\n\nFind the minimum total cost required to complete all the task.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq A_1, A_2, A_3 \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA_1 A_2 A_3\n\nOutput\n\nPrint the minimum total cost required to complete all the task.\n\nSample Input 1\n\n1 6 3\n\nSample Output 1\n\n5\n\nWhen the tasks are completed in the following order, the total cost will be 5, which is the minimum:\n\nComplete the first task at cost 0.\n\nComplete the third task at cost 2.\n\nComplete the second task at cost 3.\n\nSample Input 2\n\n11 5 5\n\nSample Output 2\n\n6\n\nSample Input 3\n\n100 100 100\n\nSample Output 3\n\n0", "sample_input": "1 6 3\n"}, "reference_outputs": ["5\n"], "source_document_id": "p03292", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou have three tasks, all of which need to be completed.\n\nFirst, you can complete any one task at cost 0.\n\nThen, just after completing the i-th task, you can complete the j-th task at cost |A_j - A_i|.\n\nHere, |x| denotes the absolute value of x.\n\nFind the minimum total cost required to complete all the task.\n\nConstraints\n\nAll values in input are integers.\n\n1 \\leq A_1, A_2, A_3 \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA_1 A_2 A_3\n\nOutput\n\nPrint the minimum total cost required to complete all the task.\n\nSample Input 1\n\n1 6 3\n\nSample Output 1\n\n5\n\nWhen the tasks are completed in the following order, the total cost will be 5, which is the minimum:\n\nComplete the first task at cost 0.\n\nComplete the third task at cost 2.\n\nComplete the second task at cost 3.\n\nSample Input 2\n\n11 5 5\n\nSample Output 2\n\n6\n\nSample Input 3\n\n100 100 100\n\nSample Output 3\n\n0", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s990257291", "group_id": "codeNet:p03293", "input_text": "let () =\n let s = read_line () in\n let t = read_line () in\n Array.init (String.length s) (fun i -> i)\n |> Array.to_list\n |> List.exists (fun i ->\n Array.init (String.length s) (fun j -> j)\n |> Array.to_list\n |> List.for_all (fun j ->\n s.[(i + j) mod String.length s] = t.[j]))\n |> (function true -> \"Yes\" | false -> \"No\")\n |> print_endline\n", "language": "OCaml", "metadata": {"date": 1532262939, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03293.html", "problem_id": "p03293", "resource_group": "low_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/OCaml/s990257291.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s990257291", "user_id": "u504158101"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "let () =\n let s = read_line () in\n let t = read_line () in\n Array.init (String.length s) (fun i -> i)\n |> Array.to_list\n |> List.exists (fun i ->\n Array.init (String.length s) (fun j -> j)\n |> Array.to_list\n |> List.for_all (fun j ->\n s.[(i + j) mod String.length s] = t.[j]))\n |> (function true -> \"Yes\" | false -> \"No\")\n |> print_endline\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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 371, "cpu_time_ms": 1, "memory_kb": 2432}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s271961346", "group_id": "codeNet:p03294", "input_text": "open Batteries\nopen Printf\nlet () =\n let n = Scanf.scanf \"%d \" (fun a -> a) in\n let a_l = Array.to_list @@ Array.init n (fun _ -> Scanf.scanf \"%d \" (fun a -> a)) in\n Printf.printf \"%d\\n\" @@\n List.fold_left (fun acc x -> acc + (x-1)) 0 a_l\n", "language": "OCaml", "metadata": {"date": 1534029648, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03294.html", "problem_id": "p03294", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03294/input.txt", "sample_output_relpath": "derived/input_output/data/p03294/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03294/OCaml/s271961346.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s271961346", "user_id": "u139013163"}, "prompt_components": {"gold_output": "10\n", "input_to_evaluate": "open Batteries\nopen Printf\nlet () =\n let n = Scanf.scanf \"%d \" (fun a -> a) in\n let a_l = Array.to_list @@ Array.init n (fun _ -> Scanf.scanf \"%d \" (fun a -> a)) in\n Printf.printf \"%d\\n\" @@\n List.fold_left (fun acc x -> acc + (x-1)) 0 a_l\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou are given N positive integers a_1, a_2, ..., a_N.\n\nFor a non-negative integer m, let f(m) = (m\\ mod\\ a_1) + (m\\ mod\\ a_2) + ... + (m\\ mod\\ a_N).\n\nHere, X\\ mod\\ Y denotes the remainder of the division of X by Y.\n\nFind the maximum value of f.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 3000\n\n2 \\leq a_i \\leq 10^5\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 ... a_N\n\nOutput\n\nPrint the maximum value of f.\n\nSample Input 1\n\n3\n3 4 6\n\nSample Output 1\n\n10\n\nf(11) = (11\\ mod\\ 3) + (11\\ mod\\ 4) + (11\\ mod\\ 6) = 10 is the maximum value of f.\n\nSample Input 2\n\n5\n7 46 11 20 11\n\nSample Output 2\n\n90\n\nSample Input 3\n\n7\n994 518 941 851 647 2 581\n\nSample Output 3\n\n4527", "sample_input": "3\n3 4 6\n"}, "reference_outputs": ["10\n"], "source_document_id": "p03294", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou are given N positive integers a_1, a_2, ..., a_N.\n\nFor a non-negative integer m, let f(m) = (m\\ mod\\ a_1) + (m\\ mod\\ a_2) + ... + (m\\ mod\\ a_N).\n\nHere, X\\ mod\\ Y denotes the remainder of the division of X by Y.\n\nFind the maximum value of f.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 3000\n\n2 \\leq a_i \\leq 10^5\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 ... a_N\n\nOutput\n\nPrint the maximum value of f.\n\nSample Input 1\n\n3\n3 4 6\n\nSample Output 1\n\n10\n\nf(11) = (11\\ mod\\ 3) + (11\\ mod\\ 4) + (11\\ mod\\ 6) = 10 is the maximum value of f.\n\nSample Input 2\n\n5\n7 46 11 20 11\n\nSample Output 2\n\n90\n\nSample Input 3\n\n7\n994 518 941 851 647 2 581\n\nSample Output 3\n\n4527", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 243, "cpu_time_ms": 3, "memory_kb": 1920}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s455922335", "group_id": "codeNet:p03294", "input_text": "open Printf open Scanf\nmodule MyInt = struct\n\tlet (+) = (+) let (-) = (-) let (/) = (/) let ( * ) = ( * ) let (mod) = (mod) let (%) = (mod) let (+=) r v = r := !r + v let (-=) r v = r := !r - v let ( *=) r v= r := !r * v let (/=) r v = r := !r / v\n\t(* let input_int_array n = Array.init n (fun _ -> Scanf.scanf \" %d\" (fun v -> v))\t\n\tlet get_int () = Scanf.scanf \" %d\" (fun v -> v)\n\tlet get_2_ints () = Scanf.scanf \" %d %d\" (fun u v -> u,v)\n\tlet get_3_ints () = Scanf.scanf \" %d %d %d\" (fun u v w -> u,v,w)\n\tlet get_4_ints () = Scanf.scanf \" %d %d %d %d\" (fun u v w x -> u,v,w,x)\n\tlet get_5_ints () = Scanf.scanf \" %d %d %d %d %d\" (fun u v w x y -> u,v,w,x,y)\n\tlet print_int_endline n = n |> string_of_int |> print_endline *)\nend\n(* module MyInt64 = struct *)\n\tlet (+$) = (+) let (-$) = (-) let (/$) = (/) let ( *$) = ( * )\n\tlet (+) p q = Int64.add p q let (-) p q = Int64.sub p q let ( * ) p q = Int64.mul p q let (/) p q = Int64.div p q let (+=) r v = r := !r + v let (-=) r v = r := !r - v let ( *=) r v= r := !r * v let (/=) r v = r := !r / v\n\tlet labs p = if p < 0L then -1L*p else p\n\tlet (~|) p = Int64.to_int p\n\tlet (~~|) p = Int64.of_int p\n\n\tlet input_i64_array n = Array.init (~| n) (fun _ -> Scanf.scanf \" %Ld\" (fun v -> v))\n\tlet get_i64 () = Scanf.scanf \" %Ld\" (fun v -> v)\n\tlet get_2_i64 () = Scanf.scanf \" %Ld %Ld\" (fun u v -> u,v)\n\tlet get_3_i64 () = Scanf.scanf \" %Ld %Ld %Ld\" (fun u v w -> u,v,w)\n\tlet get_4_i64 () = Scanf.scanf \" %Ld %Ld %Ld %Ld\" (fun u v w x -> u,v,w,x)\n\tlet get_5_i64 () = Scanf.scanf \" %Ld %Ld %Ld %Ld %Ld\" (fun u v w x y -> u,v,w,x,y)\n\tlet print_i64_endline n =\n\t\tn |> Int64.to_string |> print_endline\n\t\n\tlet (mod) m n = m - (m/n) * n let (%) = (mod)\n\tlet rec gcd m n = match m,n with | m,0L -> m | m,n -> gcd n (m mod n)\n\tlet rec lcm m n = (m*n) / gcd m n\n\tlet rep from_ to_ fbod =\n\t\tlet i,f = ref ~|from_,ref true in while !i <= ~|to_-$1 && !f do\n\t\t\tmatch fbod !i with\n\t\t\t| `Ok -> i := !i +$ 1;\n\t\t\t| `Ng -> f := false\n\t\tdone\n(* end open MyInt64 *)\n\nlet () =\n\tlet n = get_i64 ()\n\tin let a = input_i64_array n\n\tin\n\tlet sum = ref 0L in\n\tfor j=0 to Array.length a -$ 1 do\n\t\tsum += (a.(j) - 1L)\n\tdone;\n\t!sum |> printf \"%Ld\\n\"", "language": "OCaml", "metadata": {"date": 1532226804, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03294.html", "problem_id": "p03294", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03294/input.txt", "sample_output_relpath": "derived/input_output/data/p03294/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03294/OCaml/s455922335.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s455922335", "user_id": "u481480055"}, "prompt_components": {"gold_output": "10\n", "input_to_evaluate": "open Printf open Scanf\nmodule MyInt = struct\n\tlet (+) = (+) let (-) = (-) let (/) = (/) let ( * ) = ( * ) let (mod) = (mod) let (%) = (mod) let (+=) r v = r := !r + v let (-=) r v = r := !r - v let ( *=) r v= r := !r * v let (/=) r v = r := !r / v\n\t(* let input_int_array n = Array.init n (fun _ -> Scanf.scanf \" %d\" (fun v -> v))\t\n\tlet get_int () = Scanf.scanf \" %d\" (fun v -> v)\n\tlet get_2_ints () = Scanf.scanf \" %d %d\" (fun u v -> u,v)\n\tlet get_3_ints () = Scanf.scanf \" %d %d %d\" (fun u v w -> u,v,w)\n\tlet get_4_ints () = Scanf.scanf \" %d %d %d %d\" (fun u v w x -> u,v,w,x)\n\tlet get_5_ints () = Scanf.scanf \" %d %d %d %d %d\" (fun u v w x y -> u,v,w,x,y)\n\tlet print_int_endline n = n |> string_of_int |> print_endline *)\nend\n(* module MyInt64 = struct *)\n\tlet (+$) = (+) let (-$) = (-) let (/$) = (/) let ( *$) = ( * )\n\tlet (+) p q = Int64.add p q let (-) p q = Int64.sub p q let ( * ) p q = Int64.mul p q let (/) p q = Int64.div p q let (+=) r v = r := !r + v let (-=) r v = r := !r - v let ( *=) r v= r := !r * v let (/=) r v = r := !r / v\n\tlet labs p = if p < 0L then -1L*p else p\n\tlet (~|) p = Int64.to_int p\n\tlet (~~|) p = Int64.of_int p\n\n\tlet input_i64_array n = Array.init (~| n) (fun _ -> Scanf.scanf \" %Ld\" (fun v -> v))\n\tlet get_i64 () = Scanf.scanf \" %Ld\" (fun v -> v)\n\tlet get_2_i64 () = Scanf.scanf \" %Ld %Ld\" (fun u v -> u,v)\n\tlet get_3_i64 () = Scanf.scanf \" %Ld %Ld %Ld\" (fun u v w -> u,v,w)\n\tlet get_4_i64 () = Scanf.scanf \" %Ld %Ld %Ld %Ld\" (fun u v w x -> u,v,w,x)\n\tlet get_5_i64 () = Scanf.scanf \" %Ld %Ld %Ld %Ld %Ld\" (fun u v w x y -> u,v,w,x,y)\n\tlet print_i64_endline n =\n\t\tn |> Int64.to_string |> print_endline\n\t\n\tlet (mod) m n = m - (m/n) * n let (%) = (mod)\n\tlet rec gcd m n = match m,n with | m,0L -> m | m,n -> gcd n (m mod n)\n\tlet rec lcm m n = (m*n) / gcd m n\n\tlet rep from_ to_ fbod =\n\t\tlet i,f = ref ~|from_,ref true in while !i <= ~|to_-$1 && !f do\n\t\t\tmatch fbod !i with\n\t\t\t| `Ok -> i := !i +$ 1;\n\t\t\t| `Ng -> f := false\n\t\tdone\n(* end open MyInt64 *)\n\nlet () =\n\tlet n = get_i64 ()\n\tin let a = input_i64_array n\n\tin\n\tlet sum = ref 0L in\n\tfor j=0 to Array.length a -$ 1 do\n\t\tsum += (a.(j) - 1L)\n\tdone;\n\t!sum |> printf \"%Ld\\n\"", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou are given N positive integers a_1, a_2, ..., a_N.\n\nFor a non-negative integer m, let f(m) = (m\\ mod\\ a_1) + (m\\ mod\\ a_2) + ... + (m\\ mod\\ a_N).\n\nHere, X\\ mod\\ Y denotes the remainder of the division of X by Y.\n\nFind the maximum value of f.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 3000\n\n2 \\leq a_i \\leq 10^5\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 ... a_N\n\nOutput\n\nPrint the maximum value of f.\n\nSample Input 1\n\n3\n3 4 6\n\nSample Output 1\n\n10\n\nf(11) = (11\\ mod\\ 3) + (11\\ mod\\ 4) + (11\\ mod\\ 6) = 10 is the maximum value of f.\n\nSample Input 2\n\n5\n7 46 11 20 11\n\nSample Output 2\n\n90\n\nSample Input 3\n\n7\n994 518 941 851 647 2 581\n\nSample Output 3\n\n4527", "sample_input": "3\n3 4 6\n"}, "reference_outputs": ["10\n"], "source_document_id": "p03294", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou are given N positive integers a_1, a_2, ..., a_N.\n\nFor a non-negative integer m, let f(m) = (m\\ mod\\ a_1) + (m\\ mod\\ a_2) + ... + (m\\ mod\\ a_N).\n\nHere, X\\ mod\\ Y denotes the remainder of the division of X by Y.\n\nFind the maximum value of f.\n\nConstraints\n\nAll values in input are integers.\n\n2 \\leq N \\leq 3000\n\n2 \\leq a_i \\leq 10^5\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 ... a_N\n\nOutput\n\nPrint the maximum value of f.\n\nSample Input 1\n\n3\n3 4 6\n\nSample Output 1\n\n10\n\nf(11) = (11\\ mod\\ 3) + (11\\ mod\\ 4) + (11\\ mod\\ 6) = 10 is the maximum value of f.\n\nSample Input 2\n\n5\n7 46 11 20 11\n\nSample Output 2\n\n90\n\nSample Input 3\n\n7\n994 518 941 851 647 2 581\n\nSample Output 3\n\n4527", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2159, "cpu_time_ms": 2, "memory_kb": 1408}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s183568639", "group_id": "codeNet:p03297", "input_text": "open Scanf\nopen Printf\n\nmodule Int = struct\n type t = int\n let compare a b = compare a b\nend\n\nmodule S = Set.Make(Int)\n\nlet consume c b x = if x <= c\n then x - b\n else if (x - c) mod b = 0\n then c\n else c + (x - c) mod b - b\n\nlet f a b c d = let memo = ref S.empty in\n let rec g x = if x < 0\n then printf \"No\\n\"\n else if S.mem x !memo\n then printf \"Yes\\n\"\n else (memo := S.add x !memo; g (consume c b (x+d)))\n in g (consume c b a)\n\nlet () = scanf \"%d\\n\" (fun c ->\n for i = 1 to c do\n scanf \"%d %d %d %d\\n\" f\n done)", "language": "OCaml", "metadata": {"date": 1532246336, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03297.html", "problem_id": "p03297", "resource_group": "low_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/OCaml/s183568639.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s183568639", "user_id": "u379439911"}, "prompt_components": {"gold_output": "No\nYes\nNo\nYes\nYes\nNo\nNo\nYes\nNo\nYes\nYes\nNo\nNo\nYes\n", "input_to_evaluate": "open Scanf\nopen Printf\n\nmodule Int = struct\n type t = int\n let compare a b = compare a b\nend\n\nmodule S = Set.Make(Int)\n\nlet consume c b x = if x <= c\n then x - b\n else if (x - c) mod b = 0\n then c\n else c + (x - c) mod b - b\n\nlet f a b c d = let memo = ref S.empty in\n let rec g x = if x < 0\n then printf \"No\\n\"\n else if S.mem x !memo\n then printf \"Yes\\n\"\n else (memo := S.add x !memo; g (consume c b (x+d)))\n in g (consume c b a)\n\nlet () = scanf \"%d\\n\" (fun c ->\n for i = 1 to c do\n scanf \"%d %d %d %d\\n\" f\n done)", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 2107, "memory_kb": 98680}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s986538960", "group_id": "codeNet:p03298", "input_text": "module M = Map.Make (struct\n type t = char list * char list\n let compare = compare\nend)\n\nlet () = Scanf.scanf \"%d\\n%s\\n\" @@ fun n s ->\n let m =\n Array.fold_left (fun m rb ->\n M.add rb (1 + try M.find rb m with Not_found -> 0) m) M.empty @@\n Array.init (1 lsl n) @@ fun i ->\n Array.fold_left (fun (r, b) j ->\n if i land (1 lsl j) = 0\n then (s.[j + n] :: r, b)\n else (r, s.[j + n] :: b)) ([], []) @@\n Array.init n @@ fun j -> j in\n Printf.printf \"%d\\n\" @@\n Array.fold_left ( + ) 0 @@\n Array.init (1 lsl n) @@ fun i ->\n let (r, b) =\n Array.fold_left (fun (r, b) j ->\n if i land (1 lsl j) = 0\n then (s.[j] :: r, b)\n else (r, s.[j] :: b)) ([], []) @@\n Array.init n @@ fun j -> j in\n try M.find (List.rev b, List.rev r) m with Not_found -> 0\n", "language": "OCaml", "metadata": {"date": 1536815889, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03298.html", "problem_id": "p03298", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03298/input.txt", "sample_output_relpath": "derived/input_output/data/p03298/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03298/OCaml/s986538960.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s986538960", "user_id": "u504158101"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "module M = Map.Make (struct\n type t = char list * char list\n let compare = compare\nend)\n\nlet () = Scanf.scanf \"%d\\n%s\\n\" @@ fun n s ->\n let m =\n Array.fold_left (fun m rb ->\n M.add rb (1 + try M.find rb m with Not_found -> 0) m) M.empty @@\n Array.init (1 lsl n) @@ fun i ->\n Array.fold_left (fun (r, b) j ->\n if i land (1 lsl j) = 0\n then (s.[j + n] :: r, b)\n else (r, s.[j + n] :: b)) ([], []) @@\n Array.init n @@ fun j -> j in\n Printf.printf \"%d\\n\" @@\n Array.fold_left ( + ) 0 @@\n Array.init (1 lsl n) @@ fun i ->\n let (r, b) =\n Array.fold_left (fun (r, b) j ->\n if i land (1 lsl j) = 0\n then (s.[j] :: r, b)\n else (r, s.[j] :: b)) ([], []) @@\n Array.init n @@ fun j -> j in\n try M.find (List.rev b, List.rev r) m with Not_found -> 0\n", "problem_context": "Score : 600 points\n\nProblem Statement\n\nYou are given a string S of length 2N consisting of lowercase English letters.\n\nThere are 2^{2N} ways to color each character in S red or blue. Among these ways, how many satisfy the following condition?\n\nThe string obtained by reading the characters painted red from left to right is equal to the string obtained by reading the characters painted blue from right to left.\n\nConstraints\n\n1 \\leq N \\leq 18\n\nThe length of S is 2N.\n\nS consists of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS\n\nOutput\n\nPrint the number of ways to paint the string that satisfy the condition.\n\nSample Input 1\n\n4\ncabaacba\n\nSample Output 1\n\n4\n\nThere are four ways to paint the string, as follows:\n\ncabaacba\n\ncabaacba\n\ncabaacba\n\ncabaacba\n\nSample Input 2\n\n11\nmippiisssisssiipsspiim\n\nSample Output 2\n\n504\n\nSample Input 3\n\n4\nabcdefgh\n\nSample Output 3\n\n0\n\nSample Input 4\n\n18\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n\nSample Output 4\n\n9075135300\n\nThe answer may not be representable as a 32-bit integer.", "sample_input": "4\ncabaacba\n"}, "reference_outputs": ["4\n"], "source_document_id": "p03298", "source_text": "Score : 600 points\n\nProblem Statement\n\nYou are given a string S of length 2N consisting of lowercase English letters.\n\nThere are 2^{2N} ways to color each character in S red or blue. Among these ways, how many satisfy the following condition?\n\nThe string obtained by reading the characters painted red from left to right is equal to the string obtained by reading the characters painted blue from right to left.\n\nConstraints\n\n1 \\leq N \\leq 18\n\nThe length of S is 2N.\n\nS consists of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS\n\nOutput\n\nPrint the number of ways to paint the string that satisfy the condition.\n\nSample Input 1\n\n4\ncabaacba\n\nSample Output 1\n\n4\n\nThere are four ways to paint the string, as follows:\n\ncabaacba\n\ncabaacba\n\ncabaacba\n\ncabaacba\n\nSample Input 2\n\n11\nmippiisssisssiipsspiim\n\nSample Output 2\n\n504\n\nSample Input 3\n\n4\nabcdefgh\n\nSample Output 3\n\n0\n\nSample Input 4\n\n18\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n\nSample Output 4\n\n9075135300\n\nThe answer may not be representable as a 32-bit integer.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 821, "cpu_time_ms": 2408, "memory_kb": 143224}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s144774489", "group_id": "codeNet:p03302", "input_text": "open Scanf\nopen Printf\n\nlet id a = a\nlet pair a b = a, b\nlet triplet a b c = a, b, c\n\nlet rec scan_list = function\n | 1 -> scanf \"%d\" (fun k -> [k])\n | n -> scanf \"%d \" (fun k -> k :: scan_list (n-1))\n\nlet f a b = if a + b = 15\n then printf \"+\\n\"\n else if a * b = 15\n then printf \"*\\n\"\n else printf \"x\\n\"\n\nlet () = scanf \"%d %d\\n\" f", "language": "OCaml", "metadata": {"date": 1531013576, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03302.html", "problem_id": "p03302", "resource_group": "low_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/OCaml/s144774489.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s144774489", "user_id": "u379439911"}, "prompt_components": {"gold_output": "+\n", "input_to_evaluate": "open Scanf\nopen Printf\n\nlet id a = a\nlet pair a b = a, b\nlet triplet a b c = a, b, c\n\nlet rec scan_list = function\n | 1 -> scanf \"%d\" (fun k -> [k])\n | n -> scanf \"%d \" (fun k -> k :: scan_list (n-1))\n\nlet f a b = if a + b = 15\n then printf \"+\\n\"\n else if a * b = 15\n then printf \"*\\n\"\n else printf \"x\\n\"\n\nlet () = scanf \"%d %d\\n\" f", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s920534044", "group_id": "codeNet:p03303", "input_text": "Scanf.scanf\"%s %d\"@@fun s w->String.iteri(fun i c->if i mod w=0 then print_char c)s", "language": "OCaml", "metadata": {"date": 1541081849, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03303.html", "problem_id": "p03303", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03303/input.txt", "sample_output_relpath": "derived/input_output/data/p03303/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03303/OCaml/s920534044.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s920534044", "user_id": "u481480055"}, "prompt_components": {"gold_output": "adg\n", "input_to_evaluate": "Scanf.scanf\"%s %d\"@@fun s w->String.iteri(fun i c->if i mod w=0 then print_char c)s", "problem_context": "Score : 200 points\n\nProblem Statement\n\nYou are given a string S consisting of lowercase English letters.\nWe will write down this string, starting a new line after every w letters. Print the string obtained by concatenating the letters at the beginnings of these lines from top to bottom.\n\nConstraints\n\n1 \\leq w \\leq |S| \\leq 1000\n\nS consists of lowercase English letters.\n\nw is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\nw\n\nOutput\n\nPrint the desired string in one line.\n\nSample Input 1\n\nabcdefgh\n3\n\nSample Output 1\n\nadg\n\nWhen we write down abcdefgh, starting a new line after every three letters, we get the following:\n\nabc\n\ndef\n\ngh\n\nConcatenating the letters at the beginnings of these lines, we obtain adg.\n\nSample Input 2\n\nlllll\n1\n\nSample Output 2\n\nlllll\n\nSample Input 3\n\nsouuundhound\n2\n\nSample Output 3\n\nsuudon", "sample_input": "abcdefgh\n3\n"}, "reference_outputs": ["adg\n"], "source_document_id": "p03303", "source_text": "Score : 200 points\n\nProblem Statement\n\nYou are given a string S consisting of lowercase English letters.\nWe will write down this string, starting a new line after every w letters. Print the string obtained by concatenating the letters at the beginnings of these lines from top to bottom.\n\nConstraints\n\n1 \\leq w \\leq |S| \\leq 1000\n\nS consists of lowercase English letters.\n\nw is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\nw\n\nOutput\n\nPrint the desired string in one line.\n\nSample Input 1\n\nabcdefgh\n3\n\nSample Output 1\n\nadg\n\nWhen we write down abcdefgh, starting a new line after every three letters, we get the following:\n\nabc\n\ndef\n\ngh\n\nConcatenating the letters at the beginnings of these lines, we obtain adg.\n\nSample Input 2\n\nlllll\n1\n\nSample Output 2\n\nlllll\n\nSample Input 3\n\nsouuundhound\n2\n\nSample Output 3\n\nsuudon", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s232473002", "group_id": "codeNet:p03304", "input_text": "let ( *> ) f g x = g (f x);;\nScanf.scanf\" %f %f %f\"@@fun n m->(function\n| 0. -> 1. /. n\n| d -> (2. *. (n -. d)) /. n /. n) *> ( *. ) (m -. 1.) *> Printf.printf\"%.12f\"", "language": "OCaml", "metadata": {"date": 1541086745, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03304.html", "problem_id": "p03304", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03304/input.txt", "sample_output_relpath": "derived/input_output/data/p03304/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03304/OCaml/s232473002.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s232473002", "user_id": "u481480055"}, "prompt_components": {"gold_output": "1.0000000000\n", "input_to_evaluate": "let ( *> ) f g x = g (f x);;\nScanf.scanf\" %f %f %f\"@@fun n m->(function\n| 0. -> 1. /. n\n| d -> (2. *. (n -. d)) /. n /. n) *> ( *. ) (m -. 1.) *> Printf.printf\"%.12f\"", "problem_context": "Score : 300 points\n\nProblem Statement\n\nLet us define the beauty of a sequence (a_1,... ,a_n) as the number of pairs of two adjacent elements in it whose absolute differences are d.\nFor example, when d=1, the beauty of the sequence (3, 2, 3, 10, 9) is 3.\n\nThere are a total of n^m sequences of length m where each element is an integer between 1 and n (inclusive).\nFind the beauty of each of these n^m sequences, and print the average of those values.\n\nConstraints\n\n0 \\leq d < n \\leq 10^9\n\n2 \\leq m \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nn m d\n\nOutput\n\nPrint the average of the beauties of the sequences of length m where each element is an integer between 1 and n.\nThe output will be judged correct if the absolute or relative error is at most 10^{-6}.\n\nSample Input 1\n\n2 3 1\n\nSample Output 1\n\n1.0000000000\n\nThe beauty of (1,1,1) is 0.\n\nThe beauty of (1,1,2) is 1.\n\nThe beauty of (1,2,1) is 2.\n\nThe beauty of (1,2,2) is 1.\n\nThe beauty of (2,1,1) is 1.\n\nThe beauty of (2,1,2) is 2.\n\nThe beauty of (2,2,1) is 1.\n\nThe beauty of (2,2,2) is 0.\n\nThe answer is the average of these values: (0+1+2+1+1+2+1+0)/8=1.\n\nSample Input 2\n\n1000000000 180707 0\n\nSample Output 2\n\n0.0001807060", "sample_input": "2 3 1\n"}, "reference_outputs": ["1.0000000000\n"], "source_document_id": "p03304", "source_text": "Score : 300 points\n\nProblem Statement\n\nLet us define the beauty of a sequence (a_1,... ,a_n) as the number of pairs of two adjacent elements in it whose absolute differences are d.\nFor example, when d=1, the beauty of the sequence (3, 2, 3, 10, 9) is 3.\n\nThere are a total of n^m sequences of length m where each element is an integer between 1 and n (inclusive).\nFind the beauty of each of these n^m sequences, and print the average of those values.\n\nConstraints\n\n0 \\leq d < n \\leq 10^9\n\n2 \\leq m \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nn m d\n\nOutput\n\nPrint the average of the beauties of the sequences of length m where each element is an integer between 1 and n.\nThe output will be judged correct if the absolute or relative error is at most 10^{-6}.\n\nSample Input 1\n\n2 3 1\n\nSample Output 1\n\n1.0000000000\n\nThe beauty of (1,1,1) is 0.\n\nThe beauty of (1,1,2) is 1.\n\nThe beauty of (1,2,1) is 2.\n\nThe beauty of (1,2,2) is 1.\n\nThe beauty of (2,1,1) is 1.\n\nThe beauty of (2,1,2) is 2.\n\nThe beauty of (2,2,1) is 1.\n\nThe beauty of (2,2,2) is 0.\n\nThe answer is the average of these values: (0+1+2+1+1+2+1+0)/8=1.\n\nSample Input 2\n\n1000000000 180707 0\n\nSample Output 2\n\n0.0001807060", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s200755350", "group_id": "codeNet:p03306", "input_text": "open Scanf\nopen Printf\n\nlet id a = a\nlet pair a b = a, b\nlet triplet a b c = a, b, c\n\nlet rec scan_list = function\n | 1 -> scanf \"%d\" (fun k -> [k])\n | n -> scanf \"%d \" (fun k -> k :: scan_list (n-1))\n\nlet g arr u v s = arr.(u-1) <- (v-1,s) :: arr.(u-1);\n arr.(v-1) <- (u-1,s) :: arr.(v-1)\n\nlet f n m = let graph = (Array.make n []) in\n for i = 1 to m do\n scanf \"%d %d %d\\n\" (g graph)\n done;\n for i = 0 to n-1 do\n graph.(i) <- List.sort compare graph.(i)\n done;\n graph\n\nlet h graph ans = let queue = Queue.create () in\n let rec enqueue a = function\n | (v, c) :: lst -> if ans.(v) = 0 then Queue.add (a, v, c) queue; enqueue a lst\n | [] -> ()\n in let rec f () = if Queue.is_empty queue\n then `Ok\n else let (u, v, c) = Queue.take queue\n in if ans.(v) = 0\n then begin\n ans.(v) <- (if c > ans.(u) then c - ans.(u) else raise @@ failwith \"negative answer\");\n enqueue v graph.(v);\n f ()\n end\n else if c = ans.(v) + ans.(u)\n then begin\n enqueue v graph.(v);\n f ()\n end\n else raise @@ failwith \"incorrect\"\n in enqueue 0 graph.(0); f()\n\nlet cost lst = List.map (function (_, c) -> c) lst\nlet minimum lst = List.fold_left min 10000000000000 lst\n\nlet compute graph = let n = ref 0 in\n for i = 1 to minimum (cost graph.(0)) - 1 do\n let ans = Array.make (Array.length graph) 0\n in ans.(0) <- i;\n match h graph ans with\n | `Ok -> n := !n + 1\n | exception Failure s -> eprintf \"%s\\n\" s\n done;\n printf \"%d\\n\" !n\n\nlet () = compute @@ scanf \"%d %d\\n\" f", "language": "OCaml", "metadata": {"date": 1531019605, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03306.html", "problem_id": "p03306", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03306/input.txt", "sample_output_relpath": "derived/input_output/data/p03306/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03306/OCaml/s200755350.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s200755350", "user_id": "u379439911"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "open Scanf\nopen Printf\n\nlet id a = a\nlet pair a b = a, b\nlet triplet a b c = a, b, c\n\nlet rec scan_list = function\n | 1 -> scanf \"%d\" (fun k -> [k])\n | n -> scanf \"%d \" (fun k -> k :: scan_list (n-1))\n\nlet g arr u v s = arr.(u-1) <- (v-1,s) :: arr.(u-1);\n arr.(v-1) <- (u-1,s) :: arr.(v-1)\n\nlet f n m = let graph = (Array.make n []) in\n for i = 1 to m do\n scanf \"%d %d %d\\n\" (g graph)\n done;\n for i = 0 to n-1 do\n graph.(i) <- List.sort compare graph.(i)\n done;\n graph\n\nlet h graph ans = let queue = Queue.create () in\n let rec enqueue a = function\n | (v, c) :: lst -> if ans.(v) = 0 then Queue.add (a, v, c) queue; enqueue a lst\n | [] -> ()\n in let rec f () = if Queue.is_empty queue\n then `Ok\n else let (u, v, c) = Queue.take queue\n in if ans.(v) = 0\n then begin\n ans.(v) <- (if c > ans.(u) then c - ans.(u) else raise @@ failwith \"negative answer\");\n enqueue v graph.(v);\n f ()\n end\n else if c = ans.(v) + ans.(u)\n then begin\n enqueue v graph.(v);\n f ()\n end\n else raise @@ failwith \"incorrect\"\n in enqueue 0 graph.(0); f()\n\nlet cost lst = List.map (function (_, c) -> c) lst\nlet minimum lst = List.fold_left min 10000000000000 lst\n\nlet compute graph = let n = ref 0 in\n for i = 1 to minimum (cost graph.(0)) - 1 do\n let ans = Array.make (Array.length graph) 0\n in ans.(0) <- i;\n match h graph ans with\n | `Ok -> n := !n + 1\n | exception Failure s -> eprintf \"%s\\n\" s\n done;\n printf \"%d\\n\" !n\n\nlet () = compute @@ scanf \"%d %d\\n\" f", "problem_context": "Score : 600 points\n\nProblem Statement\n\nKenkoooo found a simple connected graph.\nThe vertices are numbered 1 through n.\nThe i-th edge connects Vertex u_i and v_i, and has a fixed integer s_i.\n\nKenkoooo is trying to write a positive integer in each vertex so that the following condition is satisfied:\n\nFor every edge i, the sum of the positive integers written in Vertex u_i and v_i is equal to s_i.\n\nFind the number of such ways to write positive integers in the vertices.\n\nConstraints\n\n2 \\leq n \\leq 10^5\n\n1 \\leq m \\leq 10^5\n\n1 \\leq u_i < v_i \\leq n\n\n2 \\leq s_i \\leq 10^9\n\nIf i\\neq j, then u_i \\neq u_j or v_i \\neq v_j.\n\nThe graph is connected.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nn m\nu_1 v_1 s_1\n:\nu_m v_m s_m\n\nOutput\n\nPrint the number of ways to write positive integers in the vertices so that the condition is satisfied.\n\nSample Input 1\n\n3 3\n1 2 3\n2 3 5\n1 3 4\n\nSample Output 1\n\n1\n\nThe condition will be satisfied if we write 1,2 and 3 in vertices 1,2 and 3, respectively.\nThere is no other way to satisfy the condition, so the answer is 1.\n\nSample Input 2\n\n4 3\n1 2 6\n2 3 7\n3 4 5\n\nSample Output 2\n\n3\n\nLet a,b,c and d be the numbers to write in vertices 1,2,3 and 4, respectively.\nThere are three quadruples (a,b,c,d) that satisfy the condition:\n\n(a,b,c,d)=(1,5,2,3)\n\n(a,b,c,d)=(2,4,3,2)\n\n(a,b,c,d)=(3,3,4,1)\n\nSample Input 3\n\n8 7\n1 2 1000000000\n2 3 2\n3 4 1000000000\n4 5 2\n5 6 1000000000\n6 7 2\n7 8 1000000000\n\nSample Output 3\n\n0", "sample_input": "3 3\n1 2 3\n2 3 5\n1 3 4\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03306", "source_text": "Score : 600 points\n\nProblem Statement\n\nKenkoooo found a simple connected graph.\nThe vertices are numbered 1 through n.\nThe i-th edge connects Vertex u_i and v_i, and has a fixed integer s_i.\n\nKenkoooo is trying to write a positive integer in each vertex so that the following condition is satisfied:\n\nFor every edge i, the sum of the positive integers written in Vertex u_i and v_i is equal to s_i.\n\nFind the number of such ways to write positive integers in the vertices.\n\nConstraints\n\n2 \\leq n \\leq 10^5\n\n1 \\leq m \\leq 10^5\n\n1 \\leq u_i < v_i \\leq n\n\n2 \\leq s_i \\leq 10^9\n\nIf i\\neq j, then u_i \\neq u_j or v_i \\neq v_j.\n\nThe graph is connected.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nn m\nu_1 v_1 s_1\n:\nu_m v_m s_m\n\nOutput\n\nPrint the number of ways to write positive integers in the vertices so that the condition is satisfied.\n\nSample Input 1\n\n3 3\n1 2 3\n2 3 5\n1 3 4\n\nSample Output 1\n\n1\n\nThe condition will be satisfied if we write 1,2 and 3 in vertices 1,2 and 3, respectively.\nThere is no other way to satisfy the condition, so the answer is 1.\n\nSample Input 2\n\n4 3\n1 2 6\n2 3 7\n3 4 5\n\nSample Output 2\n\n3\n\nLet a,b,c and d be the numbers to write in vertices 1,2,3 and 4, respectively.\nThere are three quadruples (a,b,c,d) that satisfy the condition:\n\n(a,b,c,d)=(1,5,2,3)\n\n(a,b,c,d)=(2,4,3,2)\n\n(a,b,c,d)=(3,3,4,1)\n\nSample Input 3\n\n8 7\n1 2 1000000000\n2 3 2\n3 4 1000000000\n4 5 2\n5 6 1000000000\n6 7 2\n7 8 1000000000\n\nSample Output 3\n\n0", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1593, "cpu_time_ms": 2105, "memory_kb": 40060}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s419201980", "group_id": "codeNet:p03307", "input_text": "Scanf.scanf \"%d\" (fun n ->\n Printf.printf \"%d\\n\" @@ if n mod 2 = 0 then n else n * 2\n)", "language": "OCaml", "metadata": {"date": 1599364482, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p03307.html", "problem_id": "p03307", "resource_group": "low_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/OCaml/s419201980.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s419201980", "user_id": "u342443598"}, "prompt_components": {"gold_output": "6\n", "input_to_evaluate": "Scanf.scanf \"%d\" (fun n ->\n Printf.printf \"%d\\n\" @@ if n mod 2 = 0 then n else 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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 7, "memory_kb": 3836}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s933242342", "group_id": "codeNet:p03309", "input_text": "let input_int_array n =\n\tArray.init n (fun _ -> Scanf.scanf \"%d \" (fun v -> v))\nlet get_int () = Scanf.scanf \"%d \" (fun v -> v)\n\nlet c a b =\n\tArray.fold_left (fun u v -> u + abs (v-b)) 0 a\n\nlet () =\n\tlet n = get_int ()\n\tin let a = Array.mapi\n\t\t(fun i v -> v - i - 1)\n\t\t(input_int_array n)\n\tin let b =\n\t\tlet b = Array.copy a\n\t\tin Array.sort Pervasives.compare b; b\n\tin\n\t(\n\t\tif n mod 2 = 1 then (\n\t\t\tc b b.(Array.length b / 2)\n\t\t) else (\n\t\t\tmin\n\t\t\t\t(c b b.(Array.length b / 2))\n\t\t\t\t(c b b.(Array.length b / 2 - 1))\n\t\t)\n\t)\n\t|> string_of_int |> print_endline", "language": "OCaml", "metadata": {"date": 1530500302, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03309.html", "problem_id": "p03309", "resource_group": "low_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/OCaml/s933242342.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s933242342", "user_id": "u481480055"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "let input_int_array n =\n\tArray.init n (fun _ -> Scanf.scanf \"%d \" (fun v -> v))\nlet get_int () = Scanf.scanf \"%d \" (fun v -> v)\n\nlet c a b =\n\tArray.fold_left (fun u v -> u + abs (v-b)) 0 a\n\nlet () =\n\tlet n = get_int ()\n\tin let a = Array.mapi\n\t\t(fun i v -> v - i - 1)\n\t\t(input_int_array n)\n\tin let b =\n\t\tlet b = Array.copy a\n\t\tin Array.sort Pervasives.compare b; b\n\tin\n\t(\n\t\tif n mod 2 = 1 then (\n\t\t\tc b b.(Array.length b / 2)\n\t\t) else (\n\t\t\tmin\n\t\t\t\t(c b b.(Array.length b / 2))\n\t\t\t\t(c b b.(Array.length b / 2 - 1))\n\t\t)\n\t)\n\t|> string_of_int |> print_endline", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 554, "cpu_time_ms": 168, "memory_kb": 8576}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s832039991", "group_id": "codeNet:p03310", "input_text": "open Batteries\nopen Printf\nlet () =\n let n = Scanf.scanf \"%d \" (fun a -> a) in\n let a_lst = Array.to_list @@ Array.init n (fun _ -> Scanf.scanf \"%d \" (fun a -> a)) in\n\n let rev_cumsum l =\n let rec aux last res = function\n | [] -> res\n | hd :: tl -> \n let last = last + hd in\n aux last (last::res) tl\n in\n aux 0 [] l\n in\n\n let l = List.rev (rev_cumsum a_lst) in\n let arr = Array.of_list l in\n let n = n-1 in\n let len = Array.length arr in\n\n let ans = ref max_int in\n let rec loop i j k arr cnt =\n if k < n then (\n let tmp =\n List.max [arr.(i); (arr.(j)-arr.(i)); (arr.(k)-arr.(j)); (arr.(len-1)-arr.(k));] -\n List.min [arr.(i); (arr.(j)-arr.(i)); (arr.(k)-arr.(j)); (arr.(len-1)-arr.(k));] in\n if !ans < tmp then () else ans := tmp;\n loop i j (k+1) arr (cnt+1)\n ) else (\n if j < n-1 then (\n loop i (j+1) (j+2) arr cnt\n ) else (\n if i < n-1 then (\n loop (i+1) (i+2) (i+3) arr cnt\n ) else (\n ()\n )\n )\n )\n in\n loop 0 1 2 arr 0;\n printf \"%d\\n\" !ans\n", "language": "OCaml", "metadata": {"date": 1530497328, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03310.html", "problem_id": "p03310", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03310/input.txt", "sample_output_relpath": "derived/input_output/data/p03310/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03310/OCaml/s832039991.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s832039991", "user_id": "u139013163"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "open Batteries\nopen Printf\nlet () =\n let n = Scanf.scanf \"%d \" (fun a -> a) in\n let a_lst = Array.to_list @@ Array.init n (fun _ -> Scanf.scanf \"%d \" (fun a -> a)) in\n\n let rev_cumsum l =\n let rec aux last res = function\n | [] -> res\n | hd :: tl -> \n let last = last + hd in\n aux last (last::res) tl\n in\n aux 0 [] l\n in\n\n let l = List.rev (rev_cumsum a_lst) in\n let arr = Array.of_list l in\n let n = n-1 in\n let len = Array.length arr in\n\n let ans = ref max_int in\n let rec loop i j k arr cnt =\n if k < n then (\n let tmp =\n List.max [arr.(i); (arr.(j)-arr.(i)); (arr.(k)-arr.(j)); (arr.(len-1)-arr.(k));] -\n List.min [arr.(i); (arr.(j)-arr.(i)); (arr.(k)-arr.(j)); (arr.(len-1)-arr.(k));] in\n if !ans < tmp then () else ans := tmp;\n loop i j (k+1) arr (cnt+1)\n ) else (\n if j < n-1 then (\n loop i (j+1) (j+2) arr cnt\n ) else (\n if i < n-1 then (\n loop (i+1) (i+2) (i+3) arr cnt\n ) else (\n ()\n )\n )\n )\n in\n loop 0 1 2 arr 0;\n printf \"%d\\n\" !ans\n", "problem_context": "Score : 600 points\n\nProblem Statement\n\nSnuke has an integer sequence A of length N.\n\nHe will make three cuts in A and divide it into four (non-empty) contiguous subsequences B, C, D and E.\nThe positions of the cuts can be freely chosen.\n\nLet P,Q,R,S be the sums of the elements in B,C,D,E, respectively.\nSnuke is happier when the absolute difference of the maximum and the minimum among P,Q,R,S is smaller.\nFind the minimum possible absolute difference of the maximum and the minimum among P,Q,R,S.\n\nConstraints\n\n4 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq A_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nFind the minimum possible absolute difference of the maximum and the minimum among P,Q,R,S.\n\nSample Input 1\n\n5\n3 2 4 1 2\n\nSample Output 1\n\n2\n\nIf we divide A as B,C,D,E=(3),(2),(4),(1,2), then P=3,Q=2,R=4,S=1+2=3.\nHere, the maximum and the minimum among P,Q,R,S are 4 and 2, with the absolute difference of 2.\nWe cannot make the absolute difference of the maximum and the minimum less than 2, so the answer is 2.\n\nSample Input 2\n\n10\n10 71 84 33 6 47 23 25 52 64\n\nSample Output 2\n\n36\n\nSample Input 3\n\n7\n1 2 3 1000000000 4 5 6\n\nSample Output 3\n\n999999994", "sample_input": "5\n3 2 4 1 2\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03310", "source_text": "Score : 600 points\n\nProblem Statement\n\nSnuke has an integer sequence A of length N.\n\nHe will make three cuts in A and divide it into four (non-empty) contiguous subsequences B, C, D and E.\nThe positions of the cuts can be freely chosen.\n\nLet P,Q,R,S be the sums of the elements in B,C,D,E, respectively.\nSnuke is happier when the absolute difference of the maximum and the minimum among P,Q,R,S is smaller.\nFind the minimum possible absolute difference of the maximum and the minimum among P,Q,R,S.\n\nConstraints\n\n4 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq A_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nFind the minimum possible absolute difference of the maximum and the minimum among P,Q,R,S.\n\nSample Input 1\n\n5\n3 2 4 1 2\n\nSample Output 1\n\n2\n\nIf we divide A as B,C,D,E=(3),(2),(4),(1,2), then P=3,Q=2,R=4,S=1+2=3.\nHere, the maximum and the minimum among P,Q,R,S are 4 and 2, with the absolute difference of 2.\nWe cannot make the absolute difference of the maximum and the minimum less than 2, so the answer is 2.\n\nSample Input 2\n\n10\n10 71 84 33 6 47 23 25 52 64\n\nSample Output 2\n\n36\n\nSample Input 3\n\n7\n1 2 3 1000000000 4 5 6\n\nSample Output 3\n\n999999994", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1089, "cpu_time_ms": 2104, "memory_kb": 16640}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s678081053", "group_id": "codeNet:p03312", "input_text": "(*\n * forall l r (p : forall n, l < n <= r -> bool),\n * ( exists m,\n * l < m <= r /\\ forall n H, p n H = true <-> m <= n ) ->\n * { m |\n * l < m <= r /\\ forall n H, p n H = true <-> m <= n }\n *)\nlet rec lower_bound l r p =\n if r <= 1 + l\n then r\n else let m = (l + r) / 2 in\n if p m\n then lower_bound l m p\n else lower_bound m r p\n\n(*\n * forall l r (p : forall n, l <= n < r -> bool),\n * ( exists m,\n * l <= m < r /\\ forall n H, p n H = true <-> n <= m ) ->\n * { m |\n * l <= m < r /\\ forall n H, p n H = true <-> n <= m }\n *)\nlet rec upper_bound l r p =\n if r <= 1 + l\n then l\n else let m = (l + r) / 2 in\n if p m \n then upper_bound m r p\n else upper_bound l m p\n\nlet () = Scanf.scanf \"%d\\n\" @@ fun n ->\n let as_ = Array.init n @@ fun _ ->\n Scanf.scanf \"%d \" @@ fun a -> a in\n let sum_as = Array.make (n + 1) 0 in\n (* sum_as.(i): 添字の範囲[0; i)におけるas_の要素の総和 *)\n (* 添字の範囲[i; j)の総和が欲しければ sum_as.(j) - sum_as.(i) で手に入る *)\n for i = 0 to n - 1 do\n sum_as.(i + 1) <- as_.(i) + sum_as.(i)\n done;\n begin\n List.concat @@ List.map (fun b1 ->\n List.concat @@ List.map (fun b2 ->\n (* 真ん中の切れ目だけ与えてやる *)\n Array.to_list @@ Array.init (n - 3) (fun j ->\n let j = j + 2 in\n (* B は[0; i),C は[i; j),D は[j; k),E は[k; n) *)\n (* PとQどちらを大きくするかをb1に委ね,にぶたんする *)\n let i =\n if b1 then\n (* P <= Q となる最大の添字 *)\n upper_bound 1 j @@ fun i ->\n sum_as.(i) <= sum_as.(j) - sum_as.(i)\n else \n (* P >= Q となる最小の添字 *)\n lower_bound 0 (j - 1) @@ fun i ->\n sum_as.(i) >= sum_as.(j) - sum_as.(i) in\n (* RとSどちらを大きくするかをb2に委ね,にぶたんする *)\n let k =\n if b2 then\n (* R <= S となる最大の添字 *)\n upper_bound (j + 1) n @@ fun k ->\n sum_as.(k) - sum_as.(j) <= sum_as.(n) - sum_as.(k)\n else \n (* R >= S となる最小の添字 *)\n lower_bound j (n - 1) @@ fun k ->\n sum_as.(k) - sum_as.(j) >= sum_as.(n) - sum_as.(k) in\n let pqrs = [ sum_as.(i); sum_as.(j) - sum_as.(i); sum_as.(k) - sum_as.(j); sum_as.(n) - sum_as.(k) ] in\n List.fold_left max min_int pqrs - List.fold_left min max_int pqrs)) [ true; false ]) [ true; false ]\n end\n |> List.fold_left min max_int\n |> Printf.printf \"%d\\n\"\n", "language": "OCaml", "metadata": {"date": 1530495380, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03312.html", "problem_id": "p03312", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03312/input.txt", "sample_output_relpath": "derived/input_output/data/p03312/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03312/OCaml/s678081053.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s678081053", "user_id": "u504158101"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "(*\n * forall l r (p : forall n, l < n <= r -> bool),\n * ( exists m,\n * l < m <= r /\\ forall n H, p n H = true <-> m <= n ) ->\n * { m |\n * l < m <= r /\\ forall n H, p n H = true <-> m <= n }\n *)\nlet rec lower_bound l r p =\n if r <= 1 + l\n then r\n else let m = (l + r) / 2 in\n if p m\n then lower_bound l m p\n else lower_bound m r p\n\n(*\n * forall l r (p : forall n, l <= n < r -> bool),\n * ( exists m,\n * l <= m < r /\\ forall n H, p n H = true <-> n <= m ) ->\n * { m |\n * l <= m < r /\\ forall n H, p n H = true <-> n <= m }\n *)\nlet rec upper_bound l r p =\n if r <= 1 + l\n then l\n else let m = (l + r) / 2 in\n if p m \n then upper_bound m r p\n else upper_bound l m p\n\nlet () = Scanf.scanf \"%d\\n\" @@ fun n ->\n let as_ = Array.init n @@ fun _ ->\n Scanf.scanf \"%d \" @@ fun a -> a in\n let sum_as = Array.make (n + 1) 0 in\n (* sum_as.(i): 添字の範囲[0; i)におけるas_の要素の総和 *)\n (* 添字の範囲[i; j)の総和が欲しければ sum_as.(j) - sum_as.(i) で手に入る *)\n for i = 0 to n - 1 do\n sum_as.(i + 1) <- as_.(i) + sum_as.(i)\n done;\n begin\n List.concat @@ List.map (fun b1 ->\n List.concat @@ List.map (fun b2 ->\n (* 真ん中の切れ目だけ与えてやる *)\n Array.to_list @@ Array.init (n - 3) (fun j ->\n let j = j + 2 in\n (* B は[0; i),C は[i; j),D は[j; k),E は[k; n) *)\n (* PとQどちらを大きくするかをb1に委ね,にぶたんする *)\n let i =\n if b1 then\n (* P <= Q となる最大の添字 *)\n upper_bound 1 j @@ fun i ->\n sum_as.(i) <= sum_as.(j) - sum_as.(i)\n else \n (* P >= Q となる最小の添字 *)\n lower_bound 0 (j - 1) @@ fun i ->\n sum_as.(i) >= sum_as.(j) - sum_as.(i) in\n (* RとSどちらを大きくするかをb2に委ね,にぶたんする *)\n let k =\n if b2 then\n (* R <= S となる最大の添字 *)\n upper_bound (j + 1) n @@ fun k ->\n sum_as.(k) - sum_as.(j) <= sum_as.(n) - sum_as.(k)\n else \n (* R >= S となる最小の添字 *)\n lower_bound j (n - 1) @@ fun k ->\n sum_as.(k) - sum_as.(j) >= sum_as.(n) - sum_as.(k) in\n let pqrs = [ sum_as.(i); sum_as.(j) - sum_as.(i); sum_as.(k) - sum_as.(j); sum_as.(n) - sum_as.(k) ] in\n List.fold_left max min_int pqrs - List.fold_left min max_int pqrs)) [ true; false ]) [ true; false ]\n end\n |> List.fold_left min max_int\n |> Printf.printf \"%d\\n\"\n", "problem_context": "Score : 600 points\n\nProblem Statement\n\nSnuke has an integer sequence A of length N.\n\nHe will make three cuts in A and divide it into four (non-empty) contiguous subsequences B, C, D and E.\nThe positions of the cuts can be freely chosen.\n\nLet P,Q,R,S be the sums of the elements in B,C,D,E, respectively.\nSnuke is happier when the absolute difference of the maximum and the minimum among P,Q,R,S is smaller.\nFind the minimum possible absolute difference of the maximum and the minimum among P,Q,R,S.\n\nConstraints\n\n4 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq A_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nFind the minimum possible absolute difference of the maximum and the minimum among P,Q,R,S.\n\nSample Input 1\n\n5\n3 2 4 1 2\n\nSample Output 1\n\n2\n\nIf we divide A as B,C,D,E=(3),(2),(4),(1,2), then P=3,Q=2,R=4,S=1+2=3.\nHere, the maximum and the minimum among P,Q,R,S are 4 and 2, with the absolute difference of 2.\nWe cannot make the absolute difference of the maximum and the minimum less than 2, so the answer is 2.\n\nSample Input 2\n\n10\n10 71 84 33 6 47 23 25 52 64\n\nSample Output 2\n\n36\n\nSample Input 3\n\n7\n1 2 3 1000000000 4 5 6\n\nSample Output 3\n\n999999994", "sample_input": "5\n3 2 4 1 2\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03312", "source_text": "Score : 600 points\n\nProblem Statement\n\nSnuke has an integer sequence A of length N.\n\nHe will make three cuts in A and divide it into four (non-empty) contiguous subsequences B, C, D and E.\nThe positions of the cuts can be freely chosen.\n\nLet P,Q,R,S be the sums of the elements in B,C,D,E, respectively.\nSnuke is happier when the absolute difference of the maximum and the minimum among P,Q,R,S is smaller.\nFind the minimum possible absolute difference of the maximum and the minimum among P,Q,R,S.\n\nConstraints\n\n4 \\leq N \\leq 2 \\times 10^5\n\n1 \\leq A_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nFind the minimum possible absolute difference of the maximum and the minimum among P,Q,R,S.\n\nSample Input 1\n\n5\n3 2 4 1 2\n\nSample Output 1\n\n2\n\nIf we divide A as B,C,D,E=(3),(2),(4),(1,2), then P=3,Q=2,R=4,S=1+2=3.\nHere, the maximum and the minimum among P,Q,R,S are 4 and 2, with the absolute difference of 2.\nWe cannot make the absolute difference of the maximum and the minimum less than 2, so the answer is 2.\n\nSample Input 2\n\n10\n10 71 84 33 6 47 23 25 52 64\n\nSample Output 2\n\n36\n\nSample Input 3\n\n7\n1 2 3 1000000000 4 5 6\n\nSample Output 3\n\n999999994", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2650, "cpu_time_ms": 483, "memory_kb": 56128}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s800775450", "group_id": "codeNet:p03315", "input_text": "let s = read_line ()\nlet ans = ref 0\nlet _ =\n String.iter (function '+' -> incr ans | _ -> decr ans) s;\n Printf.printf \"%d\\n\" !ans", "language": "OCaml", "metadata": {"date": 1562314427, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03315.html", "problem_id": "p03315", "resource_group": "low_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/OCaml/s800775450.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s800775450", "user_id": "u732304692"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "let s = read_line ()\nlet ans = ref 0\nlet _ =\n String.iter (function '+' -> incr ans | _ -> decr ans) s;\n Printf.printf \"%d\\n\" !ans", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s145929815", "group_id": "codeNet:p03315", "input_text": "let () =\n let s = read_line () in\n Array.init (String.length s) (fun i ->\n if s.[i] = '+' then 1\n else (-1))\n |> Array.fold_left ( + ) 0\n |> Printf.printf \"%d\\n\"\n", "language": "OCaml", "metadata": {"date": 1530506704, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03315.html", "problem_id": "p03315", "resource_group": "low_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/OCaml/s145929815.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s145929815", "user_id": "u504158101"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "let () =\n let s = read_line () in\n Array.init (String.length s) (fun i ->\n if s.[i] = '+' then 1\n else (-1))\n |> Array.fold_left ( + ) 0\n |> Printf.printf \"%d\\n\"\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nThere is always an integer in Takahashi's mind.\n\nInitially, the integer in Takahashi's mind is 0. Takahashi is now going to eat four symbols, each of which is + or -. When he eats +, the integer in his mind increases by 1; when he eats -, the integer in his mind decreases by 1.\n\nThe symbols Takahashi is going to eat are given to you as a string S. The i-th character in S is the i-th symbol for him to eat.\n\nFind the integer in Takahashi's mind after he eats all the symbols.\n\nConstraints\n\nThe length of S is 4.\n\nEach character in S is + or -.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the integer in Takahashi's mind after he eats all the symbols.\n\nSample Input 1\n\n+-++\n\nSample Output 1\n\n2\n\nInitially, the integer in Takahashi's mind is 0.\n\nThe first integer for him to eat is +. After eating it, the integer in his mind becomes 1.\n\nThe second integer to eat is -. After eating it, the integer in his mind becomes 0.\n\nThe third integer to eat is +. After eating it, the integer in his mind becomes 1.\n\nThe fourth integer to eat is +. After eating it, the integer in his mind becomes 2.\n\nThus, the integer in Takahashi's mind after he eats all the symbols is 2.\n\nSample Input 2\n\n-+--\n\nSample Output 2\n\n-2\n\nSample Input 3\n\n----\n\nSample Output 3\n\n-4", "sample_input": "+-++\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03315", "source_text": "Score : 100 points\n\nProblem Statement\n\nThere is always an integer in Takahashi's mind.\n\nInitially, the integer in Takahashi's mind is 0. Takahashi is now going to eat four symbols, each of which is + or -. When he eats +, the integer in his mind increases by 1; when he eats -, the integer in his mind decreases by 1.\n\nThe symbols Takahashi is going to eat are given to you as a string S. The i-th character in S is the i-th symbol for him to eat.\n\nFind the integer in Takahashi's mind after he eats all the symbols.\n\nConstraints\n\nThe length of S is 4.\n\nEach character in S is + or -.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the integer in Takahashi's mind after he eats all the symbols.\n\nSample Input 1\n\n+-++\n\nSample Output 1\n\n2\n\nInitially, the integer in Takahashi's mind is 0.\n\nThe first integer for him to eat is +. After eating it, the integer in his mind becomes 1.\n\nThe second integer to eat is -. After eating it, the integer in his mind becomes 0.\n\nThe third integer to eat is +. After eating it, the integer in his mind becomes 1.\n\nThe fourth integer to eat is +. After eating it, the integer in his mind becomes 2.\n\nThus, the integer in Takahashi's mind after he eats all the symbols is 2.\n\nSample Input 2\n\n-+--\n\nSample Output 2\n\n-2\n\nSample Input 3\n\n----\n\nSample Output 3\n\n-4", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 172, "cpu_time_ms": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s103333974", "group_id": "codeNet:p03316", "input_text": "let rec dig_sum n = if n <= 0 then 0 else n mod 10 + dig_sum (n / 10)\nlet () =\n Scanf.scanf \"%d\" (fun n -> if n mod dig_sum n = 0 then \"Yes\" else \"No\")\n |> print_endline", "language": "OCaml", "metadata": {"date": 1531254244, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03316.html", "problem_id": "p03316", "resource_group": "low_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/OCaml/s103333974.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s103333974", "user_id": "u798181098"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "let rec dig_sum n = if n <= 0 then 0 else n mod 10 + dig_sum (n / 10)\nlet () =\n Scanf.scanf \"%d\" (fun n -> if n mod dig_sum n = 0 then \"Yes\" else \"No\")\n |> print_endline", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s557629232", "group_id": "codeNet:p03317", "input_text": "let () =\n let n, k = Scanf.scanf \"%d %d\" (fun n k -> n, k) in\n let a =\n Array.init n (fun _ ->\n Scanf.scanf \" %d\" (fun x -> x)) in\n let (_, i1) = Array.fold_left (fun (i, res) x ->\n if x = 1 then\n (i+1, res)\n else\n (i+1, res)\n ) (0, 0) a in\n Printf.printf \"%d\\n\"\n (if i1 = 0 then\n (n) / (k-1)\n else if i1 < k then\n 1 + (n-i1) / (k-1)\n else\n 1 + (i1) / (k-1) + (n-i1)/(k-1))\n", "language": "OCaml", "metadata": {"date": 1529806031, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03317.html", "problem_id": "p03317", "resource_group": "low_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/OCaml/s557629232.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s557629232", "user_id": "u614063956"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "let () =\n let n, k = Scanf.scanf \"%d %d\" (fun n k -> n, k) in\n let a =\n Array.init n (fun _ ->\n Scanf.scanf \" %d\" (fun x -> x)) in\n let (_, i1) = Array.fold_left (fun (i, res) x ->\n if x = 1 then\n (i+1, res)\n else\n (i+1, res)\n ) (0, 0) a in\n Printf.printf \"%d\\n\"\n (if i1 = 0 then\n (n) / (k-1)\n else if i1 < k then\n 1 + (n-i1) / (k-1)\n else\n 1 + (i1) / (k-1) + (n-i1)/(k-1))\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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 486, "cpu_time_ms": 25, "memory_kb": 4864}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s325291443", "group_id": "codeNet:p03319", "input_text": "let () = Scanf.scanf \"%d %d\\n\" @@ fun n k ->\n let as_ = Array.init n @@ fun _ -> Scanf.scanf \"%d \" @@ fun a -> a in\n Printf.printf \"%d\\n\" @@ n / (k - 1)\n", "language": "OCaml", "metadata": {"date": 1529809325, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03319.html", "problem_id": "p03319", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03319/input.txt", "sample_output_relpath": "derived/input_output/data/p03319/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03319/OCaml/s325291443.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s325291443", "user_id": "u504158101"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "let () = Scanf.scanf \"%d %d\\n\" @@ fun n k ->\n let as_ = Array.init n @@ fun _ -> Scanf.scanf \"%d \" @@ fun a -> a in\n Printf.printf \"%d\\n\" @@ n / (k - 1)\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N.\n\nOn this sequence, Snuke can perform the following operation:\n\nChoose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value among the chosen elements.\n\nSnuke would like to make all the elements in this sequence equal by repeating the operation above some number of times.\nFind the minimum number of operations required.\nIt can be proved that, Under the constraints of this problem, this objective is always achievable.\n\nConstraints\n\n2 \\leq K \\leq N \\leq 100000\n\nA_1, A_2, ..., A_N is a permutation of 1, 2, ..., N.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the minimum number of operations required.\n\nSample Input 1\n\n4 3\n2 3 1 4\n\nSample Output 1\n\n2\n\nOne optimal strategy is as follows:\n\nIn the first operation, choose the first, second and third elements. The sequence A becomes 1, 1, 1, 4.\n\nIn the second operation, choose the second, third and fourth elements. The sequence A becomes 1, 1, 1, 1.\n\nSample Input 2\n\n3 3\n1 2 3\n\nSample Output 2\n\n1\n\nSample Input 3\n\n8 3\n7 3 1 8 4 6 2 5\n\nSample Output 3\n\n4", "sample_input": "4 3\n2 3 1 4\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03319", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N.\n\nOn this sequence, Snuke can perform the following operation:\n\nChoose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value among the chosen elements.\n\nSnuke would like to make all the elements in this sequence equal by repeating the operation above some number of times.\nFind the minimum number of operations required.\nIt can be proved that, Under the constraints of this problem, this objective is always achievable.\n\nConstraints\n\n2 \\leq K \\leq N \\leq 100000\n\nA_1, A_2, ..., A_N is a permutation of 1, 2, ..., N.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the minimum number of operations required.\n\nSample Input 1\n\n4 3\n2 3 1 4\n\nSample Output 1\n\n2\n\nOne optimal strategy is as follows:\n\nIn the first operation, choose the first, second and third elements. The sequence A becomes 1, 1, 1, 4.\n\nIn the second operation, choose the second, third and fourth elements. The sequence A becomes 1, 1, 1, 1.\n\nSample Input 2\n\n3 3\n1 2 3\n\nSample Output 2\n\n1\n\nSample Input 3\n\n8 3\n7 3 1 8 4 6 2 5\n\nSample Output 3\n\n4", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 155, "cpu_time_ms": 26, "memory_kb": 5248}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s806427329", "group_id": "codeNet:p03320", "input_text": "open Scanf\nopen Printf\n\nlet id a = a\nlet pair a b = a, b\nlet triplet a b c = a, b, c\n\nlet rec scan_list = function\n | 1 -> scanf \"%d\" (fun k -> [k])\n | n -> scanf \"%d \" (fun k -> k :: scan_list (n-1))\n\nlet rec s = function\n | 0 -> 0\n | n -> n mod 10 + s (n / 10)\n\nlet sunuke n = float_of_int n /. float_of_int (s n)\n\nlet rec repeat c = function\n | 0 -> []\n | n -> c :: repeat c (n-1)\n\nlet f n = for i = 1 to n do\n printf \"%d99\\n\" i\n done\n\nlet g n = if n > 9\n then begin\n for i = 1 to 9 do\n printf \"%d9\\n\" i\n done;\n f (n-9)\n end\n else\n for i = 1 to n do\n printf \"%d9\\n\" i\n done\n\nlet h n = if n > 9\n then begin\n for i = 1 to 9 do\n printf \"%d\\n\" i\n done;\n g (n-9)\n end\n else\n for i = 1 to 9 do\n printf \"%d\\n\" i\n done\n\nlet () = scanf \"%d\\n\" h", "language": "OCaml", "metadata": {"date": 1529806572, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03320.html", "problem_id": "p03320", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03320/input.txt", "sample_output_relpath": "derived/input_output/data/p03320/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03320/OCaml/s806427329.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s806427329", "user_id": "u379439911"}, "prompt_components": {"gold_output": "1\n2\n3\n4\n5\n6\n7\n8\n9\n19\n", "input_to_evaluate": "open Scanf\nopen Printf\n\nlet id a = a\nlet pair a b = a, b\nlet triplet a b c = a, b, c\n\nlet rec scan_list = function\n | 1 -> scanf \"%d\" (fun k -> [k])\n | n -> scanf \"%d \" (fun k -> k :: scan_list (n-1))\n\nlet rec s = function\n | 0 -> 0\n | n -> n mod 10 + s (n / 10)\n\nlet sunuke n = float_of_int n /. float_of_int (s n)\n\nlet rec repeat c = function\n | 0 -> []\n | n -> c :: repeat c (n-1)\n\nlet f n = for i = 1 to n do\n printf \"%d99\\n\" i\n done\n\nlet g n = if n > 9\n then begin\n for i = 1 to 9 do\n printf \"%d9\\n\" i\n done;\n f (n-9)\n end\n else\n for i = 1 to n do\n printf \"%d9\\n\" i\n done\n\nlet h n = if n > 9\n then begin\n for i = 1 to 9 do\n printf \"%d\\n\" i\n done;\n g (n-9)\n end\n else\n for i = 1 to 9 do\n printf \"%d\\n\" i\n done\n\nlet () = scanf \"%d\\n\" h", "problem_context": "Score : 500 points\n\nProblem Statement\n\nLet S(n) denote the sum of the digits in the decimal notation of n.\nFor example, S(123) = 1 + 2 + 3 = 6.\n\nWe will call an integer n a Snuke number when, for all positive integers m such that m > n, \\frac{n}{S(n)} \\leq \\frac{m}{S(m)} holds.\n\nGiven an integer K, list the K smallest Snuke numbers.\n\nConstraints\n\n1 \\leq K\n\nThe K-th smallest Snuke number is not greater than 10^{15}.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK\n\nOutput\n\nPrint K lines. The i-th line should contain the i-th smallest Snuke number.\n\nSample Input 1\n\n10\n\nSample Output 1\n\n1\n2\n3\n4\n5\n6\n7\n8\n9\n19", "sample_input": "10\n"}, "reference_outputs": ["1\n2\n3\n4\n5\n6\n7\n8\n9\n19\n"], "source_document_id": "p03320", "source_text": "Score : 500 points\n\nProblem Statement\n\nLet S(n) denote the sum of the digits in the decimal notation of n.\nFor example, S(123) = 1 + 2 + 3 = 6.\n\nWe will call an integer n a Snuke number when, for all positive integers m such that m > n, \\frac{n}{S(n)} \\leq \\frac{m}{S(m)} holds.\n\nGiven an integer K, list the K smallest Snuke numbers.\n\nConstraints\n\n1 \\leq K\n\nThe K-th smallest Snuke number is not greater than 10^{15}.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK\n\nOutput\n\nPrint K lines. The i-th line should contain the i-th smallest Snuke number.\n\nSample Input 1\n\n10\n\nSample Output 1\n\n1\n2\n3\n4\n5\n6\n7\n8\n9\n19", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 804, "cpu_time_ms": 1, "memory_kb": 512}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s094188163", "group_id": "codeNet:p03323", "input_text": "Scanf.scanf \"%d %d\" (fun a b ->\n print_endline @@ if a <= 8 && b <= 8 then \"Yay!\" else \":(\"\n)", "language": "OCaml", "metadata": {"date": 1587780326, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03323.html", "problem_id": "p03323", "resource_group": "low_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/OCaml/s094188163.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s094188163", "user_id": "u342443598"}, "prompt_components": {"gold_output": "Yay!\n", "input_to_evaluate": "Scanf.scanf \"%d %d\" (fun a b ->\n print_endline @@ if a <= 8 && b <= 8 then \"Yay!\" else \":(\"\n)", "problem_context": "Score: 100 points\n\nProblem Statement\n\nE869120's and square1001's 16-th birthday is coming soon.\n\nTakahashi from AtCoder Kingdom gave them a round cake cut into 16 equal fan-shaped pieces.\n\nE869120 and square1001 were just about to eat A and B of those pieces, respectively,\n\nwhen they found a note attached to the cake saying that \"the same person should not take two adjacent pieces of cake\".\n\nCan both of them obey the instruction in the note and take desired numbers of pieces of cake?\n\nConstraints\n\nA and B are integers between 1 and 16 (inclusive).\n\nA+B is at most 16.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nIf both E869120 and square1001 can obey the instruction in the note and take desired numbers of pieces of cake, print Yay!; otherwise, print :(.\n\nSample Input 1\n\n5 4\n\nSample Output 1\n\nYay!\n\nBoth of them can take desired number of pieces as follows:\n\nSample Input 2\n\n8 8\n\nSample Output 2\n\nYay!\n\nBoth of them can take desired number of pieces as follows:\n\nSample Input 3\n\n11 4\n\nSample Output 3\n\n:(\n\nIn this case, there is no way for them to take desired number of pieces, unfortunately.", "sample_input": "5 4\n"}, "reference_outputs": ["Yay!\n"], "source_document_id": "p03323", "source_text": "Score: 100 points\n\nProblem Statement\n\nE869120's and square1001's 16-th birthday is coming soon.\n\nTakahashi from AtCoder Kingdom gave them a round cake cut into 16 equal fan-shaped pieces.\n\nE869120 and square1001 were just about to eat A and B of those pieces, respectively,\n\nwhen they found a note attached to the cake saying that \"the same person should not take two adjacent pieces of cake\".\n\nCan both of them obey the instruction in the note and take desired numbers of pieces of cake?\n\nConstraints\n\nA and B are integers between 1 and 16 (inclusive).\n\nA+B is at most 16.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nIf both E869120 and square1001 can obey the instruction in the note and take desired numbers of pieces of cake, print Yay!; otherwise, print :(.\n\nSample Input 1\n\n5 4\n\nSample Output 1\n\nYay!\n\nBoth of them can take desired number of pieces as follows:\n\nSample Input 2\n\n8 8\n\nSample Output 2\n\nYay!\n\nBoth of them can take desired number of pieces as follows:\n\nSample Input 3\n\n11 4\n\nSample Output 3\n\n:(\n\nIn this case, there is no way for them to take desired number of pieces, unfortunately.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s085684688", "group_id": "codeNet:p03323", "input_text": "let a, b = Scanf.scanf \" %d %d\" @@ fun a b -> a, b\nlet _ = print_endline @@ if a <= 8 && b <= 8 then \"Yay!\" else \":(\"", "language": "OCaml", "metadata": {"date": 1565014139, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03323.html", "problem_id": "p03323", "resource_group": "low_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/OCaml/s085684688.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s085684688", "user_id": "u732304692"}, "prompt_components": {"gold_output": "Yay!\n", "input_to_evaluate": "let a, b = Scanf.scanf \" %d %d\" @@ fun a b -> a, b\nlet _ = print_endline @@ if a <= 8 && b <= 8 then \"Yay!\" else \":(\"", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s754859257", "group_id": "codeNet:p03323", "input_text": "let () = Scanf.scanf \"%d %d\" @@ fun a b ->\n if a <= 8 && b <= 8 then print_endline \"Yay!\"\n else print_endline \":(\"\n", "language": "OCaml", "metadata": {"date": 1529198867, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03323.html", "problem_id": "p03323", "resource_group": "low_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/OCaml/s754859257.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s754859257", "user_id": "u504158101"}, "prompt_components": {"gold_output": "Yay!\n", "input_to_evaluate": "let () = Scanf.scanf \"%d %d\" @@ fun a b ->\n if a <= 8 && b <= 8 then print_endline \"Yay!\"\n else print_endline \":(\"\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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s065372198", "group_id": "codeNet:p03325", "input_text": "Scanf.scanf \"%d\" (fun n ->\n let a = Array.init n (fun _ -> Scanf.scanf \" %d\" (fun a -> a)) in\n let calc t =\n let rec loop i acc =\n if i mod 2 = 0 then loop (i lsr 1) (acc + 1) else acc\n in\n loop t 0\n in\n Array.fold_left (fun acc v -> acc + calc v) 0 a |> Printf.printf \"%d\\n\"\n)", "language": "OCaml", "metadata": {"date": 1587620675, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03325.html", "problem_id": "p03325", "resource_group": "low_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/OCaml/s065372198.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s065372198", "user_id": "u342443598"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "Scanf.scanf \"%d\" (fun n ->\n let a = Array.init n (fun _ -> Scanf.scanf \" %d\" (fun a -> a)) in\n let calc t =\n let rec loop i acc =\n if i mod 2 = 0 then loop (i lsr 1) (acc + 1) else acc\n in\n loop t 0\n in\n Array.fold_left (fun acc v -> acc + calc v) 0 a |> Printf.printf \"%d\\n\"\n)", "problem_context": "Score: 300 points\n\nProblem Statement\n\nAs AtCoder Beginner Contest 100 is taking place, the office of AtCoder, Inc. is decorated with a sequence of length N, a = {a_1, a_2, a_3, ..., a_N}.\n\nSnuke, an employee, would like to play with this sequence.\n\nSpecifically, he would like to repeat the following operation as many times as possible:\n\nFor every i satisfying 1 \\leq i \\leq N, perform one of the following: \"divide a_i by 2\" and \"multiply a_i by 3\".\nHere, choosing \"multiply a_i by 3\" for every i is not allowed, and the value of a_i after the operation must be an integer.\n\nAt most how many operations can be performed?\n\nConstraints\n\nN is an integer between 1 and 10 \\ 000 (inclusive).\n\na_i is an integer between 1 and 1 \\ 000 \\ 000 \\ 000 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 a_3 ... a_N\n\nOutput\n\nPrint the maximum number of operations that Snuke can perform.\n\nSample Input 1\n\n3\n5 2 4\n\nSample Output 1\n\n3\n\nThe sequence is initially {5, 2, 4}. Three operations can be performed as follows:\n\nFirst, multiply a_1 by 3, multiply a_2 by 3 and divide a_3 by 2. The sequence is now {15, 6, 2}.\n\nNext, multiply a_1 by 3, divide a_2 by 2 and multiply a_3 by 3. The sequence is now {45, 3, 6}.\n\nFinally, multiply a_1 by 3, multiply a_2 by 3 and divide a_3 by 2. The sequence is now {135, 9, 3}.\n\nSample Input 2\n\n4\n631 577 243 199\n\nSample Output 2\n\n0\n\nNo operation can be performed since all the elements are odd. Thus, the answer is 0.\n\nSample Input 3\n\n10\n2184 2126 1721 1800 1024 2528 3360 1945 1280 1776\n\nSample Output 3\n\n39", "sample_input": "3\n5 2 4\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03325", "source_text": "Score: 300 points\n\nProblem Statement\n\nAs AtCoder Beginner Contest 100 is taking place, the office of AtCoder, Inc. is decorated with a sequence of length N, a = {a_1, a_2, a_3, ..., a_N}.\n\nSnuke, an employee, would like to play with this sequence.\n\nSpecifically, he would like to repeat the following operation as many times as possible:\n\nFor every i satisfying 1 \\leq i \\leq N, perform one of the following: \"divide a_i by 2\" and \"multiply a_i by 3\".\nHere, choosing \"multiply a_i by 3\" for every i is not allowed, and the value of a_i after the operation must be an integer.\n\nAt most how many operations can be performed?\n\nConstraints\n\nN is an integer between 1 and 10 \\ 000 (inclusive).\n\na_i is an integer between 1 and 1 \\ 000 \\ 000 \\ 000 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 a_3 ... a_N\n\nOutput\n\nPrint the maximum number of operations that Snuke can perform.\n\nSample Input 1\n\n3\n5 2 4\n\nSample Output 1\n\n3\n\nThe sequence is initially {5, 2, 4}. Three operations can be performed as follows:\n\nFirst, multiply a_1 by 3, multiply a_2 by 3 and divide a_3 by 2. The sequence is now {15, 6, 2}.\n\nNext, multiply a_1 by 3, divide a_2 by 2 and multiply a_3 by 3. The sequence is now {45, 3, 6}.\n\nFinally, multiply a_1 by 3, multiply a_2 by 3 and divide a_3 by 2. The sequence is now {135, 9, 3}.\n\nSample Input 2\n\n4\n631 577 243 199\n\nSample Output 2\n\n0\n\nNo operation can be performed since all the elements are odd. Thus, the answer is 0.\n\nSample Input 3\n\n10\n2184 2126 1721 1800 1024 2528 3360 1945 1280 1776\n\nSample Output 3\n\n39", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 6, "memory_kb": 2688}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s261395529", "group_id": "codeNet:p03327", "input_text": "open Scanf\nopen Printf\n\nlet () = scanf \"%d\" (fun k -> if k > 999 then printf \"ABC\\n\" else printf \"ABD\\n\")", "language": "OCaml", "metadata": {"date": 1528679758, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03327.html", "problem_id": "p03327", "resource_group": "low_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/OCaml/s261395529.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s261395529", "user_id": "u379439911"}, "prompt_components": {"gold_output": "ABC\n", "input_to_evaluate": "open Scanf\nopen Printf\n\nlet () = scanf \"%d\" (fun k -> if k > 999 then printf \"ABC\\n\" else printf \"ABD\\n\")", "problem_context": "Score : 100 points\n\nProblem Statement\n\nDecades have passed since the beginning of AtCoder Beginner Contest.\n\nThe contests are labeled as ABC001, ABC002, ... from the first round, but after the 999-th round ABC999, a problem occurred: how the future rounds should be labeled?\n\nIn the end, the labels for the rounds from the 1000-th to the 1998-th are decided: ABD001, ABD002, ..., ABD999.\n\nYou are given an integer N between 1 and 1998 (inclusive). Print the first three characters of the label of the N-th round of AtCoder Beginner Contest.\n\nConstraints\n\n1 \\leq N \\leq 1998\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the first three characters of the label of the N-th round of AtCoder Beginner Contest.\n\nSample Input 1\n\n999\n\nSample Output 1\n\nABC\n\nThe 999-th round of AtCoder Beginner Contest is labeled as ABC999.\n\nSample Input 2\n\n1000\n\nSample Output 2\n\nABD\n\nThe 1000-th round of AtCoder Beginner Contest is labeled as ABD001.\n\nSample Input 3\n\n1481\n\nSample Output 3\n\nABD\n\nThe 1481-th round of AtCoder Beginner Contest is labeled as ABD482.", "sample_input": "999\n"}, "reference_outputs": ["ABC\n"], "source_document_id": "p03327", "source_text": "Score : 100 points\n\nProblem Statement\n\nDecades have passed since the beginning of AtCoder Beginner Contest.\n\nThe contests are labeled as ABC001, ABC002, ... from the first round, but after the 999-th round ABC999, a problem occurred: how the future rounds should be labeled?\n\nIn the end, the labels for the rounds from the 1000-th to the 1998-th are decided: ABD001, ABD002, ..., ABD999.\n\nYou are given an integer N between 1 and 1998 (inclusive). Print the first three characters of the label of the N-th round of AtCoder Beginner Contest.\n\nConstraints\n\n1 \\leq N \\leq 1998\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the first three characters of the label of the N-th round of AtCoder Beginner Contest.\n\nSample Input 1\n\n999\n\nSample Output 1\n\nABC\n\nThe 999-th round of AtCoder Beginner Contest is labeled as ABC999.\n\nSample Input 2\n\n1000\n\nSample Output 2\n\nABD\n\nThe 1000-th round of AtCoder Beginner Contest is labeled as ABD001.\n\nSample Input 3\n\n1481\n\nSample Output 3\n\nABD\n\nThe 1481-th round of AtCoder Beginner Contest is labeled as ABD482.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s420598614", "group_id": "codeNet:p03329", "input_text": "let rec take_while pred = function\n [] -> []\n | (x::xs) -> if pred x then x :: take_while pred xs else []\n\nlet rec scan_n n f v = if n <= 0 then [] else v :: scan_n (n-1) f (f v)\n\nlet arr = Array.init 101010 (fun i -> i)\nlet () = Scanf.scanf \"%d\" (fun n ->\n Array.init (n+1) (fun i ->\n [6; 9] |> List.iter (fun m ->\n scan_n 20 (( * ) m) 1 |> take_while ((>=) i) |> List.iter (fun j ->\n arr.(i) <- min arr.(i) (arr.(i - j) + 1)))) |> ignore;\n Printf.printf \"%d\\n\" arr.(n))\n", "language": "OCaml", "metadata": {"date": 1529283004, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03329.html", "problem_id": "p03329", "resource_group": "low_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/OCaml/s420598614.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s420598614", "user_id": "u798181098"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "let rec take_while pred = function\n [] -> []\n | (x::xs) -> if pred x then x :: take_while pred xs else []\n\nlet rec scan_n n f v = if n <= 0 then [] else v :: scan_n (n-1) f (f v)\n\nlet arr = Array.init 101010 (fun i -> i)\nlet () = Scanf.scanf \"%d\" (fun n ->\n Array.init (n+1) (fun i ->\n [6; 9] |> List.iter (fun m ->\n scan_n 20 (( * ) m) 1 |> take_while ((>=) i) |> List.iter (fun j ->\n arr.(i) <- min arr.(i) (arr.(i - j) + 1)))) |> ignore;\n Printf.printf \"%d\\n\" arr.(n))\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nTo make it difficult to withdraw money, a certain bank allows its customers to withdraw only one of the following amounts in one operation:\n\n1 yen (the currency of Japan)\n\n6 yen, 6^2(=36) yen, 6^3(=216) yen, ...\n\n9 yen, 9^2(=81) yen, 9^3(=729) yen, ...\n\nAt least how many operations are required to withdraw exactly N yen in total?\n\nIt is not allowed to re-deposit the money you withdrew.\n\nConstraints\n\n1 \\leq N \\leq 100000\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nIf at least x operations are required to withdraw exactly N yen in total, print x.\n\nSample Input 1\n\n127\n\nSample Output 1\n\n4\n\nBy withdrawing 1 yen, 9 yen, 36(=6^2) yen and 81(=9^2) yen, we can withdraw 127 yen in four operations.\n\nSample Input 2\n\n3\n\nSample Output 2\n\n3\n\nBy withdrawing 1 yen three times, we can withdraw 3 yen in three operations.\n\nSample Input 3\n\n44852\n\nSample Output 3\n\n16", "sample_input": "127\n"}, "reference_outputs": ["4\n"], "source_document_id": "p03329", "source_text": "Score : 300 points\n\nProblem Statement\n\nTo make it difficult to withdraw money, a certain bank allows its customers to withdraw only one of the following amounts in one operation:\n\n1 yen (the currency of Japan)\n\n6 yen, 6^2(=36) yen, 6^3(=216) yen, ...\n\n9 yen, 9^2(=81) yen, 9^3(=729) yen, ...\n\nAt least how many operations are required to withdraw exactly N yen in total?\n\nIt is not allowed to re-deposit the money you withdrew.\n\nConstraints\n\n1 \\leq N \\leq 100000\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nIf at least x operations are required to withdraw exactly N yen in total, print x.\n\nSample Input 1\n\n127\n\nSample Output 1\n\n4\n\nBy withdrawing 1 yen, 9 yen, 36(=6^2) yen and 81(=9^2) yen, we can withdraw 127 yen in four operations.\n\nSample Input 2\n\n3\n\nSample Output 2\n\n3\n\nBy withdrawing 1 yen three times, we can withdraw 3 yen in three operations.\n\nSample Input 3\n\n44852\n\nSample Output 3\n\n16", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 493, "cpu_time_ms": 66, "memory_kb": 5888}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s029422120", "group_id": "codeNet:p03330", "input_text": "(* 与えられたリストからk要素を選ぶ順列 *)\nlet perm k xs =\n let rec perm_aux trace n k i xs ys acc =\n match k, i, xs with\n | 0, _, _ -> trace :: acc\n | _, 0, _ -> acc\n | _, _, [] -> perm_aux trace n k i (List.rev ys) [] acc\n | _, _, x :: xs ->\n perm_aux trace n k (i - 1) xs (x :: ys) @@\n perm_aux (x :: trace) (n - 1) (k - 1) (n - 1) xs ys acc in\n let n = List.length xs in\n perm_aux [] n k n xs [] []\n\nlet () = Scanf.scanf \"%d %d\\n\" @@ fun n c ->\n let dss =\n Array.init c @@ fun _ ->\n Array.init c @@ fun _ ->\n Scanf.scanf \"%d \" @@ fun d -> d in\n let css =\n Array.init n @@ fun _ ->\n Array.init n @@ fun _ ->\n Scanf.scanf \"%d \" @@ fun c -> c in\n let colours = Array.make_matrix 3 c 0 in\n Array.iteri (fun i ->\n Array.iteri (fun j c ->\n colours.((i + j + 2) mod 3).(c - 1) <- colours.((i + j + 2) mod 3).(c - 1) + 1)) css;\n Array.init c (fun c -> c)\n |> Array.to_list\n |> perm 3\n |> List.map (List.mapi (fun m y ->\n Array.mapi (fun x n -> n * dss.(x).(y)) colours.(m)\n |> Array.fold_left ( + ) 0))\n |> List.map (List.fold_left ( + ) 0)\n |> List.fold_left min max_int\n |> Printf.printf \"%d\\n\"\n\n", "language": "OCaml", "metadata": {"date": 1589611391, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03330.html", "problem_id": "p03330", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03330/input.txt", "sample_output_relpath": "derived/input_output/data/p03330/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03330/OCaml/s029422120.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s029422120", "user_id": "u504158101"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "(* 与えられたリストからk要素を選ぶ順列 *)\nlet perm k xs =\n let rec perm_aux trace n k i xs ys acc =\n match k, i, xs with\n | 0, _, _ -> trace :: acc\n | _, 0, _ -> acc\n | _, _, [] -> perm_aux trace n k i (List.rev ys) [] acc\n | _, _, x :: xs ->\n perm_aux trace n k (i - 1) xs (x :: ys) @@\n perm_aux (x :: trace) (n - 1) (k - 1) (n - 1) xs ys acc in\n let n = List.length xs in\n perm_aux [] n k n xs [] []\n\nlet () = Scanf.scanf \"%d %d\\n\" @@ fun n c ->\n let dss =\n Array.init c @@ fun _ ->\n Array.init c @@ fun _ ->\n Scanf.scanf \"%d \" @@ fun d -> d in\n let css =\n Array.init n @@ fun _ ->\n Array.init n @@ fun _ ->\n Scanf.scanf \"%d \" @@ fun c -> c in\n let colours = Array.make_matrix 3 c 0 in\n Array.iteri (fun i ->\n Array.iteri (fun j c ->\n colours.((i + j + 2) mod 3).(c - 1) <- colours.((i + j + 2) mod 3).(c - 1) + 1)) css;\n Array.init c (fun c -> c)\n |> Array.to_list\n |> perm 3\n |> List.map (List.mapi (fun m y ->\n Array.mapi (fun x n -> n * dss.(x).(y)) colours.(m)\n |> Array.fold_left ( + ) 0))\n |> List.map (List.fold_left ( + ) 0)\n |> List.fold_left min max_int\n |> Printf.printf \"%d\\n\"\n\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nThere is a grid with N rows and N columns of squares. Let (i,j) be the square at the i-th row from the top and the j-th column from the left.\n\nThese squares have to be painted in one of the C colors from Color 1 to Color C. Initially, (i,j) is painted in Color c_{i,j}.\n\nWe say the grid is a good grid when the following condition is met for all i,j,x,y satisfying 1 \\leq i,j,x,y \\leq N:\n\nIf (i+j) \\% 3=(x+y) \\% 3, the color of (i,j) and the color of (x,y) are the same.\n\nIf (i+j) \\% 3 \\neq (x+y) \\% 3, the color of (i,j) and the color of (x,y) are different.\n\nHere, X \\% Y represents X modulo Y.\n\nWe will repaint zero or more squares so that the grid will be a good grid.\n\nFor a square, the wrongness when the color of the square is X before repainting and Y after repainting, is D_{X,Y}.\n\nFind the minimum possible sum of the wrongness of all the squares.\n\nConstraints\n\n1 \\leq N \\leq 500\n\n3 \\leq C \\leq 30\n\n1 \\leq D_{i,j} \\leq 1000 (i \\neq j),D_{i,j}=0 (i=j)\n\n1 \\leq c_{i,j} \\leq C\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN C\nD_{1,1} ... D_{1,C}\n:\nD_{C,1} ... D_{C,C}\nc_{1,1} ... c_{1,N}\n:\nc_{N,1} ... c_{N,N}\n\nOutput\n\nIf the minimum possible sum of the wrongness of all the squares is x, print x.\n\nSample Input 1\n\n2 3\n0 1 1\n1 0 1\n1 4 0\n1 2\n3 3\n\nSample Output 1\n\n3\n\nRepaint (1,1) to Color 2. The wrongness of (1,1) becomes D_{1,2}=1.\n\nRepaint (1,2) to Color 3. The wrongness of (1,2) becomes D_{2,3}=1.\n\nRepaint (2,2) to Color 1. The wrongness of (2,2) becomes D_{3,1}=1.\n\nIn this case, the sum of the wrongness of all the squares is 3.\n\nNote that D_{i,j} \\neq D_{j,i} is possible.\n\nSample Input 2\n\n4 3\n0 12 71\n81 0 53\n14 92 0\n1 1 2 1\n2 1 1 2\n2 2 1 3\n1 1 2 2\n\nSample Output 2\n\n428", "sample_input": "2 3\n0 1 1\n1 0 1\n1 4 0\n1 2\n3 3\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03330", "source_text": "Score : 400 points\n\nProblem Statement\n\nThere is a grid with N rows and N columns of squares. Let (i,j) be the square at the i-th row from the top and the j-th column from the left.\n\nThese squares have to be painted in one of the C colors from Color 1 to Color C. Initially, (i,j) is painted in Color c_{i,j}.\n\nWe say the grid is a good grid when the following condition is met for all i,j,x,y satisfying 1 \\leq i,j,x,y \\leq N:\n\nIf (i+j) \\% 3=(x+y) \\% 3, the color of (i,j) and the color of (x,y) are the same.\n\nIf (i+j) \\% 3 \\neq (x+y) \\% 3, the color of (i,j) and the color of (x,y) are different.\n\nHere, X \\% Y represents X modulo Y.\n\nWe will repaint zero or more squares so that the grid will be a good grid.\n\nFor a square, the wrongness when the color of the square is X before repainting and Y after repainting, is D_{X,Y}.\n\nFind the minimum possible sum of the wrongness of all the squares.\n\nConstraints\n\n1 \\leq N \\leq 500\n\n3 \\leq C \\leq 30\n\n1 \\leq D_{i,j} \\leq 1000 (i \\neq j),D_{i,j}=0 (i=j)\n\n1 \\leq c_{i,j} \\leq C\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN C\nD_{1,1} ... D_{1,C}\n:\nD_{C,1} ... D_{C,C}\nc_{1,1} ... c_{1,N}\n:\nc_{N,1} ... c_{N,N}\n\nOutput\n\nIf the minimum possible sum of the wrongness of all the squares is x, print x.\n\nSample Input 1\n\n2 3\n0 1 1\n1 0 1\n1 4 0\n1 2\n3 3\n\nSample Output 1\n\n3\n\nRepaint (1,1) to Color 2. The wrongness of (1,1) becomes D_{1,2}=1.\n\nRepaint (1,2) to Color 3. The wrongness of (1,2) becomes D_{2,3}=1.\n\nRepaint (2,2) to Color 1. The wrongness of (2,2) becomes D_{3,1}=1.\n\nIn this case, the sum of the wrongness of all the squares is 3.\n\nNote that D_{i,j} \\neq D_{j,i} is possible.\n\nSample Input 2\n\n4 3\n0 12 71\n81 0 53\n14 92 0\n1 1 2 1\n2 1 1 2\n2 2 1 3\n1 1 2 2\n\nSample Output 2\n\n428", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1201, "cpu_time_ms": 95, "memory_kb": 7552}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s203836905", "group_id": "codeNet:p03330", "input_text": "let rec seq a b = if a > b then [] else a :: seq (a+1) b\nlet (>>=) x f = List.map f x |> List.concat\nlet () =\n Scanf.scanf \"%d %d\" @@ fun n c ->\n let d =\n Array.init c (fun i ->\n Array.init c (fun j -> Scanf.scanf \" %d\" ((+) 0)))\n in\n let b =\n Array.init n (fun i ->\n Array.init n (fun j -> Scanf.scanf \" %d\" ((+) 0)))\n in\n (seq 0 (c-1) >>= fun i ->\n seq 0 (c-1) >>= fun j ->\n seq 0 (c-1) >>= fun k ->\n if i = j || j = k || k = i then []\n else [\n let t = [|i; j; k;|] in\n (seq 0 (n-1) >>= fun x ->\n seq 0 (n-1) >>= fun y ->\n [d.(b.(x).(y)-1).(t.((x+y) mod 3))])\n |> List.fold_left (+) 0\n ])\n |> List.fold_left min 10101010101010 \n |> Printf.printf \"%d\\n\"", "language": "OCaml", "metadata": {"date": 1541102513, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03330.html", "problem_id": "p03330", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03330/input.txt", "sample_output_relpath": "derived/input_output/data/p03330/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03330/OCaml/s203836905.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s203836905", "user_id": "u798181098"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "let rec seq a b = if a > b then [] else a :: seq (a+1) b\nlet (>>=) x f = List.map f x |> List.concat\nlet () =\n Scanf.scanf \"%d %d\" @@ fun n c ->\n let d =\n Array.init c (fun i ->\n Array.init c (fun j -> Scanf.scanf \" %d\" ((+) 0)))\n in\n let b =\n Array.init n (fun i ->\n Array.init n (fun j -> Scanf.scanf \" %d\" ((+) 0)))\n in\n (seq 0 (c-1) >>= fun i ->\n seq 0 (c-1) >>= fun j ->\n seq 0 (c-1) >>= fun k ->\n if i = j || j = k || k = i then []\n else [\n let t = [|i; j; k;|] in\n (seq 0 (n-1) >>= fun x ->\n seq 0 (n-1) >>= fun y ->\n [d.(b.(x).(y)-1).(t.((x+y) mod 3))])\n |> List.fold_left (+) 0\n ])\n |> List.fold_left min 10101010101010 \n |> Printf.printf \"%d\\n\"", "problem_context": "Score : 400 points\n\nProblem Statement\n\nThere is a grid with N rows and N columns of squares. Let (i,j) be the square at the i-th row from the top and the j-th column from the left.\n\nThese squares have to be painted in one of the C colors from Color 1 to Color C. Initially, (i,j) is painted in Color c_{i,j}.\n\nWe say the grid is a good grid when the following condition is met for all i,j,x,y satisfying 1 \\leq i,j,x,y \\leq N:\n\nIf (i+j) \\% 3=(x+y) \\% 3, the color of (i,j) and the color of (x,y) are the same.\n\nIf (i+j) \\% 3 \\neq (x+y) \\% 3, the color of (i,j) and the color of (x,y) are different.\n\nHere, X \\% Y represents X modulo Y.\n\nWe will repaint zero or more squares so that the grid will be a good grid.\n\nFor a square, the wrongness when the color of the square is X before repainting and Y after repainting, is D_{X,Y}.\n\nFind the minimum possible sum of the wrongness of all the squares.\n\nConstraints\n\n1 \\leq N \\leq 500\n\n3 \\leq C \\leq 30\n\n1 \\leq D_{i,j} \\leq 1000 (i \\neq j),D_{i,j}=0 (i=j)\n\n1 \\leq c_{i,j} \\leq C\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN C\nD_{1,1} ... D_{1,C}\n:\nD_{C,1} ... D_{C,C}\nc_{1,1} ... c_{1,N}\n:\nc_{N,1} ... c_{N,N}\n\nOutput\n\nIf the minimum possible sum of the wrongness of all the squares is x, print x.\n\nSample Input 1\n\n2 3\n0 1 1\n1 0 1\n1 4 0\n1 2\n3 3\n\nSample Output 1\n\n3\n\nRepaint (1,1) to Color 2. The wrongness of (1,1) becomes D_{1,2}=1.\n\nRepaint (1,2) to Color 3. The wrongness of (1,2) becomes D_{2,3}=1.\n\nRepaint (2,2) to Color 1. The wrongness of (2,2) becomes D_{3,1}=1.\n\nIn this case, the sum of the wrongness of all the squares is 3.\n\nNote that D_{i,j} \\neq D_{j,i} is possible.\n\nSample Input 2\n\n4 3\n0 12 71\n81 0 53\n14 92 0\n1 1 2 1\n2 1 1 2\n2 2 1 3\n1 1 2 2\n\nSample Output 2\n\n428", "sample_input": "2 3\n0 1 1\n1 0 1\n1 4 0\n1 2\n3 3\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03330", "source_text": "Score : 400 points\n\nProblem Statement\n\nThere is a grid with N rows and N columns of squares. Let (i,j) be the square at the i-th row from the top and the j-th column from the left.\n\nThese squares have to be painted in one of the C colors from Color 1 to Color C. Initially, (i,j) is painted in Color c_{i,j}.\n\nWe say the grid is a good grid when the following condition is met for all i,j,x,y satisfying 1 \\leq i,j,x,y \\leq N:\n\nIf (i+j) \\% 3=(x+y) \\% 3, the color of (i,j) and the color of (x,y) are the same.\n\nIf (i+j) \\% 3 \\neq (x+y) \\% 3, the color of (i,j) and the color of (x,y) are different.\n\nHere, X \\% Y represents X modulo Y.\n\nWe will repaint zero or more squares so that the grid will be a good grid.\n\nFor a square, the wrongness when the color of the square is X before repainting and Y after repainting, is D_{X,Y}.\n\nFind the minimum possible sum of the wrongness of all the squares.\n\nConstraints\n\n1 \\leq N \\leq 500\n\n3 \\leq C \\leq 30\n\n1 \\leq D_{i,j} \\leq 1000 (i \\neq j),D_{i,j}=0 (i=j)\n\n1 \\leq c_{i,j} \\leq C\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN C\nD_{1,1} ... D_{1,C}\n:\nD_{C,1} ... D_{C,C}\nc_{1,1} ... c_{1,N}\n:\nc_{N,1} ... c_{N,N}\n\nOutput\n\nIf the minimum possible sum of the wrongness of all the squares is x, print x.\n\nSample Input 1\n\n2 3\n0 1 1\n1 0 1\n1 4 0\n1 2\n3 3\n\nSample Output 1\n\n3\n\nRepaint (1,1) to Color 2. The wrongness of (1,1) becomes D_{1,2}=1.\n\nRepaint (1,2) to Color 3. The wrongness of (1,2) becomes D_{2,3}=1.\n\nRepaint (2,2) to Color 1. The wrongness of (2,2) becomes D_{3,1}=1.\n\nIn this case, the sum of the wrongness of all the squares is 3.\n\nNote that D_{i,j} \\neq D_{j,i} is possible.\n\nSample Input 2\n\n4 3\n0 12 71\n81 0 53\n14 92 0\n1 1 2 1\n2 1 1 2\n2 2 1 3\n1 1 2 2\n\nSample Output 2\n\n428", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 728, "cpu_time_ms": 2105, "memory_kb": 28320}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s113233169", "group_id": "codeNet:p03331", "input_text": "let n = read_line ()\nlet s = Array.fold_left (+) 0 @@ Array.init (String.length n) @@ fun i -> Char.code n.[i] - Char.code '0'\nlet _ = Printf.printf \"%d\\n\" @@ if s = 1 then 10 else s", "language": "OCaml", "metadata": {"date": 1561695149, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03331.html", "problem_id": "p03331", "resource_group": "low_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/OCaml/s113233169.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s113233169", "user_id": "u732304692"}, "prompt_components": {"gold_output": "6\n", "input_to_evaluate": "let n = read_line ()\nlet s = Array.fold_left (+) 0 @@ Array.init (String.length n) @@ fun i -> Char.code n.[i] - Char.code '0'\nlet _ = Printf.printf \"%d\\n\" @@ if s = 1 then 10 else s", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s231448962", "group_id": "codeNet:p03331", "input_text": "let rec digits_sum = function\n | 0 -> 0\n | n -> n mod 10 + digits_sum (n / 10)\n\nlet () = Scanf.scanf \"%d\" @@ fun n ->\n Array.init (n - 1) (fun a -> a + 1, n - a - 1)\n |> Array.map (fun (a, b) -> digits_sum a + digits_sum b)\n |> Array.fold_left min max_int\n |> Printf.printf \"%d\\n\"", "language": "OCaml", "metadata": {"date": 1528135686, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03331.html", "problem_id": "p03331", "resource_group": "low_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/OCaml/s231448962.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s231448962", "user_id": "u504158101"}, "prompt_components": {"gold_output": "6\n", "input_to_evaluate": "let rec digits_sum = function\n | 0 -> 0\n | n -> n mod 10 + digits_sum (n / 10)\n\nlet () = Scanf.scanf \"%d\" @@ fun n ->\n Array.init (n - 1) (fun a -> a + 1, n - a - 1)\n |> Array.map (fun (a, b) -> digits_sum a + digits_sum b)\n |> Array.fold_left min max_int\n |> Printf.printf \"%d\\n\"", "problem_context": "Score : 200 points\n\nProblem Statement\n\nTakahashi has two positive integers A and B.\n\nIt is known that A plus B equals N.\nFind the minimum possible value of \"the sum of the digits of A\" plus \"the sum of the digits of B\" (in base 10).\n\nConstraints\n\n2 ≤ N ≤ 10^5\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the minimum possible value of \"the sum of the digits of A\" plus \"the sum of the digits of B\".\n\nSample Input 1\n\n15\n\nSample Output 1\n\n6\n\nWhen A=2 and B=13, the sums of their digits are 2 and 4, which minimizes the value in question.\n\nSample Input 2\n\n100000\n\nSample Output 2\n\n10", "sample_input": "15\n"}, "reference_outputs": ["6\n"], "source_document_id": "p03331", "source_text": "Score : 200 points\n\nProblem Statement\n\nTakahashi has two positive integers A and B.\n\nIt is known that A plus B equals N.\nFind the minimum possible value of \"the sum of the digits of A\" plus \"the sum of the digits of B\" (in base 10).\n\nConstraints\n\n2 ≤ N ≤ 10^5\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the minimum possible value of \"the sum of the digits of A\" plus \"the sum of the digits of B\".\n\nSample Input 1\n\n15\n\nSample Output 1\n\n6\n\nWhen A=2 and B=13, the sums of their digits are 2 and 4, which minimizes the value in question.\n\nSample Input 2\n\n100000\n\nSample Output 2\n\n10", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 286, "cpu_time_ms": 15, "memory_kb": 5760}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s994291239", "group_id": "codeNet:p03332", "input_text": "(* nCr = {(n-r+1)/r}nCr-1 *)\nlet const = 998244353\nlet ( *$ ) x y = x * y mod const\nlet ( +$ ) x y = x + y mod const\nlet rec power x n =\n if n <= 0 then 1\n else if n mod 2 = 0 then\n power (x *$ x) (n/2)\n else\n x *$ power x (n - 1)\nlet mod_inv x =\n power x (const - 2)\n \nlet () =\n let n, a, b, k = Scanf.scanf \"%d %d %d %d\"\n (fun n a b k -> n, a, b, k) in\n let binomial = Array.make (n + 1) 1 in\n for i = 1 to n do\n binomial.(i) <- binomial.(i-1) *$ (n+1-i) *$ mod_inv i\n done;\n Array.init n (fun x ->\n let y = (k - a * x) / b in\n if a * x + b * y = k && 0 <= y && y <= n then\n binomial.(x) *$ binomial.(y)\n else\n 0)\n |> Array.fold_left (fun x y -> x +$ y) 0\n |> Printf.printf \"%d\\n\"\n", "language": "OCaml", "metadata": {"date": 1528443679, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03332.html", "problem_id": "p03332", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03332/input.txt", "sample_output_relpath": "derived/input_output/data/p03332/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03332/OCaml/s994291239.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s994291239", "user_id": "u614063956"}, "prompt_components": {"gold_output": "40\n", "input_to_evaluate": "(* nCr = {(n-r+1)/r}nCr-1 *)\nlet const = 998244353\nlet ( *$ ) x y = x * y mod const\nlet ( +$ ) x y = x + y mod const\nlet rec power x n =\n if n <= 0 then 1\n else if n mod 2 = 0 then\n power (x *$ x) (n/2)\n else\n x *$ power x (n - 1)\nlet mod_inv x =\n power x (const - 2)\n \nlet () =\n let n, a, b, k = Scanf.scanf \"%d %d %d %d\"\n (fun n a b k -> n, a, b, k) in\n let binomial = Array.make (n + 1) 1 in\n for i = 1 to n do\n binomial.(i) <- binomial.(i-1) *$ (n+1-i) *$ mod_inv i\n done;\n Array.init n (fun x ->\n let y = (k - a * x) / b in\n if a * x + b * y = k && 0 <= y && y <= n then\n binomial.(x) *$ binomial.(y)\n else\n 0)\n |> Array.fold_left (fun x y -> x +$ y) 0\n |> Printf.printf \"%d\\n\"\n", "problem_context": "Score : 700 points\n\nProblem Statement\n\nTakahashi has a tower which is divided into N layers.\nInitially, all the layers are uncolored. Takahashi is going to paint some of the layers in red, green or blue to make a beautiful tower.\nHe defines the beauty of the tower as follows:\n\nThe beauty of the tower is the sum of the scores of the N layers, where the score of a layer is A if the layer is painted red, A+B if the layer is painted green, B if the layer is painted blue, and 0 if the layer is uncolored.\n\nHere, A and B are positive integer constants given beforehand. Also note that a layer may not be painted in two or more colors.\n\nTakahashi is planning to paint the tower so that the beauty of the tower becomes exactly K.\nHow many such ways are there to paint the tower? Find the count modulo 998244353.\nTwo ways to paint the tower are considered different when there exists a layer that is painted in different colors, or a layer that is painted in some color in one of the ways and not in the other.\n\nConstraints\n\n1 ≤ N ≤ 3×10^5\n\n1 ≤ A,B ≤ 3×10^5\n\n0 ≤ K ≤ 18×10^{10}\n\nAll values in the input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN A B K\n\nOutput\n\nPrint the number of the ways to paint tiles, modulo 998244353.\n\nSample Input 1\n\n4 1 2 5\n\nSample Output 1\n\n40\n\nIn this case, a red layer worth 1 points, a green layer worth 3 points and the blue layer worth 2 points. The beauty of the tower is 5 when we have one of the following sets of painted layers:\n\n1 green, 1 blue\n\n1 red, 2 blues\n\n2 reds, 1 green\n\n3 reds, 1 blue\n\nThe total number of the ways to produce them is 40.\n\nSample Input 2\n\n2 5 6 0\n\nSample Output 2\n\n1\n\nThe beauty of the tower is 0 only when all the layers are uncolored. Thus, the answer is 1.\n\nSample Input 3\n\n90081 33447 90629 6391049189\n\nSample Output 3\n\n577742975", "sample_input": "4 1 2 5\n"}, "reference_outputs": ["40\n"], "source_document_id": "p03332", "source_text": "Score : 700 points\n\nProblem Statement\n\nTakahashi has a tower which is divided into N layers.\nInitially, all the layers are uncolored. Takahashi is going to paint some of the layers in red, green or blue to make a beautiful tower.\nHe defines the beauty of the tower as follows:\n\nThe beauty of the tower is the sum of the scores of the N layers, where the score of a layer is A if the layer is painted red, A+B if the layer is painted green, B if the layer is painted blue, and 0 if the layer is uncolored.\n\nHere, A and B are positive integer constants given beforehand. Also note that a layer may not be painted in two or more colors.\n\nTakahashi is planning to paint the tower so that the beauty of the tower becomes exactly K.\nHow many such ways are there to paint the tower? Find the count modulo 998244353.\nTwo ways to paint the tower are considered different when there exists a layer that is painted in different colors, or a layer that is painted in some color in one of the ways and not in the other.\n\nConstraints\n\n1 ≤ N ≤ 3×10^5\n\n1 ≤ A,B ≤ 3×10^5\n\n0 ≤ K ≤ 18×10^{10}\n\nAll values in the input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN A B K\n\nOutput\n\nPrint the number of the ways to paint tiles, modulo 998244353.\n\nSample Input 1\n\n4 1 2 5\n\nSample Output 1\n\n40\n\nIn this case, a red layer worth 1 points, a green layer worth 3 points and the blue layer worth 2 points. The beauty of the tower is 5 when we have one of the following sets of painted layers:\n\n1 green, 1 blue\n\n1 red, 2 blues\n\n2 reds, 1 green\n\n3 reds, 1 blue\n\nThe total number of the ways to produce them is 40.\n\nSample Input 2\n\n2 5 6 0\n\nSample Output 2\n\n1\n\nThe beauty of the tower is 0 only when all the layers are uncolored. Thus, the answer is 1.\n\nSample Input 3\n\n90081 33447 90629 6391049189\n\nSample Output 3\n\n577742975", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 754, "cpu_time_ms": 122, "memory_kb": 8448}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s517823720", "group_id": "codeNet:p03337", "input_text": "let () =\n Scanf.scanf \"%d %d\" (fun a b -> max (a+b) (max (a-b) (a*b)))\n |> Printf.printf \"%d\\n\"", "language": "OCaml", "metadata": {"date": 1531254173, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03337.html", "problem_id": "p03337", "resource_group": "low_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/OCaml/s517823720.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s517823720", "user_id": "u798181098"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "let () =\n Scanf.scanf \"%d %d\" (fun a b -> max (a+b) (max (a-b) (a*b)))\n |> Printf.printf \"%d\\n\"", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou are given two integers A and B.\nFind the largest value among A+B, A-B and A \\times B.\n\nConstraints\n\n-1000 \\leq A,B \\leq 1000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the largest value among A+B, A-B and A \\times B.\n\nSample Input 1\n\n3 1\n\nSample Output 1\n\n4\n\n3+1=4, 3-1=2 and 3 \\times 1=3. The largest among them is 4.\n\nSample Input 2\n\n4 -2\n\nSample Output 2\n\n6\n\nThe largest is 4 - (-2) = 6.\n\nSample Input 3\n\n0 0\n\nSample Output 3\n\n0", "sample_input": "3 1\n"}, "reference_outputs": ["4\n"], "source_document_id": "p03337", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou are given two integers A and B.\nFind the largest value among A+B, A-B and A \\times B.\n\nConstraints\n\n-1000 \\leq A,B \\leq 1000\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the largest value among A+B, A-B and A \\times B.\n\nSample Input 1\n\n3 1\n\nSample Output 1\n\n4\n\n3+1=4, 3-1=2 and 3 \\times 1=3. The largest among them is 4.\n\nSample Input 2\n\n4 -2\n\nSample Output 2\n\n6\n\nThe largest is 4 - (-2) = 6.\n\nSample Input 3\n\n0 0\n\nSample Output 3\n\n0", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s084835085", "group_id": "codeNet:p03338", "input_text": "open Printf\nopen Scanf\nopen BatPervasives\n\n(*open Core*)\n\n\n(*let map2 f a1 a2 = Array.of_list (List.map2 f (Array.to_list a1) (Array.to_list a2))*)\n\nlet count (s1, s2) =\n let count_array s =\n let toi x = int_of_char x - int_of_char 'a' in\n let a = BatArray.create (toi 'z' + 1) 0 in\n BatString.iter (fun x -> a.(toi x) <- 1) s;\n a in\n let a1 = count_array s1 in\n let a2 = count_array s2 in\n let b = BatArray.map2 (fun a b ->\n match (a, b) with\n | (1, 1) -> 1\n | _ -> 0\n ) a1 a2 in\n BatArray.fold_left (+) 0 b\n\nlet split_string s i length =\n let s1 = String.sub s 0 i in\n let s2 = String.sub s i (length - i) in\n (s1, s2)\n\nlet main =\n let (length, s) = scanf \"%d\\n%s\" (fun a b -> (a, b)) in\n let rec iter i v =\n match i with\n | i when i = length -> v\n | i -> iter (i + 1) (max (count (split_string s i length)) v) in\n let init = count (split_string s 1 length) in\n printf \"%d\\n\" (iter 2 init)\n\n\n", "language": "OCaml", "metadata": {"date": 1528659093, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03338.html", "problem_id": "p03338", "resource_group": "low_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/OCaml/s084835085.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s084835085", "user_id": "u625631018"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "open Printf\nopen Scanf\nopen BatPervasives\n\n(*open Core*)\n\n\n(*let map2 f a1 a2 = Array.of_list (List.map2 f (Array.to_list a1) (Array.to_list a2))*)\n\nlet count (s1, s2) =\n let count_array s =\n let toi x = int_of_char x - int_of_char 'a' in\n let a = BatArray.create (toi 'z' + 1) 0 in\n BatString.iter (fun x -> a.(toi x) <- 1) s;\n a in\n let a1 = count_array s1 in\n let a2 = count_array s2 in\n let b = BatArray.map2 (fun a b ->\n match (a, b) with\n | (1, 1) -> 1\n | _ -> 0\n ) a1 a2 in\n BatArray.fold_left (+) 0 b\n\nlet split_string s i length =\n let s1 = String.sub s 0 i in\n let s2 = String.sub s i (length - i) in\n (s1, s2)\n\nlet main =\n let (length, s) = scanf \"%d\\n%s\" (fun a b -> (a, b)) in\n let rec iter i v =\n match i with\n | i when i = length -> v\n | i -> iter (i + 1) (max (count (split_string s i length)) v) in\n let init = count (split_string s 1 length) in\n printf \"%d\\n\" (iter 2 init)\n\n\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nYou are given a string S of length N consisting of lowercase English letters.\nWe will cut this string at one position into two strings X and Y.\nHere, we would like to maximize the number of different letters contained in both X and Y.\nFind the largest possible number of different letters contained in both X and Y when we cut the string at the optimal position.\n\nConstraints\n\n2 \\leq N \\leq 100\n\n|S| = N\n\nS consists of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS\n\nOutput\n\nPrint the largest possible number of different letters contained in both X and Y.\n\nSample Input 1\n\n6\naabbca\n\nSample Output 1\n\n2\n\nIf we cut the string between the third and fourth letters into X = aab and Y = bca, the letters contained in both X and Y are a and b.\nThere will never be three or more different letters contained in both X and Y, so the answer is 2.\n\nSample Input 2\n\n10\naaaaaaaaaa\n\nSample Output 2\n\n1\n\nHowever we divide S, only a will be contained in both X and Y.\n\nSample Input 3\n\n45\ntgxgdqkyjzhyputjjtllptdfxocrylqfqjynmfbfucbir\n\nSample Output 3\n\n9", "sample_input": "6\naabbca\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03338", "source_text": "Score : 200 points\n\nProblem Statement\n\nYou are given a string S of length N consisting of lowercase English letters.\nWe will cut this string at one position into two strings X and Y.\nHere, we would like to maximize the number of different letters contained in both X and Y.\nFind the largest possible number of different letters contained in both X and Y when we cut the string at the optimal position.\n\nConstraints\n\n2 \\leq N \\leq 100\n\n|S| = N\n\nS consists of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS\n\nOutput\n\nPrint the largest possible number of different letters contained in both X and Y.\n\nSample Input 1\n\n6\naabbca\n\nSample Output 1\n\n2\n\nIf we cut the string between the third and fourth letters into X = aab and Y = bca, the letters contained in both X and Y are a and b.\nThere will never be three or more different letters contained in both X and Y, so the answer is 2.\n\nSample Input 2\n\n10\naaaaaaaaaa\n\nSample Output 2\n\n1\n\nHowever we divide S, only a will be contained in both X and Y.\n\nSample Input 3\n\n45\ntgxgdqkyjzhyputjjtllptdfxocrylqfqjynmfbfucbir\n\nSample Output 3\n\n9", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 2, "memory_kb": 768}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s054435105", "group_id": "codeNet:p03339", "input_text": "let result = ref 1000000\nlet () =\n let n = Scanf.scanf \"%d \" (fun x -> x) in\n let s = Array.init n (fun _ -> Scanf.scanf \"%c\"\n (fun x -> x)) in\n for i = 0 to (n-1) do\n let left = Array.sub s 0 i in\n let right = Array.sub s (i+1) (n-i-1) in\n let left' = Array.to_list left in\n let right' = Array.to_list right in\n let res_l =\n List.fold_left (fun sum x ->\n match x with\n | 'W' -> sum + 1\n | 'E' -> sum) 0 left' in\n let res_r =\n List.fold_left (fun sum x ->\n match x with\n | 'E' -> sum + 1\n | 'W' -> sum) 0 right' in\n let res = res_l + res_r in\n if res < !result then\n result := res\n else\n ()\n done;\n Printf.printf \"%d\\n\" !result\n\n", "language": "OCaml", "metadata": {"date": 1528488016, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03339.html", "problem_id": "p03339", "resource_group": "low_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/OCaml/s054435105.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s054435105", "user_id": "u614063956"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "let result = ref 1000000\nlet () =\n let n = Scanf.scanf \"%d \" (fun x -> x) in\n let s = Array.init n (fun _ -> Scanf.scanf \"%c\"\n (fun x -> x)) in\n for i = 0 to (n-1) do\n let left = Array.sub s 0 i in\n let right = Array.sub s (i+1) (n-i-1) in\n let left' = Array.to_list left in\n let right' = Array.to_list right in\n let res_l =\n List.fold_left (fun sum x ->\n match x with\n | 'W' -> sum + 1\n | 'E' -> sum) 0 left' in\n let res_r =\n List.fold_left (fun sum x ->\n match x with\n | 'E' -> sum + 1\n | 'W' -> sum) 0 right' in\n let res = res_l + res_r in\n if res < !result then\n result := res\n else\n ()\n done;\n Printf.printf \"%d\\n\" !result\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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 769, "cpu_time_ms": 2106, "memory_kb": 32544}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s420672299", "group_id": "codeNet:p03345", "input_text": "(*\nocamlfind ocamlopt -package batteries -linkpkg main.ml -o a.out\n*)\nopen Batteries\n\nlet unfair = Int.pow 10 18\nlet a, b, c, k = Scanf.sscanf (read_line ()) \"%d %d %d %d\" ( fun a b c k -> a, b, c, k)\n\nlet rec f a b c k = \n let ans = \n (\n if k = 0 then\n a - b\n else\n if k = 1 then\n (b + c) - (a + c)\n else\n if k = 2 then\n (2 * a + (b + c)) - (2 * b + (a + c))\n else\n let ki = 3 + 2 * (k - 3) in\n (2 * (ki - 2) * a + ki * (b + c)) - (2 * (ki - 2) * b + ki * (a + c))\n ) in\n if abs ans > unfair then\n \"Unsafe\"\n else\n string_of_int ans\n\n\nlet () =\n f a b c k\n |> Printf.printf \"%s\\n\"\n", "language": "OCaml", "metadata": {"date": 1590797771, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03345.html", "problem_id": "p03345", "resource_group": "low_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/OCaml/s420672299.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s420672299", "user_id": "u280335093"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "(*\nocamlfind ocamlopt -package batteries -linkpkg main.ml -o a.out\n*)\nopen Batteries\n\nlet unfair = Int.pow 10 18\nlet a, b, c, k = Scanf.sscanf (read_line ()) \"%d %d %d %d\" ( fun a b c k -> a, b, c, k)\n\nlet rec f a b c k = \n let ans = \n (\n if k = 0 then\n a - b\n else\n if k = 1 then\n (b + c) - (a + c)\n else\n if k = 2 then\n (2 * a + (b + c)) - (2 * b + (a + c))\n else\n let ki = 3 + 2 * (k - 3) in\n (2 * (ki - 2) * a + ki * (b + c)) - (2 * (ki - 2) * b + ki * (a + c))\n ) in\n if abs ans > unfair then\n \"Unsafe\"\n else\n string_of_int ans\n\n\nlet () =\n f a b c k\n |> Printf.printf \"%s\\n\"\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nTakahashi, Nakahashi and Hikuhashi have integers A, B and C, respectively.\nAfter repeating the following operation K times, find the integer Takahashi will get minus the integer Nakahashi will get:\n\nEach of them simultaneously calculate the sum of the integers that the other two people have, then replace his own integer with the result.\n\nHowever, if the absolute value of the answer exceeds 10^{18}, print Unfair instead.\n\nConstraints\n\n1 \\leq A,B,C \\leq 10^9\n\n0 \\leq K \\leq 10^{18}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C K\n\nOutput\n\nPrint the integer Takahashi will get minus the integer Nakahashi will get, after repeating the following operation K times.\nIf the absolute value of the answer exceeds 10^{18}, print Unfair instead.\n\nSample Input 1\n\n1 2 3 1\n\nSample Output 1\n\n1\n\nAfter one operation, Takahashi, Nakahashi and Hikuhashi have 5, 4 and 3, respectively. We should print 5-4=1.\n\nSample Input 2\n\n2 3 2 0\n\nSample Output 2\n\n-1\n\nSample Input 3\n\n1000000000 1000000000 1000000000 1000000000000000000\n\nSample Output 3\n\n0", "sample_input": "1 2 3 1\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03345", "source_text": "Score : 300 points\n\nProblem Statement\n\nTakahashi, Nakahashi and Hikuhashi have integers A, B and C, respectively.\nAfter repeating the following operation K times, find the integer Takahashi will get minus the integer Nakahashi will get:\n\nEach of them simultaneously calculate the sum of the integers that the other two people have, then replace his own integer with the result.\n\nHowever, if the absolute value of the answer exceeds 10^{18}, print Unfair instead.\n\nConstraints\n\n1 \\leq A,B,C \\leq 10^9\n\n0 \\leq K \\leq 10^{18}\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C K\n\nOutput\n\nPrint the integer Takahashi will get minus the integer Nakahashi will get, after repeating the following operation K times.\nIf the absolute value of the answer exceeds 10^{18}, print Unfair instead.\n\nSample Input 1\n\n1 2 3 1\n\nSample Output 1\n\n1\n\nAfter one operation, Takahashi, Nakahashi and Hikuhashi have 5, 4 and 3, respectively. We should print 5-4=1.\n\nSample Input 2\n\n2 3 2 0\n\nSample Output 2\n\n-1\n\nSample Input 3\n\n1000000000 1000000000 1000000000 1000000000000000000\n\nSample Output 3\n\n0", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1008, "cpu_time_ms": 2, "memory_kb": 3072}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s217818970", "group_id": "codeNet:p03346", "input_text": "Scanf.scanf \"%d\" (fun n ->\n let len = Array.make n 0 in\n for i = 1 to n do\n Scanf.scanf \" %d\" (fun p ->\n let p = p - 1 in\n len.(p) <- 1;\n if p > 0 && len.(p - 1) > 0 then (\n len.(p) <- len.(p - 1) + 1;\n len.(p - 1) <- 0\n )\n )\n done;\n Printf.printf \"%d\\n\" @@ n - Array.fold_left max 0 len\n)", "language": "OCaml", "metadata": {"date": 1597636114, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p03346.html", "problem_id": "p03346", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03346/input.txt", "sample_output_relpath": "derived/input_output/data/p03346/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03346/OCaml/s217818970.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s217818970", "user_id": "u342443598"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "Scanf.scanf \"%d\" (fun n ->\n let len = Array.make n 0 in\n for i = 1 to n do\n Scanf.scanf \" %d\" (fun p ->\n let p = p - 1 in\n len.(p) <- 1;\n if p > 0 && len.(p - 1) > 0 then (\n len.(p) <- len.(p - 1) + 1;\n len.(p - 1) <- 0\n )\n )\n done;\n Printf.printf \"%d\\n\" @@ n - Array.fold_left max 0 len\n)", "problem_context": "Score : 500 points\n\nProblem Statement\n\nYou are given a sequence (P_1,P_2,...,P_N) which is a permutation of the integers from 1 through N.\nYou would like to sort this sequence in ascending order by repeating the following operation:\n\nChoose an element in the sequence and move it to the beginning or the end of the sequence.\n\nFind the minimum number of operations required.\nIt can be proved that it is actually possible to sort the sequence using this operation.\n\nConstraints\n\n1 \\leq N \\leq 2\\times 10^5\n\n(P_1,P_2,...,P_N) is a permutation of (1,2,...,N).\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nP_1\n:\nP_N\n\nOutput\n\nPrint the minimum number of operations required.\n\nSample Input 1\n\n4\n1\n3\n2\n4\n\nSample Output 1\n\n2\n\nFor example, the sequence can be sorted in ascending order as follows:\n\nMove 2 to the beginning. The sequence is now (2,1,3,4).\n\nMove 1 to the beginning. The sequence is now (1,2,3,4).\n\nSample Input 2\n\n6\n3\n2\n5\n1\n4\n6\n\nSample Output 2\n\n4\n\nSample Input 3\n\n8\n6\n3\n1\n2\n7\n4\n8\n5\n\nSample Output 3\n\n5", "sample_input": "4\n1\n3\n2\n4\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03346", "source_text": "Score : 500 points\n\nProblem Statement\n\nYou are given a sequence (P_1,P_2,...,P_N) which is a permutation of the integers from 1 through N.\nYou would like to sort this sequence in ascending order by repeating the following operation:\n\nChoose an element in the sequence and move it to the beginning or the end of the sequence.\n\nFind the minimum number of operations required.\nIt can be proved that it is actually possible to sort the sequence using this operation.\n\nConstraints\n\n1 \\leq N \\leq 2\\times 10^5\n\n(P_1,P_2,...,P_N) is a permutation of (1,2,...,N).\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nP_1\n:\nP_N\n\nOutput\n\nPrint the minimum number of operations required.\n\nSample Input 1\n\n4\n1\n3\n2\n4\n\nSample Output 1\n\n2\n\nFor example, the sequence can be sorted in ascending order as follows:\n\nMove 2 to the beginning. The sequence is now (2,1,3,4).\n\nMove 1 to the beginning. The sequence is now (1,2,3,4).\n\nSample Input 2\n\n6\n3\n2\n5\n1\n4\n6\n\nSample Output 2\n\n4\n\nSample Input 3\n\n8\n6\n3\n1\n2\n7\n4\n8\n5\n\nSample Output 3\n\n5", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 389, "cpu_time_ms": 55, "memory_kb": 7556}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s364392562", "group_id": "codeNet:p03347", "input_text": "Scanf.scanf \"%d\" (fun n ->\n let a = Array.init n (fun _ -> Scanf.scanf \" %d\" (fun a -> a)) in\n let rec loop i expect acc =\n if i = 0 then (if expect = 0 then acc else -1) else\n if a.(i) < expect then -1 else\n loop (i - 1) (max 0 (a.(i) - 1)) (if expect = a.(i) then acc else acc + a.(i))\n in\n loop (n - 1) 0 0 |> Printf.printf \"%d\\n\"\n)", "language": "OCaml", "metadata": {"date": 1600918335, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p03347.html", "problem_id": "p03347", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03347/input.txt", "sample_output_relpath": "derived/input_output/data/p03347/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03347/OCaml/s364392562.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s364392562", "user_id": "u342443598"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "Scanf.scanf \"%d\" (fun n ->\n let a = Array.init n (fun _ -> Scanf.scanf \" %d\" (fun a -> a)) in\n let rec loop i expect acc =\n if i = 0 then (if expect = 0 then acc else -1) else\n if a.(i) < expect then -1 else\n loop (i - 1) (max 0 (a.(i) - 1)) (if expect = a.(i) then acc else acc + a.(i))\n in\n loop (n - 1) 0 0 |> Printf.printf \"%d\\n\"\n)", "problem_context": "Score : 700 points\n\nProblem Statement\n\nThere is a sequence X of length N, where every element is initially 0. Let X_i denote the i-th element of X.\n\nYou are given a sequence A of length N. The i-th element of A is A_i. Determine if we can make X equal to A by repeating the operation below. If we can, find the minimum number of operations required.\n\nChoose an integer i such that 1\\leq i\\leq N-1. Replace the value of X_{i+1} with the value of X_i plus 1.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\n0 \\leq A_i \\leq 10^9(1\\leq i\\leq N)\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1\n:\nA_N\n\nOutput\n\nIf we can make X equal to A by repeating the operation, print the minimum number of operations required. If we cannot, print -1.\n\nSample Input 1\n\n4\n0\n1\n1\n2\n\nSample Output 1\n\n3\n\nWe can make X equal to A as follows:\n\nChoose i=2. X becomes (0,0,1,0).\n\nChoose i=1. X becomes (0,1,1,0).\n\nChoose i=3. X becomes (0,1,1,2).\n\nSample Input 2\n\n3\n1\n2\n1\n\nSample Output 2\n\n-1\n\nSample Input 3\n\n9\n0\n1\n1\n0\n1\n2\n2\n1\n2\n\nSample Output 3\n\n8", "sample_input": "4\n0\n1\n1\n2\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03347", "source_text": "Score : 700 points\n\nProblem Statement\n\nThere is a sequence X of length N, where every element is initially 0. Let X_i denote the i-th element of X.\n\nYou are given a sequence A of length N. The i-th element of A is A_i. Determine if we can make X equal to A by repeating the operation below. If we can, find the minimum number of operations required.\n\nChoose an integer i such that 1\\leq i\\leq N-1. Replace the value of X_{i+1} with the value of X_i plus 1.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\n0 \\leq A_i \\leq 10^9(1\\leq i\\leq N)\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1\n:\nA_N\n\nOutput\n\nIf we can make X equal to A by repeating the operation, print the minimum number of operations required. If we cannot, print -1.\n\nSample Input 1\n\n4\n0\n1\n1\n2\n\nSample Output 1\n\n3\n\nWe can make X equal to A as follows:\n\nChoose i=2. X becomes (0,0,1,0).\n\nChoose i=1. X becomes (0,1,1,0).\n\nChoose i=3. X becomes (0,1,1,2).\n\nSample Input 2\n\n3\n1\n2\n1\n\nSample Output 2\n\n-1\n\nSample Input 3\n\n9\n0\n1\n1\n0\n1\n2\n2\n1\n2\n\nSample Output 3\n\n8", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 380, "cpu_time_ms": 60, "memory_kb": 7548}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s842601618", "group_id": "codeNet:p03351", "input_text": "let a = ref 0 and b = ref 0 and c = ref 0 and d = ref 0 in\n Scanf.sscanf (read_line ()) \"%d %d %d %d\" (fun w x y z -> a := w; b := x; c := y; d := z);\n if !b - !c <= !d then begin if !a - !b <= !d then print_string \"Yes\" else print_string \"No\" end else print_string \"No\"; print_string \"\\n\"", "language": "OCaml", "metadata": {"date": 1526173949, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03351.html", "problem_id": "p03351", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03351/input.txt", "sample_output_relpath": "derived/input_output/data/p03351/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03351/OCaml/s842601618.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s842601618", "user_id": "u689344211"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "let a = ref 0 and b = ref 0 and c = ref 0 and d = ref 0 in\n Scanf.sscanf (read_line ()) \"%d %d %d %d\" (fun w x y z -> a := w; b := x; c := y; d := z);\n if !b - !c <= !d then begin if !a - !b <= !d then print_string \"Yes\" else print_string \"No\" end else print_string \"No\"; print_string \"\\n\"", "problem_context": "Score : 100 points\n\nProblem Statement\n\nThree people, A, B and C, are trying to communicate using transceivers.\nThey are standing along a number line, and the coordinates of A, B and C are a, b and c (in meters), respectively.\nTwo people can directly communicate when the distance between them is at most d meters.\nDetermine if A and C can communicate, either directly or indirectly.\nHere, A and C can indirectly communicate when A and B can directly communicate and also B and C can directly communicate.\n\nConstraints\n\n1 ≤ a,b,c ≤ 100\n\n1 ≤ d ≤ 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\na b c d\n\nOutput\n\nIf A and C can communicate, print Yes; if they cannot, print No.\n\nSample Input 1\n\n4 7 9 3\n\nSample Output 1\n\nYes\n\nA and B can directly communicate, and also B and C can directly communicate, so we should print Yes.\n\nSample Input 2\n\n100 10 1 2\n\nSample Output 2\n\nNo\n\nThey cannot communicate in this case.\n\nSample Input 3\n\n10 10 10 1\n\nSample Output 3\n\nYes\n\nThere can be multiple people at the same position.\n\nSample Input 4\n\n1 100 2 10\n\nSample Output 4\n\nYes", "sample_input": "4 7 9 3\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03351", "source_text": "Score : 100 points\n\nProblem Statement\n\nThree people, A, B and C, are trying to communicate using transceivers.\nThey are standing along a number line, and the coordinates of A, B and C are a, b and c (in meters), respectively.\nTwo people can directly communicate when the distance between them is at most d meters.\nDetermine if A and C can communicate, either directly or indirectly.\nHere, A and C can indirectly communicate when A and B can directly communicate and also B and C can directly communicate.\n\nConstraints\n\n1 ≤ a,b,c ≤ 100\n\n1 ≤ d ≤ 100\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\na b c d\n\nOutput\n\nIf A and C can communicate, print Yes; if they cannot, print No.\n\nSample Input 1\n\n4 7 9 3\n\nSample Output 1\n\nYes\n\nA and B can directly communicate, and also B and C can directly communicate, so we should print Yes.\n\nSample Input 2\n\n100 10 1 2\n\nSample Output 2\n\nNo\n\nThey cannot communicate in this case.\n\nSample Input 3\n\n10 10 10 1\n\nSample Output 3\n\nYes\n\nThere can be multiple people at the same position.\n\nSample Input 4\n\n1 100 2 10\n\nSample Output 4\n\nYes", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 295, "cpu_time_ms": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s432004329", "group_id": "codeNet:p03352", "input_text": "open Batteries\n\nlet sqrt_int x = int_of_float @@ sqrt @@ float_of_int x\n\nlet pow_below n x =\n let rec aux acc =\n if acc > x then []\n else\n acc :: (aux @@ ( * ) n acc)\n in\n aux n\n\nlet lower_than x =\n let num_exp_below =\n let rec aux n =\n if n =1 then\n [1]\n else\n (pow_below n x) @ (aux @@ pred n)\n in\n let num = sqrt_int x in\n List.sort compare @@ aux num in\n num_exp_below\n\nlet main () =\n int_of_string @@ input_line stdin\n |> lower_than\n |> List.rev\n |> List.hd\n |> print_int\n\nlet () = main ()\n", "language": "OCaml", "metadata": {"date": 1545841402, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03352.html", "problem_id": "p03352", "resource_group": "low_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/OCaml/s432004329.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s432004329", "user_id": "u802614675"}, "prompt_components": {"gold_output": "9\n", "input_to_evaluate": "open Batteries\n\nlet sqrt_int x = int_of_float @@ sqrt @@ float_of_int x\n\nlet pow_below n x =\n let rec aux acc =\n if acc > x then []\n else\n acc :: (aux @@ ( * ) n acc)\n in\n aux n\n\nlet lower_than x =\n let num_exp_below =\n let rec aux n =\n if n =1 then\n [1]\n else\n (pow_below n x) @ (aux @@ pred n)\n in\n let num = sqrt_int x in\n List.sort compare @@ aux num in\n num_exp_below\n\nlet main () =\n int_of_string @@ input_line stdin\n |> lower_than\n |> List.rev\n |> List.hd\n |> print_int\n\nlet () = main ()\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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 5, "memory_kb": 1408}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s353224353", "group_id": "codeNet:p03353", "input_text": "module Ss = Set.Make(String)\n\nlet s = read_line ()\nlet len = String.length s\nlet k = read_int ()\n\nlet f i j set =\n let sub = String.sub s i j in\n if (Ss.mem sub set) then set\n else (Ss.add sub set)\n\nlet rec inner i j set =\n if j <= k then\n let set' = f i j set in\n inner i (succ j) set'\n else\n set\n\nlet rec outer i set =\n if i <= (len - 1) then\n let set' = inner i 1 set in\n outer (succ i) set'\n else\n set\n\nlet () =\n let ls = outer 0 Ss.empty |> Ss.elements in\n let ar = Array.of_list ls in\n let () = Array.fast_sort String.compare ar in\n print_endline ar.(k-1)\n", "language": "OCaml", "metadata": {"date": 1526180435, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03353.html", "problem_id": "p03353", "resource_group": "low_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/OCaml/s353224353.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s353224353", "user_id": "u987869509"}, "prompt_components": {"gold_output": "b\n", "input_to_evaluate": "module Ss = Set.Make(String)\n\nlet s = read_line ()\nlet len = String.length s\nlet k = read_int ()\n\nlet f i j set =\n let sub = String.sub s i j in\n if (Ss.mem sub set) then set\n else (Ss.add sub set)\n\nlet rec inner i j set =\n if j <= k then\n let set' = f i j set in\n inner i (succ j) set'\n else\n set\n\nlet rec outer i set =\n if i <= (len - 1) then\n let set' = inner i 1 set in\n outer (succ i) set'\n else\n set\n\nlet () =\n let ls = outer 0 Ss.empty |> Ss.elements in\n let ar = Array.of_list ls in\n let () = Array.fast_sort String.compare ar in\n print_endline ar.(k-1)\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou are given a string s.\nAmong the different substrings of s, print the K-th lexicographically smallest one.\n\nA substring of s is a string obtained by taking out a non-empty contiguous part in s.\nFor example, if s = ababc, a, bab and ababc are substrings of s, while ac, z and an empty string are not.\nAlso, we say that substrings are different when they are different as strings.\n\nLet X = x_{1}x_{2}...x_{n} and Y = y_{1}y_{2}...y_{m} be two distinct strings. X is lexicographically larger than Y if and only if Y is a prefix of X or x_{j} > y_{j} where j is the smallest integer such that x_{j} \\neq y_{j}.\n\nConstraints\n\n1 ≤ |s| ≤ 5000\n\ns consists of lowercase English letters.\n\n1 ≤ K ≤ 5\n\ns has at least K different substrings.\n\nPartial Score\n\n200 points will be awarded as a partial score for passing the test set satisfying |s| ≤ 50.\n\nInput\n\nInput is given from Standard Input in the following format:\n\ns\nK\n\nOutput\n\nPrint the K-th lexicographically smallest substring of K.\n\nSample Input 1\n\naba\n4\n\nSample Output 1\n\nb\n\ns has five substrings: a, b, ab, ba and aba.\nAmong them, we should print the fourth smallest one, b.\nNote that we do not count a twice.\n\nSample Input 2\n\natcoderandatcodeer\n5\n\nSample Output 2\n\nandat\n\nSample Input 3\n\nz\n1\n\nSample Output 3\n\nz", "sample_input": "aba\n4\n"}, "reference_outputs": ["b\n"], "source_document_id": "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 591, "cpu_time_ms": 19, "memory_kb": 5248}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s435867243", "group_id": "codeNet:p03354", "input_text": "let () =\n Scanf.scanf \"%d %d\" @@ fun n m ->\n let uf = Array.make (n+1) (-1) in\n let rec find x =\n if uf.(x) < 0 then x else begin\n let x' = find uf.(x) in\n uf.(x) <- x'; x'\n end in\n let unite x y =\n let x, y = find x, find y in\n if x <> y then begin\n if uf.(x) < uf.(y) then (\n uf.(x) <- uf.(x) + uf.(y); uf.(y) <- x\n ) else (\n uf.(y) <- uf.(x) + uf.(y); uf.(x) <- y)\n end in\n let same x y = find x = find y in\n\n let p = Array.init n (fun _ -> Scanf.scanf \" %d\" ((+) 0)) in\n for _ = 1 to m do Scanf.scanf \" %d %d\" unite done;\n\n Array.init n (fun i -> if same (i+1) p.(i) then 1 else 0)\n |> Array.fold_left (+) 0 |> Printf.printf \"%d\\n\"", "language": "OCaml", "metadata": {"date": 1532776154, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03354.html", "problem_id": "p03354", "resource_group": "low_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/OCaml/s435867243.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s435867243", "user_id": "u798181098"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "let () =\n Scanf.scanf \"%d %d\" @@ fun n m ->\n let uf = Array.make (n+1) (-1) in\n let rec find x =\n if uf.(x) < 0 then x else begin\n let x' = find uf.(x) in\n uf.(x) <- x'; x'\n end in\n let unite x y =\n let x, y = find x, find y in\n if x <> y then begin\n if uf.(x) < uf.(y) then (\n uf.(x) <- uf.(x) + uf.(y); uf.(y) <- x\n ) else (\n uf.(y) <- uf.(x) + uf.(y); uf.(x) <- y)\n end in\n let same x y = find x = find y in\n\n let p = Array.init n (fun _ -> Scanf.scanf \" %d\" ((+) 0)) in\n for _ = 1 to m do Scanf.scanf \" %d %d\" unite done;\n\n Array.init n (fun i -> if same (i+1) p.(i) then 1 else 0)\n |> Array.fold_left (+) 0 |> Printf.printf \"%d\\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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 74, "memory_kb": 6272}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s350495298", "group_id": "codeNet:p03355", "input_text": "module CharMap = Map.Make (Char)\n\nlet () =\n let s = read_line () in\n Array.init (String.length s) (fun i -> i, s.[i])\n |> Array.fold_left (fun m (i, c) ->\n CharMap.add c (i :: try CharMap.find c m with Not_found -> []) m) CharMap.empty\n |> CharMap.bindings\n |> List.map (fun (_, is) ->\n List.map (fun i ->\n Array.init 5 (fun n ->\n try [String.init (n + 1) (fun j -> s.[i + j])]\n with _ -> [])\n |> Array.to_list\n |> List.concat) is |> List.concat)\n |> List.concat\n |> List.sort_uniq compare\n |> Scanf.scanf \"%d\\n\" (fun k l -> List.nth l (k - 1))\n |> print_endline", "language": "OCaml", "metadata": {"date": 1526178236, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03355.html", "problem_id": "p03355", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03355/input.txt", "sample_output_relpath": "derived/input_output/data/p03355/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03355/OCaml/s350495298.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s350495298", "user_id": "u504158101"}, "prompt_components": {"gold_output": "b\n", "input_to_evaluate": "module CharMap = Map.Make (Char)\n\nlet () =\n let s = read_line () in\n Array.init (String.length s) (fun i -> i, s.[i])\n |> Array.fold_left (fun m (i, c) ->\n CharMap.add c (i :: try CharMap.find c m with Not_found -> []) m) CharMap.empty\n |> CharMap.bindings\n |> List.map (fun (_, is) ->\n List.map (fun i ->\n Array.init 5 (fun n ->\n try [String.init (n + 1) (fun j -> s.[i + j])]\n with _ -> [])\n |> Array.to_list\n |> List.concat) is |> List.concat)\n |> List.concat\n |> List.sort_uniq compare\n |> Scanf.scanf \"%d\\n\" (fun k l -> List.nth l (k - 1))\n |> print_endline", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou are given a string s.\nAmong the different substrings of s, print the K-th lexicographically smallest one.\n\nA substring of s is a string obtained by taking out a non-empty contiguous part in s.\nFor example, if s = ababc, a, bab and ababc are substrings of s, while ac, z and an empty string are not.\nAlso, we say that substrings are different when they are different as strings.\n\nLet X = x_{1}x_{2}...x_{n} and Y = y_{1}y_{2}...y_{m} be two distinct strings. X is lexicographically larger than Y if and only if Y is a prefix of X or x_{j} > y_{j} where j is the smallest integer such that x_{j} \\neq y_{j}.\n\nConstraints\n\n1 ≤ |s| ≤ 5000\n\ns consists of lowercase English letters.\n\n1 ≤ K ≤ 5\n\ns has at least K different substrings.\n\nPartial Score\n\n200 points will be awarded as a partial score for passing the test set satisfying |s| ≤ 50.\n\nInput\n\nInput is given from Standard Input in the following format:\n\ns\nK\n\nOutput\n\nPrint the K-th lexicographically smallest substring of K.\n\nSample Input 1\n\naba\n4\n\nSample Output 1\n\nb\n\ns has five substrings: a, b, ab, ba and aba.\nAmong them, we should print the fourth smallest one, b.\nNote that we do not count a twice.\n\nSample Input 2\n\natcoderandatcodeer\n5\n\nSample Output 2\n\nandat\n\nSample Input 3\n\nz\n1\n\nSample Output 3\n\nz", "sample_input": "aba\n4\n"}, "reference_outputs": ["b\n"], "source_document_id": "p03355", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou are given a string s.\nAmong the different substrings of s, print the K-th lexicographically smallest one.\n\nA substring of s is a string obtained by taking out a non-empty contiguous part in s.\nFor example, if s = ababc, a, bab and ababc are substrings of s, while ac, z and an empty string are not.\nAlso, we say that substrings are different when they are different as strings.\n\nLet X = x_{1}x_{2}...x_{n} and Y = y_{1}y_{2}...y_{m} be two distinct strings. X is lexicographically larger than Y if and only if Y is a prefix of X or x_{j} > y_{j} where j is the smallest integer such that x_{j} \\neq y_{j}.\n\nConstraints\n\n1 ≤ |s| ≤ 5000\n\ns consists of lowercase English letters.\n\n1 ≤ K ≤ 5\n\ns has at least K different substrings.\n\nPartial Score\n\n200 points will be awarded as a partial score for passing the test set satisfying |s| ≤ 50.\n\nInput\n\nInput is given from Standard Input in the following format:\n\ns\nK\n\nOutput\n\nPrint the K-th lexicographically smallest substring of K.\n\nSample Input 1\n\naba\n4\n\nSample Output 1\n\nb\n\ns has five substrings: a, b, ab, ba and aba.\nAmong them, we should print the fourth smallest one, b.\nNote that we do not count a twice.\n\nSample Input 2\n\natcoderandatcodeer\n5\n\nSample Output 2\n\nandat\n\nSample Input 3\n\nz\n1\n\nSample Output 3\n\nz", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 620, "cpu_time_ms": 17, "memory_kb": 6528}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s176085397", "group_id": "codeNet:p03357", "input_text": "let () = Scanf.scanf \"%d\\n\" @@ fun n ->\n let cas = Array.init (2 * n) @@ fun _ -> Scanf.scanf \"%c %d\\n\" @@ fun c a -> c, a in\n let inv_ws = Array.make n 0 in\n let inv_bs = Array.make n 0 in\n let acc_ws = Array.make_matrix (2 * n + 1) (n + 1) 0 in\n let acc_bs = Array.make_matrix (2 * n + 1) (n + 1) 0 in\n for i = 2 * n - 1 downto 0 do\n begin match cas.(i) with\n | ('W', a) ->\n inv_ws.(a - 1) <- i;\n acc_ws.(i).(a) <- 1 + acc_ws.(i).(a)\n | ('B', a) ->\n inv_bs.(a - 1) <- i;\n acc_bs.(i).(a) <- 1 + acc_bs.(i).(a)\n end;\n for j = 1 to n do\n acc_ws.(i).(j) <- acc_ws.(i).(j) + acc_ws.(i).(j - 1);\n acc_bs.(i).(j) <- acc_bs.(i).(j) + acc_bs.(i).(j - 1)\n done;\n for j = 0 to n do\n acc_ws.(i).(j) <- acc_ws.(i).(j) + acc_ws.(i + 1).(j);\n acc_bs.(i).(j) <- acc_bs.(i).(j) + acc_bs.(i + 1).(j)\n done\n done;\n let dp = Array.make_matrix (n + 1) (n + 1) max_int in\n dp.(0).(0) <- 0;\n for w = 1 to n do\n dp.(w).(0) <- dp.(w - 1).(0) - w + 1\n + inv_ws.(w - 1)\n + acc_ws.(inv_ws.(w - 1) + 1).(w)\n done;\n for b = 1 to n do\n dp.(0).(b) <- dp.(0).(b - 1) - b + 1\n + inv_bs.(b - 1)\n + acc_bs.(inv_bs.(b - 1) + 1).(b)\n done;\n for w = 1 to n do\n for b = 1 to n do\n dp.(w).(b) <- min\n ( dp.(w - 1).(b) + inv_ws.(w - 1)\n + acc_ws.(inv_ws.(w - 1) + 1).(w)\n + acc_bs.(inv_ws.(w - 1) + 1).(b) )\n ( dp.(w).(b - 1) + inv_bs.(b - 1)\n + acc_ws.(inv_bs.(b - 1) + 1).(w)\n + acc_bs.(inv_bs.(b - 1) + 1).(b) ) - w - b + 1\n done\n done;\n Printf.printf \"%d\\n\" @@ dp.(n).(n)\n", "language": "OCaml", "metadata": {"date": 1536134157, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03357.html", "problem_id": "p03357", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03357/input.txt", "sample_output_relpath": "derived/input_output/data/p03357/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03357/OCaml/s176085397.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s176085397", "user_id": "u504158101"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "let () = Scanf.scanf \"%d\\n\" @@ fun n ->\n let cas = Array.init (2 * n) @@ fun _ -> Scanf.scanf \"%c %d\\n\" @@ fun c a -> c, a in\n let inv_ws = Array.make n 0 in\n let inv_bs = Array.make n 0 in\n let acc_ws = Array.make_matrix (2 * n + 1) (n + 1) 0 in\n let acc_bs = Array.make_matrix (2 * n + 1) (n + 1) 0 in\n for i = 2 * n - 1 downto 0 do\n begin match cas.(i) with\n | ('W', a) ->\n inv_ws.(a - 1) <- i;\n acc_ws.(i).(a) <- 1 + acc_ws.(i).(a)\n | ('B', a) ->\n inv_bs.(a - 1) <- i;\n acc_bs.(i).(a) <- 1 + acc_bs.(i).(a)\n end;\n for j = 1 to n do\n acc_ws.(i).(j) <- acc_ws.(i).(j) + acc_ws.(i).(j - 1);\n acc_bs.(i).(j) <- acc_bs.(i).(j) + acc_bs.(i).(j - 1)\n done;\n for j = 0 to n do\n acc_ws.(i).(j) <- acc_ws.(i).(j) + acc_ws.(i + 1).(j);\n acc_bs.(i).(j) <- acc_bs.(i).(j) + acc_bs.(i + 1).(j)\n done\n done;\n let dp = Array.make_matrix (n + 1) (n + 1) max_int in\n dp.(0).(0) <- 0;\n for w = 1 to n do\n dp.(w).(0) <- dp.(w - 1).(0) - w + 1\n + inv_ws.(w - 1)\n + acc_ws.(inv_ws.(w - 1) + 1).(w)\n done;\n for b = 1 to n do\n dp.(0).(b) <- dp.(0).(b - 1) - b + 1\n + inv_bs.(b - 1)\n + acc_bs.(inv_bs.(b - 1) + 1).(b)\n done;\n for w = 1 to n do\n for b = 1 to n do\n dp.(w).(b) <- min\n ( dp.(w - 1).(b) + inv_ws.(w - 1)\n + acc_ws.(inv_ws.(w - 1) + 1).(w)\n + acc_bs.(inv_ws.(w - 1) + 1).(b) )\n ( dp.(w).(b - 1) + inv_bs.(b - 1)\n + acc_ws.(inv_bs.(b - 1) + 1).(w)\n + acc_bs.(inv_bs.(b - 1) + 1).(b) ) - w - b + 1\n done\n done;\n Printf.printf \"%d\\n\" @@ dp.(n).(n)\n", "problem_context": "Score : 600 points\n\nProblem Statement\n\nThere are 2N balls, N white and N black, arranged in a row. The integers from 1 through N are written on the white balls, one on each ball, and they are also written on the black balls, one on each ball.\nThe integer written on the i-th ball from the left (1 ≤ i ≤ 2N) is a_i, and the color of this ball is represented by a letter c_i.\nc_i = W represents the ball is white; c_i = B represents the ball is black.\n\nTakahashi the human wants to achieve the following objective:\n\nFor every pair of integers (i,j) such that 1 ≤ i < j ≤ N, the white ball with i written on it is to the left of the white ball with j written on it.\n\nFor every pair of integers (i,j) such that 1 ≤ i < j ≤ N, the black ball with i written on it is to the left of the black ball with j written on it.\n\nIn order to achieve this, he can perform the following operation:\n\nSwap two adjacent balls.\n\nFind the minimum number of operations required to achieve the objective.\n\nConstraints\n\n1 ≤ N ≤ 2000\n\n1 ≤ a_i ≤ N\n\nc_i = W or c_i = B.\n\nIf i ≠ j, (a_i,c_i) ≠ (a_j,c_j).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nc_1 a_1\nc_2 a_2\n:\nc_{2N} a_{2N}\n\nOutput\n\nPrint the minimum number of operations required to achieve the objective.\n\nSample Input 1\n\n3\nB 1\nW 2\nB 3\nW 1\nW 3\nB 2\n\nSample Output 1\n\n4\n\nThe objective can be achieved in four operations, for example, as follows:\n\nSwap the black 3 and white 1.\n\nSwap the white 1 and white 2.\n\nSwap the black 3 and white 3.\n\nSwap the black 3 and black 2.\n\nSample Input 2\n\n4\nB 4\nW 4\nB 3\nW 3\nB 2\nW 2\nB 1\nW 1\n\nSample Output 2\n\n18\n\nSample Input 3\n\n9\nW 3\nB 1\nB 4\nW 1\nB 5\nW 9\nW 2\nB 6\nW 5\nB 3\nW 8\nB 9\nW 7\nB 2\nB 8\nW 4\nW 6\nB 7\n\nSample Output 3\n\n41", "sample_input": "3\nB 1\nW 2\nB 3\nW 1\nW 3\nB 2\n"}, "reference_outputs": ["4\n"], "source_document_id": "p03357", "source_text": "Score : 600 points\n\nProblem Statement\n\nThere are 2N balls, N white and N black, arranged in a row. The integers from 1 through N are written on the white balls, one on each ball, and they are also written on the black balls, one on each ball.\nThe integer written on the i-th ball from the left (1 ≤ i ≤ 2N) is a_i, and the color of this ball is represented by a letter c_i.\nc_i = W represents the ball is white; c_i = B represents the ball is black.\n\nTakahashi the human wants to achieve the following objective:\n\nFor every pair of integers (i,j) such that 1 ≤ i < j ≤ N, the white ball with i written on it is to the left of the white ball with j written on it.\n\nFor every pair of integers (i,j) such that 1 ≤ i < j ≤ N, the black ball with i written on it is to the left of the black ball with j written on it.\n\nIn order to achieve this, he can perform the following operation:\n\nSwap two adjacent balls.\n\nFind the minimum number of operations required to achieve the objective.\n\nConstraints\n\n1 ≤ N ≤ 2000\n\n1 ≤ a_i ≤ N\n\nc_i = W or c_i = B.\n\nIf i ≠ j, (a_i,c_i) ≠ (a_j,c_j).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nc_1 a_1\nc_2 a_2\n:\nc_{2N} a_{2N}\n\nOutput\n\nPrint the minimum number of operations required to achieve the objective.\n\nSample Input 1\n\n3\nB 1\nW 2\nB 3\nW 1\nW 3\nB 2\n\nSample Output 1\n\n4\n\nThe objective can be achieved in four operations, for example, as follows:\n\nSwap the black 3 and white 1.\n\nSwap the white 1 and white 2.\n\nSwap the black 3 and white 3.\n\nSwap the black 3 and black 2.\n\nSample Input 2\n\n4\nB 4\nW 4\nB 3\nW 3\nB 2\nW 2\nB 1\nW 1\n\nSample Output 2\n\n18\n\nSample Input 3\n\n9\nW 3\nB 1\nB 4\nW 1\nB 5\nW 9\nW 2\nB 6\nW 5\nB 3\nW 8\nB 9\nW 7\nB 2\nB 8\nW 4\nW 6\nB 7\n\nSample Output 3\n\n41", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1611, "cpu_time_ms": 515, "memory_kb": 161976}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s115475919", "group_id": "codeNet:p03357", "input_text": "module MultiSet = struct\n (* 多重集合 *)\n\n module type OrderedType =\n sig\n type t\n val compare: t -> t -> int\n end\n\n module type S =\n sig\n type elt\n type t\n (* 空集合 *)\n val empty : t\n (* 要素数 *)\n val cardinal : t -> int\n (* 要素xをn個追加 *)\n val add : elt -> int -> t -> t\n (* 要素xをn個削除 要素がn個以上存在しない場合は全て削除 *)\n val remove : elt -> int -> t -> t\n (* 要素xの数を数える *)\n val count : elt -> t -> int\n (* xより小さい要素の数を数える *)\n val count_lt : elt -> t -> int\n (* xより大きい要素の数を数える *)\n val count_gt : elt -> t -> int\n (* 昇順に見た時のn番目の要素 範囲外ならNot_foundを投げる *)\n val nth_inc : int -> t -> elt\n (* 降順に見た時のn番目の要素 範囲外ならNot_foundを投げる *)\n val nth_dec : int -> t -> elt\n (* 昇順に見てn要素を取り出す n要素に満たなければ全ての要素を昇順に列挙する *)\n val take_inc : int -> t -> elt list\n (* 降順に見てn要素を取り出す n要素に満たなければ全ての要素を降順に列挙する *)\n val take_dec : int -> t -> elt list\n (* 全ての要素を昇順に列挙する *)\n val elements_inc : t -> elt list\n (* 全ての要素を降順に列挙する *)\n val elements_dec : t -> elt list\n (* 昇順に要素を畳み込む *)\n val fold_inc : ('a -> elt -> 'a) -> 'a -> t -> 'a\n (* 降順に要素を畳み込む *)\n val fold_dec : (elt -> 'a -> 'a) -> t -> 'a -> 'a\n (* 最小の要素 空集合が与えられた場合はNot_foundを投げる *)\n val min_elt : t -> elt\n (* 最大の要素 空集合が与えられた場合はNot_foundを投げる *)\n val max_elt : t -> elt\n end\n\n module Make (Ord : OrderedType) : S with type elt = Ord.t =\n struct\n type elt = Ord.t\n\n (* MapからパクったのでAVL木の変種(高さの差を2以下まで許容する) *)\n type t =\n | Empty\n | Node of body\n and body =\n { left : t;\n data : elt;\n count : int;\n right : t;\n height : int;\n cardinal : int }\n\n let empty = Empty\n\n let height = function\n | Empty -> 0\n | Node { height } -> height\n\n let cardinal = function\n | Empty -> 0\n | Node { cardinal } -> cardinal\n\n let create ~left ~data ~count ~right =\n Node\n { left; data; count; right;\n height = 1 + max (height left) (height right);\n cardinal = count + cardinal left + cardinal right }\n\n let balance ~left:l ~data:x ~count:d ~right:r =\n let hl = height l in\n let hr = height r in\n if hl > hr + 2 then begin\n match l with\n | Empty -> invalid_arg \"MultiSet.balance\" | Node { left = ll; data = lv; count = ld; right = lr } ->\n if height ll >= height lr then\n create ll lv ld (create lr x d r)\n else begin\n match lr with\n | Empty -> invalid_arg \"MultiSet.balance\"\n | Node { left = lrl; data = lrv; count = lrd; right = lrr } ->\n create (create ll lv ld lrl) lrv lrd (create lrr x d r)\n end\n end else if hr > hl + 2 then begin\n match r with\n | Empty -> invalid_arg \"MultiSet.balance\"\n | Node { left = rl; data = rv; count = rd; right = rr } ->\n if height rr >= height rl then\n create (create l x d rl) rv rd rr\n else begin\n match rl with\n | Empty -> invalid_arg \"MultiSet.balance\"\n | Node { left = rll; data = rlv; count = rld; right = rlr } ->\n create (create l x d rll) rlv rld (create rlr rv rd rr)\n end\n end else create l x d r\n\n let rec add x n = function\n | Empty -> create Empty x 1 Empty\n | Node { left; data = y; count; right } ->\n match Ord.compare x y with\n | 0 ->\n create left x (count + n) right\n | c when c < 0 ->\n balance (add x n left) y count right\n | _ ->\n balance left y count (add x n right)\n\n (* 最小の要素とその数を返す *)\n let rec count_min_elt = function\n | Empty -> raise Not_found\n | Node { left = Empty; data; count } -> (data, count)\n | Node { left } -> count_min_elt left\n\n (* 最小の要素を全て削除する *)\n let rec clear_min_elt = function\n | Empty -> invalid_arg \"MultiSet.clear_min_elt\"\n | Node { left = Empty; right } -> right\n | Node { left; data; count; right } -> balance (clear_min_elt left) data count right\n\n let merge t1 t2 =\n match t1, t2 with\n | Empty, t\n | t, Empty -> t\n | Node _, Node _ ->\n let (x, c) = count_min_elt t2 in\n balance t1 x c (clear_min_elt t2)\n\n let rec remove x n = function\n | Empty -> Empty\n | Node { left; data = y; count; right } ->\n match Ord.compare x y with\n | 0 ->\n if count <= n then\n merge left right\n else\n create left y (count - n) right\n | c when c < 0 ->\n balance (remove x n left) y count right\n | _ ->\n balance left y count (remove x n right)\n\n let rec count x = function\n | Empty -> 0\n | Node { left; data = y; count = n; right } ->\n match Ord.compare x y with\n | 0 -> n\n | c when c < 0 ->\n count x left\n | _ ->\n count x right\n\n let rec count_lt x = function\n | Empty -> 0\n | Node { left; data = y; count; right } ->\n match Ord.compare x y with\n | 0 ->\n cardinal left\n | c when c < 0 ->\n count_lt x left\n | _ ->\n count_lt x right + count + cardinal left\n\n let rec count_gt x = function\n | Empty -> 0\n | Node { left; data = y; count; right } ->\n match Ord.compare x y with\n | 0 ->\n cardinal right\n | c when 0 < c ->\n count_gt x right\n | _ ->\n count_gt x left + count + cardinal right\n\n let rec nth_inc n = function\n | Empty -> raise Not_found\n | Node { left; data; count; right } ->\n if n < cardinal left then\n nth_inc n left\n else if n < cardinal left + count then\n data\n else\n nth_inc (n - cardinal left - count) right\n\n let rec nth_dec n = function\n | Empty -> raise Not_found\n | Node { left; data; count; right } ->\n if n < cardinal right then\n nth_dec n right\n else if n < cardinal right + count then\n data\n else\n nth_dec (n - cardinal right - count) left\n\n let rec elements_inc acc = function\n | Empty -> acc\n | Node { left; data; count; right } ->\n elements_inc\n (Array.fold_left (fun acc x -> x :: acc)\n (elements_inc acc right)\n (Array.make count data)) left\n\n let rec elements_dec acc = function\n | Empty -> acc\n | Node { left; data; count; right } ->\n elements_dec\n (Array.fold_left (fun acc x -> x :: acc)\n (elements_dec acc left)\n (Array.make count data)) right\n\n let rec take_inc n = function\n | Empty -> []\n | Node { left; data; count; right } ->\n if n < cardinal left then\n take_inc n left\n else if n < cardinal left + count then\n elements_inc (Array.to_list (Array.make (n - cardinal left) data)) left\n else\n elements_inc\n (Array.fold_left (fun acc x -> x :: acc)\n (take_inc (n - cardinal left - count) right)\n (Array.make count data)) left\n\n let rec take_dec n = function\n | Empty -> []\n | Node { left; data; count; right } ->\n if n < cardinal right then\n take_dec n right\n else if n < cardinal right + count then\n elements_dec (Array.to_list (Array.make (n - cardinal right) data)) right\n else\n elements_dec\n (Array.fold_left (fun acc x -> x :: acc)\n (take_dec (n - cardinal right - count) left)\n (Array.make count data)) right\n\n let elements_inc = elements_inc []\n let elements_dec = elements_dec []\n\n let rec fold_inc f acc = function\n | Empty -> acc\n | Node { left; data; count; right } ->\n fold_inc f\n (Array.fold_left f\n (fold_inc f acc left)\n (Array.make count data)) right\n\n let rec fold_dec f acc = function\n | Empty -> acc\n | Node { left; data; count; right } ->\n fold_dec f\n (Array.fold_right f\n (Array.make count data)\n (fold_dec f acc right)) left\n let fold_dec f t acc = fold_dec f acc t\n\n let rec min_elt t = fst (count_min_elt t)\n\n let rec max_elt = function\n | Empty -> raise Not_found\n | Node { data; right = Empty } -> data\n | Node { right } -> max_elt right\n end\nend\n\nmodule IntMultiSet = MultiSet.Make (struct\n type t = int\n let compare = compare\nend)\n\nlet memoize n f =\n let dp = Hashtbl.create n in\n let rec get x =\n try Hashtbl.find dp x with\n | Not_found ->\n let result = f get x in\n Hashtbl.add dp x result;\n result in\n get\n\nlet () = Scanf.scanf \"%d\\n\" @@ fun n ->\n let cas = Array.init (2 * n) @@ fun _ -> Scanf.scanf \"%c %d\\n\" @@ fun c a -> c, a in\n let inv_ws = Array.make n 0 in\n let inv_bs = Array.make n 0 in\n let acc_ws = Array.make (2 * n + 1) IntMultiSet.empty in\n let acc_bs = Array.make (2 * n + 1) IntMultiSet.empty in\n for i = 2 * n - 1 downto 0 do\n match cas.(i) with\n | ('W', a) ->\n inv_ws.(a - 1) <- i;\n acc_ws.(i) <- IntMultiSet.add (a - 1) 1 acc_ws.(i + 1);\n acc_bs.(i) <- acc_bs.(i + 1)\n | ('B', a) ->\n inv_bs.(a - 1) <- i;\n acc_ws.(i) <- acc_ws.(i + 1);\n acc_bs.(i) <- IntMultiSet.add (a - 1) 1 acc_bs.(i + 1)\n done;\n let dp = memoize ((n + 1) * (n + 1)) @@ fun dp (w, b) ->\n if w = 0 && b = 0 then 0\n else min\n (if w = 0 then max_int else\n dp (w - 1, b) + inv_ws.(w - 1) - w - b + 1\n + IntMultiSet.count_lt w acc_ws.(inv_ws.(w - 1) + 1)\n + IntMultiSet.count_lt b acc_bs.(inv_ws.(w - 1) + 1))\n (if b = 0 then max_int else\n dp (w, b - 1) + inv_bs.(b - 1) - w - b + 1\n + IntMultiSet.count_lt w acc_ws.(inv_bs.(b - 1) + 1)\n + IntMultiSet.count_lt b acc_bs.(inv_bs.(b - 1) + 1)) in\n Printf.printf \"%d\\n\" @@ dp (n, n)\n", "language": "OCaml", "metadata": {"date": 1536132598, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03357.html", "problem_id": "p03357", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03357/input.txt", "sample_output_relpath": "derived/input_output/data/p03357/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03357/OCaml/s115475919.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s115475919", "user_id": "u504158101"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "module MultiSet = struct\n (* 多重集合 *)\n\n module type OrderedType =\n sig\n type t\n val compare: t -> t -> int\n end\n\n module type S =\n sig\n type elt\n type t\n (* 空集合 *)\n val empty : t\n (* 要素数 *)\n val cardinal : t -> int\n (* 要素xをn個追加 *)\n val add : elt -> int -> t -> t\n (* 要素xをn個削除 要素がn個以上存在しない場合は全て削除 *)\n val remove : elt -> int -> t -> t\n (* 要素xの数を数える *)\n val count : elt -> t -> int\n (* xより小さい要素の数を数える *)\n val count_lt : elt -> t -> int\n (* xより大きい要素の数を数える *)\n val count_gt : elt -> t -> int\n (* 昇順に見た時のn番目の要素 範囲外ならNot_foundを投げる *)\n val nth_inc : int -> t -> elt\n (* 降順に見た時のn番目の要素 範囲外ならNot_foundを投げる *)\n val nth_dec : int -> t -> elt\n (* 昇順に見てn要素を取り出す n要素に満たなければ全ての要素を昇順に列挙する *)\n val take_inc : int -> t -> elt list\n (* 降順に見てn要素を取り出す n要素に満たなければ全ての要素を降順に列挙する *)\n val take_dec : int -> t -> elt list\n (* 全ての要素を昇順に列挙する *)\n val elements_inc : t -> elt list\n (* 全ての要素を降順に列挙する *)\n val elements_dec : t -> elt list\n (* 昇順に要素を畳み込む *)\n val fold_inc : ('a -> elt -> 'a) -> 'a -> t -> 'a\n (* 降順に要素を畳み込む *)\n val fold_dec : (elt -> 'a -> 'a) -> t -> 'a -> 'a\n (* 最小の要素 空集合が与えられた場合はNot_foundを投げる *)\n val min_elt : t -> elt\n (* 最大の要素 空集合が与えられた場合はNot_foundを投げる *)\n val max_elt : t -> elt\n end\n\n module Make (Ord : OrderedType) : S with type elt = Ord.t =\n struct\n type elt = Ord.t\n\n (* MapからパクったのでAVL木の変種(高さの差を2以下まで許容する) *)\n type t =\n | Empty\n | Node of body\n and body =\n { left : t;\n data : elt;\n count : int;\n right : t;\n height : int;\n cardinal : int }\n\n let empty = Empty\n\n let height = function\n | Empty -> 0\n | Node { height } -> height\n\n let cardinal = function\n | Empty -> 0\n | Node { cardinal } -> cardinal\n\n let create ~left ~data ~count ~right =\n Node\n { left; data; count; right;\n height = 1 + max (height left) (height right);\n cardinal = count + cardinal left + cardinal right }\n\n let balance ~left:l ~data:x ~count:d ~right:r =\n let hl = height l in\n let hr = height r in\n if hl > hr + 2 then begin\n match l with\n | Empty -> invalid_arg \"MultiSet.balance\" | Node { left = ll; data = lv; count = ld; right = lr } ->\n if height ll >= height lr then\n create ll lv ld (create lr x d r)\n else begin\n match lr with\n | Empty -> invalid_arg \"MultiSet.balance\"\n | Node { left = lrl; data = lrv; count = lrd; right = lrr } ->\n create (create ll lv ld lrl) lrv lrd (create lrr x d r)\n end\n end else if hr > hl + 2 then begin\n match r with\n | Empty -> invalid_arg \"MultiSet.balance\"\n | Node { left = rl; data = rv; count = rd; right = rr } ->\n if height rr >= height rl then\n create (create l x d rl) rv rd rr\n else begin\n match rl with\n | Empty -> invalid_arg \"MultiSet.balance\"\n | Node { left = rll; data = rlv; count = rld; right = rlr } ->\n create (create l x d rll) rlv rld (create rlr rv rd rr)\n end\n end else create l x d r\n\n let rec add x n = function\n | Empty -> create Empty x 1 Empty\n | Node { left; data = y; count; right } ->\n match Ord.compare x y with\n | 0 ->\n create left x (count + n) right\n | c when c < 0 ->\n balance (add x n left) y count right\n | _ ->\n balance left y count (add x n right)\n\n (* 最小の要素とその数を返す *)\n let rec count_min_elt = function\n | Empty -> raise Not_found\n | Node { left = Empty; data; count } -> (data, count)\n | Node { left } -> count_min_elt left\n\n (* 最小の要素を全て削除する *)\n let rec clear_min_elt = function\n | Empty -> invalid_arg \"MultiSet.clear_min_elt\"\n | Node { left = Empty; right } -> right\n | Node { left; data; count; right } -> balance (clear_min_elt left) data count right\n\n let merge t1 t2 =\n match t1, t2 with\n | Empty, t\n | t, Empty -> t\n | Node _, Node _ ->\n let (x, c) = count_min_elt t2 in\n balance t1 x c (clear_min_elt t2)\n\n let rec remove x n = function\n | Empty -> Empty\n | Node { left; data = y; count; right } ->\n match Ord.compare x y with\n | 0 ->\n if count <= n then\n merge left right\n else\n create left y (count - n) right\n | c when c < 0 ->\n balance (remove x n left) y count right\n | _ ->\n balance left y count (remove x n right)\n\n let rec count x = function\n | Empty -> 0\n | Node { left; data = y; count = n; right } ->\n match Ord.compare x y with\n | 0 -> n\n | c when c < 0 ->\n count x left\n | _ ->\n count x right\n\n let rec count_lt x = function\n | Empty -> 0\n | Node { left; data = y; count; right } ->\n match Ord.compare x y with\n | 0 ->\n cardinal left\n | c when c < 0 ->\n count_lt x left\n | _ ->\n count_lt x right + count + cardinal left\n\n let rec count_gt x = function\n | Empty -> 0\n | Node { left; data = y; count; right } ->\n match Ord.compare x y with\n | 0 ->\n cardinal right\n | c when 0 < c ->\n count_gt x right\n | _ ->\n count_gt x left + count + cardinal right\n\n let rec nth_inc n = function\n | Empty -> raise Not_found\n | Node { left; data; count; right } ->\n if n < cardinal left then\n nth_inc n left\n else if n < cardinal left + count then\n data\n else\n nth_inc (n - cardinal left - count) right\n\n let rec nth_dec n = function\n | Empty -> raise Not_found\n | Node { left; data; count; right } ->\n if n < cardinal right then\n nth_dec n right\n else if n < cardinal right + count then\n data\n else\n nth_dec (n - cardinal right - count) left\n\n let rec elements_inc acc = function\n | Empty -> acc\n | Node { left; data; count; right } ->\n elements_inc\n (Array.fold_left (fun acc x -> x :: acc)\n (elements_inc acc right)\n (Array.make count data)) left\n\n let rec elements_dec acc = function\n | Empty -> acc\n | Node { left; data; count; right } ->\n elements_dec\n (Array.fold_left (fun acc x -> x :: acc)\n (elements_dec acc left)\n (Array.make count data)) right\n\n let rec take_inc n = function\n | Empty -> []\n | Node { left; data; count; right } ->\n if n < cardinal left then\n take_inc n left\n else if n < cardinal left + count then\n elements_inc (Array.to_list (Array.make (n - cardinal left) data)) left\n else\n elements_inc\n (Array.fold_left (fun acc x -> x :: acc)\n (take_inc (n - cardinal left - count) right)\n (Array.make count data)) left\n\n let rec take_dec n = function\n | Empty -> []\n | Node { left; data; count; right } ->\n if n < cardinal right then\n take_dec n right\n else if n < cardinal right + count then\n elements_dec (Array.to_list (Array.make (n - cardinal right) data)) right\n else\n elements_dec\n (Array.fold_left (fun acc x -> x :: acc)\n (take_dec (n - cardinal right - count) left)\n (Array.make count data)) right\n\n let elements_inc = elements_inc []\n let elements_dec = elements_dec []\n\n let rec fold_inc f acc = function\n | Empty -> acc\n | Node { left; data; count; right } ->\n fold_inc f\n (Array.fold_left f\n (fold_inc f acc left)\n (Array.make count data)) right\n\n let rec fold_dec f acc = function\n | Empty -> acc\n | Node { left; data; count; right } ->\n fold_dec f\n (Array.fold_right f\n (Array.make count data)\n (fold_dec f acc right)) left\n let fold_dec f t acc = fold_dec f acc t\n\n let rec min_elt t = fst (count_min_elt t)\n\n let rec max_elt = function\n | Empty -> raise Not_found\n | Node { data; right = Empty } -> data\n | Node { right } -> max_elt right\n end\nend\n\nmodule IntMultiSet = MultiSet.Make (struct\n type t = int\n let compare = compare\nend)\n\nlet memoize n f =\n let dp = Hashtbl.create n in\n let rec get x =\n try Hashtbl.find dp x with\n | Not_found ->\n let result = f get x in\n Hashtbl.add dp x result;\n result in\n get\n\nlet () = Scanf.scanf \"%d\\n\" @@ fun n ->\n let cas = Array.init (2 * n) @@ fun _ -> Scanf.scanf \"%c %d\\n\" @@ fun c a -> c, a in\n let inv_ws = Array.make n 0 in\n let inv_bs = Array.make n 0 in\n let acc_ws = Array.make (2 * n + 1) IntMultiSet.empty in\n let acc_bs = Array.make (2 * n + 1) IntMultiSet.empty in\n for i = 2 * n - 1 downto 0 do\n match cas.(i) with\n | ('W', a) ->\n inv_ws.(a - 1) <- i;\n acc_ws.(i) <- IntMultiSet.add (a - 1) 1 acc_ws.(i + 1);\n acc_bs.(i) <- acc_bs.(i + 1)\n | ('B', a) ->\n inv_bs.(a - 1) <- i;\n acc_ws.(i) <- acc_ws.(i + 1);\n acc_bs.(i) <- IntMultiSet.add (a - 1) 1 acc_bs.(i + 1)\n done;\n let dp = memoize ((n + 1) * (n + 1)) @@ fun dp (w, b) ->\n if w = 0 && b = 0 then 0\n else min\n (if w = 0 then max_int else\n dp (w - 1, b) + inv_ws.(w - 1) - w - b + 1\n + IntMultiSet.count_lt w acc_ws.(inv_ws.(w - 1) + 1)\n + IntMultiSet.count_lt b acc_bs.(inv_ws.(w - 1) + 1))\n (if b = 0 then max_int else\n dp (w, b - 1) + inv_bs.(b - 1) - w - b + 1\n + IntMultiSet.count_lt w acc_ws.(inv_bs.(b - 1) + 1)\n + IntMultiSet.count_lt b acc_bs.(inv_bs.(b - 1) + 1)) in\n Printf.printf \"%d\\n\" @@ dp (n, n)\n", "problem_context": "Score : 600 points\n\nProblem Statement\n\nThere are 2N balls, N white and N black, arranged in a row. The integers from 1 through N are written on the white balls, one on each ball, and they are also written on the black balls, one on each ball.\nThe integer written on the i-th ball from the left (1 ≤ i ≤ 2N) is a_i, and the color of this ball is represented by a letter c_i.\nc_i = W represents the ball is white; c_i = B represents the ball is black.\n\nTakahashi the human wants to achieve the following objective:\n\nFor every pair of integers (i,j) such that 1 ≤ i < j ≤ N, the white ball with i written on it is to the left of the white ball with j written on it.\n\nFor every pair of integers (i,j) such that 1 ≤ i < j ≤ N, the black ball with i written on it is to the left of the black ball with j written on it.\n\nIn order to achieve this, he can perform the following operation:\n\nSwap two adjacent balls.\n\nFind the minimum number of operations required to achieve the objective.\n\nConstraints\n\n1 ≤ N ≤ 2000\n\n1 ≤ a_i ≤ N\n\nc_i = W or c_i = B.\n\nIf i ≠ j, (a_i,c_i) ≠ (a_j,c_j).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nc_1 a_1\nc_2 a_2\n:\nc_{2N} a_{2N}\n\nOutput\n\nPrint the minimum number of operations required to achieve the objective.\n\nSample Input 1\n\n3\nB 1\nW 2\nB 3\nW 1\nW 3\nB 2\n\nSample Output 1\n\n4\n\nThe objective can be achieved in four operations, for example, as follows:\n\nSwap the black 3 and white 1.\n\nSwap the white 1 and white 2.\n\nSwap the black 3 and white 3.\n\nSwap the black 3 and black 2.\n\nSample Input 2\n\n4\nB 4\nW 4\nB 3\nW 3\nB 2\nW 2\nB 1\nW 1\n\nSample Output 2\n\n18\n\nSample Input 3\n\n9\nW 3\nB 1\nB 4\nW 1\nB 5\nW 9\nW 2\nB 6\nW 5\nB 3\nW 8\nB 9\nW 7\nB 2\nB 8\nW 4\nW 6\nB 7\n\nSample Output 3\n\n41", "sample_input": "3\nB 1\nW 2\nB 3\nW 1\nW 3\nB 2\n"}, "reference_outputs": ["4\n"], "source_document_id": "p03357", "source_text": "Score : 600 points\n\nProblem Statement\n\nThere are 2N balls, N white and N black, arranged in a row. The integers from 1 through N are written on the white balls, one on each ball, and they are also written on the black balls, one on each ball.\nThe integer written on the i-th ball from the left (1 ≤ i ≤ 2N) is a_i, and the color of this ball is represented by a letter c_i.\nc_i = W represents the ball is white; c_i = B represents the ball is black.\n\nTakahashi the human wants to achieve the following objective:\n\nFor every pair of integers (i,j) such that 1 ≤ i < j ≤ N, the white ball with i written on it is to the left of the white ball with j written on it.\n\nFor every pair of integers (i,j) such that 1 ≤ i < j ≤ N, the black ball with i written on it is to the left of the black ball with j written on it.\n\nIn order to achieve this, he can perform the following operation:\n\nSwap two adjacent balls.\n\nFind the minimum number of operations required to achieve the objective.\n\nConstraints\n\n1 ≤ N ≤ 2000\n\n1 ≤ a_i ≤ N\n\nc_i = W or c_i = B.\n\nIf i ≠ j, (a_i,c_i) ≠ (a_j,c_j).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nc_1 a_1\nc_2 a_2\n:\nc_{2N} a_{2N}\n\nOutput\n\nPrint the minimum number of operations required to achieve the objective.\n\nSample Input 1\n\n3\nB 1\nW 2\nB 3\nW 1\nW 3\nB 2\n\nSample Output 1\n\n4\n\nThe objective can be achieved in four operations, for example, as follows:\n\nSwap the black 3 and white 1.\n\nSwap the white 1 and white 2.\n\nSwap the black 3 and white 3.\n\nSwap the black 3 and black 2.\n\nSample Input 2\n\n4\nB 4\nW 4\nB 3\nW 3\nB 2\nW 2\nB 1\nW 1\n\nSample Output 2\n\n18\n\nSample Input 3\n\n9\nW 3\nB 1\nB 4\nW 1\nB 5\nW 9\nW 2\nB 6\nW 5\nB 3\nW 8\nB 9\nW 7\nB 2\nB 8\nW 4\nW 6\nB 7\n\nSample Output 3\n\n41", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 11201, "cpu_time_ms": 2105, "memory_kb": 157852}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s908149060", "group_id": "codeNet:p03359", "input_text": "open Batteries\n\nlet () =\n let a, b = Scanf.scanf \"%d %d\\n\" (fun a b -> a, b) in\n\n print_endline (string_of_int (if a > b then a-1 else a))\n\n", "language": "OCaml", "metadata": {"date": 1525568922, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03359.html", "problem_id": "p03359", "resource_group": "low_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/OCaml/s908149060.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s908149060", "user_id": "u139013163"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "open Batteries\n\nlet () =\n let a, b = Scanf.scanf \"%d %d\\n\" (fun a b -> a, b) in\n\n print_endline (string_of_int (if a > b then a-1 else a))\n\n", "problem_context": "Score: 100 points\n\nProblem Statement\n\nIn AtCoder Kingdom, Gregorian calendar is used, and dates are written in the \"year-month-day\" order, or the \"month-day\" order without the year.\n\nFor example, May 3, 2018 is written as 2018-5-3, or 5-3 without the year.\n\nIn this country, a date is called Takahashi when the month and the day are equal as numbers. For example, 5-5 is Takahashi.\n\nHow many days from 2018-1-1 through 2018-a-b are Takahashi?\n\nConstraints\n\na is an integer between 1 and 12 (inclusive).\n\nb is an integer between 1 and 31 (inclusive).\n\n2018-a-b is a valid date in Gregorian calendar.\n\nInput\n\nInput is given from Standard Input in the following format:\n\na b\n\nOutput\n\nPrint the number of days from 2018-1-1 through 2018-a-b that are Takahashi.\n\nSample Input 1\n\n5 5\n\nSample Output 1\n\n5\n\nThere are five days that are Takahashi: 1-1, 2-2, 3-3, 4-4 and 5-5.\n\nSample Input 2\n\n2 1\n\nSample Output 2\n\n1\n\nThere is only one day that is Takahashi: 1-1.\n\nSample Input 3\n\n11 30\n\nSample Output 3\n\n11\n\nThere are eleven days that are Takahashi: 1-1, 2-2, 3-3, 4-4, 5-5, 6-6, 7-7, 8-8, 9-9, 10-10 and 11-11.", "sample_input": "5 5\n"}, "reference_outputs": ["5\n"], "source_document_id": "p03359", "source_text": "Score: 100 points\n\nProblem Statement\n\nIn AtCoder Kingdom, Gregorian calendar is used, and dates are written in the \"year-month-day\" order, or the \"month-day\" order without the year.\n\nFor example, May 3, 2018 is written as 2018-5-3, or 5-3 without the year.\n\nIn this country, a date is called Takahashi when the month and the day are equal as numbers. For example, 5-5 is Takahashi.\n\nHow many days from 2018-1-1 through 2018-a-b are Takahashi?\n\nConstraints\n\na is an integer between 1 and 12 (inclusive).\n\nb is an integer between 1 and 31 (inclusive).\n\n2018-a-b is a valid date in Gregorian calendar.\n\nInput\n\nInput is given from Standard Input in the following format:\n\na b\n\nOutput\n\nPrint the number of days from 2018-1-1 through 2018-a-b that are Takahashi.\n\nSample Input 1\n\n5 5\n\nSample Output 1\n\n5\n\nThere are five days that are Takahashi: 1-1, 2-2, 3-3, 4-4 and 5-5.\n\nSample Input 2\n\n2 1\n\nSample Output 2\n\n1\n\nThere is only one day that is Takahashi: 1-1.\n\nSample Input 3\n\n11 30\n\nSample Output 3\n\n11\n\nThere are eleven days that are Takahashi: 1-1, 2-2, 3-3, 4-4, 5-5, 6-6, 7-7, 8-8, 9-9, 10-10 and 11-11.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 2, "memory_kb": 1024}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s865194659", "group_id": "codeNet:p03360", "input_text": "let s, m, k = Scanf.scanf \" %d %d %d %d\" @@ fun a b c d -> a + b + c, max a (max b c), d\nlet _ = s - m + m * 1 lsl k |> Printf.printf \"%d\\n\"", "language": "OCaml", "metadata": {"date": 1573806662, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03360.html", "problem_id": "p03360", "resource_group": "low_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/OCaml/s865194659.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s865194659", "user_id": "u732304692"}, "prompt_components": {"gold_output": "30\n", "input_to_evaluate": "let s, m, k = Scanf.scanf \" %d %d %d %d\" @@ fun a b c d -> a + b + c, max a (max b c), d\nlet _ = s - m + m * 1 lsl k |> Printf.printf \"%d\\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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 140, "cpu_time_ms": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s224238413", "group_id": "codeNet:p03360", "input_text": "let () =\n Scanf.scanf \"%d %d %d\\n\" @@ fun a b c ->\n Scanf.scanf \"%d\\n\" @@ fun k ->\n Printf.printf \"%d\\n\" @@ a + b + c + max a (max b c) * (1 lsl k - 1)", "language": "OCaml", "metadata": {"date": 1525570753, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03360.html", "problem_id": "p03360", "resource_group": "low_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/OCaml/s224238413.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s224238413", "user_id": "u504158101"}, "prompt_components": {"gold_output": "30\n", "input_to_evaluate": "let () =\n Scanf.scanf \"%d %d %d\\n\" @@ fun a b c ->\n Scanf.scanf \"%d\\n\" @@ fun k ->\n Printf.printf \"%d\\n\" @@ a + b + c + max a (max b c) * (1 lsl k - 1)", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 2, "memory_kb": 2432}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s986928312", "group_id": "codeNet:p03361", "input_text": "open Batteries\n\nlet () =\n let h, w = Scanf.scanf \"%d %d\\n\" (fun a b -> a, b) in\n let arr = Array.make h (Array.make w \"\") in\n for i = 0 to h-1 do\n let str = Scanf.scanf \"%s\\n\" (fun a -> a) in\n let str_list = Str.split (Str.regexp \"\") str in\n arr.(i) <- (Array.of_list str_list)\n done;\n\n let res = ref true in\n\n for i = 0 to h-1 do\n for j = 0 to w-1 do\n if arr.(i).(j) = \"#\" then (\n let tmp = ref false in\n if i <> 0 then (\n if arr.(i-1).(j) = \"#\" then tmp := true;\n );\n if i <> h-1 then (\n if arr.(i+1).(j) = \"#\" then tmp := true;\n );\n if j <> 0 then (\n if arr.(i).(j-1) = \"#\" then tmp := true;\n );\n if j <> w-1 then (\n if arr.(i).(j+1) = \"#\" then tmp := true;\n );\n if !tmp = false then res := false\n );\n done;\n done;\n\n print_endline (if !res then \"Yes\" else \"No\")\n", "language": "OCaml", "metadata": {"date": 1525582457, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03361.html", "problem_id": "p03361", "resource_group": "low_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/OCaml/s986928312.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s986928312", "user_id": "u139013163"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "open Batteries\n\nlet () =\n let h, w = Scanf.scanf \"%d %d\\n\" (fun a b -> a, b) in\n let arr = Array.make h (Array.make w \"\") in\n for i = 0 to h-1 do\n let str = Scanf.scanf \"%s\\n\" (fun a -> a) in\n let str_list = Str.split (Str.regexp \"\") str in\n arr.(i) <- (Array.of_list str_list)\n done;\n\n let res = ref true in\n\n for i = 0 to h-1 do\n for j = 0 to w-1 do\n if arr.(i).(j) = \"#\" then (\n let tmp = ref false in\n if i <> 0 then (\n if arr.(i-1).(j) = \"#\" then tmp := true;\n );\n if i <> h-1 then (\n if arr.(i+1).(j) = \"#\" then tmp := true;\n );\n if j <> 0 then (\n if arr.(i).(j-1) = \"#\" then tmp := true;\n );\n if j <> w-1 then (\n if arr.(i).(j+1) = \"#\" then tmp := true;\n );\n if !tmp = false then res := false\n );\n done;\n done;\n\n print_endline (if !res then \"Yes\" else \"No\")\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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 904, "cpu_time_ms": 4, "memory_kb": 1664}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s727055303", "group_id": "codeNet:p03363", "input_text": "open Batteries\nmodule CountDict = Map.Make(Int)\nlet cnt_int lst =\n let rec add_lst dict l =\n match l with\n | [] -> dict\n | first :: rest ->\n if CountDict.mem first dict then add_lst (CountDict.add first ((CountDict.find first dict) + 1) dict) rest else\n add_lst (CountDict.add first 1 dict) rest\n in add_lst CountDict.empty lst\nlet n = read_int ()\nlet a = Array.init n @@ fun _ -> Scanf.scanf \" %d\" @@ fun a -> a\nlet dp = Array.init (n+1) (fun _ -> 0)\n\nlet rec loop i =\n if i >= n then () else (dp.(i+1) <- dp.(i) + a.(i); loop (i+1))\n\nlet _ = dp.(1) <- a.(0); loop 1\n\nlet dict = cnt_int @@ Array.to_list dp\n\nlet _ = Printf.printf \"%d\\n\" @@ (CountDict.fold (fun f m a -> a + (m * (m - 1))) dict 0) / 2\n", "language": "OCaml", "metadata": {"date": 1587686593, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03363.html", "problem_id": "p03363", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03363/input.txt", "sample_output_relpath": "derived/input_output/data/p03363/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03363/OCaml/s727055303.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s727055303", "user_id": "u511870776"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "open Batteries\nmodule CountDict = Map.Make(Int)\nlet cnt_int lst =\n let rec add_lst dict l =\n match l with\n | [] -> dict\n | first :: rest ->\n if CountDict.mem first dict then add_lst (CountDict.add first ((CountDict.find first dict) + 1) dict) rest else\n add_lst (CountDict.add first 1 dict) rest\n in add_lst CountDict.empty lst\nlet n = read_int ()\nlet a = Array.init n @@ fun _ -> Scanf.scanf \" %d\" @@ fun a -> a\nlet dp = Array.init (n+1) (fun _ -> 0)\n\nlet rec loop i =\n if i >= n then () else (dp.(i+1) <- dp.(i) + a.(i); loop (i+1))\n\nlet _ = dp.(1) <- a.(0); loop 1\n\nlet dict = cnt_int @@ Array.to_list dp\n\nlet _ = Printf.printf \"%d\\n\" @@ (CountDict.fold (fun f m a -> a + (m * (m - 1))) dict 0) / 2\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nWe have an integer sequence A, whose length is N.\n\nFind the number of the non-empty contiguous subsequences of A whose sums are 0.\nNote that we are counting the ways to take out subsequences.\nThat is, even if the contents of some two subsequences are the same, they are counted individually if they are taken from different positions.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\n-10^9 \\leq A_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nFind the number of the non-empty contiguous subsequences of A whose sum is 0.\n\nSample Input 1\n\n6\n1 3 -4 2 2 -2\n\nSample Output 1\n\n3\n\nThere are three contiguous subsequences whose sums are 0: (1,3,-4), (-4,2,2) and (2,-2).\n\nSample Input 2\n\n7\n1 -1 1 -1 1 -1 1\n\nSample Output 2\n\n12\n\nIn this case, some subsequences that have the same contents but are taken from different positions are counted individually.\nFor example, three occurrences of (1, -1) are counted.\n\nSample Input 3\n\n5\n1 -2 3 -4 5\n\nSample Output 3\n\n0\n\nThere are no contiguous subsequences whose sums are 0.", "sample_input": "6\n1 3 -4 2 2 -2\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03363", "source_text": "Score : 200 points\n\nProblem Statement\n\nWe have an integer sequence A, whose length is N.\n\nFind the number of the non-empty contiguous subsequences of A whose sums are 0.\nNote that we are counting the ways to take out subsequences.\nThat is, even if the contents of some two subsequences are the same, they are counted individually if they are taken from different positions.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\n-10^9 \\leq A_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nFind the number of the non-empty contiguous subsequences of A whose sum is 0.\n\nSample Input 1\n\n6\n1 3 -4 2 2 -2\n\nSample Output 1\n\n3\n\nThere are three contiguous subsequences whose sums are 0: (1,3,-4), (-4,2,2) and (2,-2).\n\nSample Input 2\n\n7\n1 -1 1 -1 1 -1 1\n\nSample Output 2\n\n12\n\nIn this case, some subsequences that have the same contents but are taken from different positions are counted individually.\nFor example, three occurrences of (1, -1) are counted.\n\nSample Input 3\n\n5\n1 -2 3 -4 5\n\nSample Output 3\n\n0\n\nThere are no contiguous subsequences whose sums are 0.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 724, "cpu_time_ms": 216, "memory_kb": 21248}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s637861294", "group_id": "codeNet:p03363", "input_text": "module P = Map.Make(struct type t = int let compare = (-) end)\nlet _ = Scanf.scanf \"%d\" @@ fun n ->\n Array.init n (fun _ -> Scanf.scanf \" %d\" ((+) 0))\n |> Array.fold_left (fun (v, (s, m)) x ->\n let c = try P.find (s+x) m with | _ -> 0 in\n (v+c, (s+x, P.add (s+x) (c+1) m))) (0, (0, P.singleton 0 1))\n |> fst |> Printf.printf \"%d\\n\"", "language": "OCaml", "metadata": {"date": 1534492608, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03363.html", "problem_id": "p03363", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03363/input.txt", "sample_output_relpath": "derived/input_output/data/p03363/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03363/OCaml/s637861294.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s637861294", "user_id": "u798181098"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "module P = Map.Make(struct type t = int let compare = (-) end)\nlet _ = Scanf.scanf \"%d\" @@ fun n ->\n Array.init n (fun _ -> Scanf.scanf \" %d\" ((+) 0))\n |> Array.fold_left (fun (v, (s, m)) x ->\n let c = try P.find (s+x) m with | _ -> 0 in\n (v+c, (s+x, P.add (s+x) (c+1) m))) (0, (0, P.singleton 0 1))\n |> fst |> Printf.printf \"%d\\n\"", "problem_context": "Score : 200 points\n\nProblem Statement\n\nWe have an integer sequence A, whose length is N.\n\nFind the number of the non-empty contiguous subsequences of A whose sums are 0.\nNote that we are counting the ways to take out subsequences.\nThat is, even if the contents of some two subsequences are the same, they are counted individually if they are taken from different positions.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\n-10^9 \\leq A_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nFind the number of the non-empty contiguous subsequences of A whose sum is 0.\n\nSample Input 1\n\n6\n1 3 -4 2 2 -2\n\nSample Output 1\n\n3\n\nThere are three contiguous subsequences whose sums are 0: (1,3,-4), (-4,2,2) and (2,-2).\n\nSample Input 2\n\n7\n1 -1 1 -1 1 -1 1\n\nSample Output 2\n\n12\n\nIn this case, some subsequences that have the same contents but are taken from different positions are counted individually.\nFor example, three occurrences of (1, -1) are counted.\n\nSample Input 3\n\n5\n1 -2 3 -4 5\n\nSample Output 3\n\n0\n\nThere are no contiguous subsequences whose sums are 0.", "sample_input": "6\n1 3 -4 2 2 -2\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03363", "source_text": "Score : 200 points\n\nProblem Statement\n\nWe have an integer sequence A, whose length is N.\n\nFind the number of the non-empty contiguous subsequences of A whose sums are 0.\nNote that we are counting the ways to take out subsequences.\nThat is, even if the contents of some two subsequences are the same, they are counted individually if they are taken from different positions.\n\nConstraints\n\n1 \\leq N \\leq 2 \\times 10^5\n\n-10^9 \\leq A_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nFind the number of the non-empty contiguous subsequences of A whose sum is 0.\n\nSample Input 1\n\n6\n1 3 -4 2 2 -2\n\nSample Output 1\n\n3\n\nThere are three contiguous subsequences whose sums are 0: (1,3,-4), (-4,2,2) and (2,-2).\n\nSample Input 2\n\n7\n1 -1 1 -1 1 -1 1\n\nSample Output 2\n\n12\n\nIn this case, some subsequences that have the same contents but are taken from different positions are counted individually.\nFor example, three occurrences of (1, -1) are counted.\n\nSample Input 3\n\n5\n1 -2 3 -4 5\n\nSample Output 3\n\n0\n\nThere are no contiguous subsequences whose sums are 0.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 344, "cpu_time_ms": 204, "memory_kb": 17280}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s220278933", "group_id": "codeNet:p03364", "input_text": "Scanf.sscanf (read_line ()) \"%d\" (fun n ->\n let s = Array.init n (fun _ -> read_line ()) in\n let check1 sh =\n let rec loop y =\n let rec loop2 x =\n if x = n then true else\n if s.(y).[(x + sh) mod n] = s.(x).[(y + sh) mod n] then loop2 (x + 1) else (\n false\n )\n in\n if y = n then true else\n if loop2 0 then loop (y + 1) else false\n in\n loop 0\n in\n let rec loop sh acc =\n if sh = n then acc * n else\n let acc = if check1 sh then acc + 1 else acc in\n loop (sh + 1) acc\n in\n loop 0 0 |> Printf.printf \"%d\\n\"\n)", "language": "OCaml", "metadata": {"date": 1584231736, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03364.html", "problem_id": "p03364", "resource_group": "low_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/OCaml/s220278933.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s220278933", "user_id": "u342443598"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "Scanf.sscanf (read_line ()) \"%d\" (fun n ->\n let s = Array.init n (fun _ -> read_line ()) in\n let check1 sh =\n let rec loop y =\n let rec loop2 x =\n if x = n then true else\n if s.(y).[(x + sh) mod n] = s.(x).[(y + sh) mod n] then loop2 (x + 1) else (\n false\n )\n in\n if y = n then true else\n if loop2 0 then loop (y + 1) else false\n in\n loop 0\n in\n let rec loop sh acc =\n if sh = n then acc * n else\n let acc = if check1 sh then acc + 1 else acc in\n loop (sh + 1) acc\n in\n loop 0 0 |> Printf.printf \"%d\\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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 696, "cpu_time_ms": 757, "memory_kb": 4736}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s965962265", "group_id": "codeNet:p03364", "input_text": "open Batteries\n\nlet () =\n let n = Scanf.scanf \"%d\\n\" (fun a -> a) in\n\n let arr = Array.make_matrix n n '-' in\n for i = 0 to n-1 do\n for j = 0 to n-1-1 do\n let c = Scanf.scanf \"%c \" (fun c -> c) in\n Array.set (Array.get arr i) j c\n done;\n let c = Scanf.scanf \"%c\\n\" (fun c -> c) in\n Array.set (Array.get arr i) (n-1) c\n done;\n\n\n let cnt = ref 0 in\n let cur_char = ref '-' in\n\n for j = 0 to n-1 do\n for i = 0 to n-1 do\n let j = j - i in\n let j = if j < 0 then j + n else j in\n let c = (Array.get (Array.get arr i) j) in\n if (i = 0) then (\n cur_char := c;\n ) else (\n if !cur_char <> c then (\n cur_char := '-';\n )\n );\n done;\n if !cur_char <> '-' then (\n cnt := !cnt + n\n )\n done;\n\n print_endline (string_of_int !cnt)\n\n\n", "language": "OCaml", "metadata": {"date": 1524971213, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03364.html", "problem_id": "p03364", "resource_group": "low_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/OCaml/s965962265.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s965962265", "user_id": "u139013163"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "open Batteries\n\nlet () =\n let n = Scanf.scanf \"%d\\n\" (fun a -> a) in\n\n let arr = Array.make_matrix n n '-' in\n for i = 0 to n-1 do\n for j = 0 to n-1-1 do\n let c = Scanf.scanf \"%c \" (fun c -> c) in\n Array.set (Array.get arr i) j c\n done;\n let c = Scanf.scanf \"%c\\n\" (fun c -> c) in\n Array.set (Array.get arr i) (n-1) c\n done;\n\n\n let cnt = ref 0 in\n let cur_char = ref '-' in\n\n for j = 0 to n-1 do\n for i = 0 to n-1 do\n let j = j - i in\n let j = if j < 0 then j + n else j in\n let c = (Array.get (Array.get arr i) j) in\n if (i = 0) then (\n cur_char := c;\n ) else (\n if !cur_char <> c then (\n cur_char := '-';\n )\n );\n done;\n if !cur_char <> '-' then (\n cnt := !cnt + n\n )\n done;\n\n print_endline (string_of_int !cnt)\n\n\n", "problem_context": "Score : 500 points\n\nProblem Statement\n\nSnuke has two boards, each divided into a grid with N rows and N columns.\nFor both of these boards, the square at the i-th row from the top and the j-th column from the left is called Square (i,j).\n\nThere is a lowercase English letter written in each square on the first board. The letter written in Square (i,j) is S_{i,j}. On the second board, nothing is written yet.\n\nSnuke will write letters on the second board, as follows:\n\nFirst, choose two integers A and B ( 0 \\leq A, B < N ).\n\nWrite one letter in each square on the second board.\nSpecifically, write the letter written in Square ( i+A, j+B ) on the first board into Square (i,j) on the second board.\nHere, the k-th row is also represented as the (N+k)-th row, and the k-th column is also represented as the (N+k)-th column.\n\nAfter this operation, the second board is called a good board when, for every i and j ( 1 \\leq i, j \\leq N ), the letter in Square (i,j) and the letter in Square (j,i) are equal.\n\nFind the number of the ways to choose integers A and B ( 0 \\leq A, B < N ) such that the second board is a good board.\n\nConstraints\n\n1 \\leq N \\leq 300\n\nS_{i,j} ( 1 \\leq i, j \\leq N ) is a lowercase English letter.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS_{1,1}S_{1,2}..S_{1,N}\nS_{2,1}S_{2,2}..S_{2,N}\n:\nS_{N,1}S_{N,2}..S_{N,N}\n\nOutput\n\nPrint the number of the ways to choose integers A and B ( 0 \\leq A, B < N ) such that the second board is a good board.\n\nSample Input 1\n\n2\nab\nca\n\nSample Output 1\n\n2\n\nFor each pair of A and B, the second board will look as shown below:\n\nThe second board is a good board when (A,B) = (0,1) or (A,B) = (1,0), thus the answer is 2.\n\nSample Input 2\n\n4\naaaa\naaaa\naaaa\naaaa\n\nSample Output 2\n\n16\n\nEvery possible choice of A and B makes the second board good.\n\nSample Input 3\n\n5\nabcde\nfghij\nklmno\npqrst\nuvwxy\n\nSample Output 3\n\n0\n\nNo possible choice of A and B makes the second board good.", "sample_input": "2\nab\nca\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03364", "source_text": "Score : 500 points\n\nProblem Statement\n\nSnuke has two boards, each divided into a grid with N rows and N columns.\nFor both of these boards, the square at the i-th row from the top and the j-th column from the left is called Square (i,j).\n\nThere is a lowercase English letter written in each square on the first board. The letter written in Square (i,j) is S_{i,j}. On the second board, nothing is written yet.\n\nSnuke will write letters on the second board, as follows:\n\nFirst, choose two integers A and B ( 0 \\leq A, B < N ).\n\nWrite one letter in each square on the second board.\nSpecifically, write the letter written in Square ( i+A, j+B ) on the first board into Square (i,j) on the second board.\nHere, the k-th row is also represented as the (N+k)-th row, and the k-th column is also represented as the (N+k)-th column.\n\nAfter this operation, the second board is called a good board when, for every i and j ( 1 \\leq i, j \\leq N ), the letter in Square (i,j) and the letter in Square (j,i) are equal.\n\nFind the number of the ways to choose integers A and B ( 0 \\leq A, B < N ) such that the second board is a good board.\n\nConstraints\n\n1 \\leq N \\leq 300\n\nS_{i,j} ( 1 \\leq i, j \\leq N ) is a lowercase English letter.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS_{1,1}S_{1,2}..S_{1,N}\nS_{2,1}S_{2,2}..S_{2,N}\n:\nS_{N,1}S_{N,2}..S_{N,N}\n\nOutput\n\nPrint the number of the ways to choose integers A and B ( 0 \\leq A, B < N ) such that the second board is a good board.\n\nSample Input 1\n\n2\nab\nca\n\nSample Output 1\n\n2\n\nFor each pair of A and B, the second board will look as shown below:\n\nThe second board is a good board when (A,B) = (0,1) or (A,B) = (1,0), thus the answer is 2.\n\nSample Input 2\n\n4\naaaa\naaaa\naaaa\naaaa\n\nSample Output 2\n\n16\n\nEvery possible choice of A and B makes the second board good.\n\nSample Input 3\n\n5\nabcde\nfghij\nklmno\npqrst\nuvwxy\n\nSample Output 3\n\n0\n\nNo possible choice of A and B makes the second board good.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 823, "cpu_time_ms": 13, "memory_kb": 5888}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s530087653", "group_id": "codeNet:p03369", "input_text": "let () =\n Scanf.scanf \"%1s%1s%1s\" (fun a b c ->\n let rec calc li o =\n match li with\n | [] -> o\n | x :: xs when x = \"o\" -> calc xs (o + 1)\n | x :: xs -> calc xs o\n in\n (calc [a; b; c] 0 * 100) + 700 |> Printf.printf \"%d\\n\" )\n", "language": "OCaml", "metadata": {"date": 1550713637, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03369.html", "problem_id": "p03369", "resource_group": "low_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/OCaml/s530087653.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s530087653", "user_id": "u406828576"}, "prompt_components": {"gold_output": "900\n", "input_to_evaluate": "let () =\n Scanf.scanf \"%1s%1s%1s\" (fun a b c ->\n let rec calc li o =\n match li with\n | [] -> o\n | x :: xs when x = \"o\" -> calc xs (o + 1)\n | x :: xs -> calc xs o\n in\n (calc [a; b; c] 0 * 100) + 700 |> Printf.printf \"%d\\n\" )\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nIn \"Takahashi-ya\", a ramen restaurant, a bowl of ramen costs 700 yen (the currency of Japan), plus 100 yen for each kind of topping (boiled egg, sliced pork, green onions).\n\nA customer ordered a bowl of ramen and told which toppings to put on his ramen to a clerk. The clerk took a memo of the order as a string S. S is three characters long, and if the first character in S is o, it means the ramen should be topped with boiled egg; if that character is x, it means the ramen should not be topped with boiled egg. Similarly, the second and third characters in S mean the presence or absence of sliced pork and green onions on top of the ramen.\n\nWrite a program that, when S is given, prints the price of the corresponding bowl of ramen.\n\nConstraints\n\nS is a string of length 3.\n\nEach character in S is o or x.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the price of the bowl of ramen corresponding to S.\n\nSample Input 1\n\noxo\n\nSample Output 1\n\n900\n\nThe price of a ramen topped with two kinds of toppings, boiled egg and green onions, is 700 + 100 \\times 2 = 900 yen.\n\nSample Input 2\n\nooo\n\nSample Output 2\n\n1000\n\nThe price of a ramen topped with all three kinds of toppings is 700 + 100 \\times 3 = 1000 yen.\n\nSample Input 3\n\nxxx\n\nSample Output 3\n\n700\n\nThe price of a ramen without any toppings is 700 yen.", "sample_input": "oxo\n"}, "reference_outputs": ["900\n"], "source_document_id": "p03369", "source_text": "Score : 100 points\n\nProblem Statement\n\nIn \"Takahashi-ya\", a ramen restaurant, a bowl of ramen costs 700 yen (the currency of Japan), plus 100 yen for each kind of topping (boiled egg, sliced pork, green onions).\n\nA customer ordered a bowl of ramen and told which toppings to put on his ramen to a clerk. The clerk took a memo of the order as a string S. S is three characters long, and if the first character in S is o, it means the ramen should be topped with boiled egg; if that character is x, it means the ramen should not be topped with boiled egg. Similarly, the second and third characters in S mean the presence or absence of sliced pork and green onions on top of the ramen.\n\nWrite a program that, when S is given, prints the price of the corresponding bowl of ramen.\n\nConstraints\n\nS is a string of length 3.\n\nEach character in S is o or x.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the price of the bowl of ramen corresponding to S.\n\nSample Input 1\n\noxo\n\nSample Output 1\n\n900\n\nThe price of a ramen topped with two kinds of toppings, boiled egg and green onions, is 700 + 100 \\times 2 = 900 yen.\n\nSample Input 2\n\nooo\n\nSample Output 2\n\n1000\n\nThe price of a ramen topped with all three kinds of toppings is 700 + 100 \\times 3 = 1000 yen.\n\nSample Input 3\n\nxxx\n\nSample Output 3\n\n700\n\nThe price of a ramen without any toppings is 700 yen.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s008893992", "group_id": "codeNet:p03370", "input_text": "Scanf.scanf \"%d %d\" (fun n x ->\n let m = Array.init n (fun _ -> Scanf.scanf \" %d\" (fun m -> m)) in\n Array.sort compare m;\n let s = Array.fold_left (+) 0 m in\n let r = x - s in\n Printf.printf \"%d\\n\" @@ n + r / m.(0)\n)", "language": "OCaml", "metadata": {"date": 1590895316, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03370.html", "problem_id": "p03370", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03370/input.txt", "sample_output_relpath": "derived/input_output/data/p03370/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03370/OCaml/s008893992.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s008893992", "user_id": "u342443598"}, "prompt_components": {"gold_output": "9\n", "input_to_evaluate": "Scanf.scanf \"%d %d\" (fun n x ->\n let m = Array.init n (fun _ -> Scanf.scanf \" %d\" (fun m -> m)) in\n Array.sort compare m;\n let s = Array.fold_left (+) 0 m in\n let r = x - s in\n Printf.printf \"%d\\n\" @@ n + r / m.(0)\n)", "problem_context": "Score : 200 points\n\nProblem Statement\n\nAkaki, a patissier, can make N kinds of doughnut using only a certain powder called \"Okashi no Moto\" (literally \"material of pastry\", simply called Moto below) as ingredient. These doughnuts are called Doughnut 1, Doughnut 2, ..., Doughnut N. In order to make one Doughnut i (1 ≤ i ≤ N), she needs to consume m_i grams of Moto. She cannot make a non-integer number of doughnuts, such as 0.5 doughnuts.\n\nNow, she has X grams of Moto. She decides to make as many doughnuts as possible for a party tonight. However, since the tastes of the guests differ, she will obey the following condition:\n\nFor each of the N kinds of doughnuts, make at least one doughnut of that kind.\n\nAt most how many doughnuts can be made here? She does not necessarily need to consume all of her Moto. Also, under the constraints of this problem, it is always possible to obey the condition.\n\nConstraints\n\n2 ≤ N ≤ 100\n\n1 ≤ m_i ≤ 1000\n\nm_1 + m_2 + ... + m_N ≤ X ≤ 10^5\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN X\nm_1\nm_2\n:\nm_N\n\nOutput\n\nPrint the maximum number of doughnuts that can be made under the condition.\n\nSample Input 1\n\n3 1000\n120\n100\n140\n\nSample Output 1\n\n9\n\nShe has 1000 grams of Moto and can make three kinds of doughnuts. If she makes one doughnut for each of the three kinds, she consumes 120 + 100 + 140 = 360 grams of Moto. From the 640 grams of Moto that remains here, she can make additional six Doughnuts 2. This is how she can made a total of nine doughnuts, which is the maximum.\n\nSample Input 2\n\n4 360\n90\n90\n90\n90\n\nSample Output 2\n\n4\n\nMaking one doughnut for each of the four kinds consumes all of her Moto.\n\nSample Input 3\n\n5 3000\n150\n130\n150\n130\n110\n\nSample Output 3\n\n26", "sample_input": "3 1000\n120\n100\n140\n"}, "reference_outputs": ["9\n"], "source_document_id": "p03370", "source_text": "Score : 200 points\n\nProblem Statement\n\nAkaki, a patissier, can make N kinds of doughnut using only a certain powder called \"Okashi no Moto\" (literally \"material of pastry\", simply called Moto below) as ingredient. These doughnuts are called Doughnut 1, Doughnut 2, ..., Doughnut N. In order to make one Doughnut i (1 ≤ i ≤ N), she needs to consume m_i grams of Moto. She cannot make a non-integer number of doughnuts, such as 0.5 doughnuts.\n\nNow, she has X grams of Moto. She decides to make as many doughnuts as possible for a party tonight. However, since the tastes of the guests differ, she will obey the following condition:\n\nFor each of the N kinds of doughnuts, make at least one doughnut of that kind.\n\nAt most how many doughnuts can be made here? She does not necessarily need to consume all of her Moto. Also, under the constraints of this problem, it is always possible to obey the condition.\n\nConstraints\n\n2 ≤ N ≤ 100\n\n1 ≤ m_i ≤ 1000\n\nm_1 + m_2 + ... + m_N ≤ X ≤ 10^5\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN X\nm_1\nm_2\n:\nm_N\n\nOutput\n\nPrint the maximum number of doughnuts that can be made under the condition.\n\nSample Input 1\n\n3 1000\n120\n100\n140\n\nSample Output 1\n\n9\n\nShe has 1000 grams of Moto and can make three kinds of doughnuts. If she makes one doughnut for each of the three kinds, she consumes 120 + 100 + 140 = 360 grams of Moto. From the 640 grams of Moto that remains here, she can make additional six Doughnuts 2. This is how she can made a total of nine doughnuts, which is the maximum.\n\nSample Input 2\n\n4 360\n90\n90\n90\n90\n\nSample Output 2\n\n4\n\nMaking one doughnut for each of the four kinds consumes all of her Moto.\n\nSample Input 3\n\n5 3000\n150\n130\n150\n130\n110\n\nSample Output 3\n\n26", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 231, "cpu_time_ms": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s472288763", "group_id": "codeNet:p03370", "input_text": "let () =\n let n, x = Scanf.scanf \"%d %d\\n\" (fun n x -> n, x) in\n let mi = Array.init n (fun _ -> Scanf.scanf \"%d\\n\" (fun x -> x)) in\n Array.sort (-) mi;\n let least = Array.fold_left (+) 0 mi in\n let count = (x - least) / mi.(0) in\n let res = n + count in\n Printf.printf \"%d\\n\" res \n \n", "language": "OCaml", "metadata": {"date": 1528524307, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03370.html", "problem_id": "p03370", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03370/input.txt", "sample_output_relpath": "derived/input_output/data/p03370/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03370/OCaml/s472288763.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s472288763", "user_id": "u614063956"}, "prompt_components": {"gold_output": "9\n", "input_to_evaluate": "let () =\n let n, x = Scanf.scanf \"%d %d\\n\" (fun n x -> n, x) in\n let mi = Array.init n (fun _ -> Scanf.scanf \"%d\\n\" (fun x -> x)) in\n Array.sort (-) mi;\n let least = Array.fold_left (+) 0 mi in\n let count = (x - least) / mi.(0) in\n let res = n + count in\n Printf.printf \"%d\\n\" res \n \n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nAkaki, a patissier, can make N kinds of doughnut using only a certain powder called \"Okashi no Moto\" (literally \"material of pastry\", simply called Moto below) as ingredient. These doughnuts are called Doughnut 1, Doughnut 2, ..., Doughnut N. In order to make one Doughnut i (1 ≤ i ≤ N), she needs to consume m_i grams of Moto. She cannot make a non-integer number of doughnuts, such as 0.5 doughnuts.\n\nNow, she has X grams of Moto. She decides to make as many doughnuts as possible for a party tonight. However, since the tastes of the guests differ, she will obey the following condition:\n\nFor each of the N kinds of doughnuts, make at least one doughnut of that kind.\n\nAt most how many doughnuts can be made here? She does not necessarily need to consume all of her Moto. Also, under the constraints of this problem, it is always possible to obey the condition.\n\nConstraints\n\n2 ≤ N ≤ 100\n\n1 ≤ m_i ≤ 1000\n\nm_1 + m_2 + ... + m_N ≤ X ≤ 10^5\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN X\nm_1\nm_2\n:\nm_N\n\nOutput\n\nPrint the maximum number of doughnuts that can be made under the condition.\n\nSample Input 1\n\n3 1000\n120\n100\n140\n\nSample Output 1\n\n9\n\nShe has 1000 grams of Moto and can make three kinds of doughnuts. If she makes one doughnut for each of the three kinds, she consumes 120 + 100 + 140 = 360 grams of Moto. From the 640 grams of Moto that remains here, she can make additional six Doughnuts 2. This is how she can made a total of nine doughnuts, which is the maximum.\n\nSample Input 2\n\n4 360\n90\n90\n90\n90\n\nSample Output 2\n\n4\n\nMaking one doughnut for each of the four kinds consumes all of her Moto.\n\nSample Input 3\n\n5 3000\n150\n130\n150\n130\n110\n\nSample Output 3\n\n26", "sample_input": "3 1000\n120\n100\n140\n"}, "reference_outputs": ["9\n"], "source_document_id": "p03370", "source_text": "Score : 200 points\n\nProblem Statement\n\nAkaki, a patissier, can make N kinds of doughnut using only a certain powder called \"Okashi no Moto\" (literally \"material of pastry\", simply called Moto below) as ingredient. These doughnuts are called Doughnut 1, Doughnut 2, ..., Doughnut N. In order to make one Doughnut i (1 ≤ i ≤ N), she needs to consume m_i grams of Moto. She cannot make a non-integer number of doughnuts, such as 0.5 doughnuts.\n\nNow, she has X grams of Moto. She decides to make as many doughnuts as possible for a party tonight. However, since the tastes of the guests differ, she will obey the following condition:\n\nFor each of the N kinds of doughnuts, make at least one doughnut of that kind.\n\nAt most how many doughnuts can be made here? She does not necessarily need to consume all of her Moto. Also, under the constraints of this problem, it is always possible to obey the condition.\n\nConstraints\n\n2 ≤ N ≤ 100\n\n1 ≤ m_i ≤ 1000\n\nm_1 + m_2 + ... + m_N ≤ X ≤ 10^5\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN X\nm_1\nm_2\n:\nm_N\n\nOutput\n\nPrint the maximum number of doughnuts that can be made under the condition.\n\nSample Input 1\n\n3 1000\n120\n100\n140\n\nSample Output 1\n\n9\n\nShe has 1000 grams of Moto and can make three kinds of doughnuts. If she makes one doughnut for each of the three kinds, she consumes 120 + 100 + 140 = 360 grams of Moto. From the 640 grams of Moto that remains here, she can make additional six Doughnuts 2. This is how she can made a total of nine doughnuts, which is the maximum.\n\nSample Input 2\n\n4 360\n90\n90\n90\n90\n\nSample Output 2\n\n4\n\nMaking one doughnut for each of the four kinds consumes all of her Moto.\n\nSample Input 3\n\n5 3000\n150\n130\n150\n130\n110\n\nSample Output 3\n\n26", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 294, "cpu_time_ms": 1, "memory_kb": 2432}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s044578192", "group_id": "codeNet:p03371", "input_text": "open Batteries\nmodule EnumL = Enum.Labels\nmodule ListL = List.Labels\nmodule ArrayL = Array.Labels\n\nlet dbg0 x = Printf.eprintf \"[debug]%s\\n\" @@ dump x\nlet dbg1 x = dbg0 x; x\n\nlet id = identity\n\nlet (++) n m = List.range n `To m\nlet (++-) n m = if n >= m then List.range n `Downto m else []\nlet (++^) n m = if n < m then List.range n `To (pred m) else []\n\nlet scan fmt = Scanf.sscanf (read_line ()) fmt\n\nlet scan_lines n fmt f =\n if n = 0 then []\n else List.map (fun _ -> scan fmt f) (1 ++ n)\n\nlet scan_list ?sep cnv =\n let line = read_line () in\n (match sep with\n | None -> List.map String.of_char @@ String.to_list line\n | Some sep -> String.split_on_char sep line)\n |> List.map cnv\n\nlet scan_array ?sep cnv = Array.of_list @@ scan_list ?sep cnv\n\nlet scan_matrix n m e ?sep conv =\n let arr = Array.make_matrix n m e in\n ListL.iter (0 ++^ n)\n ~f:(fun i -> arr.(i) <- Array.of_list @@ scan_list ?sep conv);\n arr\n\nlet rec powerset e =\n match Enum.get e with\n | None -> Enum.singleton @@ Enum.empty ()\n | Some v ->\n let f = powerset e in\n let g = Enum.clone f in\n EnumL.map f ~f:(fun x -> let y = Enum.clone x in push y v; y)\n |> Enum.append g\n\nlet permutations l =\n let rec aux l =\n let rec interleave x = function\n | [] -> [[x]]\n | (hd::tl) as lst ->\n (x::lst) ::\n (ListL.map ~f:(List.cons hd) @@ interleave x tl)\n in\n match l with\n | [] -> [[]]\n | hd::tl -> List.concat @@ List.map (interleave hd) @@ aux tl in\n let l = List.sort (List.compare Int.compare) @@ aux @@ List.of_enum l in\n List.enum % ListL.map ~f:List.enum @@ l\n\nlet intersection l =\n EnumL.filter ~f:(fun x -> EnumL.exists ~f:((=) x) @@ Enum.clone l)\n\nlet zip l m =\n let n = min (List.length l) (List.length m) in\n List.combine (List.take n l) (List.take n m)\n\nlet lower_bound n f =\n let rec aux l u =\n if u - l > 1 then\n let m = (l + u) / 2 in\n if f m then aux l m\n else aux m u\n else u in aux (-1) n\n\nlet between n x m = n <= x && x < m\n\nlet (a,b,c,x,y) = scan \"%d %d %d %d %d\" Tuple5.make\n\nlet () =\n [a*x + b*y; 2 * c * (max x y);\n 2*c*(min x y) + a*(x- min x y) + b*(y- min x y)]\n |> List.min\n |> Printf.printf \"%d\\n\"\n", "language": "OCaml", "metadata": {"date": 1591069617, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03371.html", "problem_id": "p03371", "resource_group": "low_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/OCaml/s044578192.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s044578192", "user_id": "u802614675"}, "prompt_components": {"gold_output": "7900\n", "input_to_evaluate": "open Batteries\nmodule EnumL = Enum.Labels\nmodule ListL = List.Labels\nmodule ArrayL = Array.Labels\n\nlet dbg0 x = Printf.eprintf \"[debug]%s\\n\" @@ dump x\nlet dbg1 x = dbg0 x; x\n\nlet id = identity\n\nlet (++) n m = List.range n `To m\nlet (++-) n m = if n >= m then List.range n `Downto m else []\nlet (++^) n m = if n < m then List.range n `To (pred m) else []\n\nlet scan fmt = Scanf.sscanf (read_line ()) fmt\n\nlet scan_lines n fmt f =\n if n = 0 then []\n else List.map (fun _ -> scan fmt f) (1 ++ n)\n\nlet scan_list ?sep cnv =\n let line = read_line () in\n (match sep with\n | None -> List.map String.of_char @@ String.to_list line\n | Some sep -> String.split_on_char sep line)\n |> List.map cnv\n\nlet scan_array ?sep cnv = Array.of_list @@ scan_list ?sep cnv\n\nlet scan_matrix n m e ?sep conv =\n let arr = Array.make_matrix n m e in\n ListL.iter (0 ++^ n)\n ~f:(fun i -> arr.(i) <- Array.of_list @@ scan_list ?sep conv);\n arr\n\nlet rec powerset e =\n match Enum.get e with\n | None -> Enum.singleton @@ Enum.empty ()\n | Some v ->\n let f = powerset e in\n let g = Enum.clone f in\n EnumL.map f ~f:(fun x -> let y = Enum.clone x in push y v; y)\n |> Enum.append g\n\nlet permutations l =\n let rec aux l =\n let rec interleave x = function\n | [] -> [[x]]\n | (hd::tl) as lst ->\n (x::lst) ::\n (ListL.map ~f:(List.cons hd) @@ interleave x tl)\n in\n match l with\n | [] -> [[]]\n | hd::tl -> List.concat @@ List.map (interleave hd) @@ aux tl in\n let l = List.sort (List.compare Int.compare) @@ aux @@ List.of_enum l in\n List.enum % ListL.map ~f:List.enum @@ l\n\nlet intersection l =\n EnumL.filter ~f:(fun x -> EnumL.exists ~f:((=) x) @@ Enum.clone l)\n\nlet zip l m =\n let n = min (List.length l) (List.length m) in\n List.combine (List.take n l) (List.take n m)\n\nlet lower_bound n f =\n let rec aux l u =\n if u - l > 1 then\n let m = (l + u) / 2 in\n if f m then aux l m\n else aux m u\n else u in aux (-1) n\n\nlet between n x m = n <= x && x < m\n\nlet (a,b,c,x,y) = scan \"%d %d %d %d %d\" Tuple5.make\n\nlet () =\n [a*x + b*y; 2 * c * (max x y);\n 2*c*(min x y) + a*(x- min x y) + b*(y- min x y)]\n |> List.min\n |> Printf.printf \"%d\\n\"\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\n\"Pizza At\", a fast food chain, offers three kinds of pizza: \"A-pizza\", \"B-pizza\" and \"AB-pizza\". A-pizza and B-pizza are completely different pizzas, and AB-pizza is one half of A-pizza and one half of B-pizza combined together. The prices of one A-pizza, B-pizza and AB-pizza are A yen, B yen and C yen (yen is the currency of Japan), respectively.\n\nNakahashi needs to prepare X A-pizzas and Y B-pizzas for a party tonight. He can only obtain these pizzas by directly buying A-pizzas and B-pizzas, or buying two AB-pizzas and then rearrange them into one A-pizza and one B-pizza. At least how much money does he need for this? It is fine to have more pizzas than necessary by rearranging pizzas.\n\nConstraints\n\n1 ≤ A, B, C ≤ 5000\n\n1 ≤ X, Y ≤ 10^5\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C X Y\n\nOutput\n\nPrint the minimum amount of money required to prepare X A-pizzas and Y B-pizzas.\n\nSample Input 1\n\n1500 2000 1600 3 2\n\nSample Output 1\n\n7900\n\nIt is optimal to buy four AB-pizzas and rearrange them into two A-pizzas and two B-pizzas, then buy additional one A-pizza.\n\nSample Input 2\n\n1500 2000 1900 3 2\n\nSample Output 2\n\n8500\n\nIt is optimal to directly buy three A-pizzas and two B-pizzas.\n\nSample Input 3\n\n1500 2000 500 90000 100000\n\nSample Output 3\n\n100000000\n\nIt is optimal to buy 200000 AB-pizzas and rearrange them into 100000 A-pizzas and 100000 B-pizzas. We will have 10000 more A-pizzas than necessary, but that is fine.", "sample_input": "1500 2000 1600 3 2\n"}, "reference_outputs": ["7900\n"], "source_document_id": "p03371", "source_text": "Score : 300 points\n\nProblem Statement\n\n\"Pizza At\", a fast food chain, offers three kinds of pizza: \"A-pizza\", \"B-pizza\" and \"AB-pizza\". A-pizza and B-pizza are completely different pizzas, and AB-pizza is one half of A-pizza and one half of B-pizza combined together. The prices of one A-pizza, B-pizza and AB-pizza are A yen, B yen and C yen (yen is the currency of Japan), respectively.\n\nNakahashi needs to prepare X A-pizzas and Y B-pizzas for a party tonight. He can only obtain these pizzas by directly buying A-pizzas and B-pizzas, or buying two AB-pizzas and then rearrange them into one A-pizza and one B-pizza. At least how much money does he need for this? It is fine to have more pizzas than necessary by rearranging pizzas.\n\nConstraints\n\n1 ≤ A, B, C ≤ 5000\n\n1 ≤ X, Y ≤ 10^5\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C X Y\n\nOutput\n\nPrint the minimum amount of money required to prepare X A-pizzas and Y B-pizzas.\n\nSample Input 1\n\n1500 2000 1600 3 2\n\nSample Output 1\n\n7900\n\nIt is optimal to buy four AB-pizzas and rearrange them into two A-pizzas and two B-pizzas, then buy additional one A-pizza.\n\nSample Input 2\n\n1500 2000 1900 3 2\n\nSample Output 2\n\n8500\n\nIt is optimal to directly buy three A-pizzas and two B-pizzas.\n\nSample Input 3\n\n1500 2000 500 90000 100000\n\nSample Output 3\n\n100000000\n\nIt is optimal to buy 200000 AB-pizzas and rearrange them into 100000 A-pizzas and 100000 B-pizzas. We will have 10000 more A-pizzas than necessary, but that is fine.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2191, "cpu_time_ms": 2, "memory_kb": 3072}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s472688994", "group_id": "codeNet:p03371", "input_text": "let () =\n let a, b, c, x, y = Scanf.scanf \"%d %d %d %d %d\\n\" (fun a b c d e -> a, b, c, d, e) in\n\n let a1 =\n if x < y\n then c * 2 * x + b * (y - x)\n else c * 2 * y + a * (x - y)\n in\n let a2 = a * x + b * y in\n let a3 = c * 2 * (if x > y then x else y) in\n\n print_endline (string_of_int (min a1 (min a2 a3)))\n\n", "language": "OCaml", "metadata": {"date": 1524450081, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03371.html", "problem_id": "p03371", "resource_group": "low_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/OCaml/s472688994.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s472688994", "user_id": "u139013163"}, "prompt_components": {"gold_output": "7900\n", "input_to_evaluate": "let () =\n let a, b, c, x, y = Scanf.scanf \"%d %d %d %d %d\\n\" (fun a b c d e -> a, b, c, d, e) in\n\n let a1 =\n if x < y\n then c * 2 * x + b * (y - x)\n else c * 2 * y + a * (x - y)\n in\n let a2 = a * x + b * y in\n let a3 = c * 2 * (if x > y then x else y) in\n\n print_endline (string_of_int (min a1 (min a2 a3)))\n\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\n\"Pizza At\", a fast food chain, offers three kinds of pizza: \"A-pizza\", \"B-pizza\" and \"AB-pizza\". A-pizza and B-pizza are completely different pizzas, and AB-pizza is one half of A-pizza and one half of B-pizza combined together. The prices of one A-pizza, B-pizza and AB-pizza are A yen, B yen and C yen (yen is the currency of Japan), respectively.\n\nNakahashi needs to prepare X A-pizzas and Y B-pizzas for a party tonight. He can only obtain these pizzas by directly buying A-pizzas and B-pizzas, or buying two AB-pizzas and then rearrange them into one A-pizza and one B-pizza. At least how much money does he need for this? It is fine to have more pizzas than necessary by rearranging pizzas.\n\nConstraints\n\n1 ≤ A, B, C ≤ 5000\n\n1 ≤ X, Y ≤ 10^5\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C X Y\n\nOutput\n\nPrint the minimum amount of money required to prepare X A-pizzas and Y B-pizzas.\n\nSample Input 1\n\n1500 2000 1600 3 2\n\nSample Output 1\n\n7900\n\nIt is optimal to buy four AB-pizzas and rearrange them into two A-pizzas and two B-pizzas, then buy additional one A-pizza.\n\nSample Input 2\n\n1500 2000 1900 3 2\n\nSample Output 2\n\n8500\n\nIt is optimal to directly buy three A-pizzas and two B-pizzas.\n\nSample Input 3\n\n1500 2000 500 90000 100000\n\nSample Output 3\n\n100000000\n\nIt is optimal to buy 200000 AB-pizzas and rearrange them into 100000 A-pizzas and 100000 B-pizzas. We will have 10000 more A-pizzas than necessary, but that is fine.", "sample_input": "1500 2000 1600 3 2\n"}, "reference_outputs": ["7900\n"], "source_document_id": "p03371", "source_text": "Score : 300 points\n\nProblem Statement\n\n\"Pizza At\", a fast food chain, offers three kinds of pizza: \"A-pizza\", \"B-pizza\" and \"AB-pizza\". A-pizza and B-pizza are completely different pizzas, and AB-pizza is one half of A-pizza and one half of B-pizza combined together. The prices of one A-pizza, B-pizza and AB-pizza are A yen, B yen and C yen (yen is the currency of Japan), respectively.\n\nNakahashi needs to prepare X A-pizzas and Y B-pizzas for a party tonight. He can only obtain these pizzas by directly buying A-pizzas and B-pizzas, or buying two AB-pizzas and then rearrange them into one A-pizza and one B-pizza. At least how much money does he need for this? It is fine to have more pizzas than necessary by rearranging pizzas.\n\nConstraints\n\n1 ≤ A, B, C ≤ 5000\n\n1 ≤ X, Y ≤ 10^5\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C X Y\n\nOutput\n\nPrint the minimum amount of money required to prepare X A-pizzas and Y B-pizzas.\n\nSample Input 1\n\n1500 2000 1600 3 2\n\nSample Output 1\n\n7900\n\nIt is optimal to buy four AB-pizzas and rearrange them into two A-pizzas and two B-pizzas, then buy additional one A-pizza.\n\nSample Input 2\n\n1500 2000 1900 3 2\n\nSample Output 2\n\n8500\n\nIt is optimal to directly buy three A-pizzas and two B-pizzas.\n\nSample Input 3\n\n1500 2000 500 90000 100000\n\nSample Output 3\n\n100000000\n\nIt is optimal to buy 200000 AB-pizzas and rearrange them into 100000 A-pizzas and 100000 B-pizzas. We will have 10000 more A-pizzas than necessary, but that is fine.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s363994297", "group_id": "codeNet:p03372", "input_text": "let () =\n let open Int64 in\n let len, b = Scanf.scanf \"%d %Ld\\n\" (fun a b -> a, b) in\n\n let arr = Array.make len (0L,0L) in\n for i = 0 to (len-1) do\n let c = Scanf.scanf \"%Ld %Ld\\n\" (fun a b -> a, b) in\n Array.set arr i c\n done;\n\n let arr_l = Array.make len (0L,0L) in\n let arr_r = Array.make len (0L,0L) in\n let arr_l2 = Array.make len (0L,0L) in\n let arr_r2 = Array.make len (0L,0L) in\n\n let t = ref (0L,0L) in\n for i = 0 to (len-1) do\n let distance = fst (Array.get arr i) in\n\n let cal = Int64.add (snd (Array.get arr i)) \n ( if (i=0) then 0L else (snd (Array.get arr_l (i-1)))) in\n\n let d_sub = if (i=0) then 0L else (fst (Array.get arr_l (i-1))) in\n let d_sub = Int64.sub distance d_sub in\n let cal = Int64.sub cal d_sub in\n\n let tt = (distance, cal) in\n if (cal > (snd !t))\n then (\n t := tt\n )\n else ();\n Array.set arr_l i tt;\n Array.set arr_l2 i !t;\n done;\n\n let u = ref (0L,0L) in\n for i = 0 to (len-1) do\n let i = len-1-i in\n let distance = Int64.sub b (fst (Array.get arr i)) in\n let cal = Int64.add (snd (Array.get arr i))\n (if (i=len-1) then 0L else (snd (Array.get arr_r (i+1))) ) in\n\n let d_sub = if (i=len-1) then 0L else (fst (Array.get arr_r (i+1))) in\n let d_sub = Int64.sub distance d_sub in\n let cal = Int64.sub cal d_sub in\n\n let tt = (distance, cal) in\n if (cal > (snd !u))\n then (\n u := tt\n )\n else ();\n Array.set arr_r i tt;\n Array.set arr_r2 i !u;\n done;\n\n let v = ref (0L,0L) in\n for i = 0 to (len-1) do\n let j = if (i=len-1) then 0 else i+1 in\n\n let d_l = fst (Array.get arr_l2 i) in\n let d_r = \n if (j = 0) then\n 0L\n else\n fst (Array.get arr_r2 j) in\n let d_sub = if d_l > d_r then d_r else d_l in\n\n let cal_l = snd (Array.get arr_l2 i) in\n let cal_r = \n if (j = 0) then\n 0L\n else\n snd (Array.get arr_r2 j) in\n let cal = Int64.sub (Int64.add cal_l cal_r) d_sub in\n\n if (cal > (snd !v))\n then (\n let tt = (0L, cal) in\n v := tt\n )\n else ();\n done;\n \n let res = max (max (snd !t) (snd !u)) (snd !v) in\n Printf.printf \"%Ld\" res;", "language": "OCaml", "metadata": {"date": 1524466169, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03372.html", "problem_id": "p03372", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03372/input.txt", "sample_output_relpath": "derived/input_output/data/p03372/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03372/OCaml/s363994297.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s363994297", "user_id": "u139013163"}, "prompt_components": {"gold_output": "191\n", "input_to_evaluate": "let () =\n let open Int64 in\n let len, b = Scanf.scanf \"%d %Ld\\n\" (fun a b -> a, b) in\n\n let arr = Array.make len (0L,0L) in\n for i = 0 to (len-1) do\n let c = Scanf.scanf \"%Ld %Ld\\n\" (fun a b -> a, b) in\n Array.set arr i c\n done;\n\n let arr_l = Array.make len (0L,0L) in\n let arr_r = Array.make len (0L,0L) in\n let arr_l2 = Array.make len (0L,0L) in\n let arr_r2 = Array.make len (0L,0L) in\n\n let t = ref (0L,0L) in\n for i = 0 to (len-1) do\n let distance = fst (Array.get arr i) in\n\n let cal = Int64.add (snd (Array.get arr i)) \n ( if (i=0) then 0L else (snd (Array.get arr_l (i-1)))) in\n\n let d_sub = if (i=0) then 0L else (fst (Array.get arr_l (i-1))) in\n let d_sub = Int64.sub distance d_sub in\n let cal = Int64.sub cal d_sub in\n\n let tt = (distance, cal) in\n if (cal > (snd !t))\n then (\n t := tt\n )\n else ();\n Array.set arr_l i tt;\n Array.set arr_l2 i !t;\n done;\n\n let u = ref (0L,0L) in\n for i = 0 to (len-1) do\n let i = len-1-i in\n let distance = Int64.sub b (fst (Array.get arr i)) in\n let cal = Int64.add (snd (Array.get arr i))\n (if (i=len-1) then 0L else (snd (Array.get arr_r (i+1))) ) in\n\n let d_sub = if (i=len-1) then 0L else (fst (Array.get arr_r (i+1))) in\n let d_sub = Int64.sub distance d_sub in\n let cal = Int64.sub cal d_sub in\n\n let tt = (distance, cal) in\n if (cal > (snd !u))\n then (\n u := tt\n )\n else ();\n Array.set arr_r i tt;\n Array.set arr_r2 i !u;\n done;\n\n let v = ref (0L,0L) in\n for i = 0 to (len-1) do\n let j = if (i=len-1) then 0 else i+1 in\n\n let d_l = fst (Array.get arr_l2 i) in\n let d_r = \n if (j = 0) then\n 0L\n else\n fst (Array.get arr_r2 j) in\n let d_sub = if d_l > d_r then d_r else d_l in\n\n let cal_l = snd (Array.get arr_l2 i) in\n let cal_r = \n if (j = 0) then\n 0L\n else\n snd (Array.get arr_r2 j) in\n let cal = Int64.sub (Int64.add cal_l cal_r) d_sub in\n\n if (cal > (snd !v))\n then (\n let tt = (0L, cal) in\n v := tt\n )\n else ();\n done;\n \n let res = max (max (snd !t) (snd !u)) (snd !v) in\n Printf.printf \"%Ld\" res;", "problem_context": "Score : 500 points\n\nProblem Statement\n\n\"Teishi-zushi\", a Japanese restaurant, is a plain restaurant with only one round counter. The outer circumference of the counter is C meters. Customers cannot go inside the counter.\n\nNakahashi entered Teishi-zushi, and he was guided to the counter. Now, there are N pieces of sushi (vinegared rice with seafood and so on) on the counter. The distance measured clockwise from the point where Nakahashi is standing to the point where the i-th sushi is placed, is x_i meters. Also, the i-th sushi has a nutritive value of v_i kilocalories.\n\nNakahashi can freely walk around the circumference of the counter. When he reach a point where a sushi is placed, he can eat that sushi and take in its nutrition (naturally, the sushi disappears). However, while walking, he consumes 1 kilocalories per meter.\n\nWhenever he is satisfied, he can leave the restaurant from any place (he does not have to return to the initial place). On balance, at most how much nutrition can he take in before he leaves? That is, what is the maximum possible value of the total nutrition taken in minus the total energy consumed? Assume that there are no other customers, and no new sushi will be added to the counter. Also, since Nakahashi has plenty of nutrition in his body, assume that no matter how much he walks and consumes energy, he never dies from hunger.\n\nConstraints\n\n1 ≤ N ≤ 10^5\n\n2 ≤ C ≤ 10^{14}\n\n1 ≤ x_1 < x_2 < ... < x_N < C\n\n1 ≤ v_i ≤ 10^9\n\nAll values in input are integers.\n\nSubscores\n\n300 points will be awarded for passing the test set satisfying N ≤ 100.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN C\nx_1 v_1\nx_2 v_2\n:\nx_N v_N\n\nOutput\n\nIf Nakahashi can take in at most c kilocalories on balance before he leaves the restaurant, print c.\n\nSample Input 1\n\n3 20\n2 80\n9 120\n16 1\n\nSample Output 1\n\n191\n\nThere are three sushi on the counter with a circumference of 20 meters. If he walks two meters clockwise from the initial place, he can eat a sushi of 80 kilocalories. If he walks seven more meters clockwise, he can eat a sushi of 120 kilocalories. If he leaves now, the total nutrition taken in is 200 kilocalories, and the total energy consumed is 9 kilocalories, thus he can take in 191 kilocalories on balance, which is the largest possible value.\n\nSample Input 2\n\n3 20\n2 80\n9 1\n16 120\n\nSample Output 2\n\n192\n\nThe second and third sushi have been swapped. Again, if he walks two meters clockwise from the initial place, he can eat a sushi of 80 kilocalories. If he walks six more meters counterclockwise this time, he can eat a sushi of 120 kilocalories. If he leaves now, the total nutrition taken in is 200 kilocalories, and the total energy consumed is 8 kilocalories, thus he can take in 192 kilocalories on balance, which is the largest possible value.\n\nSample Input 3\n\n1 100000000000000\n50000000000000 1\n\nSample Output 3\n\n0\n\nEven though the only sushi is so far that it does not fit into a 32-bit integer, its nutritive value is low, thus he should immediately leave without doing anything.\n\nSample Input 4\n\n15 10000000000\n400000000 1000000000\n800000000 1000000000\n1900000000 1000000000\n2400000000 1000000000\n2900000000 1000000000\n3300000000 1000000000\n3700000000 1000000000\n3800000000 1000000000\n4000000000 1000000000\n4100000000 1000000000\n5200000000 1000000000\n6600000000 1000000000\n8000000000 1000000000\n9300000000 1000000000\n9700000000 1000000000\n\nSample Output 4\n\n6500000000\n\nAll these sample inputs above are included in the test set for the partial score.", "sample_input": "3 20\n2 80\n9 120\n16 1\n"}, "reference_outputs": ["191\n"], "source_document_id": "p03372", "source_text": "Score : 500 points\n\nProblem Statement\n\n\"Teishi-zushi\", a Japanese restaurant, is a plain restaurant with only one round counter. The outer circumference of the counter is C meters. Customers cannot go inside the counter.\n\nNakahashi entered Teishi-zushi, and he was guided to the counter. Now, there are N pieces of sushi (vinegared rice with seafood and so on) on the counter. The distance measured clockwise from the point where Nakahashi is standing to the point where the i-th sushi is placed, is x_i meters. Also, the i-th sushi has a nutritive value of v_i kilocalories.\n\nNakahashi can freely walk around the circumference of the counter. When he reach a point where a sushi is placed, he can eat that sushi and take in its nutrition (naturally, the sushi disappears). However, while walking, he consumes 1 kilocalories per meter.\n\nWhenever he is satisfied, he can leave the restaurant from any place (he does not have to return to the initial place). On balance, at most how much nutrition can he take in before he leaves? That is, what is the maximum possible value of the total nutrition taken in minus the total energy consumed? Assume that there are no other customers, and no new sushi will be added to the counter. Also, since Nakahashi has plenty of nutrition in his body, assume that no matter how much he walks and consumes energy, he never dies from hunger.\n\nConstraints\n\n1 ≤ N ≤ 10^5\n\n2 ≤ C ≤ 10^{14}\n\n1 ≤ x_1 < x_2 < ... < x_N < C\n\n1 ≤ v_i ≤ 10^9\n\nAll values in input are integers.\n\nSubscores\n\n300 points will be awarded for passing the test set satisfying N ≤ 100.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN C\nx_1 v_1\nx_2 v_2\n:\nx_N v_N\n\nOutput\n\nIf Nakahashi can take in at most c kilocalories on balance before he leaves the restaurant, print c.\n\nSample Input 1\n\n3 20\n2 80\n9 120\n16 1\n\nSample Output 1\n\n191\n\nThere are three sushi on the counter with a circumference of 20 meters. If he walks two meters clockwise from the initial place, he can eat a sushi of 80 kilocalories. If he walks seven more meters clockwise, he can eat a sushi of 120 kilocalories. If he leaves now, the total nutrition taken in is 200 kilocalories, and the total energy consumed is 9 kilocalories, thus he can take in 191 kilocalories on balance, which is the largest possible value.\n\nSample Input 2\n\n3 20\n2 80\n9 1\n16 120\n\nSample Output 2\n\n192\n\nThe second and third sushi have been swapped. Again, if he walks two meters clockwise from the initial place, he can eat a sushi of 80 kilocalories. If he walks six more meters counterclockwise this time, he can eat a sushi of 120 kilocalories. If he leaves now, the total nutrition taken in is 200 kilocalories, and the total energy consumed is 8 kilocalories, thus he can take in 192 kilocalories on balance, which is the largest possible value.\n\nSample Input 3\n\n1 100000000000000\n50000000000000 1\n\nSample Output 3\n\n0\n\nEven though the only sushi is so far that it does not fit into a 32-bit integer, its nutritive value is low, thus he should immediately leave without doing anything.\n\nSample Input 4\n\n15 10000000000\n400000000 1000000000\n800000000 1000000000\n1900000000 1000000000\n2400000000 1000000000\n2900000000 1000000000\n3300000000 1000000000\n3700000000 1000000000\n3800000000 1000000000\n4000000000 1000000000\n4100000000 1000000000\n5200000000 1000000000\n6600000000 1000000000\n8000000000 1000000000\n9300000000 1000000000\n9700000000 1000000000\n\nSample Output 4\n\n6500000000\n\nAll these sample inputs above are included in the test set for the partial score.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2168, "cpu_time_ms": 126, "memory_kb": 27776}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s890253450", "group_id": "codeNet:p03372", "input_text": "let () =\n let open Int64 in\n let len, b = Scanf.scanf \"%d %Ld\\n\" (fun a b -> a, b) in\n\n let arr = Array.make len (0L,0L) in\n for i = 0 to (len-1) do\n let c = Scanf.scanf \"%Ld %Ld\\n\" (fun a b -> a, b) in\n Array.set arr i c\n done;\n let t = ref 0L in\n\n let arr_l = Array.make len (0L,0L) in\n let arr_r = Array.make len (0L,0L) in\n\n for i = 0 to (len-1) do\n let distance = fst (Array.get arr i) in\n\n let cal = Int64.add (snd (Array.get arr i)) \n ( if (i=0) then 0L else (snd (Array.get arr_l (i-1)))) in\n\n let d_sub = if (i=0) then 0L else (fst (Array.get arr_l (i-1))) in\n let d_sub = Int64.sub distance d_sub in\n let cal = Int64.sub cal d_sub in\n\n if (cal > !t) \n then (t := cal)\n else ();\n Array.set arr_l i (distance, cal)\n\n done;\n for i = 0 to (len-1) do\n let i = len-1-i in\n let distance = Int64.sub b (fst (Array.get arr i)) in\n let cal = Int64.add (snd (Array.get arr i))\n (if (i=len-1) then 0L else (snd (Array.get arr_r (i+1))) ) in\n\n let d_sub = if (i=len-1) then 0L else (fst (Array.get arr_r (i+1))) in\n let d_sub = Int64.sub distance d_sub in\n let cal = Int64.sub cal d_sub in\n\n if (cal > !t) \n then (t := cal)\n else ();\n Array.set arr_r i (distance, cal)\n done;\n\n for i = 0 to (len-1) do\n for j = 0 to (len-1) do\n let cal =\n if i >= j then 0L\n else\n let d_l = fst (Array.get arr_l i) in\n let d_r = fst (Array.get arr_r j) in\n let d_sub = if d_l > d_r then d_r else d_l in\n\n let cal_l = snd (Array.get arr_l i) in\n let cal_r = snd (Array.get arr_r j) in\n let cal = Int64.sub (Int64.add cal_l cal_r) d_sub in\n cal\n in\n\n if (cal > !t) \n then (t := cal)\n else ()\n done;\n done;\n\n Printf.printf \"%Ld\" !t;", "language": "OCaml", "metadata": {"date": 1524458958, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03372.html", "problem_id": "p03372", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03372/input.txt", "sample_output_relpath": "derived/input_output/data/p03372/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03372/OCaml/s890253450.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s890253450", "user_id": "u139013163"}, "prompt_components": {"gold_output": "191\n", "input_to_evaluate": "let () =\n let open Int64 in\n let len, b = Scanf.scanf \"%d %Ld\\n\" (fun a b -> a, b) in\n\n let arr = Array.make len (0L,0L) in\n for i = 0 to (len-1) do\n let c = Scanf.scanf \"%Ld %Ld\\n\" (fun a b -> a, b) in\n Array.set arr i c\n done;\n let t = ref 0L in\n\n let arr_l = Array.make len (0L,0L) in\n let arr_r = Array.make len (0L,0L) in\n\n for i = 0 to (len-1) do\n let distance = fst (Array.get arr i) in\n\n let cal = Int64.add (snd (Array.get arr i)) \n ( if (i=0) then 0L else (snd (Array.get arr_l (i-1)))) in\n\n let d_sub = if (i=0) then 0L else (fst (Array.get arr_l (i-1))) in\n let d_sub = Int64.sub distance d_sub in\n let cal = Int64.sub cal d_sub in\n\n if (cal > !t) \n then (t := cal)\n else ();\n Array.set arr_l i (distance, cal)\n\n done;\n for i = 0 to (len-1) do\n let i = len-1-i in\n let distance = Int64.sub b (fst (Array.get arr i)) in\n let cal = Int64.add (snd (Array.get arr i))\n (if (i=len-1) then 0L else (snd (Array.get arr_r (i+1))) ) in\n\n let d_sub = if (i=len-1) then 0L else (fst (Array.get arr_r (i+1))) in\n let d_sub = Int64.sub distance d_sub in\n let cal = Int64.sub cal d_sub in\n\n if (cal > !t) \n then (t := cal)\n else ();\n Array.set arr_r i (distance, cal)\n done;\n\n for i = 0 to (len-1) do\n for j = 0 to (len-1) do\n let cal =\n if i >= j then 0L\n else\n let d_l = fst (Array.get arr_l i) in\n let d_r = fst (Array.get arr_r j) in\n let d_sub = if d_l > d_r then d_r else d_l in\n\n let cal_l = snd (Array.get arr_l i) in\n let cal_r = snd (Array.get arr_r j) in\n let cal = Int64.sub (Int64.add cal_l cal_r) d_sub in\n cal\n in\n\n if (cal > !t) \n then (t := cal)\n else ()\n done;\n done;\n\n Printf.printf \"%Ld\" !t;", "problem_context": "Score : 500 points\n\nProblem Statement\n\n\"Teishi-zushi\", a Japanese restaurant, is a plain restaurant with only one round counter. The outer circumference of the counter is C meters. Customers cannot go inside the counter.\n\nNakahashi entered Teishi-zushi, and he was guided to the counter. Now, there are N pieces of sushi (vinegared rice with seafood and so on) on the counter. The distance measured clockwise from the point where Nakahashi is standing to the point where the i-th sushi is placed, is x_i meters. Also, the i-th sushi has a nutritive value of v_i kilocalories.\n\nNakahashi can freely walk around the circumference of the counter. When he reach a point where a sushi is placed, he can eat that sushi and take in its nutrition (naturally, the sushi disappears). However, while walking, he consumes 1 kilocalories per meter.\n\nWhenever he is satisfied, he can leave the restaurant from any place (he does not have to return to the initial place). On balance, at most how much nutrition can he take in before he leaves? That is, what is the maximum possible value of the total nutrition taken in minus the total energy consumed? Assume that there are no other customers, and no new sushi will be added to the counter. Also, since Nakahashi has plenty of nutrition in his body, assume that no matter how much he walks and consumes energy, he never dies from hunger.\n\nConstraints\n\n1 ≤ N ≤ 10^5\n\n2 ≤ C ≤ 10^{14}\n\n1 ≤ x_1 < x_2 < ... < x_N < C\n\n1 ≤ v_i ≤ 10^9\n\nAll values in input are integers.\n\nSubscores\n\n300 points will be awarded for passing the test set satisfying N ≤ 100.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN C\nx_1 v_1\nx_2 v_2\n:\nx_N v_N\n\nOutput\n\nIf Nakahashi can take in at most c kilocalories on balance before he leaves the restaurant, print c.\n\nSample Input 1\n\n3 20\n2 80\n9 120\n16 1\n\nSample Output 1\n\n191\n\nThere are three sushi on the counter with a circumference of 20 meters. If he walks two meters clockwise from the initial place, he can eat a sushi of 80 kilocalories. If he walks seven more meters clockwise, he can eat a sushi of 120 kilocalories. If he leaves now, the total nutrition taken in is 200 kilocalories, and the total energy consumed is 9 kilocalories, thus he can take in 191 kilocalories on balance, which is the largest possible value.\n\nSample Input 2\n\n3 20\n2 80\n9 1\n16 120\n\nSample Output 2\n\n192\n\nThe second and third sushi have been swapped. Again, if he walks two meters clockwise from the initial place, he can eat a sushi of 80 kilocalories. If he walks six more meters counterclockwise this time, he can eat a sushi of 120 kilocalories. If he leaves now, the total nutrition taken in is 200 kilocalories, and the total energy consumed is 8 kilocalories, thus he can take in 192 kilocalories on balance, which is the largest possible value.\n\nSample Input 3\n\n1 100000000000000\n50000000000000 1\n\nSample Output 3\n\n0\n\nEven though the only sushi is so far that it does not fit into a 32-bit integer, its nutritive value is low, thus he should immediately leave without doing anything.\n\nSample Input 4\n\n15 10000000000\n400000000 1000000000\n800000000 1000000000\n1900000000 1000000000\n2400000000 1000000000\n2900000000 1000000000\n3300000000 1000000000\n3700000000 1000000000\n3800000000 1000000000\n4000000000 1000000000\n4100000000 1000000000\n5200000000 1000000000\n6600000000 1000000000\n8000000000 1000000000\n9300000000 1000000000\n9700000000 1000000000\n\nSample Output 4\n\n6500000000\n\nAll these sample inputs above are included in the test set for the partial score.", "sample_input": "3 20\n2 80\n9 120\n16 1\n"}, "reference_outputs": ["191\n"], "source_document_id": "p03372", "source_text": "Score : 500 points\n\nProblem Statement\n\n\"Teishi-zushi\", a Japanese restaurant, is a plain restaurant with only one round counter. The outer circumference of the counter is C meters. Customers cannot go inside the counter.\n\nNakahashi entered Teishi-zushi, and he was guided to the counter. Now, there are N pieces of sushi (vinegared rice with seafood and so on) on the counter. The distance measured clockwise from the point where Nakahashi is standing to the point where the i-th sushi is placed, is x_i meters. Also, the i-th sushi has a nutritive value of v_i kilocalories.\n\nNakahashi can freely walk around the circumference of the counter. When he reach a point where a sushi is placed, he can eat that sushi and take in its nutrition (naturally, the sushi disappears). However, while walking, he consumes 1 kilocalories per meter.\n\nWhenever he is satisfied, he can leave the restaurant from any place (he does not have to return to the initial place). On balance, at most how much nutrition can he take in before he leaves? That is, what is the maximum possible value of the total nutrition taken in minus the total energy consumed? Assume that there are no other customers, and no new sushi will be added to the counter. Also, since Nakahashi has plenty of nutrition in his body, assume that no matter how much he walks and consumes energy, he never dies from hunger.\n\nConstraints\n\n1 ≤ N ≤ 10^5\n\n2 ≤ C ≤ 10^{14}\n\n1 ≤ x_1 < x_2 < ... < x_N < C\n\n1 ≤ v_i ≤ 10^9\n\nAll values in input are integers.\n\nSubscores\n\n300 points will be awarded for passing the test set satisfying N ≤ 100.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN C\nx_1 v_1\nx_2 v_2\n:\nx_N v_N\n\nOutput\n\nIf Nakahashi can take in at most c kilocalories on balance before he leaves the restaurant, print c.\n\nSample Input 1\n\n3 20\n2 80\n9 120\n16 1\n\nSample Output 1\n\n191\n\nThere are three sushi on the counter with a circumference of 20 meters. If he walks two meters clockwise from the initial place, he can eat a sushi of 80 kilocalories. If he walks seven more meters clockwise, he can eat a sushi of 120 kilocalories. If he leaves now, the total nutrition taken in is 200 kilocalories, and the total energy consumed is 9 kilocalories, thus he can take in 191 kilocalories on balance, which is the largest possible value.\n\nSample Input 2\n\n3 20\n2 80\n9 1\n16 120\n\nSample Output 2\n\n192\n\nThe second and third sushi have been swapped. Again, if he walks two meters clockwise from the initial place, he can eat a sushi of 80 kilocalories. If he walks six more meters counterclockwise this time, he can eat a sushi of 120 kilocalories. If he leaves now, the total nutrition taken in is 200 kilocalories, and the total energy consumed is 8 kilocalories, thus he can take in 192 kilocalories on balance, which is the largest possible value.\n\nSample Input 3\n\n1 100000000000000\n50000000000000 1\n\nSample Output 3\n\n0\n\nEven though the only sushi is so far that it does not fit into a 32-bit integer, its nutritive value is low, thus he should immediately leave without doing anything.\n\nSample Input 4\n\n15 10000000000\n400000000 1000000000\n800000000 1000000000\n1900000000 1000000000\n2400000000 1000000000\n2900000000 1000000000\n3300000000 1000000000\n3700000000 1000000000\n3800000000 1000000000\n4000000000 1000000000\n4100000000 1000000000\n5200000000 1000000000\n6600000000 1000000000\n8000000000 1000000000\n9300000000 1000000000\n9700000000 1000000000\n\nSample Output 4\n\n6500000000\n\nAll these sample inputs above are included in the test set for the partial score.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1809, "cpu_time_ms": 2105, "memory_kb": 27164}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s851303057", "group_id": "codeNet:p03373", "input_text": "open Printf open Scanf\nmodule MyInt = struct let (+) = (+) let (-) = (-) let (/) = (/) let ( * ) = ( * ) let (mod) = (mod) let (%) = (mod) let (+=) r v = r := !r + v let (-=) r v = r := !r - v let ( *=) r v= r := !r * v let (/=) r v = r := !r / v end\nmodule MyInt64 = struct\n\tlet (+$) = (+) let (-$) = (-) let (/$) = (/) let ( *$) = ( * ) let (+) p q = Int64.add p q let (-) p q = Int64.sub p q let ( * ) p q = Int64.mul p q let (/) p q = Int64.div p q let (+=) r v = r := !r + v let (-=) r v = r := !r - v let ( *=) r v= r := !r * v let (/=) r v = r := !r / v let labs p = if p < 0L then -1L*p else p let (~|) p = Int64.to_int p let (~~|) p = Int64.of_int p let input_i64_array n = Array.init (~| n) (fun _ -> Scanf.scanf \" %Ld\" (fun v -> v)) let get_i64 _ = Scanf.scanf \" %Ld\" (fun v -> v) let get_2_i64 _ = Scanf.scanf \" %Ld %Ld\" (fun u v -> u,v) let get_3_i64 _ = Scanf.scanf \" %Ld %Ld %Ld\" (fun u v w -> u,v,w) let get_4_i64 _ = Scanf.scanf \" %Ld %Ld %Ld %Ld\" (fun u v w x -> u,v,w,x) let get_5_i64 _ = Scanf.scanf \" %Ld %Ld %Ld %Ld %Ld\" (fun u v w x y -> u,v,w,x,y) let print_i64_endline n = n |> Int64.to_string |> print_endline let (mod) m n = m - (m/n) * n let (%) = (mod) let rec gcd m n = match m,n with | m,0L -> m | m,n -> gcd n (m mod n) let lcm m n = (m*n) / gcd m n let rep from_ to_ fbod = let i,f = ref ~|from_,ref true in while !i <= ~|to_ && !f do match fbod ~~| !i with | `Break -> f := false | _ -> i := !i +$ 1; done let repb from_ to_ fbod = let i,f = ref ~|from_,ref true in while !i <= ~|to_ && !f do match fbod (~~| !i) with | `Break -> f := false | _ -> i := !i +$ 1 done; !f let repm from_ to_ m_init fbod = let i,f,m = ref ~|from_,ref true,ref m_init in while !i <= ~|to_ && !f do match fbod !m (~~| !i) with | `Break -> f := false | `Break_m m' -> (f := false; m := m') | `Ok m' -> (i := !i +$ 1; m := m') done; !m let repmb from_ to_ m_init fbod = let i,f,m = ref ~|from_,ref true,ref m_init in while !i <= ~|to_ && !f do match fbod (~~| !i) !m with | `Break -> f := false | `Break_m m' -> (f := false; m := m') | `Ok m' -> (i := !i +$ 1; m := m') done; (!m,!f) let string_of_list ?(separator=\" \") f ls = let rec f0 a s = match a with | [] -> s | [h] -> s ^ (f h) ^ separator | h::t -> f0 t (s ^ (f h) ^ separator) in f0 ls \"\" let char_list_of_string str = let rec f0 i a = if i<0 then a else f0 (i-$1) (str.[i]::a) in f0 (String.length str -$ 1) [] let string_of_char_list ls = List.fold_left (fun u v -> u ^ (String.make 1 v)) \"\" ls\n\tlet (@@@) = (@) let (@) a i = a.(~|i) let (<@) a (i,v) = a.(~|i) <- v\n\tlet ceildiv m n = (m+n-1L) / n\nend open MyInt64\n\nlet () =\n\tlet a,b,c,x,y = get_5_i64 0 in\n\trepm 0L (max x y) Int64.max_int (fun u v ->\n\t\tlet xr,yr = max 0L (x-v),max 0L (y-v) in\n\t\t`Ok (min u (2L*c*v + a*xr + b * yr))\n\t) |> printf \"%Ld\\n\"", "language": "OCaml", "metadata": {"date": 1536502192, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03373.html", "problem_id": "p03373", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03373/input.txt", "sample_output_relpath": "derived/input_output/data/p03373/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03373/OCaml/s851303057.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s851303057", "user_id": "u481480055"}, "prompt_components": {"gold_output": "7900\n", "input_to_evaluate": "open Printf open Scanf\nmodule MyInt = struct let (+) = (+) let (-) = (-) let (/) = (/) let ( * ) = ( * ) let (mod) = (mod) let (%) = (mod) let (+=) r v = r := !r + v let (-=) r v = r := !r - v let ( *=) r v= r := !r * v let (/=) r v = r := !r / v end\nmodule MyInt64 = struct\n\tlet (+$) = (+) let (-$) = (-) let (/$) = (/) let ( *$) = ( * ) let (+) p q = Int64.add p q let (-) p q = Int64.sub p q let ( * ) p q = Int64.mul p q let (/) p q = Int64.div p q let (+=) r v = r := !r + v let (-=) r v = r := !r - v let ( *=) r v= r := !r * v let (/=) r v = r := !r / v let labs p = if p < 0L then -1L*p else p let (~|) p = Int64.to_int p let (~~|) p = Int64.of_int p let input_i64_array n = Array.init (~| n) (fun _ -> Scanf.scanf \" %Ld\" (fun v -> v)) let get_i64 _ = Scanf.scanf \" %Ld\" (fun v -> v) let get_2_i64 _ = Scanf.scanf \" %Ld %Ld\" (fun u v -> u,v) let get_3_i64 _ = Scanf.scanf \" %Ld %Ld %Ld\" (fun u v w -> u,v,w) let get_4_i64 _ = Scanf.scanf \" %Ld %Ld %Ld %Ld\" (fun u v w x -> u,v,w,x) let get_5_i64 _ = Scanf.scanf \" %Ld %Ld %Ld %Ld %Ld\" (fun u v w x y -> u,v,w,x,y) let print_i64_endline n = n |> Int64.to_string |> print_endline let (mod) m n = m - (m/n) * n let (%) = (mod) let rec gcd m n = match m,n with | m,0L -> m | m,n -> gcd n (m mod n) let lcm m n = (m*n) / gcd m n let rep from_ to_ fbod = let i,f = ref ~|from_,ref true in while !i <= ~|to_ && !f do match fbod ~~| !i with | `Break -> f := false | _ -> i := !i +$ 1; done let repb from_ to_ fbod = let i,f = ref ~|from_,ref true in while !i <= ~|to_ && !f do match fbod (~~| !i) with | `Break -> f := false | _ -> i := !i +$ 1 done; !f let repm from_ to_ m_init fbod = let i,f,m = ref ~|from_,ref true,ref m_init in while !i <= ~|to_ && !f do match fbod !m (~~| !i) with | `Break -> f := false | `Break_m m' -> (f := false; m := m') | `Ok m' -> (i := !i +$ 1; m := m') done; !m let repmb from_ to_ m_init fbod = let i,f,m = ref ~|from_,ref true,ref m_init in while !i <= ~|to_ && !f do match fbod (~~| !i) !m with | `Break -> f := false | `Break_m m' -> (f := false; m := m') | `Ok m' -> (i := !i +$ 1; m := m') done; (!m,!f) let string_of_list ?(separator=\" \") f ls = let rec f0 a s = match a with | [] -> s | [h] -> s ^ (f h) ^ separator | h::t -> f0 t (s ^ (f h) ^ separator) in f0 ls \"\" let char_list_of_string str = let rec f0 i a = if i<0 then a else f0 (i-$1) (str.[i]::a) in f0 (String.length str -$ 1) [] let string_of_char_list ls = List.fold_left (fun u v -> u ^ (String.make 1 v)) \"\" ls\n\tlet (@@@) = (@) let (@) a i = a.(~|i) let (<@) a (i,v) = a.(~|i) <- v\n\tlet ceildiv m n = (m+n-1L) / n\nend open MyInt64\n\nlet () =\n\tlet a,b,c,x,y = get_5_i64 0 in\n\trepm 0L (max x y) Int64.max_int (fun u v ->\n\t\tlet xr,yr = max 0L (x-v),max 0L (y-v) in\n\t\t`Ok (min u (2L*c*v + a*xr + b * yr))\n\t) |> printf \"%Ld\\n\"", "problem_context": "Score : 300 points\n\nProblem Statement\n\n\"Pizza At\", a fast food chain, offers three kinds of pizza: \"A-pizza\", \"B-pizza\" and \"AB-pizza\". A-pizza and B-pizza are completely different pizzas, and AB-pizza is one half of A-pizza and one half of B-pizza combined together. The prices of one A-pizza, B-pizza and AB-pizza are A yen, B yen and C yen (yen is the currency of Japan), respectively.\n\nNakahashi needs to prepare X A-pizzas and Y B-pizzas for a party tonight. He can only obtain these pizzas by directly buying A-pizzas and B-pizzas, or buying two AB-pizzas and then rearrange them into one A-pizza and one B-pizza. At least how much money does he need for this? It is fine to have more pizzas than necessary by rearranging pizzas.\n\nConstraints\n\n1 ≤ A, B, C ≤ 5000\n\n1 ≤ X, Y ≤ 10^5\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C X Y\n\nOutput\n\nPrint the minimum amount of money required to prepare X A-pizzas and Y B-pizzas.\n\nSample Input 1\n\n1500 2000 1600 3 2\n\nSample Output 1\n\n7900\n\nIt is optimal to buy four AB-pizzas and rearrange them into two A-pizzas and two B-pizzas, then buy additional one A-pizza.\n\nSample Input 2\n\n1500 2000 1900 3 2\n\nSample Output 2\n\n8500\n\nIt is optimal to directly buy three A-pizzas and two B-pizzas.\n\nSample Input 3\n\n1500 2000 500 90000 100000\n\nSample Output 3\n\n100000000\n\nIt is optimal to buy 200000 AB-pizzas and rearrange them into 100000 A-pizzas and 100000 B-pizzas. We will have 10000 more A-pizzas than necessary, but that is fine.", "sample_input": "1500 2000 1600 3 2\n"}, "reference_outputs": ["7900\n"], "source_document_id": "p03373", "source_text": "Score : 300 points\n\nProblem Statement\n\n\"Pizza At\", a fast food chain, offers three kinds of pizza: \"A-pizza\", \"B-pizza\" and \"AB-pizza\". A-pizza and B-pizza are completely different pizzas, and AB-pizza is one half of A-pizza and one half of B-pizza combined together. The prices of one A-pizza, B-pizza and AB-pizza are A yen, B yen and C yen (yen is the currency of Japan), respectively.\n\nNakahashi needs to prepare X A-pizzas and Y B-pizzas for a party tonight. He can only obtain these pizzas by directly buying A-pizzas and B-pizzas, or buying two AB-pizzas and then rearrange them into one A-pizza and one B-pizza. At least how much money does he need for this? It is fine to have more pizzas than necessary by rearranging pizzas.\n\nConstraints\n\n1 ≤ A, B, C ≤ 5000\n\n1 ≤ X, Y ≤ 10^5\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C X Y\n\nOutput\n\nPrint the minimum amount of money required to prepare X A-pizzas and Y B-pizzas.\n\nSample Input 1\n\n1500 2000 1600 3 2\n\nSample Output 1\n\n7900\n\nIt is optimal to buy four AB-pizzas and rearrange them into two A-pizzas and two B-pizzas, then buy additional one A-pizza.\n\nSample Input 2\n\n1500 2000 1900 3 2\n\nSample Output 2\n\n8500\n\nIt is optimal to directly buy three A-pizzas and two B-pizzas.\n\nSample Input 3\n\n1500 2000 500 90000 100000\n\nSample Output 3\n\n100000000\n\nIt is optimal to buy 200000 AB-pizzas and rearrange them into 100000 A-pizzas and 100000 B-pizzas. We will have 10000 more A-pizzas than necessary, but that is fine.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2776, "cpu_time_ms": 11, "memory_kb": 2560}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s874130599", "group_id": "codeNet:p03377", "input_text": "let _ = Scanf.sscanf (read_line ()) \"%d %d %d\" (fun a b x ->\n if x < a || x > (a+b) then \"NO\" else \"YES\"\n) |> print_endline", "language": "OCaml", "metadata": {"date": 1584045880, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03377.html", "problem_id": "p03377", "resource_group": "low_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/OCaml/s874130599.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s874130599", "user_id": "u511870776"}, "prompt_components": {"gold_output": "YES\n", "input_to_evaluate": "let _ = Scanf.sscanf (read_line ()) \"%d %d %d\" (fun a b x ->\n if x < a || x > (a+b) then \"NO\" else \"YES\"\n) |> print_endline", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s718548093", "group_id": "codeNet:p03378", "input_text": "let n, m, x = Scanf.scanf \" %d %d %d\" @@ fun a b c -> a, b, c\nlet a_s = Array.init m @@ fun _ -> Scanf.scanf \" %d\" (+) 0\nlet _ = for i = 0 to m - 1 do if a_s.(i) > x then (Printf.printf \"%d\\n\" @@ min i @@ m - i; exit 0) done; print_endline \"0\"", "language": "OCaml", "metadata": {"date": 1574152934, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03378.html", "problem_id": "p03378", "resource_group": "low_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/OCaml/s718548093.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s718548093", "user_id": "u732304692"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "let n, m, x = Scanf.scanf \" %d %d %d\" @@ fun a b c -> a, b, c\nlet a_s = Array.init m @@ fun _ -> Scanf.scanf \" %d\" (+) 0\nlet _ = for i = 0 to m - 1 do if a_s.(i) > x then (Printf.printf \"%d\\n\" @@ min i @@ m - i; exit 0) done; print_endline \"0\"", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 243, "cpu_time_ms": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s958867200", "group_id": "codeNet:p03379", "input_text": "open Printf open Scanf\nmodule Lib = struct\n\tlet i32,i64,ist = Int64.(to_int,of_int,to_string)\n\tlet (+$) = (+) let (-$) = (-) let (/$) = (/) let ( *$) = ( * ) let (%$) = (mod)\n\tlet labs = Int64.abs\n\tlet (+),(-),( * ),(/),(mod),(%) = Int64.(add,sub,mul,div,rem,rem)\n\tlet (+=) r v = r := !r + v\n\tlet (-=) r v = r := !r - v\n\tlet ( *= ) r v = r := !r * v\n\tlet (/=) r v = r := !r / v\n\tlet (%=) r v = r := !r % v\n\t(* math *)\n\tlet ceildiv p q = (p+q-1L) / q\n\tlet rec gcd m n = match m,n with | m,0L -> m | m,n -> gcd n (m mod n)\n\tlet lcm m n = m / gcd m n * n \n\tmodule I64_infix = struct\n\t\tlet (land),(lor),(lxor),lnot,(lsl),(lsr),(asr) =\n\t\t\tlet open Int64 in\n\t\t\t(logand),(logor),(logxor),lognot,\n\t\t\t(fun u v -> shift_left u (i32 v)),\n\t\t\t(fun u v -> shift_right u (i32 v)),\n\t\t\t(fun u v -> shift_right_logical u (i32 v))\n\tend\n\t(* input *)\n\tlet input_i64_array n = Array.init (i32 n) (fun _ -> Scanf.scanf \" %Ld\" (fun v -> v))\n\tlet get_i64 _ = Scanf.scanf \" %Ld\" (fun v -> v)\n\tlet get_2_i64 _ = Scanf.scanf \" %Ld %Ld\" (fun u v -> u,v)\n\tlet get_3_i64 _ = Scanf.scanf \" %Ld %Ld %Ld\" (fun u v w -> u,v,w)\n\tlet get_4_i64 _ = Scanf.scanf \" %Ld %Ld %Ld %Ld\" (fun u v w x -> u,v,w,x)\n\tlet get_5_i64 _ = Scanf.scanf \" %Ld %Ld %Ld %Ld %Ld\" (fun u v w x y -> u,v,w,x,y)\n\tlet i32_get_int _ = Scanf.scanf \" %d\" (fun v -> v) let i32_get_2_ints _ = Scanf.scanf \" %d %d\" (fun u v -> u,v) let i32_get_3_ints _ = Scanf.scanf \" %d %d %d\" (fun u v w -> u,v,w) let i32_get_4_ints _ = Scanf.scanf \" %d %d %d %d\" (fun u v w x -> u,v,w,x) let i32_get_5_ints _ = Scanf.scanf \" %d %d %d %d %d\" (fun u v w x y -> u,v,w,x,y)\n\t(* utils *)\n\texternal id : 'a -> 'a = \"%identity\"\n\tlet alen a = i64 @@ Array.length a\n\tlet llen l = i64 @@ List.length l\n\tlet string_of_list ?(separator=\" \") f ls = ls |> List.map f |> String.concat separator\n\tlet string_of_array ?(separator=\" \") f a = a |> Array.to_list |> string_of_list ~separator f\n\tlet char_list_of_string str = let rec f0 i a = if i<0 then a else f0 (i-$1) (str.[i]::a) in f0 (String.length str -$ 1) []\n\tlet string_of_char_list ls = List.fold_left (fun u v -> u ^ (String.make 1 v)) \"\" ls\n\tlet fail _ = failwith \"fail\"\n\tlet dx,dy = [|1;0;-1;0|],[|0;1;0;-1|]\n\tlet range l r = let ls = ref [] in for i=i32 l to i32 r do ls := i :: !ls done;!ls |> List.rev\n\tlet cartesian_product u v = u |> List.map (fun p -> List.map (fun q -> p,q) v) |> List.flatten\n\tlet shuffle a = Array.sort (fun _ _ -> (Random.int 3) -$ 1) a\n\tlet binary_search ng ok f = let d = if ng < ok then 1L else -1L in\n\t\tlet rec f0 ng ok =\n\t\t\tif labs (ok - ng) <= 1L then ok\n\t\t\telse let mid = ng + (ok - ng) / 2L in if f mid then f0 ng mid else f0 mid ok\n\t\tin f0 (ng-1L*d) (ok+1L*d)\n\t(* imperative *)\n\tlet rep f t fbod = let i = ref f in while !i <= t do fbod !i; i := !i + 1L done\n\tlet repb f t fbod = let i,c = ref f,ref true in while !i <= t && !c do\n\t\tmatch fbod !i with | `Break -> c := false | `Ok -> i := !i + 1L done\n\tlet repm f t m0 fbod =\n\t\tlet i,c,m = ref f,ref true,ref m0 in\n\t\twhile !i<=t && !c do match fbod !m !i with\n\t\t| `Break -> c := false | `Break_m m' -> (c := false; m := m') | `Ok m' -> m := m'; i := !i + 1L done; !m\n\tlet repi f t fbod = let i = ref f in while !i <= t do fbod !i; i := !i +$ 1 done\n\tlet repib f t fbod = let i,c = ref f,ref true in while !i <= t && !c do\n\t\tmatch fbod !i with | `Break -> c := false | `Ok -> i := !i +$ 1 done\n\tlet repim f t m0 fbod =\n\t\tlet i,c,m = ref f,ref true,ref m0 in\n\t\twhile !i<=t && !c do match fbod !m !i with\n\t\t| `Break -> c := false | `Break_m m' -> (c := false; m := m') | `Ok m' -> m := m'; i := !i +$ 1 done; !m\n\tlet rep_rev f t fbod = rep t f @@ fun v -> fbod @@ f + t - v\n\tlet repb_rev f t fbod = repb t f @@ fun v -> fbod @@ f + t - v\n\tlet repm_rev f t m0 fbod = repm f t m0 @@ fun u v -> fbod u @@ f + t - v\n\tlet repi_rev f t fbod = repi t f @@ fun v -> fbod @@ f +$ t -$ v\n\tlet repib_rev f t fbod = repib t f @@ fun v -> fbod @@ f +$ t -$ v\n\tlet repim_rev f t m0 fbod = repim f t m0 @@ fun u v -> fbod u @@ f +$ t -$ v\n\t(* output *)\n\tlet print_list_mle f ls = string_of_list f ls |> print_endline\n\tlet print_array_mle f a = string_of_array f a |> print_endline\n\tlet print_list f ls = ls |> List.iter (fun v -> printf \"%s \" @@ f v); print_newline ()\n\tlet print_array f a = a |> Array.iter (fun v -> printf \"%s \" @@ f v); print_newline ()\n\t(* debug *)\n\tlet dump_2darr f a = a |> Array.iter (fun b -> print_array f b)\n\tlet dump_i64_list ls = print_list ist ls\n\tlet dump_i64_array a = print_array ist a\nend open Lib\n\nlet () =\n\tlet n = get_i64 0 in let a = input_i64_array n in\n\tlet a = Array.mapi (fun i v -> (v,i)) a in\n\tArray.sort compare a;\n\tlet (p,_),(q,_) = a.(i32@@n/2L-1L),a.(i32@@n/2L) in\n\tlet res = Array.make (i32 n) 0L in\n\tArray.iter (fun (v,i) ->\n\t\tif v<=p then res.(i) <- q else res.(i) <- p\n\t) a;\n\tArray.iter (fun v -> print_endline @@ ist v) res\n\n\n\n\n\n\n", "language": "OCaml", "metadata": {"date": 1541158711, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03379.html", "problem_id": "p03379", "resource_group": "low_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/OCaml/s958867200.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s958867200", "user_id": "u481480055"}, "prompt_components": {"gold_output": "4\n3\n3\n4\n", "input_to_evaluate": "open Printf open Scanf\nmodule Lib = struct\n\tlet i32,i64,ist = Int64.(to_int,of_int,to_string)\n\tlet (+$) = (+) let (-$) = (-) let (/$) = (/) let ( *$) = ( * ) let (%$) = (mod)\n\tlet labs = Int64.abs\n\tlet (+),(-),( * ),(/),(mod),(%) = Int64.(add,sub,mul,div,rem,rem)\n\tlet (+=) r v = r := !r + v\n\tlet (-=) r v = r := !r - v\n\tlet ( *= ) r v = r := !r * v\n\tlet (/=) r v = r := !r / v\n\tlet (%=) r v = r := !r % v\n\t(* math *)\n\tlet ceildiv p q = (p+q-1L) / q\n\tlet rec gcd m n = match m,n with | m,0L -> m | m,n -> gcd n (m mod n)\n\tlet lcm m n = m / gcd m n * n \n\tmodule I64_infix = struct\n\t\tlet (land),(lor),(lxor),lnot,(lsl),(lsr),(asr) =\n\t\t\tlet open Int64 in\n\t\t\t(logand),(logor),(logxor),lognot,\n\t\t\t(fun u v -> shift_left u (i32 v)),\n\t\t\t(fun u v -> shift_right u (i32 v)),\n\t\t\t(fun u v -> shift_right_logical u (i32 v))\n\tend\n\t(* input *)\n\tlet input_i64_array n = Array.init (i32 n) (fun _ -> Scanf.scanf \" %Ld\" (fun v -> v))\n\tlet get_i64 _ = Scanf.scanf \" %Ld\" (fun v -> v)\n\tlet get_2_i64 _ = Scanf.scanf \" %Ld %Ld\" (fun u v -> u,v)\n\tlet get_3_i64 _ = Scanf.scanf \" %Ld %Ld %Ld\" (fun u v w -> u,v,w)\n\tlet get_4_i64 _ = Scanf.scanf \" %Ld %Ld %Ld %Ld\" (fun u v w x -> u,v,w,x)\n\tlet get_5_i64 _ = Scanf.scanf \" %Ld %Ld %Ld %Ld %Ld\" (fun u v w x y -> u,v,w,x,y)\n\tlet i32_get_int _ = Scanf.scanf \" %d\" (fun v -> v) let i32_get_2_ints _ = Scanf.scanf \" %d %d\" (fun u v -> u,v) let i32_get_3_ints _ = Scanf.scanf \" %d %d %d\" (fun u v w -> u,v,w) let i32_get_4_ints _ = Scanf.scanf \" %d %d %d %d\" (fun u v w x -> u,v,w,x) let i32_get_5_ints _ = Scanf.scanf \" %d %d %d %d %d\" (fun u v w x y -> u,v,w,x,y)\n\t(* utils *)\n\texternal id : 'a -> 'a = \"%identity\"\n\tlet alen a = i64 @@ Array.length a\n\tlet llen l = i64 @@ List.length l\n\tlet string_of_list ?(separator=\" \") f ls = ls |> List.map f |> String.concat separator\n\tlet string_of_array ?(separator=\" \") f a = a |> Array.to_list |> string_of_list ~separator f\n\tlet char_list_of_string str = let rec f0 i a = if i<0 then a else f0 (i-$1) (str.[i]::a) in f0 (String.length str -$ 1) []\n\tlet string_of_char_list ls = List.fold_left (fun u v -> u ^ (String.make 1 v)) \"\" ls\n\tlet fail _ = failwith \"fail\"\n\tlet dx,dy = [|1;0;-1;0|],[|0;1;0;-1|]\n\tlet range l r = let ls = ref [] in for i=i32 l to i32 r do ls := i :: !ls done;!ls |> List.rev\n\tlet cartesian_product u v = u |> List.map (fun p -> List.map (fun q -> p,q) v) |> List.flatten\n\tlet shuffle a = Array.sort (fun _ _ -> (Random.int 3) -$ 1) a\n\tlet binary_search ng ok f = let d = if ng < ok then 1L else -1L in\n\t\tlet rec f0 ng ok =\n\t\t\tif labs (ok - ng) <= 1L then ok\n\t\t\telse let mid = ng + (ok - ng) / 2L in if f mid then f0 ng mid else f0 mid ok\n\t\tin f0 (ng-1L*d) (ok+1L*d)\n\t(* imperative *)\n\tlet rep f t fbod = let i = ref f in while !i <= t do fbod !i; i := !i + 1L done\n\tlet repb f t fbod = let i,c = ref f,ref true in while !i <= t && !c do\n\t\tmatch fbod !i with | `Break -> c := false | `Ok -> i := !i + 1L done\n\tlet repm f t m0 fbod =\n\t\tlet i,c,m = ref f,ref true,ref m0 in\n\t\twhile !i<=t && !c do match fbod !m !i with\n\t\t| `Break -> c := false | `Break_m m' -> (c := false; m := m') | `Ok m' -> m := m'; i := !i + 1L done; !m\n\tlet repi f t fbod = let i = ref f in while !i <= t do fbod !i; i := !i +$ 1 done\n\tlet repib f t fbod = let i,c = ref f,ref true in while !i <= t && !c do\n\t\tmatch fbod !i with | `Break -> c := false | `Ok -> i := !i +$ 1 done\n\tlet repim f t m0 fbod =\n\t\tlet i,c,m = ref f,ref true,ref m0 in\n\t\twhile !i<=t && !c do match fbod !m !i with\n\t\t| `Break -> c := false | `Break_m m' -> (c := false; m := m') | `Ok m' -> m := m'; i := !i +$ 1 done; !m\n\tlet rep_rev f t fbod = rep t f @@ fun v -> fbod @@ f + t - v\n\tlet repb_rev f t fbod = repb t f @@ fun v -> fbod @@ f + t - v\n\tlet repm_rev f t m0 fbod = repm f t m0 @@ fun u v -> fbod u @@ f + t - v\n\tlet repi_rev f t fbod = repi t f @@ fun v -> fbod @@ f +$ t -$ v\n\tlet repib_rev f t fbod = repib t f @@ fun v -> fbod @@ f +$ t -$ v\n\tlet repim_rev f t m0 fbod = repim f t m0 @@ fun u v -> fbod u @@ f +$ t -$ v\n\t(* output *)\n\tlet print_list_mle f ls = string_of_list f ls |> print_endline\n\tlet print_array_mle f a = string_of_array f a |> print_endline\n\tlet print_list f ls = ls |> List.iter (fun v -> printf \"%s \" @@ f v); print_newline ()\n\tlet print_array f a = a |> Array.iter (fun v -> printf \"%s \" @@ f v); print_newline ()\n\t(* debug *)\n\tlet dump_2darr f a = a |> Array.iter (fun b -> print_array f b)\n\tlet dump_i64_list ls = print_list ist ls\n\tlet dump_i64_array a = print_array ist a\nend open Lib\n\nlet () =\n\tlet n = get_i64 0 in let a = input_i64_array n in\n\tlet a = Array.mapi (fun i v -> (v,i)) a in\n\tArray.sort compare a;\n\tlet (p,_),(q,_) = a.(i32@@n/2L-1L),a.(i32@@n/2L) in\n\tlet res = Array.make (i32 n) 0L in\n\tArray.iter (fun (v,i) ->\n\t\tif v<=p then res.(i) <- q else res.(i) <- p\n\t) a;\n\tArray.iter (fun v -> print_endline @@ ist v) res\n\n\n\n\n\n\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nWhen l is an odd number, the median of l numbers a_1, a_2, ..., a_l is the (\\frac{l+1}{2})-th largest value among a_1, a_2, ..., a_l.\n\nYou are given N numbers X_1, X_2, ..., X_N, where N is an even number.\nFor each i = 1, 2, ..., N, let the median of X_1, X_2, ..., X_N excluding X_i, that is, the median of X_1, X_2, ..., X_{i-1}, X_{i+1}, ..., X_N be B_i.\n\nFind B_i for each i = 1, 2, ..., N.\n\nConstraints\n\n2 \\leq N \\leq 200000\n\nN is even.\n\n1 \\leq X_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nX_1 X_2 ... X_N\n\nOutput\n\nPrint N lines.\nThe i-th line should contain B_i.\n\nSample Input 1\n\n4\n2 4 4 3\n\nSample Output 1\n\n4\n3\n3\n4\n\nSince the median of X_2, X_3, X_4 is 4, B_1 = 4.\n\nSince the median of X_1, X_3, X_4 is 3, B_2 = 3.\n\nSince the median of X_1, X_2, X_4 is 3, B_3 = 3.\n\nSince the median of X_1, X_2, X_3 is 4, B_4 = 4.\n\nSample Input 2\n\n2\n1 2\n\nSample Output 2\n\n2\n1\n\nSample Input 3\n\n6\n5 5 4 4 3 3\n\nSample Output 3\n\n4\n4\n4\n4\n4\n4", "sample_input": "4\n2 4 4 3\n"}, "reference_outputs": ["4\n3\n3\n4\n"], "source_document_id": "p03379", "source_text": "Score : 300 points\n\nProblem Statement\n\nWhen l is an odd number, the median of l numbers a_1, a_2, ..., a_l is the (\\frac{l+1}{2})-th largest value among a_1, a_2, ..., a_l.\n\nYou are given N numbers X_1, X_2, ..., X_N, where N is an even number.\nFor each i = 1, 2, ..., N, let the median of X_1, X_2, ..., X_N excluding X_i, that is, the median of X_1, X_2, ..., X_{i-1}, X_{i+1}, ..., X_N be B_i.\n\nFind B_i for each i = 1, 2, ..., N.\n\nConstraints\n\n2 \\leq N \\leq 200000\n\nN is even.\n\n1 \\leq X_i \\leq 10^9\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nX_1 X_2 ... X_N\n\nOutput\n\nPrint N lines.\nThe i-th line should contain B_i.\n\nSample Input 1\n\n4\n2 4 4 3\n\nSample Output 1\n\n4\n3\n3\n4\n\nSince the median of X_2, X_3, X_4 is 4, B_1 = 4.\n\nSince the median of X_1, X_3, X_4 is 3, B_2 = 3.\n\nSince the median of X_1, X_2, X_4 is 3, B_3 = 3.\n\nSince the median of X_1, X_2, X_3 is 4, B_4 = 4.\n\nSample Input 2\n\n2\n1 2\n\nSample Output 2\n\n2\n1\n\nSample Input 3\n\n6\n5 5 4 4 3 3\n\nSample Output 3\n\n4\n4\n4\n4\n4\n4", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 4814, "cpu_time_ms": 762, "memory_kb": 20480}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s284661300", "group_id": "codeNet:p03382", "input_text": "let min_with f x y = if f x <= f y then x else y\n\nlet () =\n let n = Scanf.scanf \"%d\\n\" (fun n -> n) in\n let as_ = Array.init n (fun _ -> Scanf.scanf \"%d \" (fun a -> a)) in\n let ai = Array.fold_left max min_int as_ in\n let aj = Array.fold_left (min_with (fun a ->\n if ai mod 2 = 0 then abs (a - ai / 2)\n else if a <= ai / 2 then ai / 2 - a\n else a - (ai + 1) / 2)) ai as_ in\n Printf.printf \"%d %d\\n\" ai aj", "language": "OCaml", "metadata": {"date": 1523756435, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03382.html", "problem_id": "p03382", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03382/input.txt", "sample_output_relpath": "derived/input_output/data/p03382/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03382/OCaml/s284661300.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s284661300", "user_id": "u504158101"}, "prompt_components": {"gold_output": "11 6\n", "input_to_evaluate": "let min_with f x y = if f x <= f y then x else y\n\nlet () =\n let n = Scanf.scanf \"%d\\n\" (fun n -> n) in\n let as_ = Array.init n (fun _ -> Scanf.scanf \"%d \" (fun a -> a)) in\n let ai = Array.fold_left max min_int as_ in\n let aj = Array.fold_left (min_with (fun a ->\n if ai mod 2 = 0 then abs (a - ai / 2)\n else if a <= ai / 2 then ai / 2 - a\n else a - (ai + 1) / 2)) ai as_ in\n Printf.printf \"%d %d\\n\" ai aj", "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": "p03382", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 418, "cpu_time_ms": 35, "memory_kb": 5248}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s779457930", "group_id": "codeNet:p03385", "input_text": "let () = Scanf.scanf \"%c%c%c\" (fun a b c -> if a<>b && b<>c && c<>a then \"Yes\" else \"No\")\n |> print_endline\n", "language": "OCaml", "metadata": {"date": 1529312476, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03385.html", "problem_id": "p03385", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03385/input.txt", "sample_output_relpath": "derived/input_output/data/p03385/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03385/OCaml/s779457930.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s779457930", "user_id": "u798181098"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "let () = Scanf.scanf \"%c%c%c\" (fun a b c -> if a<>b && b<>c && c<>a then \"Yes\" else \"No\")\n |> print_endline\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou are given a string S of length 3 consisting of a, b and c. Determine if S can be obtained by permuting abc.\n\nConstraints\n\n|S|=3\n\nS consists of a, b and c.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nIf S can be obtained by permuting abc, print Yes; otherwise, print No.\n\nSample Input 1\n\nbac\n\nSample Output 1\n\nYes\n\nSwapping the first and second characters in bac results in abc.\n\nSample Input 2\n\nbab\n\nSample Output 2\n\nNo\n\nSample Input 3\n\nabc\n\nSample Output 3\n\nYes\n\nSample Input 4\n\naaa\n\nSample Output 4\n\nNo", "sample_input": "bac\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03385", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou are given a string S of length 3 consisting of a, b and c. Determine if S can be obtained by permuting abc.\n\nConstraints\n\n|S|=3\n\nS consists of a, b and c.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nIf S can be obtained by permuting abc, print Yes; otherwise, print No.\n\nSample Input 1\n\nbac\n\nSample Output 1\n\nYes\n\nSwapping the first and second characters in bac results in abc.\n\nSample Input 2\n\nbab\n\nSample Output 2\n\nNo\n\nSample Input 3\n\nabc\n\nSample Output 3\n\nYes\n\nSample Input 4\n\naaa\n\nSample Output 4\n\nNo", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s180487103", "group_id": "codeNet:p03386", "input_text": "let a, b, k = Scanf.scanf \" %d %d %d\" @@ fun a b c -> a, b, c\nlet m = b - a + 1\nlet f = Printf.printf \"%d\\n\"\nlet _ = if 2 * k >= m then for i = a to b do f i done else (for i = a to a - 1 + k do f i done; for i = b + 1 - k to b do f i done)", "language": "OCaml", "metadata": {"date": 1564572311, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03386.html", "problem_id": "p03386", "resource_group": "low_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/OCaml/s180487103.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s180487103", "user_id": "u732304692"}, "prompt_components": {"gold_output": "3\n4\n7\n8\n", "input_to_evaluate": "let a, b, k = Scanf.scanf \" %d %d %d\" @@ fun a b c -> a, b, c\nlet m = b - a + 1\nlet f = Printf.printf \"%d\\n\"\nlet _ = if 2 * k >= m then for i = a to b do f i done else (for i = a to a - 1 + k do f i done; for i = b + 1 - k to b do f i done)", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 240, "cpu_time_ms": 1, "memory_kb": 2432}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s693113814", "group_id": "codeNet:p03387", "input_text": "let () =\n let a,b,c = Scanf.scanf \"%d %d %d \" (fun a b c -> a,b,c) in\n let l = [a;b;c] in\n let ls = List.sort compare l in\n let d2 = (List.nth ls 2) - (List.nth ls 0) in\n let d1 = (List.nth ls 2) - (List.nth ls 1) in\n\n Printf.printf \"%d\\n\" @@\n if (d2+d1) mod 2 = 0 then (d2+d1)/2 else 2+((d2+d1)/2)\n\n\n\n\n\n", "language": "OCaml", "metadata": {"date": 1528869401, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03387.html", "problem_id": "p03387", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03387/input.txt", "sample_output_relpath": "derived/input_output/data/p03387/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03387/OCaml/s693113814.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s693113814", "user_id": "u139013163"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "let () =\n let a,b,c = Scanf.scanf \"%d %d %d \" (fun a b c -> a,b,c) in\n let l = [a;b;c] in\n let ls = List.sort compare l in\n let d2 = (List.nth ls 2) - (List.nth ls 0) in\n let d1 = (List.nth ls 2) - (List.nth ls 1) in\n\n Printf.printf \"%d\\n\" @@\n if (d2+d1) mod 2 = 0 then (d2+d1)/2 else 2+((d2+d1)/2)\n\n\n\n\n\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou are given three integers A, B and C. Find the minimum number of operations required to make A, B and C all equal by repeatedly performing the following two kinds of operations in any order:\n\nChoose two among A, B and C, then increase both by 1.\n\nChoose one among A, B and C, then increase it by 2.\n\nIt can be proved that we can always make A, B and C all equal by repeatedly performing these operations.\n\nConstraints\n\n0 \\leq A,B,C \\leq 50\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C\n\nOutput\n\nPrint the minimum number of operations required to make A, B and C all equal.\n\nSample Input 1\n\n2 5 4\n\nSample Output 1\n\n2\n\nWe can make A, B and C all equal by the following operations:\n\nIncrease A and C by 1. Now, A, B, C are 3, 5, 5, respectively.\n\nIncrease A by 2. Now, A, B, C are 5, 5, 5, respectively.\n\nSample Input 2\n\n2 6 3\n\nSample Output 2\n\n5\n\nSample Input 3\n\n31 41 5\n\nSample Output 3\n\n23", "sample_input": "2 5 4\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03387", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou are given three integers A, B and C. Find the minimum number of operations required to make A, B and C all equal by repeatedly performing the following two kinds of operations in any order:\n\nChoose two among A, B and C, then increase both by 1.\n\nChoose one among A, B and C, then increase it by 2.\n\nIt can be proved that we can always make A, B and C all equal by repeatedly performing these operations.\n\nConstraints\n\n0 \\leq A,B,C \\leq 50\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C\n\nOutput\n\nPrint the minimum number of operations required to make A, B and C all equal.\n\nSample Input 1\n\n2 5 4\n\nSample Output 1\n\n2\n\nWe can make A, B and C all equal by the following operations:\n\nIncrease A and C by 1. Now, A, B, C are 3, 5, 5, respectively.\n\nIncrease A by 2. Now, A, B, C are 5, 5, 5, respectively.\n\nSample Input 2\n\n2 6 3\n\nSample Output 2\n\n5\n\nSample Input 3\n\n31 41 5\n\nSample Output 3\n\n23", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 2432}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s491809199", "group_id": "codeNet:p03388", "input_text": "let sqrt_int x = float_of_int x |> sqrt |> int_of_float\n\nlet solve a b =\n let c = sqrt_int (a * b - 1) in\n let f a b =\n if b-a <= 1 then 2*a - 2\n else if c * (c+1) >= a*b then 2*c - 2\n else 2*c - 1\n in f (min a b) (max a b)\n\nlet () =\n Scanf.scanf \"%d\" @@ fun q ->\n Array.init q (fun _ -> Scanf.scanf \" %d %d\" solve)\n |> Array.iter (Printf.printf \"%d\\n\")\n", "language": "OCaml", "metadata": {"date": 1532603362, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03388.html", "problem_id": "p03388", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03388/input.txt", "sample_output_relpath": "derived/input_output/data/p03388/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03388/OCaml/s491809199.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s491809199", "user_id": "u798181098"}, "prompt_components": {"gold_output": "1\n12\n4\n11\n14\n57\n31\n671644785\n", "input_to_evaluate": "let sqrt_int x = float_of_int x |> sqrt |> int_of_float\n\nlet solve a b =\n let c = sqrt_int (a * b - 1) in\n let f a b =\n if b-a <= 1 then 2*a - 2\n else if c * (c+1) >= a*b then 2*c - 2\n else 2*c - 1\n in f (min a b) (max a b)\n\nlet () =\n Scanf.scanf \"%d\" @@ fun q ->\n Array.init q (fun _ -> Scanf.scanf \" %d %d\" solve)\n |> Array.iter (Printf.printf \"%d\\n\")\n", "problem_context": "Score : 700 points\n\nProblem Statement\n\n10^{10^{10}} participants, including Takahashi, competed in two programming contests.\nIn each contest, all participants had distinct ranks from first through 10^{10^{10}}-th.\n\nThe score of a participant is the product of his/her ranks in the two contests.\n\nProcess the following Q queries:\n\nIn the i-th query, you are given two positive integers A_i and B_i. Assuming that Takahashi was ranked A_i-th in the first contest and B_i-th in the second contest, find the maximum possible number of participants whose scores are smaller than Takahashi's.\n\nConstraints\n\n1 \\leq Q \\leq 100\n\n1\\leq A_i,B_i\\leq 10^9(1\\leq i\\leq Q)\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nQ\nA_1 B_1\n:\nA_Q B_Q\n\nOutput\n\nFor each query, print the maximum possible number of participants whose scores are smaller than Takahashi's.\n\nSample Input 1\n\n8\n1 4\n10 5\n3 3\n4 11\n8 9\n22 40\n8 36\n314159265 358979323\n\nSample Output 1\n\n1\n12\n4\n11\n14\n57\n31\n671644785\n\nLet us denote a participant who was ranked x-th in the first contest and y-th in the second contest as (x,y).\n\nIn the first query, (2,1) is a possible candidate of a participant whose score is smaller than Takahashi's. There are never two or more participants whose scores are smaller than Takahashi's, so we should print 1.", "sample_input": "8\n1 4\n10 5\n3 3\n4 11\n8 9\n22 40\n8 36\n314159265 358979323\n"}, "reference_outputs": ["1\n12\n4\n11\n14\n57\n31\n671644785\n"], "source_document_id": "p03388", "source_text": "Score : 700 points\n\nProblem Statement\n\n10^{10^{10}} participants, including Takahashi, competed in two programming contests.\nIn each contest, all participants had distinct ranks from first through 10^{10^{10}}-th.\n\nThe score of a participant is the product of his/her ranks in the two contests.\n\nProcess the following Q queries:\n\nIn the i-th query, you are given two positive integers A_i and B_i. Assuming that Takahashi was ranked A_i-th in the first contest and B_i-th in the second contest, find the maximum possible number of participants whose scores are smaller than Takahashi's.\n\nConstraints\n\n1 \\leq Q \\leq 100\n\n1\\leq A_i,B_i\\leq 10^9(1\\leq i\\leq Q)\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nQ\nA_1 B_1\n:\nA_Q B_Q\n\nOutput\n\nFor each query, print the maximum possible number of participants whose scores are smaller than Takahashi's.\n\nSample Input 1\n\n8\n1 4\n10 5\n3 3\n4 11\n8 9\n22 40\n8 36\n314159265 358979323\n\nSample Output 1\n\n1\n12\n4\n11\n14\n57\n31\n671644785\n\nLet us denote a participant who was ranked x-th in the first contest and y-th in the second contest as (x,y).\n\nIn the first query, (2,1) is a possible candidate of a participant whose score is smaller than Takahashi's. There are never two or more participants whose scores are smaller than Takahashi's, so we should print 1.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 369, "cpu_time_ms": 1, "memory_kb": 2432}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s108999214", "group_id": "codeNet:p03391", "input_text": "Scanf.scanf \"%d\" (fun n ->\n let ab = Array.init n (fun _ -> Scanf.scanf \" %d %d\" (fun a b -> a, b)) in\n\n let rec loop i sum minb =\n if i = n then (if minb = max_int then 0 else sum - minb) else\n let a, b = ab.(i) in\n loop (i + 1) (sum + a) (if a > b then min b minb else minb)\n in\n loop 0 0 max_int |> Printf.printf \"%d\\n\"\n)", "language": "OCaml", "metadata": {"date": 1587871912, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03391.html", "problem_id": "p03391", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03391/input.txt", "sample_output_relpath": "derived/input_output/data/p03391/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03391/OCaml/s108999214.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s108999214", "user_id": "u342443598"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "Scanf.scanf \"%d\" (fun n ->\n let ab = Array.init n (fun _ -> Scanf.scanf \" %d %d\" (fun a b -> a, b)) in\n\n let rec loop i sum minb =\n if i = n then (if minb = max_int then 0 else sum - minb) else\n let a, b = ab.(i) in\n loop (i + 1) (sum + a) (if a > b then min b minb else minb)\n in\n loop 0 0 max_int |> Printf.printf \"%d\\n\"\n)", "problem_context": "Score : 700 points\n\nProblem Statement\n\nYou are given sequences A and B consisting of non-negative integers.\nThe lengths of both A and B are N, and the sums of the elements in A and B are equal.\nThe i-th element in A is A_i, and the i-th element in B is B_i.\n\nTozan and Gezan repeats the following sequence of operations:\n\nIf A and B are equal sequences, terminate the process.\n\nOtherwise, first Tozan chooses a positive element in A and decrease it by 1.\n\nThen, Gezan chooses a positive element in B and decrease it by 1.\n\nThen, give one candy to Takahashi, their pet.\n\nTozan wants the number of candies given to Takahashi until the process is terminated to be as large as possible, while Gezan wants it to be as small as possible.\nFind the number of candies given to Takahashi when both of them perform the operations optimally.\n\nConstraints\n\n1 \\leq N \\leq 2 × 10^5\n\n0 \\leq A_i,B_i \\leq 10^9(1\\leq i\\leq N)\n\nThe sums of the elements in A and B are equal.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 B_1\n:\nA_N B_N\n\nOutput\n\nPrint the number of candies given to Takahashi when both Tozan and Gezan perform the operations optimally.\n\nSample Input 1\n\n2\n1 2\n3 2\n\nSample Output 1\n\n2\n\nWhen both Tozan and Gezan perform the operations optimally, the process will proceed as follows:\n\nTozan decreases A_1 by 1.\n\nGezan decreases B_1 by 1.\n\nOne candy is given to Takahashi.\n\nTozan decreases A_2 by 1.\n\nGezan decreases B_1 by 1.\n\nOne candy is given to Takahashi.\n\nAs A and B are equal, the process is terminated.\n\nSample Input 2\n\n3\n8 3\n0 1\n4 8\n\nSample Output 2\n\n9\n\nSample Input 3\n\n1\n1 1\n\nSample Output 3\n\n0", "sample_input": "2\n1 2\n3 2\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03391", "source_text": "Score : 700 points\n\nProblem Statement\n\nYou are given sequences A and B consisting of non-negative integers.\nThe lengths of both A and B are N, and the sums of the elements in A and B are equal.\nThe i-th element in A is A_i, and the i-th element in B is B_i.\n\nTozan and Gezan repeats the following sequence of operations:\n\nIf A and B are equal sequences, terminate the process.\n\nOtherwise, first Tozan chooses a positive element in A and decrease it by 1.\n\nThen, Gezan chooses a positive element in B and decrease it by 1.\n\nThen, give one candy to Takahashi, their pet.\n\nTozan wants the number of candies given to Takahashi until the process is terminated to be as large as possible, while Gezan wants it to be as small as possible.\nFind the number of candies given to Takahashi when both of them perform the operations optimally.\n\nConstraints\n\n1 \\leq N \\leq 2 × 10^5\n\n0 \\leq A_i,B_i \\leq 10^9(1\\leq i\\leq N)\n\nThe sums of the elements in A and B are equal.\n\nAll values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 B_1\n:\nA_N B_N\n\nOutput\n\nPrint the number of candies given to Takahashi when both Tozan and Gezan perform the operations optimally.\n\nSample Input 1\n\n2\n1 2\n3 2\n\nSample Output 1\n\n2\n\nWhen both Tozan and Gezan perform the operations optimally, the process will proceed as follows:\n\nTozan decreases A_1 by 1.\n\nGezan decreases B_1 by 1.\n\nOne candy is given to Takahashi.\n\nTozan decreases A_2 by 1.\n\nGezan decreases B_1 by 1.\n\nOne candy is given to Takahashi.\n\nAs A and B are equal, the process is terminated.\n\nSample Input 2\n\n3\n8 3\n0 1\n4 8\n\nSample Output 2\n\n9\n\nSample Input 3\n\n1\n1 1\n\nSample Output 3\n\n0", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 16, "memory_kb": 5504}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s191589947", "group_id": "codeNet:p03393", "input_text": "let s = read_line ()\nlet n, fs, i = Array.(String.length s, make 26 false, ref 0)\nlet f s n = Printf.printf \"%s%c\\n\" s (Char.chr (n + 97)); exit 0\nlet _ = String.(Char.(iter (fun c -> fs.(code c - 97) <- true; incr i) s; if n < 26 then (i := 0; while fs.(!i) do incr i done; f s !i);\n for j = n - 1 downto 0 do i := code s.[j] - 96; while !i < 26 && fs.(!i) do incr i done; if !i < 26 then f (sub s 0 j) !i; fs.(code s.[j] - 97) <- false done; print_endline \"-1\"))", "language": "OCaml", "metadata": {"date": 1577321547, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03393.html", "problem_id": "p03393", "resource_group": "low_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/OCaml/s191589947.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s191589947", "user_id": "u732304692"}, "prompt_components": {"gold_output": "atcoderb\n", "input_to_evaluate": "let s = read_line ()\nlet n, fs, i = Array.(String.length s, make 26 false, ref 0)\nlet f s n = Printf.printf \"%s%c\\n\" s (Char.chr (n + 97)); exit 0\nlet _ = String.(Char.(iter (fun c -> fs.(code c - 97) <- true; incr i) s; if n < 26 then (i := 0; while fs.(!i) do incr i done; f s !i);\n for j = n - 1 downto 0 do i := code s.[j] - 96; while !i < 26 && fs.(!i) do incr i done; if !i < 26 then f (sub s 0 j) !i; fs.(code s.[j] - 97) <- false done; print_endline \"-1\"))", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s651610608", "group_id": "codeNet:p03393", "input_text": "let s = read_line ()\nlet n = String.length s\nlet fs, is, i = Array.(make 26 false, make 26 0, ref 0)\nlet _ = String.(Char.(iter (fun c -> let n = code c - 97 in fs.(n) <- true; is.(!i) <- n; incr i) s;\n if n < 26 then (i := 0; while fs.(!i) do incr i done; Printf.printf \"%s%c\\n\" s (chr (!i + 97)))\n else (for j = n - 1 downto 0 do i := code s.[j] - 96; while !i < 26 && fs.(!i) do incr i done; if !i < 26 then (Printf.printf \"%s%c\\n\" (sub s 0 j) (chr (!i + 97)); exit 0) else (fs.(is.(j)) <- false) done; print_endline \"-1\")))", "language": "OCaml", "metadata": {"date": 1577319608, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03393.html", "problem_id": "p03393", "resource_group": "low_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/OCaml/s651610608.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s651610608", "user_id": "u732304692"}, "prompt_components": {"gold_output": "atcoderb\n", "input_to_evaluate": "let s = read_line ()\nlet n = String.length s\nlet fs, is, i = Array.(make 26 false, make 26 0, ref 0)\nlet _ = String.(Char.(iter (fun c -> let n = code c - 97 in fs.(n) <- true; is.(!i) <- n; incr i) s;\n if n < 26 then (i := 0; while fs.(!i) do incr i done; Printf.printf \"%s%c\\n\" s (chr (!i + 97)))\n else (for j = n - 1 downto 0 do i := code s.[j] - 96; while !i < 26 && fs.(!i) do incr i done; if !i < 26 then (Printf.printf \"%s%c\\n\" (sub s 0 j) (chr (!i + 97)); exit 0) else (fs.(is.(j)) <- false) done; print_endline \"-1\")))", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 529, "cpu_time_ms": 1, "memory_kb": 2432}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s418286980", "group_id": "codeNet:p03393", "input_text": "let () =\n let a = Scanf.scanf \"%d\\n\" (fun a -> a) in\n print_endline \"abcd\"\n", "language": "OCaml", "metadata": {"date": 1524433251, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03393.html", "problem_id": "p03393", "resource_group": "low_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/OCaml/s418286980.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s418286980", "user_id": "u139013163"}, "prompt_components": {"gold_output": "atcoderb\n", "input_to_evaluate": "let () =\n let a = Scanf.scanf \"%d\\n\" (fun a -> a) in\n print_endline \"abcd\"\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nGotou just received a dictionary. However, he doesn't recognize the language used in the dictionary. He did some analysis on the dictionary and realizes that the dictionary contains all possible diverse words in lexicographical order.\n\nA word is called diverse if and only if it is a nonempty string of English lowercase letters and all letters in the word are distinct. For example, atcoder, zscoder and agc are diverse words while gotou and connect aren't diverse words.\n\nGiven a diverse word S, determine the next word that appears after S in the dictionary, i.e. the lexicographically smallest diverse word that is lexicographically larger than S, or determine that it doesn't exist.\n\nLet X = x_{1}x_{2}...x_{n} and Y = y_{1}y_{2}...y_{m} be two distinct strings. X is lexicographically larger than Y if and only if Y is a prefix of X or x_{j} > y_{j} where j is the smallest integer such that x_{j} \\neq y_{j}.\n\nConstraints\n\n1 \\leq |S| \\leq 26\n\nS is a diverse word.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the next word that appears after S in the dictionary, or -1 if it doesn't exist.\n\nSample Input 1\n\natcoder\n\nSample Output 1\n\natcoderb\n\natcoderb is the lexicographically smallest diverse word that is lexicographically larger than atcoder. Note that atcoderb is lexicographically smaller than b.\n\nSample Input 2\n\nabc\n\nSample Output 2\n\nabcd\n\nSample Input 3\n\nzyxwvutsrqponmlkjihgfedcba\n\nSample Output 3\n\n-1\n\nThis is the lexicographically largest diverse word, so the answer is -1.\n\nSample Input 4\n\nabcdefghijklmnopqrstuvwzyx\n\nSample Output 4\n\nabcdefghijklmnopqrstuvx", "sample_input": "atcoder\n"}, "reference_outputs": ["atcoderb\n"], "source_document_id": "p03393", "source_text": "Score : 300 points\n\nProblem Statement\n\nGotou just received a dictionary. However, he doesn't recognize the language used in the dictionary. He did some analysis on the dictionary and realizes that the dictionary contains all possible diverse words in lexicographical order.\n\nA word is called diverse if and only if it is a nonempty string of English lowercase letters and all letters in the word are distinct. For example, atcoder, zscoder and agc are diverse words while gotou and connect aren't diverse words.\n\nGiven a diverse word S, determine the next word that appears after S in the dictionary, i.e. the lexicographically smallest diverse word that is lexicographically larger than S, or determine that it doesn't exist.\n\nLet X = x_{1}x_{2}...x_{n} and Y = y_{1}y_{2}...y_{m} be two distinct strings. X is lexicographically larger than Y if and only if Y is a prefix of X or x_{j} > y_{j} where j is the smallest integer such that x_{j} \\neq y_{j}.\n\nConstraints\n\n1 \\leq |S| \\leq 26\n\nS is a diverse word.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the next word that appears after S in the dictionary, or -1 if it doesn't exist.\n\nSample Input 1\n\natcoder\n\nSample Output 1\n\natcoderb\n\natcoderb is the lexicographically smallest diverse word that is lexicographically larger than atcoder. Note that atcoderb is lexicographically smaller than b.\n\nSample Input 2\n\nabc\n\nSample Output 2\n\nabcd\n\nSample Input 3\n\nzyxwvutsrqponmlkjihgfedcba\n\nSample Output 3\n\n-1\n\nThis is the lexicographically largest diverse word, so the answer is -1.\n\nSample Input 4\n\nabcdefghijklmnopqrstuvwzyx\n\nSample Output 4\n\nabcdefghijklmnopqrstuvx", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s290955829", "group_id": "codeNet:p03394", "input_text": "Scanf.scanf \"%d\" (fun n ->\n let rec gcd a b = if b = 0 then a else gcd b (a mod b) in\n let lcm a b = a / gcd a b * b in\n\n let smooth k l =\n let rec loop r mask = function\n | [] -> if r = 1 then mask else 0\n | (hd :: tl) as l ->\n if r mod hd = 0 then loop (r / hd) (mask lor (1 lsl hd)) l\n else loop r mask tl\n in\n loop k 0 l\n in\n\n let m2prod mask =\n let rec loop r i c =\n if r = 0 then c else\n if r land 1 = 0 then loop (r lsr 1) (i + 1) c\n else loop (r lsr 1) (i + 1) (c * i)\n in\n loop mask 0 1\n in\n\n let rec loop i acc sum mask =\n let c = smooth i [ 2; 3; 5; 7; 11; 13; 17; 19; 23 ] in\n if c > 0 then (\n Printf.printf \"%d \" i;\n let acc = acc + 1 in\n let sum = sum + i in\n let mask = mask lor c in\n if acc = n - 1 then Printf.printf \"%d\\n\" (lcm sum (m2prod mask) - sum) else loop (i +1) acc sum mask\n ) else loop (i + 1) acc sum mask\n in\n loop 2 0 0 0\n)", "language": "OCaml", "metadata": {"date": 1590733882, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03394.html", "problem_id": "p03394", "resource_group": "low_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/OCaml/s290955829.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s290955829", "user_id": "u342443598"}, "prompt_components": {"gold_output": "2 5 63\n", "input_to_evaluate": "Scanf.scanf \"%d\" (fun n ->\n let rec gcd a b = if b = 0 then a else gcd b (a mod b) in\n let lcm a b = a / gcd a b * b in\n\n let smooth k l =\n let rec loop r mask = function\n | [] -> if r = 1 then mask else 0\n | (hd :: tl) as l ->\n if r mod hd = 0 then loop (r / hd) (mask lor (1 lsl hd)) l\n else loop r mask tl\n in\n loop k 0 l\n in\n\n let m2prod mask =\n let rec loop r i c =\n if r = 0 then c else\n if r land 1 = 0 then loop (r lsr 1) (i + 1) c\n else loop (r lsr 1) (i + 1) (c * i)\n in\n loop mask 0 1\n in\n\n let rec loop i acc sum mask =\n let c = smooth i [ 2; 3; 5; 7; 11; 13; 17; 19; 23 ] in\n if c > 0 then (\n Printf.printf \"%d \" i;\n let acc = acc + 1 in\n let sum = sum + i in\n let mask = mask lor c in\n if acc = n - 1 then Printf.printf \"%d\\n\" (lcm sum (m2prod mask) - sum) else loop (i +1) acc sum mask\n ) else loop (i + 1) acc sum mask\n in\n loop 2 0 0 0\n)", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1133, "cpu_time_ms": 751, "memory_kb": 2816}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s887587646", "group_id": "codeNet:p03400", "input_text": "(*\nocamlfind ocamlopt -package batteries -linkpkg main.ml -o a.out\n*)\nopen Batteries\n\nlet n = Scanf.sscanf (read_line ()) \"%d\" ( fun n -> n)\nlet d, x = Scanf.sscanf (read_line ()) \"%d %d\" ( fun d x -> d, x)\nlet lst = List.init n ( fun _ -> Scanf.sscanf (read_line ()) \"%d\" ( fun a -> a))\n\nlet f a = (List.range 0 `To 100)\n |> List.map (fun elmnt -> (a * elmnt) + 1)\n |> List.filter (fun elmnt -> elmnt <= d)\n\nlet rec f2 lst =\n match lst with\n [] -> x\n | first :: rest -> \n List.length (f first) + (f2 rest)\n\nlet () =\n f2 lst \n |> Printf.printf \"%d\\n\"\n", "language": "OCaml", "metadata": {"date": 1590260835, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03400.html", "problem_id": "p03400", "resource_group": "low_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/OCaml/s887587646.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s887587646", "user_id": "u280335093"}, "prompt_components": {"gold_output": "8\n", "input_to_evaluate": "(*\nocamlfind ocamlopt -package batteries -linkpkg main.ml -o a.out\n*)\nopen Batteries\n\nlet n = Scanf.sscanf (read_line ()) \"%d\" ( fun n -> n)\nlet d, x = Scanf.sscanf (read_line ()) \"%d %d\" ( fun d x -> d, x)\nlet lst = List.init n ( fun _ -> Scanf.sscanf (read_line ()) \"%d\" ( fun a -> a))\n\nlet f a = (List.range 0 `To 100)\n |> List.map (fun elmnt -> (a * elmnt) + 1)\n |> List.filter (fun elmnt -> elmnt <= d)\n\nlet rec f2 lst =\n match lst with\n [] -> x\n | first :: rest -> \n List.length (f first) + (f2 rest)\n\nlet () =\n f2 lst \n |> Printf.printf \"%d\\n\"\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nSome number of chocolate pieces were prepared for a training camp.\nThe camp had N participants and lasted for D days.\nThe i-th participant (1 \\leq i \\leq N) ate one chocolate piece on each of the following days in the camp: the 1-st day, the (A_i + 1)-th day, the (2A_i + 1)-th day, and so on.\nAs a result, there were X chocolate pieces remaining at the end of the camp. During the camp, nobody except the participants ate chocolate pieces.\n\nFind the number of chocolate pieces prepared at the beginning of the camp.\n\nConstraints\n\n1 \\leq N \\leq 100\n\n1 \\leq D \\leq 100\n\n1 \\leq X \\leq 100\n\n1 \\leq A_i \\leq 100 (1 \\leq i \\leq N)\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nD X\nA_1\nA_2\n:\nA_N\n\nOutput\n\nFind the number of chocolate pieces prepared at the beginning of the camp.\n\nSample Input 1\n\n3\n7 1\n2\n5\n10\n\nSample Output 1\n\n8\n\nThe camp has 3 participants and lasts for 7 days.\nEach participant eats chocolate pieces as follows:\n\nThe first participant eats one chocolate piece on Day 1, 3, 5 and 7, for a total of four.\n\nThe second participant eats one chocolate piece on Day 1 and 6, for a total of two.\n\nThe third participant eats one chocolate piece only on Day 1, for a total of one.\n\nSince the number of pieces remaining at the end of the camp is one, the number of pieces prepared at the beginning of the camp is 1 + 4 + 2 + 1 = 8.\n\nSample Input 2\n\n2\n8 20\n1\n10\n\nSample Output 2\n\n29\n\nSample Input 3\n\n5\n30 44\n26\n18\n81\n18\n6\n\nSample Output 3\n\n56", "sample_input": "3\n7 1\n2\n5\n10\n"}, "reference_outputs": ["8\n"], "source_document_id": "p03400", "source_text": "Score : 200 points\n\nProblem Statement\n\nSome number of chocolate pieces were prepared for a training camp.\nThe camp had N participants and lasted for D days.\nThe i-th participant (1 \\leq i \\leq N) ate one chocolate piece on each of the following days in the camp: the 1-st day, the (A_i + 1)-th day, the (2A_i + 1)-th day, and so on.\nAs a result, there were X chocolate pieces remaining at the end of the camp. During the camp, nobody except the participants ate chocolate pieces.\n\nFind the number of chocolate pieces prepared at the beginning of the camp.\n\nConstraints\n\n1 \\leq N \\leq 100\n\n1 \\leq D \\leq 100\n\n1 \\leq X \\leq 100\n\n1 \\leq A_i \\leq 100 (1 \\leq i \\leq N)\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nD X\nA_1\nA_2\n:\nA_N\n\nOutput\n\nFind the number of chocolate pieces prepared at the beginning of the camp.\n\nSample Input 1\n\n3\n7 1\n2\n5\n10\n\nSample Output 1\n\n8\n\nThe camp has 3 participants and lasts for 7 days.\nEach participant eats chocolate pieces as follows:\n\nThe first participant eats one chocolate piece on Day 1, 3, 5 and 7, for a total of four.\n\nThe second participant eats one chocolate piece on Day 1 and 6, for a total of two.\n\nThe third participant eats one chocolate piece only on Day 1, for a total of one.\n\nSince the number of pieces remaining at the end of the camp is one, the number of pieces prepared at the beginning of the camp is 1 + 4 + 2 + 1 = 8.\n\nSample Input 2\n\n2\n8 20\n1\n10\n\nSample Output 2\n\n29\n\nSample Input 3\n\n5\n30 44\n26\n18\n81\n18\n6\n\nSample Output 3\n\n56", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 645, "cpu_time_ms": 2, "memory_kb": 1792}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s806609415", "group_id": "codeNet:p03401", "input_text": "let id x = x\nlet n = Scanf.scanf \"%d\\n\" id\nlet ar = Array.make (n+2) 0\nlet sum_init i =\n let rec sum i' tmp =\n if i' = (n + 1) then tmp + abs ar.(0) + abs ar.(n)\n else\n let v = Scanf.scanf \"%d \" id in\n let () = ar.(i') <- v in\n sum (i' + 1) (tmp + abs (v - ar.(i' - 1)))\n in\n sum 1 0\n\nlet cost = sum_init n\n\nlet skip i =\n let off = abs (ar.(i) - ar.(i-1)) + abs (ar.(i + 1) - ar.(i))\n and add = abs (ar.(i + 1) - ar.(i - 1)) in\n cost - off + add\n\nlet () = for i = 1 to n do skip i |> Printf.printf \"%d\\n\" done", "language": "OCaml", "metadata": {"date": 1523144730, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03401.html", "problem_id": "p03401", "resource_group": "low_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/OCaml/s806609415.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s806609415", "user_id": "u987869509"}, "prompt_components": {"gold_output": "12\n8\n10\n", "input_to_evaluate": "let id x = x\nlet n = Scanf.scanf \"%d\\n\" id\nlet ar = Array.make (n+2) 0\nlet sum_init i =\n let rec sum i' tmp =\n if i' = (n + 1) then tmp + abs ar.(0) + abs ar.(n)\n else\n let v = Scanf.scanf \"%d \" id in\n let () = ar.(i') <- v in\n sum (i' + 1) (tmp + abs (v - ar.(i' - 1)))\n in\n sum 1 0\n\nlet cost = sum_init n\n\nlet skip i =\n let off = abs (ar.(i) - ar.(i-1)) + abs (ar.(i + 1) - ar.(i))\n and add = abs (ar.(i + 1) - ar.(i - 1)) in\n cost - off + add\n\nlet () = for i = 1 to n do skip i |> Printf.printf \"%d\\n\" done", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 50, "memory_kb": 6272}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s563444289", "group_id": "codeNet:p03402", "input_text": "let () =\n Scanf.scanf \"%d %d\" @@ fun a b ->\n let w = 100 in\n let res = Array.init 50 (fun _ -> Array.make 100 '.') in\n\n let r = (b+48)/50 - 1 in\n\n (* A *)\n let la = 2*r + 4 in\n for i = 0 to (a-2) do\n let x = i / (w/2) * 2 in\n let y = i mod (w/2) * 2 in\n res.(la + x).(y) <- '#';\n done;\n\n (* B *)\n for i = 0 to 2*r+1 do res.(i).(0) <- '#' done;\n for i = 0 to r do\n for j = 0 to w-1 do res.(2*i+1).(j) <- '#' done;\n done;\n for i = 0 to r-1 do\n for j = 0 to (w-2)/2 do res.(2*i).(2*j) <- '#' done;\n done;\n if r >= 0 then\n for i = 0 to (b+48) mod 50 do\n res.(2*r).(2*i) <- '#';\n done\n else res.(0).(0) <- '#';\n\n print_endline \"50 100\";\n res |> Array.iter @@ fun r ->\n r |> Array.iter print_char;\n print_newline ();", "language": "OCaml", "metadata": {"date": 1532773513, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03402.html", "problem_id": "p03402", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03402/input.txt", "sample_output_relpath": "derived/input_output/data/p03402/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03402/OCaml/s563444289.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s563444289", "user_id": "u798181098"}, "prompt_components": {"gold_output": "3 3\n##.\n..#\n#.#\n", "input_to_evaluate": "let () =\n Scanf.scanf \"%d %d\" @@ fun a b ->\n let w = 100 in\n let res = Array.init 50 (fun _ -> Array.make 100 '.') in\n\n let r = (b+48)/50 - 1 in\n\n (* A *)\n let la = 2*r + 4 in\n for i = 0 to (a-2) do\n let x = i / (w/2) * 2 in\n let y = i mod (w/2) * 2 in\n res.(la + x).(y) <- '#';\n done;\n\n (* B *)\n for i = 0 to 2*r+1 do res.(i).(0) <- '#' done;\n for i = 0 to r do\n for j = 0 to w-1 do res.(2*i+1).(j) <- '#' done;\n done;\n for i = 0 to r-1 do\n for j = 0 to (w-2)/2 do res.(2*i).(2*j) <- '#' done;\n done;\n if r >= 0 then\n for i = 0 to (b+48) mod 50 do\n res.(2*r).(2*i) <- '#';\n done\n else res.(0).(0) <- '#';\n\n print_endline \"50 100\";\n res |> Array.iter @@ fun r ->\n r |> Array.iter print_char;\n print_newline ();", "problem_context": "Score : 500 points\n\nProblem Statement\n\nYou are given two integers A and B.\n\nPrint a grid where each square is painted white or black that satisfies the following conditions, in the format specified in Output section:\n\nLet the size of the grid be h \\times w (h vertical, w horizontal). Both h and w are at most 100.\n\nThe set of the squares painted white is divided into exactly A connected components.\n\nThe set of the squares painted black is divided into exactly B connected components.\n\nIt can be proved that there always exist one or more solutions under the conditions specified in Constraints section.\nIf there are multiple solutions, any of them may be printed.\n\nNotes\n\nTwo squares painted white, c_1 and c_2, are called connected when the square c_2 can be reached from the square c_1 passing only white squares by repeatedly moving up, down, left or right to an adjacent square.\n\nA set of squares painted white, S, forms a connected component when the following conditions are met:\n\nAny two squares in S are connected.\n\nNo pair of a square painted white that is not included in S and a square included in S is connected.\n\nA connected component of squares painted black is defined similarly.\n\nConstraints\n\n1 \\leq A \\leq 500\n\n1 \\leq B \\leq 500\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nOutput should be in the following format:\n\nIn the first line, print integers h and w representing the size of the grid you constructed, with a space in between.\n\nThen, print h more lines. The i-th (1 \\leq i \\leq h) of these lines should contain a string s_i as follows:\n\nIf the square at the i-th row and j-th column (1 \\leq j \\leq w) in the grid is painted white, the j-th character in s_i should be ..\n\nIf the square at the i-th row and j-th column (1 \\leq j \\leq w) in the grid is painted black, the j-th character in s_i should be #.\n\nSample Input 1\n\n2 3\n\nSample Output 1\n\n3 3\n##.\n..#\n#.#\n\nThis output corresponds to the grid below:\n\nSample Input 2\n\n7 8\n\nSample Output 2\n\n3 5\n#.#.#\n.#.#.\n#.#.#\n\nSample Input 3\n\n1 1\n\nSample Output 3\n\n4 2\n..\n#.\n##\n##\n\nSample Input 4\n\n3 14\n\nSample Output 4\n\n8 18\n..................\n..................\n....##.......####.\n....#.#.....#.....\n...#...#....#.....\n..#.###.#...#.....\n.#.......#..#.....\n#.........#..####.", "sample_input": "2 3\n"}, "reference_outputs": ["3 3\n##.\n..#\n#.#\n"], "source_document_id": "p03402", "source_text": "Score : 500 points\n\nProblem Statement\n\nYou are given two integers A and B.\n\nPrint a grid where each square is painted white or black that satisfies the following conditions, in the format specified in Output section:\n\nLet the size of the grid be h \\times w (h vertical, w horizontal). Both h and w are at most 100.\n\nThe set of the squares painted white is divided into exactly A connected components.\n\nThe set of the squares painted black is divided into exactly B connected components.\n\nIt can be proved that there always exist one or more solutions under the conditions specified in Constraints section.\nIf there are multiple solutions, any of them may be printed.\n\nNotes\n\nTwo squares painted white, c_1 and c_2, are called connected when the square c_2 can be reached from the square c_1 passing only white squares by repeatedly moving up, down, left or right to an adjacent square.\n\nA set of squares painted white, S, forms a connected component when the following conditions are met:\n\nAny two squares in S are connected.\n\nNo pair of a square painted white that is not included in S and a square included in S is connected.\n\nA connected component of squares painted black is defined similarly.\n\nConstraints\n\n1 \\leq A \\leq 500\n\n1 \\leq B \\leq 500\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nOutput should be in the following format:\n\nIn the first line, print integers h and w representing the size of the grid you constructed, with a space in between.\n\nThen, print h more lines. The i-th (1 \\leq i \\leq h) of these lines should contain a string s_i as follows:\n\nIf the square at the i-th row and j-th column (1 \\leq j \\leq w) in the grid is painted white, the j-th character in s_i should be ..\n\nIf the square at the i-th row and j-th column (1 \\leq j \\leq w) in the grid is painted black, the j-th character in s_i should be #.\n\nSample Input 1\n\n2 3\n\nSample Output 1\n\n3 3\n##.\n..#\n#.#\n\nThis output corresponds to the grid below:\n\nSample Input 2\n\n7 8\n\nSample Output 2\n\n3 5\n#.#.#\n.#.#.\n#.#.#\n\nSample Input 3\n\n1 1\n\nSample Output 3\n\n4 2\n..\n#.\n##\n##\n\nSample Input 4\n\n3 14\n\nSample Output 4\n\n8 18\n..................\n..................\n....##.......####.\n....#.#.....#.....\n...#...#....#.....\n..#.###.#...#.....\n.#.......#..#.....\n#.........#..####.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 760, "cpu_time_ms": 2, "memory_kb": 4480}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s953628015", "group_id": "codeNet:p03407", "input_text": "let f a b c = if a + b > c then \"Yes\" else \"No\";;\nlet () = Scanf.scanf \"%d %d %d\" f\n|> Printf.printf \"%s\\n\"", "language": "OCaml", "metadata": {"date": 1561262608, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03407.html", "problem_id": "p03407", "resource_group": "low_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/OCaml/s953628015.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s953628015", "user_id": "u635974378"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "let f a b c = if a + b > c then \"Yes\" else \"No\";;\nlet () = Scanf.scanf \"%d %d %d\" f\n|> Printf.printf \"%s\\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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s280534174", "group_id": "codeNet:p03408", "input_text": "(* O(k^2) (k = max n m) *)\nlet n = read_int () in\nlet ss = Array.init n @@ fun _ -> read_line () in\nlet m = read_int () in\nlet ts = Array.init m @@ fun _ -> read_line () in\nlet f acc s =\n let c = Array.fold_left (fun c s' -> if s' = s then c + 1 else c) 0 ss in\n max acc @@ Array.fold_left (fun c t -> if t = s then c - 1 else c) c ts in\nArray.fold_left f 0 ss |> Printf.printf \"%d\\n\"", "language": "OCaml", "metadata": {"date": 1559218752, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03408.html", "problem_id": "p03408", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03408/input.txt", "sample_output_relpath": "derived/input_output/data/p03408/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03408/OCaml/s280534174.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s280534174", "user_id": "u732304692"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "(* O(k^2) (k = max n m) *)\nlet n = read_int () in\nlet ss = Array.init n @@ fun _ -> read_line () in\nlet m = read_int () in\nlet ts = Array.init m @@ fun _ -> read_line () in\nlet f acc s =\n let c = Array.fold_left (fun c s' -> if s' = s then c + 1 else c) 0 ss in\n max acc @@ Array.fold_left (fun c t -> if t = s then c - 1 else c) c ts in\nArray.fold_left f 0 ss |> Printf.printf \"%d\\n\"", "problem_context": "Score : 200 points\n\nProblem Statement\n\nTakahashi has N blue cards and M red cards.\nA string is written on each card. The string written on the i-th blue card is s_i, and the string written on the i-th red card is t_i.\n\nTakahashi will now announce a string, and then check every card. Each time he finds a blue card with the string announced by him, he will earn 1 yen (the currency of Japan); each time he finds a red card with that string, he will lose 1 yen.\n\nHere, we only consider the case where the string announced by Takahashi and the string on the card are exactly the same. For example, if he announces atcoder, he will not earn money even if there are blue cards with atcoderr, atcode, btcoder, and so on. (On the other hand, he will not lose money even if there are red cards with such strings, either.)\n\nAt most how much can he earn on balance?\n\nNote that the same string may be written on multiple cards.\n\nConstraints\n\nN and M are integers.\n\n1 \\leq N, M \\leq 100\n\ns_1, s_2, ..., s_N, t_1, t_2, ..., t_M are all strings of lengths between 1 and 10 (inclusive) consisting of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\ns_1\ns_2\n:\ns_N\nM\nt_1\nt_2\n:\nt_M\n\nOutput\n\nIf Takahashi can earn at most X yen on balance, print X.\n\nSample Input 1\n\n3\napple\norange\napple\n1\ngrape\n\nSample Output 1\n\n2\n\nHe can earn 2 yen by announcing apple.\n\nSample Input 2\n\n3\napple\norange\napple\n5\napple\napple\napple\napple\napple\n\nSample Output 2\n\n1\n\nIf he announces apple, he will lose 3 yen. If he announces orange, he can earn 1 yen.\n\nSample Input 3\n\n1\nvoldemort\n10\nvoldemort\nvoldemort\nvoldemort\nvoldemort\nvoldemort\nvoldemort\nvoldemort\nvoldemort\nvoldemort\nvoldemort\n\nSample Output 3\n\n0\n\nIf he announces voldemort, he will lose 9 yen. If he announces orange, for example, he can avoid losing a yen.\n\nSample Input 4\n\n6\nred\nred\nblue\nyellow\nyellow\nred\n5\nred\nred\nyellow\ngreen\nblue\n\nSample Output 4\n\n1", "sample_input": "3\napple\norange\napple\n1\ngrape\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03408", "source_text": "Score : 200 points\n\nProblem Statement\n\nTakahashi has N blue cards and M red cards.\nA string is written on each card. The string written on the i-th blue card is s_i, and the string written on the i-th red card is t_i.\n\nTakahashi will now announce a string, and then check every card. Each time he finds a blue card with the string announced by him, he will earn 1 yen (the currency of Japan); each time he finds a red card with that string, he will lose 1 yen.\n\nHere, we only consider the case where the string announced by Takahashi and the string on the card are exactly the same. For example, if he announces atcoder, he will not earn money even if there are blue cards with atcoderr, atcode, btcoder, and so on. (On the other hand, he will not lose money even if there are red cards with such strings, either.)\n\nAt most how much can he earn on balance?\n\nNote that the same string may be written on multiple cards.\n\nConstraints\n\nN and M are integers.\n\n1 \\leq N, M \\leq 100\n\ns_1, s_2, ..., s_N, t_1, t_2, ..., t_M are all strings of lengths between 1 and 10 (inclusive) consisting of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\ns_1\ns_2\n:\ns_N\nM\nt_1\nt_2\n:\nt_M\n\nOutput\n\nIf Takahashi can earn at most X yen on balance, print X.\n\nSample Input 1\n\n3\napple\norange\napple\n1\ngrape\n\nSample Output 1\n\n2\n\nHe can earn 2 yen by announcing apple.\n\nSample Input 2\n\n3\napple\norange\napple\n5\napple\napple\napple\napple\napple\n\nSample Output 2\n\n1\n\nIf he announces apple, he will lose 3 yen. If he announces orange, he can earn 1 yen.\n\nSample Input 3\n\n1\nvoldemort\n10\nvoldemort\nvoldemort\nvoldemort\nvoldemort\nvoldemort\nvoldemort\nvoldemort\nvoldemort\nvoldemort\nvoldemort\n\nSample Output 3\n\n0\n\nIf he announces voldemort, he will lose 9 yen. If he announces orange, for example, he can avoid losing a yen.\n\nSample Input 4\n\n6\nred\nred\nblue\nyellow\nyellow\nred\n5\nred\nred\nyellow\ngreen\nblue\n\nSample Output 4\n\n1", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s103249254", "group_id": "codeNet:p03409", "input_text": "let scan_line () = Scanf.scanf \"%d %d\\n\" (fun a b -> (a, b))\n\nlet n = Scanf.scanf \"%d\\n\" (fun x -> x)\n\nlet init n =\n let rec aux i ls =\n if i = 0 then List.fast_sort (fun i j -> fst i - fst j) ls\n else aux (i - 1) (scan_line () :: ls)\n in\n aux n []\n\n\nlet r' = init n\nlet b' = init n\n\nlet rec solve r count = function\n | [] -> count\n | bp :: l ->\n match List.filter (fun rp -> fst rp < fst bp && snd rp < snd bp) r with\n | [] -> solve r count l\n | r' ->\n let v = List.fast_sort (fun i j -> snd j - snd i) r' |> List.hd in\n solve (List.remove_assoc (fst v) r) (count + 1) l\n\n\nlet () = solve r' 0 b' |> Printf.printf \"%d\\n\"", "language": "OCaml", "metadata": {"date": 1523171492, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03409.html", "problem_id": "p03409", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03409/input.txt", "sample_output_relpath": "derived/input_output/data/p03409/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03409/OCaml/s103249254.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s103249254", "user_id": "u987869509"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "let scan_line () = Scanf.scanf \"%d %d\\n\" (fun a b -> (a, b))\n\nlet n = Scanf.scanf \"%d\\n\" (fun x -> x)\n\nlet init n =\n let rec aux i ls =\n if i = 0 then List.fast_sort (fun i j -> fst i - fst j) ls\n else aux (i - 1) (scan_line () :: ls)\n in\n aux n []\n\n\nlet r' = init n\nlet b' = init n\n\nlet rec solve r count = function\n | [] -> count\n | bp :: l ->\n match List.filter (fun rp -> fst rp < fst bp && snd rp < snd bp) r with\n | [] -> solve r count l\n | r' ->\n let v = List.fast_sort (fun i j -> snd j - snd i) r' |> List.hd in\n solve (List.remove_assoc (fst v) r) (count + 1) l\n\n\nlet () = solve r' 0 b' |> Printf.printf \"%d\\n\"", "problem_context": "Score : 400 points\n\nProblem Statement\n\nOn a two-dimensional plane, there are N red points and N blue points.\nThe coordinates of the i-th red point are (a_i, b_i), and the coordinates of the i-th blue point are (c_i, d_i).\n\nA red point and a blue point can form a friendly pair when, the x-coordinate of the red point is smaller than that of the blue point, and the y-coordinate of the red point is also smaller than that of the blue point.\n\nAt most how many friendly pairs can you form? Note that a point cannot belong to multiple pairs.\n\nConstraints\n\nAll input values are integers.\n\n1 \\leq N \\leq 100\n\n0 \\leq a_i, b_i, c_i, d_i < 2N\n\na_1, a_2, ..., a_N, c_1, c_2, ..., c_N are all different.\n\nb_1, b_2, ..., b_N, d_1, d_2, ..., d_N are all different.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 b_1\na_2 b_2\n:\na_N b_N\nc_1 d_1\nc_2 d_2\n:\nc_N d_N\n\nOutput\n\nPrint the maximum number of friendly pairs.\n\nSample Input 1\n\n3\n2 0\n3 1\n1 3\n4 2\n0 4\n5 5\n\nSample Output 1\n\n2\n\nFor example, you can pair (2, 0) and (4, 2), then (3, 1) and (5, 5).\n\nSample Input 2\n\n3\n0 0\n1 1\n5 2\n2 3\n3 4\n4 5\n\nSample Output 2\n\n2\n\nFor example, you can pair (0, 0) and (2, 3), then (1, 1) and (3, 4).\n\nSample Input 3\n\n2\n2 2\n3 3\n0 0\n1 1\n\nSample Output 3\n\n0\n\nIt is possible that no pair can be formed.\n\nSample Input 4\n\n5\n0 0\n7 3\n2 2\n4 8\n1 6\n8 5\n6 9\n5 4\n9 1\n3 7\n\nSample Output 4\n\n5\n\nSample Input 5\n\n5\n0 0\n1 1\n5 5\n6 6\n7 7\n2 2\n3 3\n4 4\n8 8\n9 9\n\nSample Output 5\n\n4", "sample_input": "3\n2 0\n3 1\n1 3\n4 2\n0 4\n5 5\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03409", "source_text": "Score : 400 points\n\nProblem Statement\n\nOn a two-dimensional plane, there are N red points and N blue points.\nThe coordinates of the i-th red point are (a_i, b_i), and the coordinates of the i-th blue point are (c_i, d_i).\n\nA red point and a blue point can form a friendly pair when, the x-coordinate of the red point is smaller than that of the blue point, and the y-coordinate of the red point is also smaller than that of the blue point.\n\nAt most how many friendly pairs can you form? Note that a point cannot belong to multiple pairs.\n\nConstraints\n\nAll input values are integers.\n\n1 \\leq N \\leq 100\n\n0 \\leq a_i, b_i, c_i, d_i < 2N\n\na_1, a_2, ..., a_N, c_1, c_2, ..., c_N are all different.\n\nb_1, b_2, ..., b_N, d_1, d_2, ..., d_N are all different.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 b_1\na_2 b_2\n:\na_N b_N\nc_1 d_1\nc_2 d_2\n:\nc_N d_N\n\nOutput\n\nPrint the maximum number of friendly pairs.\n\nSample Input 1\n\n3\n2 0\n3 1\n1 3\n4 2\n0 4\n5 5\n\nSample Output 1\n\n2\n\nFor example, you can pair (2, 0) and (4, 2), then (3, 1) and (5, 5).\n\nSample Input 2\n\n3\n0 0\n1 1\n5 2\n2 3\n3 4\n4 5\n\nSample Output 2\n\n2\n\nFor example, you can pair (0, 0) and (2, 3), then (1, 1) and (3, 4).\n\nSample Input 3\n\n2\n2 2\n3 3\n0 0\n1 1\n\nSample Output 3\n\n0\n\nIt is possible that no pair can be formed.\n\nSample Input 4\n\n5\n0 0\n7 3\n2 2\n4 8\n1 6\n8 5\n6 9\n5 4\n9 1\n3 7\n\nSample Output 4\n\n5\n\nSample Input 5\n\n5\n0 0\n1 1\n5 5\n6 6\n7 7\n2 2\n3 3\n4 4\n8 8\n9 9\n\nSample Output 5\n\n4", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 640}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s154841537", "group_id": "codeNet:p03411", "input_text": "let n = read_int()\n\nlet ab = Array.init n (fun _ -> Scanf.scanf \" %d %d\" (fun a b -> a, b))\n\nlet cd = Array.init n (fun _ -> Scanf.scanf \" %d %d\" (fun c d -> c, d))\n\nlet list = Array.make n 0\nlet li = ref 0\n\nlet rec f i j p =\n if i = n then p\n else\n let c, d = cd.(i) in\n let rec g j =\n if j < n then (\n let a, b = ab.(j) in\n if a < c then (\n list.(!li) <- b;\n li := !li + 1;\n g (j + 1)\n ) else j\n ) else j in\n let j = g j in\n let rec g k l m =\n if k = !li then l\n else if list.(k) < d && m < list.(k) then g (k + 1) k list.(k)\n else g (k + 1) l m in\n let l = g 0 ~-1 ~-1 in\n if l > -1 then (\n list.(l) <- list.(!li - 1);\n li := !li - 1;\n f (i + 1) j (p + 1)\n ) else f (i + 1) j p\n\nlet () =\n Array.sort (fun (x1, _) (x2, _) -> x1 - x2) ab;\n Array.sort (fun (x1, _) (x2, _) -> x1 - x2) cd;\n let ans = f 0 0 0 in\n Printf.printf \"%d\\n\" ans\n", "language": "OCaml", "metadata": {"date": 1601333245, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p03411.html", "problem_id": "p03411", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03411/input.txt", "sample_output_relpath": "derived/input_output/data/p03411/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03411/OCaml/s154841537.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s154841537", "user_id": "u752907799"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "let n = read_int()\n\nlet ab = Array.init n (fun _ -> Scanf.scanf \" %d %d\" (fun a b -> a, b))\n\nlet cd = Array.init n (fun _ -> Scanf.scanf \" %d %d\" (fun c d -> c, d))\n\nlet list = Array.make n 0\nlet li = ref 0\n\nlet rec f i j p =\n if i = n then p\n else\n let c, d = cd.(i) in\n let rec g j =\n if j < n then (\n let a, b = ab.(j) in\n if a < c then (\n list.(!li) <- b;\n li := !li + 1;\n g (j + 1)\n ) else j\n ) else j in\n let j = g j in\n let rec g k l m =\n if k = !li then l\n else if list.(k) < d && m < list.(k) then g (k + 1) k list.(k)\n else g (k + 1) l m in\n let l = g 0 ~-1 ~-1 in\n if l > -1 then (\n list.(l) <- list.(!li - 1);\n li := !li - 1;\n f (i + 1) j (p + 1)\n ) else f (i + 1) j p\n\nlet () =\n Array.sort (fun (x1, _) (x2, _) -> x1 - x2) ab;\n Array.sort (fun (x1, _) (x2, _) -> x1 - x2) cd;\n let ans = f 0 0 0 in\n Printf.printf \"%d\\n\" ans\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nOn a two-dimensional plane, there are N red points and N blue points.\nThe coordinates of the i-th red point are (a_i, b_i), and the coordinates of the i-th blue point are (c_i, d_i).\n\nA red point and a blue point can form a friendly pair when, the x-coordinate of the red point is smaller than that of the blue point, and the y-coordinate of the red point is also smaller than that of the blue point.\n\nAt most how many friendly pairs can you form? Note that a point cannot belong to multiple pairs.\n\nConstraints\n\nAll input values are integers.\n\n1 \\leq N \\leq 100\n\n0 \\leq a_i, b_i, c_i, d_i < 2N\n\na_1, a_2, ..., a_N, c_1, c_2, ..., c_N are all different.\n\nb_1, b_2, ..., b_N, d_1, d_2, ..., d_N are all different.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 b_1\na_2 b_2\n:\na_N b_N\nc_1 d_1\nc_2 d_2\n:\nc_N d_N\n\nOutput\n\nPrint the maximum number of friendly pairs.\n\nSample Input 1\n\n3\n2 0\n3 1\n1 3\n4 2\n0 4\n5 5\n\nSample Output 1\n\n2\n\nFor example, you can pair (2, 0) and (4, 2), then (3, 1) and (5, 5).\n\nSample Input 2\n\n3\n0 0\n1 1\n5 2\n2 3\n3 4\n4 5\n\nSample Output 2\n\n2\n\nFor example, you can pair (0, 0) and (2, 3), then (1, 1) and (3, 4).\n\nSample Input 3\n\n2\n2 2\n3 3\n0 0\n1 1\n\nSample Output 3\n\n0\n\nIt is possible that no pair can be formed.\n\nSample Input 4\n\n5\n0 0\n7 3\n2 2\n4 8\n1 6\n8 5\n6 9\n5 4\n9 1\n3 7\n\nSample Output 4\n\n5\n\nSample Input 5\n\n5\n0 0\n1 1\n5 5\n6 6\n7 7\n2 2\n3 3\n4 4\n8 8\n9 9\n\nSample Output 5\n\n4", "sample_input": "3\n2 0\n3 1\n1 3\n4 2\n0 4\n5 5\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03411", "source_text": "Score : 400 points\n\nProblem Statement\n\nOn a two-dimensional plane, there are N red points and N blue points.\nThe coordinates of the i-th red point are (a_i, b_i), and the coordinates of the i-th blue point are (c_i, d_i).\n\nA red point and a blue point can form a friendly pair when, the x-coordinate of the red point is smaller than that of the blue point, and the y-coordinate of the red point is also smaller than that of the blue point.\n\nAt most how many friendly pairs can you form? Note that a point cannot belong to multiple pairs.\n\nConstraints\n\nAll input values are integers.\n\n1 \\leq N \\leq 100\n\n0 \\leq a_i, b_i, c_i, d_i < 2N\n\na_1, a_2, ..., a_N, c_1, c_2, ..., c_N are all different.\n\nb_1, b_2, ..., b_N, d_1, d_2, ..., d_N are all different.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 b_1\na_2 b_2\n:\na_N b_N\nc_1 d_1\nc_2 d_2\n:\nc_N d_N\n\nOutput\n\nPrint the maximum number of friendly pairs.\n\nSample Input 1\n\n3\n2 0\n3 1\n1 3\n4 2\n0 4\n5 5\n\nSample Output 1\n\n2\n\nFor example, you can pair (2, 0) and (4, 2), then (3, 1) and (5, 5).\n\nSample Input 2\n\n3\n0 0\n1 1\n5 2\n2 3\n3 4\n4 5\n\nSample Output 2\n\n2\n\nFor example, you can pair (0, 0) and (2, 3), then (1, 1) and (3, 4).\n\nSample Input 3\n\n2\n2 2\n3 3\n0 0\n1 1\n\nSample Output 3\n\n0\n\nIt is possible that no pair can be formed.\n\nSample Input 4\n\n5\n0 0\n7 3\n2 2\n4 8\n1 6\n8 5\n6 9\n5 4\n9 1\n3 7\n\nSample Output 4\n\n5\n\nSample Input 5\n\n5\n0 0\n1 1\n5 5\n6 6\n7 7\n2 2\n3 3\n4 4\n8 8\n9 9\n\nSample Output 5\n\n4", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 952, "cpu_time_ms": 9, "memory_kb": 3872}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s235442179", "group_id": "codeNet:p03415", "input_text": "let f c1 c2 c3 c4 c5 c6 c7 c8 c9 = String.concat \"\" [String.make 1 c1; String.make 1 c5; String. make 1 c9];;\nlet () = Scanf.scanf \"%c%c%c %c%c%c %c%c%c\" f\n|> Printf.printf \"%s\\n\"", "language": "OCaml", "metadata": {"date": 1561262367, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03415.html", "problem_id": "p03415", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03415/input.txt", "sample_output_relpath": "derived/input_output/data/p03415/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03415/OCaml/s235442179.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s235442179", "user_id": "u635974378"}, "prompt_components": {"gold_output": "abc\n", "input_to_evaluate": "let f c1 c2 c3 c4 c5 c6 c7 c8 c9 = String.concat \"\" [String.make 1 c1; String.make 1 c5; String. make 1 c9];;\nlet () = Scanf.scanf \"%c%c%c %c%c%c %c%c%c\" f\n|> Printf.printf \"%s\\n\"", "problem_context": "Score : 100 points\n\nProblem Statement\n\nWe have a 3×3 square grid, where each square contains a lowercase English letters.\nThe letter in the square at the i-th row from the top and j-th column from the left is c_{ij}.\n\nPrint the string of length 3 that can be obtained by concatenating the letters in the squares on the diagonal connecting the top-left and bottom-right corner of the grid, from the top-left to bottom-right.\n\nConstraints\n\nInput consists of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nc_{11}c_{12}c_{13}\nc_{21}c_{22}c_{23}\nc_{31}c_{32}c_{33}\n\nOutput\n\nPrint the string of length 3 that can be obtained by concatenating the letters on the diagonal connecting the top-left and bottom-right corner of the grid, from the top-left to bottom-right.\n\nSample Input 1\n\nant\nobe\nrec\n\nSample Output 1\n\nabc\n\nThe letters in the squares on the diagonal connecting the top-left and bottom-right corner of the grid are a, b and c from top-right to bottom-left. Concatenate these letters and print abc.\n\nSample Input 2\n\nedu\ncat\nion\n\nSample Output 2\n\nean", "sample_input": "ant\nobe\nrec\n"}, "reference_outputs": ["abc\n"], "source_document_id": "p03415", "source_text": "Score : 100 points\n\nProblem Statement\n\nWe have a 3×3 square grid, where each square contains a lowercase English letters.\nThe letter in the square at the i-th row from the top and j-th column from the left is c_{ij}.\n\nPrint the string of length 3 that can be obtained by concatenating the letters in the squares on the diagonal connecting the top-left and bottom-right corner of the grid, from the top-left to bottom-right.\n\nConstraints\n\nInput consists of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nc_{11}c_{12}c_{13}\nc_{21}c_{22}c_{23}\nc_{31}c_{32}c_{33}\n\nOutput\n\nPrint the string of length 3 that can be obtained by concatenating the letters on the diagonal connecting the top-left and bottom-right corner of the grid, from the top-left to bottom-right.\n\nSample Input 1\n\nant\nobe\nrec\n\nSample Output 1\n\nabc\n\nThe letters in the squares on the diagonal connecting the top-left and bottom-right corner of the grid are a, b and c from top-right to bottom-left. Concatenate these letters and print abc.\n\nSample Input 2\n\nedu\ncat\nion\n\nSample Output 2\n\nean", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s730665682", "group_id": "codeNet:p03417", "input_text": "let () =\n Scanf.scanf \"%d %d\" (fun n m -> n * m - (2 * n + 2 * m - 4))\n |> abs |> Printf.printf \"%d\\n\"", "language": "OCaml", "metadata": {"date": 1523183370, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03417.html", "problem_id": "p03417", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03417/input.txt", "sample_output_relpath": "derived/input_output/data/p03417/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03417/OCaml/s730665682.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s730665682", "user_id": "u987869509"}, "prompt_components": {"gold_output": "0\n", "input_to_evaluate": "let () =\n Scanf.scanf \"%d %d\" (fun n m -> n * m - (2 * n + 2 * m - 4))\n |> abs |> Printf.printf \"%d\\n\"", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere is a grid with infinitely many rows and columns. In this grid, there is a rectangular region with consecutive N rows and M columns, and a card is placed in each square in this region.\nThe front and back sides of these cards can be distinguished, and initially every card faces up.\n\nWe will perform the following operation once for each square contains a card:\n\nFor each of the following nine squares, flip the card in it if it exists: the target square itself and the eight squares that shares a corner or a side with the target square.\n\nIt can be proved that, whether each card faces up or down after all the operations does not depend on the order the operations are performed.\nFind the number of cards that face down after all the operations.\n\nConstraints\n\n1 \\leq N,M \\leq 10^9\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\n\nOutput\n\nPrint the number of cards that face down after all the operations.\n\nSample Input 1\n\n2 2\n\nSample Output 1\n\n0\n\nWe will flip every card in any of the four operations. Thus, after all the operations, all cards face up.\n\nSample Input 2\n\n1 7\n\nSample Output 2\n\n5\n\nAfter all the operations, all cards except at both ends face down.\n\nSample Input 3\n\n314 1592\n\nSample Output 3\n\n496080", "sample_input": "2 2\n"}, "reference_outputs": ["0\n"], "source_document_id": "p03417", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere is a grid with infinitely many rows and columns. In this grid, there is a rectangular region with consecutive N rows and M columns, and a card is placed in each square in this region.\nThe front and back sides of these cards can be distinguished, and initially every card faces up.\n\nWe will perform the following operation once for each square contains a card:\n\nFor each of the following nine squares, flip the card in it if it exists: the target square itself and the eight squares that shares a corner or a side with the target square.\n\nIt can be proved that, whether each card faces up or down after all the operations does not depend on the order the operations are performed.\nFind the number of cards that face down after all the operations.\n\nConstraints\n\n1 \\leq N,M \\leq 10^9\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\n\nOutput\n\nPrint the number of cards that face down after all the operations.\n\nSample Input 1\n\n2 2\n\nSample Output 1\n\n0\n\nWe will flip every card in any of the four operations. Thus, after all the operations, all cards face up.\n\nSample Input 2\n\n1 7\n\nSample Output 2\n\n5\n\nAfter all the operations, all cards except at both ends face down.\n\nSample Input 3\n\n314 1592\n\nSample Output 3\n\n496080", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s848711877", "group_id": "codeNet:p03418", "input_text": "Scanf.scanf \"%d %d\" (fun n k ->\n let rec loop b acc =\n if b > n then acc else\n let m = n / b in\n let r = n - m * b in\n let acc = acc + m * (b - k) + if k = 0 then max 0 (r - k) else max 0 (r - k + 1) in\n loop (b + 1) acc\n in\n loop (k + 1) 0 |> Printf.printf \"%d\\n\"\n)", "language": "OCaml", "metadata": {"date": 1598243532, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p03418.html", "problem_id": "p03418", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03418/input.txt", "sample_output_relpath": "derived/input_output/data/p03418/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03418/OCaml/s848711877.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s848711877", "user_id": "u342443598"}, "prompt_components": {"gold_output": "7\n", "input_to_evaluate": "Scanf.scanf \"%d %d\" (fun n k ->\n let rec loop b acc =\n if b > n then acc else\n let m = n / b in\n let r = n - m * b in\n let acc = acc + m * (b - k) + if k = 0 then max 0 (r - k) else max 0 (r - k + 1) in\n loop (b + 1) acc\n in\n loop (k + 1) 0 |> Printf.printf \"%d\\n\"\n)", "problem_context": "Score : 400 points\n\nProblem Statement\n\nTakahashi had a pair of two positive integers not exceeding N, (a,b), which he has forgotten.\nHe remembers that the remainder of a divided by b was greater than or equal to K.\nFind the number of possible pairs that he may have had.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n0 \\leq K \\leq N-1\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\n\nOutput\n\nPrint the number of possible pairs that he may have had.\n\nSample Input 1\n\n5 2\n\nSample Output 1\n\n7\n\nThere are seven possible pairs: (2,3),(5,3),(2,4),(3,4),(2,5),(3,5) and (4,5).\n\nSample Input 2\n\n10 0\n\nSample Output 2\n\n100\n\nSample Input 3\n\n31415 9265\n\nSample Output 3\n\n287927211", "sample_input": "5 2\n"}, "reference_outputs": ["7\n"], "source_document_id": "p03418", "source_text": "Score : 400 points\n\nProblem Statement\n\nTakahashi had a pair of two positive integers not exceeding N, (a,b), which he has forgotten.\nHe remembers that the remainder of a divided by b was greater than or equal to K.\nFind the number of possible pairs that he may have had.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n0 \\leq K \\leq N-1\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\n\nOutput\n\nPrint the number of possible pairs that he may have had.\n\nSample Input 1\n\n5 2\n\nSample Output 1\n\n7\n\nThere are seven possible pairs: (2,3),(5,3),(2,4),(3,4),(2,5),(3,5) and (4,5).\n\nSample Input 2\n\n10 0\n\nSample Output 2\n\n100\n\nSample Input 3\n\n31415 9265\n\nSample Output 3\n\n287927211", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 12, "memory_kb": 3792}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s735314158", "group_id": "codeNet:p03423", "input_text": "let id x = x\n\ntype v = T | F\n\nlet rec slv = function\n\t| 0 -> T\n\t| n -> if (Scanf.scanf \"%c\" id) = 'Y' then F else slv (n-1)\n\nlet () =\n\tlet n = Scanf.scanf \"%d\\n\" id in\n\tmatch slv n with\n\t| F -> print_string \"Four\"\n\t| T -> print_string \"Three\"\n", "language": "OCaml", "metadata": {"date": 1520752641, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03423.html", "problem_id": "p03423", "resource_group": "low_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/OCaml/s735314158.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s735314158", "user_id": "u604818425"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "let id x = x\n\ntype v = T | F\n\nlet rec slv = function\n\t| 0 -> T\n\t| n -> if (Scanf.scanf \"%c\" id) = 'Y' then F else slv (n-1)\n\nlet () =\n\tlet n = Scanf.scanf \"%d\\n\" id in\n\tmatch slv n with\n\t| F -> print_string \"Four\"\n\t| T -> print_string \"Three\"\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nThere are N students in a school.\n\nWe will divide these students into some groups, and in each group they will discuss some themes.\n\nYou think that groups consisting of two or less students cannot have an effective discussion, so you want to have as many groups consisting of three or more students as possible.\n\nDivide the students so that the number of groups consisting of three or more students is maximized.\n\nConstraints\n\n1 \\leq N \\leq 1000\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nIf you can form at most x groups consisting of three or more students, print x.\n\nSample Input 1\n\n8\n\nSample Output 1\n\n2\n\nFor example, you can form a group of three students and another of five students.\n\nSample Input 2\n\n2\n\nSample Output 2\n\n0\n\nSometimes you cannot form any group consisting of three or more students, regardless of how you divide the students.\n\nSample Input 3\n\n9\n\nSample Output 3\n\n3", "sample_input": "8\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03423", "source_text": "Score : 100 points\n\nProblem Statement\n\nThere are N students in a school.\n\nWe will divide these students into some groups, and in each group they will discuss some themes.\n\nYou think that groups consisting of two or less students cannot have an effective discussion, so you want to have as many groups consisting of three or more students as possible.\n\nDivide the students so that the number of groups consisting of three or more students is maximized.\n\nConstraints\n\n1 \\leq N \\leq 1000\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nIf you can form at most x groups consisting of three or more students, print x.\n\nSample Input 1\n\n8\n\nSample Output 1\n\n2\n\nFor example, you can form a group of three students and another of five students.\n\nSample Input 2\n\n2\n\nSample Output 2\n\n0\n\nSometimes you cannot form any group consisting of three or more students, regardless of how you divide the students.\n\nSample Input 3\n\n9\n\nSample Output 3\n\n3", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 243, "cpu_time_ms": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s529094687", "group_id": "codeNet:p03424", "input_text": "open Batteries;;\nlet _ = read_line () in\nlet l = read_line () |> String.split_on_char ' ' in \nprint_string (if List.mem \"Y\" l then \"Four\" else \"Three\") \n;;\n", "language": "OCaml", "metadata": {"date": 1520216267, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03424.html", "problem_id": "p03424", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03424/input.txt", "sample_output_relpath": "derived/input_output/data/p03424/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03424/OCaml/s529094687.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s529094687", "user_id": "u161156777"}, "prompt_components": {"gold_output": "Four\n", "input_to_evaluate": "open Batteries;;\nlet _ = read_line () in\nlet l = read_line () |> String.split_on_char ' ' in \nprint_string (if List.mem \"Y\" l then \"Four\" else \"Three\") \n;;\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nIn Japan, people make offerings called hina arare, colorful crackers, on March 3.\n\nWe have a bag that contains N hina arare. (From here, we call them arare.)\n\nIt is known that the bag either contains arare in three colors: pink, white and green, or contains arare in four colors: pink, white, green and yellow.\n\nWe have taken out the arare in the bag one by one, and the color of the i-th arare was S_i, where colors are represented as follows - pink: P, white: W, green: G, yellow: Y.\n\nIf the number of colors of the arare in the bag was three, print Three; if the number of colors was four, print Four.\n\nConstraints\n\n1 \\leq N \\leq 100\n\nS_i is P, W, G or Y.\n\nThere always exist i, j and k such that S_i=P, S_j=W and S_k=G.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS_1 S_2 ... S_N\n\nOutput\n\nIf the number of colors of the arare in the bag was three, print Three; if the number of colors was four, print Four.\n\nSample Input 1\n\n6\nG W Y P Y W\n\nSample Output 1\n\nFour\n\nThe bag contained arare in four colors, so you should print Four.\n\nSample Input 2\n\n9\nG W W G P W P G G\n\nSample Output 2\n\nThree\n\nThe bag contained arare in three colors, so you should print Three.\n\nSample Input 3\n\n8\nP Y W G Y W Y Y\n\nSample Output 3\n\nFour", "sample_input": "6\nG W Y P Y W\n"}, "reference_outputs": ["Four\n"], "source_document_id": "p03424", "source_text": "Score : 200 points\n\nProblem Statement\n\nIn Japan, people make offerings called hina arare, colorful crackers, on March 3.\n\nWe have a bag that contains N hina arare. (From here, we call them arare.)\n\nIt is known that the bag either contains arare in three colors: pink, white and green, or contains arare in four colors: pink, white, green and yellow.\n\nWe have taken out the arare in the bag one by one, and the color of the i-th arare was S_i, where colors are represented as follows - pink: P, white: W, green: G, yellow: Y.\n\nIf the number of colors of the arare in the bag was three, print Three; if the number of colors was four, print Four.\n\nConstraints\n\n1 \\leq N \\leq 100\n\nS_i is P, W, G or Y.\n\nThere always exist i, j and k such that S_i=P, S_j=W and S_k=G.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS_1 S_2 ... S_N\n\nOutput\n\nIf the number of colors of the arare in the bag was three, print Three; if the number of colors was four, print Four.\n\nSample Input 1\n\n6\nG W Y P Y W\n\nSample Output 1\n\nFour\n\nThe bag contained arare in four colors, so you should print Four.\n\nSample Input 2\n\n9\nG W W G P W P G G\n\nSample Output 2\n\nThree\n\nThe bag contained arare in three colors, so you should print Three.\n\nSample Input 3\n\n8\nP Y W G Y W Y Y\n\nSample Output 3\n\nFour", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 2, "memory_kb": 1152}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s487101038", "group_id": "codeNet:p03425", "input_text": "let rec comb n xs =\n match n, xs with\n | 0, _ -> [[]]\n | _, [] -> []\n | n, x :: xs ->\n List.map (fun ys -> x :: ys) (comb (n - 1) xs) @ comb n xs\n\nlet () =\n let n = Scanf.scanf \"%d\\n\" (fun n -> n) in\n let ss = Array.init n (fun _ -> Scanf.scanf \"%s\\n\" (fun s -> s)) in\n Array.fold_left (fun [m; a; r; c; h] s ->\n match s.[0] with\n | 'M' -> [m + 1; a; r; c; h]\n | 'A' -> [m; a + 1; r; c; h]\n | 'R' -> [m; a; r + 1; c; h]\n | 'C' -> [m; a; r; c + 1; h]\n | 'H' -> [m; a; r; c; h + 1]\n | _ -> [m; a; r; c; h]) [0; 0; 0; 0; 0] ss\n |> comb 3\n |> List.map (List.fold_left ( * ) 1)\n |> List.fold_left ( + ) 0\n |> Printf.printf \"%d\\n\"", "language": "OCaml", "metadata": {"date": 1520217646, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03425.html", "problem_id": "p03425", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03425/input.txt", "sample_output_relpath": "derived/input_output/data/p03425/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03425/OCaml/s487101038.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s487101038", "user_id": "u504158101"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "let rec comb n xs =\n match n, xs with\n | 0, _ -> [[]]\n | _, [] -> []\n | n, x :: xs ->\n List.map (fun ys -> x :: ys) (comb (n - 1) xs) @ comb n xs\n\nlet () =\n let n = Scanf.scanf \"%d\\n\" (fun n -> n) in\n let ss = Array.init n (fun _ -> Scanf.scanf \"%s\\n\" (fun s -> s)) in\n Array.fold_left (fun [m; a; r; c; h] s ->\n match s.[0] with\n | 'M' -> [m + 1; a; r; c; h]\n | 'A' -> [m; a + 1; r; c; h]\n | 'R' -> [m; a; r + 1; c; h]\n | 'C' -> [m; a; r; c + 1; h]\n | 'H' -> [m; a; r; c; h + 1]\n | _ -> [m; a; r; c; h]) [0; 0; 0; 0; 0] ss\n |> comb 3\n |> List.map (List.fold_left ( * ) 1)\n |> List.fold_left ( + ) 0\n |> Printf.printf \"%d\\n\"", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere are N people. The name of the i-th person is S_i.\n\nWe would like to choose three people so that the following conditions are met:\n\nThe name of every chosen person begins with M, A, R, C or H.\n\nThere are no multiple people whose names begin with the same letter.\n\nHow many such ways are there to choose three people, disregarding order?\n\nNote that the answer may not fit into a 32-bit integer type.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\nS_i consists of uppercase English letters.\n\n1 \\leq |S_i| \\leq 10\n\nS_i \\neq S_j (i \\neq j)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS_1\n:\nS_N\n\nOutput\n\nIf there are x ways to choose three people so that the given conditions are met, print x.\n\nSample Input 1\n\n5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI\n\nSample Output 1\n\n2\n\nWe can choose three people with the following names:\n\nMASHIKE, RUMOI, HABORO\n\nMASHIKE, RUMOI, HOROKANAI\n\nThus, we have two ways.\n\nSample Input 2\n\n4\nZZ\nZZZ\nZ\nZZZZZZZZZZ\n\nSample Output 2\n\n0\n\nNote that there may be no ways to choose three people so that the given conditions are met.\n\nSample Input 3\n\n5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO\n\nSample Output 3\n\n7", "sample_input": "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03425", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere are N people. The name of the i-th person is S_i.\n\nWe would like to choose three people so that the following conditions are met:\n\nThe name of every chosen person begins with M, A, R, C or H.\n\nThere are no multiple people whose names begin with the same letter.\n\nHow many such ways are there to choose three people, disregarding order?\n\nNote that the answer may not fit into a 32-bit integer type.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\nS_i consists of uppercase English letters.\n\n1 \\leq |S_i| \\leq 10\n\nS_i \\neq S_j (i \\neq j)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nS_1\n:\nS_N\n\nOutput\n\nIf there are x ways to choose three people so that the given conditions are met, print x.\n\nSample Input 1\n\n5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI\n\nSample Output 1\n\n2\n\nWe can choose three people with the following names:\n\nMASHIKE, RUMOI, HABORO\n\nMASHIKE, RUMOI, HOROKANAI\n\nThus, we have two ways.\n\nSample Input 2\n\n4\nZZ\nZZZ\nZ\nZZZZZZZZZZ\n\nSample Output 2\n\n0\n\nNote that there may be no ways to choose three people so that the given conditions are met.\n\nSample Input 3\n\n5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO\n\nSample Output 3\n\n7", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 661, "cpu_time_ms": 31, "memory_kb": 6784}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s459020836", "group_id": "codeNet:p03426", "input_text": "\nopen Scanf\nopen Printf\n\nlet flip f x y = f y x\n\nlet rec range a b = if a >= b then [] else a :: range (a+1) b\n\nlet read_int () = scanf \" %d\" (fun x -> x)\nlet rec read_ints n = if n = 0 then [] else let i = read_int () in i :: read_ints (n-1)\n\nlet rec for_iter a b f = if a >= b then [] else let x = f a in x :: for_iter (a+1) b f\nlet rec for_iter_ a b f = if a >= b then () else (f a; for_iter_ (a+1) b f)\n\nlet list_of_string str = range 0 (String.length str) |> List.map (fun i -> str.[i])\nlet array_of_string str = Array.init (String.length str) (fun i -> str.[i])\n\nlet () =\n let h, w, d = scanf \"%d %d %d\" (fun a b c -> a, b, c) in\n let arr = Array.init h (fun _ -> Array.init w (fun _ -> scanf \" %d\" (fun x -> x))) in\n let qs = scanf \" %d\" (fun q -> Array.init q (fun _ -> scanf \" %d %d\" (fun x y -> x, y))) in\n let ps = Array.make (h*w+1) (-1, -1) in\n let cs = Array.make (h*w+1) (h*w) in\n\n for_iter_ 0 h (fun x -> for_iter_ 0 w (fun y -> ps.(arr.(x).(y)) <- (x, y)));\n\n for_iter_ 0 d (fun i -> cs.(i) <- 0);\n for_iter_ d (h*w+1) (fun i ->\n let (x, y) = ps.(i) in let (x', y') = ps.(i-d) in\n cs.(i) <- cs.(i-d) + abs (x-x') + abs (y-y'));\n\n qs\n |> Array.map (fun (i, j) -> cs.(j) - cs.(i))\n |> Array.iter (printf \"%d\\n\")\n\n", "language": "OCaml", "metadata": {"date": 1520216656, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03426.html", "problem_id": "p03426", "resource_group": "low_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/OCaml/s459020836.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s459020836", "user_id": "u798181098"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "\nopen Scanf\nopen Printf\n\nlet flip f x y = f y x\n\nlet rec range a b = if a >= b then [] else a :: range (a+1) b\n\nlet read_int () = scanf \" %d\" (fun x -> x)\nlet rec read_ints n = if n = 0 then [] else let i = read_int () in i :: read_ints (n-1)\n\nlet rec for_iter a b f = if a >= b then [] else let x = f a in x :: for_iter (a+1) b f\nlet rec for_iter_ a b f = if a >= b then () else (f a; for_iter_ (a+1) b f)\n\nlet list_of_string str = range 0 (String.length str) |> List.map (fun i -> str.[i])\nlet array_of_string str = Array.init (String.length str) (fun i -> str.[i])\n\nlet () =\n let h, w, d = scanf \"%d %d %d\" (fun a b c -> a, b, c) in\n let arr = Array.init h (fun _ -> Array.init w (fun _ -> scanf \" %d\" (fun x -> x))) in\n let qs = scanf \" %d\" (fun q -> Array.init q (fun _ -> scanf \" %d %d\" (fun x y -> x, y))) in\n let ps = Array.make (h*w+1) (-1, -1) in\n let cs = Array.make (h*w+1) (h*w) in\n\n for_iter_ 0 h (fun x -> for_iter_ 0 w (fun y -> ps.(arr.(x).(y)) <- (x, y)));\n\n for_iter_ 0 d (fun i -> cs.(i) <- 0);\n for_iter_ d (h*w+1) (fun i ->\n let (x, y) = ps.(i) in let (x', y') = ps.(i-d) in\n cs.(i) <- cs.(i-d) + abs (x-x') + abs (y-y'));\n\n qs\n |> Array.map (fun (i, j) -> cs.(j) - cs.(i))\n |> Array.iter (printf \"%d\\n\")\n\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nWe have a grid with H rows and W columns. The square at the i-th row and the j-th column will be called Square (i,j).\n\nThe integers from 1 through H×W are written throughout the grid, and the integer written in Square (i,j) is A_{i,j}.\n\nYou, a magical girl, can teleport a piece placed on Square (i,j) to Square (x,y) by consuming |x-i|+|y-j| magic points.\n\nYou now have to take Q practical tests of your ability as a magical girl.\n\nThe i-th test will be conducted as follows:\n\nInitially, a piece is placed on the square where the integer L_i is written.\n\nLet x be the integer written in the square occupied by the piece. Repeatedly move the piece to the square where the integer x+D is written, as long as x is not R_i. The test ends when x=R_i.\n\nHere, it is guaranteed that R_i-L_i is a multiple of D.\n\nFor each test, find the sum of magic points consumed during that test.\n\nConstraints\n\n1 \\leq H,W \\leq 300\n\n1 \\leq D \\leq H×W\n\n1 \\leq A_{i,j} \\leq H×W\n\nA_{i,j} \\neq A_{x,y} ((i,j) \\neq (x,y))\n\n1 \\leq Q \\leq 10^5\n\n1 \\leq L_i \\leq R_i \\leq H×W\n\n(R_i-L_i) is a multiple of D.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W D\nA_{1,1} A_{1,2} ... A_{1,W}\n:\nA_{H,1} A_{H,2} ... A_{H,W}\nQ\nL_1 R_1\n:\nL_Q R_Q\n\nOutput\n\nFor each test, print the sum of magic points consumed during that test.\n\nOutput should be in the order the tests are conducted.\n\nSample Input 1\n\n3 3 2\n1 4 3\n2 5 7\n8 9 6\n1\n4 8\n\nSample Output 1\n\n5\n\n4 is written in Square (1,2).\n\n6 is written in Square (3,3).\n\n8 is written in Square (3,1).\n\nThus, the sum of magic points consumed during the first test is (|3-1|+|3-2|)+(|3-3|+|1-3|)=5.\n\nSample Input 2\n\n4 2 3\n3 7\n1 4\n5 2\n6 8\n2\n2 2\n2 2\n\nSample Output 2\n\n0\n0\n\nNote that there may be a test where the piece is not moved at all, and there may be multiple identical tests.\n\nSample Input 3\n\n5 5 4\n13 25 7 15 17\n16 22 20 2 9\n14 11 12 1 19\n10 6 23 8 18\n3 21 5 24 4\n3\n13 13\n2 10\n13 13\n\nSample Output 3\n\n0\n5\n0", "sample_input": "3 3 2\n1 4 3\n2 5 7\n8 9 6\n1\n4 8\n"}, "reference_outputs": ["5\n"], "source_document_id": "p03426", "source_text": "Score : 400 points\n\nProblem Statement\n\nWe have a grid with H rows and W columns. The square at the i-th row and the j-th column will be called Square (i,j).\n\nThe integers from 1 through H×W are written throughout the grid, and the integer written in Square (i,j) is A_{i,j}.\n\nYou, a magical girl, can teleport a piece placed on Square (i,j) to Square (x,y) by consuming |x-i|+|y-j| magic points.\n\nYou now have to take Q practical tests of your ability as a magical girl.\n\nThe i-th test will be conducted as follows:\n\nInitially, a piece is placed on the square where the integer L_i is written.\n\nLet x be the integer written in the square occupied by the piece. Repeatedly move the piece to the square where the integer x+D is written, as long as x is not R_i. The test ends when x=R_i.\n\nHere, it is guaranteed that R_i-L_i is a multiple of D.\n\nFor each test, find the sum of magic points consumed during that test.\n\nConstraints\n\n1 \\leq H,W \\leq 300\n\n1 \\leq D \\leq H×W\n\n1 \\leq A_{i,j} \\leq H×W\n\nA_{i,j} \\neq A_{x,y} ((i,j) \\neq (x,y))\n\n1 \\leq Q \\leq 10^5\n\n1 \\leq L_i \\leq R_i \\leq H×W\n\n(R_i-L_i) is a multiple of D.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W D\nA_{1,1} A_{1,2} ... A_{1,W}\n:\nA_{H,1} A_{H,2} ... A_{H,W}\nQ\nL_1 R_1\n:\nL_Q R_Q\n\nOutput\n\nFor each test, print the sum of magic points consumed during that test.\n\nOutput should be in the order the tests are conducted.\n\nSample Input 1\n\n3 3 2\n1 4 3\n2 5 7\n8 9 6\n1\n4 8\n\nSample Output 1\n\n5\n\n4 is written in Square (1,2).\n\n6 is written in Square (3,3).\n\n8 is written in Square (3,1).\n\nThus, the sum of magic points consumed during the first test is (|3-1|+|3-2|)+(|3-3|+|1-3|)=5.\n\nSample Input 2\n\n4 2 3\n3 7\n1 4\n5 2\n6 8\n2\n2 2\n2 2\n\nSample Output 2\n\n0\n0\n\nNote that there may be a test where the piece is not moved at all, and there may be multiple identical tests.\n\nSample Input 3\n\n5 5 4\n13 25 7 15 17\n16 22 20 2 9\n14 11 12 1 19\n10 6 23 8 18\n3 21 5 24 4\n3\n13 13\n2 10\n13 13\n\nSample Output 3\n\n0\n5\n0", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1245, "cpu_time_ms": 104, "memory_kb": 12544}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s372839143", "group_id": "codeNet:p03427", "input_text": "let n = read_int ()\nlet rec f n i j = if n < 10 then j else f (n / 10) (i + 1) @@ if n mod 10 = 9 then j else i + 1\nlet rec g s n i j = if n = 0 then s else g (s + if i = j then n mod 10 - 1 else if i > j then n mod 10 else 9) (n / 10) (i + 1) j\nlet j = f n 0 ~-1\nlet _ = Printf.printf \"%d\\n\" @@ if j = -1 then n else g 0 n 0 j", "language": "OCaml", "metadata": {"date": 1571826531, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03427.html", "problem_id": "p03427", "resource_group": "low_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/OCaml/s372839143.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s372839143", "user_id": "u732304692"}, "prompt_components": {"gold_output": "18\n", "input_to_evaluate": "let n = read_int ()\nlet rec f n i j = if n < 10 then j else f (n / 10) (i + 1) @@ if n mod 10 = 9 then j else i + 1\nlet rec g s n i j = if n = 0 then s else g (s + if i = j then n mod 10 - 1 else if i > j then n mod 10 else 9) (n / 10) (i + 1) j\nlet j = f n 0 ~-1\nlet _ = Printf.printf \"%d\\n\" @@ if j = -1 then n else g 0 n 0 j", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 327, "cpu_time_ms": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s751796748", "group_id": "codeNet:p03428", "input_text": "let () = Scanf.scanf \"%d\\n\" @@ fun n ->\n let xys = Array.init n @@ fun i ->\n Scanf.scanf \"%d %d\\n\" @@ fun x y -> i, x, y in\n let (i, px, py), rest = Array.fold_left (fun ((i, x, y), acc) (j, x', y') ->\n if y <= y'\n then ((i, x, y), (j, x', y') :: acc)\n else ((j, x', y'), (i, x, y) :: acc)) (xys.(0), []) @@ Array.sub xys 1 (n - 1) in\n let convex =\n Array.of_list @@\n List.fold_left (fun stack (i, x, y) ->\n let rec drop = function\n | ([] | [_]) as stack -> stack\n | ((_, x1, y1) :: (((_, x2, y2) :: _) as rest)) as stack ->\n if (x2 - x1) * (y - y1) - (y2 - y1) * (x - x1) <= 0\n then stack\n else drop rest in (i, x, y) :: drop stack) [(i, px, py)] @@\n List.sort (fun (_, x, y) (_, x', y') ->\n compare\n (x <= px, (y - py) * (x' - px))\n (x' <= px, (y' - py) * (x - px))) rest in\n let ps = Array.make n 0. in\n for i = 0 to Array.length convex - 1 do\n let (_, x1, y1) = convex.(i) in\n let (j, x2, y2) = convex.((i + 1) mod Array.length convex) in\n let (_, x3, y3) = convex.((i + 2) mod Array.length convex) in\n ps.(j) <-\n 0.5 -. acos\n (float_of_int ((x1 - x2) * (x3 - x2) + (y1 - y2) * (y3 - y2)) /.\n sqrt\n ((float_of_int (x1 - x2) ** 2. +. float_of_int (y1 - y2) ** 2.) *.\n (float_of_int (x3 - x2) ** 2. +. float_of_int (y3 - y2) ** 2.)))\n /. (8. *. atan 1.)\n done;\n Array.iter (Printf.printf \"%.20f\\n\") ps\n", "language": "OCaml", "metadata": {"date": 1537331491, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03428.html", "problem_id": "p03428", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03428/input.txt", "sample_output_relpath": "derived/input_output/data/p03428/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03428/OCaml/s751796748.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s751796748", "user_id": "u504158101"}, "prompt_components": {"gold_output": "0.5\n0.5\n", "input_to_evaluate": "let () = Scanf.scanf \"%d\\n\" @@ fun n ->\n let xys = Array.init n @@ fun i ->\n Scanf.scanf \"%d %d\\n\" @@ fun x y -> i, x, y in\n let (i, px, py), rest = Array.fold_left (fun ((i, x, y), acc) (j, x', y') ->\n if y <= y'\n then ((i, x, y), (j, x', y') :: acc)\n else ((j, x', y'), (i, x, y) :: acc)) (xys.(0), []) @@ Array.sub xys 1 (n - 1) in\n let convex =\n Array.of_list @@\n List.fold_left (fun stack (i, x, y) ->\n let rec drop = function\n | ([] | [_]) as stack -> stack\n | ((_, x1, y1) :: (((_, x2, y2) :: _) as rest)) as stack ->\n if (x2 - x1) * (y - y1) - (y2 - y1) * (x - x1) <= 0\n then stack\n else drop rest in (i, x, y) :: drop stack) [(i, px, py)] @@\n List.sort (fun (_, x, y) (_, x', y') ->\n compare\n (x <= px, (y - py) * (x' - px))\n (x' <= px, (y' - py) * (x - px))) rest in\n let ps = Array.make n 0. in\n for i = 0 to Array.length convex - 1 do\n let (_, x1, y1) = convex.(i) in\n let (j, x2, y2) = convex.((i + 1) mod Array.length convex) in\n let (_, x3, y3) = convex.((i + 2) mod Array.length convex) in\n ps.(j) <-\n 0.5 -. acos\n (float_of_int ((x1 - x2) * (x3 - x2) + (y1 - y2) * (y3 - y2)) /.\n sqrt\n ((float_of_int (x1 - x2) ** 2. +. float_of_int (y1 - y2) ** 2.) *.\n (float_of_int (x3 - x2) ** 2. +. float_of_int (y3 - y2) ** 2.)))\n /. (8. *. atan 1.)\n done;\n Array.iter (Printf.printf \"%.20f\\n\") ps\n", "problem_context": "Score : 600 points\n\nProblem Statement\n\nThere are N holes in a two-dimensional plane. The coordinates of the i-th hole are (x_i,y_i).\n\nLet R=10^{10^{10^{10}}}. Ringo performs the following operation:\n\nRandomly choose a point from the interior of a circle of radius R centered at the origin, and put Snuke there. Snuke will move to the hole with the smallest Euclidean distance from the point, and fall into that hole. If there are multiple such holes, the hole with the smallest index will be chosen.\n\nFor every i (1 \\leq i \\leq N), find the probability that Snuke falls into the i-th hole.\n\nHere, the operation of randomly choosing a point from the interior of a circle of radius R is defined as follows:\n\nPick two real numbers x and y independently according to uniform distribution on [-R,R].\n\nIf x^2+y^2\\leq R^2, the point (x,y) is chosen. Otherwise, repeat picking the real numbers x,y until the condition is met.\n\nConstraints\n\n2 \\leq N \\leq 100\n\n|x_i|,|y_i| \\leq 10^6(1\\leq i\\leq N)\n\nAll given points are pairwise distinct.\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nx_1 y_1\n:\nx_N y_N\n\nOutput\n\nPrint N real numbers. The i-th real number must represent the probability that Snuke falls into the i-th hole.\n\nThe output will be judged correct when, for all output values, the absolute or relative error is at most 10^{-5}.\n\nSample Input 1\n\n2\n0 0\n1 1\n\nSample Output 1\n\n0.5\n0.5\n\nIf Ringo put Snuke in the region x+y\\leq 1, Snuke will fall into the first hole. The probability of this happening is very close to 0.5.\nOtherwise, Snuke will fall into the second hole, the probability of which happening is also very close to 0.5.\n\nSample Input 2\n\n5\n0 0\n2 8\n4 5\n2 6\n3 10\n\nSample Output 2\n\n0.43160120892732328768\n0.03480224363653196956\n0.13880483535586193855\n0.00000000000000000000\n0.39479171208028279727", "sample_input": "2\n0 0\n1 1\n"}, "reference_outputs": ["0.5\n0.5\n"], "source_document_id": "p03428", "source_text": "Score : 600 points\n\nProblem Statement\n\nThere are N holes in a two-dimensional plane. The coordinates of the i-th hole are (x_i,y_i).\n\nLet R=10^{10^{10^{10}}}. Ringo performs the following operation:\n\nRandomly choose a point from the interior of a circle of radius R centered at the origin, and put Snuke there. Snuke will move to the hole with the smallest Euclidean distance from the point, and fall into that hole. If there are multiple such holes, the hole with the smallest index will be chosen.\n\nFor every i (1 \\leq i \\leq N), find the probability that Snuke falls into the i-th hole.\n\nHere, the operation of randomly choosing a point from the interior of a circle of radius R is defined as follows:\n\nPick two real numbers x and y independently according to uniform distribution on [-R,R].\n\nIf x^2+y^2\\leq R^2, the point (x,y) is chosen. Otherwise, repeat picking the real numbers x,y until the condition is met.\n\nConstraints\n\n2 \\leq N \\leq 100\n\n|x_i|,|y_i| \\leq 10^6(1\\leq i\\leq N)\n\nAll given points are pairwise distinct.\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nx_1 y_1\n:\nx_N y_N\n\nOutput\n\nPrint N real numbers. The i-th real number must represent the probability that Snuke falls into the i-th hole.\n\nThe output will be judged correct when, for all output values, the absolute or relative error is at most 10^{-5}.\n\nSample Input 1\n\n2\n0 0\n1 1\n\nSample Output 1\n\n0.5\n0.5\n\nIf Ringo put Snuke in the region x+y\\leq 1, Snuke will fall into the first hole. The probability of this happening is very close to 0.5.\nOtherwise, Snuke will fall into the second hole, the probability of which happening is also very close to 0.5.\n\nSample Input 2\n\n5\n0 0\n2 8\n4 5\n2 6\n3 10\n\nSample Output 2\n\n0.43160120892732328768\n0.03480224363653196956\n0.13880483535586193855\n0.00000000000000000000\n0.39479171208028279727", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1461, "cpu_time_ms": 7, "memory_kb": 768}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s398902256", "group_id": "codeNet:p03433", "input_text": "let n = read_int ()\nlet a = read_int ()\n\nlet result = if a <= (n mod 500) then \"Yes\" else \"No\"\n\nlet () = print_string result", "language": "OCaml", "metadata": {"date": 1581224318, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03433.html", "problem_id": "p03433", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03433/input.txt", "sample_output_relpath": "derived/input_output/data/p03433/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03433/OCaml/s398902256.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s398902256", "user_id": "u818201294"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "let n = read_int ()\nlet a = read_int ()\n\nlet result = if a <= (n mod 500) then \"Yes\" else \"No\"\n\nlet () = print_string result", "problem_context": "Score: 100 points\n\nProblem Statement\n\nE869120 has A 1-yen coins and infinitely many 500-yen coins.\n\nDetermine if he can pay exactly N yen using only these coins.\n\nConstraints\n\nN is an integer between 1 and 10000 (inclusive).\n\nA is an integer between 0 and 1000 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA\n\nOutput\n\nIf E869120 can pay exactly N yen using only his 1-yen and 500-yen coins, print Yes; otherwise, print No.\n\nSample Input 1\n\n2018\n218\n\nSample Output 1\n\nYes\n\nWe can pay 2018 yen with four 500-yen coins and 18 1-yen coins, so the answer is Yes.\n\nSample Input 2\n\n2763\n0\n\nSample Output 2\n\nNo\n\nWhen we have no 1-yen coins, we can only pay a multiple of 500 yen using only 500-yen coins. Since 2763 is not a multiple of 500, we cannot pay this amount.\n\nSample Input 3\n\n37\n514\n\nSample Output 3\n\nYes", "sample_input": "2018\n218\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03433", "source_text": "Score: 100 points\n\nProblem Statement\n\nE869120 has A 1-yen coins and infinitely many 500-yen coins.\n\nDetermine if he can pay exactly N yen using only these coins.\n\nConstraints\n\nN is an integer between 1 and 10000 (inclusive).\n\nA is an integer between 0 and 1000 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA\n\nOutput\n\nIf E869120 can pay exactly N yen using only his 1-yen and 500-yen coins, print Yes; otherwise, print No.\n\nSample Input 1\n\n2018\n218\n\nSample Output 1\n\nYes\n\nWe can pay 2018 yen with four 500-yen coins and 18 1-yen coins, so the answer is Yes.\n\nSample Input 2\n\n2763\n0\n\nSample Output 2\n\nNo\n\nWhen we have no 1-yen coins, we can only pay a multiple of 500 yen using only 500-yen coins. Since 2763 is not a multiple of 500, we cannot pay this amount.\n\nSample Input 3\n\n37\n514\n\nSample Output 3\n\nYes", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s341675283", "group_id": "codeNet:p03433", "input_text": "let f n = n mod 500\nlet g a m = if a < m then \"No\" else \"Yes\"\nlet () = f (read_int ()) |> g (read_int ()) |> print_endline", "language": "OCaml", "metadata": {"date": 1523252951, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03433.html", "problem_id": "p03433", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03433/input.txt", "sample_output_relpath": "derived/input_output/data/p03433/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03433/OCaml/s341675283.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s341675283", "user_id": "u987869509"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "let f n = n mod 500\nlet g a m = if a < m then \"No\" else \"Yes\"\nlet () = f (read_int ()) |> g (read_int ()) |> print_endline", "problem_context": "Score: 100 points\n\nProblem Statement\n\nE869120 has A 1-yen coins and infinitely many 500-yen coins.\n\nDetermine if he can pay exactly N yen using only these coins.\n\nConstraints\n\nN is an integer between 1 and 10000 (inclusive).\n\nA is an integer between 0 and 1000 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA\n\nOutput\n\nIf E869120 can pay exactly N yen using only his 1-yen and 500-yen coins, print Yes; otherwise, print No.\n\nSample Input 1\n\n2018\n218\n\nSample Output 1\n\nYes\n\nWe can pay 2018 yen with four 500-yen coins and 18 1-yen coins, so the answer is Yes.\n\nSample Input 2\n\n2763\n0\n\nSample Output 2\n\nNo\n\nWhen we have no 1-yen coins, we can only pay a multiple of 500 yen using only 500-yen coins. Since 2763 is not a multiple of 500, we cannot pay this amount.\n\nSample Input 3\n\n37\n514\n\nSample Output 3\n\nYes", "sample_input": "2018\n218\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03433", "source_text": "Score: 100 points\n\nProblem Statement\n\nE869120 has A 1-yen coins and infinitely many 500-yen coins.\n\nDetermine if he can pay exactly N yen using only these coins.\n\nConstraints\n\nN is an integer between 1 and 10000 (inclusive).\n\nA is an integer between 0 and 1000 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA\n\nOutput\n\nIf E869120 can pay exactly N yen using only his 1-yen and 500-yen coins, print Yes; otherwise, print No.\n\nSample Input 1\n\n2018\n218\n\nSample Output 1\n\nYes\n\nWe can pay 2018 yen with four 500-yen coins and 18 1-yen coins, so the answer is Yes.\n\nSample Input 2\n\n2763\n0\n\nSample Output 2\n\nNo\n\nWhen we have no 1-yen coins, we can only pay a multiple of 500 yen using only 500-yen coins. Since 2763 is not a multiple of 500, we cannot pay this amount.\n\nSample Input 3\n\n37\n514\n\nSample Output 3\n\nYes", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 2432}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s766240881", "group_id": "codeNet:p03435", "input_text": "let css = Array.init 3 @@ fun _ -> Array.init 3 @@ fun _ -> Scanf.scanf \" %d\" @@ (+) 0 in\nlet bs = Array.init 3 @@ fun i -> css.(0).(i) in\nlet a_s = Array.init 3 @@ fun i -> css.(i).(0) - bs.(0) in\nfor i = 0 to 2 do\n for j = 0 to 2 do\n if css.(i).(j) <> a_s.(i) + bs.(j) then begin print_endline \"No\"; exit 0 end\n done\ndone;\nprint_endline \"Yes\"", "language": "OCaml", "metadata": {"date": 1559614260, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03435.html", "problem_id": "p03435", "resource_group": "low_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/OCaml/s766240881.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s766240881", "user_id": "u732304692"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "let css = Array.init 3 @@ fun _ -> Array.init 3 @@ fun _ -> Scanf.scanf \" %d\" @@ (+) 0 in\nlet bs = Array.init 3 @@ fun i -> css.(0).(i) in\nlet a_s = Array.init 3 @@ fun i -> css.(i).(0) - bs.(0) in\nfor i = 0 to 2 do\n for j = 0 to 2 do\n if css.(i).(j) <> a_s.(i) + bs.(j) then begin print_endline \"No\"; exit 0 end\n done\ndone;\nprint_endline \"Yes\"", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 349, "cpu_time_ms": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s313462154", "group_id": "codeNet:p03436", "input_text": "open Batteries\nmodule EnumL = Enum.Labels\nmodule ListL = List.Labels\nmodule ArrayL = Array.Labels\n\nlet dbg0 x = Printf.eprintf \"[debug]%s\\n\" @@ dump x\nlet dbg1 x = dbg0 x; x\n\nlet id = identity\n\nlet (++) n m = List.range n `To m\nlet (++^) n m = if n < m then List.range n `To (pred m) else []\n\nlet scan fmt = Scanf.sscanf (read_line ()) fmt\n\nlet scan_lines n fmt f =\n if n = 0 then Enum.empty ()\n else\n List.map (fun _ -> scan fmt f) (1 ++ n)\n |> List.enum\n\nlet scan_list sep cnv =\n let line = read_line () in\n (match sep with\n | None -> List.map String.of_char @@ String.to_list line\n | Some sep -> String.split_on_char sep line)\n |> List.map cnv\n\nlet scan_array ?sep cnv = Array.of_list @@ scan_list sep cnv\n\nlet scan_matrix n m e ?sep conv =\n let arr = Array.make_matrix n m e in\n ListL.iter (0 ++^ n)\n ~f:(fun i -> arr.(i) <- Array.of_list @@ scan_list sep conv);\n arr\n\nlet rec powerset e =\n match Enum.get e with\n | None -> Enum.singleton @@ Enum.empty ()\n | Some v ->\n let f = powerset e in\n let g = Enum.clone f in\n EnumL.map f ~f:(fun x -> let y = Enum.clone x in push y v; y)\n |> Enum.append g\n\nlet permutations l =\n let rec aux l =\n let rec interleave x = function\n | [] -> [[x]]\n | (hd::tl) as lst ->\n (x::lst) ::\n (ListL.map ~f:(List.cons hd) @@ interleave x tl)\n in\n match l with\n | [] -> [[]]\n | hd::tl -> List.concat @@ List.map (interleave hd) @@ aux tl in\n let l = List.sort (List.compare Int.compare) @@ aux @@ List.of_enum l in\n List.enum % ListL.map ~f:List.enum @@ l\n\nlet intersection l =\n EnumL.filter ~f:(fun x -> EnumL.exists ~f:((=) x) @@ Enum.clone l)\n\nlet lower_bound n f =\n let rec aux l u =\n if u - l > 1 then\n let m = (l + u) / 2 in\n if f m then aux l m\n else aux m u\n else u in aux (-1) n\n\nlet between n x m = n <= x && x < m\n\nlet (h, w) = scan \"%d %d\" Tuple.Tuple2.make\nlet g = scan_matrix h w \".\" id\nlet m = Array.make_matrix h w (-1)\nlet ds = [(-1,0);(1,0);(0,-1);(0,1)]\n\nlet rec bfs visited queue =\n if Queue.is_empty queue then ()\n else\n let (i, j, n) = Queue.pop queue in\n if visited.(i).(j) then bfs visited queue\n else\n (visited.(i).(j) <- true;\n m.(i).(j) <- n;\n ListL.iter ds ~f:(fun (di, dj) ->\n let x, y = i + di, j + dj in\n if between 0 x h && between 0 y w && not visited.(x).(y)\n && g.(x).(y) = \".\" then\n Queue.push (x,y, succ n) queue);\n bfs visited queue)\n\nlet () =\n let visited = Array.make_matrix h w false in\n let q = Queue.create () in\n Queue.push (0,0,1) q;\n bfs visited q;\n let n = m.(h-1).(w-1) in\n (if n = -1 then -1\n else\n h*w -\n (ArrayL.map g\n ~f:(fun line ->\n ArrayL.filter line ~f:((=) \"#\")\n |> Array.length)\n |> Array.sum) - n)\n |> Printf.printf \"%d\\n\"\n", "language": "OCaml", "metadata": {"date": 1587916965, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03436.html", "problem_id": "p03436", "resource_group": "low_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/OCaml/s313462154.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s313462154", "user_id": "u802614675"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "open Batteries\nmodule EnumL = Enum.Labels\nmodule ListL = List.Labels\nmodule ArrayL = Array.Labels\n\nlet dbg0 x = Printf.eprintf \"[debug]%s\\n\" @@ dump x\nlet dbg1 x = dbg0 x; x\n\nlet id = identity\n\nlet (++) n m = List.range n `To m\nlet (++^) n m = if n < m then List.range n `To (pred m) else []\n\nlet scan fmt = Scanf.sscanf (read_line ()) fmt\n\nlet scan_lines n fmt f =\n if n = 0 then Enum.empty ()\n else\n List.map (fun _ -> scan fmt f) (1 ++ n)\n |> List.enum\n\nlet scan_list sep cnv =\n let line = read_line () in\n (match sep with\n | None -> List.map String.of_char @@ String.to_list line\n | Some sep -> String.split_on_char sep line)\n |> List.map cnv\n\nlet scan_array ?sep cnv = Array.of_list @@ scan_list sep cnv\n\nlet scan_matrix n m e ?sep conv =\n let arr = Array.make_matrix n m e in\n ListL.iter (0 ++^ n)\n ~f:(fun i -> arr.(i) <- Array.of_list @@ scan_list sep conv);\n arr\n\nlet rec powerset e =\n match Enum.get e with\n | None -> Enum.singleton @@ Enum.empty ()\n | Some v ->\n let f = powerset e in\n let g = Enum.clone f in\n EnumL.map f ~f:(fun x -> let y = Enum.clone x in push y v; y)\n |> Enum.append g\n\nlet permutations l =\n let rec aux l =\n let rec interleave x = function\n | [] -> [[x]]\n | (hd::tl) as lst ->\n (x::lst) ::\n (ListL.map ~f:(List.cons hd) @@ interleave x tl)\n in\n match l with\n | [] -> [[]]\n | hd::tl -> List.concat @@ List.map (interleave hd) @@ aux tl in\n let l = List.sort (List.compare Int.compare) @@ aux @@ List.of_enum l in\n List.enum % ListL.map ~f:List.enum @@ l\n\nlet intersection l =\n EnumL.filter ~f:(fun x -> EnumL.exists ~f:((=) x) @@ Enum.clone l)\n\nlet lower_bound n f =\n let rec aux l u =\n if u - l > 1 then\n let m = (l + u) / 2 in\n if f m then aux l m\n else aux m u\n else u in aux (-1) n\n\nlet between n x m = n <= x && x < m\n\nlet (h, w) = scan \"%d %d\" Tuple.Tuple2.make\nlet g = scan_matrix h w \".\" id\nlet m = Array.make_matrix h w (-1)\nlet ds = [(-1,0);(1,0);(0,-1);(0,1)]\n\nlet rec bfs visited queue =\n if Queue.is_empty queue then ()\n else\n let (i, j, n) = Queue.pop queue in\n if visited.(i).(j) then bfs visited queue\n else\n (visited.(i).(j) <- true;\n m.(i).(j) <- n;\n ListL.iter ds ~f:(fun (di, dj) ->\n let x, y = i + di, j + dj in\n if between 0 x h && between 0 y w && not visited.(x).(y)\n && g.(x).(y) = \".\" then\n Queue.push (x,y, succ n) queue);\n bfs visited queue)\n\nlet () =\n let visited = Array.make_matrix h w false in\n let q = Queue.create () in\n Queue.push (0,0,1) q;\n bfs visited q;\n let n = m.(h-1).(w-1) in\n (if n = -1 then -1\n else\n h*w -\n (ArrayL.map g\n ~f:(fun line ->\n ArrayL.filter line ~f:((=) \"#\")\n |> Array.length)\n |> Array.sum) - n)\n |> Printf.printf \"%d\\n\"\n", "problem_context": "Score: 400 points\n\nProblem statement\n\nWe have an H \\times W grid whose squares are painted black or white. The square at the i-th row from the top and the j-th column from the left is denoted as (i, j).\n\nSnuke would like to play the following game on this grid. At the beginning of the game, there is a character called Kenus at square (1, 1). The player repeatedly moves Kenus up, down, left or right by one square. The game is completed when Kenus reaches square (H, W) passing only white squares.\n\nBefore Snuke starts the game, he can change the color of some of the white squares to black. However, he cannot change the color of square (1, 1) and (H, W). Also, changes of color must all be carried out before the beginning of the game.\n\nWhen the game is completed, Snuke's score will be the number of times he changed the color of a square before the beginning of the game. Find the maximum possible score that Snuke can achieve, or print -1 if the game cannot be completed, that is, Kenus can never reach square (H, W) regardless of how Snuke changes the color of the squares.\n\nThe color of the squares are given to you as characters s_{i, j}. If square (i, j) is initially painted by white, s_{i, j} is .; if square (i, j) is initially painted by black, s_{i, j} is #.\n\nConstraints\n\nH is an integer between 2 and 50 (inclusive).\n\nW is an integer between 2 and 50 (inclusive).\n\ns_{i, j} is . or # (1 \\leq i \\leq H, 1 \\leq j \\leq W).\n\ns_{1, 1} and s_{H, W} are ..\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\ns_{1, 1}s_{1, 2}s_{1, 3} ... s_{1, W}\ns_{2, 1}s_{2, 2}s_{2, 3} ... s_{2, W}\n: :\ns_{H, 1}s_{H, 2}s_{H, 3} ... s_{H, W}\n\nOutput\n\nPrint the maximum possible score that Snuke can achieve, or print -1 if the game cannot be completed.\n\nSample Input 1\n\n3 3\n..#\n#..\n...\n\nSample Output 1\n\n2\n\nThe score 2 can be achieved by changing the color of squares as follows:\n\nSample Input 2\n\n10 37\n.....................................\n...#...####...####..###...###...###..\n..#.#..#...#.##....#...#.#...#.#...#.\n..#.#..#...#.#.....#...#.#...#.#...#.\n.#...#.#..##.#.....#...#.#.###.#.###.\n.#####.####..#.....#...#..##....##...\n.#...#.#...#.#.....#...#.#...#.#...#.\n.#...#.#...#.##....#...#.#...#.#...#.\n.#...#.####...####..###...###...###..\n.....................................\n\nSample Output 2\n\n209", "sample_input": "3 3\n..#\n#..\n...\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03436", "source_text": "Score: 400 points\n\nProblem statement\n\nWe have an H \\times W grid whose squares are painted black or white. The square at the i-th row from the top and the j-th column from the left is denoted as (i, j).\n\nSnuke would like to play the following game on this grid. At the beginning of the game, there is a character called Kenus at square (1, 1). The player repeatedly moves Kenus up, down, left or right by one square. The game is completed when Kenus reaches square (H, W) passing only white squares.\n\nBefore Snuke starts the game, he can change the color of some of the white squares to black. However, he cannot change the color of square (1, 1) and (H, W). Also, changes of color must all be carried out before the beginning of the game.\n\nWhen the game is completed, Snuke's score will be the number of times he changed the color of a square before the beginning of the game. Find the maximum possible score that Snuke can achieve, or print -1 if the game cannot be completed, that is, Kenus can never reach square (H, W) regardless of how Snuke changes the color of the squares.\n\nThe color of the squares are given to you as characters s_{i, j}. If square (i, j) is initially painted by white, s_{i, j} is .; if square (i, j) is initially painted by black, s_{i, j} is #.\n\nConstraints\n\nH is an integer between 2 and 50 (inclusive).\n\nW is an integer between 2 and 50 (inclusive).\n\ns_{i, j} is . or # (1 \\leq i \\leq H, 1 \\leq j \\leq W).\n\ns_{1, 1} and s_{H, W} are ..\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\ns_{1, 1}s_{1, 2}s_{1, 3} ... s_{1, W}\ns_{2, 1}s_{2, 2}s_{2, 3} ... s_{2, W}\n: :\ns_{H, 1}s_{H, 2}s_{H, 3} ... s_{H, W}\n\nOutput\n\nPrint the maximum possible score that Snuke can achieve, or print -1 if the game cannot be completed.\n\nSample Input 1\n\n3 3\n..#\n#..\n...\n\nSample Output 1\n\n2\n\nThe score 2 can be achieved by changing the color of squares as follows:\n\nSample Input 2\n\n10 37\n.....................................\n...#...####...####..###...###...###..\n..#.#..#...#.##....#...#.#...#.#...#.\n..#.#..#...#.#.....#...#.#...#.#...#.\n.#...#.#..##.#.....#...#.#.###.#.###.\n.#####.####..#.....#...#..##....##...\n.#...#.#...#.#.....#...#.#...#.#...#.\n.#...#.#...#.##....#...#.#...#.#...#.\n.#...#.####...####..###...###...###..\n.....................................\n\nSample Output 2\n\n209", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2847, "cpu_time_ms": 3, "memory_kb": 2176}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s189660498", "group_id": "codeNet:p03436", "input_text": "open Batteries\nmodule EnumL = Enum.Labels\nmodule ListL = List.Labels\nmodule ArrayL = Array.Labels\n\nlet dbg0 x = Printf.eprintf \"[debug]%s\\n\" @@ dump x\nlet dbg1 x = dbg0 x; x\n\nlet id = identity\n\nlet (++) n m = List.range n `To m\nlet (++^) n m = if n < m then List.range n `To (pred m) else []\n\nlet scan fmt = Scanf.sscanf (read_line ()) fmt\n\nlet scan_lines n fmt f =\n if n = 0 then Enum.empty ()\n else\n List.map (fun _ -> scan fmt f) (1 ++ n)\n |> List.enum\n\nlet scan_list sep cnv =\n let line = read_line () in\n (match sep with\n | None -> List.map String.of_char @@ String.to_list line\n | Some sep -> String.split_on_char sep line)\n |> List.map cnv\n\nlet scan_array ?sep cnv = Array.of_list @@ scan_list sep cnv\n\nlet scan_matrix n m e ?sep conv =\n let arr = Array.make_matrix n m e in\n ListL.iter (0 ++^ n)\n ~f:(fun i -> arr.(i) <- Array.of_list @@ scan_list sep conv);\n arr\n\nlet rec powerset e =\n match Enum.get e with\n | None -> Enum.singleton @@ Enum.empty ()\n | Some v ->\n let f = powerset e in\n let g = Enum.clone f in\n EnumL.map f ~f:(fun x -> let y = Enum.clone x in push y v; y)\n |> Enum.append g\n\nlet permutations l =\n let rec aux l =\n let rec interleave x = function\n | [] -> [[x]]\n | (hd::tl) as lst ->\n (x::lst) ::\n (ListL.map ~f:(List.cons hd) @@ interleave x tl)\n in\n match l with\n | [] -> [[]]\n | hd::tl -> List.concat @@ List.map (interleave hd) @@ aux tl in\n let l = List.sort (List.compare Int.compare) @@ aux @@ List.of_enum l in\n List.enum % ListL.map ~f:List.enum @@ l\n\nlet intersection l =\n EnumL.filter ~f:(fun x -> EnumL.exists ~f:((=) x) @@ Enum.clone l)\n\nlet lower_bound n f =\n let rec aux l u =\n if u - l > 1 then\n let m = (l + u) / 2 in\n if f m then aux l m\n else aux m u\n else u in aux (-1) n\n\nlet between n x m = n <= x && x < m\n\nlet (h, w) = scan \"%d %d\" Tuple.Tuple2.make\nlet g = scan_matrix h w \".\" id\nlet m = Array.make_matrix h w (-1)\nlet ds = [(-1,0);(1,0);(0,-1);(0,1)]\n\nlet rec bfs visited queue =\n if Queue.is_empty queue then ()\n else\n let (i, j, n) = Queue.pop queue in\n visited.(i).(j) <- true;\n m.(i).(j) <- n;\n ListL.iter ds ~f:(fun (di, dj) ->\n let x, y = i + di, j + dj in\n if between 0 x h && between 0 y w && not visited.(x).(y)\n && g.(x).(y) = \".\" then\n Queue.push (x,y, succ n) queue);\n bfs visited queue\n\nlet () =\n let visited = Array.make_matrix h w false in\n let q = Queue.create () in\n Queue.push (0,0,1) q;\n bfs visited q;\n let n = dbg1 m.(h-1).(w-1) in\n (if n = -1 then -1\n else\n h*w -\n (ArrayL.map g\n ~f:(fun line ->\n ArrayL.filter line ~f:((=) \"#\")\n |> Array.length)\n |> Array.sum) - n)\n |> Printf.printf \"%d\\n\"\n", "language": "OCaml", "metadata": {"date": 1587909998, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03436.html", "problem_id": "p03436", "resource_group": "low_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/OCaml/s189660498.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s189660498", "user_id": "u802614675"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "open Batteries\nmodule EnumL = Enum.Labels\nmodule ListL = List.Labels\nmodule ArrayL = Array.Labels\n\nlet dbg0 x = Printf.eprintf \"[debug]%s\\n\" @@ dump x\nlet dbg1 x = dbg0 x; x\n\nlet id = identity\n\nlet (++) n m = List.range n `To m\nlet (++^) n m = if n < m then List.range n `To (pred m) else []\n\nlet scan fmt = Scanf.sscanf (read_line ()) fmt\n\nlet scan_lines n fmt f =\n if n = 0 then Enum.empty ()\n else\n List.map (fun _ -> scan fmt f) (1 ++ n)\n |> List.enum\n\nlet scan_list sep cnv =\n let line = read_line () in\n (match sep with\n | None -> List.map String.of_char @@ String.to_list line\n | Some sep -> String.split_on_char sep line)\n |> List.map cnv\n\nlet scan_array ?sep cnv = Array.of_list @@ scan_list sep cnv\n\nlet scan_matrix n m e ?sep conv =\n let arr = Array.make_matrix n m e in\n ListL.iter (0 ++^ n)\n ~f:(fun i -> arr.(i) <- Array.of_list @@ scan_list sep conv);\n arr\n\nlet rec powerset e =\n match Enum.get e with\n | None -> Enum.singleton @@ Enum.empty ()\n | Some v ->\n let f = powerset e in\n let g = Enum.clone f in\n EnumL.map f ~f:(fun x -> let y = Enum.clone x in push y v; y)\n |> Enum.append g\n\nlet permutations l =\n let rec aux l =\n let rec interleave x = function\n | [] -> [[x]]\n | (hd::tl) as lst ->\n (x::lst) ::\n (ListL.map ~f:(List.cons hd) @@ interleave x tl)\n in\n match l with\n | [] -> [[]]\n | hd::tl -> List.concat @@ List.map (interleave hd) @@ aux tl in\n let l = List.sort (List.compare Int.compare) @@ aux @@ List.of_enum l in\n List.enum % ListL.map ~f:List.enum @@ l\n\nlet intersection l =\n EnumL.filter ~f:(fun x -> EnumL.exists ~f:((=) x) @@ Enum.clone l)\n\nlet lower_bound n f =\n let rec aux l u =\n if u - l > 1 then\n let m = (l + u) / 2 in\n if f m then aux l m\n else aux m u\n else u in aux (-1) n\n\nlet between n x m = n <= x && x < m\n\nlet (h, w) = scan \"%d %d\" Tuple.Tuple2.make\nlet g = scan_matrix h w \".\" id\nlet m = Array.make_matrix h w (-1)\nlet ds = [(-1,0);(1,0);(0,-1);(0,1)]\n\nlet rec bfs visited queue =\n if Queue.is_empty queue then ()\n else\n let (i, j, n) = Queue.pop queue in\n visited.(i).(j) <- true;\n m.(i).(j) <- n;\n ListL.iter ds ~f:(fun (di, dj) ->\n let x, y = i + di, j + dj in\n if between 0 x h && between 0 y w && not visited.(x).(y)\n && g.(x).(y) = \".\" then\n Queue.push (x,y, succ n) queue);\n bfs visited queue\n\nlet () =\n let visited = Array.make_matrix h w false in\n let q = Queue.create () in\n Queue.push (0,0,1) q;\n bfs visited q;\n let n = dbg1 m.(h-1).(w-1) in\n (if n = -1 then -1\n else\n h*w -\n (ArrayL.map g\n ~f:(fun line ->\n ArrayL.filter line ~f:((=) \"#\")\n |> Array.length)\n |> Array.sum) - n)\n |> Printf.printf \"%d\\n\"\n", "problem_context": "Score: 400 points\n\nProblem statement\n\nWe have an H \\times W grid whose squares are painted black or white. The square at the i-th row from the top and the j-th column from the left is denoted as (i, j).\n\nSnuke would like to play the following game on this grid. At the beginning of the game, there is a character called Kenus at square (1, 1). The player repeatedly moves Kenus up, down, left or right by one square. The game is completed when Kenus reaches square (H, W) passing only white squares.\n\nBefore Snuke starts the game, he can change the color of some of the white squares to black. However, he cannot change the color of square (1, 1) and (H, W). Also, changes of color must all be carried out before the beginning of the game.\n\nWhen the game is completed, Snuke's score will be the number of times he changed the color of a square before the beginning of the game. Find the maximum possible score that Snuke can achieve, or print -1 if the game cannot be completed, that is, Kenus can never reach square (H, W) regardless of how Snuke changes the color of the squares.\n\nThe color of the squares are given to you as characters s_{i, j}. If square (i, j) is initially painted by white, s_{i, j} is .; if square (i, j) is initially painted by black, s_{i, j} is #.\n\nConstraints\n\nH is an integer between 2 and 50 (inclusive).\n\nW is an integer between 2 and 50 (inclusive).\n\ns_{i, j} is . or # (1 \\leq i \\leq H, 1 \\leq j \\leq W).\n\ns_{1, 1} and s_{H, W} are ..\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\ns_{1, 1}s_{1, 2}s_{1, 3} ... s_{1, W}\ns_{2, 1}s_{2, 2}s_{2, 3} ... s_{2, W}\n: :\ns_{H, 1}s_{H, 2}s_{H, 3} ... s_{H, W}\n\nOutput\n\nPrint the maximum possible score that Snuke can achieve, or print -1 if the game cannot be completed.\n\nSample Input 1\n\n3 3\n..#\n#..\n...\n\nSample Output 1\n\n2\n\nThe score 2 can be achieved by changing the color of squares as follows:\n\nSample Input 2\n\n10 37\n.....................................\n...#...####...####..###...###...###..\n..#.#..#...#.##....#...#.#...#.#...#.\n..#.#..#...#.#.....#...#.#...#.#...#.\n.#...#.#..##.#.....#...#.#.###.#.###.\n.#####.####..#.....#...#..##....##...\n.#...#.#...#.#.....#...#.#...#.#...#.\n.#...#.#...#.##....#...#.#...#.#...#.\n.#...#.####...####..###...###...###..\n.....................................\n\nSample Output 2\n\n209", "sample_input": "3 3\n..#\n#..\n...\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03436", "source_text": "Score: 400 points\n\nProblem statement\n\nWe have an H \\times W grid whose squares are painted black or white. The square at the i-th row from the top and the j-th column from the left is denoted as (i, j).\n\nSnuke would like to play the following game on this grid. At the beginning of the game, there is a character called Kenus at square (1, 1). The player repeatedly moves Kenus up, down, left or right by one square. The game is completed when Kenus reaches square (H, W) passing only white squares.\n\nBefore Snuke starts the game, he can change the color of some of the white squares to black. However, he cannot change the color of square (1, 1) and (H, W). Also, changes of color must all be carried out before the beginning of the game.\n\nWhen the game is completed, Snuke's score will be the number of times he changed the color of a square before the beginning of the game. Find the maximum possible score that Snuke can achieve, or print -1 if the game cannot be completed, that is, Kenus can never reach square (H, W) regardless of how Snuke changes the color of the squares.\n\nThe color of the squares are given to you as characters s_{i, j}. If square (i, j) is initially painted by white, s_{i, j} is .; if square (i, j) is initially painted by black, s_{i, j} is #.\n\nConstraints\n\nH is an integer between 2 and 50 (inclusive).\n\nW is an integer between 2 and 50 (inclusive).\n\ns_{i, j} is . or # (1 \\leq i \\leq H, 1 \\leq j \\leq W).\n\ns_{1, 1} and s_{H, W} are ..\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\ns_{1, 1}s_{1, 2}s_{1, 3} ... s_{1, W}\ns_{2, 1}s_{2, 2}s_{2, 3} ... s_{2, W}\n: :\ns_{H, 1}s_{H, 2}s_{H, 3} ... s_{H, W}\n\nOutput\n\nPrint the maximum possible score that Snuke can achieve, or print -1 if the game cannot be completed.\n\nSample Input 1\n\n3 3\n..#\n#..\n...\n\nSample Output 1\n\n2\n\nThe score 2 can be achieved by changing the color of squares as follows:\n\nSample Input 2\n\n10 37\n.....................................\n...#...####...####..###...###...###..\n..#.#..#...#.##....#...#.#...#.#...#.\n..#.#..#...#.#.....#...#.#...#.#...#.\n.#...#.#..##.#.....#...#.#.###.#.###.\n.#####.####..#.....#...#..##....##...\n.#...#.#...#.#.....#...#.#...#.#...#.\n.#...#.#...#.##....#...#.#...#.#...#.\n.#...#.####...####..###...###...###..\n.....................................\n\nSample Output 2\n\n209", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2772, "cpu_time_ms": 2109, "memory_kb": 286324}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s944468039", "group_id": "codeNet:p03436", "input_text": "(* O(h w) *)\nlet h, w = Scanf.scanf \" %d %d\" @@ fun a b -> a, b\nlet b = ref 0\nlet sss = Array.init h @@ fun _ ->\n Array.init w @@ fun _ -> Scanf.scanf \" %c\" @@ fun c -> if c = '#' then incr b; c\nlet ds = Array.make_matrix h w @@ -1\nlet bfs () =\n let q = Queue.create () in\n ds.(0).(0) <- 0;\n Queue.push (0, 0) q;\n while not @@ Queue.is_empty q do\n let y0, x0 = Queue.pop q in\n let f (dy, dx) =\n let y, x = y0 + dy, x0 + dx in\n if 0 <= y && y < h && 0 <= x && x < w && ds.(y).(x) = -1 && sss.(y).(x) <> '#' then\n (ds.(y).(x) <- ds.(y0).(x0) + 1;\n Queue.push (y, x) q) in\n List.iter f [0, -1; -1, 0; 0, 1; 1, 0]\n done;\n ds.(h - 1).(w - 1)\nlet _ =\n h * w - !b - bfs () - 1 |> Printf.printf \"%d\\n\"", "language": "OCaml", "metadata": {"date": 1560247172, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03436.html", "problem_id": "p03436", "resource_group": "low_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/OCaml/s944468039.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s944468039", "user_id": "u732304692"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "(* O(h w) *)\nlet h, w = Scanf.scanf \" %d %d\" @@ fun a b -> a, b\nlet b = ref 0\nlet sss = Array.init h @@ fun _ ->\n Array.init w @@ fun _ -> Scanf.scanf \" %c\" @@ fun c -> if c = '#' then incr b; c\nlet ds = Array.make_matrix h w @@ -1\nlet bfs () =\n let q = Queue.create () in\n ds.(0).(0) <- 0;\n Queue.push (0, 0) q;\n while not @@ Queue.is_empty q do\n let y0, x0 = Queue.pop q in\n let f (dy, dx) =\n let y, x = y0 + dy, x0 + dx in\n if 0 <= y && y < h && 0 <= x && x < w && ds.(y).(x) = -1 && sss.(y).(x) <> '#' then\n (ds.(y).(x) <- ds.(y0).(x0) + 1;\n Queue.push (y, x) q) in\n List.iter f [0, -1; -1, 0; 0, 1; 1, 0]\n done;\n ds.(h - 1).(w - 1)\nlet _ =\n h * w - !b - bfs () - 1 |> Printf.printf \"%d\\n\"", "problem_context": "Score: 400 points\n\nProblem statement\n\nWe have an H \\times W grid whose squares are painted black or white. The square at the i-th row from the top and the j-th column from the left is denoted as (i, j).\n\nSnuke would like to play the following game on this grid. At the beginning of the game, there is a character called Kenus at square (1, 1). The player repeatedly moves Kenus up, down, left or right by one square. The game is completed when Kenus reaches square (H, W) passing only white squares.\n\nBefore Snuke starts the game, he can change the color of some of the white squares to black. However, he cannot change the color of square (1, 1) and (H, W). Also, changes of color must all be carried out before the beginning of the game.\n\nWhen the game is completed, Snuke's score will be the number of times he changed the color of a square before the beginning of the game. Find the maximum possible score that Snuke can achieve, or print -1 if the game cannot be completed, that is, Kenus can never reach square (H, W) regardless of how Snuke changes the color of the squares.\n\nThe color of the squares are given to you as characters s_{i, j}. If square (i, j) is initially painted by white, s_{i, j} is .; if square (i, j) is initially painted by black, s_{i, j} is #.\n\nConstraints\n\nH is an integer between 2 and 50 (inclusive).\n\nW is an integer between 2 and 50 (inclusive).\n\ns_{i, j} is . or # (1 \\leq i \\leq H, 1 \\leq j \\leq W).\n\ns_{1, 1} and s_{H, W} are ..\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\ns_{1, 1}s_{1, 2}s_{1, 3} ... s_{1, W}\ns_{2, 1}s_{2, 2}s_{2, 3} ... s_{2, W}\n: :\ns_{H, 1}s_{H, 2}s_{H, 3} ... s_{H, W}\n\nOutput\n\nPrint the maximum possible score that Snuke can achieve, or print -1 if the game cannot be completed.\n\nSample Input 1\n\n3 3\n..#\n#..\n...\n\nSample Output 1\n\n2\n\nThe score 2 can be achieved by changing the color of squares as follows:\n\nSample Input 2\n\n10 37\n.....................................\n...#...####...####..###...###...###..\n..#.#..#...#.##....#...#.#...#.#...#.\n..#.#..#...#.#.....#...#.#...#.#...#.\n.#...#.#..##.#.....#...#.#.###.#.###.\n.#####.####..#.....#...#..##....##...\n.#...#.#...#.#.....#...#.#...#.#...#.\n.#...#.#...#.##....#...#.#...#.#...#.\n.#...#.####...####..###...###...###..\n.....................................\n\nSample Output 2\n\n209", "sample_input": "3 3\n..#\n#..\n...\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03436", "source_text": "Score: 400 points\n\nProblem statement\n\nWe have an H \\times W grid whose squares are painted black or white. The square at the i-th row from the top and the j-th column from the left is denoted as (i, j).\n\nSnuke would like to play the following game on this grid. At the beginning of the game, there is a character called Kenus at square (1, 1). The player repeatedly moves Kenus up, down, left or right by one square. The game is completed when Kenus reaches square (H, W) passing only white squares.\n\nBefore Snuke starts the game, he can change the color of some of the white squares to black. However, he cannot change the color of square (1, 1) and (H, W). Also, changes of color must all be carried out before the beginning of the game.\n\nWhen the game is completed, Snuke's score will be the number of times he changed the color of a square before the beginning of the game. Find the maximum possible score that Snuke can achieve, or print -1 if the game cannot be completed, that is, Kenus can never reach square (H, W) regardless of how Snuke changes the color of the squares.\n\nThe color of the squares are given to you as characters s_{i, j}. If square (i, j) is initially painted by white, s_{i, j} is .; if square (i, j) is initially painted by black, s_{i, j} is #.\n\nConstraints\n\nH is an integer between 2 and 50 (inclusive).\n\nW is an integer between 2 and 50 (inclusive).\n\ns_{i, j} is . or # (1 \\leq i \\leq H, 1 \\leq j \\leq W).\n\ns_{1, 1} and s_{H, W} are ..\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\ns_{1, 1}s_{1, 2}s_{1, 3} ... s_{1, W}\ns_{2, 1}s_{2, 2}s_{2, 3} ... s_{2, W}\n: :\ns_{H, 1}s_{H, 2}s_{H, 3} ... s_{H, W}\n\nOutput\n\nPrint the maximum possible score that Snuke can achieve, or print -1 if the game cannot be completed.\n\nSample Input 1\n\n3 3\n..#\n#..\n...\n\nSample Output 1\n\n2\n\nThe score 2 can be achieved by changing the color of squares as follows:\n\nSample Input 2\n\n10 37\n.....................................\n...#...####...####..###...###...###..\n..#.#..#...#.##....#...#.#...#.#...#.\n..#.#..#...#.#.....#...#.#...#.#...#.\n.#...#.#..##.#.....#...#.#.###.#.###.\n.#####.####..#.....#...#..##....##...\n.#...#.#...#.#.....#...#.#...#.#...#.\n.#...#.#...#.##....#...#.#...#.#...#.\n.#...#.####...####..###...###...###..\n.....................................\n\nSample Output 2\n\n209", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 734, "cpu_time_ms": 2, "memory_kb": 1408}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s550197498", "group_id": "codeNet:p03437", "input_text": "let x, y = Scanf.scanf \" %d %d\" @@ fun a b -> a, b\nlet _ = Printf.printf \"%d\\n\" @@ if x mod y = 0 then -1 else x", "language": "OCaml", "metadata": {"date": 1563935098, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03437.html", "problem_id": "p03437", "resource_group": "low_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/OCaml/s550197498.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s550197498", "user_id": "u732304692"}, "prompt_components": {"gold_output": "16\n", "input_to_evaluate": "let x, y = Scanf.scanf \" %d %d\" @@ fun a b -> a, b\nlet _ = Printf.printf \"%d\\n\" @@ if x mod y = 0 then -1 else x", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s891797106", "group_id": "codeNet:p03437", "input_text": "let () =\n let (x,y) = Scanf.scanf \"%d %d\\n\" (fun x y -> x,y) in\n let check =\n if x mod y = 0 then -1\n else x\n in\n let ans = check in\n print_int ans;", "language": "OCaml", "metadata": {"date": 1517724575, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03437.html", "problem_id": "p03437", "resource_group": "low_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/OCaml/s891797106.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s891797106", "user_id": "u161156777"}, "prompt_components": {"gold_output": "16\n", "input_to_evaluate": "let () =\n let (x,y) = Scanf.scanf \"%d %d\\n\" (fun x y -> x,y) in\n let check =\n if x mod y = 0 then -1\n else x\n in\n let ans = check in\n print_int ans;", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s618199550", "group_id": "codeNet:p03438", "input_text": "let split_string ?(pattern=\"\") = Str.split @@ Str.regexp pattern\n\nlet n = Scanf.sscanf (read_line ()) \"%d\" @@ fun n -> n\nlet a = read_line () |> split_string ~pattern:\" \" |> List.map int_of_string\nlet b = read_line () |> split_string ~pattern:\" \" |> List.map int_of_string\n\nlet () =\n let sum_a, sum_b = List.fold_left2 (fun (sum_a, sum_b) a b ->\n if a > b then (sum_a, sum_b + a - b)\n else (sum_a + (b - a) / 2, sum_b)\n ) (0, 0) a b in\n print_endline @@ if sum_a > sum_b then \"Yes\" else \"No\"", "language": "OCaml", "metadata": {"date": 1592914981, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p03438.html", "problem_id": "p03438", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03438/input.txt", "sample_output_relpath": "derived/input_output/data/p03438/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03438/OCaml/s618199550.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s618199550", "user_id": "u811309788"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "let split_string ?(pattern=\"\") = Str.split @@ Str.regexp pattern\n\nlet n = Scanf.sscanf (read_line ()) \"%d\" @@ fun n -> n\nlet a = read_line () |> split_string ~pattern:\" \" |> List.map int_of_string\nlet b = read_line () |> split_string ~pattern:\" \" |> List.map int_of_string\n\nlet () =\n let sum_a, sum_b = List.fold_left2 (fun (sum_a, sum_b) a b ->\n if a > b then (sum_a, sum_b + a - b)\n else (sum_a + (b - a) / 2, sum_b)\n ) (0, 0) a b in\n print_endline @@ if sum_a > sum_b then \"Yes\" else \"No\"", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou are given two integer sequences of length N: a_1,a_2,..,a_N and b_1,b_2,..,b_N.\nDetermine if we can repeat the following operation zero or more times so that the sequences a and b become equal.\n\nOperation: Choose two integers i and j (possibly the same) between 1 and N (inclusive), then perform the following two actions simultaneously:\n\nAdd 2 to a_i.\n\nAdd 1 to b_j.\n\nConstraints\n\n1 ≤ N ≤ 10 000\n\n0 ≤ a_i,b_i ≤ 10^9 (1 ≤ i ≤ N)\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 .. a_N\nb_1 b_2 .. b_N\n\nOutput\n\nIf we can repeat the operation zero or more times so that the sequences a and b become equal, print Yes; otherwise, print No.\n\nSample Input 1\n\n3\n1 2 3\n5 2 2\n\nSample Output 1\n\nYes\n\nFor example, we can perform three operations as follows to do our job:\n\nFirst operation: i=1 and j=2. Now we have a = \\{3,2,3\\}, b = \\{5,3,2\\}.\n\nSecond operation: i=1 and j=2. Now we have a = \\{5,2,3\\}, b = \\{5,4,2\\}.\n\nThird operation: i=2 and j=3. Now we have a = \\{5,4,3\\}, b = \\{5,4,3\\}.\n\nSample Input 2\n\n5\n3 1 4 1 5\n2 7 1 8 2\n\nSample Output 2\n\nNo\n\nSample Input 3\n\n5\n2 7 1 8 2\n3 1 4 1 5\n\nSample Output 3\n\nNo", "sample_input": "3\n1 2 3\n5 2 2\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03438", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou are given two integer sequences of length N: a_1,a_2,..,a_N and b_1,b_2,..,b_N.\nDetermine if we can repeat the following operation zero or more times so that the sequences a and b become equal.\n\nOperation: Choose two integers i and j (possibly the same) between 1 and N (inclusive), then perform the following two actions simultaneously:\n\nAdd 2 to a_i.\n\nAdd 1 to b_j.\n\nConstraints\n\n1 ≤ N ≤ 10 000\n\n0 ≤ a_i,b_i ≤ 10^9 (1 ≤ i ≤ N)\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 .. a_N\nb_1 b_2 .. b_N\n\nOutput\n\nIf we can repeat the operation zero or more times so that the sequences a and b become equal, print Yes; otherwise, print No.\n\nSample Input 1\n\n3\n1 2 3\n5 2 2\n\nSample Output 1\n\nYes\n\nFor example, we can perform three operations as follows to do our job:\n\nFirst operation: i=1 and j=2. Now we have a = \\{3,2,3\\}, b = \\{5,3,2\\}.\n\nSecond operation: i=1 and j=2. Now we have a = \\{5,2,3\\}, b = \\{5,4,2\\}.\n\nThird operation: i=2 and j=3. Now we have a = \\{5,4,3\\}, b = \\{5,4,3\\}.\n\nSample Input 2\n\n5\n3 1 4 1 5\n2 7 1 8 2\n\nSample Output 2\n\nNo\n\nSample Input 3\n\n5\n2 7 1 8 2\n3 1 4 1 5\n\nSample Output 3\n\nNo", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 17, "memory_kb": 7032}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s162008920", "group_id": "codeNet:p03438", "input_text": "let () =\n let n = Scanf.scanf \"%d\\n\" (fun n -> n) in\n let as_ = Array.to_list @@ Array.init n (fun _ -> Scanf.scanf \"%d \" (fun a -> a)) in\n let bs = Array.to_list @@ Array.init n (fun _ -> Scanf.scanf \"%d \" (fun b -> b)) in\n List.fold_left2 (fun (as_, bs) a b ->\n if a <= b then (as_, bs + (b - a) / 2)\n else (as_ + a - b, bs)) (0, 0) as_ bs\n |> (fun (as_, bs) -> as_ <= bs)\n |> (function true -> \"Yes\" | false -> \"No\")\n |> print_endline\n", "language": "OCaml", "metadata": {"date": 1517719656, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03438.html", "problem_id": "p03438", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03438/input.txt", "sample_output_relpath": "derived/input_output/data/p03438/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03438/OCaml/s162008920.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s162008920", "user_id": "u504158101"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "let () =\n let n = Scanf.scanf \"%d\\n\" (fun n -> n) in\n let as_ = Array.to_list @@ Array.init n (fun _ -> Scanf.scanf \"%d \" (fun a -> a)) in\n let bs = Array.to_list @@ Array.init n (fun _ -> Scanf.scanf \"%d \" (fun b -> b)) in\n List.fold_left2 (fun (as_, bs) a b ->\n if a <= b then (as_, bs + (b - a) / 2)\n else (as_ + a - b, bs)) (0, 0) as_ bs\n |> (fun (as_, bs) -> as_ <= bs)\n |> (function true -> \"Yes\" | false -> \"No\")\n |> print_endline\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou are given two integer sequences of length N: a_1,a_2,..,a_N and b_1,b_2,..,b_N.\nDetermine if we can repeat the following operation zero or more times so that the sequences a and b become equal.\n\nOperation: Choose two integers i and j (possibly the same) between 1 and N (inclusive), then perform the following two actions simultaneously:\n\nAdd 2 to a_i.\n\nAdd 1 to b_j.\n\nConstraints\n\n1 ≤ N ≤ 10 000\n\n0 ≤ a_i,b_i ≤ 10^9 (1 ≤ i ≤ N)\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 .. a_N\nb_1 b_2 .. b_N\n\nOutput\n\nIf we can repeat the operation zero or more times so that the sequences a and b become equal, print Yes; otherwise, print No.\n\nSample Input 1\n\n3\n1 2 3\n5 2 2\n\nSample Output 1\n\nYes\n\nFor example, we can perform three operations as follows to do our job:\n\nFirst operation: i=1 and j=2. Now we have a = \\{3,2,3\\}, b = \\{5,3,2\\}.\n\nSecond operation: i=1 and j=2. Now we have a = \\{5,2,3\\}, b = \\{5,4,2\\}.\n\nThird operation: i=2 and j=3. Now we have a = \\{5,4,3\\}, b = \\{5,4,3\\}.\n\nSample Input 2\n\n5\n3 1 4 1 5\n2 7 1 8 2\n\nSample Output 2\n\nNo\n\nSample Input 3\n\n5\n2 7 1 8 2\n3 1 4 1 5\n\nSample Output 3\n\nNo", "sample_input": "3\n1 2 3\n5 2 2\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03438", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou are given two integer sequences of length N: a_1,a_2,..,a_N and b_1,b_2,..,b_N.\nDetermine if we can repeat the following operation zero or more times so that the sequences a and b become equal.\n\nOperation: Choose two integers i and j (possibly the same) between 1 and N (inclusive), then perform the following two actions simultaneously:\n\nAdd 2 to a_i.\n\nAdd 1 to b_j.\n\nConstraints\n\n1 ≤ N ≤ 10 000\n\n0 ≤ a_i,b_i ≤ 10^9 (1 ≤ i ≤ N)\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 .. a_N\nb_1 b_2 .. b_N\n\nOutput\n\nIf we can repeat the operation zero or more times so that the sequences a and b become equal, print Yes; otherwise, print No.\n\nSample Input 1\n\n3\n1 2 3\n5 2 2\n\nSample Output 1\n\nYes\n\nFor example, we can perform three operations as follows to do our job:\n\nFirst operation: i=1 and j=2. Now we have a = \\{3,2,3\\}, b = \\{5,3,2\\}.\n\nSecond operation: i=1 and j=2. Now we have a = \\{5,2,3\\}, b = \\{5,4,2\\}.\n\nThird operation: i=2 and j=3. Now we have a = \\{5,4,3\\}, b = \\{5,4,3\\}.\n\nSample Input 2\n\n5\n3 1 4 1 5\n2 7 1 8 2\n\nSample Output 2\n\nNo\n\nSample Input 3\n\n5\n2 7 1 8 2\n3 1 4 1 5\n\nSample Output 3\n\nNo", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 9, "memory_kb": 5120}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s758824751", "group_id": "codeNet:p03447", "input_text": "let x, a, b = Scanf.scanf \" %d %d %d\" @@ fun a b c -> a, b, c\nlet _ = Printf.printf \"%d\\n\" @@ (x - a) mod b", "language": "OCaml", "metadata": {"date": 1565090867, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03447.html", "problem_id": "p03447", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03447/input.txt", "sample_output_relpath": "derived/input_output/data/p03447/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03447/OCaml/s758824751.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s758824751", "user_id": "u732304692"}, "prompt_components": {"gold_output": "84\n", "input_to_evaluate": "let x, a, b = Scanf.scanf \" %d %d %d\" @@ fun a b c -> a, b, c\nlet _ = Printf.printf \"%d\\n\" @@ (x - a) mod b", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou went shopping to buy cakes and donuts with X yen (the currency of Japan).\n\nFirst, you bought one cake for A yen at a cake shop.\nThen, you bought as many donuts as possible for B yen each, at a donut shop.\n\nHow much do you have left after shopping?\n\nConstraints\n\n1 \\leq A, B \\leq 1 000\n\nA + B \\leq X \\leq 10 000\n\nX, A and B are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX\nA\nB\n\nOutput\n\nPrint the amount you have left after shopping.\n\nSample Input 1\n\n1234\n150\n100\n\nSample Output 1\n\n84\n\nYou have 1234 - 150 = 1084 yen left after buying a cake.\nWith this amount, you can buy 10 donuts, after which you have 84 yen left.\n\nSample Input 2\n\n1000\n108\n108\n\nSample Output 2\n\n28\n\nSample Input 3\n\n579\n123\n456\n\nSample Output 3\n\n0\n\nSample Input 4\n\n7477\n549\n593\n\nSample Output 4\n\n405", "sample_input": "1234\n150\n100\n"}, "reference_outputs": ["84\n"], "source_document_id": "p03447", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou went shopping to buy cakes and donuts with X yen (the currency of Japan).\n\nFirst, you bought one cake for A yen at a cake shop.\nThen, you bought as many donuts as possible for B yen each, at a donut shop.\n\nHow much do you have left after shopping?\n\nConstraints\n\n1 \\leq A, B \\leq 1 000\n\nA + B \\leq X \\leq 10 000\n\nX, A and B are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX\nA\nB\n\nOutput\n\nPrint the amount you have left after shopping.\n\nSample Input 1\n\n1234\n150\n100\n\nSample Output 1\n\n84\n\nYou have 1234 - 150 = 1084 yen left after buying a cake.\nWith this amount, you can buy 10 donuts, after which you have 84 yen left.\n\nSample Input 2\n\n1000\n108\n108\n\nSample Output 2\n\n28\n\nSample Input 3\n\n579\n123\n456\n\nSample Output 3\n\n0\n\nSample Input 4\n\n7477\n549\n593\n\nSample Output 4\n\n405", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s820097839", "group_id": "codeNet:p03449", "input_text": "let id x = x in\nlet id2 x y = x in\nlet n = Scanf.scanf \"%d\" id in\nlet lista = (Array.to_list @@ Array.init n (fun _ ->\n Scanf.scanf \"%d ^\\n\" id )) in\nlet _ =Scanf.scanf \"\\n\" (fun _ -> ()) in\nlet listb = (Array.to_list @@ Array.init n (fun _ ->\n Scanf.scanf \"%d ^\\n\" id )) in\n\nlet rec check la lb count =\n match la, lb with\n | [], [] -> count \n | hda :: resta, hdb :: restb ->\n max (check resta restb (count+hda)) (check [] restb (count+hda+hdb))\nin\n\nlet ans = check lista listb 0 in\n\nprint_int ans\n;;", "language": "OCaml", "metadata": {"date": 1517197189, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03449.html", "problem_id": "p03449", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03449/input.txt", "sample_output_relpath": "derived/input_output/data/p03449/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03449/OCaml/s820097839.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s820097839", "user_id": "u161156777"}, "prompt_components": {"gold_output": "14\n", "input_to_evaluate": "let id x = x in\nlet id2 x y = x in\nlet n = Scanf.scanf \"%d\" id in\nlet lista = (Array.to_list @@ Array.init n (fun _ ->\n Scanf.scanf \"%d ^\\n\" id )) in\nlet _ =Scanf.scanf \"\\n\" (fun _ -> ()) in\nlet listb = (Array.to_list @@ Array.init n (fun _ ->\n Scanf.scanf \"%d ^\\n\" id )) in\n\nlet rec check la lb count =\n match la, lb with\n | [], [] -> count \n | hda :: resta, hdb :: restb ->\n max (check resta restb (count+hda)) (check [] restb (count+hda+hdb))\nin\n\nlet ans = check lista listb 0 in\n\nprint_int ans\n;;", "problem_context": "Score : 300 points\n\nProblem Statement\n\nWe have a 2 \\times N grid. We will denote the square at the i-th row and j-th column (1 \\leq i \\leq 2, 1 \\leq j \\leq N) as (i, j).\n\nYou are initially in the top-left square, (1, 1).\nYou will travel to the bottom-right square, (2, N), by repeatedly moving right or down.\n\nThe square (i, j) contains A_{i, j} candies.\nYou will collect all the candies you visit during the travel.\nThe top-left and bottom-right squares also contain candies, and you will also collect them.\n\nAt most how many candies can you collect when you choose the best way to travel?\n\nConstraints\n\n1 \\leq N \\leq 100\n\n1 \\leq A_{i, j} \\leq 100 (1 \\leq i \\leq 2, 1 \\leq j \\leq N)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_{1, 1} A_{1, 2} ... A_{1, N}\nA_{2, 1} A_{2, 2} ... A_{2, N}\n\nOutput\n\nPrint the maximum number of candies that can be collected.\n\nSample Input 1\n\n5\n3 2 2 4 1\n1 2 2 2 1\n\nSample Output 1\n\n14\n\nThe number of collected candies will be maximized when you:\n\nmove right three times, then move down once, then move right once.\n\nSample Input 2\n\n4\n1 1 1 1\n1 1 1 1\n\nSample Output 2\n\n5\n\nYou will always collect the same number of candies, regardless of how you travel.\n\nSample Input 3\n\n7\n3 3 4 5 4 5 3\n5 3 4 4 2 3 2\n\nSample Output 3\n\n29\n\nSample Input 4\n\n1\n2\n3\n\nSample Output 4\n\n5", "sample_input": "5\n3 2 2 4 1\n1 2 2 2 1\n"}, "reference_outputs": ["14\n"], "source_document_id": "p03449", "source_text": "Score : 300 points\n\nProblem Statement\n\nWe have a 2 \\times N grid. We will denote the square at the i-th row and j-th column (1 \\leq i \\leq 2, 1 \\leq j \\leq N) as (i, j).\n\nYou are initially in the top-left square, (1, 1).\nYou will travel to the bottom-right square, (2, N), by repeatedly moving right or down.\n\nThe square (i, j) contains A_{i, j} candies.\nYou will collect all the candies you visit during the travel.\nThe top-left and bottom-right squares also contain candies, and you will also collect them.\n\nAt most how many candies can you collect when you choose the best way to travel?\n\nConstraints\n\n1 \\leq N \\leq 100\n\n1 \\leq A_{i, j} \\leq 100 (1 \\leq i \\leq 2, 1 \\leq j \\leq N)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_{1, 1} A_{1, 2} ... A_{1, N}\nA_{2, 1} A_{2, 2} ... A_{2, N}\n\nOutput\n\nPrint the maximum number of candies that can be collected.\n\nSample Input 1\n\n5\n3 2 2 4 1\n1 2 2 2 1\n\nSample Output 1\n\n14\n\nThe number of collected candies will be maximized when you:\n\nmove right three times, then move down once, then move right once.\n\nSample Input 2\n\n4\n1 1 1 1\n1 1 1 1\n\nSample Output 2\n\n5\n\nYou will always collect the same number of candies, regardless of how you travel.\n\nSample Input 3\n\n7\n3 3 4 5 4 5 3\n5 3 4 4 2 3 2\n\nSample Output 3\n\n29\n\nSample Input 4\n\n1\n2\n3\n\nSample Output 4\n\n5", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s566053670", "group_id": "codeNet:p03456", "input_text": "let input = Scanf.scanf \"%d %d\\n\" (fun x y -> int_of_string (string_of_int x ^ (string_of_int y))) in\n\nlet rec check x c=\n if x/2 int_of_string (string_of_int x ^ (string_of_int y))) in\n\nlet rec check x c=\n if x/2 Scanf.scanf \" %d %d %d\" @@ fun a b c -> a, b, c\nlet f (t0, x0, y0) (t, x, y) =\n let d = abs (x - x0) + abs(y - y0) in\n if t - t0 < d || (t - t0 - d) mod 2 = 1 then (print_endline \"No\"; exit 0);\n t, x, y\nlet _ =\n Array.fold_left f (0, 0, 0) txys |> ignore;\n print_endline \"Yes\"", "language": "OCaml", "metadata": {"date": 1561332848, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03457.html", "problem_id": "p03457", "resource_group": "low_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/OCaml/s309920198.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s309920198", "user_id": "u732304692"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "let n = Scanf.scanf \" %d\" @@ (+) 0\nlet txys = Array.init n @@ fun _ -> Scanf.scanf \" %d %d %d\" @@ fun a b c -> a, b, c\nlet f (t0, x0, y0) (t, x, y) =\n let d = abs (x - x0) + abs(y - y0) in\n if t - t0 < d || (t - t0 - d) mod 2 = 1 then (print_endline \"No\"; exit 0);\n t, x, y\nlet _ =\n Array.fold_left f (0, 0, 0) txys |> ignore;\n print_endline \"Yes\"", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 67, "memory_kb": 6912}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s267008075", "group_id": "codeNet:p03457", "input_text": "let id x = x in\nlet n = Scanf.scanf \"%d\\n\" id in\nlet list = (0,0,0) :: (Array.to_list @@ Array.init n (fun _ ->\n Scanf.scanf \"%d %d %d\\n\" (fun a b c-> a, b, c))) in\n \nlet rec check : (int*int*int) list -> string =\n fun list ->\n match list with\n | [] -> \"Yes\"\n | _ :: [] -> \"Yes\"\n | (t, x, y) :: ((t', x', y') as next) :: rest ->\n let dift=t'-t in\n let difd=x'-x+(y'-y) in\n if (dift+difd) mod 2 = 0 && difd<=dift\n then check (next :: rest)\n else \"No\" in\n\nprint_string (check list)\n;;\n ", "language": "OCaml", "metadata": {"date": 1516591869, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03457.html", "problem_id": "p03457", "resource_group": "low_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/OCaml/s267008075.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s267008075", "user_id": "u161156777"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "let id x = x in\nlet n = Scanf.scanf \"%d\\n\" id in\nlet list = (0,0,0) :: (Array.to_list @@ Array.init n (fun _ ->\n Scanf.scanf \"%d %d %d\\n\" (fun a b c-> a, b, c))) in\n \nlet rec check : (int*int*int) list -> string =\n fun list ->\n match list with\n | [] -> \"Yes\"\n | _ :: [] -> \"Yes\"\n | (t, x, y) :: ((t', x', y') as next) :: rest ->\n let dift=t'-t in\n let difd=x'-x+(y'-y) in\n if (dift+difd) mod 2 = 0 && difd<=dift\n then check (next :: rest)\n else \"No\" in\n\nprint_string (check list)\n;;\n ", "problem_context": "Score : 300 points\n\nProblem Statement\n\nAtCoDeer the deer is going on a trip in a two-dimensional plane.\nIn his plan, he will depart from point (0, 0) at time 0, then for each i between 1 and N (inclusive), he will visit point (x_i,y_i) at time t_i.\n\nIf AtCoDeer is at point (x, y) at time t, he can be at one of the following points at time t+1: (x+1,y), (x-1,y), (x,y+1) and (x,y-1).\nNote that he cannot stay at his place.\nDetermine whether he can carry out his plan.\n\nConstraints\n\n1 ≤ N ≤ 10^5\n\n0 ≤ x_i ≤ 10^5\n\n0 ≤ y_i ≤ 10^5\n\n1 ≤ t_i ≤ 10^5\n\nt_i < t_{i+1} (1 ≤ i ≤ N-1)\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nt_1 x_1 y_1\nt_2 x_2 y_2\n:\nt_N x_N y_N\n\nOutput\n\nIf AtCoDeer can carry out his plan, print Yes; if he cannot, print No.\n\nSample Input 1\n\n2\n3 1 2\n6 1 1\n\nSample Output 1\n\nYes\n\nFor example, he can travel as follows: (0,0), (0,1), (1,1), (1,2), (1,1), (1,0), then (1,1).\n\nSample Input 2\n\n1\n2 100 100\n\nSample Output 2\n\nNo\n\nIt is impossible to be at (100,100) two seconds after being at (0,0).\n\nSample Input 3\n\n2\n5 1 1\n100 1 1\n\nSample Output 3\n\nNo", "sample_input": "2\n3 1 2\n6 1 1\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03457", "source_text": "Score : 300 points\n\nProblem Statement\n\nAtCoDeer the deer is going on a trip in a two-dimensional plane.\nIn his plan, he will depart from point (0, 0) at time 0, then for each i between 1 and N (inclusive), he will visit point (x_i,y_i) at time t_i.\n\nIf AtCoDeer is at point (x, y) at time t, he can be at one of the following points at time t+1: (x+1,y), (x-1,y), (x,y+1) and (x,y-1).\nNote that he cannot stay at his place.\nDetermine whether he can carry out his plan.\n\nConstraints\n\n1 ≤ N ≤ 10^5\n\n0 ≤ x_i ≤ 10^5\n\n0 ≤ y_i ≤ 10^5\n\n1 ≤ t_i ≤ 10^5\n\nt_i < t_{i+1} (1 ≤ i ≤ N-1)\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nt_1 x_1 y_1\nt_2 x_2 y_2\n:\nt_N x_N y_N\n\nOutput\n\nIf AtCoDeer can carry out his plan, print Yes; if he cannot, print No.\n\nSample Input 1\n\n2\n3 1 2\n6 1 1\n\nSample Output 1\n\nYes\n\nFor example, he can travel as follows: (0,0), (0,1), (1,1), (1,2), (1,1), (1,0), then (1,1).\n\nSample Input 2\n\n1\n2 100 100\n\nSample Output 2\n\nNo\n\nIt is impossible to be at (100,100) two seconds after being at (0,0).\n\nSample Input 3\n\n2\n5 1 1\n100 1 1\n\nSample Output 3\n\nNo", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 517, "cpu_time_ms": 69, "memory_kb": 8448}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s808218646", "group_id": "codeNet:p03469", "input_text": "let () = Scanf.scanf \"%s\" (fun s -> \"2018/01/\" ^ String.sub s 7 2)\n |> Printf.printf \"%s\\n\"\n", "language": "OCaml", "metadata": {"date": 1595901757, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p03469.html", "problem_id": "p03469", "resource_group": "low_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/OCaml/s808218646.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s808218646", "user_id": "u272377260"}, "prompt_components": {"gold_output": "2018/01/07\n", "input_to_evaluate": "let () = Scanf.scanf \"%s\" (fun s -> \"2018/01/\" ^ String.sub s 7 2)\n |> Printf.printf \"%s\\n\"\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nOn some day in January 2018, Takaki is writing a document. The document has a column where the current date is written in yyyy/mm/dd format. For example, January 23, 2018 should be written as 2018/01/23.\n\nAfter finishing the document, she noticed that she had mistakenly wrote 2017 at the beginning of the date column. Write a program that, when the string that Takaki wrote in the date column, S, is given as input, modifies the first four characters in S to 2018 and prints it.\n\nConstraints\n\nS is a string of length 10.\n\nThe first eight characters in S are 2017/01/.\n\nThe last two characters in S are digits and represent an integer between 1 and 31 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nReplace the first four characters in S with 2018 and print it.\n\nSample Input 1\n\n2017/01/07\n\nSample Output 1\n\n2018/01/07\n\nSample Input 2\n\n2017/01/31\n\nSample Output 2\n\n2018/01/31", "sample_input": "2017/01/07\n"}, "reference_outputs": ["2018/01/07\n"], "source_document_id": "p03469", "source_text": "Score : 100 points\n\nProblem Statement\n\nOn some day in January 2018, Takaki is writing a document. The document has a column where the current date is written in yyyy/mm/dd format. For example, January 23, 2018 should be written as 2018/01/23.\n\nAfter finishing the document, she noticed that she had mistakenly wrote 2017 at the beginning of the date column. Write a program that, when the string that Takaki wrote in the date column, S, is given as input, modifies the first four characters in S to 2018 and prints it.\n\nConstraints\n\nS is a string of length 10.\n\nThe first eight characters in S are 2017/01/.\n\nThe last two characters in S are digits and represent an integer between 1 and 31 (inclusive).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nReplace the first four characters in S with 2018 and print it.\n\nSample Input 1\n\n2017/01/07\n\nSample Output 1\n\n2018/01/07\n\nSample Input 2\n\n2017/01/31\n\nSample Output 2\n\n2018/01/31", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 3740}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s528190507", "group_id": "codeNet:p03469", "input_text": "let rewrite s =\n let s_as_bytes = Bytes.of_string s in\n let _ = Bytes.set s_as_bytes 3 '8' in\n Bytes.to_string s_as_bytes\n \n\nlet () =\n let s = Scanf.scanf \"%s\" (fun x -> x) in\n let ans = rewrite s in\n Printf.printf \"%s\\n\" ans\n", "language": "OCaml", "metadata": {"date": 1592207716, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03469.html", "problem_id": "p03469", "resource_group": "low_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/OCaml/s528190507.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s528190507", "user_id": "u589100520"}, "prompt_components": {"gold_output": "2018/01/07\n", "input_to_evaluate": "let rewrite s =\n let s_as_bytes = Bytes.of_string s in\n let _ = Bytes.set s_as_bytes 3 '8' in\n Bytes.to_string s_as_bytes\n \n\nlet () =\n let s = Scanf.scanf \"%s\" (fun x -> x) in\n let ans = rewrite s in\n Printf.printf \"%s\\n\" ans\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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s938535942", "group_id": "codeNet:p03470", "input_text": "open Core\n\nlet n = Scanf.scanf \"%d\" ident\n\nlet a =\n List.init n ~f:(fun _ -> Scanf.scanf \" %d\" Fn.id)\n\nlet ans = a |> List.dedup_and_sort ~compare:Int.compare |> List.length\n\nlet () = Printf.printf \"%d\\n\" ans\n", "language": "OCaml", "metadata": {"date": 1592665526, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p03470.html", "problem_id": "p03470", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03470/input.txt", "sample_output_relpath": "derived/input_output/data/p03470/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03470/OCaml/s938535942.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s938535942", "user_id": "u573744781"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "open Core\n\nlet n = Scanf.scanf \"%d\" ident\n\nlet a =\n List.init n ~f:(fun _ -> Scanf.scanf \" %d\" Fn.id)\n\nlet ans = a |> List.dedup_and_sort ~compare:Int.compare |> List.length\n\nlet () = Printf.printf \"%d\\n\" ans\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nAn X-layered kagami mochi (X ≥ 1) is a pile of X round mochi (rice cake) stacked vertically where each mochi (except the bottom one) has a smaller diameter than that of the mochi directly below it. For example, if you stack three mochi with diameters of 10, 8 and 6 centimeters from bottom to top in this order, you have a 3-layered kagami mochi; if you put just one mochi, you have a 1-layered kagami mochi.\n\nLunlun the dachshund has N round mochi, and the diameter of the i-th mochi is d_i centimeters. When we make a kagami mochi using some or all of them, at most how many layers can our kagami mochi have?\n\nConstraints\n\n1 ≤ N ≤ 100\n\n1 ≤ d_i ≤ 100\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nd_1\n:\nd_N\n\nOutput\n\nPrint the maximum number of layers in a kagami mochi that can be made.\n\nSample Input 1\n\n4\n10\n8\n8\n6\n\nSample Output 1\n\n3\n\nIf we stack the mochi with diameters of 10, 8 and 6 centimeters from bottom to top in this order, we have a 3-layered kagami mochi, which is the maximum number of layers.\n\nSample Input 2\n\n3\n15\n15\n15\n\nSample Output 2\n\n1\n\nWhen all the mochi have the same diameter, we can only have a 1-layered kagami mochi.\n\nSample Input 3\n\n7\n50\n30\n50\n100\n50\n80\n30\n\nSample Output 3\n\n4", "sample_input": "4\n10\n8\n8\n6\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03470", "source_text": "Score : 200 points\n\nProblem Statement\n\nAn X-layered kagami mochi (X ≥ 1) is a pile of X round mochi (rice cake) stacked vertically where each mochi (except the bottom one) has a smaller diameter than that of the mochi directly below it. For example, if you stack three mochi with diameters of 10, 8 and 6 centimeters from bottom to top in this order, you have a 3-layered kagami mochi; if you put just one mochi, you have a 1-layered kagami mochi.\n\nLunlun the dachshund has N round mochi, and the diameter of the i-th mochi is d_i centimeters. When we make a kagami mochi using some or all of them, at most how many layers can our kagami mochi have?\n\nConstraints\n\n1 ≤ N ≤ 100\n\n1 ≤ d_i ≤ 100\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nd_1\n:\nd_N\n\nOutput\n\nPrint the maximum number of layers in a kagami mochi that can be made.\n\nSample Input 1\n\n4\n10\n8\n8\n6\n\nSample Output 1\n\n3\n\nIf we stack the mochi with diameters of 10, 8 and 6 centimeters from bottom to top in this order, we have a 3-layered kagami mochi, which is the maximum number of layers.\n\nSample Input 2\n\n3\n15\n15\n15\n\nSample Output 2\n\n1\n\nWhen all the mochi have the same diameter, we can only have a 1-layered kagami mochi.\n\nSample Input 3\n\n7\n50\n30\n50\n100\n50\n80\n30\n\nSample Output 3\n\n4", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 210, "cpu_time_ms": 17, "memory_kb": 13584}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s781010127", "group_id": "codeNet:p03470", "input_text": "let n = Scanf.scanf \" %d\" (+) 0\nlet ds = Array.to_list @@ Array.init n @@ fun _ -> Scanf.scanf \" %d\" (+) 0\nlet _ = List.sort_uniq compare ds |> List.length |> Printf.printf \"%d\\n\"", "language": "OCaml", "metadata": {"date": 1562872884, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03470.html", "problem_id": "p03470", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03470/input.txt", "sample_output_relpath": "derived/input_output/data/p03470/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03470/OCaml/s781010127.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s781010127", "user_id": "u732304692"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "let n = Scanf.scanf \" %d\" (+) 0\nlet ds = Array.to_list @@ Array.init n @@ fun _ -> Scanf.scanf \" %d\" (+) 0\nlet _ = List.sort_uniq compare ds |> List.length |> Printf.printf \"%d\\n\"", "problem_context": "Score : 200 points\n\nProblem Statement\n\nAn X-layered kagami mochi (X ≥ 1) is a pile of X round mochi (rice cake) stacked vertically where each mochi (except the bottom one) has a smaller diameter than that of the mochi directly below it. For example, if you stack three mochi with diameters of 10, 8 and 6 centimeters from bottom to top in this order, you have a 3-layered kagami mochi; if you put just one mochi, you have a 1-layered kagami mochi.\n\nLunlun the dachshund has N round mochi, and the diameter of the i-th mochi is d_i centimeters. When we make a kagami mochi using some or all of them, at most how many layers can our kagami mochi have?\n\nConstraints\n\n1 ≤ N ≤ 100\n\n1 ≤ d_i ≤ 100\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nd_1\n:\nd_N\n\nOutput\n\nPrint the maximum number of layers in a kagami mochi that can be made.\n\nSample Input 1\n\n4\n10\n8\n8\n6\n\nSample Output 1\n\n3\n\nIf we stack the mochi with diameters of 10, 8 and 6 centimeters from bottom to top in this order, we have a 3-layered kagami mochi, which is the maximum number of layers.\n\nSample Input 2\n\n3\n15\n15\n15\n\nSample Output 2\n\n1\n\nWhen all the mochi have the same diameter, we can only have a 1-layered kagami mochi.\n\nSample Input 3\n\n7\n50\n30\n50\n100\n50\n80\n30\n\nSample Output 3\n\n4", "sample_input": "4\n10\n8\n8\n6\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03470", "source_text": "Score : 200 points\n\nProblem Statement\n\nAn X-layered kagami mochi (X ≥ 1) is a pile of X round mochi (rice cake) stacked vertically where each mochi (except the bottom one) has a smaller diameter than that of the mochi directly below it. For example, if you stack three mochi with diameters of 10, 8 and 6 centimeters from bottom to top in this order, you have a 3-layered kagami mochi; if you put just one mochi, you have a 1-layered kagami mochi.\n\nLunlun the dachshund has N round mochi, and the diameter of the i-th mochi is d_i centimeters. When we make a kagami mochi using some or all of them, at most how many layers can our kagami mochi have?\n\nConstraints\n\n1 ≤ N ≤ 100\n\n1 ≤ d_i ≤ 100\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nd_1\n:\nd_N\n\nOutput\n\nPrint the maximum number of layers in a kagami mochi that can be made.\n\nSample Input 1\n\n4\n10\n8\n8\n6\n\nSample Output 1\n\n3\n\nIf we stack the mochi with diameters of 10, 8 and 6 centimeters from bottom to top in this order, we have a 3-layered kagami mochi, which is the maximum number of layers.\n\nSample Input 2\n\n3\n15\n15\n15\n\nSample Output 2\n\n1\n\nWhen all the mochi have the same diameter, we can only have a 1-layered kagami mochi.\n\nSample Input 3\n\n7\n50\n30\n50\n100\n50\n80\n30\n\nSample Output 3\n\n4", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 512}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s491147609", "group_id": "codeNet:p03470", "input_text": "let input () =\n let n = int_of_string (read_line ())\n in let rec ds i result = if i >= n\n then result\n else let input = int_of_string (read_line ())\n in ds (i+1) (input::result)\n in List.rev (ds 0 [])\n\nlet remove_duplicate (x::xs) = \n let rec remove_duplicate' prev l = \n match l with\n | [] -> []\n | x::xs -> if x == prev \n then remove_duplicate' x xs\n else x :: (remove_duplicate' x xs)\n in x :: (remove_duplicate' x xs)\n\nlet _ = List.sort (Pervasives.compare) (input ())\n |> remove_duplicate\n |> List.length \n |> print_int \n |> print_newline", "language": "OCaml", "metadata": {"date": 1519076356, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03470.html", "problem_id": "p03470", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03470/input.txt", "sample_output_relpath": "derived/input_output/data/p03470/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03470/OCaml/s491147609.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s491147609", "user_id": "u219949952"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "let input () =\n let n = int_of_string (read_line ())\n in let rec ds i result = if i >= n\n then result\n else let input = int_of_string (read_line ())\n in ds (i+1) (input::result)\n in List.rev (ds 0 [])\n\nlet remove_duplicate (x::xs) = \n let rec remove_duplicate' prev l = \n match l with\n | [] -> []\n | x::xs -> if x == prev \n then remove_duplicate' x xs\n else x :: (remove_duplicate' x xs)\n in x :: (remove_duplicate' x xs)\n\nlet _ = List.sort (Pervasives.compare) (input ())\n |> remove_duplicate\n |> List.length \n |> print_int \n |> print_newline", "problem_context": "Score : 200 points\n\nProblem Statement\n\nAn X-layered kagami mochi (X ≥ 1) is a pile of X round mochi (rice cake) stacked vertically where each mochi (except the bottom one) has a smaller diameter than that of the mochi directly below it. For example, if you stack three mochi with diameters of 10, 8 and 6 centimeters from bottom to top in this order, you have a 3-layered kagami mochi; if you put just one mochi, you have a 1-layered kagami mochi.\n\nLunlun the dachshund has N round mochi, and the diameter of the i-th mochi is d_i centimeters. When we make a kagami mochi using some or all of them, at most how many layers can our kagami mochi have?\n\nConstraints\n\n1 ≤ N ≤ 100\n\n1 ≤ d_i ≤ 100\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nd_1\n:\nd_N\n\nOutput\n\nPrint the maximum number of layers in a kagami mochi that can be made.\n\nSample Input 1\n\n4\n10\n8\n8\n6\n\nSample Output 1\n\n3\n\nIf we stack the mochi with diameters of 10, 8 and 6 centimeters from bottom to top in this order, we have a 3-layered kagami mochi, which is the maximum number of layers.\n\nSample Input 2\n\n3\n15\n15\n15\n\nSample Output 2\n\n1\n\nWhen all the mochi have the same diameter, we can only have a 1-layered kagami mochi.\n\nSample Input 3\n\n7\n50\n30\n50\n100\n50\n80\n30\n\nSample Output 3\n\n4", "sample_input": "4\n10\n8\n8\n6\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03470", "source_text": "Score : 200 points\n\nProblem Statement\n\nAn X-layered kagami mochi (X ≥ 1) is a pile of X round mochi (rice cake) stacked vertically where each mochi (except the bottom one) has a smaller diameter than that of the mochi directly below it. For example, if you stack three mochi with diameters of 10, 8 and 6 centimeters from bottom to top in this order, you have a 3-layered kagami mochi; if you put just one mochi, you have a 1-layered kagami mochi.\n\nLunlun the dachshund has N round mochi, and the diameter of the i-th mochi is d_i centimeters. When we make a kagami mochi using some or all of them, at most how many layers can our kagami mochi have?\n\nConstraints\n\n1 ≤ N ≤ 100\n\n1 ≤ d_i ≤ 100\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nd_1\n:\nd_N\n\nOutput\n\nPrint the maximum number of layers in a kagami mochi that can be made.\n\nSample Input 1\n\n4\n10\n8\n8\n6\n\nSample Output 1\n\n3\n\nIf we stack the mochi with diameters of 10, 8 and 6 centimeters from bottom to top in this order, we have a 3-layered kagami mochi, which is the maximum number of layers.\n\nSample Input 2\n\n3\n15\n15\n15\n\nSample Output 2\n\n1\n\nWhen all the mochi have the same diameter, we can only have a 1-layered kagami mochi.\n\nSample Input 3\n\n7\n50\n30\n50\n100\n50\n80\n30\n\nSample Output 3\n\n4", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s832278357", "group_id": "codeNet:p03473", "input_text": "let () = Scanf.scanf \"%d\" (fun m -> 48 - m)\n |> Printf.printf \"%d\\n\"", "language": "OCaml", "metadata": {"date": 1595901890, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p03473.html", "problem_id": "p03473", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03473/input.txt", "sample_output_relpath": "derived/input_output/data/p03473/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03473/OCaml/s832278357.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s832278357", "user_id": "u272377260"}, "prompt_components": {"gold_output": "27\n", "input_to_evaluate": "let () = Scanf.scanf \"%d\" (fun m -> 48 - m)\n |> Printf.printf \"%d\\n\"", "problem_context": "Score : 100 points\n\nProblem Statement\n\nHow many hours do we have until New Year at M o'clock (24-hour notation) on 30th, December?\n\nConstraints\n\n1≤M≤23\n\nM is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nM\n\nOutput\n\nIf we have x hours until New Year at M o'clock on 30th, December, print x.\n\nSample Input 1\n\n21\n\nSample Output 1\n\n27\n\nWe have 27 hours until New Year at 21 o'clock on 30th, December.\n\nSample Input 2\n\n12\n\nSample Output 2\n\n36", "sample_input": "21\n"}, "reference_outputs": ["27\n"], "source_document_id": "p03473", "source_text": "Score : 100 points\n\nProblem Statement\n\nHow many hours do we have until New Year at M o'clock (24-hour notation) on 30th, December?\n\nConstraints\n\n1≤M≤23\n\nM is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nM\n\nOutput\n\nIf we have x hours until New Year at M o'clock on 30th, December, print x.\n\nSample Input 1\n\n21\n\nSample Output 1\n\n27\n\nWe have 27 hours until New Year at 21 o'clock on 30th, December.\n\nSample Input 2\n\n12\n\nSample Output 2\n\n36", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 10, "memory_kb": 3800}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s207699448", "group_id": "codeNet:p03473", "input_text": "let () = Scanf.scanf \"%d\" (fun a -> Printf.printf \"%d\\n\" (48 - a))\n", "language": "OCaml", "metadata": {"date": 1519667756, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03473.html", "problem_id": "p03473", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03473/input.txt", "sample_output_relpath": "derived/input_output/data/p03473/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03473/OCaml/s207699448.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s207699448", "user_id": "u798181098"}, "prompt_components": {"gold_output": "27\n", "input_to_evaluate": "let () = Scanf.scanf \"%d\" (fun a -> Printf.printf \"%d\\n\" (48 - a))\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nHow many hours do we have until New Year at M o'clock (24-hour notation) on 30th, December?\n\nConstraints\n\n1≤M≤23\n\nM is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nM\n\nOutput\n\nIf we have x hours until New Year at M o'clock on 30th, December, print x.\n\nSample Input 1\n\n21\n\nSample Output 1\n\n27\n\nWe have 27 hours until New Year at 21 o'clock on 30th, December.\n\nSample Input 2\n\n12\n\nSample Output 2\n\n36", "sample_input": "21\n"}, "reference_outputs": ["27\n"], "source_document_id": "p03473", "source_text": "Score : 100 points\n\nProblem Statement\n\nHow many hours do we have until New Year at M o'clock (24-hour notation) on 30th, December?\n\nConstraints\n\n1≤M≤23\n\nM is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nM\n\nOutput\n\nIf we have x hours until New Year at M o'clock on 30th, December, print x.\n\nSample Input 1\n\n21\n\nSample Output 1\n\n27\n\nWe have 27 hours until New Year at 21 o'clock on 30th, December.\n\nSample Input 2\n\n12\n\nSample Output 2\n\n36", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s210390535", "group_id": "codeNet:p03474", "input_text": "let a, b, s = Scanf.scanf \" %d %d %s\" @@ fun a b c -> a, b, c\nlet f s x = let n = ref 0 in String.iter (fun c -> if c = x then incr n) s; !n\nlet _ = print_endline @@ if s.[a] = '-' && f s '-' = 1 then \"Yes\" else \"No\"", "language": "OCaml", "metadata": {"date": 1564730984, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03474.html", "problem_id": "p03474", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03474/input.txt", "sample_output_relpath": "derived/input_output/data/p03474/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03474/OCaml/s210390535.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s210390535", "user_id": "u732304692"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "let a, b, s = Scanf.scanf \" %d %d %s\" @@ fun a b c -> a, b, c\nlet f s x = let n = ref 0 in String.iter (fun c -> if c = x then incr n) s; !n\nlet _ = print_endline @@ if s.[a] = '-' && f s '-' = 1 then \"Yes\" else \"No\"", "problem_context": "Score : 200 points\n\nProblem Statement\n\nThe postal code in Atcoder Kingdom is A+B+1 characters long, its (A+1)-th character is a hyphen -, and the other characters are digits from 0 through 9.\n\nYou are given a string S. Determine whether it follows the postal code format in Atcoder Kingdom.\n\nConstraints\n\n1≤A,B≤5\n\n|S|=A+B+1\n\nS consists of - and digits from 0 through 9.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\nS\n\nOutput\n\nPrint Yes if S follows the postal code format in AtCoder Kingdom; print No otherwise.\n\nSample Input 1\n\n3 4\n269-6650\n\nSample Output 1\n\nYes\n\nThe (A+1)-th character of S is -, and the other characters are digits from 0 through 9, so it follows the format.\n\nSample Input 2\n\n1 1\n---\n\nSample Output 2\n\nNo\n\nS contains unnecessary -s other than the (A+1)-th character, so it does not follow the format.\n\nSample Input 3\n\n1 2\n7444\n\nSample Output 3\n\nNo", "sample_input": "3 4\n269-6650\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03474", "source_text": "Score : 200 points\n\nProblem Statement\n\nThe postal code in Atcoder Kingdom is A+B+1 characters long, its (A+1)-th character is a hyphen -, and the other characters are digits from 0 through 9.\n\nYou are given a string S. Determine whether it follows the postal code format in Atcoder Kingdom.\n\nConstraints\n\n1≤A,B≤5\n\n|S|=A+B+1\n\nS consists of - and digits from 0 through 9.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\nS\n\nOutput\n\nPrint Yes if S follows the postal code format in AtCoder Kingdom; print No otherwise.\n\nSample Input 1\n\n3 4\n269-6650\n\nSample Output 1\n\nYes\n\nThe (A+1)-th character of S is -, and the other characters are digits from 0 through 9, so it follows the format.\n\nSample Input 2\n\n1 1\n---\n\nSample Output 2\n\nNo\n\nS contains unnecessary -s other than the (A+1)-th character, so it does not follow the format.\n\nSample Input 3\n\n1 2\n7444\n\nSample Output 3\n\nNo", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 216, "cpu_time_ms": 1, "memory_kb": 2432}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s494838419", "group_id": "codeNet:p03474", "input_text": "let a, b = Scanf.scanf \" %d %d\" @@ fun a b -> a, b\nlet s = Scanf.scanf \" %s\" @@ fun s -> s\nlet is_digit c = 48 <= Char.code c && Char.code c <= 57\nlet c = Array.fold_left (+) 0 @@ Array.init (a + b + 1) @@ fun i -> if is_digit s.[i] then 1 else 0\nlet _ = print_endline @@ if c = a + b && s.[a] = '-' then \"Yes\" else \"No\"", "language": "OCaml", "metadata": {"date": 1562060747, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03474.html", "problem_id": "p03474", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03474/input.txt", "sample_output_relpath": "derived/input_output/data/p03474/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03474/OCaml/s494838419.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s494838419", "user_id": "u732304692"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "let a, b = Scanf.scanf \" %d %d\" @@ fun a b -> a, b\nlet s = Scanf.scanf \" %s\" @@ fun s -> s\nlet is_digit c = 48 <= Char.code c && Char.code c <= 57\nlet c = Array.fold_left (+) 0 @@ Array.init (a + b + 1) @@ fun i -> if is_digit s.[i] then 1 else 0\nlet _ = print_endline @@ if c = a + b && s.[a] = '-' then \"Yes\" else \"No\"", "problem_context": "Score : 200 points\n\nProblem Statement\n\nThe postal code in Atcoder Kingdom is A+B+1 characters long, its (A+1)-th character is a hyphen -, and the other characters are digits from 0 through 9.\n\nYou are given a string S. Determine whether it follows the postal code format in Atcoder Kingdom.\n\nConstraints\n\n1≤A,B≤5\n\n|S|=A+B+1\n\nS consists of - and digits from 0 through 9.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\nS\n\nOutput\n\nPrint Yes if S follows the postal code format in AtCoder Kingdom; print No otherwise.\n\nSample Input 1\n\n3 4\n269-6650\n\nSample Output 1\n\nYes\n\nThe (A+1)-th character of S is -, and the other characters are digits from 0 through 9, so it follows the format.\n\nSample Input 2\n\n1 1\n---\n\nSample Output 2\n\nNo\n\nS contains unnecessary -s other than the (A+1)-th character, so it does not follow the format.\n\nSample Input 3\n\n1 2\n7444\n\nSample Output 3\n\nNo", "sample_input": "3 4\n269-6650\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03474", "source_text": "Score : 200 points\n\nProblem Statement\n\nThe postal code in Atcoder Kingdom is A+B+1 characters long, its (A+1)-th character is a hyphen -, and the other characters are digits from 0 through 9.\n\nYou are given a string S. Determine whether it follows the postal code format in Atcoder Kingdom.\n\nConstraints\n\n1≤A,B≤5\n\n|S|=A+B+1\n\nS consists of - and digits from 0 through 9.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\nS\n\nOutput\n\nPrint Yes if S follows the postal code format in AtCoder Kingdom; print No otherwise.\n\nSample Input 1\n\n3 4\n269-6650\n\nSample Output 1\n\nYes\n\nThe (A+1)-th character of S is -, and the other characters are digits from 0 through 9, so it follows the format.\n\nSample Input 2\n\n1 1\n---\n\nSample Output 2\n\nNo\n\nS contains unnecessary -s other than the (A+1)-th character, so it does not follow the format.\n\nSample Input 3\n\n1 2\n7444\n\nSample Output 3\n\nNo", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s374783633", "group_id": "codeNet:p03476", "input_text": "\nopen Scanf\nopen Printf\n\nlet flip f x y = f y x\n\nlet rec range a b = if a >= b then [] else a :: range (a+1) b\n\nlet read_int () = scanf \" %d\" (fun x -> x)\nlet rec read_ints n = if n = 0 then [] else let i = read_int () in i :: read_ints (n-1)\n\nlet rec for_iter a b f = if a >= b then [] else let x = f a in x :: for_iter (a+1) b f\nlet rec for_iter_ a b f = if a >= b then () else (f a; for_iter_ (a+1) b f)\nlet rec for_iterr_ a b f = if a <= b then () else (f a; for_iterr_ (a-1) b f)\n\nlet gen_table ubound =\n let res = Array.make ubound 1 in\n res.(0) <- 0; res.(1) <- 0;\n for_iter_ 2 ubound (fun i ->\n if res.(i) > 0 then for_iter_ 2 (ubound / i) @@ fun j -> res.(i*j) <- 0);\n for_iterr_ ((ubound+1)/2) 1 (fun a ->\n let i = 2*a-1 in\n res.(i) <- if res.(i) = 1 && res.((i+1)/2) = 1 then 1 else 0);\n res.(2) <- 0;\n for_iter_ 1 ubound (fun i -> res.(i) <- res.(i) + res.(i-1));\n res\n\nlet () =\n let q = read_int () in\n let rs = for_iter 0 q (fun _ -> let l = read_int () in let r = read_int () in (l, r)) in\n let table = gen_table 200010 in\n flip List.iter rs (fun (l, r) -> printf \"%d\\n\" (table.(r) - table.(l-1)))\n\n\n", "language": "OCaml", "metadata": {"date": 1519105819, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03476.html", "problem_id": "p03476", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03476/input.txt", "sample_output_relpath": "derived/input_output/data/p03476/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03476/OCaml/s374783633.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s374783633", "user_id": "u798181098"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "\nopen Scanf\nopen Printf\n\nlet flip f x y = f y x\n\nlet rec range a b = if a >= b then [] else a :: range (a+1) b\n\nlet read_int () = scanf \" %d\" (fun x -> x)\nlet rec read_ints n = if n = 0 then [] else let i = read_int () in i :: read_ints (n-1)\n\nlet rec for_iter a b f = if a >= b then [] else let x = f a in x :: for_iter (a+1) b f\nlet rec for_iter_ a b f = if a >= b then () else (f a; for_iter_ (a+1) b f)\nlet rec for_iterr_ a b f = if a <= b then () else (f a; for_iterr_ (a-1) b f)\n\nlet gen_table ubound =\n let res = Array.make ubound 1 in\n res.(0) <- 0; res.(1) <- 0;\n for_iter_ 2 ubound (fun i ->\n if res.(i) > 0 then for_iter_ 2 (ubound / i) @@ fun j -> res.(i*j) <- 0);\n for_iterr_ ((ubound+1)/2) 1 (fun a ->\n let i = 2*a-1 in\n res.(i) <- if res.(i) = 1 && res.((i+1)/2) = 1 then 1 else 0);\n res.(2) <- 0;\n for_iter_ 1 ubound (fun i -> res.(i) <- res.(i) + res.(i-1));\n res\n\nlet () =\n let q = read_int () in\n let rs = for_iter 0 q (fun _ -> let l = read_int () in let r = read_int () in (l, r)) in\n let table = gen_table 200010 in\n flip List.iter rs (fun (l, r) -> printf \"%d\\n\" (table.(r) - table.(l-1)))\n\n\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nWe say that a odd number N is similar to 2017 when both N and (N+1)/2 are prime.\n\nYou are given Q queries.\n\nIn the i-th query, given two odd numbers l_i and r_i, find the number of odd numbers x similar to 2017 such that l_i ≤ x ≤ r_i.\n\nConstraints\n\n1≤Q≤10^5\n\n1≤l_i≤r_i≤10^5\n\nl_i and r_i are odd.\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nQ\nl_1 r_1\n:\nl_Q r_Q\n\nOutput\n\nPrint Q lines. The i-th line (1≤i≤Q) should contain the response to the i-th query.\n\nSample Input 1\n\n1\n3 7\n\nSample Output 1\n\n2\n\n3 is similar to 2017, since both 3 and (3+1)/2=2 are prime.\n\n5 is similar to 2017, since both 5 and (5+1)/2=3 are prime.\n\n7 is not similar to 2017, since (7+1)/2=4 is not prime, although 7 is prime.\n\nThus, the response to the first query should be 2.\n\nSample Input 2\n\n4\n13 13\n7 11\n7 11\n2017 2017\n\nSample Output 2\n\n1\n0\n0\n1\n\nNote that 2017 is also similar to 2017.\n\nSample Input 3\n\n6\n1 53\n13 91\n37 55\n19 51\n73 91\n13 49\n\nSample Output 3\n\n4\n4\n1\n1\n1\n2", "sample_input": "1\n3 7\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03476", "source_text": "Score : 400 points\n\nProblem Statement\n\nWe say that a odd number N is similar to 2017 when both N and (N+1)/2 are prime.\n\nYou are given Q queries.\n\nIn the i-th query, given two odd numbers l_i and r_i, find the number of odd numbers x similar to 2017 such that l_i ≤ x ≤ r_i.\n\nConstraints\n\n1≤Q≤10^5\n\n1≤l_i≤r_i≤10^5\n\nl_i and r_i are odd.\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nQ\nl_1 r_1\n:\nl_Q r_Q\n\nOutput\n\nPrint Q lines. The i-th line (1≤i≤Q) should contain the response to the i-th query.\n\nSample Input 1\n\n1\n3 7\n\nSample Output 1\n\n2\n\n3 is similar to 2017, since both 3 and (3+1)/2=2 are prime.\n\n5 is similar to 2017, since both 5 and (5+1)/2=3 are prime.\n\n7 is not similar to 2017, since (7+1)/2=4 is not prime, although 7 is prime.\n\nThus, the response to the first query should be 2.\n\nSample Input 2\n\n4\n13 13\n7 11\n7 11\n2017 2017\n\nSample Output 2\n\n1\n0\n0\n1\n\nNote that 2017 is also similar to 2017.\n\nSample Input 3\n\n6\n1 53\n13 91\n37 55\n19 51\n73 91\n13 49\n\nSample Output 3\n\n4\n4\n1\n1\n1\n2", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1135, "cpu_time_ms": 104, "memory_kb": 14592}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s003271488", "group_id": "codeNet:p03477", "input_text": "Scanf.scanf \"%d %d %d %d\" (fun a b c d ->\n let q = a + b in\n let r = c + d in\n print_endline @@\n if q > r then \"Left\" else\n if q < r then \"Right\" else \"Balanced\"\n)", "language": "OCaml", "metadata": {"date": 1600228171, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p03477.html", "problem_id": "p03477", "resource_group": "low_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/OCaml/s003271488.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s003271488", "user_id": "u342443598"}, "prompt_components": {"gold_output": "Left\n", "input_to_evaluate": "Scanf.scanf \"%d %d %d %d\" (fun a b c d ->\n let q = a + b in\n let r = c + d in\n print_endline @@\n if q > r then \"Left\" else\n if q < r then \"Right\" else \"Balanced\"\n)", "problem_context": "Score : 100 points\n\nProblem Statement\n\nA balance scale tips to the left if L>R, where L is the total weight of the masses on the left pan and R is the total weight of the masses on the right pan. Similarly, it balances if L=R, and tips to the right if L8, we should print Left.\n\nSample Input 2\n\n3 4 5 2\n\nSample Output 2\n\nBalanced\n\nThe total weight of the masses on the left pan is 7, and the total weight of the masses on the right pan is 7. Since 7=7, we should print Balanced.\n\nSample Input 3\n\n1 7 6 4\n\nSample Output 3\n\nRight\n\nThe total weight of the masses on the left pan is 8, and the total weight of the masses on the right pan is 10. Since 8<10, we should print Right.", "sample_input": "3 8 7 1\n"}, "reference_outputs": ["Left\n"], "source_document_id": "p03477", "source_text": "Score : 100 points\n\nProblem Statement\n\nA balance scale tips to the left if L>R, where L is the total weight of the masses on the left pan and R is the total weight of the masses on the right pan. Similarly, it balances if L=R, and tips to the right if L8, we should print Left.\n\nSample Input 2\n\n3 4 5 2\n\nSample Output 2\n\nBalanced\n\nThe total weight of the masses on the left pan is 7, and the total weight of the masses on the right pan is 7. Since 7=7, we should print Balanced.\n\nSample Input 3\n\n1 7 6 4\n\nSample Output 3\n\nRight\n\nThe total weight of the masses on the left pan is 8, and the total weight of the masses on the right pan is 10. Since 8<10, we should print Right.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 3716}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s959837423", "group_id": "codeNet:p03477", "input_text": "\nopen Scanf\nopen Printf\n\nlet flip f x y = f y x\n\nlet rec range a b = if a >= b then [] else a :: range (a+1) b\n\nlet read_int () = scanf \" %d\" (fun x -> x)\nlet rec read_ints n = if n = 0 then [] else let i = read_int () in i :: read_ints (n-1)\n\nlet rec for_iter a b f = if a >= b then [] else let x = f a in x :: for_iter (a+1) b f\n\nlet () =\n let [a; b; c; d] = read_ints 4 in\n let res = if a+b > c+d then \"Left\" else if a+b < c+d then \"Right\" else \"Balanced\" in\n printf \"%s\\n\" res\n", "language": "OCaml", "metadata": {"date": 1519106134, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03477.html", "problem_id": "p03477", "resource_group": "low_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/OCaml/s959837423.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s959837423", "user_id": "u798181098"}, "prompt_components": {"gold_output": "Left\n", "input_to_evaluate": "\nopen Scanf\nopen Printf\n\nlet flip f x y = f y x\n\nlet rec range a b = if a >= b then [] else a :: range (a+1) b\n\nlet read_int () = scanf \" %d\" (fun x -> x)\nlet rec read_ints n = if n = 0 then [] else let i = read_int () in i :: read_ints (n-1)\n\nlet rec for_iter a b f = if a >= b then [] else let x = f a in x :: for_iter (a+1) b f\n\nlet () =\n let [a; b; c; d] = read_ints 4 in\n let res = if a+b > c+d then \"Left\" else if a+b < c+d then \"Right\" else \"Balanced\" in\n printf \"%s\\n\" res\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nA balance scale tips to the left if L>R, where L is the total weight of the masses on the left pan and R is the total weight of the masses on the right pan. Similarly, it balances if L=R, and tips to the right if L8, we should print Left.\n\nSample Input 2\n\n3 4 5 2\n\nSample Output 2\n\nBalanced\n\nThe total weight of the masses on the left pan is 7, and the total weight of the masses on the right pan is 7. Since 7=7, we should print Balanced.\n\nSample Input 3\n\n1 7 6 4\n\nSample Output 3\n\nRight\n\nThe total weight of the masses on the left pan is 8, and the total weight of the masses on the right pan is 10. Since 8<10, we should print Right.", "sample_input": "3 8 7 1\n"}, "reference_outputs": ["Left\n"], "source_document_id": "p03477", "source_text": "Score : 100 points\n\nProblem Statement\n\nA balance scale tips to the left if L>R, where L is the total weight of the masses on the left pan and R is the total weight of the masses on the right pan. Similarly, it balances if L=R, and tips to the right if L8, we should print Left.\n\nSample Input 2\n\n3 4 5 2\n\nSample Output 2\n\nBalanced\n\nThe total weight of the masses on the left pan is 7, and the total weight of the masses on the right pan is 7. Since 7=7, we should print Balanced.\n\nSample Input 3\n\n1 7 6 4\n\nSample Output 3\n\nRight\n\nThe total weight of the masses on the left pan is 8, and the total weight of the masses on the right pan is 10. Since 8<10, we should print Right.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 484, "cpu_time_ms": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s447173045", "group_id": "codeNet:p03477", "input_text": "let (a,b,c,d) = Scanf.scanf \"%d %d %d %d\\n\" (fun x y z w -> (x,y,z,w))\n\nlet () = if a + b > c + d then print_endline \"Left\"\n else if a + b < c + d then print_endline \"Right\"\n else print_endline \"Balanced\"\n", "language": "OCaml", "metadata": {"date": 1514081120, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03477.html", "problem_id": "p03477", "resource_group": "low_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/OCaml/s447173045.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s447173045", "user_id": "u459801769"}, "prompt_components": {"gold_output": "Left\n", "input_to_evaluate": "let (a,b,c,d) = Scanf.scanf \"%d %d %d %d\\n\" (fun x y z w -> (x,y,z,w))\n\nlet () = if a + b > c + d then print_endline \"Left\"\n else if a + b < c + d then print_endline \"Right\"\n else print_endline \"Balanced\"\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nA balance scale tips to the left if L>R, where L is the total weight of the masses on the left pan and R is the total weight of the masses on the right pan. Similarly, it balances if L=R, and tips to the right if L8, we should print Left.\n\nSample Input 2\n\n3 4 5 2\n\nSample Output 2\n\nBalanced\n\nThe total weight of the masses on the left pan is 7, and the total weight of the masses on the right pan is 7. Since 7=7, we should print Balanced.\n\nSample Input 3\n\n1 7 6 4\n\nSample Output 3\n\nRight\n\nThe total weight of the masses on the left pan is 8, and the total weight of the masses on the right pan is 10. Since 8<10, we should print Right.", "sample_input": "3 8 7 1\n"}, "reference_outputs": ["Left\n"], "source_document_id": "p03477", "source_text": "Score : 100 points\n\nProblem Statement\n\nA balance scale tips to the left if L>R, where L is the total weight of the masses on the left pan and R is the total weight of the masses on the right pan. Similarly, it balances if L=R, and tips to the right if L8, we should print Left.\n\nSample Input 2\n\n3 4 5 2\n\nSample Output 2\n\nBalanced\n\nThe total weight of the masses on the left pan is 7, and the total weight of the masses on the right pan is 7. Since 7=7, we should print Balanced.\n\nSample Input 3\n\n1 7 6 4\n\nSample Output 3\n\nRight\n\nThe total weight of the masses on the left pan is 8, and the total weight of the masses on the right pan is 10. Since 8<10, we should print Right.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s109974203", "group_id": "codeNet:p03479", "input_text": "\nopen Scanf\nopen Printf\n\nlet flip f x y = f y x\n\nlet rec range a b = if a >= b then [] else a :: range (a+1) b\n\nlet read_int () = scanf \" %d\" (fun x -> x)\nlet rec read_ints n = if n = 0 then [] else let i = read_int () in i :: read_ints (n-1)\n\nlet rec for_iter a b f = if a >= b then [] else let x = f a in x :: for_iter (a+1) b f\n\nlet rec solve v x y = if x > y then v else solve (v+1) (2*x) y\n\nlet () =\n let x = read_int () in let y = read_int () in\n solve 0 x y |> printf \"%d\\n\"\n", "language": "OCaml", "metadata": {"date": 1519106852, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03479.html", "problem_id": "p03479", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03479/input.txt", "sample_output_relpath": "derived/input_output/data/p03479/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03479/OCaml/s109974203.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s109974203", "user_id": "u798181098"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "\nopen Scanf\nopen Printf\n\nlet flip f x y = f y x\n\nlet rec range a b = if a >= b then [] else a :: range (a+1) b\n\nlet read_int () = scanf \" %d\" (fun x -> x)\nlet rec read_ints n = if n = 0 then [] else let i = read_int () in i :: read_ints (n-1)\n\nlet rec for_iter a b f = if a >= b then [] else let x = f a in x :: for_iter (a+1) b f\n\nlet rec solve v x y = if x > y then v else solve (v+1) (2*x) y\n\nlet () =\n let x = read_int () in let y = read_int () in\n solve 0 x y |> printf \"%d\\n\"\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nAs a token of his gratitude, Takahashi has decided to give his mother an integer sequence.\nThe sequence A needs to satisfy the conditions below:\n\nA consists of integers between X and Y (inclusive).\n\nFor each 1\\leq i \\leq |A|-1, A_{i+1} is a multiple of A_i and strictly greater than A_i.\n\nFind the maximum possible length of the sequence.\n\nConstraints\n\n1 \\leq X \\leq Y \\leq 10^{18}\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX Y\n\nOutput\n\nPrint the maximum possible length of the sequence.\n\nSample Input 1\n\n3 20\n\nSample Output 1\n\n3\n\nThe sequence 3,6,18 satisfies the conditions.\n\nSample Input 2\n\n25 100\n\nSample Output 2\n\n3\n\nSample Input 3\n\n314159265 358979323846264338\n\nSample Output 3\n\n31", "sample_input": "3 20\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03479", "source_text": "Score : 300 points\n\nProblem Statement\n\nAs a token of his gratitude, Takahashi has decided to give his mother an integer sequence.\nThe sequence A needs to satisfy the conditions below:\n\nA consists of integers between X and Y (inclusive).\n\nFor each 1\\leq i \\leq |A|-1, A_{i+1} is a multiple of A_i and strictly greater than A_i.\n\nFind the maximum possible length of the sequence.\n\nConstraints\n\n1 \\leq X \\leq Y \\leq 10^{18}\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX Y\n\nOutput\n\nPrint the maximum possible length of the sequence.\n\nSample Input 1\n\n3 20\n\nSample Output 1\n\n3\n\nThe sequence 3,6,18 satisfies the conditions.\n\nSample Input 2\n\n25 100\n\nSample Output 2\n\n3\n\nSample Input 3\n\n314159265 358979323846264338\n\nSample Output 3\n\n31", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 484, "cpu_time_ms": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s752469125", "group_id": "codeNet:p03480", "input_text": "let pr x = print_endline @@ string_of_int x\n\nlet fold f init s =\n let rec iter i res =\n if i < 0 then res else iter (i - 1) (f res s.[i]) in\n iter (String.length s - 1) init\n\nlet solve seq =\n let len = String.length seq in\n let (_,_,res) = fold\n (fun (cnt,pre,mv) x ->\n if x != pre then\n (cnt+1,x,min mv (max cnt (len - cnt)))\n else (cnt+1,x,mv))\n (0,seq.[0],len) seq in res\n\nlet () = input_line stdin\n |> solve\n |> pr", "language": "OCaml", "metadata": {"date": 1514132775, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03480.html", "problem_id": "p03480", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03480/input.txt", "sample_output_relpath": "derived/input_output/data/p03480/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03480/OCaml/s752469125.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s752469125", "user_id": "u459801769"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "let pr x = print_endline @@ string_of_int x\n\nlet fold f init s =\n let rec iter i res =\n if i < 0 then res else iter (i - 1) (f res s.[i]) in\n iter (String.length s - 1) init\n\nlet solve seq =\n let len = String.length seq in\n let (_,_,res) = fold\n (fun (cnt,pre,mv) x ->\n if x != pre then\n (cnt+1,x,min mv (max cnt (len - cnt)))\n else (cnt+1,x,mv))\n (0,seq.[0],len) seq in res\n\nlet () = input_line stdin\n |> solve\n |> pr", "problem_context": "Score : 500 points\n\nProblem Statement\n\nYou are given a string S consisting of 0 and 1.\nFind the maximum integer K not greater than |S| such that we can turn all the characters of S into 0 by repeating the following operation some number of times.\n\nChoose a contiguous segment [l,r] in S whose length is at least K (that is, r-l+1\\geq K must be satisfied). For each integer i such that l\\leq i\\leq r, do the following: if S_i is 0, replace it with 1; if S_i is 1, replace it with 0.\n\nConstraints\n\n1\\leq |S|\\leq 10^5\n\nS_i(1\\leq i\\leq N) is either 0 or 1.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the maximum integer K such that we can turn all the characters of S into 0 by repeating the operation some number of times.\n\nSample Input 1\n\n010\n\nSample Output 1\n\n2\n\nWe can turn all the characters of S into 0 by the following operations:\n\nPerform the operation on the segment S[1,3] with length 3. S is now 101.\n\nPerform the operation on the segment S[1,2] with length 2. S is now 011.\n\nPerform the operation on the segment S[2,3] with length 2. S is now 000.\n\nSample Input 2\n\n100000000\n\nSample Output 2\n\n8\n\nSample Input 3\n\n00001111\n\nSample Output 3\n\n4", "sample_input": "010\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03480", "source_text": "Score : 500 points\n\nProblem Statement\n\nYou are given a string S consisting of 0 and 1.\nFind the maximum integer K not greater than |S| such that we can turn all the characters of S into 0 by repeating the following operation some number of times.\n\nChoose a contiguous segment [l,r] in S whose length is at least K (that is, r-l+1\\geq K must be satisfied). For each integer i such that l\\leq i\\leq r, do the following: if S_i is 0, replace it with 1; if S_i is 1, replace it with 0.\n\nConstraints\n\n1\\leq |S|\\leq 10^5\n\nS_i(1\\leq i\\leq N) is either 0 or 1.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint the maximum integer K such that we can turn all the characters of S into 0 by repeating the operation some number of times.\n\nSample Input 1\n\n010\n\nSample Output 1\n\n2\n\nWe can turn all the characters of S into 0 by the following operations:\n\nPerform the operation on the segment S[1,3] with length 3. S is now 101.\n\nPerform the operation on the segment S[1,2] with length 2. S is now 011.\n\nPerform the operation on the segment S[2,3] with length 2. S is now 000.\n\nSample Input 2\n\n100000000\n\nSample Output 2\n\n8\n\nSample Input 3\n\n00001111\n\nSample Output 3\n\n4", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 544, "cpu_time_ms": 4, "memory_kb": 4864}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s504299139", "group_id": "codeNet:p03485", "input_text": "let f a b = int_of_float (ceil ((a +. b) /. 2.0));;\nScanf.scanf \"%f %f\" f\n|> Printf.printf \"%d\\n\"\n", "language": "OCaml", "metadata": {"date": 1561097463, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03485.html", "problem_id": "p03485", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03485/input.txt", "sample_output_relpath": "derived/input_output/data/p03485/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03485/OCaml/s504299139.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s504299139", "user_id": "u635974378"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "let f a b = int_of_float (ceil ((a +. b) /. 2.0));;\nScanf.scanf \"%f %f\" f\n|> Printf.printf \"%d\\n\"\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou are given two positive integers a and b.\nLet x be the average of a and b.\nPrint x rounded up to the nearest integer.\n\nConstraints\n\na and b are integers.\n\n1 \\leq a, b \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\na b\n\nOutput\n\nPrint x rounded up to the nearest integer.\n\nSample Input 1\n\n1 3\n\nSample Output 1\n\n2\n\nThe average of 1 and 3 is 2.0, and it will be rounded up to the nearest integer, 2.\n\nSample Input 2\n\n7 4\n\nSample Output 2\n\n6\n\nThe average of 7 and 4 is 5.5, and it will be rounded up to the nearest integer, 6.\n\nSample Input 3\n\n5 5\n\nSample Output 3\n\n5", "sample_input": "1 3\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03485", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou are given two positive integers a and b.\nLet x be the average of a and b.\nPrint x rounded up to the nearest integer.\n\nConstraints\n\na and b are integers.\n\n1 \\leq a, b \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\na b\n\nOutput\n\nPrint x rounded up to the nearest integer.\n\nSample Input 1\n\n1 3\n\nSample Output 1\n\n2\n\nThe average of 1 and 3 is 2.0, and it will be rounded up to the nearest integer, 2.\n\nSample Input 2\n\n7 4\n\nSample Output 2\n\n6\n\nThe average of 7 and 4 is 5.5, and it will be rounded up to the nearest integer, 6.\n\nSample Input 3\n\n5 5\n\nSample Output 3\n\n5", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s820120241", "group_id": "codeNet:p03485", "input_text": "let solve a b = (a + b) / 2 + if (a + b) mod 2 = 0 then 0 else 1\n\nlet read_ints () = read_line () |> Str.split (Str.regexp \" \") |> List.map int_of_string\n\nlet _ =\n match read_ints () with\n | [a; b] -> solve a b |> string_of_int |> print_endline\n | _ -> ()", "language": "OCaml", "metadata": {"date": 1557307571, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03485.html", "problem_id": "p03485", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03485/input.txt", "sample_output_relpath": "derived/input_output/data/p03485/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03485/OCaml/s820120241.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s820120241", "user_id": "u732304692"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "let solve a b = (a + b) / 2 + if (a + b) mod 2 = 0 then 0 else 1\n\nlet read_ints () = read_line () |> Str.split (Str.regexp \" \") |> List.map int_of_string\n\nlet _ =\n match read_ints () with\n | [a; b] -> solve a b |> string_of_int |> print_endline\n | _ -> ()", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou are given two positive integers a and b.\nLet x be the average of a and b.\nPrint x rounded up to the nearest integer.\n\nConstraints\n\na and b are integers.\n\n1 \\leq a, b \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\na b\n\nOutput\n\nPrint x rounded up to the nearest integer.\n\nSample Input 1\n\n1 3\n\nSample Output 1\n\n2\n\nThe average of 1 and 3 is 2.0, and it will be rounded up to the nearest integer, 2.\n\nSample Input 2\n\n7 4\n\nSample Output 2\n\n6\n\nThe average of 7 and 4 is 5.5, and it will be rounded up to the nearest integer, 6.\n\nSample Input 3\n\n5 5\n\nSample Output 3\n\n5", "sample_input": "1 3\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03485", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou are given two positive integers a and b.\nLet x be the average of a and b.\nPrint x rounded up to the nearest integer.\n\nConstraints\n\na and b are integers.\n\n1 \\leq a, b \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\na b\n\nOutput\n\nPrint x rounded up to the nearest integer.\n\nSample Input 1\n\n1 3\n\nSample Output 1\n\n2\n\nThe average of 1 and 3 is 2.0, and it will be rounded up to the nearest integer, 2.\n\nSample Input 2\n\n7 4\n\nSample Output 2\n\n6\n\nThe average of 7 and 4 is 5.5, and it will be rounded up to the nearest integer, 6.\n\nSample Input 3\n\n5 5\n\nSample Output 3\n\n5", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s588239355", "group_id": "codeNet:p03485", "input_text": "let solve a b = (float_of_int (a + b)) /. 2.0\n |> ceil |> int_of_float |> print_int\n\nlet () = Scanf.scanf \"%d %d\" solve\n", "language": "OCaml", "metadata": {"date": 1513476500, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03485.html", "problem_id": "p03485", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03485/input.txt", "sample_output_relpath": "derived/input_output/data/p03485/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03485/OCaml/s588239355.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s588239355", "user_id": "u508294160"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "let solve a b = (float_of_int (a + b)) /. 2.0\n |> ceil |> int_of_float |> print_int\n\nlet () = Scanf.scanf \"%d %d\" solve\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou are given two positive integers a and b.\nLet x be the average of a and b.\nPrint x rounded up to the nearest integer.\n\nConstraints\n\na and b are integers.\n\n1 \\leq a, b \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\na b\n\nOutput\n\nPrint x rounded up to the nearest integer.\n\nSample Input 1\n\n1 3\n\nSample Output 1\n\n2\n\nThe average of 1 and 3 is 2.0, and it will be rounded up to the nearest integer, 2.\n\nSample Input 2\n\n7 4\n\nSample Output 2\n\n6\n\nThe average of 7 and 4 is 5.5, and it will be rounded up to the nearest integer, 6.\n\nSample Input 3\n\n5 5\n\nSample Output 3\n\n5", "sample_input": "1 3\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03485", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou are given two positive integers a and b.\nLet x be the average of a and b.\nPrint x rounded up to the nearest integer.\n\nConstraints\n\na and b are integers.\n\n1 \\leq a, b \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\na b\n\nOutput\n\nPrint x rounded up to the nearest integer.\n\nSample Input 1\n\n1 3\n\nSample Output 1\n\n2\n\nThe average of 1 and 3 is 2.0, and it will be rounded up to the nearest integer, 2.\n\nSample Input 2\n\n7 4\n\nSample Output 2\n\n6\n\nThe average of 7 and 4 is 5.5, and it will be rounded up to the nearest integer, 6.\n\nSample Input 3\n\n5 5\n\nSample Output 3\n\n5", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s806538746", "group_id": "codeNet:p03486", "input_text": "(* O(n) (n = |s|) *)\nlet string_to_char_array s = Array.init (String.length s) (fun i -> s.[i])\n\n(* O(n) (n = |cs|) *)\nlet char_array_to_string cs = String.init (Array.length cs) (fun i -> cs.(i))\n\n(* O(n * log(n)) (n = |s|) *)\nlet string_sort cmp s =\n let cs = string_to_char_array s in\n Array.sort cmp cs;\n char_array_to_string cs\n\n(* O(n * log(n)) (n = max {|s|, |t|}) *)\nlet solve s t =\n if string_sort compare s < string_sort (fun x y -> compare x y * -1) t then\n \"Yes\"\n else\n \"No\"\n\nlet _ =\n let s = read_line () in\n let t = read_line () in\n solve s t |> print_endline", "language": "OCaml", "metadata": {"date": 1557309532, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03486.html", "problem_id": "p03486", "resource_group": "low_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/OCaml/s806538746.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s806538746", "user_id": "u732304692"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "(* O(n) (n = |s|) *)\nlet string_to_char_array s = Array.init (String.length s) (fun i -> s.[i])\n\n(* O(n) (n = |cs|) *)\nlet char_array_to_string cs = String.init (Array.length cs) (fun i -> cs.(i))\n\n(* O(n * log(n)) (n = |s|) *)\nlet string_sort cmp s =\n let cs = string_to_char_array s in\n Array.sort cmp cs;\n char_array_to_string cs\n\n(* O(n * log(n)) (n = max {|s|, |t|}) *)\nlet solve s t =\n if string_sort compare s < string_sort (fun x y -> compare x y * -1) t then\n \"Yes\"\n else\n \"No\"\n\nlet _ =\n let s = read_line () in\n let t = read_line () in\n solve s t |> print_endline", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s138851724", "group_id": "codeNet:p03487", "input_text": "let ans, a_s = ref 0, Array.init (read_int ()) @@ fun _ -> Scanf.scanf \" %d\" (+) 0\nlet f (p, c) a = a, if a <> p then (ans := !ans + if p > c then c else c - p; 1) else c + 1\nlet _ = Array.(sort (-) a_s; f (fold_left f (a_s.(0), 0) a_s) 0) |> ignore; Printf.printf \"%d\\n\" !ans", "language": "OCaml", "metadata": {"date": 1576419442, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03487.html", "problem_id": "p03487", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03487/input.txt", "sample_output_relpath": "derived/input_output/data/p03487/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03487/OCaml/s138851724.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s138851724", "user_id": "u732304692"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "let ans, a_s = ref 0, Array.init (read_int ()) @@ fun _ -> Scanf.scanf \" %d\" (+) 0\nlet f (p, c) a = a, if a <> p then (ans := !ans + if p > c then c else c - p; 1) else c + 1\nlet _ = Array.(sort (-) a_s; f (fold_left f (a_s.(0), 0) a_s) 0) |> ignore; Printf.printf \"%d\\n\" !ans", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou are given a sequence of positive integers of length N, a = (a_1, a_2, ..., a_N).\nYour objective is to remove some of the elements in a so that a will be a good sequence.\n\nHere, an sequence b is a good sequence when the following condition holds true:\n\nFor each element x in b, the value x occurs exactly x times in b.\n\nFor example, (3, 3, 3), (4, 2, 4, 1, 4, 2, 4) and () (an empty sequence) are good sequences, while (3, 3, 3, 3) and (2, 4, 1, 4, 2) are not.\n\nFind the minimum number of elements that needs to be removed so that a will be a good sequence.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\na_i is an integer.\n\n1 \\leq a_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 ... a_N\n\nOutput\n\nPrint the minimum number of elements that needs to be removed so that a will be a good sequence.\n\nSample Input 1\n\n4\n3 3 3 3\n\nSample Output 1\n\n1\n\nWe can, for example, remove one occurrence of 3. Then, (3, 3, 3) is a good sequence.\n\nSample Input 2\n\n5\n2 4 1 4 2\n\nSample Output 2\n\n2\n\nWe can, for example, remove two occurrences of 4. Then, (2, 1, 2) is a good sequence.\n\nSample Input 3\n\n6\n1 2 2 3 3 3\n\nSample Output 3\n\n0\n\nSample Input 4\n\n1\n1000000000\n\nSample Output 4\n\n1\n\nRemove one occurrence of 10^9. Then, () is a good sequence.\n\nSample Input 5\n\n8\n2 7 1 8 2 8 1 8\n\nSample Output 5\n\n5", "sample_input": "4\n3 3 3 3\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03487", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou are given a sequence of positive integers of length N, a = (a_1, a_2, ..., a_N).\nYour objective is to remove some of the elements in a so that a will be a good sequence.\n\nHere, an sequence b is a good sequence when the following condition holds true:\n\nFor each element x in b, the value x occurs exactly x times in b.\n\nFor example, (3, 3, 3), (4, 2, 4, 1, 4, 2, 4) and () (an empty sequence) are good sequences, while (3, 3, 3, 3) and (2, 4, 1, 4, 2) are not.\n\nFind the minimum number of elements that needs to be removed so that a will be a good sequence.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\na_i is an integer.\n\n1 \\leq a_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 ... a_N\n\nOutput\n\nPrint the minimum number of elements that needs to be removed so that a will be a good sequence.\n\nSample Input 1\n\n4\n3 3 3 3\n\nSample Output 1\n\n1\n\nWe can, for example, remove one occurrence of 3. Then, (3, 3, 3) is a good sequence.\n\nSample Input 2\n\n5\n2 4 1 4 2\n\nSample Output 2\n\n2\n\nWe can, for example, remove two occurrences of 4. Then, (2, 1, 2) is a good sequence.\n\nSample Input 3\n\n6\n1 2 2 3 3 3\n\nSample Output 3\n\n0\n\nSample Input 4\n\n1\n1000000000\n\nSample Output 4\n\n1\n\nRemove one occurrence of 10^9. Then, () is a good sequence.\n\nSample Input 5\n\n8\n2 7 1 8 2 8 1 8\n\nSample Output 5\n\n5", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 276, "cpu_time_ms": 62, "memory_kb": 5376}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s511540152", "group_id": "codeNet:p03487", "input_text": "open Batteries\n\nmodule Intmap = Map.Make(Int)\n\nlet () =\n let n = Scanf.scanf \"%d \" (fun a -> a) in\n let a_lst = Array.to_list @@ Array.init n (fun _ -> Scanf.scanf \"%d \" (fun a -> a)) in\n\n let intmap = Intmap.empty in\n let intmap = List.fold_left (fun accum x -> Intmap.modify_opt x (fun v_opt -> match v_opt with\n Some v -> Some (v+1)\n | None -> Some 1\n ) accum) intmap a_lst\n in\n let assoc = Intmap.bindings intmap in\n let ans = List.map (fun (i,c) -> if i < c then c-i else if i > c then c else 0) assoc |> List.fold_left (+) 0 in\n\n Printf.printf \"%d\\n\" ans\n", "language": "OCaml", "metadata": {"date": 1529214915, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03487.html", "problem_id": "p03487", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03487/input.txt", "sample_output_relpath": "derived/input_output/data/p03487/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03487/OCaml/s511540152.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s511540152", "user_id": "u139013163"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "open Batteries\n\nmodule Intmap = Map.Make(Int)\n\nlet () =\n let n = Scanf.scanf \"%d \" (fun a -> a) in\n let a_lst = Array.to_list @@ Array.init n (fun _ -> Scanf.scanf \"%d \" (fun a -> a)) in\n\n let intmap = Intmap.empty in\n let intmap = List.fold_left (fun accum x -> Intmap.modify_opt x (fun v_opt -> match v_opt with\n Some v -> Some (v+1)\n | None -> Some 1\n ) accum) intmap a_lst\n in\n let assoc = Intmap.bindings intmap in\n let ans = List.map (fun (i,c) -> if i < c then c-i else if i > c then c else 0) assoc |> List.fold_left (+) 0 in\n\n Printf.printf \"%d\\n\" ans\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou are given a sequence of positive integers of length N, a = (a_1, a_2, ..., a_N).\nYour objective is to remove some of the elements in a so that a will be a good sequence.\n\nHere, an sequence b is a good sequence when the following condition holds true:\n\nFor each element x in b, the value x occurs exactly x times in b.\n\nFor example, (3, 3, 3), (4, 2, 4, 1, 4, 2, 4) and () (an empty sequence) are good sequences, while (3, 3, 3, 3) and (2, 4, 1, 4, 2) are not.\n\nFind the minimum number of elements that needs to be removed so that a will be a good sequence.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\na_i is an integer.\n\n1 \\leq a_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 ... a_N\n\nOutput\n\nPrint the minimum number of elements that needs to be removed so that a will be a good sequence.\n\nSample Input 1\n\n4\n3 3 3 3\n\nSample Output 1\n\n1\n\nWe can, for example, remove one occurrence of 3. Then, (3, 3, 3) is a good sequence.\n\nSample Input 2\n\n5\n2 4 1 4 2\n\nSample Output 2\n\n2\n\nWe can, for example, remove two occurrences of 4. Then, (2, 1, 2) is a good sequence.\n\nSample Input 3\n\n6\n1 2 2 3 3 3\n\nSample Output 3\n\n0\n\nSample Input 4\n\n1\n1000000000\n\nSample Output 4\n\n1\n\nRemove one occurrence of 10^9. Then, () is a good sequence.\n\nSample Input 5\n\n8\n2 7 1 8 2 8 1 8\n\nSample Output 5\n\n5", "sample_input": "4\n3 3 3 3\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03487", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou are given a sequence of positive integers of length N, a = (a_1, a_2, ..., a_N).\nYour objective is to remove some of the elements in a so that a will be a good sequence.\n\nHere, an sequence b is a good sequence when the following condition holds true:\n\nFor each element x in b, the value x occurs exactly x times in b.\n\nFor example, (3, 3, 3), (4, 2, 4, 1, 4, 2, 4) and () (an empty sequence) are good sequences, while (3, 3, 3, 3) and (2, 4, 1, 4, 2) are not.\n\nFind the minimum number of elements that needs to be removed so that a will be a good sequence.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\na_i is an integer.\n\n1 \\leq a_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 ... a_N\n\nOutput\n\nPrint the minimum number of elements that needs to be removed so that a will be a good sequence.\n\nSample Input 1\n\n4\n3 3 3 3\n\nSample Output 1\n\n1\n\nWe can, for example, remove one occurrence of 3. Then, (3, 3, 3) is a good sequence.\n\nSample Input 2\n\n5\n2 4 1 4 2\n\nSample Output 2\n\n2\n\nWe can, for example, remove two occurrences of 4. Then, (2, 1, 2) is a good sequence.\n\nSample Input 3\n\n6\n1 2 2 3 3 3\n\nSample Output 3\n\n0\n\nSample Input 4\n\n1\n1000000000\n\nSample Output 4\n\n1\n\nRemove one occurrence of 10^9. Then, () is a good sequence.\n\nSample Input 5\n\n8\n2 7 1 8 2 8 1 8\n\nSample Output 5\n\n5", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 584, "cpu_time_ms": 131, "memory_kb": 15488}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s262974185", "group_id": "codeNet:p03487", "input_text": "\nopen Scanf\nopen Printf\n\nlet flip f x y = f y x\n\nlet rec range a b = if a >= b then [] else a :: range (a+1) b\n\nlet read_int () = scanf \" %d\" (fun x -> x)\nlet rec read_ints n = if n = 0 then [] else let i = read_int () in i :: read_ints (n-1)\n\nlet rec for_iter a b f = if a >= b then [] else let x = f a in x :: for_iter (a+1) b f\n\nlet () =\n let n = read_int () in\n let xs = read_ints n in\n let cs = Array.make 100002 0 in\n flip List.iter xs (fun x ->\n let i = min 100001 x in cs.(i) <- cs.(i) + 1);\n for_iter 0 100002 (fun i -> if i <= cs.(i) then cs.(i) - i else cs.(i))\n |> List.fold_left (+) 0\n |> printf \"%d\\n\"\n", "language": "OCaml", "metadata": {"date": 1519117019, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03487.html", "problem_id": "p03487", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03487/input.txt", "sample_output_relpath": "derived/input_output/data/p03487/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03487/OCaml/s262974185.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s262974185", "user_id": "u798181098"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "\nopen Scanf\nopen Printf\n\nlet flip f x y = f y x\n\nlet rec range a b = if a >= b then [] else a :: range (a+1) b\n\nlet read_int () = scanf \" %d\" (fun x -> x)\nlet rec read_ints n = if n = 0 then [] else let i = read_int () in i :: read_ints (n-1)\n\nlet rec for_iter a b f = if a >= b then [] else let x = f a in x :: for_iter (a+1) b f\n\nlet () =\n let n = read_int () in\n let xs = read_ints n in\n let cs = Array.make 100002 0 in\n flip List.iter xs (fun x ->\n let i = min 100001 x in cs.(i) <- cs.(i) + 1);\n for_iter 0 100002 (fun i -> if i <= cs.(i) then cs.(i) - i else cs.(i))\n |> List.fold_left (+) 0\n |> printf \"%d\\n\"\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou are given a sequence of positive integers of length N, a = (a_1, a_2, ..., a_N).\nYour objective is to remove some of the elements in a so that a will be a good sequence.\n\nHere, an sequence b is a good sequence when the following condition holds true:\n\nFor each element x in b, the value x occurs exactly x times in b.\n\nFor example, (3, 3, 3), (4, 2, 4, 1, 4, 2, 4) and () (an empty sequence) are good sequences, while (3, 3, 3, 3) and (2, 4, 1, 4, 2) are not.\n\nFind the minimum number of elements that needs to be removed so that a will be a good sequence.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\na_i is an integer.\n\n1 \\leq a_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 ... a_N\n\nOutput\n\nPrint the minimum number of elements that needs to be removed so that a will be a good sequence.\n\nSample Input 1\n\n4\n3 3 3 3\n\nSample Output 1\n\n1\n\nWe can, for example, remove one occurrence of 3. Then, (3, 3, 3) is a good sequence.\n\nSample Input 2\n\n5\n2 4 1 4 2\n\nSample Output 2\n\n2\n\nWe can, for example, remove two occurrences of 4. Then, (2, 1, 2) is a good sequence.\n\nSample Input 3\n\n6\n1 2 2 3 3 3\n\nSample Output 3\n\n0\n\nSample Input 4\n\n1\n1000000000\n\nSample Output 4\n\n1\n\nRemove one occurrence of 10^9. Then, () is a good sequence.\n\nSample Input 5\n\n8\n2 7 1 8 2 8 1 8\n\nSample Output 5\n\n5", "sample_input": "4\n3 3 3 3\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03487", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou are given a sequence of positive integers of length N, a = (a_1, a_2, ..., a_N).\nYour objective is to remove some of the elements in a so that a will be a good sequence.\n\nHere, an sequence b is a good sequence when the following condition holds true:\n\nFor each element x in b, the value x occurs exactly x times in b.\n\nFor example, (3, 3, 3), (4, 2, 4, 1, 4, 2, 4) and () (an empty sequence) are good sequences, while (3, 3, 3, 3) and (2, 4, 1, 4, 2) are not.\n\nFind the minimum number of elements that needs to be removed so that a will be a good sequence.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\na_i is an integer.\n\n1 \\leq a_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 ... a_N\n\nOutput\n\nPrint the minimum number of elements that needs to be removed so that a will be a good sequence.\n\nSample Input 1\n\n4\n3 3 3 3\n\nSample Output 1\n\n1\n\nWe can, for example, remove one occurrence of 3. Then, (3, 3, 3) is a good sequence.\n\nSample Input 2\n\n5\n2 4 1 4 2\n\nSample Output 2\n\n2\n\nWe can, for example, remove two occurrences of 4. Then, (2, 1, 2) is a good sequence.\n\nSample Input 3\n\n6\n1 2 2 3 3 3\n\nSample Output 3\n\n0\n\nSample Input 4\n\n1\n1000000000\n\nSample Output 4\n\n1\n\nRemove one occurrence of 10^9. Then, () is a good sequence.\n\nSample Input 5\n\n8\n2 7 1 8 2 8 1 8\n\nSample Output 5\n\n5", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 47, "memory_kb": 12416}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s871138404", "group_id": "codeNet:p03488", "input_text": "open Scanf\nopen Printf\n\nlet flip f x y = f y x\n\nlet rec range a b = if a >= b then [] else a :: range (a+1) b\n\nlet read_int () = scanf \" %d\" (fun x -> x)\nlet rec read_ints n = if n = 0 then [] else let i = read_int () in i :: read_ints (n-1)\n\nlet rec for_iter a b f = if a >= b then [] else let x = f a in x :: for_iter (a+1) b f\nlet rec for_iter_ a b f = if a >= b then () else (f a; for_iter_ (a+1) b f)\n\nlet list_of_string str =\n let len = String.length str in\n let rec f i = if i >= len then [] else str.[i] :: f (i+1) in\n f 0\n\nlet lim_width = 16002\nlet cp = lim_width / 2\n\nlet swt ax = match ax with 'X' -> 'Y' | 'Y' -> 'X'\n\nlet rec parse ax acc xs =\n match xs with\n | [] -> if acc = 0 then [] else [(acc, ax)]\n | (x::xs') ->\n if x = 'T' then\n if acc = 0 then parse (swt ax) 0 xs'\n else (acc, ax) :: parse (swt ax) 0 xs'\n else parse ax (acc+1) xs'\n\nlet () =\n let s0::_ as s = read_line () |> list_of_string in\n let [xp; yp] = read_ints 2 in\n let f_first = s0 = 'F' in\n let steps = parse 'X' 0 s in\n let xs' = steps |> List.filter (fun z -> snd z = 'X') |> List.map fst in\n let (x0, xs) = match xs' with\n | (z::zs) when f_first -> (z, zs)\n | _ -> (0, xs') in\n let ys = steps |> List.filter (fun z -> snd z = 'Y') |> List.map fst in\n\n let dp = Array.make lim_width 0 in\n let bak = Array.make lim_width 0 in\n\n let result = List.for_all (fun (ss, src, dst) ->\n Array.fill dp 0 lim_width 0; dp.(src) <- 1;\n List.iter (fun s ->\n Array.fill bak 0 lim_width 0;\n for_iter_ 0 lim_width (fun i ->\n if dp.(i) = 1 then (\n if i-s >= 0 then bak.(i-s) <- 1;\n if i+s < lim_width then bak.(i+s) <- 1\n ));\n for_iter_ 0 lim_width (fun i -> dp.(i) <- bak.(i));\n ) ss;\n dp.(dst) = 1) [(xs, cp+x0, cp+xp); (ys, cp, cp+yp)] in\n\n print_endline @@ if result then \"Yes\" else \"No\"\n", "language": "OCaml", "metadata": {"date": 1519122702, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03488.html", "problem_id": "p03488", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03488/input.txt", "sample_output_relpath": "derived/input_output/data/p03488/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03488/OCaml/s871138404.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s871138404", "user_id": "u798181098"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "open Scanf\nopen Printf\n\nlet flip f x y = f y x\n\nlet rec range a b = if a >= b then [] else a :: range (a+1) b\n\nlet read_int () = scanf \" %d\" (fun x -> x)\nlet rec read_ints n = if n = 0 then [] else let i = read_int () in i :: read_ints (n-1)\n\nlet rec for_iter a b f = if a >= b then [] else let x = f a in x :: for_iter (a+1) b f\nlet rec for_iter_ a b f = if a >= b then () else (f a; for_iter_ (a+1) b f)\n\nlet list_of_string str =\n let len = String.length str in\n let rec f i = if i >= len then [] else str.[i] :: f (i+1) in\n f 0\n\nlet lim_width = 16002\nlet cp = lim_width / 2\n\nlet swt ax = match ax with 'X' -> 'Y' | 'Y' -> 'X'\n\nlet rec parse ax acc xs =\n match xs with\n | [] -> if acc = 0 then [] else [(acc, ax)]\n | (x::xs') ->\n if x = 'T' then\n if acc = 0 then parse (swt ax) 0 xs'\n else (acc, ax) :: parse (swt ax) 0 xs'\n else parse ax (acc+1) xs'\n\nlet () =\n let s0::_ as s = read_line () |> list_of_string in\n let [xp; yp] = read_ints 2 in\n let f_first = s0 = 'F' in\n let steps = parse 'X' 0 s in\n let xs' = steps |> List.filter (fun z -> snd z = 'X') |> List.map fst in\n let (x0, xs) = match xs' with\n | (z::zs) when f_first -> (z, zs)\n | _ -> (0, xs') in\n let ys = steps |> List.filter (fun z -> snd z = 'Y') |> List.map fst in\n\n let dp = Array.make lim_width 0 in\n let bak = Array.make lim_width 0 in\n\n let result = List.for_all (fun (ss, src, dst) ->\n Array.fill dp 0 lim_width 0; dp.(src) <- 1;\n List.iter (fun s ->\n Array.fill bak 0 lim_width 0;\n for_iter_ 0 lim_width (fun i ->\n if dp.(i) = 1 then (\n if i-s >= 0 then bak.(i-s) <- 1;\n if i+s < lim_width then bak.(i+s) <- 1\n ));\n for_iter_ 0 lim_width (fun i -> dp.(i) <- bak.(i));\n ) ss;\n dp.(dst) = 1) [(xs, cp+x0, cp+xp); (ys, cp, cp+yp)] in\n\n print_endline @@ if result then \"Yes\" else \"No\"\n", "problem_context": "Score : 500 points\n\nProblem Statement\n\nA robot is put at the origin in a two-dimensional plane.\nInitially, the robot is facing in the positive x-axis direction.\n\nThis robot will be given an instruction sequence s.\ns consists of the following two kinds of letters, and will be executed in order from front to back.\n\nF : Move in the current direction by distance 1.\n\nT : Turn 90 degrees, either clockwise or counterclockwise.\n\nThe objective of the robot is to be at coordinates (x, y) after all the instructions are executed.\nDetermine whether this objective is achievable.\n\nConstraints\n\ns consists of F and T.\n\n1 \\leq |s| \\leq 8 000\n\nx and y are integers.\n\n|x|, |y| \\leq |s|\n\nInput\n\nInput is given from Standard Input in the following format:\n\ns\nx y\n\nOutput\n\nIf the objective is achievable, print Yes; if it is not, print No.\n\nSample Input 1\n\nFTFFTFFF\n4 2\n\nSample Output 1\n\nYes\n\nThe objective can be achieved by, for example, turning counterclockwise in the first T and turning clockwise in the second T.\n\nSample Input 2\n\nFTFFTFFF\n-2 -2\n\nSample Output 2\n\nYes\n\nThe objective can be achieved by, for example, turning clockwise in the first T and turning clockwise in the second T.\n\nSample Input 3\n\nFF\n1 0\n\nSample Output 3\n\nNo\n\nSample Input 4\n\nTF\n1 0\n\nSample Output 4\n\nNo\n\nSample Input 5\n\nFFTTFF\n0 0\n\nSample Output 5\n\nYes\n\nThe objective can be achieved by, for example, turning counterclockwise in the first T and turning counterclockwise in the second T.\n\nSample Input 6\n\nTTTT\n1 0\n\nSample Output 6\n\nNo", "sample_input": "FTFFTFFF\n4 2\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03488", "source_text": "Score : 500 points\n\nProblem Statement\n\nA robot is put at the origin in a two-dimensional plane.\nInitially, the robot is facing in the positive x-axis direction.\n\nThis robot will be given an instruction sequence s.\ns consists of the following two kinds of letters, and will be executed in order from front to back.\n\nF : Move in the current direction by distance 1.\n\nT : Turn 90 degrees, either clockwise or counterclockwise.\n\nThe objective of the robot is to be at coordinates (x, y) after all the instructions are executed.\nDetermine whether this objective is achievable.\n\nConstraints\n\ns consists of F and T.\n\n1 \\leq |s| \\leq 8 000\n\nx and y are integers.\n\n|x|, |y| \\leq |s|\n\nInput\n\nInput is given from Standard Input in the following format:\n\ns\nx y\n\nOutput\n\nIf the objective is achievable, print Yes; if it is not, print No.\n\nSample Input 1\n\nFTFFTFFF\n4 2\n\nSample Output 1\n\nYes\n\nThe objective can be achieved by, for example, turning counterclockwise in the first T and turning clockwise in the second T.\n\nSample Input 2\n\nFTFFTFFF\n-2 -2\n\nSample Output 2\n\nYes\n\nThe objective can be achieved by, for example, turning clockwise in the first T and turning clockwise in the second T.\n\nSample Input 3\n\nFF\n1 0\n\nSample Output 3\n\nNo\n\nSample Input 4\n\nTF\n1 0\n\nSample Output 4\n\nNo\n\nSample Input 5\n\nFFTTFF\n0 0\n\nSample Output 5\n\nYes\n\nThe objective can be achieved by, for example, turning counterclockwise in the first T and turning counterclockwise in the second T.\n\nSample Input 6\n\nTTTT\n1 0\n\nSample Output 6\n\nNo", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1886, "cpu_time_ms": 815, "memory_kb": 3456}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s210599121", "group_id": "codeNet:p03488", "input_text": "open Scanf\nopen Printf\n\nlet flip f x y = f y x\n\nlet rec range a b = if a >= b then [] else a :: range (a+1) b\n\nlet read_int () = scanf \" %d\" (fun x -> x)\nlet rec read_ints n = if n = 0 then [] else let i = read_int () in i :: read_ints (n-1)\n\nlet rec for_iter a b f = if a >= b then [] else let x = f a in x :: for_iter (a+1) b f\nlet rec for_iter_ a b f = if a >= b then () else (f a; for_iter_ (a+1) b f)\n\nlet list_of_string str =\n let len = String.length str in\n let rec f i = if i >= len then [] else str.[i] :: f (i+1) in\n f 0\n\nlet lim_width = 16010\nlet cp = lim_width / 2\n\ntype axis = X | Y\n\nlet swt ax = match ax with X -> Y | Y -> X\n\nlet rec parse ax acc xs =\n match xs with\n | [] -> if acc = 0 then [] else [(acc, ax)]\n | (x::xs') ->\n if x = 'T' then\n if acc = 0 then parse (swt ax) 0 xs'\n else (acc, ax) :: parse (swt ax) 0 xs'\n else parse ax (acc+1) xs'\n\nlet () =\n let hs::_ as s = list_of_string @@ read_line () in\n let [xp; yp] = read_ints 2 in\n let f_first = hs = 'F' in\n let steps = parse X 0 s in\n let xs' = steps |> List.filter (fun z -> snd z = X) |> List.map fst in\n let (x0, xs) = match xs' with\n | (y::ys) when f_first -> (y, ys)\n | _ -> (0, xs') in\n let ys = steps |> List.filter (fun t -> snd t = Y) |> List.map fst in\n\n let dp = Array.make lim_width false in\n let bak = Array.make lim_width false in\n\n let result = List.for_all (fun (ss, src, dst) ->\n Array.fill dp 0 lim_width false; dp.(src) <- true;\n List.iter (fun x ->\n Array.fill bak 0 lim_width false;\n for_iter_ 0 lim_width (fun i ->\n if dp.(i) then \n if i >= x then bak.(i-x) <- true;\n if i+x < lim_width then bak.(i+x) <- true);\n for_iter_ 0 lim_width (fun i ->\n dp.(i) <- bak.(i));\n ) ss;\n dp.(dst)) [(xs, cp+x0, cp+xp); (ys, cp, cp+yp)] in\n\n print_endline @@ if result then \"Yes\" else \"No\"\n", "language": "OCaml", "metadata": {"date": 1519121141, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03488.html", "problem_id": "p03488", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03488/input.txt", "sample_output_relpath": "derived/input_output/data/p03488/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03488/OCaml/s210599121.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s210599121", "user_id": "u798181098"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "open Scanf\nopen Printf\n\nlet flip f x y = f y x\n\nlet rec range a b = if a >= b then [] else a :: range (a+1) b\n\nlet read_int () = scanf \" %d\" (fun x -> x)\nlet rec read_ints n = if n = 0 then [] else let i = read_int () in i :: read_ints (n-1)\n\nlet rec for_iter a b f = if a >= b then [] else let x = f a in x :: for_iter (a+1) b f\nlet rec for_iter_ a b f = if a >= b then () else (f a; for_iter_ (a+1) b f)\n\nlet list_of_string str =\n let len = String.length str in\n let rec f i = if i >= len then [] else str.[i] :: f (i+1) in\n f 0\n\nlet lim_width = 16010\nlet cp = lim_width / 2\n\ntype axis = X | Y\n\nlet swt ax = match ax with X -> Y | Y -> X\n\nlet rec parse ax acc xs =\n match xs with\n | [] -> if acc = 0 then [] else [(acc, ax)]\n | (x::xs') ->\n if x = 'T' then\n if acc = 0 then parse (swt ax) 0 xs'\n else (acc, ax) :: parse (swt ax) 0 xs'\n else parse ax (acc+1) xs'\n\nlet () =\n let hs::_ as s = list_of_string @@ read_line () in\n let [xp; yp] = read_ints 2 in\n let f_first = hs = 'F' in\n let steps = parse X 0 s in\n let xs' = steps |> List.filter (fun z -> snd z = X) |> List.map fst in\n let (x0, xs) = match xs' with\n | (y::ys) when f_first -> (y, ys)\n | _ -> (0, xs') in\n let ys = steps |> List.filter (fun t -> snd t = Y) |> List.map fst in\n\n let dp = Array.make lim_width false in\n let bak = Array.make lim_width false in\n\n let result = List.for_all (fun (ss, src, dst) ->\n Array.fill dp 0 lim_width false; dp.(src) <- true;\n List.iter (fun x ->\n Array.fill bak 0 lim_width false;\n for_iter_ 0 lim_width (fun i ->\n if dp.(i) then \n if i >= x then bak.(i-x) <- true;\n if i+x < lim_width then bak.(i+x) <- true);\n for_iter_ 0 lim_width (fun i ->\n dp.(i) <- bak.(i));\n ) ss;\n dp.(dst)) [(xs, cp+x0, cp+xp); (ys, cp, cp+yp)] in\n\n print_endline @@ if result then \"Yes\" else \"No\"\n", "problem_context": "Score : 500 points\n\nProblem Statement\n\nA robot is put at the origin in a two-dimensional plane.\nInitially, the robot is facing in the positive x-axis direction.\n\nThis robot will be given an instruction sequence s.\ns consists of the following two kinds of letters, and will be executed in order from front to back.\n\nF : Move in the current direction by distance 1.\n\nT : Turn 90 degrees, either clockwise or counterclockwise.\n\nThe objective of the robot is to be at coordinates (x, y) after all the instructions are executed.\nDetermine whether this objective is achievable.\n\nConstraints\n\ns consists of F and T.\n\n1 \\leq |s| \\leq 8 000\n\nx and y are integers.\n\n|x|, |y| \\leq |s|\n\nInput\n\nInput is given from Standard Input in the following format:\n\ns\nx y\n\nOutput\n\nIf the objective is achievable, print Yes; if it is not, print No.\n\nSample Input 1\n\nFTFFTFFF\n4 2\n\nSample Output 1\n\nYes\n\nThe objective can be achieved by, for example, turning counterclockwise in the first T and turning clockwise in the second T.\n\nSample Input 2\n\nFTFFTFFF\n-2 -2\n\nSample Output 2\n\nYes\n\nThe objective can be achieved by, for example, turning clockwise in the first T and turning clockwise in the second T.\n\nSample Input 3\n\nFF\n1 0\n\nSample Output 3\n\nNo\n\nSample Input 4\n\nTF\n1 0\n\nSample Output 4\n\nNo\n\nSample Input 5\n\nFFTTFF\n0 0\n\nSample Output 5\n\nYes\n\nThe objective can be achieved by, for example, turning counterclockwise in the first T and turning counterclockwise in the second T.\n\nSample Input 6\n\nTTTT\n1 0\n\nSample Output 6\n\nNo", "sample_input": "FTFFTFFF\n4 2\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03488", "source_text": "Score : 500 points\n\nProblem Statement\n\nA robot is put at the origin in a two-dimensional plane.\nInitially, the robot is facing in the positive x-axis direction.\n\nThis robot will be given an instruction sequence s.\ns consists of the following two kinds of letters, and will be executed in order from front to back.\n\nF : Move in the current direction by distance 1.\n\nT : Turn 90 degrees, either clockwise or counterclockwise.\n\nThe objective of the robot is to be at coordinates (x, y) after all the instructions are executed.\nDetermine whether this objective is achievable.\n\nConstraints\n\ns consists of F and T.\n\n1 \\leq |s| \\leq 8 000\n\nx and y are integers.\n\n|x|, |y| \\leq |s|\n\nInput\n\nInput is given from Standard Input in the following format:\n\ns\nx y\n\nOutput\n\nIf the objective is achievable, print Yes; if it is not, print No.\n\nSample Input 1\n\nFTFFTFFF\n4 2\n\nSample Output 1\n\nYes\n\nThe objective can be achieved by, for example, turning counterclockwise in the first T and turning clockwise in the second T.\n\nSample Input 2\n\nFTFFTFFF\n-2 -2\n\nSample Output 2\n\nYes\n\nThe objective can be achieved by, for example, turning clockwise in the first T and turning clockwise in the second T.\n\nSample Input 3\n\nFF\n1 0\n\nSample Output 3\n\nNo\n\nSample Input 4\n\nTF\n1 0\n\nSample Output 4\n\nNo\n\nSample Input 5\n\nFFTTFF\n0 0\n\nSample Output 5\n\nYes\n\nThe objective can be achieved by, for example, turning counterclockwise in the first T and turning counterclockwise in the second T.\n\nSample Input 6\n\nTTTT\n1 0\n\nSample Output 6\n\nNo", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1905, "cpu_time_ms": 896, "memory_kb": 3584}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s074955144", "group_id": "codeNet:p03494", "input_text": "open Batteries\n\nmodule IntSet = Set.Make (struct\n let compare = Pervasives.compare\n\n type t = int\nend)\n\nlet read_two () = Scanf.sscanf (read_line ()) \"%d %d\" (fun a b -> (a, b))\n\nlet read_three () =\n Scanf.sscanf (read_line ()) \"%d %d %d\" (fun a b c -> (a, b, c))\n\nlet read_four () =\n Scanf.sscanf (read_line ()) \"%d %d %d\" (fun a b c d -> (a, b, c, d))\n\nlet read_list () =\n read_line () |> String.split_on_char ' '\n |> List.map (fun s -> int_of_string s)\n\nlet rec read_list_nl n =\n if n = 0 then [] else (read_line () |> int_of_string) :: read_list_nl (n - 1)\n\n(* a**x *)\nlet pow a x =\n let rec aux acc = function 0 -> acc | n -> aux (acc * a) (n - 1) in\n aux 1 x\n\nlet rec pow2 n = if n mod 2 = 0 then 1 + pow2 (n / 2) else 0\n\nlet rec f d a n = if n > d then 0 else 1 + f d a (n + a)\n\nlet rec total acc = function [] -> acc | x :: rest -> total (acc + x) rest\n\nlet () =\n let _ = read_int () in\n let ans =\n read_list () |> List.map pow2\n |> List.fold_left (fun x acc -> if acc > x then x else acc) 32\n in\n print_int ans;\n print_newline ()\n", "language": "OCaml", "metadata": {"date": 1587174957, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03494.html", "problem_id": "p03494", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03494/input.txt", "sample_output_relpath": "derived/input_output/data/p03494/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03494/OCaml/s074955144.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s074955144", "user_id": "u395620499"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "open Batteries\n\nmodule IntSet = Set.Make (struct\n let compare = Pervasives.compare\n\n type t = int\nend)\n\nlet read_two () = Scanf.sscanf (read_line ()) \"%d %d\" (fun a b -> (a, b))\n\nlet read_three () =\n Scanf.sscanf (read_line ()) \"%d %d %d\" (fun a b c -> (a, b, c))\n\nlet read_four () =\n Scanf.sscanf (read_line ()) \"%d %d %d\" (fun a b c d -> (a, b, c, d))\n\nlet read_list () =\n read_line () |> String.split_on_char ' '\n |> List.map (fun s -> int_of_string s)\n\nlet rec read_list_nl n =\n if n = 0 then [] else (read_line () |> int_of_string) :: read_list_nl (n - 1)\n\n(* a**x *)\nlet pow a x =\n let rec aux acc = function 0 -> acc | n -> aux (acc * a) (n - 1) in\n aux 1 x\n\nlet rec pow2 n = if n mod 2 = 0 then 1 + pow2 (n / 2) else 0\n\nlet rec f d a n = if n > d then 0 else 1 + f d a (n + a)\n\nlet rec total acc = function [] -> acc | x :: rest -> total (acc + x) rest\n\nlet () =\n let _ = read_int () in\n let ans =\n read_list () |> List.map pow2\n |> List.fold_left (fun x acc -> if acc > x then x else acc) 32\n in\n print_int ans;\n print_newline ()\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nThere are N positive integers written on a blackboard: A_1, ..., A_N.\n\nSnuke can perform the following operation when all integers on the blackboard are even:\n\nReplace each integer X on the blackboard by X divided by 2.\n\nFind the maximum possible number of operations that Snuke can perform.\n\nConstraints\n\n1 \\leq N \\leq 200\n\n1 \\leq A_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the maximum possible number of operations that Snuke can perform.\n\nSample Input 1\n\n3\n8 12 40\n\nSample Output 1\n\n2\n\nInitially, [8, 12, 40] are written on the blackboard.\nSince all those integers are even, Snuke can perform the operation.\n\nAfter the operation is performed once, [4, 6, 20] are written on the blackboard.\nSince all those integers are again even, he can perform the operation.\n\nAfter the operation is performed twice, [2, 3, 10] are written on the blackboard.\nNow, there is an odd number 3 on the blackboard, so he cannot perform the operation any more.\n\nThus, Snuke can perform the operation at most twice.\n\nSample Input 2\n\n4\n5 6 8 10\n\nSample Output 2\n\n0\n\nSince there is an odd number 5 on the blackboard already in the beginning, Snuke cannot perform the operation at all.\n\nSample Input 3\n\n6\n382253568 723152896 37802240 379425024 404894720 471526144\n\nSample Output 3\n\n8", "sample_input": "3\n8 12 40\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03494", "source_text": "Score : 200 points\n\nProblem Statement\n\nThere are N positive integers written on a blackboard: A_1, ..., A_N.\n\nSnuke can perform the following operation when all integers on the blackboard are even:\n\nReplace each integer X on the blackboard by X divided by 2.\n\nFind the maximum possible number of operations that Snuke can perform.\n\nConstraints\n\n1 \\leq N \\leq 200\n\n1 \\leq A_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the maximum possible number of operations that Snuke can perform.\n\nSample Input 1\n\n3\n8 12 40\n\nSample Output 1\n\n2\n\nInitially, [8, 12, 40] are written on the blackboard.\nSince all those integers are even, Snuke can perform the operation.\n\nAfter the operation is performed once, [4, 6, 20] are written on the blackboard.\nSince all those integers are again even, he can perform the operation.\n\nAfter the operation is performed twice, [2, 3, 10] are written on the blackboard.\nNow, there is an odd number 3 on the blackboard, so he cannot perform the operation any more.\n\nThus, Snuke can perform the operation at most twice.\n\nSample Input 2\n\n4\n5 6 8 10\n\nSample Output 2\n\n0\n\nSince there is an odd number 5 on the blackboard already in the beginning, Snuke cannot perform the operation at all.\n\nSample Input 3\n\n6\n382253568 723152896 37802240 379425024 404894720 471526144\n\nSample Output 3\n\n8", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1059, "cpu_time_ms": 6, "memory_kb": 1408}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s998264735", "group_id": "codeNet:p03494", "input_text": "let cnt n =\n let rec f n' c = if n' mod 2 = 1 then c else f (n' / 2) (c + 1) in\n f n 0\n\nlet solve n =\n let rec f i ans =\n if i > n then ans\n else let tmp = Scanf.scanf \"%d \" cnt in f (i + 1) (min ans tmp)\n in\n f 1 max_int\n\nlet () = Scanf.scanf \"%d\\n\" solve |> Printf.printf \"%d\\n\"", "language": "OCaml", "metadata": {"date": 1523649934, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03494.html", "problem_id": "p03494", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03494/input.txt", "sample_output_relpath": "derived/input_output/data/p03494/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03494/OCaml/s998264735.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s998264735", "user_id": "u987869509"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "let cnt n =\n let rec f n' c = if n' mod 2 = 1 then c else f (n' / 2) (c + 1) in\n f n 0\n\nlet solve n =\n let rec f i ans =\n if i > n then ans\n else let tmp = Scanf.scanf \"%d \" cnt in f (i + 1) (min ans tmp)\n in\n f 1 max_int\n\nlet () = Scanf.scanf \"%d\\n\" solve |> Printf.printf \"%d\\n\"", "problem_context": "Score : 200 points\n\nProblem Statement\n\nThere are N positive integers written on a blackboard: A_1, ..., A_N.\n\nSnuke can perform the following operation when all integers on the blackboard are even:\n\nReplace each integer X on the blackboard by X divided by 2.\n\nFind the maximum possible number of operations that Snuke can perform.\n\nConstraints\n\n1 \\leq N \\leq 200\n\n1 \\leq A_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the maximum possible number of operations that Snuke can perform.\n\nSample Input 1\n\n3\n8 12 40\n\nSample Output 1\n\n2\n\nInitially, [8, 12, 40] are written on the blackboard.\nSince all those integers are even, Snuke can perform the operation.\n\nAfter the operation is performed once, [4, 6, 20] are written on the blackboard.\nSince all those integers are again even, he can perform the operation.\n\nAfter the operation is performed twice, [2, 3, 10] are written on the blackboard.\nNow, there is an odd number 3 on the blackboard, so he cannot perform the operation any more.\n\nThus, Snuke can perform the operation at most twice.\n\nSample Input 2\n\n4\n5 6 8 10\n\nSample Output 2\n\n0\n\nSince there is an odd number 5 on the blackboard already in the beginning, Snuke cannot perform the operation at all.\n\nSample Input 3\n\n6\n382253568 723152896 37802240 379425024 404894720 471526144\n\nSample Output 3\n\n8", "sample_input": "3\n8 12 40\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03494", "source_text": "Score : 200 points\n\nProblem Statement\n\nThere are N positive integers written on a blackboard: A_1, ..., A_N.\n\nSnuke can perform the following operation when all integers on the blackboard are even:\n\nReplace each integer X on the blackboard by X divided by 2.\n\nFind the maximum possible number of operations that Snuke can perform.\n\nConstraints\n\n1 \\leq N \\leq 200\n\n1 \\leq A_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the maximum possible number of operations that Snuke can perform.\n\nSample Input 1\n\n3\n8 12 40\n\nSample Output 1\n\n2\n\nInitially, [8, 12, 40] are written on the blackboard.\nSince all those integers are even, Snuke can perform the operation.\n\nAfter the operation is performed once, [4, 6, 20] are written on the blackboard.\nSince all those integers are again even, he can perform the operation.\n\nAfter the operation is performed twice, [2, 3, 10] are written on the blackboard.\nNow, there is an odd number 3 on the blackboard, so he cannot perform the operation any more.\n\nThus, Snuke can perform the operation at most twice.\n\nSample Input 2\n\n4\n5 6 8 10\n\nSample Output 2\n\n0\n\nSince there is an odd number 5 on the blackboard already in the beginning, Snuke cannot perform the operation at all.\n\nSample Input 3\n\n6\n382253568 723152896 37802240 379425024 404894720 471526144\n\nSample Output 3\n\n8", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 512}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s936771576", "group_id": "codeNet:p03494", "input_text": "\nopen Scanf\nopen Printf\n\nlet read_int () = scanf \" %d\" (fun x -> x)\nlet rec read_ints n = if n = 0 then [] else let i = read_int () in i :: read_ints (n-1)\n\nlet rec calc x = if x mod 2 = 1 then 0 else 1 + calc (x/2)\n\nlet () =\n let n = read_int () in\n read_ints n |> List.map calc |> List.fold_left min 100 |> printf \"%d\\n\"\n", "language": "OCaml", "metadata": {"date": 1519124906, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03494.html", "problem_id": "p03494", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03494/input.txt", "sample_output_relpath": "derived/input_output/data/p03494/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03494/OCaml/s936771576.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s936771576", "user_id": "u798181098"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "\nopen Scanf\nopen Printf\n\nlet read_int () = scanf \" %d\" (fun x -> x)\nlet rec read_ints n = if n = 0 then [] else let i = read_int () in i :: read_ints (n-1)\n\nlet rec calc x = if x mod 2 = 1 then 0 else 1 + calc (x/2)\n\nlet () =\n let n = read_int () in\n read_ints n |> List.map calc |> List.fold_left min 100 |> printf \"%d\\n\"\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nThere are N positive integers written on a blackboard: A_1, ..., A_N.\n\nSnuke can perform the following operation when all integers on the blackboard are even:\n\nReplace each integer X on the blackboard by X divided by 2.\n\nFind the maximum possible number of operations that Snuke can perform.\n\nConstraints\n\n1 \\leq N \\leq 200\n\n1 \\leq A_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the maximum possible number of operations that Snuke can perform.\n\nSample Input 1\n\n3\n8 12 40\n\nSample Output 1\n\n2\n\nInitially, [8, 12, 40] are written on the blackboard.\nSince all those integers are even, Snuke can perform the operation.\n\nAfter the operation is performed once, [4, 6, 20] are written on the blackboard.\nSince all those integers are again even, he can perform the operation.\n\nAfter the operation is performed twice, [2, 3, 10] are written on the blackboard.\nNow, there is an odd number 3 on the blackboard, so he cannot perform the operation any more.\n\nThus, Snuke can perform the operation at most twice.\n\nSample Input 2\n\n4\n5 6 8 10\n\nSample Output 2\n\n0\n\nSince there is an odd number 5 on the blackboard already in the beginning, Snuke cannot perform the operation at all.\n\nSample Input 3\n\n6\n382253568 723152896 37802240 379425024 404894720 471526144\n\nSample Output 3\n\n8", "sample_input": "3\n8 12 40\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03494", "source_text": "Score : 200 points\n\nProblem Statement\n\nThere are N positive integers written on a blackboard: A_1, ..., A_N.\n\nSnuke can perform the following operation when all integers on the blackboard are even:\n\nReplace each integer X on the blackboard by X divided by 2.\n\nFind the maximum possible number of operations that Snuke can perform.\n\nConstraints\n\n1 \\leq N \\leq 200\n\n1 \\leq A_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the maximum possible number of operations that Snuke can perform.\n\nSample Input 1\n\n3\n8 12 40\n\nSample Output 1\n\n2\n\nInitially, [8, 12, 40] are written on the blackboard.\nSince all those integers are even, Snuke can perform the operation.\n\nAfter the operation is performed once, [4, 6, 20] are written on the blackboard.\nSince all those integers are again even, he can perform the operation.\n\nAfter the operation is performed twice, [2, 3, 10] are written on the blackboard.\nNow, there is an odd number 3 on the blackboard, so he cannot perform the operation any more.\n\nThus, Snuke can perform the operation at most twice.\n\nSample Input 2\n\n4\n5 6 8 10\n\nSample Output 2\n\n0\n\nSince there is an odd number 5 on the blackboard already in the beginning, Snuke cannot perform the operation at all.\n\nSample Input 3\n\n6\n382253568 723152896 37802240 379425024 404894720 471526144\n\nSample Output 3\n\n8", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 512}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s862856759", "group_id": "codeNet:p03495", "input_text": "(* O(n log n) *)\nScanf.scanf \" %d %d\" @@ fun n k ->\n let balls = Array.make n 0 in\n for i = 1 to n do\n let a = Scanf.scanf \" %d\" @@ (+) 0 in\n balls.(a - 1) <- balls.(a - 1) + 1\n done;\n Array.sort (-) balls;\n Array.sub balls 0 @@ n - k |> Array.fold_left (+) 0 |> Printf.printf \"%d\\n\"", "language": "OCaml", "metadata": {"date": 1559195509, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03495.html", "problem_id": "p03495", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03495/input.txt", "sample_output_relpath": "derived/input_output/data/p03495/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03495/OCaml/s862856759.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s862856759", "user_id": "u732304692"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "(* O(n log n) *)\nScanf.scanf \" %d %d\" @@ fun n k ->\n let balls = Array.make n 0 in\n for i = 1 to n do\n let a = Scanf.scanf \" %d\" @@ (+) 0 in\n balls.(a - 1) <- balls.(a - 1) + 1\n done;\n Array.sort (-) balls;\n Array.sub balls 0 @@ n - k |> Array.fold_left (+) 0 |> Printf.printf \"%d\\n\"", "problem_context": "Score : 300 points\n\nProblem Statement\n\nTakahashi has N balls. Initially, an integer A_i is written on the i-th ball.\n\nHe would like to rewrite the integer on some balls so that there are at most K different integers written on the N balls.\n\nFind the minimum number of balls that Takahashi needs to rewrite the integers on them.\n\nConstraints\n\n1 \\leq K \\leq N \\leq 200000\n\n1 \\leq A_i \\leq N\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the minimum number of balls that Takahashi needs to rewrite the integers on them.\n\nSample Input 1\n\n5 2\n1 1 2 2 5\n\nSample Output 1\n\n1\n\nFor example, if we rewrite the integer on the fifth ball to 2, there are two different integers written on the balls: 1 and 2.\nOn the other hand, it is not possible to rewrite the integers on zero balls so that there are at most two different integers written on the balls, so we should print 1.\n\nSample Input 2\n\n4 4\n1 1 2 2\n\nSample Output 2\n\n0\n\nAlready in the beginning, there are two different integers written on the balls, so we do not need to rewrite anything.\n\nSample Input 3\n\n10 3\n5 1 3 2 4 1 1 2 3 4\n\nSample Output 3\n\n3", "sample_input": "5 2\n1 1 2 2 5\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03495", "source_text": "Score : 300 points\n\nProblem Statement\n\nTakahashi has N balls. Initially, an integer A_i is written on the i-th ball.\n\nHe would like to rewrite the integer on some balls so that there are at most K different integers written on the N balls.\n\nFind the minimum number of balls that Takahashi needs to rewrite the integers on them.\n\nConstraints\n\n1 \\leq K \\leq N \\leq 200000\n\n1 \\leq A_i \\leq N\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the minimum number of balls that Takahashi needs to rewrite the integers on them.\n\nSample Input 1\n\n5 2\n1 1 2 2 5\n\nSample Output 1\n\n1\n\nFor example, if we rewrite the integer on the fifth ball to 2, there are two different integers written on the balls: 1 and 2.\nOn the other hand, it is not possible to rewrite the integers on zero balls so that there are at most two different integers written on the balls, so we should print 1.\n\nSample Input 2\n\n4 4\n1 1 2 2\n\nSample Output 2\n\n0\n\nAlready in the beginning, there are two different integers written on the balls, so we do not need to rewrite anything.\n\nSample Input 3\n\n10 3\n5 1 3 2 4 1 1 2 3 4\n\nSample Output 3\n\n3", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 294, "cpu_time_ms": 103, "memory_kb": 6400}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s949085676", "group_id": "codeNet:p03501", "input_text": "Scanf.scanf \"%d %d %d\" (fun n a b ->\n min b (a * n) |> Printf.printf \"%d\\n\"\n)", "language": "OCaml", "metadata": {"date": 1585886305, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03501.html", "problem_id": "p03501", "resource_group": "low_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/OCaml/s949085676.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s949085676", "user_id": "u342443598"}, "prompt_components": {"gold_output": "119\n", "input_to_evaluate": "Scanf.scanf \"%d %d %d\" (fun n a b ->\n min b (a * n) |> Printf.printf \"%d\\n\"\n)", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou are parking at a parking lot. You can choose from the following two fee plans:\n\nPlan 1: The fee will be A×T yen (the currency of Japan) when you park for T hours.\n\nPlan 2: The fee will be B yen, regardless of the duration.\n\nFind the minimum fee when you park for N hours.\n\nConstraints\n\n1≤N≤20\n\n1≤A≤100\n\n1≤B≤2000\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN A B\n\nOutput\n\nWhen the minimum fee is x yen, print the value of x.\n\nSample Input 1\n\n7 17 120\n\nSample Output 1\n\n119\n\nIf you choose Plan 1, the fee will be 7×17=119 yen.\n\nIf you choose Plan 2, the fee will be 120 yen.\n\nThus, the minimum fee is 119 yen.\n\nSample Input 2\n\n5 20 100\n\nSample Output 2\n\n100\n\nThe fee might be the same in the two plans.\n\nSample Input 3\n\n6 18 100\n\nSample Output 3\n\n100", "sample_input": "7 17 120\n"}, "reference_outputs": ["119\n"], "source_document_id": "p03501", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou are parking at a parking lot. You can choose from the following two fee plans:\n\nPlan 1: The fee will be A×T yen (the currency of Japan) when you park for T hours.\n\nPlan 2: The fee will be B yen, regardless of the duration.\n\nFind the minimum fee when you park for N hours.\n\nConstraints\n\n1≤N≤20\n\n1≤A≤100\n\n1≤B≤2000\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN A B\n\nOutput\n\nWhen the minimum fee is x yen, print the value of x.\n\nSample Input 1\n\n7 17 120\n\nSample Output 1\n\n119\n\nIf you choose Plan 1, the fee will be 7×17=119 yen.\n\nIf you choose Plan 2, the fee will be 120 yen.\n\nThus, the minimum fee is 119 yen.\n\nSample Input 2\n\n5 20 100\n\nSample Output 2\n\n100\n\nThe fee might be the same in the two plans.\n\nSample Input 3\n\n6 18 100\n\nSample Output 3\n\n100", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 2432}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s642906226", "group_id": "codeNet:p03502", "input_text": "let solve n =\n let rec f x sum = if x < 1 then sum else f (x / 10) (x mod 10 + sum) in\n if n mod f n 0 = 0 then \"Yes\" else \"No\"\n\nlet () = solve (read_int ()) |> print_endline", "language": "OCaml", "metadata": {"date": 1523741631, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03502.html", "problem_id": "p03502", "resource_group": "low_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/OCaml/s642906226.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s642906226", "user_id": "u987869509"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "let solve n =\n let rec f x sum = if x < 1 then sum else f (x / 10) (x mod 10 + sum) in\n if n mod f n 0 = 0 then \"Yes\" else \"No\"\n\nlet () = solve (read_int ()) |> print_endline", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s037783307", "group_id": "codeNet:p03504", "input_text": "let n, m = Scanf.scanf \" %d %d\" @@ fun a b -> a, b\nlet csts = Array.init n @@ fun _ -> Scanf.scanf \" %d %d %d\" @@ fun s t c -> c, s, t\nlet acc = Array.make 100002 0\nlet _ = Array.(sort compare csts; fold_left (fun (c0, t0) (c, s, t) -> if c0 = c && t0 = s then acc.(t0 + 1) <- acc.(t0 + 1) + 1 else acc.(s) <- acc.(s) + 1; acc.(t + 1) <- acc.(t + 1) - 1; c, t) (0, 0) csts |> ignore; iteri (fun i a -> if i > 0 then acc.(i) <- acc.(i) + acc.(i - 1)) acc; fold_left max 0 acc) |> Printf.printf \"%d\\n\"", "language": "OCaml", "metadata": {"date": 1583313556, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03504.html", "problem_id": "p03504", "resource_group": "low_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/OCaml/s037783307.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s037783307", "user_id": "u732304692"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "let n, m = Scanf.scanf \" %d %d\" @@ fun a b -> a, b\nlet csts = Array.init n @@ fun _ -> Scanf.scanf \" %d %d %d\" @@ fun s t c -> c, s, t\nlet acc = Array.make 100002 0\nlet _ = Array.(sort compare csts; fold_left (fun (c0, t0) (c, s, t) -> if c0 = c && t0 = s then acc.(t0 + 1) <- acc.(t0 + 1) + 1 else acc.(s) <- acc.(s) + 1; acc.(t + 1) <- acc.(t + 1) - 1; c, t) (0, 0) csts |> ignore; iteri (fun i a -> if i > 0 then acc.(i) <- acc.(i) + acc.(i - 1)) acc; fold_left max 0 acc) |> Printf.printf \"%d\\n\"", "problem_context": "Score : 400 points\n\nProblem Statement\n\nJoisino is planning to record N TV programs with recorders.\n\nThe TV can receive C channels numbered 1 through C.\n\nThe i-th program that she wants to record will be broadcast from time s_i to time t_i (including time s_i but not t_i) on Channel c_i.\n\nHere, there will never be more than one program that are broadcast on the same channel at the same time.\n\nWhen the recorder is recording a channel from time S to time T (including time S but not T), it cannot record other channels from time S-0.5 to time T (including time S-0.5 but not T).\n\nFind the minimum number of recorders required to record the channels so that all the N programs are completely recorded.\n\nConstraints\n\n1≤N≤10^5\n\n1≤C≤30\n\n1≤s_i= String.length t then u = s\n else if t.[i] = 'A' then f (u ^ \"A\") (i + 1) || f u (i + 1) else f (u ^ String.make 1 t.[i]) (i + 1)\nlet _ = print_endline @@ if f \"\" 0 then \"YES\" else \"NO\"", "language": "OCaml", "metadata": {"date": 1565890697, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03523.html", "problem_id": "p03523", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03523/input.txt", "sample_output_relpath": "derived/input_output/data/p03523/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03523/OCaml/s133885560.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s133885560", "user_id": "u732304692"}, "prompt_components": {"gold_output": "YES\n", "input_to_evaluate": "let s = read_line ()\nlet t = \"AKIHABARA\"\nlet rec f u i = if i >= String.length t then u = s\n else if t.[i] = 'A' then f (u ^ \"A\") (i + 1) || f u (i + 1) else f (u ^ String.make 1 t.[i]) (i + 1)\nlet _ = print_endline @@ if f \"\" 0 then \"YES\" else \"NO\"", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou are given a string S.\n\nTakahashi can insert the character A at any position in this string any number of times.\n\nCan he change S into AKIHABARA?\n\nConstraints\n\n1 \\leq |S| \\leq 50\n\nS consists of uppercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nIf it is possible to change S into AKIHABARA, print YES; otherwise, print NO.\n\nSample Input 1\n\nKIHBR\n\nSample Output 1\n\nYES\n\nInsert one A at each of the four positions: the beginning, immediately after H, immediately after B and the end.\n\nSample Input 2\n\nAKIBAHARA\n\nSample Output 2\n\nNO\n\nThe correct spell is AKIHABARA.\n\nSample Input 3\n\nAAKIAHBAARA\n\nSample Output 3\n\nNO", "sample_input": "KIHBR\n"}, "reference_outputs": ["YES\n"], "source_document_id": "p03523", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou are given a string S.\n\nTakahashi can insert the character A at any position in this string any number of times.\n\nCan he change S into AKIHABARA?\n\nConstraints\n\n1 \\leq |S| \\leq 50\n\nS consists of uppercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nIf it is possible to change S into AKIHABARA, print YES; otherwise, print NO.\n\nSample Input 1\n\nKIHBR\n\nSample Output 1\n\nYES\n\nInsert one A at each of the four positions: the beginning, immediately after H, immediately after B and the end.\n\nSample Input 2\n\nAKIBAHARA\n\nSample Output 2\n\nNO\n\nThe correct spell is AKIHABARA.\n\nSample Input 3\n\nAAKIAHBAARA\n\nSample Output 3\n\nNO", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 2432}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s437650311", "group_id": "codeNet:p03526", "input_text": "Scanf.scanf \"%d\" (fun n ->\n let hp = Array.init n (fun _ -> Scanf.scanf \" %d %d\" (fun h p -> h, p)) in\n Array.sort (fun (h1, p1) (h2, p2) -> compare (h1 + p1, h1) (h2 + p2, h2)) hp;\n\n let rec loop i dp =\n if i = n then dp else (\n let h, p = hp.(i) in\n let dp2 = Array.copy dp in\n for j = 1 to n do\n if dp.(j - 1) <= h then dp2.(j) <- min dp.(j) (dp.(j - 1) + p)\n done;\n loop (i + 1) dp2\n )\n in\n let init = Array.make (n + 1) max_int in\n init.(0) <- 0;\n let dp = loop 0 init in\n\n let rec loop i =\n if i = n + 1 || dp.(i) = max_int then i - 1 else loop (i + 1)\n in\n loop 0 |> Printf.printf \"%d\\n\"\n)", "language": "OCaml", "metadata": {"date": 1594262555, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p03526.html", "problem_id": "p03526", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03526/input.txt", "sample_output_relpath": "derived/input_output/data/p03526/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03526/OCaml/s437650311.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s437650311", "user_id": "u342443598"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "Scanf.scanf \"%d\" (fun n ->\n let hp = Array.init n (fun _ -> Scanf.scanf \" %d %d\" (fun h p -> h, p)) in\n Array.sort (fun (h1, p1) (h2, p2) -> compare (h1 + p1, h1) (h2 + p2, h2)) hp;\n\n let rec loop i dp =\n if i = n then dp else (\n let h, p = hp.(i) in\n let dp2 = Array.copy dp in\n for j = 1 to n do\n if dp.(j - 1) <= h then dp2.(j) <- min dp.(j) (dp.(j - 1) + p)\n done;\n loop (i + 1) dp2\n )\n in\n let init = Array.make (n + 1) max_int in\n init.(0) <- 0;\n let dp = loop 0 init in\n\n let rec loop i =\n if i = n + 1 || dp.(i) = max_int then i - 1 else loop (i + 1)\n in\n loop 0 |> Printf.printf \"%d\\n\"\n)", "problem_context": "Score : 700 points\n\nProblem Statement\n\nIn the final of CODE FESTIVAL in some year, there are N participants.\nThe height and power of Participant i is H_i and P_i, respectively.\n\nRingo is hosting a game of stacking zabuton (cushions).\n\nThe participants will line up in a row in some order, and they will in turn try to add zabuton to the stack of zabuton.\nInitially, the stack is empty.\nWhen it is Participant i's turn, if there are H_i or less zabuton already stacked, he/she will add exactly P_i zabuton to the stack. Otherwise, he/she will give up and do nothing.\n\nRingo wants to maximize the number of participants who can add zabuton to the stack.\nHow many participants can add zabuton to the stack in the optimal order of participants?\n\nConstraints\n\n1 \\leq N \\leq 5000\n\n0 \\leq H_i \\leq 10^9\n\n1 \\leq P_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nH_1 P_1\nH_2 P_2\n:\nH_N P_N\n\nOutput\n\nPrint the maximum number of participants who can add zabuton to the stack.\n\nSample Input 1\n\n3\n0 2\n1 3\n3 4\n\nSample Output 1\n\n2\n\nWhen the participants line up in the same order as the input, Participants 1 and 3 will be able to add zabuton.\n\nOn the other hand, there is no order such that all three participants can add zabuton. Thus, the answer is 2.\n\nSample Input 2\n\n3\n2 4\n3 1\n4 1\n\nSample Output 2\n\n3\n\nWhen the participants line up in the order 2, 3, 1, all of them will be able to add zabuton.\n\nSample Input 3\n\n10\n1 3\n8 4\n8 3\n9 1\n6 4\n2 3\n4 2\n9 2\n8 3\n0 1\n\nSample Output 3\n\n5", "sample_input": "3\n0 2\n1 3\n3 4\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03526", "source_text": "Score : 700 points\n\nProblem Statement\n\nIn the final of CODE FESTIVAL in some year, there are N participants.\nThe height and power of Participant i is H_i and P_i, respectively.\n\nRingo is hosting a game of stacking zabuton (cushions).\n\nThe participants will line up in a row in some order, and they will in turn try to add zabuton to the stack of zabuton.\nInitially, the stack is empty.\nWhen it is Participant i's turn, if there are H_i or less zabuton already stacked, he/she will add exactly P_i zabuton to the stack. Otherwise, he/she will give up and do nothing.\n\nRingo wants to maximize the number of participants who can add zabuton to the stack.\nHow many participants can add zabuton to the stack in the optimal order of participants?\n\nConstraints\n\n1 \\leq N \\leq 5000\n\n0 \\leq H_i \\leq 10^9\n\n1 \\leq P_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nH_1 P_1\nH_2 P_2\n:\nH_N P_N\n\nOutput\n\nPrint the maximum number of participants who can add zabuton to the stack.\n\nSample Input 1\n\n3\n0 2\n1 3\n3 4\n\nSample Output 1\n\n2\n\nWhen the participants line up in the same order as the input, Participants 1 and 3 will be able to add zabuton.\n\nOn the other hand, there is no order such that all three participants can add zabuton. Thus, the answer is 2.\n\nSample Input 2\n\n3\n2 4\n3 1\n4 1\n\nSample Output 2\n\n3\n\nWhen the participants line up in the order 2, 3, 1, all of them will be able to add zabuton.\n\nSample Input 3\n\n10\n1 3\n8 4\n8 3\n9 1\n6 4\n2 3\n4 2\n9 2\n8 3\n0 1\n\nSample Output 3\n\n5", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 717, "cpu_time_ms": 302, "memory_kb": 19480}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s119811548", "group_id": "codeNet:p03543", "input_text": "module A = Array\nmodule C = Char\nmodule I = Int64\nmodule L = List\nmodule Q = Queue\n\nlet pf = Printf.printf\nlet sf = Scanf.scanf\nlet ssf = Scanf.sscanf\n\nlet read_int () = sf \"%d \" (fun x -> x)\nlet read_float () = sf \"%f \" (fun x -> x)\nlet read_str () = sf \"%s \" (fun x -> x)\nlet read_array read n = A.init n (fun _ -> read ())\nlet err s = raise (Failure s)\n\nlet range s t = A.init (t - s) @@ (+) s\nlet foreach fold_f init s t map_f =\n range s t |> A.map map_f |> A.fold_left fold_f init\n\nlet inf = int_of_float 1e18\nlet eps = 1e-11\n\nmodule S = struct\n include String\n let of_array a = String.init (A.length a) (A.get a)\n let to_array s = A.init (String.length s) (String.get s)\nend;;\n\nlet () =\n let s = read_str () in\n let n = S.length s in\n let res =\n foreach (||) false 0 (n - 2) (fun i ->\n s.[i] = s.[i+1] && s.[i] = s.[i+2] ) in\n let ans = if res then \"Yes\" else \"No\" in\n pf \"%s\\n\" ans\n", "language": "OCaml", "metadata": {"date": 1514968936, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03543.html", "problem_id": "p03543", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03543/input.txt", "sample_output_relpath": "derived/input_output/data/p03543/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03543/OCaml/s119811548.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s119811548", "user_id": "u748871552"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "module A = Array\nmodule C = Char\nmodule I = Int64\nmodule L = List\nmodule Q = Queue\n\nlet pf = Printf.printf\nlet sf = Scanf.scanf\nlet ssf = Scanf.sscanf\n\nlet read_int () = sf \"%d \" (fun x -> x)\nlet read_float () = sf \"%f \" (fun x -> x)\nlet read_str () = sf \"%s \" (fun x -> x)\nlet read_array read n = A.init n (fun _ -> read ())\nlet err s = raise (Failure s)\n\nlet range s t = A.init (t - s) @@ (+) s\nlet foreach fold_f init s t map_f =\n range s t |> A.map map_f |> A.fold_left fold_f init\n\nlet inf = int_of_float 1e18\nlet eps = 1e-11\n\nmodule S = struct\n include String\n let of_array a = String.init (A.length a) (A.get a)\n let to_array s = A.init (String.length s) (String.get s)\nend;;\n\nlet () =\n let s = read_str () in\n let n = S.length s in\n let res =\n foreach (||) false 0 (n - 2) (fun i ->\n s.[i] = s.[i+1] && s.[i] = s.[i+2] ) in\n let ans = if res then \"Yes\" else \"No\" in\n pf \"%s\\n\" ans\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nWe call a 4-digit integer with three or more consecutive same digits, such as 1118, good.\n\nYou are given a 4-digit integer N. Answer the question: Is N good?\n\nConstraints\n\n1000 ≤ N ≤ 9999\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nIf N is good, print Yes; otherwise, print No.\n\nSample Input 1\n\n1118\n\nSample Output 1\n\nYes\n\nN is good, since it contains three consecutive 1.\n\nSample Input 2\n\n7777\n\nSample Output 2\n\nYes\n\nAn integer is also good when all the digits are the same.\n\nSample Input 3\n\n1234\n\nSample Output 3\n\nNo", "sample_input": "1118\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03543", "source_text": "Score : 100 points\n\nProblem Statement\n\nWe call a 4-digit integer with three or more consecutive same digits, such as 1118, good.\n\nYou are given a 4-digit integer N. Answer the question: Is N good?\n\nConstraints\n\n1000 ≤ N ≤ 9999\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nIf N is good, print Yes; otherwise, print No.\n\nSample Input 1\n\n1118\n\nSample Output 1\n\nYes\n\nN is good, since it contains three consecutive 1.\n\nSample Input 2\n\n7777\n\nSample Output 2\n\nYes\n\nAn integer is also good when all the digits are the same.\n\nSample Input 3\n\n1234\n\nSample Output 3\n\nNo", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s433773432", "group_id": "codeNet:p03544", "input_text": "Scanf.scanf \"%d\" (fun n ->\n let rec loop i l0 l1 =\n if i = n then l0 else\n loop (i + 1) l1 (l0 + l1)\n in\n loop 0 2 1 |> Printf.printf \"%d\\n\"\n)", "language": "OCaml", "metadata": {"date": 1599104676, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p03544.html", "problem_id": "p03544", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03544/input.txt", "sample_output_relpath": "derived/input_output/data/p03544/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03544/OCaml/s433773432.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s433773432", "user_id": "u342443598"}, "prompt_components": {"gold_output": "11\n", "input_to_evaluate": "Scanf.scanf \"%d\" (fun n ->\n let rec loop i l0 l1 =\n if i = n then l0 else\n loop (i + 1) l1 (l0 + l1)\n in\n loop 0 2 1 |> Printf.printf \"%d\\n\"\n)", "problem_context": "Score : 200 points\n\nProblem Statement\n\nIt is November 18 now in Japan. By the way, 11 and 18 are adjacent Lucas numbers.\n\nYou are given an integer N. Find the N-th Lucas number.\n\nHere, the i-th Lucas number L_i is defined as follows:\n\nL_0=2\n\nL_1=1\n\nL_i=L_{i-1}+L_{i-2} (i≥2)\n\nConstraints\n\n1≤N≤86\n\nIt is guaranteed that the answer is less than 10^{18}.\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the N-th Lucas number.\n\nSample Input 1\n\n5\n\nSample Output 1\n\n11\n\nL_0=2\n\nL_1=1\n\nL_2=L_0+L_1=3\n\nL_3=L_1+L_2=4\n\nL_4=L_2+L_3=7\n\nL_5=L_3+L_4=11\n\nThus, the 5-th Lucas number is 11.\n\nSample Input 2\n\n86\n\nSample Output 2\n\n939587134549734843", "sample_input": "5\n"}, "reference_outputs": ["11\n"], "source_document_id": "p03544", "source_text": "Score : 200 points\n\nProblem Statement\n\nIt is November 18 now in Japan. By the way, 11 and 18 are adjacent Lucas numbers.\n\nYou are given an integer N. Find the N-th Lucas number.\n\nHere, the i-th Lucas number L_i is defined as follows:\n\nL_0=2\n\nL_1=1\n\nL_i=L_{i-1}+L_{i-2} (i≥2)\n\nConstraints\n\n1≤N≤86\n\nIt is guaranteed that the answer is less than 10^{18}.\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the N-th Lucas number.\n\nSample Input 1\n\n5\n\nSample Output 1\n\n11\n\nL_0=2\n\nL_1=1\n\nL_2=L_0+L_1=3\n\nL_3=L_1+L_2=4\n\nL_4=L_2+L_3=7\n\nL_5=L_3+L_4=11\n\nThus, the 5-th Lucas number is 11.\n\nSample Input 2\n\n86\n\nSample Output 2\n\n939587134549734843", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 9, "memory_kb": 3820}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s555379598", "group_id": "codeNet:p03544", "input_text": "(*\nocamlfind ocamlopt -package batteries -linkpkg main.ml -o a.out\n*)\nopen Batteries\n\nlet n = Scanf.sscanf (read_line ()) \"%d\" ( fun n -> n)\n\nlet rec f lst n =\n match lst with\n [] -> 0\n | first :: [] -> 0 \n | first :: second :: rest -> \n let luca = first + second in\n if n = 0 then\n luca\n else\n f (luca :: lst) (n - 1)\n\nlet () =\n (\n if n = 0 then\n 2\n else\n if n = 1 then\n 1\n else\n f [1; 2] (n - 2)\n )\n |> Printf.printf \"%d\\n\"\n", "language": "OCaml", "metadata": {"date": 1590799149, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03544.html", "problem_id": "p03544", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03544/input.txt", "sample_output_relpath": "derived/input_output/data/p03544/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03544/OCaml/s555379598.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s555379598", "user_id": "u280335093"}, "prompt_components": {"gold_output": "11\n", "input_to_evaluate": "(*\nocamlfind ocamlopt -package batteries -linkpkg main.ml -o a.out\n*)\nopen Batteries\n\nlet n = Scanf.sscanf (read_line ()) \"%d\" ( fun n -> n)\n\nlet rec f lst n =\n match lst with\n [] -> 0\n | first :: [] -> 0 \n | first :: second :: rest -> \n let luca = first + second in\n if n = 0 then\n luca\n else\n f (luca :: lst) (n - 1)\n\nlet () =\n (\n if n = 0 then\n 2\n else\n if n = 1 then\n 1\n else\n f [1; 2] (n - 2)\n )\n |> Printf.printf \"%d\\n\"\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nIt is November 18 now in Japan. By the way, 11 and 18 are adjacent Lucas numbers.\n\nYou are given an integer N. Find the N-th Lucas number.\n\nHere, the i-th Lucas number L_i is defined as follows:\n\nL_0=2\n\nL_1=1\n\nL_i=L_{i-1}+L_{i-2} (i≥2)\n\nConstraints\n\n1≤N≤86\n\nIt is guaranteed that the answer is less than 10^{18}.\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the N-th Lucas number.\n\nSample Input 1\n\n5\n\nSample Output 1\n\n11\n\nL_0=2\n\nL_1=1\n\nL_2=L_0+L_1=3\n\nL_3=L_1+L_2=4\n\nL_4=L_2+L_3=7\n\nL_5=L_3+L_4=11\n\nThus, the 5-th Lucas number is 11.\n\nSample Input 2\n\n86\n\nSample Output 2\n\n939587134549734843", "sample_input": "5\n"}, "reference_outputs": ["11\n"], "source_document_id": "p03544", "source_text": "Score : 200 points\n\nProblem Statement\n\nIt is November 18 now in Japan. By the way, 11 and 18 are adjacent Lucas numbers.\n\nYou are given an integer N. Find the N-th Lucas number.\n\nHere, the i-th Lucas number L_i is defined as follows:\n\nL_0=2\n\nL_1=1\n\nL_i=L_{i-1}+L_{i-2} (i≥2)\n\nConstraints\n\n1≤N≤86\n\nIt is guaranteed that the answer is less than 10^{18}.\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the N-th Lucas number.\n\nSample Input 1\n\n5\n\nSample Output 1\n\n11\n\nL_0=2\n\nL_1=1\n\nL_2=L_0+L_1=3\n\nL_3=L_1+L_2=4\n\nL_4=L_2+L_3=7\n\nL_5=L_3+L_4=11\n\nThus, the 5-th Lucas number is 11.\n\nSample Input 2\n\n86\n\nSample Output 2\n\n939587134549734843", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 793, "cpu_time_ms": 2, "memory_kb": 1024}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s859775299", "group_id": "codeNet:p03544", "input_text": "let lucas n =\n let rec f i pre now =\n if i = n then now else f (i + 1) now (pre + now)\n in\n if n = 0 then 2 else f 1 2 1\n\nlet () = read_int () |> lucas |> Printf.printf \"%d\\n\"", "language": "OCaml", "metadata": {"date": 1523956959, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03544.html", "problem_id": "p03544", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03544/input.txt", "sample_output_relpath": "derived/input_output/data/p03544/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03544/OCaml/s859775299.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s859775299", "user_id": "u987869509"}, "prompt_components": {"gold_output": "11\n", "input_to_evaluate": "let lucas n =\n let rec f i pre now =\n if i = n then now else f (i + 1) now (pre + now)\n in\n if n = 0 then 2 else f 1 2 1\n\nlet () = read_int () |> lucas |> Printf.printf \"%d\\n\"", "problem_context": "Score : 200 points\n\nProblem Statement\n\nIt is November 18 now in Japan. By the way, 11 and 18 are adjacent Lucas numbers.\n\nYou are given an integer N. Find the N-th Lucas number.\n\nHere, the i-th Lucas number L_i is defined as follows:\n\nL_0=2\n\nL_1=1\n\nL_i=L_{i-1}+L_{i-2} (i≥2)\n\nConstraints\n\n1≤N≤86\n\nIt is guaranteed that the answer is less than 10^{18}.\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the N-th Lucas number.\n\nSample Input 1\n\n5\n\nSample Output 1\n\n11\n\nL_0=2\n\nL_1=1\n\nL_2=L_0+L_1=3\n\nL_3=L_1+L_2=4\n\nL_4=L_2+L_3=7\n\nL_5=L_3+L_4=11\n\nThus, the 5-th Lucas number is 11.\n\nSample Input 2\n\n86\n\nSample Output 2\n\n939587134549734843", "sample_input": "5\n"}, "reference_outputs": ["11\n"], "source_document_id": "p03544", "source_text": "Score : 200 points\n\nProblem Statement\n\nIt is November 18 now in Japan. By the way, 11 and 18 are adjacent Lucas numbers.\n\nYou are given an integer N. Find the N-th Lucas number.\n\nHere, the i-th Lucas number L_i is defined as follows:\n\nL_0=2\n\nL_1=1\n\nL_i=L_{i-1}+L_{i-2} (i≥2)\n\nConstraints\n\n1≤N≤86\n\nIt is guaranteed that the answer is less than 10^{18}.\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the N-th Lucas number.\n\nSample Input 1\n\n5\n\nSample Output 1\n\n11\n\nL_0=2\n\nL_1=1\n\nL_2=L_0+L_1=3\n\nL_3=L_1+L_2=4\n\nL_4=L_2+L_3=7\n\nL_5=L_3+L_4=11\n\nThus, the 5-th Lucas number is 11.\n\nSample Input 2\n\n86\n\nSample Output 2\n\n939587134549734843", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s853506445", "group_id": "codeNet:p03544", "input_text": "let id x = x\nlet n = Scanf.scanf \"%d\\n\" id\n\nlet rec lucas n =\n let rec lucas_pair n =\n match n with\n | 0 -> (2,0)\n | 1 -> (1,2)\n | m -> let (i,j) = lucas_pair (n-1) in (i+j,i)\n in let (i,_) = lucas_pair n in i\n\nlet ans = lucas n\n\nlet () =\n Printf.printf \"%d\\n\" ans", "language": "OCaml", "metadata": {"date": 1511058408, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03544.html", "problem_id": "p03544", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03544/input.txt", "sample_output_relpath": "derived/input_output/data/p03544/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03544/OCaml/s853506445.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s853506445", "user_id": "u735499035"}, "prompt_components": {"gold_output": "11\n", "input_to_evaluate": "let id x = x\nlet n = Scanf.scanf \"%d\\n\" id\n\nlet rec lucas n =\n let rec lucas_pair n =\n match n with\n | 0 -> (2,0)\n | 1 -> (1,2)\n | m -> let (i,j) = lucas_pair (n-1) in (i+j,i)\n in let (i,_) = lucas_pair n in i\n\nlet ans = lucas n\n\nlet () =\n Printf.printf \"%d\\n\" ans", "problem_context": "Score : 200 points\n\nProblem Statement\n\nIt is November 18 now in Japan. By the way, 11 and 18 are adjacent Lucas numbers.\n\nYou are given an integer N. Find the N-th Lucas number.\n\nHere, the i-th Lucas number L_i is defined as follows:\n\nL_0=2\n\nL_1=1\n\nL_i=L_{i-1}+L_{i-2} (i≥2)\n\nConstraints\n\n1≤N≤86\n\nIt is guaranteed that the answer is less than 10^{18}.\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the N-th Lucas number.\n\nSample Input 1\n\n5\n\nSample Output 1\n\n11\n\nL_0=2\n\nL_1=1\n\nL_2=L_0+L_1=3\n\nL_3=L_1+L_2=4\n\nL_4=L_2+L_3=7\n\nL_5=L_3+L_4=11\n\nThus, the 5-th Lucas number is 11.\n\nSample Input 2\n\n86\n\nSample Output 2\n\n939587134549734843", "sample_input": "5\n"}, "reference_outputs": ["11\n"], "source_document_id": "p03544", "source_text": "Score : 200 points\n\nProblem Statement\n\nIt is November 18 now in Japan. By the way, 11 and 18 are adjacent Lucas numbers.\n\nYou are given an integer N. Find the N-th Lucas number.\n\nHere, the i-th Lucas number L_i is defined as follows:\n\nL_0=2\n\nL_1=1\n\nL_i=L_{i-1}+L_{i-2} (i≥2)\n\nConstraints\n\n1≤N≤86\n\nIt is guaranteed that the answer is less than 10^{18}.\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the N-th Lucas number.\n\nSample Input 1\n\n5\n\nSample Output 1\n\n11\n\nL_0=2\n\nL_1=1\n\nL_2=L_0+L_1=3\n\nL_3=L_1+L_2=4\n\nL_4=L_2+L_3=7\n\nL_5=L_3+L_4=11\n\nThus, the 5-th Lucas number is 11.\n\nSample Input 2\n\n86\n\nSample Output 2\n\n939587134549734843", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s259148233", "group_id": "codeNet:p03545", "input_text": "type op =\n | Plus\n | Minus\n | Id\n\nlet print_op = function\n Plus -> print_char '+'\n | Minus -> print_char '-'\n | Id -> ()\n\n(* list_all 2 [true; false];;\n * - : bool list list =\n * [[true; true]; [false; true]; [true; false]; [false; false]] *)\n(* olに含まれる要素で作れる長さnのリストすべてを返す *)\nlet rec list_all : int -> 'a list -> 'a list list = fun n ol ->\n if n > 0 then\n List.fold_right (fun l ans ->\n List.fold_right\n (fun o xs ->\n (o :: l) :: xs)\n ol ans)\n (list_all (n - 1) ol) []\n else\n [[]]\n\nlet calc_op l opss = \n let rec loop ans =\n (function\n | (x :: xs, o :: os) ->\n (match o with\n Plus -> loop (ans + x) (xs, os)\n | Minus -> loop (ans - x) (xs, os)\n | Id -> loop x (xs, os))\n | _ -> ans)\n in\n loop 0 (l, opss) \n\nlet ic c = int_of_char c - int_of_char '0'\n\nlet () =\n let (a, b, c, d) = Scanf.sscanf (input_line stdin) \"%c%c%c%c\" (fun a b c d -> (ic a, ic b, ic c, ic d)) in\n let ops_lists = list_all 3 [Plus; Minus] in\n let ops_lists' = List.map (fun ops -> Id :: ops) ops_lists in\n let rec solve = function\n [] -> failwith \"Not found\"\n | ops :: opss ->\n if calc_op [a;b;c;d] ops = 7 then\n ops\n else\n solve opss\n in\n let ans = solve ops_lists' in\n List.iter2 (fun x op ->\n print_op op;\n print_int x) [a;b;c;d] ans;\n print_string \"=7\";\n print_newline ()\n", "language": "OCaml", "metadata": {"date": 1573858845, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03545.html", "problem_id": "p03545", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03545/input.txt", "sample_output_relpath": "derived/input_output/data/p03545/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03545/OCaml/s259148233.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s259148233", "user_id": "u977566741"}, "prompt_components": {"gold_output": "1+2+2+2=7\n", "input_to_evaluate": "type op =\n | Plus\n | Minus\n | Id\n\nlet print_op = function\n Plus -> print_char '+'\n | Minus -> print_char '-'\n | Id -> ()\n\n(* list_all 2 [true; false];;\n * - : bool list list =\n * [[true; true]; [false; true]; [true; false]; [false; false]] *)\n(* olに含まれる要素で作れる長さnのリストすべてを返す *)\nlet rec list_all : int -> 'a list -> 'a list list = fun n ol ->\n if n > 0 then\n List.fold_right (fun l ans ->\n List.fold_right\n (fun o xs ->\n (o :: l) :: xs)\n ol ans)\n (list_all (n - 1) ol) []\n else\n [[]]\n\nlet calc_op l opss = \n let rec loop ans =\n (function\n | (x :: xs, o :: os) ->\n (match o with\n Plus -> loop (ans + x) (xs, os)\n | Minus -> loop (ans - x) (xs, os)\n | Id -> loop x (xs, os))\n | _ -> ans)\n in\n loop 0 (l, opss) \n\nlet ic c = int_of_char c - int_of_char '0'\n\nlet () =\n let (a, b, c, d) = Scanf.sscanf (input_line stdin) \"%c%c%c%c\" (fun a b c d -> (ic a, ic b, ic c, ic d)) in\n let ops_lists = list_all 3 [Plus; Minus] in\n let ops_lists' = List.map (fun ops -> Id :: ops) ops_lists in\n let rec solve = function\n [] -> failwith \"Not found\"\n | ops :: opss ->\n if calc_op [a;b;c;d] ops = 7 then\n ops\n else\n solve opss\n in\n let ans = solve ops_lists' in\n List.iter2 (fun x op ->\n print_op op;\n print_int x) [a;b;c;d] ans;\n print_string \"=7\";\n print_newline ()\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nSitting in a station waiting room, Joisino is gazing at her train ticket.\n\nThe ticket is numbered with four digits A, B, C and D in this order, each between 0 and 9 (inclusive).\n\nIn the formula A op1 B op2 C op3 D = 7, replace each of the symbols op1, op2 and op3 with + or - so that the formula holds.\n\nThe given input guarantees that there is a solution. If there are multiple solutions, any of them will be accepted.\n\nConstraints\n\n0≤A,B,C,D≤9\n\nAll input values are integers.\n\nIt is guaranteed that there is a solution.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nABCD\n\nOutput\n\nPrint the formula you made, including the part =7.\n\nUse the signs + and -.\n\nDo not print a space between a digit and a sign.\n\nSample Input 1\n\n1222\n\nSample Output 1\n\n1+2+2+2=7\n\nThis is the only valid solution.\n\nSample Input 2\n\n0290\n\nSample Output 2\n\n0-2+9+0=7\n\n0 - 2 + 9 - 0 = 7 is also a valid solution.\n\nSample Input 3\n\n3242\n\nSample Output 3\n\n3+2+4-2=7", "sample_input": "1222\n"}, "reference_outputs": ["1+2+2+2=7\n"], "source_document_id": "p03545", "source_text": "Score : 300 points\n\nProblem Statement\n\nSitting in a station waiting room, Joisino is gazing at her train ticket.\n\nThe ticket is numbered with four digits A, B, C and D in this order, each between 0 and 9 (inclusive).\n\nIn the formula A op1 B op2 C op3 D = 7, replace each of the symbols op1, op2 and op3 with + or - so that the formula holds.\n\nThe given input guarantees that there is a solution. If there are multiple solutions, any of them will be accepted.\n\nConstraints\n\n0≤A,B,C,D≤9\n\nAll input values are integers.\n\nIt is guaranteed that there is a solution.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nABCD\n\nOutput\n\nPrint the formula you made, including the part =7.\n\nUse the signs + and -.\n\nDo not print a space between a digit and a sign.\n\nSample Input 1\n\n1222\n\nSample Output 1\n\n1+2+2+2=7\n\nThis is the only valid solution.\n\nSample Input 2\n\n0290\n\nSample Output 2\n\n0-2+9+0=7\n\n0 - 2 + 9 - 0 = 7 is also a valid solution.\n\nSample Input 3\n\n3242\n\nSample Output 3\n\n3+2+4-2=7", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1449, "cpu_time_ms": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s059918080", "group_id": "codeNet:p03545", "input_text": "let id x = x\nlet n = Scanf.scanf \"%s\\n\" id\nlet a = (int_of_char n.[0]) - 48\nlet b = (int_of_char n.[1]) - 48\nlet c = (int_of_char n.[2]) - 48\nlet d = (int_of_char n.[3]) - 48\nlet oplist = [1;0]\n\nlet i2op i = if i = 1 then (+) else (-)\nlet i2c i = if i = 1 then '+' else '-'\n \nlet rec loop3 op1 op2 l =\n match l with\n | [] -> []\n | op3 :: rest ->\n if (i2op op3) ((i2op op2) ((i2op op1) a b) c) d = 7 then (op1,op2,op3) :: loop3 op1 op2 rest\n else loop3 op1 op2 rest\n\nlet rec loop2 op1 l =\n match l with\n | [] -> []\n | op2 :: rest -> (loop3 op1 op2 oplist) @ loop2 op1 rest\n \nlet rec loop1 l =\n match l with\n | [] -> []\n | op1 :: rest -> (loop2 op1 oplist) @ loop1 rest\n \nlet (op1,op2,op3) = List.hd (loop1 oplist)\nlet (op1,op2,op3) = (i2c op1,i2c op2,i2c op3)\n \nlet () =\n Printf.printf \"%d%c%d%c%d%c%d=7\\n\" a op1 b op2 c op3 d", "language": "OCaml", "metadata": {"date": 1511061210, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03545.html", "problem_id": "p03545", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03545/input.txt", "sample_output_relpath": "derived/input_output/data/p03545/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03545/OCaml/s059918080.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s059918080", "user_id": "u735499035"}, "prompt_components": {"gold_output": "1+2+2+2=7\n", "input_to_evaluate": "let id x = x\nlet n = Scanf.scanf \"%s\\n\" id\nlet a = (int_of_char n.[0]) - 48\nlet b = (int_of_char n.[1]) - 48\nlet c = (int_of_char n.[2]) - 48\nlet d = (int_of_char n.[3]) - 48\nlet oplist = [1;0]\n\nlet i2op i = if i = 1 then (+) else (-)\nlet i2c i = if i = 1 then '+' else '-'\n \nlet rec loop3 op1 op2 l =\n match l with\n | [] -> []\n | op3 :: rest ->\n if (i2op op3) ((i2op op2) ((i2op op1) a b) c) d = 7 then (op1,op2,op3) :: loop3 op1 op2 rest\n else loop3 op1 op2 rest\n\nlet rec loop2 op1 l =\n match l with\n | [] -> []\n | op2 :: rest -> (loop3 op1 op2 oplist) @ loop2 op1 rest\n \nlet rec loop1 l =\n match l with\n | [] -> []\n | op1 :: rest -> (loop2 op1 oplist) @ loop1 rest\n \nlet (op1,op2,op3) = List.hd (loop1 oplist)\nlet (op1,op2,op3) = (i2c op1,i2c op2,i2c op3)\n \nlet () =\n Printf.printf \"%d%c%d%c%d%c%d=7\\n\" a op1 b op2 c op3 d", "problem_context": "Score : 300 points\n\nProblem Statement\n\nSitting in a station waiting room, Joisino is gazing at her train ticket.\n\nThe ticket is numbered with four digits A, B, C and D in this order, each between 0 and 9 (inclusive).\n\nIn the formula A op1 B op2 C op3 D = 7, replace each of the symbols op1, op2 and op3 with + or - so that the formula holds.\n\nThe given input guarantees that there is a solution. If there are multiple solutions, any of them will be accepted.\n\nConstraints\n\n0≤A,B,C,D≤9\n\nAll input values are integers.\n\nIt is guaranteed that there is a solution.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nABCD\n\nOutput\n\nPrint the formula you made, including the part =7.\n\nUse the signs + and -.\n\nDo not print a space between a digit and a sign.\n\nSample Input 1\n\n1222\n\nSample Output 1\n\n1+2+2+2=7\n\nThis is the only valid solution.\n\nSample Input 2\n\n0290\n\nSample Output 2\n\n0-2+9+0=7\n\n0 - 2 + 9 - 0 = 7 is also a valid solution.\n\nSample Input 3\n\n3242\n\nSample Output 3\n\n3+2+4-2=7", "sample_input": "1222\n"}, "reference_outputs": ["1+2+2+2=7\n"], "source_document_id": "p03545", "source_text": "Score : 300 points\n\nProblem Statement\n\nSitting in a station waiting room, Joisino is gazing at her train ticket.\n\nThe ticket is numbered with four digits A, B, C and D in this order, each between 0 and 9 (inclusive).\n\nIn the formula A op1 B op2 C op3 D = 7, replace each of the symbols op1, op2 and op3 with + or - so that the formula holds.\n\nThe given input guarantees that there is a solution. If there are multiple solutions, any of them will be accepted.\n\nConstraints\n\n0≤A,B,C,D≤9\n\nAll input values are integers.\n\nIt is guaranteed that there is a solution.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nABCD\n\nOutput\n\nPrint the formula you made, including the part =7.\n\nUse the signs + and -.\n\nDo not print a space between a digit and a sign.\n\nSample Input 1\n\n1222\n\nSample Output 1\n\n1+2+2+2=7\n\nThis is the only valid solution.\n\nSample Input 2\n\n0290\n\nSample Output 2\n\n0-2+9+0=7\n\n0 - 2 + 9 - 0 = 7 is also a valid solution.\n\nSample Input 3\n\n3242\n\nSample Output 3\n\n3+2+4-2=7", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 854, "cpu_time_ms": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s133130493", "group_id": "codeNet:p03546", "input_text": "(* quite naive implementation *)\nlet rec dikjstra ( +. ) ( < ) q edge d =\n match q with\n | [] -> ()\n | u :: q ->\n let u, q = \n List.fold_left (fun (u, q') u' ->\n if d.(u) < d.(u') then (u, u' :: q')\n else (u', u :: q')) (u, []) q in\n List.iter (fun (v, c) ->\n if c +. d.(u) < d.(v) then\n d.(v) <- c +. d.(u)) (edge u);\n dikjstra ( +. ) ( < ) q edge d\n\nlet () =\n let h, w = Scanf.scanf \"%d %d\\n\" (fun h w -> h, w) in\n let css =\n Array.init 10 (fun _ ->\n Array.init 10 (fun i ->\n Scanf.scanf \"%d \" (fun c -> c))) in\n let css' =\n Array.init 10 (fun i ->\n Array.to_list @@ Array.init 10 (fun j -> (j, css.(j).(i)))) in\n let ass =\n Array.init h (fun _ ->\n Array.init w (fun _ ->\n Scanf.scanf \"%d \" (fun a -> a))) in\n let cost = Array.make 10 1145141919 in\n cost.(1) <- 0;\n dikjstra ( + ) ( < ) [1; 2; 3; 4; 5; 6; 7; 8; 9; 0] (fun i -> css'.(i)) cost;\n Printf.printf \"%d\\n\" @@ Array.fold_left ( + ) 0 @@ Array.map (fun as_ ->\n Array.fold_left ( + ) 0 @@ Array.map (function -1 -> 0 | n -> cost.(n)) as_) ass\n", "language": "OCaml", "metadata": {"date": 1511059951, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03546.html", "problem_id": "p03546", "resource_group": "low_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/OCaml/s133130493.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s133130493", "user_id": "u504158101"}, "prompt_components": {"gold_output": "12\n", "input_to_evaluate": "(* quite naive implementation *)\nlet rec dikjstra ( +. ) ( < ) q edge d =\n match q with\n | [] -> ()\n | u :: q ->\n let u, q = \n List.fold_left (fun (u, q') u' ->\n if d.(u) < d.(u') then (u, u' :: q')\n else (u', u :: q')) (u, []) q in\n List.iter (fun (v, c) ->\n if c +. d.(u) < d.(v) then\n d.(v) <- c +. d.(u)) (edge u);\n dikjstra ( +. ) ( < ) q edge d\n\nlet () =\n let h, w = Scanf.scanf \"%d %d\\n\" (fun h w -> h, w) in\n let css =\n Array.init 10 (fun _ ->\n Array.init 10 (fun i ->\n Scanf.scanf \"%d \" (fun c -> c))) in\n let css' =\n Array.init 10 (fun i ->\n Array.to_list @@ Array.init 10 (fun j -> (j, css.(j).(i)))) in\n let ass =\n Array.init h (fun _ ->\n Array.init w (fun _ ->\n Scanf.scanf \"%d \" (fun a -> a))) in\n let cost = Array.make 10 1145141919 in\n cost.(1) <- 0;\n dikjstra ( + ) ( < ) [1; 2; 3; 4; 5; 6; 7; 8; 9; 0] (fun i -> css'.(i)) cost;\n Printf.printf \"%d\\n\" @@ Array.fold_left ( + ) 0 @@ Array.map (fun as_ ->\n Array.fold_left ( + ) 0 @@ Array.map (function -1 -> 0 | n -> cost.(n)) as_) ass\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nJoisino the magical girl has decided to turn every single digit that exists on this world into 1.\n\nRewriting a digit i with j (0≤i,j≤9) costs c_{i,j} MP (Magic Points).\n\nShe is now standing before a wall. The wall is divided into HW squares in H rows and W columns, and at least one square contains a digit between 0 and 9 (inclusive).\n\nYou are given A_{i,j} that describes the square at the i-th row from the top and j-th column from the left, as follows:\n\nIf A_{i,j}≠-1, the square contains a digit A_{i,j}.\n\nIf A_{i,j}=-1, the square does not contain a digit.\n\nFind the minimum total amount of MP required to turn every digit on this wall into 1 in the end.\n\nConstraints\n\n1≤H,W≤200\n\n1≤c_{i,j}≤10^3 (i≠j)\n\nc_{i,j}=0 (i=j)\n\n-1≤A_{i,j}≤9\n\nAll input values are integers.\n\nThere is at least one digit on the wall.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\nc_{0,0} ... c_{0,9}\n:\nc_{9,0} ... c_{9,9}\nA_{1,1} ... A_{1,W}\n:\nA_{H,1} ... A_{H,W}\n\nOutput\n\nPrint the minimum total amount of MP required to turn every digit on the wall into 1 in the end.\n\nSample Input 1\n\n2 4\n0 9 9 9 9 9 9 9 9 9\n9 0 9 9 9 9 9 9 9 9\n9 9 0 9 9 9 9 9 9 9\n9 9 9 0 9 9 9 9 9 9\n9 9 9 9 0 9 9 9 9 2\n9 9 9 9 9 0 9 9 9 9\n9 9 9 9 9 9 0 9 9 9\n9 9 9 9 9 9 9 0 9 9\n9 9 9 9 2 9 9 9 0 9\n9 2 9 9 9 9 9 9 9 0\n-1 -1 -1 -1\n8 1 1 8\n\nSample Output 1\n\n12\n\nTo turn a single 8 into 1, it is optimal to first turn 8 into 4, then turn 4 into 9, and finally turn 9 into 1, costing 6 MP.\n\nThe wall contains two 8s, so the minimum total MP required is 6×2=12.\n\nSample Input 2\n\n5 5\n0 999 999 999 999 999 999 999 999 999\n999 0 999 999 999 999 999 999 999 999\n999 999 0 999 999 999 999 999 999 999\n999 999 999 0 999 999 999 999 999 999\n999 999 999 999 0 999 999 999 999 999\n999 999 999 999 999 0 999 999 999 999\n999 999 999 999 999 999 0 999 999 999\n999 999 999 999 999 999 999 0 999 999\n999 999 999 999 999 999 999 999 0 999\n999 999 999 999 999 999 999 999 999 0\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1\n\nSample Output 2\n\n0\n\nNote that she may not need to change any digit.\n\nSample Input 3\n\n3 5\n0 4 3 6 2 7 2 5 3 3\n4 0 5 3 7 5 3 7 2 7\n5 7 0 7 2 9 3 2 9 1\n3 6 2 0 2 4 6 4 2 3\n3 5 7 4 0 6 9 7 6 7\n9 8 5 2 2 0 4 7 6 5\n5 4 6 3 2 3 0 5 4 3\n3 6 2 3 4 2 4 0 8 9\n4 6 5 4 3 5 3 2 0 8\n2 1 3 4 5 7 8 6 4 0\n3 5 2 6 1\n2 5 3 2 1\n6 9 2 5 6\n\nSample Output 3\n\n47", "sample_input": "2 4\n0 9 9 9 9 9 9 9 9 9\n9 0 9 9 9 9 9 9 9 9\n9 9 0 9 9 9 9 9 9 9\n9 9 9 0 9 9 9 9 9 9\n9 9 9 9 0 9 9 9 9 2\n9 9 9 9 9 0 9 9 9 9\n9 9 9 9 9 9 0 9 9 9\n9 9 9 9 9 9 9 0 9 9\n9 9 9 9 2 9 9 9 0 9\n9 2 9 9 9 9 9 9 9 0\n-1 -1 -1 -1\n8 1 1 8\n"}, "reference_outputs": ["12\n"], "source_document_id": "p03546", "source_text": "Score : 400 points\n\nProblem Statement\n\nJoisino the magical girl has decided to turn every single digit that exists on this world into 1.\n\nRewriting a digit i with j (0≤i,j≤9) costs c_{i,j} MP (Magic Points).\n\nShe is now standing before a wall. The wall is divided into HW squares in H rows and W columns, and at least one square contains a digit between 0 and 9 (inclusive).\n\nYou are given A_{i,j} that describes the square at the i-th row from the top and j-th column from the left, as follows:\n\nIf A_{i,j}≠-1, the square contains a digit A_{i,j}.\n\nIf A_{i,j}=-1, the square does not contain a digit.\n\nFind the minimum total amount of MP required to turn every digit on this wall into 1 in the end.\n\nConstraints\n\n1≤H,W≤200\n\n1≤c_{i,j}≤10^3 (i≠j)\n\nc_{i,j}=0 (i=j)\n\n-1≤A_{i,j}≤9\n\nAll input values are integers.\n\nThere is at least one digit on the wall.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\nc_{0,0} ... c_{0,9}\n:\nc_{9,0} ... c_{9,9}\nA_{1,1} ... A_{1,W}\n:\nA_{H,1} ... A_{H,W}\n\nOutput\n\nPrint the minimum total amount of MP required to turn every digit on the wall into 1 in the end.\n\nSample Input 1\n\n2 4\n0 9 9 9 9 9 9 9 9 9\n9 0 9 9 9 9 9 9 9 9\n9 9 0 9 9 9 9 9 9 9\n9 9 9 0 9 9 9 9 9 9\n9 9 9 9 0 9 9 9 9 2\n9 9 9 9 9 0 9 9 9 9\n9 9 9 9 9 9 0 9 9 9\n9 9 9 9 9 9 9 0 9 9\n9 9 9 9 2 9 9 9 0 9\n9 2 9 9 9 9 9 9 9 0\n-1 -1 -1 -1\n8 1 1 8\n\nSample Output 1\n\n12\n\nTo turn a single 8 into 1, it is optimal to first turn 8 into 4, then turn 4 into 9, and finally turn 9 into 1, costing 6 MP.\n\nThe wall contains two 8s, so the minimum total MP required is 6×2=12.\n\nSample Input 2\n\n5 5\n0 999 999 999 999 999 999 999 999 999\n999 0 999 999 999 999 999 999 999 999\n999 999 0 999 999 999 999 999 999 999\n999 999 999 0 999 999 999 999 999 999\n999 999 999 999 0 999 999 999 999 999\n999 999 999 999 999 0 999 999 999 999\n999 999 999 999 999 999 0 999 999 999\n999 999 999 999 999 999 999 0 999 999\n999 999 999 999 999 999 999 999 0 999\n999 999 999 999 999 999 999 999 999 0\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1\n\nSample Output 2\n\n0\n\nNote that she may not need to change any digit.\n\nSample Input 3\n\n3 5\n0 4 3 6 2 7 2 5 3 3\n4 0 5 3 7 5 3 7 2 7\n5 7 0 7 2 9 3 2 9 1\n3 6 2 0 2 4 6 4 2 3\n3 5 7 4 0 6 9 7 6 7\n9 8 5 2 2 0 4 7 6 5\n5 4 6 3 2 3 0 5 4 3\n3 6 2 3 4 2 4 0 8 9\n4 6 5 4 3 5 3 2 0 8\n2 1 3 4 5 7 8 6 4 0\n3 5 2 6 1\n2 5 3 2 1\n6 9 2 5 6\n\nSample Output 3\n\n47", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1110, "cpu_time_ms": 11, "memory_kb": 4992}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s308495619", "group_id": "codeNet:p03547", "input_text": "Scanf.scanf \"%c %c\" (fun x y ->\n print_endline @@ if x < y then \"<\" else\n if x > y then \">\" else \"=\"\n)", "language": "OCaml", "metadata": {"date": 1601092271, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p03547.html", "problem_id": "p03547", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03547/input.txt", "sample_output_relpath": "derived/input_output/data/p03547/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03547/OCaml/s308495619.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s308495619", "user_id": "u342443598"}, "prompt_components": {"gold_output": "<\n", "input_to_evaluate": "Scanf.scanf \"%c %c\" (fun x y ->\n print_endline @@ if x < y then \"<\" else\n if x > y then \">\" else \"=\"\n)", "problem_context": "Score : 100 points\n\nProblem Statement\n\nIn programming, hexadecimal notation is often used.\n\nIn hexadecimal notation, besides the ten digits 0, 1, ..., 9, the six letters A, B, C, D, E and F are used to represent the values 10, 11, 12, 13, 14 and 15, respectively.\n\nIn this problem, you are given two letters X and Y. Each X and Y is A, B, C, D, E or F.\n\nWhen X and Y are seen as hexadecimal numbers, which is larger?\n\nConstraints\n\nEach X and Y is A, B, C, D, E or F.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX Y\n\nOutput\n\nIf X is smaller, print <; if Y is smaller, print >; if they are equal, print =.\n\nSample Input 1\n\nA B\n\nSample Output 1\n\n<\n\n10 < 11.\n\nSample Input 2\n\nE C\n\nSample Output 2\n\n>\n\n14 > 12.\n\nSample Input 3\n\nF F\n\nSample Output 3\n\n=\n\n15 = 15.", "sample_input": "A B\n"}, "reference_outputs": ["<\n"], "source_document_id": "p03547", "source_text": "Score : 100 points\n\nProblem Statement\n\nIn programming, hexadecimal notation is often used.\n\nIn hexadecimal notation, besides the ten digits 0, 1, ..., 9, the six letters A, B, C, D, E and F are used to represent the values 10, 11, 12, 13, 14 and 15, respectively.\n\nIn this problem, you are given two letters X and Y. Each X and Y is A, B, C, D, E or F.\n\nWhen X and Y are seen as hexadecimal numbers, which is larger?\n\nConstraints\n\nEach X and Y is A, B, C, D, E or F.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX Y\n\nOutput\n\nIf X is smaller, print <; if Y is smaller, print >; if they are equal, print =.\n\nSample Input 1\n\nA B\n\nSample Output 1\n\n<\n\n10 < 11.\n\nSample Input 2\n\nE C\n\nSample Output 2\n\n>\n\n14 > 12.\n\nSample Input 3\n\nF F\n\nSample Output 3\n\n=\n\n15 = 15.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 9, "memory_kb": 3736}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s714136907", "group_id": "codeNet:p03547", "input_text": "let id x = x\nlet (x,y) = Scanf.scanf \"%c %c\\n\" (fun x y -> (x,y))\n\nlet ans = if x = y then '=' else\n if x < y then '<' else '>' \n\nlet () =\n Printf.printf \"%c\\n\" ans\n", "language": "OCaml", "metadata": {"date": 1510452491, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03547.html", "problem_id": "p03547", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03547/input.txt", "sample_output_relpath": "derived/input_output/data/p03547/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03547/OCaml/s714136907.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s714136907", "user_id": "u735499035"}, "prompt_components": {"gold_output": "<\n", "input_to_evaluate": "let id x = x\nlet (x,y) = Scanf.scanf \"%c %c\\n\" (fun x y -> (x,y))\n\nlet ans = if x = y then '=' else\n if x < y then '<' else '>' \n\nlet () =\n Printf.printf \"%c\\n\" ans\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nIn programming, hexadecimal notation is often used.\n\nIn hexadecimal notation, besides the ten digits 0, 1, ..., 9, the six letters A, B, C, D, E and F are used to represent the values 10, 11, 12, 13, 14 and 15, respectively.\n\nIn this problem, you are given two letters X and Y. Each X and Y is A, B, C, D, E or F.\n\nWhen X and Y are seen as hexadecimal numbers, which is larger?\n\nConstraints\n\nEach X and Y is A, B, C, D, E or F.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX Y\n\nOutput\n\nIf X is smaller, print <; if Y is smaller, print >; if they are equal, print =.\n\nSample Input 1\n\nA B\n\nSample Output 1\n\n<\n\n10 < 11.\n\nSample Input 2\n\nE C\n\nSample Output 2\n\n>\n\n14 > 12.\n\nSample Input 3\n\nF F\n\nSample Output 3\n\n=\n\n15 = 15.", "sample_input": "A B\n"}, "reference_outputs": ["<\n"], "source_document_id": "p03547", "source_text": "Score : 100 points\n\nProblem Statement\n\nIn programming, hexadecimal notation is often used.\n\nIn hexadecimal notation, besides the ten digits 0, 1, ..., 9, the six letters A, B, C, D, E and F are used to represent the values 10, 11, 12, 13, 14 and 15, respectively.\n\nIn this problem, you are given two letters X and Y. Each X and Y is A, B, C, D, E or F.\n\nWhen X and Y are seen as hexadecimal numbers, which is larger?\n\nConstraints\n\nEach X and Y is A, B, C, D, E or F.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nX Y\n\nOutput\n\nIf X is smaller, print <; if Y is smaller, print >; if they are equal, print =.\n\nSample Input 1\n\nA B\n\nSample Output 1\n\n<\n\n10 < 11.\n\nSample Input 2\n\nE C\n\nSample Output 2\n\n>\n\n14 > 12.\n\nSample Input 3\n\nF F\n\nSample Output 3\n\n=\n\n15 = 15.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s756571441", "group_id": "codeNet:p03548", "input_text": "let x, y, z = Scanf.scanf \" %d %d %d\" @@ fun a b c -> a, b, c\nlet n = ref 1\nlet _ =\n while !n * y + (!n + 1) * z <= x do incr n done;\n Printf.printf \"%d\\n\" @@ !n - 1", "language": "OCaml", "metadata": {"date": 1562032147, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03548.html", "problem_id": "p03548", "resource_group": "low_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/OCaml/s756571441.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s756571441", "user_id": "u732304692"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "let x, y, z = Scanf.scanf \" %d %d %d\" @@ fun a b c -> a, b, c\nlet n = ref 1\nlet _ =\n while !n * y + (!n + 1) * z <= x do incr n done;\n Printf.printf \"%d\\n\" @@ !n - 1", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s056967645", "group_id": "codeNet:p03551", "input_text": "let memoize n f =\n let dp = Hashtbl.create n in\n let rec get x =\n try Hashtbl.find dp x with\n | Not_found ->\n let result = f get x in\n Hashtbl.add dp x result;\n result in\n get\n\nlet () =\n let n, z, w = Scanf.scanf \"%d %d %d\\n\" (fun n z w -> n, z, w) in\n let as_ = Array.init n (fun _ -> Scanf.scanf \"%d \" (fun a -> a)) in\n let as' = Array.init (n + 2) (function 0 -> z | 1 -> w | i -> as_.(i - 2)) in\n let solve = memoize (n * n) (fun self (i, j) ->\n if j = n + 1 then abs (as'.(i) - as'.(j)), abs (as'.(i) - as'.(j))\n else\n Array.init (n - j + 1) (fun k -> self (j, 1 + k + j))\n |> Array.fold_left (fun (z, w) (x, y) -> (max z x, min w y)) (min_int, max_int)) in\n Printf.printf \"%d\\n\" @@ fst @@ solve (1, 2)", "language": "OCaml", "metadata": {"date": 1510462756, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03551.html", "problem_id": "p03551", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03551/input.txt", "sample_output_relpath": "derived/input_output/data/p03551/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03551/OCaml/s056967645.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s056967645", "user_id": "u504158101"}, "prompt_components": {"gold_output": "3800\n", "input_to_evaluate": "let memoize n f =\n let dp = Hashtbl.create n in\n let rec get x =\n try Hashtbl.find dp x with\n | Not_found ->\n let result = f get x in\n Hashtbl.add dp x result;\n result in\n get\n\nlet () =\n let n, z, w = Scanf.scanf \"%d %d %d\\n\" (fun n z w -> n, z, w) in\n let as_ = Array.init n (fun _ -> Scanf.scanf \"%d \" (fun a -> a)) in\n let as' = Array.init (n + 2) (function 0 -> z | 1 -> w | i -> as_.(i - 2)) in\n let solve = memoize (n * n) (fun self (i, j) ->\n if j = n + 1 then abs (as'.(i) - as'.(j)), abs (as'.(i) - as'.(j))\n else\n Array.init (n - j + 1) (fun k -> self (j, 1 + k + j))\n |> Array.fold_left (fun (z, w) (x, y) -> (max z x, min w y)) (min_int, max_int)) in\n Printf.printf \"%d\\n\" @@ fst @@ solve (1, 2)", "problem_context": "Score : 300 points\n\nProblem Statement\n\nTakahashi is now competing in a programming contest, but he received TLE in a problem where the answer is YES or NO.\n\nWhen he checked the detailed status of the submission, there were N test cases in the problem, and the code received TLE in M of those cases.\n\nThen, he rewrote the code to correctly solve each of those M cases with 1/2 probability in 1900 milliseconds, and correctly solve each of the other N-M cases without fail in 100 milliseconds.\n\nNow, he goes through the following process:\n\nSubmit the code.\n\nWait until the code finishes execution on all the cases.\n\nIf the code fails to correctly solve some of the M cases, submit it again.\n\nRepeat until the code correctly solve all the cases in one submission.\n\nLet the expected value of the total execution time of the code be X milliseconds. Print X (as an integer).\n\nConstraints\n\nAll input values are integers.\n\n1 \\leq N \\leq 100\n\n1 \\leq M \\leq {\\rm min}(N, 5)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\n\nOutput\n\nPrint X, the expected value of the total execution time of the code, as an integer. It can be proved that, under the constraints in this problem, X is an integer not exceeding 10^9.\n\nSample Input 1\n\n1 1\n\nSample Output 1\n\n3800\n\nIn this input, there is only one case. Takahashi will repeatedly submit the code that correctly solves this case with 1/2 probability in 1900 milliseconds.\n\nThe code will succeed in one attempt with 1/2 probability, in two attempts with 1/4 probability, and in three attempts with 1/8 probability, and so on.\n\nThus, the answer is 1900 \\times 1/2 + (2 \\times 1900) \\times 1/4 + (3 \\times 1900) \\times 1/8 + ... = 3800.\n\nSample Input 2\n\n10 2\n\nSample Output 2\n\n18400\n\nThe code will take 1900 milliseconds in each of the 2 cases, and 100 milliseconds in each of the 10-2=8 cases. The probability of the code correctly solving all the cases is 1/2 \\times 1/2 = 1/4.\n\nSample Input 3\n\n100 5\n\nSample Output 3\n\n608000", "sample_input": "1 1\n"}, "reference_outputs": ["3800\n"], "source_document_id": "p03551", "source_text": "Score : 300 points\n\nProblem Statement\n\nTakahashi is now competing in a programming contest, but he received TLE in a problem where the answer is YES or NO.\n\nWhen he checked the detailed status of the submission, there were N test cases in the problem, and the code received TLE in M of those cases.\n\nThen, he rewrote the code to correctly solve each of those M cases with 1/2 probability in 1900 milliseconds, and correctly solve each of the other N-M cases without fail in 100 milliseconds.\n\nNow, he goes through the following process:\n\nSubmit the code.\n\nWait until the code finishes execution on all the cases.\n\nIf the code fails to correctly solve some of the M cases, submit it again.\n\nRepeat until the code correctly solve all the cases in one submission.\n\nLet the expected value of the total execution time of the code be X milliseconds. Print X (as an integer).\n\nConstraints\n\nAll input values are integers.\n\n1 \\leq N \\leq 100\n\n1 \\leq M \\leq {\\rm min}(N, 5)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\n\nOutput\n\nPrint X, the expected value of the total execution time of the code, as an integer. It can be proved that, under the constraints in this problem, X is an integer not exceeding 10^9.\n\nSample Input 1\n\n1 1\n\nSample Output 1\n\n3800\n\nIn this input, there is only one case. Takahashi will repeatedly submit the code that correctly solves this case with 1/2 probability in 1900 milliseconds.\n\nThe code will succeed in one attempt with 1/2 probability, in two attempts with 1/4 probability, and in three attempts with 1/8 probability, and so on.\n\nThus, the answer is 1900 \\times 1/2 + (2 \\times 1900) \\times 1/4 + (3 \\times 1900) \\times 1/8 + ... = 3800.\n\nSample Input 2\n\n10 2\n\nSample Output 2\n\n18400\n\nThe code will take 1900 milliseconds in each of the 2 cases, and 100 milliseconds in each of the 10-2=8 cases. The probability of the code correctly solving all the cases is 1/2 \\times 1/2 = 1/4.\n\nSample Input 3\n\n100 5\n\nSample Output 3\n\n608000", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 758, "cpu_time_ms": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s250933093", "group_id": "codeNet:p03552", "input_text": "let rec select acc trace = function\n | [] -> acc\n | x :: xs -> select ((trace, x, xs) :: acc) (x :: trace) xs\nlet select xs = select [] [] xs\n\nlet rec maximize z w xs =\n select xs\n |> List.map (function\n | (_, x, []) -> abs (x - w)\n | (_, x, ys) -> minimize x w ys)\n |> List.fold_left max min_int\nand minimize z w ys = \n select ys\n |> List.map (function\n | (_, y, []) -> abs (z - y)\n | (_, y, xs) -> maximize z y xs)\n |> List.fold_left max min_int\n\nlet () =\n let n, z, w = Scanf.scanf \"%d %d %d\\n\" (fun n z w -> n, z, w) in\n let as_ = Array.init n (fun _ -> Scanf.scanf \"%d \" (fun a -> a)) in\n Printf.printf \"%d\\n\" @@ maximize z w (Array.to_list as_)", "language": "OCaml", "metadata": {"date": 1510464173, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03552.html", "problem_id": "p03552", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03552/input.txt", "sample_output_relpath": "derived/input_output/data/p03552/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03552/OCaml/s250933093.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s250933093", "user_id": "u504158101"}, "prompt_components": {"gold_output": "900\n", "input_to_evaluate": "let rec select acc trace = function\n | [] -> acc\n | x :: xs -> select ((trace, x, xs) :: acc) (x :: trace) xs\nlet select xs = select [] [] xs\n\nlet rec maximize z w xs =\n select xs\n |> List.map (function\n | (_, x, []) -> abs (x - w)\n | (_, x, ys) -> minimize x w ys)\n |> List.fold_left max min_int\nand minimize z w ys = \n select ys\n |> List.map (function\n | (_, y, []) -> abs (z - y)\n | (_, y, xs) -> maximize z y xs)\n |> List.fold_left max min_int\n\nlet () =\n let n, z, w = Scanf.scanf \"%d %d %d\\n\" (fun n z w -> n, z, w) in\n let as_ = Array.init n (fun _ -> Scanf.scanf \"%d \" (fun a -> a)) in\n Printf.printf \"%d\\n\" @@ maximize z w (Array.to_list as_)", "problem_context": "Score : 500 points\n\nProblem Statement\n\nWe have a deck consisting of N cards. Each card has an integer written on it. The integer on the i-th card from the top is a_i.\n\nTwo people X and Y will play a game using this deck. Initially, X has a card with Z written on it in his hand, and Y has a card with W written on it in his hand. Then, starting from X, they will alternately perform the following action:\n\nDraw some number of cards from the top of the deck. Then, discard the card in his hand and keep the last drawn card instead. Here, at least one card must be drawn.\n\nThe game ends when there is no more card in the deck. The score of the game is the absolute difference of the integers written on the cards in the two players' hand.\n\nX will play the game so that the score will be maximized, and Y will play the game so that the score will be minimized. What will be the score of the game?\n\nConstraints\n\nAll input values are integers.\n\n1 \\leq N \\leq 2000\n\n1 \\leq Z, W, a_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN Z W\na_1 a_2 ... a_N\n\nOutput\n\nPrint the score.\n\nSample Input 1\n\n3 100 100\n10 1000 100\n\nSample Output 1\n\n900\n\nIf X draws two cards first, Y will draw the last card, and the score will be |1000 - 100| = 900.\n\nSample Input 2\n\n3 100 1000\n10 100 100\n\nSample Output 2\n\n900\n\nIf X draws all the cards first, the score will be |1000 - 100| = 900.\n\nSample Input 3\n\n5 1 1\n1 1 1 1 1\n\nSample Output 3\n\n0\n\nSample Input 4\n\n1 1 1\n1000000000\n\nSample Output 4\n\n999999999", "sample_input": "3 100 100\n10 1000 100\n"}, "reference_outputs": ["900\n"], "source_document_id": "p03552", "source_text": "Score : 500 points\n\nProblem Statement\n\nWe have a deck consisting of N cards. Each card has an integer written on it. The integer on the i-th card from the top is a_i.\n\nTwo people X and Y will play a game using this deck. Initially, X has a card with Z written on it in his hand, and Y has a card with W written on it in his hand. Then, starting from X, they will alternately perform the following action:\n\nDraw some number of cards from the top of the deck. Then, discard the card in his hand and keep the last drawn card instead. Here, at least one card must be drawn.\n\nThe game ends when there is no more card in the deck. The score of the game is the absolute difference of the integers written on the cards in the two players' hand.\n\nX will play the game so that the score will be maximized, and Y will play the game so that the score will be minimized. What will be the score of the game?\n\nConstraints\n\nAll input values are integers.\n\n1 \\leq N \\leq 2000\n\n1 \\leq Z, W, a_i \\leq 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN Z W\na_1 a_2 ... a_N\n\nOutput\n\nPrint the score.\n\nSample Input 1\n\n3 100 100\n10 1000 100\n\nSample Output 1\n\n900\n\nIf X draws two cards first, Y will draw the last card, and the score will be |1000 - 100| = 900.\n\nSample Input 2\n\n3 100 1000\n10 100 100\n\nSample Output 2\n\n900\n\nIf X draws all the cards first, the score will be |1000 - 100| = 900.\n\nSample Input 3\n\n5 1 1\n1 1 1 1 1\n\nSample Output 3\n\n0\n\nSample Input 4\n\n1 1 1\n1000000000\n\nSample Output 4\n\n999999999", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 689, "cpu_time_ms": 2104, "memory_kb": 5504}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s972868702", "group_id": "codeNet:p03553", "input_text": "module DirectedGraph\n (* 道の表現 *)\n (Path : sig\n type t\n (* 辺の名前 *)\n type edge\n (* 長さ0の道 *)\n val nil : t\n (* 道の後ろに辺を付け足した道 *)\n val snoc : t -> edge -> t\n end) :\nsig\n (* BFSにより,重みのないグラフの最短経路を求める *)\n val bfs :\n (* 頂点数(Hashtblを用いるので目安程度) *)\n int ->\n (* 辺の名前が付いた隣接リスト *)\n ('v -> ('v * Path.edge) list) ->\n (* 始点 *)\n 'v ->\n (* 最短経路を返す関数 辿り着けなければNoneを返す) *)\n ('v -> Path.t option)\nend = struct\n let rec bfs_aux es d frontier t =\n try Some (Hashtbl.find d t) with\n | Not_found ->\n match !frontier with\n | [] -> None\n | _ :: _ ->\n frontier := List.fold_right (fun u ->\n List.fold_right (fun (v, e) frontier ->\n if Hashtbl.mem d v\n then frontier\n else (Hashtbl.add d v (Path.snoc (Hashtbl.find d u) e); v :: frontier))\n (es u)) !frontier [];\n bfs_aux es d frontier t\n\n (*\n * 終点に辿り着いた時点で探索を切り上げるが,\n * 戻り値の関数を覚えておくと,途中まで探索した結果が再利用される\n * (#trace bfs_aux すると分かりやすい)\n *)\n let bfs n es s =\n let d = Hashtbl.create n in\n Hashtbl.add d s Path.nil;\n let frontier = ref [s] in\n bfs_aux es d frontier\nend\n\nmodule FlowNetwork\n (* 流量 *)\n (Flow : sig\n type t\n val inf : t\n val zero : t\n val ( + ) : t -> t -> t\n val ( - ) : t -> t -> t\n val compare : t -> t -> int\n end) :\nsig\n val max_flow :\n (* 頂点の数(Hashtblを用いるので目安程度) *)\n int ->\n (* 始点 *)\n 'v ->\n (* 終点 *)\n 'v ->\n (* 各辺とその逆辺の容量 *)\n ('v * 'v * Flow.t * Flow.t) list ->\n (* 最大フロー *)\n Flow.t *\n (* 最大フローを流した際の各辺の流量 *)\n ('v * 'v * Flow.t) list\nend =\nstruct\n module G = DirectedGraph (struct\n type t = int\n type edge = unit\n let nil = 0\n let snoc t _ = t + 1\n end)\n\n (* 増加パスをDFSで探し,流せるだけ流していく *)\n let rec dfs capacity add_edge iter level v t f =\n if v = t then f\n else begin\n let rec find () =\n match Hashtbl.find iter v with\n | exception Not_found -> Flow.zero\n | (u, i) ->\n Hashtbl.remove iter v;\n (* capacity i <= 0 *)\n if Flow.compare (capacity i) Flow.zero <= 0 || level u <= level v then find ()\n else begin\n let d = dfs capacity add_edge iter level u t @@\n (* min f (capacity i) *)\n if Flow.compare f (capacity i) <= 0 then f else capacity i in\n (* d <= 0 *)\n if Flow.compare d Flow.zero <= 0 then find ()\n else (add_edge i d; d)\n end in find ()\n end\n\n let max_flow n s t es =\n assert (s <> t);\n (* 各辺に流せる流量 *)\n let capacity = Array.make (2 * List.length es) Flow.zero in\n (* 逆辺を張りつつ,隣接リスト形式に変換 *)\n let adj = Hashtbl.create n in\n List.iteri (fun i (u, v, c, c') ->\n (* 各辺は番号で管理する *)\n Hashtbl.add adj u (v, 2 * i);\n (* 容量はcapacityを見てほしい *)\n capacity.(2 * i) <- c;\n (* 逆辺 *)\n Hashtbl.add adj v (u, 2 * i + 1);\n capacity.(2 * i + 1) <- c') es;\n (* 番号iの辺にcだけフローを流す *)\n let add_edge i c =\n let open Flow in\n capacity.(i) <- capacity.(i) - c;\n (* 逆辺 *)\n capacity.(i lxor 1) <- capacity.(i lxor 1) + c in\n let rec outer flow =\n let level = G.bfs n (fun v ->\n List.concat @@ List.map (fun (u, i) ->\n if Flow.compare capacity.(i) Flow.zero <= 0 then []\n else [(u, ())]) @@ Hashtbl.find_all adj v) s in\n if level t = None then flow\n else\n let iter = Hashtbl.copy adj in\n let rec inner flow =\n let f = dfs (fun i -> capacity.(i)) add_edge iter level s t Flow.inf in\n if Flow.compare f Flow.zero <= 0 then flow\n else inner (Flow.( + ) flow f) in\n outer @@ inner flow in\n let f = outer Flow.zero in\n (f, List.mapi (fun i (u, v, c, _) ->\n (u, v, Flow.( - ) c capacity.(2 * i))) es)\nend\n\nmodule G = FlowNetwork (struct\n type t = int\n let inf = max_int\n let zero = 0\n let ( + ) = ( + )\n let ( - ) = ( - )\n let compare = compare\nend)\n\nlet () = Scanf.scanf \"%d\\n\" @@ fun n ->\n let as_ = Array.to_list @@\n Array.init n @@ fun _ ->\n Scanf.scanf \"%d \" @@ fun a -> a in\n Printf.printf \"%d\\n\" @@ ( - ) (List.fold_right (fun a -> ( + ) @@ max 0 a) as_ 0) @@\n fst @@ G.max_flow n 0 1 @@ List.concat @@ List.mapi (fun i a ->\n ( if a = 0 then []\n else if a < 0 then [(0, i + 2, ~- a, 0)]\n else [(i + 2, 1, a, 0)] ) @\n List.concat @@ Array.to_list @@ Array.init n @@ fun j ->\n if i < j && (j + 1) mod (i + 1) = 0 then [(i + 2, j + 2, max_int, 0)]\n else []) as_\n", "language": "OCaml", "metadata": {"date": 1536102308, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03553.html", "problem_id": "p03553", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03553/input.txt", "sample_output_relpath": "derived/input_output/data/p03553/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03553/OCaml/s972868702.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s972868702", "user_id": "u504158101"}, "prompt_components": {"gold_output": "12\n", "input_to_evaluate": "module DirectedGraph\n (* 道の表現 *)\n (Path : sig\n type t\n (* 辺の名前 *)\n type edge\n (* 長さ0の道 *)\n val nil : t\n (* 道の後ろに辺を付け足した道 *)\n val snoc : t -> edge -> t\n end) :\nsig\n (* BFSにより,重みのないグラフの最短経路を求める *)\n val bfs :\n (* 頂点数(Hashtblを用いるので目安程度) *)\n int ->\n (* 辺の名前が付いた隣接リスト *)\n ('v -> ('v * Path.edge) list) ->\n (* 始点 *)\n 'v ->\n (* 最短経路を返す関数 辿り着けなければNoneを返す) *)\n ('v -> Path.t option)\nend = struct\n let rec bfs_aux es d frontier t =\n try Some (Hashtbl.find d t) with\n | Not_found ->\n match !frontier with\n | [] -> None\n | _ :: _ ->\n frontier := List.fold_right (fun u ->\n List.fold_right (fun (v, e) frontier ->\n if Hashtbl.mem d v\n then frontier\n else (Hashtbl.add d v (Path.snoc (Hashtbl.find d u) e); v :: frontier))\n (es u)) !frontier [];\n bfs_aux es d frontier t\n\n (*\n * 終点に辿り着いた時点で探索を切り上げるが,\n * 戻り値の関数を覚えておくと,途中まで探索した結果が再利用される\n * (#trace bfs_aux すると分かりやすい)\n *)\n let bfs n es s =\n let d = Hashtbl.create n in\n Hashtbl.add d s Path.nil;\n let frontier = ref [s] in\n bfs_aux es d frontier\nend\n\nmodule FlowNetwork\n (* 流量 *)\n (Flow : sig\n type t\n val inf : t\n val zero : t\n val ( + ) : t -> t -> t\n val ( - ) : t -> t -> t\n val compare : t -> t -> int\n end) :\nsig\n val max_flow :\n (* 頂点の数(Hashtblを用いるので目安程度) *)\n int ->\n (* 始点 *)\n 'v ->\n (* 終点 *)\n 'v ->\n (* 各辺とその逆辺の容量 *)\n ('v * 'v * Flow.t * Flow.t) list ->\n (* 最大フロー *)\n Flow.t *\n (* 最大フローを流した際の各辺の流量 *)\n ('v * 'v * Flow.t) list\nend =\nstruct\n module G = DirectedGraph (struct\n type t = int\n type edge = unit\n let nil = 0\n let snoc t _ = t + 1\n end)\n\n (* 増加パスをDFSで探し,流せるだけ流していく *)\n let rec dfs capacity add_edge iter level v t f =\n if v = t then f\n else begin\n let rec find () =\n match Hashtbl.find iter v with\n | exception Not_found -> Flow.zero\n | (u, i) ->\n Hashtbl.remove iter v;\n (* capacity i <= 0 *)\n if Flow.compare (capacity i) Flow.zero <= 0 || level u <= level v then find ()\n else begin\n let d = dfs capacity add_edge iter level u t @@\n (* min f (capacity i) *)\n if Flow.compare f (capacity i) <= 0 then f else capacity i in\n (* d <= 0 *)\n if Flow.compare d Flow.zero <= 0 then find ()\n else (add_edge i d; d)\n end in find ()\n end\n\n let max_flow n s t es =\n assert (s <> t);\n (* 各辺に流せる流量 *)\n let capacity = Array.make (2 * List.length es) Flow.zero in\n (* 逆辺を張りつつ,隣接リスト形式に変換 *)\n let adj = Hashtbl.create n in\n List.iteri (fun i (u, v, c, c') ->\n (* 各辺は番号で管理する *)\n Hashtbl.add adj u (v, 2 * i);\n (* 容量はcapacityを見てほしい *)\n capacity.(2 * i) <- c;\n (* 逆辺 *)\n Hashtbl.add adj v (u, 2 * i + 1);\n capacity.(2 * i + 1) <- c') es;\n (* 番号iの辺にcだけフローを流す *)\n let add_edge i c =\n let open Flow in\n capacity.(i) <- capacity.(i) - c;\n (* 逆辺 *)\n capacity.(i lxor 1) <- capacity.(i lxor 1) + c in\n let rec outer flow =\n let level = G.bfs n (fun v ->\n List.concat @@ List.map (fun (u, i) ->\n if Flow.compare capacity.(i) Flow.zero <= 0 then []\n else [(u, ())]) @@ Hashtbl.find_all adj v) s in\n if level t = None then flow\n else\n let iter = Hashtbl.copy adj in\n let rec inner flow =\n let f = dfs (fun i -> capacity.(i)) add_edge iter level s t Flow.inf in\n if Flow.compare f Flow.zero <= 0 then flow\n else inner (Flow.( + ) flow f) in\n outer @@ inner flow in\n let f = outer Flow.zero in\n (f, List.mapi (fun i (u, v, c, _) ->\n (u, v, Flow.( - ) c capacity.(2 * i))) es)\nend\n\nmodule G = FlowNetwork (struct\n type t = int\n let inf = max_int\n let zero = 0\n let ( + ) = ( + )\n let ( - ) = ( - )\n let compare = compare\nend)\n\nlet () = Scanf.scanf \"%d\\n\" @@ fun n ->\n let as_ = Array.to_list @@\n Array.init n @@ fun _ ->\n Scanf.scanf \"%d \" @@ fun a -> a in\n Printf.printf \"%d\\n\" @@ ( - ) (List.fold_right (fun a -> ( + ) @@ max 0 a) as_ 0) @@\n fst @@ G.max_flow n 0 1 @@ List.concat @@ List.mapi (fun i a ->\n ( if a = 0 then []\n else if a < 0 then [(0, i + 2, ~- a, 0)]\n else [(i + 2, 1, a, 0)] ) @\n List.concat @@ Array.to_list @@ Array.init n @@ fun j ->\n if i < j && (j + 1) mod (i + 1) = 0 then [(i + 2, j + 2, max_int, 0)]\n else []) as_\n", "problem_context": "Score : 700 points\n\nProblem Statement\n\nWe have N gemstones labeled 1 through N.\n\nYou can perform the following operation any number of times (possibly zero).\n\nSelect a positive integer x, and smash all the gems labeled with multiples of x.\n\nThen, for each i, if the gem labeled i remains without getting smashed, you will receive a_i yen (the currency of Japan).\nHowever, a_i may be negative, in which case you will be charged money.\n\nBy optimally performing the operation, how much yen can you earn?\n\nConstraints\n\nAll input values are integers.\n\n1 \\leq N \\leq 100\n\n|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 amount of money that can be earned.\n\nSample Input 1\n\n6\n1 2 -6 4 5 3\n\nSample Output 1\n\n12\n\nIt is optimal to smash Gem 3 and 6.\n\nSample Input 2\n\n6\n100 -100 -100 -100 100 -100\n\nSample Output 2\n\n200\n\nSample Input 3\n\n5\n-1 -2 -3 -4 -5\n\nSample Output 3\n\n0\n\nIt is optimal to smash all the gems.\n\nSample Input 4\n\n2\n-1000 100000\n\nSample Output 4\n\n99000", "sample_input": "6\n1 2 -6 4 5 3\n"}, "reference_outputs": ["12\n"], "source_document_id": "p03553", "source_text": "Score : 700 points\n\nProblem Statement\n\nWe have N gemstones labeled 1 through N.\n\nYou can perform the following operation any number of times (possibly zero).\n\nSelect a positive integer x, and smash all the gems labeled with multiples of x.\n\nThen, for each i, if the gem labeled i remains without getting smashed, you will receive a_i yen (the currency of Japan).\nHowever, a_i may be negative, in which case you will be charged money.\n\nBy optimally performing the operation, how much yen can you earn?\n\nConstraints\n\nAll input values are integers.\n\n1 \\leq N \\leq 100\n\n|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 amount of money that can be earned.\n\nSample Input 1\n\n6\n1 2 -6 4 5 3\n\nSample Output 1\n\n12\n\nIt is optimal to smash Gem 3 and 6.\n\nSample Input 2\n\n6\n100 -100 -100 -100 100 -100\n\nSample Output 2\n\n200\n\nSample Input 3\n\n5\n-1 -2 -3 -4 -5\n\nSample Output 3\n\n0\n\nIt is optimal to smash all the gems.\n\nSample Input 4\n\n2\n-1000 100000\n\nSample Output 4\n\n99000", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 5129, "cpu_time_ms": 3, "memory_kb": 3328}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s423138888", "group_id": "codeNet:p03555", "input_text": "let s1 = read_line ()\nlet s2 = read_line ()\nlet _ = print_endline @@ if s1.[0] = s2.[2] && s1.[1] = s2.[1] && s1.[2] = s2.[0] then \"YES\" else \"NO\"", "language": "OCaml", "metadata": {"date": 1564658755, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03555.html", "problem_id": "p03555", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03555/input.txt", "sample_output_relpath": "derived/input_output/data/p03555/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03555/OCaml/s423138888.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s423138888", "user_id": "u732304692"}, "prompt_components": {"gold_output": "YES\n", "input_to_evaluate": "let s1 = read_line ()\nlet s2 = read_line ()\nlet _ = print_endline @@ if s1.[0] = s2.[2] && s1.[1] = s2.[1] && s1.[2] = s2.[0] then \"YES\" else \"NO\"", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou are given a grid with 2 rows and 3 columns of squares.\nThe color of the square at the i-th row and j-th column is represented by the character C_{ij}.\n\nWrite a program that prints YES if this grid remains the same when rotated 180 degrees, and prints NO otherwise.\n\nConstraints\n\nC_{i,j}(1 \\leq i \\leq 2, 1 \\leq j \\leq 3) is a lowercase English letter.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nC_{11}C_{12}C_{13}\nC_{21}C_{22}C_{23}\n\nOutput\n\nPrint YES if this grid remains the same when rotated 180 degrees; print NO otherwise.\n\nSample Input 1\n\npot\ntop\n\nSample Output 1\n\nYES\n\nThis grid remains the same when rotated 180 degrees.\n\nSample Input 2\n\ntab\nbet\n\nSample Output 2\n\nNO\n\nThis grid does not remain the same when rotated 180 degrees.\n\nSample Input 3\n\neye\neel\n\nSample Output 3\n\nNO", "sample_input": "pot\ntop\n"}, "reference_outputs": ["YES\n"], "source_document_id": "p03555", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou are given a grid with 2 rows and 3 columns of squares.\nThe color of the square at the i-th row and j-th column is represented by the character C_{ij}.\n\nWrite a program that prints YES if this grid remains the same when rotated 180 degrees, and prints NO otherwise.\n\nConstraints\n\nC_{i,j}(1 \\leq i \\leq 2, 1 \\leq j \\leq 3) is a lowercase English letter.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nC_{11}C_{12}C_{13}\nC_{21}C_{22}C_{23}\n\nOutput\n\nPrint YES if this grid remains the same when rotated 180 degrees; print NO otherwise.\n\nSample Input 1\n\npot\ntop\n\nSample Output 1\n\nYES\n\nThis grid remains the same when rotated 180 degrees.\n\nSample Input 2\n\ntab\nbet\n\nSample Output 2\n\nNO\n\nThis grid does not remain the same when rotated 180 degrees.\n\nSample Input 3\n\neye\neel\n\nSample Output 3\n\nNO", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s247929561", "group_id": "codeNet:p03555", "input_text": "let () =\n let a, b = Scanf.scanf \"%s %s\" (fun a b -> a, b) in\n Printf.printf \"%s\\n\" @@ if a.[0] = b.[2] && a.[1] = b.[1] && a.[2] = b.[0] then \"YES\" else \"NO\"\n", "language": "OCaml", "metadata": {"date": 1519621472, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03555.html", "problem_id": "p03555", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03555/input.txt", "sample_output_relpath": "derived/input_output/data/p03555/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03555/OCaml/s247929561.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s247929561", "user_id": "u798181098"}, "prompt_components": {"gold_output": "YES\n", "input_to_evaluate": "let () =\n let a, b = Scanf.scanf \"%s %s\" (fun a b -> a, b) in\n Printf.printf \"%s\\n\" @@ if a.[0] = b.[2] && a.[1] = b.[1] && a.[2] = b.[0] then \"YES\" else \"NO\"\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou are given a grid with 2 rows and 3 columns of squares.\nThe color of the square at the i-th row and j-th column is represented by the character C_{ij}.\n\nWrite a program that prints YES if this grid remains the same when rotated 180 degrees, and prints NO otherwise.\n\nConstraints\n\nC_{i,j}(1 \\leq i \\leq 2, 1 \\leq j \\leq 3) is a lowercase English letter.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nC_{11}C_{12}C_{13}\nC_{21}C_{22}C_{23}\n\nOutput\n\nPrint YES if this grid remains the same when rotated 180 degrees; print NO otherwise.\n\nSample Input 1\n\npot\ntop\n\nSample Output 1\n\nYES\n\nThis grid remains the same when rotated 180 degrees.\n\nSample Input 2\n\ntab\nbet\n\nSample Output 2\n\nNO\n\nThis grid does not remain the same when rotated 180 degrees.\n\nSample Input 3\n\neye\neel\n\nSample Output 3\n\nNO", "sample_input": "pot\ntop\n"}, "reference_outputs": ["YES\n"], "source_document_id": "p03555", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou are given a grid with 2 rows and 3 columns of squares.\nThe color of the square at the i-th row and j-th column is represented by the character C_{ij}.\n\nWrite a program that prints YES if this grid remains the same when rotated 180 degrees, and prints NO otherwise.\n\nConstraints\n\nC_{i,j}(1 \\leq i \\leq 2, 1 \\leq j \\leq 3) is a lowercase English letter.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nC_{11}C_{12}C_{13}\nC_{21}C_{22}C_{23}\n\nOutput\n\nPrint YES if this grid remains the same when rotated 180 degrees; print NO otherwise.\n\nSample Input 1\n\npot\ntop\n\nSample Output 1\n\nYES\n\nThis grid remains the same when rotated 180 degrees.\n\nSample Input 2\n\ntab\nbet\n\nSample Output 2\n\nNO\n\nThis grid does not remain the same when rotated 180 degrees.\n\nSample Input 3\n\neye\neel\n\nSample Output 3\n\nNO", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s650328276", "group_id": "codeNet:p03556", "input_text": "let ()=Scanf.scanf\"%f\"(fun x->x)|>sqrt|>int_of_float|>(fun x->x*x)|>Printf.printf\"%d\\n\"", "language": "OCaml", "metadata": {"date": 1519621686, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03556.html", "problem_id": "p03556", "resource_group": "low_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/OCaml/s650328276.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s650328276", "user_id": "u798181098"}, "prompt_components": {"gold_output": "9\n", "input_to_evaluate": "let ()=Scanf.scanf\"%f\"(fun x->x)|>sqrt|>int_of_float|>(fun x->x*x)|>Printf.printf\"%d\\n\"", "problem_context": "Score : 200 points\n\nProblem Statement\n\nFind the largest square number not exceeding N. Here, a square number is an integer that can be represented as the square of an integer.\n\nConstraints\n\n1 \\leq N \\leq 10^9\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the largest square number not exceeding N.\n\nSample Input 1\n\n10\n\nSample Output 1\n\n9\n\n10 is not square, but 9 = 3 × 3 is. Thus, we print 9.\n\nSample Input 2\n\n81\n\nSample Output 2\n\n81\n\nSample Input 3\n\n271828182\n\nSample Output 3\n\n271821169", "sample_input": "10\n"}, "reference_outputs": ["9\n"], "source_document_id": "p03556", "source_text": "Score : 200 points\n\nProblem Statement\n\nFind the largest square number not exceeding N. Here, a square number is an integer that can be represented as the square of an integer.\n\nConstraints\n\n1 \\leq N \\leq 10^9\n\nN is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the largest square number not exceeding N.\n\nSample Input 1\n\n10\n\nSample Output 1\n\n9\n\n10 is not square, but 9 = 3 × 3 is. Thus, we print 9.\n\nSample Input 2\n\n81\n\nSample Output 2\n\n81\n\nSample Input 3\n\n271828182\n\nSample Output 3\n\n271821169", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s949312606", "group_id": "codeNet:p03557", "input_text": "open Scanf\nopen Printf\n \nlet input_array n = Array.init n (fun _ -> scanf \"%d \" (fun x -> x))\n\nlet n = scanf \"%d\\n\" (fun x -> x)\nlet a_ = input_array n\nlet b_ = input_array n\nlet c_ = input_array n\n\nlet rec lower_bound' arr (first, last) n =\n let mid = (first+last)/2\n in if last - first <= 1\n then if (arr.(first) < n) then last else first\n else if (arr.(mid) < n) \n then lower_bound' arr (mid, last) n\n else lower_bound' arr (first, mid) n\n\nlet lower_bound arr n = if arr.(Array.length arr - 1) < n\n then Array.length arr\n else lower_bound' arr (0, Array.length arr - 1) n\n\nlet upper_bound arr n = lower_bound arr (n+1)\n\nlet _ = Array.sort Pervasives.compare a_; Array.sort Pervasives.compare c_;\n Array.fold_left (fun s x -> s + lower_bound a_ x * (n - upper_bound c_ x)) 0 b_\n |> print_int\n |> print_newline\n", "language": "OCaml", "metadata": {"date": 1519085106, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03557.html", "problem_id": "p03557", "resource_group": "low_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/OCaml/s949312606.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s949312606", "user_id": "u988832865"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "open Scanf\nopen Printf\n \nlet input_array n = Array.init n (fun _ -> scanf \"%d \" (fun x -> x))\n\nlet n = scanf \"%d\\n\" (fun x -> x)\nlet a_ = input_array n\nlet b_ = input_array n\nlet c_ = input_array n\n\nlet rec lower_bound' arr (first, last) n =\n let mid = (first+last)/2\n in if last - first <= 1\n then if (arr.(first) < n) then last else first\n else if (arr.(mid) < n) \n then lower_bound' arr (mid, last) n\n else lower_bound' arr (first, mid) n\n\nlet lower_bound arr n = if arr.(Array.length arr - 1) < n\n then Array.length arr\n else lower_bound' arr (0, Array.length arr - 1) n\n\nlet upper_bound arr n = lower_bound arr (n+1)\n\nlet _ = Array.sort Pervasives.compare a_; Array.sort Pervasives.compare c_;\n Array.fold_left (fun s x -> s + lower_bound a_ x * (n - upper_bound c_ x)) 0 b_\n |> print_int\n |> print_newline\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThe season for Snuke Festival has come again this year. First of all, Ringo will perform a ritual to summon Snuke. For the ritual, he needs an altar, which consists of three parts, one in each of the three categories: upper, middle and lower.\n\nHe has N parts for each of the three categories. The size of the i-th upper part is A_i, the size of the i-th middle part is B_i, and the size of the i-th lower part is C_i.\n\nTo build an altar, the size of the middle part must be strictly greater than that of the upper part, and the size of the lower part must be strictly greater than that of the middle part. On the other hand, any three parts that satisfy these conditions can be combined to form an altar.\n\nHow many different altars can Ringo build? Here, two altars are considered different when at least one of the three parts used is different.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq A_i \\leq 10^9(1\\leq i\\leq N)\n\n1 \\leq B_i \\leq 10^9(1\\leq i\\leq N)\n\n1 \\leq C_i \\leq 10^9(1\\leq i\\leq N)\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 ... A_N\nB_1 ... B_N\nC_1 ... C_N\n\nOutput\n\nPrint the number of different altars that Ringo can build.\n\nSample Input 1\n\n2\n1 5\n2 4\n3 6\n\nSample Output 1\n\n3\n\nThe following three altars can be built:\n\nUpper: 1-st part, Middle: 1-st part, Lower: 1-st part\n\nUpper: 1-st part, Middle: 1-st part, Lower: 2-nd part\n\nUpper: 1-st part, Middle: 2-nd part, Lower: 2-nd part\n\nSample Input 2\n\n3\n1 1 1\n2 2 2\n3 3 3\n\nSample Output 2\n\n27\n\nSample Input 3\n\n6\n3 14 159 2 6 53\n58 9 79 323 84 6\n2643 383 2 79 50 288\n\nSample Output 3\n\n87", "sample_input": "2\n1 5\n2 4\n3 6\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03557", "source_text": "Score : 300 points\n\nProblem Statement\n\nThe season for Snuke Festival has come again this year. First of all, Ringo will perform a ritual to summon Snuke. For the ritual, he needs an altar, which consists of three parts, one in each of the three categories: upper, middle and lower.\n\nHe has N parts for each of the three categories. The size of the i-th upper part is A_i, the size of the i-th middle part is B_i, and the size of the i-th lower part is C_i.\n\nTo build an altar, the size of the middle part must be strictly greater than that of the upper part, and the size of the lower part must be strictly greater than that of the middle part. On the other hand, any three parts that satisfy these conditions can be combined to form an altar.\n\nHow many different altars can Ringo build? Here, two altars are considered different when at least one of the three parts used is different.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq A_i \\leq 10^9(1\\leq i\\leq N)\n\n1 \\leq B_i \\leq 10^9(1\\leq i\\leq N)\n\n1 \\leq C_i \\leq 10^9(1\\leq i\\leq N)\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 ... A_N\nB_1 ... B_N\nC_1 ... C_N\n\nOutput\n\nPrint the number of different altars that Ringo can build.\n\nSample Input 1\n\n2\n1 5\n2 4\n3 6\n\nSample Output 1\n\n3\n\nThe following three altars can be built:\n\nUpper: 1-st part, Middle: 1-st part, Lower: 1-st part\n\nUpper: 1-st part, Middle: 1-st part, Lower: 2-nd part\n\nUpper: 1-st part, Middle: 2-nd part, Lower: 2-nd part\n\nSample Input 2\n\n3\n1 1 1\n2 2 2\n3 3 3\n\nSample Output 2\n\n27\n\nSample Input 3\n\n6\n3 14 159 2 6 53\n58 9 79 323 84 6\n2643 383 2 79 50 288\n\nSample Output 3\n\n87", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 870, "cpu_time_ms": 252, "memory_kb": 6400}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s566357282", "group_id": "codeNet:p03558", "input_text": "module WeightedDirectedGraph\n (Vertex : sig\n type t\n val compare : t -> t -> int\n end)\n (Weight : sig\n type t\n val zero : t\n val ( + ) : t -> t -> t\n val compare : t -> t -> int\n end) :\nsig\n val dijkstra :\n (* 隣接リスト *)\n (Vertex.t -> (Vertex.t * Weight.t) list) ->\n (* 始点 *)\n Vertex.t ->\n (* 始点から辿り着けなければNoneを返す *)\n (Vertex.t -> Weight.t option)\nend =\nstruct\n module WMap = Map.Make (Weight)\n module VMap = Map.Make (Vertex)\n\n (* ダイクストラ法のメインループ *)\n (* d に入っていない頂点への距離は無限大とみなす *)\n let rec dijkstra_aux e (d, q) =\n match WMap.min_binding q with\n | exception Not_found -> d\n | (w, us) ->\n dijkstra_aux e @@ List.fold_left (fun (d, q) u ->\n if Weight.compare (VMap.find u d) w < 0\n (* 既に頂点uを訪れていた *)\n then (d, q)\n (* w = d.(u) *)\n else List.fold_left (fun (d, q) (v, c) ->\n let open Weight in\n if\n (* d.(v) <= d.(u) + c *)\n try Weight.compare (VMap.find v d) (w + c) <= 0\n with Not_found -> false (* d.(v) は無限大 *)\n then (d, q)\n else\n VMap.add v (w + c) d,\n WMap.add (w + c) (v :: try WMap.find (w + c) q with Not_found -> []) q)\n (d, q) (e u)) (d, WMap.remove w q) us\n\n let dijkstra e s =\n let d =\n dijkstra_aux e\n (VMap.singleton s Weight.zero, WMap.singleton Weight.zero [s]) in\n fun t -> try Some (VMap.find t d) with Not_found -> None\nend\n\nmodule Int = struct\n type t = int\n let zero = 0\n let ( + ) = ( + )\n let compare = compare\nend\n\nmodule G = WeightedDirectedGraph (Int) (Int)\n\nlet () = Scanf.scanf \"%d\\n\" @@ fun k ->\n let Some d = G.dijkstra (fun i -> [((i + 1) mod k, 1); (i * 10 mod k, 0)]) 1 0 in\n Printf.printf \"%d\\n\" @@ 1 + d", "language": "OCaml", "metadata": {"date": 1532008549, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03558.html", "problem_id": "p03558", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03558/input.txt", "sample_output_relpath": "derived/input_output/data/p03558/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03558/OCaml/s566357282.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s566357282", "user_id": "u504158101"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "module WeightedDirectedGraph\n (Vertex : sig\n type t\n val compare : t -> t -> int\n end)\n (Weight : sig\n type t\n val zero : t\n val ( + ) : t -> t -> t\n val compare : t -> t -> int\n end) :\nsig\n val dijkstra :\n (* 隣接リスト *)\n (Vertex.t -> (Vertex.t * Weight.t) list) ->\n (* 始点 *)\n Vertex.t ->\n (* 始点から辿り着けなければNoneを返す *)\n (Vertex.t -> Weight.t option)\nend =\nstruct\n module WMap = Map.Make (Weight)\n module VMap = Map.Make (Vertex)\n\n (* ダイクストラ法のメインループ *)\n (* d に入っていない頂点への距離は無限大とみなす *)\n let rec dijkstra_aux e (d, q) =\n match WMap.min_binding q with\n | exception Not_found -> d\n | (w, us) ->\n dijkstra_aux e @@ List.fold_left (fun (d, q) u ->\n if Weight.compare (VMap.find u d) w < 0\n (* 既に頂点uを訪れていた *)\n then (d, q)\n (* w = d.(u) *)\n else List.fold_left (fun (d, q) (v, c) ->\n let open Weight in\n if\n (* d.(v) <= d.(u) + c *)\n try Weight.compare (VMap.find v d) (w + c) <= 0\n with Not_found -> false (* d.(v) は無限大 *)\n then (d, q)\n else\n VMap.add v (w + c) d,\n WMap.add (w + c) (v :: try WMap.find (w + c) q with Not_found -> []) q)\n (d, q) (e u)) (d, WMap.remove w q) us\n\n let dijkstra e s =\n let d =\n dijkstra_aux e\n (VMap.singleton s Weight.zero, WMap.singleton Weight.zero [s]) in\n fun t -> try Some (VMap.find t d) with Not_found -> None\nend\n\nmodule Int = struct\n type t = int\n let zero = 0\n let ( + ) = ( + )\n let compare = compare\nend\n\nmodule G = WeightedDirectedGraph (Int) (Int)\n\nlet () = Scanf.scanf \"%d\\n\" @@ fun k ->\n let Some d = G.dijkstra (fun i -> [((i + 1) mod k, 1); (i * 10 mod k, 0)]) 1 0 in\n Printf.printf \"%d\\n\" @@ 1 + d", "problem_context": "Score : 700 points\n\nProblem Statement\n\nFind the smallest possible sum of the digits in the decimal notation of a positive multiple of K.\n\nConstraints\n\n2 \\leq K \\leq 10^5\n\nK is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK\n\nOutput\n\nPrint the smallest possible sum of the digits in the decimal notation of a positive multiple of K.\n\nSample Input 1\n\n6\n\nSample Output 1\n\n3\n\n12=6×2 yields the smallest sum.\n\nSample Input 2\n\n41\n\nSample Output 2\n\n5\n\n11111=41×271 yields the smallest sum.\n\nSample Input 3\n\n79992\n\nSample Output 3\n\n36", "sample_input": "6\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03558", "source_text": "Score : 700 points\n\nProblem Statement\n\nFind the smallest possible sum of the digits in the decimal notation of a positive multiple of K.\n\nConstraints\n\n2 \\leq K \\leq 10^5\n\nK is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK\n\nOutput\n\nPrint the smallest possible sum of the digits in the decimal notation of a positive multiple of K.\n\nSample Input 1\n\n6\n\nSample Output 1\n\n3\n\n12=6×2 yields the smallest sum.\n\nSample Input 2\n\n41\n\nSample Output 2\n\n5\n\n11111=41×271 yields the smallest sum.\n\nSample Input 3\n\n79992\n\nSample Output 3\n\n36", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1925, "cpu_time_ms": 264, "memory_kb": 14464}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s195603145", "group_id": "codeNet:p03560", "input_text": "Scanf.scanf \"%d\" (fun k ->\n let arr = Array.make k max_int in\n\n let deq = Array.make (2 * k) 0 in\n\n let rec loop f l =\n if f <= l then (\n let num = deq.(f) in\n let f = f + 1 in\n let cost = arr.(num) in\n let next = (num * 10) mod k in\n let f = if cost < arr.(next) then (\n arr.(next) <- cost;\n let f = f - 1 in\n deq.(f) <- next;\n f\n ) else f in\n let next = (num + 1) mod k in\n let l = if cost + 1 < arr.(next) then (\n arr.(next) <- cost + 1;\n let l = l + 1 in\n deq.(l) <- next;\n l\n ) else l\n in\n loop f l\n ) else f, l\n in\n arr.(1) <- 1;\n deq.(k) <- 1;\n ignore (loop k k);\n Printf.printf \"%d\\n\" arr.(0)\n)", "language": "OCaml", "metadata": {"date": 1596935397, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p03560.html", "problem_id": "p03560", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03560/input.txt", "sample_output_relpath": "derived/input_output/data/p03560/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03560/OCaml/s195603145.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s195603145", "user_id": "u342443598"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "Scanf.scanf \"%d\" (fun k ->\n let arr = Array.make k max_int in\n\n let deq = Array.make (2 * k) 0 in\n\n let rec loop f l =\n if f <= l then (\n let num = deq.(f) in\n let f = f + 1 in\n let cost = arr.(num) in\n let next = (num * 10) mod k in\n let f = if cost < arr.(next) then (\n arr.(next) <- cost;\n let f = f - 1 in\n deq.(f) <- next;\n f\n ) else f in\n let next = (num + 1) mod k in\n let l = if cost + 1 < arr.(next) then (\n arr.(next) <- cost + 1;\n let l = l + 1 in\n deq.(l) <- next;\n l\n ) else l\n in\n loop f l\n ) else f, l\n in\n arr.(1) <- 1;\n deq.(k) <- 1;\n ignore (loop k k);\n Printf.printf \"%d\\n\" arr.(0)\n)", "problem_context": "Score : 700 points\n\nProblem Statement\n\nFind the smallest possible sum of the digits in the decimal notation of a positive multiple of K.\n\nConstraints\n\n2 \\leq K \\leq 10^5\n\nK is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK\n\nOutput\n\nPrint the smallest possible sum of the digits in the decimal notation of a positive multiple of K.\n\nSample Input 1\n\n6\n\nSample Output 1\n\n3\n\n12=6×2 yields the smallest sum.\n\nSample Input 2\n\n41\n\nSample Output 2\n\n5\n\n11111=41×271 yields the smallest sum.\n\nSample Input 3\n\n79992\n\nSample Output 3\n\n36", "sample_input": "6\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03560", "source_text": "Score : 700 points\n\nProblem Statement\n\nFind the smallest possible sum of the digits in the decimal notation of a positive multiple of K.\n\nConstraints\n\n2 \\leq K \\leq 10^5\n\nK is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK\n\nOutput\n\nPrint the smallest possible sum of the digits in the decimal notation of a positive multiple of K.\n\nSample Input 1\n\n6\n\nSample Output 1\n\n3\n\n12=6×2 yields the smallest sum.\n\nSample Input 2\n\n41\n\nSample Output 2\n\n5\n\n11111=41×271 yields the smallest sum.\n\nSample Input 3\n\n79992\n\nSample Output 3\n\n36", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 881, "cpu_time_ms": 24, "memory_kb": 6148}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s798037249", "group_id": "codeNet:p03560", "input_text": "Scanf.scanf \"%d\" (fun k ->\n let arr = Array.make k (-1) in\n\n let deq = Array.make (2 * k) 0 in\n\n let rec loop f l =\n if f <= l then (\n let num = deq.(f) in\n let f = f + 1 in\n let cost = arr.(num) in\n let next = (num * 10) mod k in\n if arr.(next) < 0 || arr.(next) > cost then (\n arr.(next) <- cost;\n let f = f - 1 in\n deq.(f) <- next;\n loop f l\n );\n let next = (num + 1) mod k in\n if arr.(next) < 0 || arr.(next) > cost + 1 then (\n arr.(next) <- cost + 1;\n let l = l + 1 in\n deq.(l) <- next;\n loop f l\n );\n )\n in\n arr.(1) <- 1;\n deq.(k) <- 1;\n loop k k;\n Printf.printf \"%d\\n\" arr.(0)\n)", "language": "OCaml", "metadata": {"date": 1596929945, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p03560.html", "problem_id": "p03560", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03560/input.txt", "sample_output_relpath": "derived/input_output/data/p03560/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03560/OCaml/s798037249.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s798037249", "user_id": "u342443598"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "Scanf.scanf \"%d\" (fun k ->\n let arr = Array.make k (-1) in\n\n let deq = Array.make (2 * k) 0 in\n\n let rec loop f l =\n if f <= l then (\n let num = deq.(f) in\n let f = f + 1 in\n let cost = arr.(num) in\n let next = (num * 10) mod k in\n if arr.(next) < 0 || arr.(next) > cost then (\n arr.(next) <- cost;\n let f = f - 1 in\n deq.(f) <- next;\n loop f l\n );\n let next = (num + 1) mod k in\n if arr.(next) < 0 || arr.(next) > cost + 1 then (\n arr.(next) <- cost + 1;\n let l = l + 1 in\n deq.(l) <- next;\n loop f l\n );\n )\n in\n arr.(1) <- 1;\n deq.(k) <- 1;\n loop k k;\n Printf.printf \"%d\\n\" arr.(0)\n)", "problem_context": "Score : 700 points\n\nProblem Statement\n\nFind the smallest possible sum of the digits in the decimal notation of a positive multiple of K.\n\nConstraints\n\n2 \\leq K \\leq 10^5\n\nK is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK\n\nOutput\n\nPrint the smallest possible sum of the digits in the decimal notation of a positive multiple of K.\n\nSample Input 1\n\n6\n\nSample Output 1\n\n3\n\n12=6×2 yields the smallest sum.\n\nSample Input 2\n\n41\n\nSample Output 2\n\n5\n\n11111=41×271 yields the smallest sum.\n\nSample Input 3\n\n79992\n\nSample Output 3\n\n36", "sample_input": "6\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03560", "source_text": "Score : 700 points\n\nProblem Statement\n\nFind the smallest possible sum of the digits in the decimal notation of a positive multiple of K.\n\nConstraints\n\n2 \\leq K \\leq 10^5\n\nK is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK\n\nOutput\n\nPrint the smallest possible sum of the digits in the decimal notation of a positive multiple of K.\n\nSample Input 1\n\n6\n\nSample Output 1\n\n3\n\n12=6×2 yields the smallest sum.\n\nSample Input 2\n\n41\n\nSample Output 2\n\n5\n\n11111=41×271 yields the smallest sum.\n\nSample Input 3\n\n79992\n\nSample Output 3\n\n36", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 842, "cpu_time_ms": 2206, "memory_kb": 10816}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s543211144", "group_id": "codeNet:p03560", "input_text": "module IntWeightedDirectedGraphByArray = struct\n type 'a church_list = { fold : 'b. ('a -> 'b -> 'b) -> 'b -> 'b }\n\n (* 辺の重さがごく小さい場合は,Mapをキュー代わりに使うより配列を使った方が効率的\n 時間計算量はO(E+VW),空間計算量はO(E+W) *)\n let dijkstra_special :\n (* 頂点数n *)\n int ->\n (* 辺の重さの上限W *)\n int ->\n (* 頂点uを受け取って,\n uから伸びる辺の終点vと重さwの組みのリストを返す関数\n 辺の重さwはW以下でなくてはならない *)\n (int -> (int * int) church_list) ->\n (* 始点 *)\n int ->\n (* 始点から辿り着けなければinfを返す関数\n この関数を覚えておけば,呼び出しごとの途中までの計算結果がシェアされる *)\n (int -> int)\n = fun n mw es s ->\n (* 各頂点への最短距離を格納するやつ *)\n let d = Array.make n max_int in\n (* キュー *)\n let q = Array.make (mw + 1) [] in\n (* ヒープの最小要素の重み *)\n let w = ref 0 in\n (* ヒープの最小要素がどのインデックスに対応するか *)\n let i = ref 0 in\n (* ヒープに格納されている要素の数 *)\n let m = ref 1 in\n d.(s) <- 0;\n q.(0) <- [s];\n let rec dijkstra_aux t =\n (* 既に終点までの距離が分かっているので返す *)\n if !m <= 0 || d.(t) <= !w then d.(t) else\n match q.(!i) with\n (* ヒープには重さがwの要素は無かった *)\n | [] ->\n incr w;\n incr i;\n if mw < !i then i := 0;\n dijkstra_aux t\n (* ヒープには重さwの要素uが存在する *)\n | u :: us ->\n (* ヒープから重さwの要素を削除する *)\n q.(!i) <- us;\n decr m;\n if !w <= d.(u) then\n (* 未だ頂点uを訪れていない *)\n (es u).fold (fun (v, c) () ->\n if !w + c < d.(v) then begin\n d.(v) <- !w + c; (* 頂点vの重さを緩和 *)\n (* ヒープにvを追加する *)\n incr m;\n let j = !i + c - if !i + c <= mw then 0 else mw + 1 in\n q.(j) <- v :: q.(j)\n end) ();\n dijkstra_aux t in\n dijkstra_aux\nend\n\nlet () = Scanf.scanf \"%d\" @@ fun k ->\n Printf.printf \"%d\\n\" @@\n succ @@\n IntWeightedDirectedGraphByArray.dijkstra_special k 1 (fun i ->\n { IntWeightedDirectedGraphByArray.fold = fun f acc -> f ((i + 1) mod k, 1) @@ f (i * 10 mod k, 0) acc }) 1 0\n", "language": "OCaml", "metadata": {"date": 1589490430, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03560.html", "problem_id": "p03560", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03560/input.txt", "sample_output_relpath": "derived/input_output/data/p03560/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03560/OCaml/s543211144.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s543211144", "user_id": "u504158101"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "module IntWeightedDirectedGraphByArray = struct\n type 'a church_list = { fold : 'b. ('a -> 'b -> 'b) -> 'b -> 'b }\n\n (* 辺の重さがごく小さい場合は,Mapをキュー代わりに使うより配列を使った方が効率的\n 時間計算量はO(E+VW),空間計算量はO(E+W) *)\n let dijkstra_special :\n (* 頂点数n *)\n int ->\n (* 辺の重さの上限W *)\n int ->\n (* 頂点uを受け取って,\n uから伸びる辺の終点vと重さwの組みのリストを返す関数\n 辺の重さwはW以下でなくてはならない *)\n (int -> (int * int) church_list) ->\n (* 始点 *)\n int ->\n (* 始点から辿り着けなければinfを返す関数\n この関数を覚えておけば,呼び出しごとの途中までの計算結果がシェアされる *)\n (int -> int)\n = fun n mw es s ->\n (* 各頂点への最短距離を格納するやつ *)\n let d = Array.make n max_int in\n (* キュー *)\n let q = Array.make (mw + 1) [] in\n (* ヒープの最小要素の重み *)\n let w = ref 0 in\n (* ヒープの最小要素がどのインデックスに対応するか *)\n let i = ref 0 in\n (* ヒープに格納されている要素の数 *)\n let m = ref 1 in\n d.(s) <- 0;\n q.(0) <- [s];\n let rec dijkstra_aux t =\n (* 既に終点までの距離が分かっているので返す *)\n if !m <= 0 || d.(t) <= !w then d.(t) else\n match q.(!i) with\n (* ヒープには重さがwの要素は無かった *)\n | [] ->\n incr w;\n incr i;\n if mw < !i then i := 0;\n dijkstra_aux t\n (* ヒープには重さwの要素uが存在する *)\n | u :: us ->\n (* ヒープから重さwの要素を削除する *)\n q.(!i) <- us;\n decr m;\n if !w <= d.(u) then\n (* 未だ頂点uを訪れていない *)\n (es u).fold (fun (v, c) () ->\n if !w + c < d.(v) then begin\n d.(v) <- !w + c; (* 頂点vの重さを緩和 *)\n (* ヒープにvを追加する *)\n incr m;\n let j = !i + c - if !i + c <= mw then 0 else mw + 1 in\n q.(j) <- v :: q.(j)\n end) ();\n dijkstra_aux t in\n dijkstra_aux\nend\n\nlet () = Scanf.scanf \"%d\" @@ fun k ->\n Printf.printf \"%d\\n\" @@\n succ @@\n IntWeightedDirectedGraphByArray.dijkstra_special k 1 (fun i ->\n { IntWeightedDirectedGraphByArray.fold = fun f acc -> f ((i + 1) mod k, 1) @@ f (i * 10 mod k, 0) acc }) 1 0\n", "problem_context": "Score : 700 points\n\nProblem Statement\n\nFind the smallest possible sum of the digits in the decimal notation of a positive multiple of K.\n\nConstraints\n\n2 \\leq K \\leq 10^5\n\nK is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK\n\nOutput\n\nPrint the smallest possible sum of the digits in the decimal notation of a positive multiple of K.\n\nSample Input 1\n\n6\n\nSample Output 1\n\n3\n\n12=6×2 yields the smallest sum.\n\nSample Input 2\n\n41\n\nSample Output 2\n\n5\n\n11111=41×271 yields the smallest sum.\n\nSample Input 3\n\n79992\n\nSample Output 3\n\n36", "sample_input": "6\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03560", "source_text": "Score : 700 points\n\nProblem Statement\n\nFind the smallest possible sum of the digits in the decimal notation of a positive multiple of K.\n\nConstraints\n\n2 \\leq K \\leq 10^5\n\nK is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nK\n\nOutput\n\nPrint the smallest possible sum of the digits in the decimal notation of a positive multiple of K.\n\nSample Input 1\n\n6\n\nSample Output 1\n\n3\n\n12=6×2 yields the smallest sum.\n\nSample Input 2\n\n41\n\nSample Output 2\n\n5\n\n11111=41×271 yields the smallest sum.\n\nSample Input 3\n\n79992\n\nSample Output 3\n\n36", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2562, "cpu_time_ms": 12, "memory_kb": 6400}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s290968195", "group_id": "codeNet:p03563", "input_text": "let () = Scanf.scanf \"%d %d\" (fun x y-> y*2 -x ) |> Printf.printf \"%d\\n\"\n", "language": "OCaml", "metadata": {"date": 1528321958, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03563.html", "problem_id": "p03563", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03563/input.txt", "sample_output_relpath": "derived/input_output/data/p03563/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03563/OCaml/s290968195.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s290968195", "user_id": "u498467508"}, "prompt_components": {"gold_output": "2032\n", "input_to_evaluate": "let () = Scanf.scanf \"%d %d\" (fun x y-> y*2 -x ) |> Printf.printf \"%d\\n\"\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nTakahashi is a user of a site that hosts programming contests.\n\nWhen a user competes in a contest, the rating of the user (not necessarily an integer) changes according to the performance of the user, as follows:\n\nLet the current rating of the user be a.\n\nSuppose that the performance of the user in the contest is b.\n\nThen, the new rating of the user will be the avarage of a and b.\n\nFor example, if a user with rating 1 competes in a contest and gives performance 1000, his/her new rating will be 500.5, the average of 1 and 1000.\n\nTakahashi's current rating is R, and he wants his rating to be exactly G after the next contest.\n\nFind the performance required to achieve it.\n\nConstraints\n\n0 \\leq R, G \\leq 4500\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nR\nG\n\nOutput\n\nPrint the performance required to achieve the objective.\n\nSample Input 1\n\n2002\n2017\n\nSample Output 1\n\n2032\n\nTakahashi's current rating is 2002.\n\nIf his performance in the contest is 2032, his rating will be the average of 2002 and 2032, which is equal to the desired rating, 2017.\n\nSample Input 2\n\n4500\n0\n\nSample Output 2\n\n-4500\n\nAlthough the current and desired ratings are between 0 and 4500, the performance of a user can be below 0.", "sample_input": "2002\n2017\n"}, "reference_outputs": ["2032\n"], "source_document_id": "p03563", "source_text": "Score : 100 points\n\nProblem Statement\n\nTakahashi is a user of a site that hosts programming contests.\n\nWhen a user competes in a contest, the rating of the user (not necessarily an integer) changes according to the performance of the user, as follows:\n\nLet the current rating of the user be a.\n\nSuppose that the performance of the user in the contest is b.\n\nThen, the new rating of the user will be the avarage of a and b.\n\nFor example, if a user with rating 1 competes in a contest and gives performance 1000, his/her new rating will be 500.5, the average of 1 and 1000.\n\nTakahashi's current rating is R, and he wants his rating to be exactly G after the next contest.\n\nFind the performance required to achieve it.\n\nConstraints\n\n0 \\leq R, G \\leq 4500\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nR\nG\n\nOutput\n\nPrint the performance required to achieve the objective.\n\nSample Input 1\n\n2002\n2017\n\nSample Output 1\n\n2032\n\nTakahashi's current rating is 2002.\n\nIf his performance in the contest is 2032, his rating will be the average of 2002 and 2032, which is equal to the desired rating, 2017.\n\nSample Input 2\n\n4500\n0\n\nSample Output 2\n\n-4500\n\nAlthough the current and desired ratings are between 0 and 4500, the performance of a user can be below 0.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s466782198", "group_id": "codeNet:p03564", "input_text": "let n = read_int ()\nlet k, ans = read_int (), ref 1\nlet _ = for _ = 1 to n do ans := min (!ans + k) (2 * !ans) done; Printf.printf \"%d\\n\" !ans", "language": "OCaml", "metadata": {"date": 1576065331, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03564.html", "problem_id": "p03564", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03564/input.txt", "sample_output_relpath": "derived/input_output/data/p03564/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03564/OCaml/s466782198.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s466782198", "user_id": "u732304692"}, "prompt_components": {"gold_output": "10\n", "input_to_evaluate": "let n = read_int ()\nlet k, ans = read_int (), ref 1\nlet _ = for _ = 1 to n do ans := min (!ans + k) (2 * !ans) done; Printf.printf \"%d\\n\" !ans", "problem_context": "Score : 200 points\n\nProblem Statement\n\nSquare1001 has seen an electric bulletin board displaying the integer 1.\nHe can perform the following operations A and B to change this value:\n\nOperation A: The displayed value is doubled.\n\nOperation B: The displayed value increases by K.\n\nSquare1001 needs to perform these operations N times in total.\nFind the minimum possible value displayed in the board after N operations.\n\nConstraints\n\n1 \\leq N, K \\leq 10\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nK\n\nOutput\n\nPrint the minimum possible value displayed in the board after N operations.\n\nSample Input 1\n\n4\n3\n\nSample Output 1\n\n10\n\nThe value will be minimized when the operations are performed in the following order: A, A, B, B.\n\nIn this case, the value will change as follows: 1 → 2 → 4 → 7 → 10.\n\nSample Input 2\n\n10\n10\n\nSample Output 2\n\n76\n\nThe value will be minimized when the operations are performed in the following order: A, A, A, A, B, B, B, B, B, B.\n\nIn this case, the value will change as follows: 1 → 2 → 4 → 8 → 16 → 26 → 36 → 46 → 56 → 66 → 76.\n\nBy the way, this contest is AtCoder Beginner Contest 076.", "sample_input": "4\n3\n"}, "reference_outputs": ["10\n"], "source_document_id": "p03564", "source_text": "Score : 200 points\n\nProblem Statement\n\nSquare1001 has seen an electric bulletin board displaying the integer 1.\nHe can perform the following operations A and B to change this value:\n\nOperation A: The displayed value is doubled.\n\nOperation B: The displayed value increases by K.\n\nSquare1001 needs to perform these operations N times in total.\nFind the minimum possible value displayed in the board after N operations.\n\nConstraints\n\n1 \\leq N, K \\leq 10\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nK\n\nOutput\n\nPrint the minimum possible value displayed in the board after N operations.\n\nSample Input 1\n\n4\n3\n\nSample Output 1\n\n10\n\nThe value will be minimized when the operations are performed in the following order: A, A, B, B.\n\nIn this case, the value will change as follows: 1 → 2 → 4 → 7 → 10.\n\nSample Input 2\n\n10\n10\n\nSample Output 2\n\n76\n\nThe value will be minimized when the operations are performed in the following order: A, A, A, A, B, B, B, B, B, B.\n\nIn this case, the value will change as follows: 1 → 2 → 4 → 8 → 16 → 26 → 36 → 46 → 56 → 66 → 76.\n\nBy the way, this contest is AtCoder Beginner Contest 076.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s432996601", "group_id": "codeNet:p03564", "input_text": "let n, k = Scanf.scanf \" %d %d\" @@ fun a b -> a, b\nlet rec f acc i = if i >= n then acc else min (f (2 * acc) (i + 1)) @@ f (acc + k) (i + 1)\nlet _ = Printf.printf \"%d\\n\" @@ f 1 0", "language": "OCaml", "metadata": {"date": 1564731880, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03564.html", "problem_id": "p03564", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03564/input.txt", "sample_output_relpath": "derived/input_output/data/p03564/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03564/OCaml/s432996601.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s432996601", "user_id": "u732304692"}, "prompt_components": {"gold_output": "10\n", "input_to_evaluate": "let n, k = Scanf.scanf \" %d %d\" @@ fun a b -> a, b\nlet rec f acc i = if i >= n then acc else min (f (2 * acc) (i + 1)) @@ f (acc + k) (i + 1)\nlet _ = Printf.printf \"%d\\n\" @@ f 1 0", "problem_context": "Score : 200 points\n\nProblem Statement\n\nSquare1001 has seen an electric bulletin board displaying the integer 1.\nHe can perform the following operations A and B to change this value:\n\nOperation A: The displayed value is doubled.\n\nOperation B: The displayed value increases by K.\n\nSquare1001 needs to perform these operations N times in total.\nFind the minimum possible value displayed in the board after N operations.\n\nConstraints\n\n1 \\leq N, K \\leq 10\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nK\n\nOutput\n\nPrint the minimum possible value displayed in the board after N operations.\n\nSample Input 1\n\n4\n3\n\nSample Output 1\n\n10\n\nThe value will be minimized when the operations are performed in the following order: A, A, B, B.\n\nIn this case, the value will change as follows: 1 → 2 → 4 → 7 → 10.\n\nSample Input 2\n\n10\n10\n\nSample Output 2\n\n76\n\nThe value will be minimized when the operations are performed in the following order: A, A, A, A, B, B, B, B, B, B.\n\nIn this case, the value will change as follows: 1 → 2 → 4 → 8 → 16 → 26 → 36 → 46 → 56 → 66 → 76.\n\nBy the way, this contest is AtCoder Beginner Contest 076.", "sample_input": "4\n3\n"}, "reference_outputs": ["10\n"], "source_document_id": "p03564", "source_text": "Score : 200 points\n\nProblem Statement\n\nSquare1001 has seen an electric bulletin board displaying the integer 1.\nHe can perform the following operations A and B to change this value:\n\nOperation A: The displayed value is doubled.\n\nOperation B: The displayed value increases by K.\n\nSquare1001 needs to perform these operations N times in total.\nFind the minimum possible value displayed in the board after N operations.\n\nConstraints\n\n1 \\leq N, K \\leq 10\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nK\n\nOutput\n\nPrint the minimum possible value displayed in the board after N operations.\n\nSample Input 1\n\n4\n3\n\nSample Output 1\n\n10\n\nThe value will be minimized when the operations are performed in the following order: A, A, B, B.\n\nIn this case, the value will change as follows: 1 → 2 → 4 → 7 → 10.\n\nSample Input 2\n\n10\n10\n\nSample Output 2\n\n76\n\nThe value will be minimized when the operations are performed in the following order: A, A, A, A, B, B, B, B, B, B.\n\nIn this case, the value will change as follows: 1 → 2 → 4 → 8 → 16 → 26 → 36 → 46 → 56 → 66 → 76.\n\nBy the way, this contest is AtCoder Beginner Contest 076.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s530019928", "group_id": "codeNet:p03568", "input_text": "open Printf\nopen Scanf\n\nlet () =\n let n = scanf \"%d \" (fun x -> x) in\n let rec read i =\n if i = 0 then []\n else let v = scanf \"%d \" (fun x -> x) in\n v :: read (i - 1) in\n let ls = read n in\n let rec expt3 n =\n if n = 0 then 1 else 3 * (expt3 (n - 1)) in\n expt3 n - (List.fold_left (fun a x -> if x mod 2 = 0 then a * 2 else a) 1 ls) |> printf \"%d\\n\"\n", "language": "OCaml", "metadata": {"date": 1508722470, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03568.html", "problem_id": "p03568", "resource_group": "low_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/OCaml/s530019928.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s530019928", "user_id": "u388783188"}, "prompt_components": {"gold_output": "7\n", "input_to_evaluate": "open Printf\nopen Scanf\n\nlet () =\n let n = scanf \"%d \" (fun x -> x) in\n let rec read i =\n if i = 0 then []\n else let v = scanf \"%d \" (fun x -> x) in\n v :: read (i - 1) in\n let ls = read n in\n let rec expt3 n =\n if n = 0 then 1 else 3 * (expt3 (n - 1)) in\n expt3 n - (List.fold_left (fun a x -> if x mod 2 = 0 then a * 2 else a) 1 ls) |> printf \"%d\\n\"\n", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 2432}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s172489764", "group_id": "codeNet:p03573", "input_text": "let f a b c = if a=b then c else (if a=c then b else a);;\nScanf.scanf \"%d %d %d\"\nf\n|> Printf.printf \"%d\\n\"", "language": "OCaml", "metadata": {"date": 1561095618, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03573.html", "problem_id": "p03573", "resource_group": "low_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/OCaml/s172489764.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s172489764", "user_id": "u635974378"}, "prompt_components": {"gold_output": "7\n", "input_to_evaluate": "let f a b c = if a=b then c else (if a=c then b else a);;\nScanf.scanf \"%d %d %d\"\nf\n|> Printf.printf \"%d\\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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s312675154", "group_id": "codeNet:p03573", "input_text": "open Printf\nopen Scanf\n\nlet () =\n let a, b, c = scanf \"%d %d %d \" (fun x y z -> (x, y, z)) in\n (if a = b then c else if b = c then a else b) |> printf \"%d\\n\"\n", "language": "OCaml", "metadata": {"date": 1508029638, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03573.html", "problem_id": "p03573", "resource_group": "low_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/OCaml/s312675154.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s312675154", "user_id": "u388783188"}, "prompt_components": {"gold_output": "7\n", "input_to_evaluate": "open Printf\nopen Scanf\n\nlet () =\n let a, b, c = scanf \"%d %d %d \" (fun x y z -> (x, y, z)) in\n (if a = b then c else if b = c then a else b) |> printf \"%d\\n\"\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou are given three integers, A, B and C.\n\nAmong them, two are the same, but the remaining one is different from the rest.\n\nFor example, when A=5,B=7,C=5, A and C are the same, but B is different.\n\nFind the one that is different from the rest among the given three integers.\n\nConstraints\n\n-100 \\leq A,B,C \\leq 100\n\nA, B and C are integers.\n\nThe input satisfies the condition in the statement.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C\n\nOutput\n\nAmong A, B and C, print the integer that is different from the rest.\n\nSample Input 1\n\n5 7 5\n\nSample Output 1\n\n7\n\nThis is the same case as the one in the statement.\n\nSample Input 2\n\n1 1 7\n\nSample Output 2\n\n7\n\nIn this case, C is the one we seek.\n\nSample Input 3\n\n-100 100 100\n\nSample Output 3\n\n-100", "sample_input": "5 7 5\n"}, "reference_outputs": ["7\n"], "source_document_id": "p03573", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou are given three integers, A, B and C.\n\nAmong them, two are the same, but the remaining one is different from the rest.\n\nFor example, when A=5,B=7,C=5, A and C are the same, but B is different.\n\nFind the one that is different from the rest among the given three integers.\n\nConstraints\n\n-100 \\leq A,B,C \\leq 100\n\nA, B and C are integers.\n\nThe input satisfies the condition in the statement.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C\n\nOutput\n\nAmong A, B and C, print the integer that is different from the rest.\n\nSample Input 1\n\n5 7 5\n\nSample Output 1\n\n7\n\nThis is the same case as the one in the statement.\n\nSample Input 2\n\n1 1 7\n\nSample Output 2\n\n7\n\nIn this case, C is the one we seek.\n\nSample Input 3\n\n-100 100 100\n\nSample Output 3\n\n-100", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s096473330", "group_id": "codeNet:p03576", "input_text": "(* n: int ref *)\nlet n = ref 0\n\n(* k: int ref *)\nlet k = ref 0\n\n(* pos: (int * int) list ref *)\nlet pos = ref []\n\n(* sort_x: ('a * 'a) list -> ('a * 'a) list *)\nlet sort_x lst =\n List.sort (fun (x1, _) (x2, _) -> if x1 < x2 then -1 else 1) lst\n\n(* sort_y: ('a * 'a) list -> ('a * 'a) list *)\nlet sort_y lst =\n List.sort (fun (_, y1) (_, y2) -> if y1 < y2 then -1 else 1) lst\n\n(* minimum: 'a list -> 'a *)\nlet minimum lst =\n List.fold_left min max_int lst\n\n(* soi: int -> string *)\nlet soi = string_of_int\n(* pr: int -> unit *)\nlet pr x = print_endline (soi x)\n\n(* calc_area: (int * int) list -> int *)\nlet calc_area lst = match lst with\n | [] -> 0\n | _ ->\n (* let _ = if List.length lst <> !k then failwith \"err\" in *)\n let h (x1, x2, y1, y2) (x, y) =\n (min x1 x, max x2 x, min y1 y, max y2 y)\n in\n let (x_min, x_max, y_min, y_max) =\n List.fold_left h (max_int, min_int, max_int, min_int) lst\n in\n (x_max - x_min) * (y_max - y_min)\n\n(* heads: int -> 'a list -> 'a list *)\nlet rec heads len l = match l with\n | _ when len = 0 -> []\n | [] -> raise Not_found\n | x :: xs -> x :: (heads (len - 1) xs)\n\n(* get_k_areas: ('a * 'a) list -> int list *)\nlet rec get_k_areas lst = match lst with\n | [] -> []\n | _ :: xs ->\n if List.length lst < !k then\n []\n else\n let l = heads !k lst in\n (calc_area l) :: (get_k_areas xs)\n\n(* get_areas_on_x: unit -> int list *)\nlet get_areas_on_x () =\n !pos\n |> sort_x\n |> get_k_areas\n\n(* get_areas_on_y: unit -> int list *)\nlet get_areas_on_y () =\n !pos\n |> sort_y\n |> get_k_areas\n\n(* main: unit -> int *)\nlet main () =\n let sq_lst1 = get_areas_on_x () in\n let min1 = minimum sq_lst1 in\n let sq_lst2 = get_areas_on_y () in\n let min2 = minimum sq_lst2 in\n min min1 min2\n\n(* subst: int -> int -> (int * int) list -> unit *)\nlet subst n_ k_ lst =\n n := n_;\n k := k_;\n pos := lst\n\n(* start: int -> int -> (int * int) list -> unit *)\nlet start n_ k_ lst =\n subst n_ k_ lst;\n main ()\n |> string_of_int\n |> print_endline\n\n(* test: unit -> unit *)\n(*\nlet test () =\n subst 4 4 [(1, 4); (3, 3); (6, 2); (8, 1)];\n assert (main () == 21);\n subst 4 2 [(0, 0); (1, 1); (2, 2); (3, 3)];\n assert (main () == 1);\n subst 4 3 [(-1000000000, -1000000000);\n (1000000000, 1000000000);\n (-999999999, 999999999);\n (999999999, -999999999)];\n assert (main () == 3999999996000000001)\n\nlet _ = test ()\n*)\n(* read_2int: (int -> int -> 'a) -> 'a *)\nlet rec read_2int cont =\n Scanf.sscanf (read_line ()) \"%d %d\" cont\n\nlet _ = if true then\n read_2int (fun n_ k_ ->\n let rec h cont acc =\n if List.length acc = n_ then cont acc\n else read_2int (fun a b -> h cont ((a, b) :: acc))\n in\n h (start n_ k_) [])", "language": "OCaml", "metadata": {"date": 1508379383, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03576.html", "problem_id": "p03576", "resource_group": "low_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/OCaml/s096473330.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s096473330", "user_id": "u638617188"}, "prompt_components": {"gold_output": "21\n", "input_to_evaluate": "(* n: int ref *)\nlet n = ref 0\n\n(* k: int ref *)\nlet k = ref 0\n\n(* pos: (int * int) list ref *)\nlet pos = ref []\n\n(* sort_x: ('a * 'a) list -> ('a * 'a) list *)\nlet sort_x lst =\n List.sort (fun (x1, _) (x2, _) -> if x1 < x2 then -1 else 1) lst\n\n(* sort_y: ('a * 'a) list -> ('a * 'a) list *)\nlet sort_y lst =\n List.sort (fun (_, y1) (_, y2) -> if y1 < y2 then -1 else 1) lst\n\n(* minimum: 'a list -> 'a *)\nlet minimum lst =\n List.fold_left min max_int lst\n\n(* soi: int -> string *)\nlet soi = string_of_int\n(* pr: int -> unit *)\nlet pr x = print_endline (soi x)\n\n(* calc_area: (int * int) list -> int *)\nlet calc_area lst = match lst with\n | [] -> 0\n | _ ->\n (* let _ = if List.length lst <> !k then failwith \"err\" in *)\n let h (x1, x2, y1, y2) (x, y) =\n (min x1 x, max x2 x, min y1 y, max y2 y)\n in\n let (x_min, x_max, y_min, y_max) =\n List.fold_left h (max_int, min_int, max_int, min_int) lst\n in\n (x_max - x_min) * (y_max - y_min)\n\n(* heads: int -> 'a list -> 'a list *)\nlet rec heads len l = match l with\n | _ when len = 0 -> []\n | [] -> raise Not_found\n | x :: xs -> x :: (heads (len - 1) xs)\n\n(* get_k_areas: ('a * 'a) list -> int list *)\nlet rec get_k_areas lst = match lst with\n | [] -> []\n | _ :: xs ->\n if List.length lst < !k then\n []\n else\n let l = heads !k lst in\n (calc_area l) :: (get_k_areas xs)\n\n(* get_areas_on_x: unit -> int list *)\nlet get_areas_on_x () =\n !pos\n |> sort_x\n |> get_k_areas\n\n(* get_areas_on_y: unit -> int list *)\nlet get_areas_on_y () =\n !pos\n |> sort_y\n |> get_k_areas\n\n(* main: unit -> int *)\nlet main () =\n let sq_lst1 = get_areas_on_x () in\n let min1 = minimum sq_lst1 in\n let sq_lst2 = get_areas_on_y () in\n let min2 = minimum sq_lst2 in\n min min1 min2\n\n(* subst: int -> int -> (int * int) list -> unit *)\nlet subst n_ k_ lst =\n n := n_;\n k := k_;\n pos := lst\n\n(* start: int -> int -> (int * int) list -> unit *)\nlet start n_ k_ lst =\n subst n_ k_ lst;\n main ()\n |> string_of_int\n |> print_endline\n\n(* test: unit -> unit *)\n(*\nlet test () =\n subst 4 4 [(1, 4); (3, 3); (6, 2); (8, 1)];\n assert (main () == 21);\n subst 4 2 [(0, 0); (1, 1); (2, 2); (3, 3)];\n assert (main () == 1);\n subst 4 3 [(-1000000000, -1000000000);\n (1000000000, 1000000000);\n (-999999999, 999999999);\n (999999999, -999999999)];\n assert (main () == 3999999996000000001)\n\nlet _ = test ()\n*)\n(* read_2int: (int -> int -> 'a) -> 'a *)\nlet rec read_2int cont =\n Scanf.sscanf (read_line ()) \"%d %d\" cont\n\nlet _ = if true then\n read_2int (fun n_ k_ ->\n let rec h cont acc =\n if List.length acc = n_ then cont acc\n else read_2int (fun a b -> h cont ((a, b) :: acc))\n in\n h (start n_ k_) [])", "problem_context": "Score : 400 points\n\nProblem Statement\n\nWe have N points in a two-dimensional plane.\n\nThe coordinates of the i-th point (1 \\leq i \\leq N) are (x_i,y_i).\n\nLet us consider a rectangle whose sides are parallel to the coordinate axes that contains K or more of the N points in its interior.\n\nHere, points on the sides of the rectangle are considered to be in the interior.\n\nFind the minimum possible area of such a rectangle.\n\nConstraints\n\n2 \\leq K \\leq N \\leq 50\n\n-10^9 \\leq x_i,y_i \\leq 10^9 (1 \\leq i \\leq N)\n\nx_i≠x_j (1 \\leq i\n begin\n List.concat @@ Array.to_list @@ Array.init 3500 (fun h ->\n Array.to_list @@ Array.init (3500 - h) (fun w -> (h + 1, h + w + 1))) end\n |> List.find (fun (h, w) ->\n 4 * h * w > n * w + n * h && (n * h * w) mod (4 * h * w - n * w - n * h) = 0)\n |> (fun (h, w) -> Printf.printf \"%d %d %d\\n\" h ((n * h * w) / (4 * h * w - n * w - n * h)) w))", "language": "OCaml", "metadata": {"date": 1506820478, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03583.html", "problem_id": "p03583", "resource_group": "low_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/OCaml/s643051312.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Memory Limit Exceeded", "submission_id": "s643051312", "user_id": "u504158101"}, "prompt_components": {"gold_output": "1 2 2\n", "input_to_evaluate": "let () = Scanf.scanf \"%d\" (fun n ->\n begin\n List.concat @@ Array.to_list @@ Array.init 3500 (fun h ->\n Array.to_list @@ Array.init (3500 - h) (fun w -> (h + 1, h + w + 1))) end\n |> List.find (fun (h, w) ->\n 4 * h * w > n * w + n * h && (n * h * w) mod (4 * h * w - n * w - n * h) = 0)\n |> (fun (h, w) -> Printf.printf \"%d %d %d\\n\" h ((n * h * w) / (4 * h * w - n * w - n * h)) w))", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 394, "cpu_time_ms": 1382, "memory_kb": 446644}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s742925605", "group_id": "codeNet:p03584", "input_text": "let population_count : int -> int = fun bits ->\n List.fold_left (fun bits (mask, shamt) ->\n (mask land bits) + (mask land (bits lsr shamt))) bits\n [ (0x5555555555555555, 1);\n (0x3333333333333333, 2);\n (0x0f0f0f0f0f0f0f0f, 4);\n (0x00ff00ff00ff00ff, 8);\n (0x0000ffff0000ffff, 16);\n (0x00000000ffffffff, 32) ]\n\nmodule ABSet = Set.Make (struct\n type t = int * int\n let compare (a, b) (a', b') =\n compare (population_count a, -b, a) (population_count a', -b', a')\nend)\n\nlet () =\n let n, k = Scanf.scanf \"%d %d\\n\" (fun n k -> n, k) in\n let abs = Array.init n (fun _ -> Scanf.scanf \"%d %d\\n\" (fun a b -> a, b)) in\n Array.fold_left (fun m (a, b) ->\n ABSet.fold (fun (a', b') m ->\n if (a lor a') <= k then begin\n match ABSet.split (a lor a', b + b') m with\n | _, true, _ -> m\n | minor, false, _ ->\n if ABSet.for_all (fun (a'', b'') -> a'' land lnot (a lor a') <> 0 || b'' < b + b') minor then ABSet.add (a lor a', b + b') m else m end else m) m m) (ABSet.singleton (0, 0)) abs\n |> (fun m -> ABSet.fold (fun (_, b) b' -> max b b') m 0)\n |> Printf.printf \"%d\\n\"", "language": "OCaml", "metadata": {"date": 1506824262, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03584.html", "problem_id": "p03584", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03584/input.txt", "sample_output_relpath": "derived/input_output/data/p03584/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03584/OCaml/s742925605.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s742925605", "user_id": "u504158101"}, "prompt_components": {"gold_output": "8\n", "input_to_evaluate": "let population_count : int -> int = fun bits ->\n List.fold_left (fun bits (mask, shamt) ->\n (mask land bits) + (mask land (bits lsr shamt))) bits\n [ (0x5555555555555555, 1);\n (0x3333333333333333, 2);\n (0x0f0f0f0f0f0f0f0f, 4);\n (0x00ff00ff00ff00ff, 8);\n (0x0000ffff0000ffff, 16);\n (0x00000000ffffffff, 32) ]\n\nmodule ABSet = Set.Make (struct\n type t = int * int\n let compare (a, b) (a', b') =\n compare (population_count a, -b, a) (population_count a', -b', a')\nend)\n\nlet () =\n let n, k = Scanf.scanf \"%d %d\\n\" (fun n k -> n, k) in\n let abs = Array.init n (fun _ -> Scanf.scanf \"%d %d\\n\" (fun a b -> a, b)) in\n Array.fold_left (fun m (a, b) ->\n ABSet.fold (fun (a', b') m ->\n if (a lor a') <= k then begin\n match ABSet.split (a lor a', b + b') m with\n | _, true, _ -> m\n | minor, false, _ ->\n if ABSet.for_all (fun (a'', b'') -> a'' land lnot (a lor a') <> 0 || b'' < b + b') minor then ABSet.add (a lor a', b + b') m else m end else m) m m) (ABSet.singleton (0, 0)) abs\n |> (fun m -> ABSet.fold (fun (_, b) b' -> max b b') m 0)\n |> Printf.printf \"%d\\n\"", "problem_context": "Score : 500 points\n\nProblem Statement\n\nSeisu-ya, a store specializing in non-negative integers, sells N non-negative integers. The i-th integer is A_i and has a utility of B_i.\nThere may be multiple equal integers with different utilities.\n\nTakahashi will buy some integers in this store. He can buy a combination of integers whose bitwise OR is less than or equal to K. He wants the sum of utilities of purchased integers to be as large as possible.\n\nFind the maximum possible sum of utilities of purchased integers.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n0 \\leq K < 2^{30}\n\n0 \\leq A_i < 2^{30}(1\\leq i\\leq N)\n\n1 \\leq B_i \\leq 10^9(1\\leq i\\leq N)\n\nAll input values are integers.\n\nInputs\n\nInput is given from Standard Input in the following format:\n\nN K\nA_1 B_1\n:\nA_N B_N\n\nOutputs\n\nPrint the maximum possible sum of utilities of purchased integers.\n\nSample Input 1\n\n3 5\n3 3\n4 4\n2 5\n\nSample Output 1\n\n8\n\nBuy 2 and 3 to achieve the maximum possible total utility, 8.\n\nSample Input 2\n\n3 6\n3 3\n4 4\n2 5\n\nSample Output 2\n\n9\n\nBuy 2 and 4 to achieve the maximum possible total utility, 9.\n\nSample Input 3\n\n7 14\n10 5\n7 4\n11 4\n9 8\n3 6\n6 2\n8 9\n\nSample Output 3\n\n32", "sample_input": "3 5\n3 3\n4 4\n2 5\n"}, "reference_outputs": ["8\n"], "source_document_id": "p03584", "source_text": "Score : 500 points\n\nProblem Statement\n\nSeisu-ya, a store specializing in non-negative integers, sells N non-negative integers. The i-th integer is A_i and has a utility of B_i.\nThere may be multiple equal integers with different utilities.\n\nTakahashi will buy some integers in this store. He can buy a combination of integers whose bitwise OR is less than or equal to K. He wants the sum of utilities of purchased integers to be as large as possible.\n\nFind the maximum possible sum of utilities of purchased integers.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n0 \\leq K < 2^{30}\n\n0 \\leq A_i < 2^{30}(1\\leq i\\leq N)\n\n1 \\leq B_i \\leq 10^9(1\\leq i\\leq N)\n\nAll input values are integers.\n\nInputs\n\nInput is given from Standard Input in the following format:\n\nN K\nA_1 B_1\n:\nA_N B_N\n\nOutputs\n\nPrint the maximum possible sum of utilities of purchased integers.\n\nSample Input 1\n\n3 5\n3 3\n4 4\n2 5\n\nSample Output 1\n\n8\n\nBuy 2 and 3 to achieve the maximum possible total utility, 8.\n\nSample Input 2\n\n3 6\n3 3\n4 4\n2 5\n\nSample Output 2\n\n9\n\nBuy 2 and 4 to achieve the maximum possible total utility, 9.\n\nSample Input 3\n\n7 14\n10 5\n7 4\n11 4\n9 8\n3 6\n6 2\n8 9\n\nSample Output 3\n\n32", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1132, "cpu_time_ms": 2104, "memory_kb": 9472}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s134792342", "group_id": "codeNet:p03588", "input_text": "let inf = 101010101010101010\nlet _ = Scanf.scanf \"%d\" @@ fun n ->\n let a = Array.init (n+1) (fun i ->\n if i = 0 then (0, inf) else Scanf.scanf \" %d %d\" (fun x y -> -x, y)) in\n Array.sort compare a;\n Array.fold_left (fun (s, (x',y')) (x,y) ->\n s + min (x-x') (y-y'), (x,y)) (snd a.(0), a.(0)) a\n |> fst |> Printf.printf \"%d\\n\"", "language": "OCaml", "metadata": {"date": 1534414852, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03588.html", "problem_id": "p03588", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03588/input.txt", "sample_output_relpath": "derived/input_output/data/p03588/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03588/OCaml/s134792342.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s134792342", "user_id": "u798181098"}, "prompt_components": {"gold_output": "8\n", "input_to_evaluate": "let inf = 101010101010101010\nlet _ = Scanf.scanf \"%d\" @@ fun n ->\n let a = Array.init (n+1) (fun i ->\n if i = 0 then (0, inf) else Scanf.scanf \" %d %d\" (fun x y -> -x, y)) in\n Array.sort compare a;\n Array.fold_left (fun (s, (x',y')) (x,y) ->\n s + min (x-x') (y-y'), (x,y)) (snd a.(0), a.(0)) a\n |> fst |> Printf.printf \"%d\\n\"", "problem_context": "Score : 200 points\n\nProblem Statement\n\nA group of people played a game. All players had distinct scores, which are positive integers.\n\nTakahashi knows N facts on the players' scores. The i-th fact is as follows: the A_i-th highest score among the players is B_i.\n\nFind the maximum possible number of players in the game.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq A_i \\leq 10^9(1\\leq i\\leq N)\n\n0 \\leq B_i \\leq 10^9(1\\leq i\\leq N)\n\nIf i ≠ j, A_i ≠ A_j.\n\nThere exists a possible outcome of the game that are consistent with the facts.\n\nAll input values are integers.\n\nInputs\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 B_1\n:\nA_N B_N\n\nOutputs\n\nPrint the maximum possible number of players in the game.\n\nSample Input 1\n\n3\n4 7\n2 9\n6 2\n\nSample Output 1\n\n8\n\nThe maximum possible number of players is achieved when, for example, the players have the following scores: 12,9,8,7,5,2,1,0.\n\nSample Input 2\n\n5\n1 10\n3 6\n5 2\n4 4\n2 8\n\nSample Output 2\n\n7\n\nSample Input 3\n\n2\n1 1000000000\n1000000000 1\n\nSample Output 3\n\n1000000001", "sample_input": "3\n4 7\n2 9\n6 2\n"}, "reference_outputs": ["8\n"], "source_document_id": "p03588", "source_text": "Score : 200 points\n\nProblem Statement\n\nA group of people played a game. All players had distinct scores, which are positive integers.\n\nTakahashi knows N facts on the players' scores. The i-th fact is as follows: the A_i-th highest score among the players is B_i.\n\nFind the maximum possible number of players in the game.\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq A_i \\leq 10^9(1\\leq i\\leq N)\n\n0 \\leq B_i \\leq 10^9(1\\leq i\\leq N)\n\nIf i ≠ j, A_i ≠ A_j.\n\nThere exists a possible outcome of the game that are consistent with the facts.\n\nAll input values are integers.\n\nInputs\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 B_1\n:\nA_N B_N\n\nOutputs\n\nPrint the maximum possible number of players in the game.\n\nSample Input 1\n\n3\n4 7\n2 9\n6 2\n\nSample Output 1\n\n8\n\nThe maximum possible number of players is achieved when, for example, the players have the following scores: 12,9,8,7,5,2,1,0.\n\nSample Input 2\n\n5\n1 10\n3 6\n5 2\n4 4\n2 8\n\nSample Output 2\n\n7\n\nSample Input 3\n\n2\n1 1000000000\n1000000000 1\n\nSample Output 3\n\n1000000001", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 155, "memory_kb": 6656}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s148694329", "group_id": "codeNet:p03591", "input_text": "let s = read_line ()\nlet _ = print_endline @@ if String.length s >= 4 && String.sub s 0 4 = \"YAKI\" then \"Yes\" else \"No\"", "language": "OCaml", "metadata": {"date": 1564098004, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03591.html", "problem_id": "p03591", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03591/input.txt", "sample_output_relpath": "derived/input_output/data/p03591/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03591/OCaml/s148694329.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s148694329", "user_id": "u732304692"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "let s = read_line ()\nlet _ = print_endline @@ if String.length s >= 4 && String.sub s 0 4 = \"YAKI\" then \"Yes\" else \"No\"", "problem_context": "Score : 100 points\n\nProblem Statement\n\nRingo is giving a present to Snuke.\n\nRingo has found out that Snuke loves yakiniku (a Japanese term meaning grilled meat. yaki: grilled, niku: meat). He supposes that Snuke likes grilled things starting with YAKI in Japanese, and does not like other things.\n\nYou are given a string S representing the Japanese name of Ringo's present to Snuke. Determine whether S starts with YAKI.\n\nConstraints\n\n1 \\leq |S| \\leq 10\n\nS consists of uppercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nIf S starts with YAKI, print Yes; otherwise, print No.\n\nSample Input 1\n\nYAKINIKU\n\nSample Output 1\n\nYes\n\nYAKINIKU starts with YAKI.\n\nSample Input 2\n\nTAKOYAKI\n\nSample Output 2\n\nNo\n\nTAKOYAKI (a Japanese snack. tako: octopus) does not start with YAKI.\n\nSample Input 3\n\nYAK\n\nSample Output 3\n\nNo", "sample_input": "YAKINIKU\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03591", "source_text": "Score : 100 points\n\nProblem Statement\n\nRingo is giving a present to Snuke.\n\nRingo has found out that Snuke loves yakiniku (a Japanese term meaning grilled meat. yaki: grilled, niku: meat). He supposes that Snuke likes grilled things starting with YAKI in Japanese, and does not like other things.\n\nYou are given a string S representing the Japanese name of Ringo's present to Snuke. Determine whether S starts with YAKI.\n\nConstraints\n\n1 \\leq |S| \\leq 10\n\nS consists of uppercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nS\n\nOutput\n\nIf S starts with YAKI, print Yes; otherwise, print No.\n\nSample Input 1\n\nYAKINIKU\n\nSample Output 1\n\nYes\n\nYAKINIKU starts with YAKI.\n\nSample Input 2\n\nTAKOYAKI\n\nSample Output 2\n\nNo\n\nTAKOYAKI (a Japanese snack. tako: octopus) does not start with YAKI.\n\nSample Input 3\n\nYAK\n\nSample Output 3\n\nNo", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s624747084", "group_id": "codeNet:p03592", "input_text": "Scanf.scanf \"%d %d %d\" (fun n m k ->\n let rec loop_a a =\n let rec loop_b b =\n if b > n then loop_a (a + 1) else\n if a * n + b * m - 2 * a * b = k then true else loop_b (b + 1)\n in\n if a > m then false else\n loop_b 0\n in\n print_endline @@ if loop_a 0 then \"Yes\" else \"No\"\n)", "language": "OCaml", "metadata": {"date": 1598846571, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p03592.html", "problem_id": "p03592", "resource_group": "low_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/OCaml/s624747084.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s624747084", "user_id": "u342443598"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "Scanf.scanf \"%d %d %d\" (fun n m k ->\n let rec loop_a a =\n let rec loop_b b =\n if b > n then loop_a (a + 1) else\n if a * n + b * m - 2 * a * b = k then true else loop_b (b + 1)\n in\n if a > m then false else\n loop_b 0\n in\n print_endline @@ if loop_a 0 then \"Yes\" else \"No\"\n)", "problem_context": "Score : 200 points\n\nProblem Statement\n\nWe have a grid with N rows and M columns of squares. Initially, all the squares are white.\n\nThere is a button attached to each row and each column.\nWhen a button attached to a row is pressed, the colors of all the squares in that row are inverted; that is, white squares become black and vice versa.\nWhen a button attached to a column is pressed, the colors of all the squares in that column are inverted.\n\nTakahashi can freely press the buttons any number of times. Determine whether he can have exactly K black squares in the grid.\n\nConstraints\n\n1 \\leq N,M \\leq 1000\n\n0 \\leq K \\leq NM\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M K\n\nOutput\n\nIf Takahashi can have exactly K black squares in the grid, print Yes; otherwise, print No.\n\nSample Input 1\n\n2 2 2\n\nSample Output 1\n\nYes\n\nPress the buttons in the order of the first row, the first column.\n\nSample Input 2\n\n2 2 1\n\nSample Output 2\n\nNo\n\nSample Input 3\n\n3 5 8\n\nSample Output 3\n\nYes\n\nPress the buttons in the order of the first column, third column, second row, fifth column.\n\nSample Input 4\n\n7 9 20\n\nSample Output 4\n\nNo", "sample_input": "2 2 2\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03592", "source_text": "Score : 200 points\n\nProblem Statement\n\nWe have a grid with N rows and M columns of squares. Initially, all the squares are white.\n\nThere is a button attached to each row and each column.\nWhen a button attached to a row is pressed, the colors of all the squares in that row are inverted; that is, white squares become black and vice versa.\nWhen a button attached to a column is pressed, the colors of all the squares in that column are inverted.\n\nTakahashi can freely press the buttons any number of times. Determine whether he can have exactly K black squares in the grid.\n\nConstraints\n\n1 \\leq N,M \\leq 1000\n\n0 \\leq K \\leq NM\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M K\n\nOutput\n\nIf Takahashi can have exactly K black squares in the grid, print Yes; otherwise, print No.\n\nSample Input 1\n\n2 2 2\n\nSample Output 1\n\nYes\n\nPress the buttons in the order of the first row, the first column.\n\nSample Input 2\n\n2 2 1\n\nSample Output 2\n\nNo\n\nSample Input 3\n\n3 5 8\n\nSample Output 3\n\nYes\n\nPress the buttons in the order of the first column, third column, second row, fifth column.\n\nSample Input 4\n\n7 9 20\n\nSample Output 4\n\nNo", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 339, "cpu_time_ms": 11, "memory_kb": 3752}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s494312360", "group_id": "codeNet:p03592", "input_text": "Scanf.scanf \"%d %d %d\" (fun n m k ->\n let rec loop_a a =\n let rec loop_b b =\n if b = n then loop_a (a + 1) else\n if a * n + b * m - 2 * a * b = k then true else loop_b (b + 1)\n in\n if a = m then false else\n loop_b 0\n in\n print_endline @@ if loop_a 0 then \"Yes\" else \"No\"\n)", "language": "OCaml", "metadata": {"date": 1598846010, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p03592.html", "problem_id": "p03592", "resource_group": "low_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/OCaml/s494312360.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s494312360", "user_id": "u342443598"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "Scanf.scanf \"%d %d %d\" (fun n m k ->\n let rec loop_a a =\n let rec loop_b b =\n if b = n then loop_a (a + 1) else\n if a * n + b * m - 2 * a * b = k then true else loop_b (b + 1)\n in\n if a = m then false else\n loop_b 0\n in\n print_endline @@ if loop_a 0 then \"Yes\" else \"No\"\n)", "problem_context": "Score : 200 points\n\nProblem Statement\n\nWe have a grid with N rows and M columns of squares. Initially, all the squares are white.\n\nThere is a button attached to each row and each column.\nWhen a button attached to a row is pressed, the colors of all the squares in that row are inverted; that is, white squares become black and vice versa.\nWhen a button attached to a column is pressed, the colors of all the squares in that column are inverted.\n\nTakahashi can freely press the buttons any number of times. Determine whether he can have exactly K black squares in the grid.\n\nConstraints\n\n1 \\leq N,M \\leq 1000\n\n0 \\leq K \\leq NM\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M K\n\nOutput\n\nIf Takahashi can have exactly K black squares in the grid, print Yes; otherwise, print No.\n\nSample Input 1\n\n2 2 2\n\nSample Output 1\n\nYes\n\nPress the buttons in the order of the first row, the first column.\n\nSample Input 2\n\n2 2 1\n\nSample Output 2\n\nNo\n\nSample Input 3\n\n3 5 8\n\nSample Output 3\n\nYes\n\nPress the buttons in the order of the first column, third column, second row, fifth column.\n\nSample Input 4\n\n7 9 20\n\nSample Output 4\n\nNo", "sample_input": "2 2 2\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03592", "source_text": "Score : 200 points\n\nProblem Statement\n\nWe have a grid with N rows and M columns of squares. Initially, all the squares are white.\n\nThere is a button attached to each row and each column.\nWhen a button attached to a row is pressed, the colors of all the squares in that row are inverted; that is, white squares become black and vice versa.\nWhen a button attached to a column is pressed, the colors of all the squares in that column are inverted.\n\nTakahashi can freely press the buttons any number of times. Determine whether he can have exactly K black squares in the grid.\n\nConstraints\n\n1 \\leq N,M \\leq 1000\n\n0 \\leq K \\leq NM\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M K\n\nOutput\n\nIf Takahashi can have exactly K black squares in the grid, print Yes; otherwise, print No.\n\nSample Input 1\n\n2 2 2\n\nSample Output 1\n\nYes\n\nPress the buttons in the order of the first row, the first column.\n\nSample Input 2\n\n2 2 1\n\nSample Output 2\n\nNo\n\nSample Input 3\n\n3 5 8\n\nSample Output 3\n\nYes\n\nPress the buttons in the order of the first column, third column, second row, fifth column.\n\nSample Input 4\n\n7 9 20\n\nSample Output 4\n\nNo", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 339, "cpu_time_ms": 13, "memory_kb": 3724}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s719286567", "group_id": "codeNet:p03592", "input_text": "open Printf\nopen Scanf\n\nlet () =\n let n, m, k = scanf \"%d %d %d \" (fun x y z -> (x, y, z)) in\n let rec loop i j =\n if i > n then \"No\"\n else if j > m then loop (i+1) 0\n else if m * i + n * j - 2 * i * j = k then \"Yes\"\n else loop i (j+1) in\n loop 0 0 |> printf \"%s\\n\"\n", "language": "OCaml", "metadata": {"date": 1506216650, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03592.html", "problem_id": "p03592", "resource_group": "low_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/OCaml/s719286567.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s719286567", "user_id": "u388783188"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "open Printf\nopen Scanf\n\nlet () =\n let n, m, k = scanf \"%d %d %d \" (fun x y z -> (x, y, z)) in\n let rec loop i j =\n if i > n then \"No\"\n else if j > m then loop (i+1) 0\n else if m * i + n * j - 2 * i * j = k then \"Yes\"\n else loop i (j+1) in\n loop 0 0 |> printf \"%s\\n\"\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nWe have a grid with N rows and M columns of squares. Initially, all the squares are white.\n\nThere is a button attached to each row and each column.\nWhen a button attached to a row is pressed, the colors of all the squares in that row are inverted; that is, white squares become black and vice versa.\nWhen a button attached to a column is pressed, the colors of all the squares in that column are inverted.\n\nTakahashi can freely press the buttons any number of times. Determine whether he can have exactly K black squares in the grid.\n\nConstraints\n\n1 \\leq N,M \\leq 1000\n\n0 \\leq K \\leq NM\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M K\n\nOutput\n\nIf Takahashi can have exactly K black squares in the grid, print Yes; otherwise, print No.\n\nSample Input 1\n\n2 2 2\n\nSample Output 1\n\nYes\n\nPress the buttons in the order of the first row, the first column.\n\nSample Input 2\n\n2 2 1\n\nSample Output 2\n\nNo\n\nSample Input 3\n\n3 5 8\n\nSample Output 3\n\nYes\n\nPress the buttons in the order of the first column, third column, second row, fifth column.\n\nSample Input 4\n\n7 9 20\n\nSample Output 4\n\nNo", "sample_input": "2 2 2\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03592", "source_text": "Score : 200 points\n\nProblem Statement\n\nWe have a grid with N rows and M columns of squares. Initially, all the squares are white.\n\nThere is a button attached to each row and each column.\nWhen a button attached to a row is pressed, the colors of all the squares in that row are inverted; that is, white squares become black and vice versa.\nWhen a button attached to a column is pressed, the colors of all the squares in that column are inverted.\n\nTakahashi can freely press the buttons any number of times. Determine whether he can have exactly K black squares in the grid.\n\nConstraints\n\n1 \\leq N,M \\leq 1000\n\n0 \\leq K \\leq NM\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M K\n\nOutput\n\nIf Takahashi can have exactly K black squares in the grid, print Yes; otherwise, print No.\n\nSample Input 1\n\n2 2 2\n\nSample Output 1\n\nYes\n\nPress the buttons in the order of the first row, the first column.\n\nSample Input 2\n\n2 2 1\n\nSample Output 2\n\nNo\n\nSample Input 3\n\n3 5 8\n\nSample Output 3\n\nYes\n\nPress the buttons in the order of the first column, third column, second row, fifth column.\n\nSample Input 4\n\n7 9 20\n\nSample Output 4\n\nNo", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 281, "cpu_time_ms": 3, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s509655248", "group_id": "codeNet:p03597", "input_text": "let () = Scanf.scanf \"%d\\n%d\" (fun n a -> n * n - a) |> Printf.printf \"%d\\n\"", "language": "OCaml", "metadata": {"date": 1524188292, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03597.html", "problem_id": "p03597", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03597/input.txt", "sample_output_relpath": "derived/input_output/data/p03597/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03597/OCaml/s509655248.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s509655248", "user_id": "u987869509"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "let () = Scanf.scanf \"%d\\n%d\" (fun n a -> n * n - a) |> Printf.printf \"%d\\n\"", "problem_context": "Score : 100 points\n\nProblem Statement\n\nWe have an N \\times N square grid.\n\nWe will paint each square in the grid either black or white.\n\nIf we paint exactly A squares white, how many squares will be painted black?\n\nConstraints\n\n1 \\leq N \\leq 100\n\n0 \\leq A \\leq N^2\n\nInputs\n\nInput is given from Standard Input in the following format:\n\nN\nA\n\nOutputs\n\nPrint the number of squares that will be painted black.\n\nSample Input 1\n\n3\n4\n\nSample Output 1\n\n5\n\nThere are nine squares in a 3 \\times 3 square grid.\nFour of them will be painted white, so the remaining five squares will be painted black.\n\nSample Input 2\n\n19\n100\n\nSample Output 2\n\n261\n\nSample Input 3\n\n10\n0\n\nSample Output 3\n\n100\n\nAs zero squares will be painted white, all the squares will be painted black.", "sample_input": "3\n4\n"}, "reference_outputs": ["5\n"], "source_document_id": "p03597", "source_text": "Score : 100 points\n\nProblem Statement\n\nWe have an N \\times N square grid.\n\nWe will paint each square in the grid either black or white.\n\nIf we paint exactly A squares white, how many squares will be painted black?\n\nConstraints\n\n1 \\leq N \\leq 100\n\n0 \\leq A \\leq N^2\n\nInputs\n\nInput is given from Standard Input in the following format:\n\nN\nA\n\nOutputs\n\nPrint the number of squares that will be painted black.\n\nSample Input 1\n\n3\n4\n\nSample Output 1\n\n5\n\nThere are nine squares in a 3 \\times 3 square grid.\nFour of them will be painted white, so the remaining five squares will be painted black.\n\nSample Input 2\n\n19\n100\n\nSample Output 2\n\n261\n\nSample Input 3\n\n10\n0\n\nSample Output 3\n\n100\n\nAs zero squares will be painted white, all the squares will be painted black.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s740070898", "group_id": "codeNet:p03598", "input_text": "let id x = x\nlet n = Scanf.scanf \"%d\\n\" id\nlet k = Scanf.scanf \"%d\\n\" id\n\nlet slv k xs =\n List.map (fun x -> min x (abs (x-k))) xs\n |> (List.fold_left (+) 0)\n |> ( * ) 2\n\nlet rec inp n = match n with\n | 0 -> []\n | _ -> Scanf.scanf \"%d \" id :: (inp (n-1))\n\nlet () =\n slv k (inp n) |> Printf.printf \"%d\"", "language": "OCaml", "metadata": {"date": 1507759791, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03598.html", "problem_id": "p03598", "resource_group": "low_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/OCaml/s740070898.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s740070898", "user_id": "u604818425"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "let id x = x\nlet n = Scanf.scanf \"%d\\n\" id\nlet k = Scanf.scanf \"%d\\n\" id\n\nlet slv k xs =\n List.map (fun x -> min x (abs (x-k))) xs\n |> (List.fold_left (+) 0)\n |> ( * ) 2\n\nlet rec inp n = match n with\n | 0 -> []\n | _ -> Scanf.scanf \"%d \" id :: (inp (n-1))\n\nlet () =\n slv k (inp n) |> Printf.printf \"%d\"", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s469273426", "group_id": "codeNet:p03599", "input_text": "let a, b, c, d, e, f = Scanf.scanf \" %d %d %d %d %d %d\" @@ fun a b c d e f -> a, b, c, d, e, f\nlet ws = Array.make (f + 1) false\nlet ss = Array.make (f + 1) false\nlet (<@) (w, s) (w2, s2) = (w2 + s2) * s < (w + s) * s2\nlet ans = ref (f, 0)\nlet _ =\n for i = 0 to f / 100 do\n for j = 0 to f / 100 do let w = 100 * i * a + 100 * j * b in if w <= f then ws.(w) <- true done done;\n for i = 0 to f do\n for j = 0 to f do if i * c + j * d <= f then ss.(i * c + j * d) <- true done done;\n for i = 0 to f do\n for j = 0 to f do if ws.(i) && ss.(j) && i + j <= f && 100 * j <= i * e then (ans := if !ans <@ (i, j) then i, j else !ans) done done;\n let w, s = !ans in Printf.printf \"%d %d\\n\" (w + s) @@ s", "language": "OCaml", "metadata": {"date": 1562860977, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03599.html", "problem_id": "p03599", "resource_group": "low_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/OCaml/s469273426.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s469273426", "user_id": "u732304692"}, "prompt_components": {"gold_output": "110 10\n", "input_to_evaluate": "let a, b, c, d, e, f = Scanf.scanf \" %d %d %d %d %d %d\" @@ fun a b c d e f -> a, b, c, d, e, f\nlet ws = Array.make (f + 1) false\nlet ss = Array.make (f + 1) false\nlet (<@) (w, s) (w2, s2) = (w2 + s2) * s < (w + s) * s2\nlet ans = ref (f, 0)\nlet _ =\n for i = 0 to f / 100 do\n for j = 0 to f / 100 do let w = 100 * i * a + 100 * j * b in if w <= f then ws.(w) <- true done done;\n for i = 0 to f do\n for j = 0 to f do if i * c + j * d <= f then ss.(i * c + j * d) <- true done done;\n for i = 0 to f do\n for j = 0 to f do if ws.(i) && ss.(j) && i + j <= f && 100 * j <= i * e then (ans := if !ans <@ (i, j) then i, j else !ans) done done;\n let w, s = !ans in Printf.printf \"%d %d\\n\" (w + s) @@ s", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 703, "cpu_time_ms": 31, "memory_kb": 640}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s020999447", "group_id": "codeNet:p03599", "input_text": "let kFMax = 3000 in\nlet kWMax = 30 in\nScanf.scanf \" %d %d %d %d %d %d\" @@ fun a b c d e f ->\n let ans = ref (0., 0, 0) in\n let water = Array.make (kWMax + 1) false in\n for i = 0 to kWMax do\n for j = 0 to kWMax do\n let w = a * i + b * j in\n if w <= kWMax then water.(w) <- true\n done\n done;\n let sugar = Array.make (kFMax + 1) false in\n for i = 0 to kFMax do\n for j = 0 to kFMax do\n let s = c * i + d * j in\n if s <= kFMax then sugar.(s) <- true\n done\n done;\n for w = 1 to kWMax do\n if water.(w) then\n for s = 0 to kFMax do\n if sugar.(s) then\n let w_s = w * 100 + s in\n if w_s <= f && w * e >= s then\n let c = 100. *. float s /. (float w +. float s) in\n ans := max !ans (c, w_s, s)\n done\n done;\n let _, w_s, s = !ans in\n Printf.printf \"%d %d\\n\" w_s s", "language": "OCaml", "metadata": {"date": 1559811152, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03599.html", "problem_id": "p03599", "resource_group": "low_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/OCaml/s020999447.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s020999447", "user_id": "u732304692"}, "prompt_components": {"gold_output": "110 10\n", "input_to_evaluate": "let kFMax = 3000 in\nlet kWMax = 30 in\nScanf.scanf \" %d %d %d %d %d %d\" @@ fun a b c d e f ->\n let ans = ref (0., 0, 0) in\n let water = Array.make (kWMax + 1) false in\n for i = 0 to kWMax do\n for j = 0 to kWMax do\n let w = a * i + b * j in\n if w <= kWMax then water.(w) <- true\n done\n done;\n let sugar = Array.make (kFMax + 1) false in\n for i = 0 to kFMax do\n for j = 0 to kFMax do\n let s = c * i + d * j in\n if s <= kFMax then sugar.(s) <- true\n done\n done;\n for w = 1 to kWMax do\n if water.(w) then\n for s = 0 to kFMax do\n if sugar.(s) then\n let w_s = w * 100 + s in\n if w_s <= f && w * e >= s then\n let c = 100. *. float s /. (float w +. float s) in\n ans := max !ans (c, w_s, s)\n done\n done;\n let _, w_s, s = !ans in\n Printf.printf \"%d %d\\n\" w_s s", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 852, "cpu_time_ms": 15, "memory_kb": 768}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s759024971", "group_id": "codeNet:p03600", "input_text": "\nopen Scanf\nopen Printf\n\nlet flip f x y = f y x\n\nlet range a b =\n let rec f acc a b = if a > b then acc else f (b::acc) a (b-1) in\n f [] a (b-1)\n\nlet read_int () = scanf \" %d\" (fun x -> x)\nlet rec read_ints n = Array.init n (fun _ -> read_int ())\n\nlet rec for_iter a b f = if a >= b then [] else let x = f a in x :: for_iter (a+1) b f\nlet rec for_iter_ a b f = if a >= b then () else (f a; for_iter_ (a+1) b f)\nlet rec for_all_iter a b f = if a >= b then true else f a && for_all_iter (a+1) b f\n\nlet inf = 20202020202020\n\nlet () =\n let n = read_int () in\n let mtx = Array.init n (fun _ -> read_ints n) in\n\n let mtx' = Array.init n (fun i -> Array.copy mtx.(i)) in\n for_iter_ 0 n (fun k -> for_iter_ 0 n (fun i -> for_iter_ 0 n (fun j ->\n mtx'.(i).(j) <- min mtx'.(i).(j) (mtx'.(i).(k) + mtx'.(k).(j)))));\n\n let valid = for_all_iter 0 n (fun i ->\n for_all_iter 0 n (fun j ->\n mtx.(i).(j) = mtx'.(i).(j))) in\n if not valid then (print_endline \"-1\"; exit 0);\n\n let edges =\n let rec f a b =\n if a >= n then []\n else if b >= n then f (a+1) (a+2)\n else (a, b, mtx.(a).(b)) :: f a (b+1) in\n List.sort (fun (_,_,w0) (_,_,w1) -> w0-w1) @@ f 0 1 in\n\n for_iter_ 0 n (fun j -> for_iter_ 0 n (fun k -> mtx'.(j).(k) <- inf); mtx'.(j).(j) <- 0);\n List.map (fun (u, v, w) ->\n if mtx'.(u).(v) <= mtx.(u).(v) then 0\n else (\n mtx'.(u).(v) <- w; mtx'.(v).(u) <- w;\n for_iter_ 0 n (fun j -> for_iter_ 0 n (fun k ->\n mtx'.(j).(k) <- min mtx'.(j).(k) (mtx'.(j).(u) + w + mtx'.(v).(k));\n mtx'.(j).(k) <- min mtx'.(j).(k) (mtx'.(j).(v) + w + mtx'.(u).(k))));\n w)) edges\n |> List.fold_left (+) 0\n |> printf \"%d\\n\"\n", "language": "OCaml", "metadata": {"date": 1519606982, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03600.html", "problem_id": "p03600", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03600/input.txt", "sample_output_relpath": "derived/input_output/data/p03600/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03600/OCaml/s759024971.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s759024971", "user_id": "u798181098"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "\nopen Scanf\nopen Printf\n\nlet flip f x y = f y x\n\nlet range a b =\n let rec f acc a b = if a > b then acc else f (b::acc) a (b-1) in\n f [] a (b-1)\n\nlet read_int () = scanf \" %d\" (fun x -> x)\nlet rec read_ints n = Array.init n (fun _ -> read_int ())\n\nlet rec for_iter a b f = if a >= b then [] else let x = f a in x :: for_iter (a+1) b f\nlet rec for_iter_ a b f = if a >= b then () else (f a; for_iter_ (a+1) b f)\nlet rec for_all_iter a b f = if a >= b then true else f a && for_all_iter (a+1) b f\n\nlet inf = 20202020202020\n\nlet () =\n let n = read_int () in\n let mtx = Array.init n (fun _ -> read_ints n) in\n\n let mtx' = Array.init n (fun i -> Array.copy mtx.(i)) in\n for_iter_ 0 n (fun k -> for_iter_ 0 n (fun i -> for_iter_ 0 n (fun j ->\n mtx'.(i).(j) <- min mtx'.(i).(j) (mtx'.(i).(k) + mtx'.(k).(j)))));\n\n let valid = for_all_iter 0 n (fun i ->\n for_all_iter 0 n (fun j ->\n mtx.(i).(j) = mtx'.(i).(j))) in\n if not valid then (print_endline \"-1\"; exit 0);\n\n let edges =\n let rec f a b =\n if a >= n then []\n else if b >= n then f (a+1) (a+2)\n else (a, b, mtx.(a).(b)) :: f a (b+1) in\n List.sort (fun (_,_,w0) (_,_,w1) -> w0-w1) @@ f 0 1 in\n\n for_iter_ 0 n (fun j -> for_iter_ 0 n (fun k -> mtx'.(j).(k) <- inf); mtx'.(j).(j) <- 0);\n List.map (fun (u, v, w) ->\n if mtx'.(u).(v) <= mtx.(u).(v) then 0\n else (\n mtx'.(u).(v) <- w; mtx'.(v).(u) <- w;\n for_iter_ 0 n (fun j -> for_iter_ 0 n (fun k ->\n mtx'.(j).(k) <- min mtx'.(j).(k) (mtx'.(j).(u) + w + mtx'.(v).(k));\n mtx'.(j).(k) <- min mtx'.(j).(k) (mtx'.(j).(v) + w + mtx'.(u).(k))));\n w)) edges\n |> List.fold_left (+) 0\n |> printf \"%d\\n\"\n", "problem_context": "Score : 500 points\n\nProblem Statement\n\nIn Takahashi Kingdom, which once existed, there are N cities, and some pairs of cities are connected bidirectionally by roads.\nThe following are known about the road network:\n\nPeople traveled between cities only through roads. It was possible to reach any city from any other city, via intermediate cities if necessary.\n\nDifferent roads may have had different lengths, but all the lengths were positive integers.\n\nSnuke the archeologist found a table with N rows and N columns, A, in the ruin of Takahashi Kingdom.\nHe thought that it represented the shortest distances between the cities along the roads in the kingdom.\n\nDetermine whether there exists a road network such that for each u and v, the integer A_{u, v} at the u-th row and v-th column of A is equal to the length of the shortest path from City u to City v.\nIf such a network exist, find the shortest possible total length of the roads.\n\nConstraints\n\n1 \\leq N \\leq 300\n\nIf i ≠ j, 1 \\leq A_{i, j} = A_{j, i} \\leq 10^9.\n\nA_{i, i} = 0\n\nInputs\n\nInput is given from Standard Input in the following format:\n\nN\nA_{1, 1} A_{1, 2} ... A_{1, N}\nA_{2, 1} A_{2, 2} ... A_{2, N}\n...\nA_{N, 1} A_{N, 2} ... A_{N, N}\n\nOutputs\n\nIf there exists no network that satisfies the condition, print -1.\nIf it exists, print the shortest possible total length of the roads.\n\nSample Input 1\n\n3\n0 1 3\n1 0 2\n3 2 0\n\nSample Output 1\n\n3\n\nThe network below satisfies the condition:\n\nCity 1 and City 2 is connected by a road of length 1.\n\nCity 2 and City 3 is connected by a road of length 2.\n\nCity 3 and City 1 is not connected by a road.\n\nSample Input 2\n\n3\n0 1 3\n1 0 1\n3 1 0\n\nSample Output 2\n\n-1\n\nAs there is a path of length 1 from City 1 to City 2 and City 2 to City 3, there is a path of length 2 from City 1 to City 3.\nHowever, according to the table, the shortest distance between City 1 and City 3 must be 3.\n\nThus, we conclude that there exists no network that satisfies the condition.\n\nSample Input 3\n\n5\n0 21 18 11 28\n21 0 13 10 26\n18 13 0 23 13\n11 10 23 0 17\n28 26 13 17 0\n\nSample Output 3\n\n82\n\nSample Input 4\n\n3\n0 1000000000 1000000000\n1000000000 0 1000000000\n1000000000 1000000000 0\n\nSample Output 4\n\n3000000000", "sample_input": "3\n0 1 3\n1 0 2\n3 2 0\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03600", "source_text": "Score : 500 points\n\nProblem Statement\n\nIn Takahashi Kingdom, which once existed, there are N cities, and some pairs of cities are connected bidirectionally by roads.\nThe following are known about the road network:\n\nPeople traveled between cities only through roads. It was possible to reach any city from any other city, via intermediate cities if necessary.\n\nDifferent roads may have had different lengths, but all the lengths were positive integers.\n\nSnuke the archeologist found a table with N rows and N columns, A, in the ruin of Takahashi Kingdom.\nHe thought that it represented the shortest distances between the cities along the roads in the kingdom.\n\nDetermine whether there exists a road network such that for each u and v, the integer A_{u, v} at the u-th row and v-th column of A is equal to the length of the shortest path from City u to City v.\nIf such a network exist, find the shortest possible total length of the roads.\n\nConstraints\n\n1 \\leq N \\leq 300\n\nIf i ≠ j, 1 \\leq A_{i, j} = A_{j, i} \\leq 10^9.\n\nA_{i, i} = 0\n\nInputs\n\nInput is given from Standard Input in the following format:\n\nN\nA_{1, 1} A_{1, 2} ... A_{1, N}\nA_{2, 1} A_{2, 2} ... A_{2, N}\n...\nA_{N, 1} A_{N, 2} ... A_{N, N}\n\nOutputs\n\nIf there exists no network that satisfies the condition, print -1.\nIf it exists, print the shortest possible total length of the roads.\n\nSample Input 1\n\n3\n0 1 3\n1 0 2\n3 2 0\n\nSample Output 1\n\n3\n\nThe network below satisfies the condition:\n\nCity 1 and City 2 is connected by a road of length 1.\n\nCity 2 and City 3 is connected by a road of length 2.\n\nCity 3 and City 1 is not connected by a road.\n\nSample Input 2\n\n3\n0 1 3\n1 0 1\n3 1 0\n\nSample Output 2\n\n-1\n\nAs there is a path of length 1 from City 1 to City 2 and City 2 to City 3, there is a path of length 2 from City 1 to City 3.\nHowever, according to the table, the shortest distance between City 1 and City 3 must be 3.\n\nThus, we conclude that there exists no network that satisfies the condition.\n\nSample Input 3\n\n5\n0 21 18 11 28\n21 0 13 10 26\n18 13 0 23 13\n11 10 23 0 17\n28 26 13 17 0\n\nSample Output 3\n\n82\n\nSample Input 4\n\n3\n0 1000000000 1000000000\n1000000000 0 1000000000\n1000000000 1000000000 0\n\nSample Output 4\n\n3000000000", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1668, "cpu_time_ms": 2104, "memory_kb": 12672}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s798252218", "group_id": "codeNet:p03603", "input_text": "module IntMap = Map.Make (struct\n type t = int\n let compare = compare\nend)\n\nlet () = Scanf.scanf \"%d\\n\" @@ fun n ->\n let es = Array.make n [] in\n let xs =\n if n = 1 then\n Scanf.scanf \"\\n%d\\n\" @@ Array.make 1\n else begin\n for i = 1 to n - 1 do\n Scanf.scanf \"%d \" @@ fun p ->\n es.(p - 1) <- i :: es.(p - 1)\n done;\n Array.init n @@ fun _ -> Scanf.scanf \"%d \" @@ fun x -> x\n end in\n let rec solve v =\n let xys = List.map (fun u -> xs.(u), solve u) es.(v) in\n let most = List.fold_right (fun (x, y) -> ( + ) @@ max x y) xys 0 in\n let least = List.fold_right (fun (x, y) -> ( + ) @@ min x y) xys 0 in\n if xs.(v) < least then raise Not_found\n else IntMap.fold (fun _ -> min)\n (List.fold_left (fun m (w, v_) ->\n let le, _, _ = IntMap.split (xs.(v) - least - w + 1) m in\n IntMap.fold (fun w' v' m ->\n IntMap.add (w + w')\n (max (v_ + v') @@\n try IntMap.find (w + w') m\n with Not_found -> min_int) m) le m) (IntMap.singleton 0 most) @@\n List.map (fun (x, y) -> abs (x - y), ~- (abs (x - y))) xys) max_int in\n print_endline @@\n try ignore (solve 0); \"POSSIBLE\"\n with Not_found -> \"IMPOSSIBLE\"\n\n", "language": "OCaml", "metadata": {"date": 1536362366, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03603.html", "problem_id": "p03603", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03603/input.txt", "sample_output_relpath": "derived/input_output/data/p03603/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03603/OCaml/s798252218.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s798252218", "user_id": "u504158101"}, "prompt_components": {"gold_output": "POSSIBLE\n", "input_to_evaluate": "module IntMap = Map.Make (struct\n type t = int\n let compare = compare\nend)\n\nlet () = Scanf.scanf \"%d\\n\" @@ fun n ->\n let es = Array.make n [] in\n let xs =\n if n = 1 then\n Scanf.scanf \"\\n%d\\n\" @@ Array.make 1\n else begin\n for i = 1 to n - 1 do\n Scanf.scanf \"%d \" @@ fun p ->\n es.(p - 1) <- i :: es.(p - 1)\n done;\n Array.init n @@ fun _ -> Scanf.scanf \"%d \" @@ fun x -> x\n end in\n let rec solve v =\n let xys = List.map (fun u -> xs.(u), solve u) es.(v) in\n let most = List.fold_right (fun (x, y) -> ( + ) @@ max x y) xys 0 in\n let least = List.fold_right (fun (x, y) -> ( + ) @@ min x y) xys 0 in\n if xs.(v) < least then raise Not_found\n else IntMap.fold (fun _ -> min)\n (List.fold_left (fun m (w, v_) ->\n let le, _, _ = IntMap.split (xs.(v) - least - w + 1) m in\n IntMap.fold (fun w' v' m ->\n IntMap.add (w + w')\n (max (v_ + v') @@\n try IntMap.find (w + w') m\n with Not_found -> min_int) m) le m) (IntMap.singleton 0 most) @@\n List.map (fun (x, y) -> abs (x - y), ~- (abs (x - y))) xys) max_int in\n print_endline @@\n try ignore (solve 0); \"POSSIBLE\"\n with Not_found -> \"IMPOSSIBLE\"\n\n", "problem_context": "Score : 700 points\n\nProblem Statement\n\nWe have a tree with N vertices. Vertex 1 is the root of the tree, and the parent of Vertex i (2 \\leq i \\leq N) is Vertex P_i.\n\nTo each vertex in the tree, Snuke will allocate a color, either black or white, and a non-negative integer weight.\n\nSnuke has a favorite integer sequence, X_1, X_2, ..., X_N, so he wants to allocate colors and weights so that the following condition is satisfied for all v.\n\nThe total weight of the vertices with the same color as v among the vertices contained in the subtree whose root is v, is X_v.\n\nHere, the subtree whose root is v is the tree consisting of Vertex v and all of its descendants.\n\nDetermine whether it is possible to allocate colors and weights in this way.\n\nConstraints\n\n1 \\leq N \\leq 1 000\n\n1 \\leq P_i \\leq i - 1\n\n0 \\leq X_i \\leq 5 000\n\nInputs\n\nInput is given from Standard Input in the following format:\n\nN\nP_2 P_3 ... P_N\nX_1 X_2 ... X_N\n\nOutputs\n\nIf it is possible to allocate colors and weights to the vertices so that the condition is satisfied, print POSSIBLE; otherwise, print IMPOSSIBLE.\n\nSample Input 1\n\n3\n1 1\n4 3 2\n\nSample Output 1\n\nPOSSIBLE\n\nFor example, the following allocation satisfies the condition:\n\nSet the color of Vertex 1 to white and its weight to 2.\n\nSet the color of Vertex 2 to black and its weight to 3.\n\nSet the color of Vertex 3 to white and its weight to 2.\n\nThere are also other possible allocations.\n\nSample Input 2\n\n3\n1 2\n1 2 3\n\nSample Output 2\n\nIMPOSSIBLE\n\nIf the same color is allocated to Vertex 2 and Vertex 3, Vertex 2 cannot be allocated a non-negative weight.\n\nIf different colors are allocated to Vertex 2 and 3, no matter which color is allocated to Vertex 1, it cannot be allocated a non-negative weight.\n\nThus, there exists no allocation of colors and weights that satisfies the condition.\n\nSample Input 3\n\n8\n1 1 1 3 4 5 5\n4 1 6 2 2 1 3 3\n\nSample Output 3\n\nPOSSIBLE\n\nSample Input 4\n\n1\n\n0\n\nSample Output 4\n\nPOSSIBLE", "sample_input": "3\n1 1\n4 3 2\n"}, "reference_outputs": ["POSSIBLE\n"], "source_document_id": "p03603", "source_text": "Score : 700 points\n\nProblem Statement\n\nWe have a tree with N vertices. Vertex 1 is the root of the tree, and the parent of Vertex i (2 \\leq i \\leq N) is Vertex P_i.\n\nTo each vertex in the tree, Snuke will allocate a color, either black or white, and a non-negative integer weight.\n\nSnuke has a favorite integer sequence, X_1, X_2, ..., X_N, so he wants to allocate colors and weights so that the following condition is satisfied for all v.\n\nThe total weight of the vertices with the same color as v among the vertices contained in the subtree whose root is v, is X_v.\n\nHere, the subtree whose root is v is the tree consisting of Vertex v and all of its descendants.\n\nDetermine whether it is possible to allocate colors and weights in this way.\n\nConstraints\n\n1 \\leq N \\leq 1 000\n\n1 \\leq P_i \\leq i - 1\n\n0 \\leq X_i \\leq 5 000\n\nInputs\n\nInput is given from Standard Input in the following format:\n\nN\nP_2 P_3 ... P_N\nX_1 X_2 ... X_N\n\nOutputs\n\nIf it is possible to allocate colors and weights to the vertices so that the condition is satisfied, print POSSIBLE; otherwise, print IMPOSSIBLE.\n\nSample Input 1\n\n3\n1 1\n4 3 2\n\nSample Output 1\n\nPOSSIBLE\n\nFor example, the following allocation satisfies the condition:\n\nSet the color of Vertex 1 to white and its weight to 2.\n\nSet the color of Vertex 2 to black and its weight to 3.\n\nSet the color of Vertex 3 to white and its weight to 2.\n\nThere are also other possible allocations.\n\nSample Input 2\n\n3\n1 2\n1 2 3\n\nSample Output 2\n\nIMPOSSIBLE\n\nIf the same color is allocated to Vertex 2 and Vertex 3, Vertex 2 cannot be allocated a non-negative weight.\n\nIf different colors are allocated to Vertex 2 and 3, no matter which color is allocated to Vertex 1, it cannot be allocated a non-negative weight.\n\nThus, there exists no allocation of colors and weights that satisfies the condition.\n\nSample Input 3\n\n8\n1 1 1 3 4 5 5\n4 1 6 2 2 1 3 3\n\nSample Output 3\n\nPOSSIBLE\n\nSample Input 4\n\n1\n\n0\n\nSample Output 4\n\nPOSSIBLE", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1222, "cpu_time_ms": 42, "memory_kb": 4992}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s276700677", "group_id": "codeNet:p03605", "input_text": "let id x = x\nlet c1 = Scanf.scanf \"%c\" id\nlet c2 = Scanf.scanf \"%c\\n\" id\n \nlet ans = if c1='9'||c2='9' then \"Yes\" else \"No\"\n \nlet () =\n Printf.printf \"%s\\n\" ans", "language": "OCaml", "metadata": {"date": 1505005457, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03605.html", "problem_id": "p03605", "resource_group": "low_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/OCaml/s276700677.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s276700677", "user_id": "u735499035"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "let id x = x\nlet c1 = Scanf.scanf \"%c\" id\nlet c2 = Scanf.scanf \"%c\\n\" id\n \nlet ans = if c1='9'||c2='9' then \"Yes\" else \"No\"\n \nlet () =\n Printf.printf \"%s\\n\" ans", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s855863387", "group_id": "codeNet:p03607", "input_text": "(* O(n) *)\nopen Hashtbl\nlet n = Scanf.scanf \" %d\" @@ (+) 0\nlet a_s = Array.init n @@ fun _ -> Scanf.scanf \" %d\" @@ (+) 0\nlet h = create n\nlet _ =\n Array.iter (fun a -> try let c = find h a in replace h a @@ c + 1 with _ -> add h a 1) a_s;\n fold (fun _ c acc -> acc + if c mod 2 = 0 then 0 else 1) h 0 |> Printf.printf \"%d\\n\"", "language": "OCaml", "metadata": {"date": 1560969829, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03607.html", "problem_id": "p03607", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03607/input.txt", "sample_output_relpath": "derived/input_output/data/p03607/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03607/OCaml/s855863387.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s855863387", "user_id": "u732304692"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "(* O(n) *)\nopen Hashtbl\nlet n = Scanf.scanf \" %d\" @@ (+) 0\nlet a_s = Array.init n @@ fun _ -> Scanf.scanf \" %d\" @@ (+) 0\nlet h = create n\nlet _ =\n Array.iter (fun a -> try let c = find h a in replace h a @@ c + 1 with _ -> add h a 1) a_s;\n fold (fun _ c acc -> acc + if c mod 2 = 0 then 0 else 1) h 0 |> Printf.printf \"%d\\n\"", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou are playing the following game with Joisino.\n\nInitially, you have a blank sheet of paper.\n\nJoisino announces a number. If that number is written on the sheet, erase the number from the sheet; if not, write the number on the sheet. This process is repeated N times.\n\nThen, you are asked a question: How many numbers are written on the sheet now?\n\nThe numbers announced by Joisino are given as A_1, ... ,A_N in the order she announces them. How many numbers will be written on the sheet at the end of the game?\n\nConstraints\n\n1≤N≤100000\n\n1≤A_i≤1000000000(=10^9)\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1\n:\nA_N\n\nOutput\n\nPrint how many numbers will be written on the sheet at the end of the game.\n\nSample Input 1\n\n3\n6\n2\n6\n\nSample Output 1\n\n1\n\nThe game proceeds as follows:\n\n6 is not written on the sheet, so write 6.\n\n2 is not written on the sheet, so write 2.\n\n6 is written on the sheet, so erase 6.\n\nThus, the sheet contains only 2 in the end. The answer is 1.\n\nSample Input 2\n\n4\n2\n5\n5\n2\n\nSample Output 2\n\n0\n\nIt is possible that no number is written on the sheet in the end.\n\nSample Input 3\n\n6\n12\n22\n16\n22\n18\n12\n\nSample Output 3\n\n2", "sample_input": "3\n6\n2\n6\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03607", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou are playing the following game with Joisino.\n\nInitially, you have a blank sheet of paper.\n\nJoisino announces a number. If that number is written on the sheet, erase the number from the sheet; if not, write the number on the sheet. This process is repeated N times.\n\nThen, you are asked a question: How many numbers are written on the sheet now?\n\nThe numbers announced by Joisino are given as A_1, ... ,A_N in the order she announces them. How many numbers will be written on the sheet at the end of the game?\n\nConstraints\n\n1≤N≤100000\n\n1≤A_i≤1000000000(=10^9)\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1\n:\nA_N\n\nOutput\n\nPrint how many numbers will be written on the sheet at the end of the game.\n\nSample Input 1\n\n3\n6\n2\n6\n\nSample Output 1\n\n1\n\nThe game proceeds as follows:\n\n6 is not written on the sheet, so write 6.\n\n2 is not written on the sheet, so write 2.\n\n6 is written on the sheet, so erase 6.\n\nThus, the sheet contains only 2 in the end. The answer is 1.\n\nSample Input 2\n\n4\n2\n5\n5\n2\n\nSample Output 2\n\n0\n\nIt is possible that no number is written on the sheet in the end.\n\nSample Input 3\n\n6\n12\n22\n16\n22\n18\n12\n\nSample Output 3\n\n2", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 49, "memory_kb": 7936}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s098450099", "group_id": "codeNet:p03608", "input_text": "module WeightedDirectedGraph\n (Weight : sig\n type t\n val inf : t (* オーバーフローの恐れはないので,max_intとか突っ込んでも良い *)\n val zero : t\n val neg_inf : t (* オーバーフローの恐れはないので,min_intとか突っ込んでも良い *)\n val ( + ) : t -> t -> t\n val compare : t -> t -> int\n end) :\nsig\n type 'a church_list = { fold : 'b. ('a -> 'b -> 'b) -> 'b -> 'b }\n\n val warshall_floyd :\n (* 頂点の数n *)\n int ->\n (* 辺のリスト *)\n (* 頂点は0からn-1までの整数でなくてはならない *)\n (int * int * Weight.t) church_list ->\n (* 辿り着けなければinf,負閉路を含む経路があればneg_infを返す関数 *)\n (int -> int -> Weight.t)\nend =\nstruct\n type 'a church_list = { fold : 'b. ('a -> 'b -> 'b) -> 'b -> 'b }\n\n let warshall_floyd n es =\n let d = Array.make_matrix n n Weight.inf in\n for v = 0 to n - 1 do\n d.(v).(v) <- Weight.zero\n done;\n es.fold (fun (u, v, c) () ->\n (* c < d.(u).(v) *)\n if 0 < Weight.compare d.(u).(v) c\n then d.(u).(v) <- c) ();\n for i = 0 to n - 1 do\n for j = 0 to n - 1 do\n for k = 0 to n - 1 do\n let open Weight in\n if \n (* 経路がない場合は更新しない *)\n 0 < Weight.compare inf d.(j).(i)\n && 0 < Weight.compare inf d.(i).(k)\n (* d.(j).(i) + d.(i).(k) < d.(j).(k) *)\n && 0 < Weight.compare d.(j).(k) (d.(j).(i) + d.(i).(k))\n then d.(j).(k) <- d.(j).(i) + d.(i).(k)\n done\n done\n done;\n for i = 0 to n - 1 do\n (* 頂点iを通る負閉路がある *)\n if 0 < Weight.compare Weight.zero d.(i).(i) then\n for j = 0 to n - 1 do\n for k = 0 to n - 1 do\n (* 負閉路を通る経路があれば,最短距離を負の無限大で更新 *)\n let open Weight in\n if 0 < Weight.compare inf d.(j).(i) && 0 < Weight.compare inf d.(i).(k)\n then d.(j).(k) <- Weight.neg_inf\n done\n done\n done;\n fun u v -> try d.(u).(v) with _ -> Weight.inf\nend\n\nmodule G = WeightedDirectedGraph (struct\n type t = int\n let zero = 0\n let ( + ) = ( + )\n let inf = max_int\n let neg_inf = min_int\n let compare = compare\nend)\n\nlet select xs f acc =\n let rec select acc trace = function\n | [] -> acc\n | x :: xs -> select (f trace x xs acc) (x :: trace) xs in \n select acc [] xs\n\nlet perm n xs f =\n let rec perm trace n xs acc =\n match n, xs with\n | 0, _ -> f trace acc\n | _, [] -> acc\n | _, _ ->\n select xs (fun xs x ys ->\n perm (x :: trace) (n - 1) @@ List.rev_append xs ys) acc in\n perm [] n xs\n\nlet () = Scanf.scanf \"%d %d %d\\n\" @@ fun n m r ->\n let rs = Array.init r @@ fun _ -> Scanf.scanf \"%d \" pred in\n let abcs = Array.init m @@ fun _ -> Scanf.scanf \"%d %d %d\\n\" @@ fun a b c -> a - 1, b - 1, c in\n let d = G.warshall_floyd n { G.fold = fun f -> Array.fold_right (fun ((a, b, c) as e) acc -> f (b, a, c) @@ f e acc) abcs } in\n Printf.printf \"%d\\n\" @@\n perm r (Array.to_list rs) (fun (r :: rs) acc ->\n min acc @@\n snd @@\n List.fold_left (fun (r, a) s -> (s, d r s + a)) (r, 0) rs) max_int\n", "language": "OCaml", "metadata": {"date": 1589612689, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03608.html", "problem_id": "p03608", "resource_group": "low_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/OCaml/s098450099.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s098450099", "user_id": "u504158101"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "module WeightedDirectedGraph\n (Weight : sig\n type t\n val inf : t (* オーバーフローの恐れはないので,max_intとか突っ込んでも良い *)\n val zero : t\n val neg_inf : t (* オーバーフローの恐れはないので,min_intとか突っ込んでも良い *)\n val ( + ) : t -> t -> t\n val compare : t -> t -> int\n end) :\nsig\n type 'a church_list = { fold : 'b. ('a -> 'b -> 'b) -> 'b -> 'b }\n\n val warshall_floyd :\n (* 頂点の数n *)\n int ->\n (* 辺のリスト *)\n (* 頂点は0からn-1までの整数でなくてはならない *)\n (int * int * Weight.t) church_list ->\n (* 辿り着けなければinf,負閉路を含む経路があればneg_infを返す関数 *)\n (int -> int -> Weight.t)\nend =\nstruct\n type 'a church_list = { fold : 'b. ('a -> 'b -> 'b) -> 'b -> 'b }\n\n let warshall_floyd n es =\n let d = Array.make_matrix n n Weight.inf in\n for v = 0 to n - 1 do\n d.(v).(v) <- Weight.zero\n done;\n es.fold (fun (u, v, c) () ->\n (* c < d.(u).(v) *)\n if 0 < Weight.compare d.(u).(v) c\n then d.(u).(v) <- c) ();\n for i = 0 to n - 1 do\n for j = 0 to n - 1 do\n for k = 0 to n - 1 do\n let open Weight in\n if \n (* 経路がない場合は更新しない *)\n 0 < Weight.compare inf d.(j).(i)\n && 0 < Weight.compare inf d.(i).(k)\n (* d.(j).(i) + d.(i).(k) < d.(j).(k) *)\n && 0 < Weight.compare d.(j).(k) (d.(j).(i) + d.(i).(k))\n then d.(j).(k) <- d.(j).(i) + d.(i).(k)\n done\n done\n done;\n for i = 0 to n - 1 do\n (* 頂点iを通る負閉路がある *)\n if 0 < Weight.compare Weight.zero d.(i).(i) then\n for j = 0 to n - 1 do\n for k = 0 to n - 1 do\n (* 負閉路を通る経路があれば,最短距離を負の無限大で更新 *)\n let open Weight in\n if 0 < Weight.compare inf d.(j).(i) && 0 < Weight.compare inf d.(i).(k)\n then d.(j).(k) <- Weight.neg_inf\n done\n done\n done;\n fun u v -> try d.(u).(v) with _ -> Weight.inf\nend\n\nmodule G = WeightedDirectedGraph (struct\n type t = int\n let zero = 0\n let ( + ) = ( + )\n let inf = max_int\n let neg_inf = min_int\n let compare = compare\nend)\n\nlet select xs f acc =\n let rec select acc trace = function\n | [] -> acc\n | x :: xs -> select (f trace x xs acc) (x :: trace) xs in \n select acc [] xs\n\nlet perm n xs f =\n let rec perm trace n xs acc =\n match n, xs with\n | 0, _ -> f trace acc\n | _, [] -> acc\n | _, _ ->\n select xs (fun xs x ys ->\n perm (x :: trace) (n - 1) @@ List.rev_append xs ys) acc in\n perm [] n xs\n\nlet () = Scanf.scanf \"%d %d %d\\n\" @@ fun n m r ->\n let rs = Array.init r @@ fun _ -> Scanf.scanf \"%d \" pred in\n let abcs = Array.init m @@ fun _ -> Scanf.scanf \"%d %d %d\\n\" @@ fun a b c -> a - 1, b - 1, c in\n let d = G.warshall_floyd n { G.fold = fun f -> Array.fold_right (fun ((a, b, c) as e) acc -> f (b, a, c) @@ f e acc) abcs } in\n Printf.printf \"%d\\n\" @@\n perm r (Array.to_list rs) (fun (r :: rs) acc ->\n min acc @@\n snd @@\n List.fold_left (fun (r, a) s -> (s, d r s + a)) (r, 0) rs) max_int\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nThere are N towns in the State of Atcoder, connected by M bidirectional roads.\n\nThe i-th road connects Town A_i and B_i and has a length of C_i.\n\nJoisino is visiting R towns in the state, r_1,r_2,..,r_R (not necessarily in this order).\n\nShe will fly to the first town she visits, and fly back from the last town she visits, but for the rest of the trip she will have to travel by road.\n\nIf she visits the towns in the order that minimizes the distance traveled by road, what will that distance be?\n\nConstraints\n\n2≤N≤200\n\n1≤M≤N×(N-1)/2\n\n2≤R≤min(8,N) (min(8,N) is the smaller of 8 and N.)\n\nr_i≠r_j (i≠j)\n\n1≤A_i,B_i≤N, A_i≠B_i\n\n(A_i,B_i)≠(A_j,B_j),(A_i,B_i)≠(B_j,A_j) (i≠j)\n\n1≤C_i≤100000\n\nEvery town can be reached from every town by road.\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M R\nr_1 ... r_R\nA_1 B_1 C_1\n:\nA_M B_M C_M\n\nOutput\n\nPrint the distance traveled by road if Joisino visits the towns in the order that minimizes it.\n\nSample Input 1\n\n3 3 3\n1 2 3\n1 2 1\n2 3 1\n3 1 4\n\nSample Output 1\n\n2\n\nFor example, if she visits the towns in the order of 1, 2, 3, the distance traveled will be 2, which is the minimum possible.\n\nSample Input 2\n\n3 3 2\n1 3\n2 3 2\n1 3 6\n1 2 2\n\nSample Output 2\n\n4\n\nThe shortest distance between Towns 1 and 3 is 4. Thus, whether she visits Town 1 or 3 first, the distance traveled will be 4.\n\nSample Input 3\n\n4 6 3\n2 3 4\n1 2 4\n2 3 3\n4 3 1\n1 4 1\n4 2 2\n3 1 6\n\nSample Output 3\n\n3", "sample_input": "3 3 3\n1 2 3\n1 2 1\n2 3 1\n3 1 4\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03608", "source_text": "Score : 400 points\n\nProblem Statement\n\nThere are N towns in the State of Atcoder, connected by M bidirectional roads.\n\nThe i-th road connects Town A_i and B_i and has a length of C_i.\n\nJoisino is visiting R towns in the state, r_1,r_2,..,r_R (not necessarily in this order).\n\nShe will fly to the first town she visits, and fly back from the last town she visits, but for the rest of the trip she will have to travel by road.\n\nIf she visits the towns in the order that minimizes the distance traveled by road, what will that distance be?\n\nConstraints\n\n2≤N≤200\n\n1≤M≤N×(N-1)/2\n\n2≤R≤min(8,N) (min(8,N) is the smaller of 8 and N.)\n\nr_i≠r_j (i≠j)\n\n1≤A_i,B_i≤N, A_i≠B_i\n\n(A_i,B_i)≠(A_j,B_j),(A_i,B_i)≠(B_j,A_j) (i≠j)\n\n1≤C_i≤100000\n\nEvery town can be reached from every town by road.\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M R\nr_1 ... r_R\nA_1 B_1 C_1\n:\nA_M B_M C_M\n\nOutput\n\nPrint the distance traveled by road if Joisino visits the towns in the order that minimizes it.\n\nSample Input 1\n\n3 3 3\n1 2 3\n1 2 1\n2 3 1\n3 1 4\n\nSample Output 1\n\n2\n\nFor example, if she visits the towns in the order of 1, 2, 3, the distance traveled will be 2, which is the minimum possible.\n\nSample Input 2\n\n3 3 2\n1 3\n2 3 2\n1 3 6\n1 2 2\n\nSample Output 2\n\n4\n\nThe shortest distance between Towns 1 and 3 is 4. Thus, whether she visits Town 1 or 3 first, the distance traveled will be 4.\n\nSample Input 3\n\n4 6 3\n2 3 4\n1 2 4\n2 3 3\n4 3 1\n1 4 1\n4 2 2\n3 1 6\n\nSample Output 3\n\n3", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3223, "cpu_time_ms": 374, "memory_kb": 5120}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s693479465", "group_id": "codeNet:p03608", "input_text": "let rec select acc trace = function\n | [] -> acc\n | x :: xs -> select ((trace, x, xs) :: acc) (x :: trace) xs\nlet select xs = select [] [] xs\n\nlet rec permutation = function\n | [] -> [[]]\n | xs -> \n List.concat @@ List.map (fun (xs, x, ys) -> List.map (fun xs -> x :: xs) (permutation (List.rev_append xs ys)))\n (select xs)\n\nlet warshall_floyd ( + ) min loop n d =\n for i = 0 to n - 1 do\n for j = 0 to n - 1 do\n for k = 0 to n - 1 do\n d.(j).(k) <- min d.(j).(k) (d.(j).(i) + loop d.(i).(i) + d.(i).(k))\n done\n done\n done\n\nlet () =\n let n, m, r = Scanf.scanf \"%d %d %d\\n\" (fun n m r -> n, m, r) in\n let rs = Array.init r (fun _ -> Scanf.scanf \"%d%c\" (fun r _ -> r - 1)) in\n let abcs = Array.init m (fun _ -> Scanf.scanf \"%d %d %d\\n\" (fun a b c -> a - 1, b - 1, c)) in\n let d = Array.make_matrix n n 100001 in\n for i = 0 to n - 1 do\n d.(i).(i) <- 0\n done;\n Array.iter (fun (a, b, c) ->\n d.(a).(b) <- c;\n d.(b).(a) <- c) abcs;\n warshall_floyd ( + ) min (fun _ -> 0) n d;\n (Array.to_list rs\n |> permutation\n |> List.map (fun (r :: rs) ->\n List.fold_left (fun (r, a) s -> (s, (r, s) :: a)) (r, []) rs\n |> snd\n |> List.map (fun (r, s) -> d.(r).(s))\n |> List.fold_left ( + ) 0)\n |> List.fold_left min max_int\n |> Printf.printf \"%d\\n\")", "language": "OCaml", "metadata": {"date": 1505007604, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03608.html", "problem_id": "p03608", "resource_group": "low_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/OCaml/s693479465.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s693479465", "user_id": "u504158101"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "let rec select acc trace = function\n | [] -> acc\n | x :: xs -> select ((trace, x, xs) :: acc) (x :: trace) xs\nlet select xs = select [] [] xs\n\nlet rec permutation = function\n | [] -> [[]]\n | xs -> \n List.concat @@ List.map (fun (xs, x, ys) -> List.map (fun xs -> x :: xs) (permutation (List.rev_append xs ys)))\n (select xs)\n\nlet warshall_floyd ( + ) min loop n d =\n for i = 0 to n - 1 do\n for j = 0 to n - 1 do\n for k = 0 to n - 1 do\n d.(j).(k) <- min d.(j).(k) (d.(j).(i) + loop d.(i).(i) + d.(i).(k))\n done\n done\n done\n\nlet () =\n let n, m, r = Scanf.scanf \"%d %d %d\\n\" (fun n m r -> n, m, r) in\n let rs = Array.init r (fun _ -> Scanf.scanf \"%d%c\" (fun r _ -> r - 1)) in\n let abcs = Array.init m (fun _ -> Scanf.scanf \"%d %d %d\\n\" (fun a b c -> a - 1, b - 1, c)) in\n let d = Array.make_matrix n n 100001 in\n for i = 0 to n - 1 do\n d.(i).(i) <- 0\n done;\n Array.iter (fun (a, b, c) ->\n d.(a).(b) <- c;\n d.(b).(a) <- c) abcs;\n warshall_floyd ( + ) min (fun _ -> 0) n d;\n (Array.to_list rs\n |> permutation\n |> List.map (fun (r :: rs) ->\n List.fold_left (fun (r, a) s -> (s, (r, s) :: a)) (r, []) rs\n |> snd\n |> List.map (fun (r, s) -> d.(r).(s))\n |> List.fold_left ( + ) 0)\n |> List.fold_left min max_int\n |> Printf.printf \"%d\\n\")", "problem_context": "Score : 400 points\n\nProblem Statement\n\nThere are N towns in the State of Atcoder, connected by M bidirectional roads.\n\nThe i-th road connects Town A_i and B_i and has a length of C_i.\n\nJoisino is visiting R towns in the state, r_1,r_2,..,r_R (not necessarily in this order).\n\nShe will fly to the first town she visits, and fly back from the last town she visits, but for the rest of the trip she will have to travel by road.\n\nIf she visits the towns in the order that minimizes the distance traveled by road, what will that distance be?\n\nConstraints\n\n2≤N≤200\n\n1≤M≤N×(N-1)/2\n\n2≤R≤min(8,N) (min(8,N) is the smaller of 8 and N.)\n\nr_i≠r_j (i≠j)\n\n1≤A_i,B_i≤N, A_i≠B_i\n\n(A_i,B_i)≠(A_j,B_j),(A_i,B_i)≠(B_j,A_j) (i≠j)\n\n1≤C_i≤100000\n\nEvery town can be reached from every town by road.\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M R\nr_1 ... r_R\nA_1 B_1 C_1\n:\nA_M B_M C_M\n\nOutput\n\nPrint the distance traveled by road if Joisino visits the towns in the order that minimizes it.\n\nSample Input 1\n\n3 3 3\n1 2 3\n1 2 1\n2 3 1\n3 1 4\n\nSample Output 1\n\n2\n\nFor example, if she visits the towns in the order of 1, 2, 3, the distance traveled will be 2, which is the minimum possible.\n\nSample Input 2\n\n3 3 2\n1 3\n2 3 2\n1 3 6\n1 2 2\n\nSample Output 2\n\n4\n\nThe shortest distance between Towns 1 and 3 is 4. Thus, whether she visits Town 1 or 3 first, the distance traveled will be 4.\n\nSample Input 3\n\n4 6 3\n2 3 4\n1 2 4\n2 3 3\n4 3 1\n1 4 1\n4 2 2\n3 1 6\n\nSample Output 3\n\n3", "sample_input": "3 3 3\n1 2 3\n1 2 1\n2 3 1\n3 1 4\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03608", "source_text": "Score : 400 points\n\nProblem Statement\n\nThere are N towns in the State of Atcoder, connected by M bidirectional roads.\n\nThe i-th road connects Town A_i and B_i and has a length of C_i.\n\nJoisino is visiting R towns in the state, r_1,r_2,..,r_R (not necessarily in this order).\n\nShe will fly to the first town she visits, and fly back from the last town she visits, but for the rest of the trip she will have to travel by road.\n\nIf she visits the towns in the order that minimizes the distance traveled by road, what will that distance be?\n\nConstraints\n\n2≤N≤200\n\n1≤M≤N×(N-1)/2\n\n2≤R≤min(8,N) (min(8,N) is the smaller of 8 and N.)\n\nr_i≠r_j (i≠j)\n\n1≤A_i,B_i≤N, A_i≠B_i\n\n(A_i,B_i)≠(A_j,B_j),(A_i,B_i)≠(B_j,A_j) (i≠j)\n\n1≤C_i≤100000\n\nEvery town can be reached from every town by road.\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M R\nr_1 ... r_R\nA_1 B_1 C_1\n:\nA_M B_M C_M\n\nOutput\n\nPrint the distance traveled by road if Joisino visits the towns in the order that minimizes it.\n\nSample Input 1\n\n3 3 3\n1 2 3\n1 2 1\n2 3 1\n3 1 4\n\nSample Output 1\n\n2\n\nFor example, if she visits the towns in the order of 1, 2, 3, the distance traveled will be 2, which is the minimum possible.\n\nSample Input 2\n\n3 3 2\n1 3\n2 3 2\n1 3 6\n1 2 2\n\nSample Output 2\n\n4\n\nThe shortest distance between Towns 1 and 3 is 4. Thus, whether she visits Town 1 or 3 first, the distance traveled will be 4.\n\nSample Input 3\n\n4 6 3\n2 3 4\n1 2 4\n2 3 3\n4 3 1\n1 4 1\n4 2 2\n3 1 6\n\nSample Output 3\n\n3", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1308, "cpu_time_ms": 271, "memory_kb": 15104}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s963091423", "group_id": "codeNet:p03609", "input_text": "let x, t = Scanf.scanf \" %d %d\" @@ fun a b -> a, b\nlet _ = max 0 @@ x - t |> Printf.printf \"%d\\n\"", "language": "OCaml", "metadata": {"date": 1562408887, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03609.html", "problem_id": "p03609", "resource_group": "low_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/OCaml/s963091423.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s963091423", "user_id": "u732304692"}, "prompt_components": {"gold_output": "83\n", "input_to_evaluate": "let x, t = Scanf.scanf \" %d %d\" @@ fun a b -> a, b\nlet _ = max 0 @@ x - t |> Printf.printf \"%d\\n\"", "problem_context": "Score : 100 points\n\nProblem Statement\n\nWe have a sandglass that runs for X seconds. The sand drops from the upper bulb at a rate of 1 gram per second. That is, the upper bulb initially contains X grams of sand.\n\nHow many grams of sand will the upper bulb contains after t seconds?\n\nConstraints\n\n1≤X≤10^9\n\n1≤t≤10^9\n\nX and t are integers.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nX t\n\nOutput\n\nPrint the number of sand in the upper bulb after t second.\n\nSample Input 1\n\n100 17\n\nSample Output 1\n\n83\n\n17 out of the initial 100 grams of sand will be consumed, resulting in 83 grams.\n\nSample Input 2\n\n48 58\n\nSample Output 2\n\n0\n\nAll 48 grams of sand will be gone, resulting in 0 grams.\n\nSample Input 3\n\n1000000000 1000000000\n\nSample Output 3\n\n0", "sample_input": "100 17\n"}, "reference_outputs": ["83\n"], "source_document_id": "p03609", "source_text": "Score : 100 points\n\nProblem Statement\n\nWe have a sandglass that runs for X seconds. The sand drops from the upper bulb at a rate of 1 gram per second. That is, the upper bulb initially contains X grams of sand.\n\nHow many grams of sand will the upper bulb contains after t seconds?\n\nConstraints\n\n1≤X≤10^9\n\n1≤t≤10^9\n\nX and t are integers.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nX t\n\nOutput\n\nPrint the number of sand in the upper bulb after t second.\n\nSample Input 1\n\n100 17\n\nSample Output 1\n\n83\n\n17 out of the initial 100 grams of sand will be consumed, resulting in 83 grams.\n\nSample Input 2\n\n48 58\n\nSample Output 2\n\n0\n\nAll 48 grams of sand will be gone, resulting in 0 grams.\n\nSample Input 3\n\n1000000000 1000000000\n\nSample Output 3\n\n0", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s349346742", "group_id": "codeNet:p03609", "input_text": "let f a b = if b>a then 0 else a-b;;\nScanf.scanf \"%d %d\"\nf\n|> Printf.printf \"%d\\n\"", "language": "OCaml", "metadata": {"date": 1561084420, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03609.html", "problem_id": "p03609", "resource_group": "low_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/OCaml/s349346742.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s349346742", "user_id": "u635974378"}, "prompt_components": {"gold_output": "83\n", "input_to_evaluate": "let f a b = if b>a then 0 else a-b;;\nScanf.scanf \"%d %d\"\nf\n|> Printf.printf \"%d\\n\"", "problem_context": "Score : 100 points\n\nProblem Statement\n\nWe have a sandglass that runs for X seconds. The sand drops from the upper bulb at a rate of 1 gram per second. That is, the upper bulb initially contains X grams of sand.\n\nHow many grams of sand will the upper bulb contains after t seconds?\n\nConstraints\n\n1≤X≤10^9\n\n1≤t≤10^9\n\nX and t are integers.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nX t\n\nOutput\n\nPrint the number of sand in the upper bulb after t second.\n\nSample Input 1\n\n100 17\n\nSample Output 1\n\n83\n\n17 out of the initial 100 grams of sand will be consumed, resulting in 83 grams.\n\nSample Input 2\n\n48 58\n\nSample Output 2\n\n0\n\nAll 48 grams of sand will be gone, resulting in 0 grams.\n\nSample Input 3\n\n1000000000 1000000000\n\nSample Output 3\n\n0", "sample_input": "100 17\n"}, "reference_outputs": ["83\n"], "source_document_id": "p03609", "source_text": "Score : 100 points\n\nProblem Statement\n\nWe have a sandglass that runs for X seconds. The sand drops from the upper bulb at a rate of 1 gram per second. That is, the upper bulb initially contains X grams of sand.\n\nHow many grams of sand will the upper bulb contains after t seconds?\n\nConstraints\n\n1≤X≤10^9\n\n1≤t≤10^9\n\nX and t are integers.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nX t\n\nOutput\n\nPrint the number of sand in the upper bulb after t second.\n\nSample Input 1\n\n100 17\n\nSample Output 1\n\n83\n\n17 out of the initial 100 grams of sand will be consumed, resulting in 83 grams.\n\nSample Input 2\n\n48 58\n\nSample Output 2\n\n0\n\nAll 48 grams of sand will be gone, resulting in 0 grams.\n\nSample Input 3\n\n1000000000 1000000000\n\nSample Output 3\n\n0", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s757447577", "group_id": "codeNet:p03610", "input_text": "open Printf\nopen Scanf\n\nlet id x = x\n\nlet s = read_line ()\n\nlet () =\n for i = 0 to String.length s - 1 do\n if i mod 2 = 0 then print_char s.[i]\n done;\n print_newline ()\n", "language": "OCaml", "metadata": {"date": 1536454431, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03610.html", "problem_id": "p03610", "resource_group": "low_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/OCaml/s757447577.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s757447577", "user_id": "u450300828"}, "prompt_components": {"gold_output": "acdr\n", "input_to_evaluate": "open Printf\nopen Scanf\n\nlet id x = x\n\nlet s = read_line ()\n\nlet () =\n for i = 0 to String.length s - 1 do\n if i mod 2 = 0 then print_char s.[i]\n done;\n print_newline ()\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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 3, "memory_kb": 768}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s543836273", "group_id": "codeNet:p03610", "input_text": "let () =\n let s = read_line () in\n print_endline @@ String.init ((String.length s + 1) / 2) (fun i -> s.[2 * i])\n", "language": "OCaml", "metadata": {"date": 1530678157, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03610.html", "problem_id": "p03610", "resource_group": "low_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/OCaml/s543836273.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s543836273", "user_id": "u504158101"}, "prompt_components": {"gold_output": "acdr\n", "input_to_evaluate": "let () =\n let s = read_line () in\n print_endline @@ String.init ((String.length s + 1) / 2) (fun i -> s.[2 * i])\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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 768}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s751348517", "group_id": "codeNet:p03611", "input_text": "let n = Scanf.scanf \" %d\" (+) 0\nlet a_s = Array.init n @@ fun _ -> Scanf.scanf \" %d\" (+) 0\nlet cs = Array.make 100001 0\nlet ans = ref 0\nlet _ = Array.iter (fun a -> cs.(a) <- cs.(a) + 1) a_s;\n for x = 1 to 100000 - 1 do ans := max !ans @@ cs.(x - 1) + cs.(x) + cs.(x + 1) done;\n Printf.printf \"%d\\n\" !ans", "language": "OCaml", "metadata": {"date": 1563311219, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03611.html", "problem_id": "p03611", "resource_group": "low_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/OCaml/s751348517.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s751348517", "user_id": "u732304692"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "let n = Scanf.scanf \" %d\" (+) 0\nlet a_s = Array.init n @@ fun _ -> Scanf.scanf \" %d\" (+) 0\nlet cs = Array.make 100001 0\nlet ans = ref 0\nlet _ = Array.iter (fun a -> cs.(a) <- cs.(a) + 1) a_s;\n for x = 1 to 100000 - 1 do ans := max !ans @@ cs.(x - 1) + cs.(x) + cs.(x + 1) done;\n Printf.printf \"%d\\n\" !ans", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 28, "memory_kb": 6272}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s217993520", "group_id": "codeNet:p03611", "input_text": "(* O(n) *)\nlet kMax = 100000\nlet n = Scanf.scanf \" %d\" @@ (+) 0\nlet ns = Array.make (kMax + 10) 0\nlet ans = ref 0\nlet _ =\n for i = 0 to n - 1 do\n let a = Scanf.scanf \" %d\" @@ (+) 0 in\n ns.(a) <- ns.(a) + 1\n done;\n for i = 0 to kMax - 1 do\n ans := max !ans @@ ns.(i) + ns.(i + 1) + ns.(i + 2)\n done;\n Printf.printf \"%d\\n\" !ans", "language": "OCaml", "metadata": {"date": 1560159693, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03611.html", "problem_id": "p03611", "resource_group": "low_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/OCaml/s217993520.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s217993520", "user_id": "u732304692"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "(* O(n) *)\nlet kMax = 100000\nlet n = Scanf.scanf \" %d\" @@ (+) 0\nlet ns = Array.make (kMax + 10) 0\nlet ans = ref 0\nlet _ =\n for i = 0 to n - 1 do\n let a = Scanf.scanf \" %d\" @@ (+) 0 in\n ns.(a) <- ns.(a) + 1\n done;\n for i = 0 to kMax - 1 do\n ans := max !ans @@ ns.(i) + ns.(i + 1) + ns.(i + 2)\n done;\n Printf.printf \"%d\\n\" !ans", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 339, "cpu_time_ms": 26, "memory_kb": 3456}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s952952521", "group_id": "codeNet:p03613", "input_text": "module IntMap = Map.Make (struct\n type t = int\n let compare = compare\nend)\n\nlet () = \n let n = Scanf.scanf \"%d\\n\" (fun n -> n) in\n let as_ = Array.init n (fun _ -> Scanf.scanf \"%d \" (fun a -> a)) in\n Array.fold_left (fun m a ->\n IntMap.add a (1 + try IntMap.find a m with Not_found -> 0) m) IntMap.empty as_\n |> (fun m -> IntMap.fold (fun a n m ->\n IntMap.add (a - 1) (n + try IntMap.find (a - 1) m with Not_found -> 0) m\n |> IntMap.add (a + 1) (n + try IntMap.find (a + 1) m with Not_found -> 0)) m m)\n |> IntMap.bindings\n |> List.map snd\n |> List.fold_left max 0\n |> Printf.printf \"%d\\n\"", "language": "OCaml", "metadata": {"date": 1504769153, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03613.html", "problem_id": "p03613", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03613/input.txt", "sample_output_relpath": "derived/input_output/data/p03613/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03613/OCaml/s952952521.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s952952521", "user_id": "u504158101"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "module IntMap = Map.Make (struct\n type t = int\n let compare = compare\nend)\n\nlet () = \n let n = Scanf.scanf \"%d\\n\" (fun n -> n) in\n let as_ = Array.init n (fun _ -> Scanf.scanf \"%d \" (fun a -> a)) in\n Array.fold_left (fun m a ->\n IntMap.add a (1 + try IntMap.find a m with Not_found -> 0) m) IntMap.empty as_\n |> (fun m -> IntMap.fold (fun a n m ->\n IntMap.add (a - 1) (n + try IntMap.find (a - 1) m with Not_found -> 0) m\n |> IntMap.add (a + 1) (n + try IntMap.find (a + 1) m with Not_found -> 0)) m m)\n |> IntMap.bindings\n |> List.map snd\n |> List.fold_left max 0\n |> Printf.printf \"%d\\n\"", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou are given an integer sequence of length N, a_1,a_2,...,a_N.\n\nFor each 1≤i≤N, you have three choices: add 1 to a_i, subtract 1 from a_i or do nothing.\n\nAfter these operations, you select an integer X and count the number of i such that a_i=X.\n\nMaximize this count by making optimal choices.\n\nConstraints\n\n1≤N≤10^5\n\n0≤a_i<10^5 (1≤i≤N)\n\na_i is an integer.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\na_1 a_2 .. a_N\n\nOutput\n\nPrint the maximum possible number of i such that a_i=X.\n\nSample Input 1\n\n7\n3 1 4 1 5 9 2\n\nSample Output 1\n\n4\n\nFor example, turn the sequence into 2,2,3,2,6,9,2 and select X=2 to obtain 4, the maximum possible count.\n\nSample Input 2\n\n10\n0 1 2 3 4 5 6 7 8 9\n\nSample Output 2\n\n3\n\nSample Input 3\n\n1\n99999\n\nSample Output 3\n\n1", "sample_input": "7\n3 1 4 1 5 9 2\n"}, "reference_outputs": ["4\n"], "source_document_id": "p03613", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou are given an integer sequence of length N, a_1,a_2,...,a_N.\n\nFor each 1≤i≤N, you have three choices: add 1 to a_i, subtract 1 from a_i or do nothing.\n\nAfter these operations, you select an integer X and count the number of i such that a_i=X.\n\nMaximize this count by making optimal choices.\n\nConstraints\n\n1≤N≤10^5\n\n0≤a_i<10^5 (1≤i≤N)\n\na_i is an integer.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\na_1 a_2 .. a_N\n\nOutput\n\nPrint the maximum possible number of i such that a_i=X.\n\nSample Input 1\n\n7\n3 1 4 1 5 9 2\n\nSample Output 1\n\n4\n\nFor example, turn the sequence into 2,2,3,2,6,9,2 and select X=2 to obtain 4, the maximum possible count.\n\nSample Input 2\n\n10\n0 1 2 3 4 5 6 7 8 9\n\nSample Output 2\n\n3\n\nSample Input 3\n\n1\n99999\n\nSample Output 3\n\n1", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 612, "cpu_time_ms": 219, "memory_kb": 17408}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s555140261", "group_id": "codeNet:p03614", "input_text": "let rec solve i n = function\n | [] | [_] -> n\n | p :: p' :: ps ->\n if i = p then\n solve (i + 1) (n + 1) (p :: ps)\n else\n solve (i + 1) n (p' :: ps)\nlet solve = solve 1 0\n\nlet () =\n let n = Scanf.scanf \"%d\\n\" (fun n -> n) in\n let ps = Array.to_list @@ Array.init n (fun _ -> Scanf.scanf \"%d \" (fun p -> p)) in\n Printf.printf \"%d\\n\" @@ solve ps", "language": "OCaml", "metadata": {"date": 1504771827, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03614.html", "problem_id": "p03614", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03614/input.txt", "sample_output_relpath": "derived/input_output/data/p03614/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03614/OCaml/s555140261.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s555140261", "user_id": "u504158101"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "let rec solve i n = function\n | [] | [_] -> n\n | p :: p' :: ps ->\n if i = p then\n solve (i + 1) (n + 1) (p :: ps)\n else\n solve (i + 1) n (p' :: ps)\nlet solve = solve 1 0\n\nlet () =\n let n = Scanf.scanf \"%d\\n\" (fun n -> n) in\n let ps = Array.to_list @@ Array.init n (fun _ -> Scanf.scanf \"%d \" (fun p -> p)) in\n Printf.printf \"%d\\n\" @@ solve ps", "problem_context": "Score : 400 points\n\nProblem Statement\n\nYou are given a permutation p_1,p_2,...,p_N consisting of 1,2,..,N.\nYou can perform the following operation any number of times (possibly zero):\n\nOperation: Swap two adjacent elements in the permutation.\n\nYou want to have p_i ≠ i for all 1≤i≤N.\nFind the minimum required number of operations to achieve this.\n\nConstraints\n\n2≤N≤10^5\n\np_1,p_2,..,p_N is a permutation of 1,2,..,N.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\np_1 p_2 .. p_N\n\nOutput\n\nPrint the minimum required number of operations\n\nSample Input 1\n\n5\n1 4 3 5 2\n\nSample Output 1\n\n2\n\nSwap 1 and 4, then swap 1 and 3. p is now 4,3,1,5,2 and satisfies the condition.\nThis is the minimum possible number, so the answer is 2.\n\nSample Input 2\n\n2\n1 2\n\nSample Output 2\n\n1\n\nSwapping 1 and 2 satisfies the condition.\n\nSample Input 3\n\n2\n2 1\n\nSample Output 3\n\n0\n\nThe condition is already satisfied initially.\n\nSample Input 4\n\n9\n1 2 4 9 5 8 7 3 6\n\nSample Output 4\n\n3", "sample_input": "5\n1 4 3 5 2\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03614", "source_text": "Score : 400 points\n\nProblem Statement\n\nYou are given a permutation p_1,p_2,...,p_N consisting of 1,2,..,N.\nYou can perform the following operation any number of times (possibly zero):\n\nOperation: Swap two adjacent elements in the permutation.\n\nYou want to have p_i ≠ i for all 1≤i≤N.\nFind the minimum required number of operations to achieve this.\n\nConstraints\n\n2≤N≤10^5\n\np_1,p_2,..,p_N is a permutation of 1,2,..,N.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\np_1 p_2 .. p_N\n\nOutput\n\nPrint the minimum required number of operations\n\nSample Input 1\n\n5\n1 4 3 5 2\n\nSample Output 1\n\n2\n\nSwap 1 and 4, then swap 1 and 3. p is now 4,3,1,5,2 and satisfies the condition.\nThis is the minimum possible number, so the answer is 2.\n\nSample Input 2\n\n2\n1 2\n\nSample Output 2\n\n1\n\nSwapping 1 and 2 satisfies the condition.\n\nSample Input 3\n\n2\n2 1\n\nSample Output 3\n\n0\n\nThe condition is already satisfied initially.\n\nSample Input 4\n\n9\n1 2 4 9 5 8 7 3 6\n\nSample Output 4\n\n3", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 371, "cpu_time_ms": 29, "memory_kb": 6400}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s631720413", "group_id": "codeNet:p03617", "input_text": "Scanf.scanf \"%d %d %d %d %d\" (fun q h s d n ->\n let best1 = min s (min (q * 4) (h * 2)) in\n let best2 = min d (best1 * 2) in\n\n Printf.printf \"%d\\n\" @@ (n / 2) * best2 + (n mod 2) * best1\n)", "language": "OCaml", "metadata": {"date": 1593054057, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p03617.html", "problem_id": "p03617", "resource_group": "low_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/OCaml/s631720413.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s631720413", "user_id": "u342443598"}, "prompt_components": {"gold_output": "150\n", "input_to_evaluate": "Scanf.scanf \"%d %d %d %d %d\" (fun q h s d n ->\n let best1 = min s (min (q * 4) (h * 2)) in\n let best2 = min d (best1 * 2) in\n\n Printf.printf \"%d\\n\" @@ (n / 2) * best2 + (n mod 2) * best1\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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 197, "cpu_time_ms": 7, "memory_kb": 3804}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s890233424", "group_id": "codeNet:p03623", "input_text": "\nopen Scanf\nopen Printf\n\nlet flip f x y = f y x\n\nlet rec range a b = if a >= b then [] else a :: range (a+1) b\n\nlet read_int () = scanf \" %d\" (fun x -> x)\nlet rec read_ints n = if n = 0 then [] else let i = read_int () in i :: read_ints (n-1)\n\nlet rec for_iter a b f = if a >= b then [] else let x = f a in x :: for_iter (a+1) b f\nlet rec for_iter_ a b f = if a >= b then () else (f a; for_iter_ (a+1) b f)\n\nlet () =\n let [x; a; b] = read_ints 3 in\n printf \"%s\\n\" @@ if (abs (x-a)) < (abs (x-b)) then \"A\" else \"B\"\n", "language": "OCaml", "metadata": {"date": 1519613833, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03623.html", "problem_id": "p03623", "resource_group": "low_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/OCaml/s890233424.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s890233424", "user_id": "u798181098"}, "prompt_components": {"gold_output": "B\n", "input_to_evaluate": "\nopen Scanf\nopen Printf\n\nlet flip f x y = f y x\n\nlet rec range a b = if a >= b then [] else a :: range (a+1) b\n\nlet read_int () = scanf \" %d\" (fun x -> x)\nlet rec read_ints n = if n = 0 then [] else let i = read_int () in i :: read_ints (n-1)\n\nlet rec for_iter a b f = if a >= b then [] else let x = f a in x :: for_iter (a+1) b f\nlet rec for_iter_ a b f = if a >= b then () else (f a; for_iter_ (a+1) b f)\n\nlet () =\n let [x; a; b] = read_ints 3 in\n printf \"%s\\n\" @@ if (abs (x-a)) < (abs (x-b)) then \"A\" else \"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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 516, "cpu_time_ms": 2, "memory_kb": 4480}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s271259280", "group_id": "codeNet:p03623", "input_text": "let () =\n let x, a, b = Scanf.scanf \"%d %d %d\" (fun x a b -> x, a, b) in\n print_endline (if abs (x - a) < abs (x - b) then \"A\" else \"B\")", "language": "OCaml", "metadata": {"date": 1503277352, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03623.html", "problem_id": "p03623", "resource_group": "low_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/OCaml/s271259280.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s271259280", "user_id": "u322845568"}, "prompt_components": {"gold_output": "B\n", "input_to_evaluate": "let () =\n let x, a, b = Scanf.scanf \"%d %d %d\" (fun x a b -> x, a, b) in\n print_endline (if abs (x - a) < abs (x - b) then \"A\" else \"B\")", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s663390289", "group_id": "codeNet:p03625", "input_text": "let n = Scanf.scanf \" %d\" (+) 0\nlet a_s = Array.init n @@ fun _ -> Scanf.scanf \" %d\" (+) 0\nlet c, p, m, i = ref 0, ref a_s.(0), ref 0, ref 0\nlet f d = Printf.printf \"%d\\n\" d; exit 0\nlet g i a = if i = 1 then f @@ !m * a else m := a\nlet _ = Array.(sort (fun x y -> y - x) a_s; iter (fun a -> if a = !p then (incr c; if !c >= 4 then f @@ a * a) else (if !c >= 2 then (g !i !p; incr i); c := 1; p := a)) a_s); if !c >= 2 then g !i !p; f 0", "language": "OCaml", "metadata": {"date": 1570372786, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03625.html", "problem_id": "p03625", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03625/input.txt", "sample_output_relpath": "derived/input_output/data/p03625/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03625/OCaml/s663390289.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s663390289", "user_id": "u732304692"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "let n = Scanf.scanf \" %d\" (+) 0\nlet a_s = Array.init n @@ fun _ -> Scanf.scanf \" %d\" (+) 0\nlet c, p, m, i = ref 0, ref a_s.(0), ref 0, ref 0\nlet f d = Printf.printf \"%d\\n\" d; exit 0\nlet g i a = if i = 1 then f @@ !m * a else m := a\nlet _ = Array.(sort (fun x y -> y - x) a_s; iter (fun a -> if a = !p then (incr c; if !c >= 4 then f @@ a * a) else (if !c >= 2 then (g !i !p; incr i); c := 1; p := a)) a_s); if !c >= 2 then g !i !p; f 0", "problem_context": "Score : 300 points\n\nProblem Statement\n\nWe have N sticks with negligible thickness.\nThe length of the i-th stick is A_i.\n\nSnuke wants to select four different sticks from these sticks and form a rectangle (including a square), using the sticks as its sides.\nFind the maximum possible area of the rectangle.\n\nConstraints\n\n4 \\leq N \\leq 10^5\n\n1 \\leq A_i \\leq 10^9\n\nA_i is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the maximum possible area of the rectangle.\nIf no rectangle can be formed, print 0.\n\nSample Input 1\n\n6\n3 1 2 4 2 1\n\nSample Output 1\n\n2\n\n1 \\times 2 rectangle can be formed.\n\nSample Input 2\n\n4\n1 2 3 4\n\nSample Output 2\n\n0\n\nNo rectangle can be formed.\n\nSample Input 3\n\n10\n3 3 3 3 4 4 4 5 5 5\n\nSample Output 3\n\n20", "sample_input": "6\n3 1 2 4 2 1\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03625", "source_text": "Score : 300 points\n\nProblem Statement\n\nWe have N sticks with negligible thickness.\nThe length of the i-th stick is A_i.\n\nSnuke wants to select four different sticks from these sticks and form a rectangle (including a square), using the sticks as its sides.\nFind the maximum possible area of the rectangle.\n\nConstraints\n\n4 \\leq N \\leq 10^5\n\n1 \\leq A_i \\leq 10^9\n\nA_i is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the maximum possible area of the rectangle.\nIf no rectangle can be formed, print 0.\n\nSample Input 1\n\n6\n3 1 2 4 2 1\n\nSample Output 1\n\n2\n\n1 \\times 2 rectangle can be formed.\n\nSample Input 2\n\n4\n1 2 3 4\n\nSample Output 2\n\n0\n\nNo rectangle can be formed.\n\nSample Input 3\n\n10\n3 3 3 3 4 4 4 5 5 5\n\nSample Output 3\n\n20", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 435, "cpu_time_ms": 66, "memory_kb": 5376}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s770340714", "group_id": "codeNet:p03625", "input_text": "let read () = Scanf.scanf \"%d \" (fun i -> i)\n\nlet () =\n let n = read () in\n let a = Array.init n (fun _ -> read ()) in\n Array.fast_sort (fun x y -> y - x) a;\n let rec doit i pre =\n if i = n then 0\n else if a.(i-1) = a.(i) then begin\n if pre <> (-1) then pre * a.(i)\n else doit (i + 2) a.(i)\n end else doit (i + 1) pre in\n doit 1 (-1) |> Printf.printf \"%d\\n\"", "language": "OCaml", "metadata": {"date": 1503278193, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03625.html", "problem_id": "p03625", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03625/input.txt", "sample_output_relpath": "derived/input_output/data/p03625/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03625/OCaml/s770340714.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s770340714", "user_id": "u322845568"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "let read () = Scanf.scanf \"%d \" (fun i -> i)\n\nlet () =\n let n = read () in\n let a = Array.init n (fun _ -> read ()) in\n Array.fast_sort (fun x y -> y - x) a;\n let rec doit i pre =\n if i = n then 0\n else if a.(i-1) = a.(i) then begin\n if pre <> (-1) then pre * a.(i)\n else doit (i + 2) a.(i)\n end else doit (i + 1) pre in\n doit 1 (-1) |> Printf.printf \"%d\\n\"", "problem_context": "Score : 300 points\n\nProblem Statement\n\nWe have N sticks with negligible thickness.\nThe length of the i-th stick is A_i.\n\nSnuke wants to select four different sticks from these sticks and form a rectangle (including a square), using the sticks as its sides.\nFind the maximum possible area of the rectangle.\n\nConstraints\n\n4 \\leq N \\leq 10^5\n\n1 \\leq A_i \\leq 10^9\n\nA_i is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the maximum possible area of the rectangle.\nIf no rectangle can be formed, print 0.\n\nSample Input 1\n\n6\n3 1 2 4 2 1\n\nSample Output 1\n\n2\n\n1 \\times 2 rectangle can be formed.\n\nSample Input 2\n\n4\n1 2 3 4\n\nSample Output 2\n\n0\n\nNo rectangle can be formed.\n\nSample Input 3\n\n10\n3 3 3 3 4 4 4 5 5 5\n\nSample Output 3\n\n20", "sample_input": "6\n3 1 2 4 2 1\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03625", "source_text": "Score : 300 points\n\nProblem Statement\n\nWe have N sticks with negligible thickness.\nThe length of the i-th stick is A_i.\n\nSnuke wants to select four different sticks from these sticks and form a rectangle (including a square), using the sticks as its sides.\nFind the maximum possible area of the rectangle.\n\nConstraints\n\n4 \\leq N \\leq 10^5\n\n1 \\leq A_i \\leq 10^9\n\nA_i is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the maximum possible area of the rectangle.\nIf no rectangle can be formed, print 0.\n\nSample Input 1\n\n6\n3 1 2 4 2 1\n\nSample Output 1\n\n2\n\n1 \\times 2 rectangle can be formed.\n\nSample Input 2\n\n4\n1 2 3 4\n\nSample Output 2\n\n0\n\nNo rectangle can be formed.\n\nSample Input 3\n\n10\n3 3 3 3 4 4 4 5 5 5\n\nSample Output 3\n\n20", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 381, "cpu_time_ms": 54, "memory_kb": 5504}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s547185173", "group_id": "codeNet:p03626", "input_text": "\nopen Scanf\nopen Printf\n\nlet flip f x y = f y x\n\nlet rec range a b = if a >= b then [] else a :: range (a+1) b\n\nlet read_int () = scanf \" %d\" (fun x -> x)\nlet rec read_ints n = if n = 0 then [] else let i = read_int () in i :: read_ints (n-1)\n\nlet rec for_iter a b f = if a >= b then [] else let x = f a in x :: for_iter (a+1) b f\nlet rec for_iter_ a b f = if a >= b then () else (f a; for_iter_ (a+1) b f)\n\nlet list_of_string str = range 0 (String.length str) |> List.map (fun i -> str.[i])\n\ntype domino = H | V\n\nlet m = 1000000007\n\nlet mm x y = (x * y) mod m\n\nlet parse s =\n let rec f str = match str with\n | [] -> []\n | [_] -> [V]\n | (x::y::ys) -> if x = y then H :: f ys else V :: f (y::ys) in\n f (list_of_string s)\n\nlet calc xs =\n let f (p, a) x =\n match p, x with\n | H, H -> (H, mm 3 a)\n | H, V -> (V, a)\n | V, _ -> (x, mm 2 a) in\n match xs with\n | [] -> 1\n | (x::xs') -> List.fold_left f (x, 3) xs' |> snd\n\nlet () =\n let _ = read_line () in\n let _ = read_line () in\n read_line () |> parse |> calc |> printf \"%d\\n\"\n", "language": "OCaml", "metadata": {"date": 1519616815, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03626.html", "problem_id": "p03626", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03626/input.txt", "sample_output_relpath": "derived/input_output/data/p03626/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03626/OCaml/s547185173.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s547185173", "user_id": "u798181098"}, "prompt_components": {"gold_output": "6\n", "input_to_evaluate": "\nopen Scanf\nopen Printf\n\nlet flip f x y = f y x\n\nlet rec range a b = if a >= b then [] else a :: range (a+1) b\n\nlet read_int () = scanf \" %d\" (fun x -> x)\nlet rec read_ints n = if n = 0 then [] else let i = read_int () in i :: read_ints (n-1)\n\nlet rec for_iter a b f = if a >= b then [] else let x = f a in x :: for_iter (a+1) b f\nlet rec for_iter_ a b f = if a >= b then () else (f a; for_iter_ (a+1) b f)\n\nlet list_of_string str = range 0 (String.length str) |> List.map (fun i -> str.[i])\n\ntype domino = H | V\n\nlet m = 1000000007\n\nlet mm x y = (x * y) mod m\n\nlet parse s =\n let rec f str = match str with\n | [] -> []\n | [_] -> [V]\n | (x::y::ys) -> if x = y then H :: f ys else V :: f (y::ys) in\n f (list_of_string s)\n\nlet calc xs =\n let f (p, a) x =\n match p, x with\n | H, H -> (H, mm 3 a)\n | H, V -> (V, a)\n | V, _ -> (x, mm 2 a) in\n match xs with\n | [] -> 1\n | (x::xs') -> List.fold_left f (x, 3) xs' |> snd\n\nlet () =\n let _ = read_line () in\n let _ = read_line () in\n read_line () |> parse |> calc |> printf \"%d\\n\"\n", "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": "p03626", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1045, "cpu_time_ms": 1, "memory_kb": 2432}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s686229191", "group_id": "codeNet:p03629", "input_text": "exception Solved of string\n\nmodule CharMap = Map.Make (Char)\n\nlet alphabet =\n [ 'a'; 'b'; 'c'; 'd'; 'e'; 'f'; 'g'; 'h'; 'i'; 'j'; 'k'; 'l'; 'm';\n 'n'; 'o'; 'p'; 'q'; 'r'; 's'; 't'; 'u'; 'v'; 'w'; 'x'; 'y'; 'z']\n\nlet () =\n let a = read_line () in\n let trie = Array.make (String.length a + 1) CharMap.empty in\n for i = String.length a - 1 downto 0 do\n trie.(i) <- CharMap.add a.[i] (i + 1) trie.(i + 1)\n done;\n let dp = Array.make (String.length a + 1) (0, []) in\n for i = String.length a downto 0 do\n dp.(i) <-\n List.fold_left min (max_int, []) @@\n List.map (fun c ->\n match dp.(CharMap.find c trie.(i)) with\n | exception Not_found -> (1, [c])\n | (n, s) -> (1 + n, c :: s)) alphabet\n done;\n List.iter print_char (snd dp.(0));\n print_newline ()\n", "language": "OCaml", "metadata": {"date": 1535958501, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03629.html", "problem_id": "p03629", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03629/input.txt", "sample_output_relpath": "derived/input_output/data/p03629/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03629/OCaml/s686229191.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s686229191", "user_id": "u504158101"}, "prompt_components": {"gold_output": "b\n", "input_to_evaluate": "exception Solved of string\n\nmodule CharMap = Map.Make (Char)\n\nlet alphabet =\n [ 'a'; 'b'; 'c'; 'd'; 'e'; 'f'; 'g'; 'h'; 'i'; 'j'; 'k'; 'l'; 'm';\n 'n'; 'o'; 'p'; 'q'; 'r'; 's'; 't'; 'u'; 'v'; 'w'; 'x'; 'y'; 'z']\n\nlet () =\n let a = read_line () in\n let trie = Array.make (String.length a + 1) CharMap.empty in\n for i = String.length a - 1 downto 0 do\n trie.(i) <- CharMap.add a.[i] (i + 1) trie.(i + 1)\n done;\n let dp = Array.make (String.length a + 1) (0, []) in\n for i = String.length a downto 0 do\n dp.(i) <-\n List.fold_left min (max_int, []) @@\n List.map (fun c ->\n match dp.(CharMap.find c trie.(i)) with\n | exception Not_found -> (1, [c])\n | (n, s) -> (1 + n, c :: s)) alphabet\n done;\n List.iter print_char (snd dp.(0));\n print_newline ()\n", "problem_context": "Score : 600 points\n\nProblem Statement\n\nA subsequence of a string S is a string that can be obtained by deleting zero or more characters from S without changing the order of the remaining characters.\nFor example, arc, artistic and (an empty string) are all subsequences of artistic; abc and ci are not.\n\nYou are given a string A consisting of lowercase English letters.\nFind the shortest string among the strings consisting of lowercase English letters that are not subsequences of A.\nIf there are more than one such string, find the lexicographically smallest one among them.\n\nConstraints\n\n1 \\leq |A| \\leq 2 \\times 10^5\n\nA consists of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA\n\nOutput\n\nPrint the lexicographically smallest string among the shortest strings consisting of lowercase English letters that are not subsequences of A.\n\nSample Input 1\n\natcoderregularcontest\n\nSample Output 1\n\nb\n\nThe string atcoderregularcontest contains a as a subsequence, but not b.\n\nSample Input 2\n\nabcdefghijklmnopqrstuvwxyz\n\nSample Output 2\n\naa\n\nSample Input 3\n\nfrqnvhydscshfcgdemurlfrutcpzhopfotpifgepnqjxupnskapziurswqazdwnwbgdhyktfyhqqxpoidfhjdakoxraiedxskywuepzfniuyskxiyjpjlxuqnfgmnjcvtlpnclfkpervxmdbvrbrdn\n\nSample Output 3\n\naca", "sample_input": "atcoderregularcontest\n"}, "reference_outputs": ["b\n"], "source_document_id": "p03629", "source_text": "Score : 600 points\n\nProblem Statement\n\nA subsequence of a string S is a string that can be obtained by deleting zero or more characters from S without changing the order of the remaining characters.\nFor example, arc, artistic and (an empty string) are all subsequences of artistic; abc and ci are not.\n\nYou are given a string A consisting of lowercase English letters.\nFind the shortest string among the strings consisting of lowercase English letters that are not subsequences of A.\nIf there are more than one such string, find the lexicographically smallest one among them.\n\nConstraints\n\n1 \\leq |A| \\leq 2 \\times 10^5\n\nA consists of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA\n\nOutput\n\nPrint the lexicographically smallest string among the shortest strings consisting of lowercase English letters that are not subsequences of A.\n\nSample Input 1\n\natcoderregularcontest\n\nSample Output 1\n\nb\n\nThe string atcoderregularcontest contains a as a subsequence, but not b.\n\nSample Input 2\n\nabcdefghijklmnopqrstuvwxyz\n\nSample Output 2\n\naa\n\nSample Input 3\n\nfrqnvhydscshfcgdemurlfrutcpzhopfotpifgepnqjxupnskapziurswqazdwnwbgdhyktfyhqqxpoidfhjdakoxraiedxskywuepzfniuyskxiyjpjlxuqnfgmnjcvtlpnclfkpervxmdbvrbrdn\n\nSample Output 3\n\naca", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 793, "cpu_time_ms": 549, "memory_kb": 59388}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s521242800", "group_id": "codeNet:p03632", "input_text": "open Batteries\nopen Printf\nlet () =\n let a,b,c,d = Scanf.scanf \"%d %d %d %d \" (fun a b c d -> a,b,c,d) in\n let ans = (min b d) - (max a c) in\n Printf.printf \"%d\\n\" @@\n if ans > 0 then ans else 0\n", "language": "OCaml", "metadata": {"date": 1529384225, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03632.html", "problem_id": "p03632", "resource_group": "low_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/OCaml/s521242800.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s521242800", "user_id": "u139013163"}, "prompt_components": {"gold_output": "50\n", "input_to_evaluate": "open Batteries\nopen Printf\nlet () =\n let a,b,c,d = Scanf.scanf \"%d %d %d %d \" (fun a b c d -> a,b,c,d) in\n let ans = (min b d) - (max a c) in\n Printf.printf \"%d\\n\" @@\n if ans > 0 then ans else 0\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 read_int ())\n |> Array.fold_left lcm 1\n |> Printf.printf \"%d\\n\"", "language": "OCaml", "metadata": {"date": 1502623016, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03633.html", "problem_id": "p03633", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03633/input.txt", "sample_output_relpath": "derived/input_output/data/p03633/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03633/OCaml/s244083243.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s244083243", "user_id": "u322845568"}, "prompt_components": {"gold_output": "6\n", "input_to_evaluate": "let gcd x y =\n let rec doit x y =\n if y = 0 then x\n else doit y (x mod y) in\n doit (max x y) (min x y)\n\nlet lcm x y = x / (gcd x y) * y\n\nlet () =\n let n = read_int () in\n Array.init n (fun _ -> read_int ())\n |> Array.fold_left lcm 1\n |> Printf.printf \"%d\\n\"", "problem_context": "Score : 300 points\n\nProblem Statement\n\nWe have N clocks. The hand of the i-th clock (1≤i≤N) rotates through 360° in exactly T_i seconds.\n\nInitially, the hand of every clock stands still, pointing directly upward.\n\nNow, Dolphin starts all the clocks simultaneously.\n\nIn how many seconds will the hand of every clock point directly upward again?\n\nConstraints\n\n1≤N≤100\n\n1≤T_i≤10^{18}\n\nAll input values are integers.\n\nThe correct answer is at most 10^{18} seconds.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nT_1\n:\nT_N\n\nOutput\n\nPrint the number of seconds after which the hand of every clock point directly upward again.\n\nSample Input 1\n\n2\n2\n3\n\nSample Output 1\n\n6\n\nWe have two clocks. The time when the hand of each clock points upward is as follows:\n\nClock 1: 2, 4, 6, ... seconds after the beginning\n\nClock 2: 3, 6, 9, ... seconds after the beginning\n\nTherefore, it takes 6 seconds until the hands of both clocks point directly upward.\n\nSample Input 2\n\n5\n2\n5\n10\n1000000000000000000\n1000000000000000000\n\nSample Output 2\n\n1000000000000000000", "sample_input": "2\n2\n3\n"}, "reference_outputs": ["6\n"], "source_document_id": "p03633", "source_text": "Score : 300 points\n\nProblem Statement\n\nWe have N clocks. The hand of the i-th clock (1≤i≤N) rotates through 360° in exactly T_i seconds.\n\nInitially, the hand of every clock stands still, pointing directly upward.\n\nNow, Dolphin starts all the clocks simultaneously.\n\nIn how many seconds will the hand of every clock point directly upward again?\n\nConstraints\n\n1≤N≤100\n\n1≤T_i≤10^{18}\n\nAll input values are integers.\n\nThe correct answer is at most 10^{18} seconds.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nT_1\n:\nT_N\n\nOutput\n\nPrint the number of seconds after which the hand of every clock point directly upward again.\n\nSample Input 1\n\n2\n2\n3\n\nSample Output 1\n\n6\n\nWe have two clocks. The time when the hand of each clock points upward is as follows:\n\nClock 1: 2, 4, 6, ... seconds after the beginning\n\nClock 2: 3, 6, 9, ... seconds after the beginning\n\nTherefore, it takes 6 seconds until the hands of both clocks point directly upward.\n\nSample Input 2\n\n5\n2\n5\n10\n1000000000000000000\n1000000000000000000\n\nSample Output 2\n\n1000000000000000000", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s334727310", "group_id": "codeNet:p03634", "input_text": "let n = read_int ()\nlet g, ds = Array.(make n [], make n 0)\nlet rec f v p s = ds.(v) <- s; List.iter (fun (u, d) -> if u <> p then f u v (s + d)) g.(v)\nlet _ = for _ = 1 to n - 1 do Scanf.scanf \" %d %d %d\" @@ fun a b c -> g.(a - 1) <- (b - 1, c) :: g.(a - 1); g.(b - 1) <- (a - 1, c) :: g.(b - 1) done; \n Scanf.scanf \" %d %d\" @@ fun q k -> f (k - 1) ~-1 0; for _ = 1 to q do Scanf.scanf \" %d %d\" @@ fun x y -> Printf.printf \"%d\\n\" @@ ds.(x - 1) + ds.(y - 1) done", "language": "OCaml", "metadata": {"date": 1582416493, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03634.html", "problem_id": "p03634", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03634/input.txt", "sample_output_relpath": "derived/input_output/data/p03634/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03634/OCaml/s334727310.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s334727310", "user_id": "u732304692"}, "prompt_components": {"gold_output": "3\n2\n4\n", "input_to_evaluate": "let n = read_int ()\nlet g, ds = Array.(make n [], make n 0)\nlet rec f v p s = ds.(v) <- s; List.iter (fun (u, d) -> if u <> p then f u v (s + d)) g.(v)\nlet _ = for _ = 1 to n - 1 do Scanf.scanf \" %d %d %d\" @@ fun a b c -> g.(a - 1) <- (b - 1, c) :: g.(a - 1); g.(b - 1) <- (a - 1, c) :: g.(b - 1) done; \n Scanf.scanf \" %d %d\" @@ fun q k -> f (k - 1) ~-1 0; for _ = 1 to q do Scanf.scanf \" %d %d\" @@ fun x y -> Printf.printf \"%d\\n\" @@ ds.(x - 1) + ds.(y - 1) done", "problem_context": "Score : 400 points\n\nProblem Statement\n\nYou are given a tree with N vertices.\n\nHere, a tree is a kind of graph, and more specifically, a connected undirected graph with N-1 edges, where N is the number of its vertices.\n\nThe i-th edge (1≤i≤N-1) connects Vertices a_i and b_i, and has a length of c_i.\n\nYou are also given Q queries and an integer K. In the j-th query (1≤j≤Q):\n\nfind the length of the shortest path from Vertex x_j and Vertex y_j via Vertex K.\n\nConstraints\n\n3≤N≤10^5\n\n1≤a_i,b_i≤N (1≤i≤N-1)\n\n1≤c_i≤10^9 (1≤i≤N-1)\n\nThe given graph is a tree.\n\n1≤Q≤10^5\n\n1≤K≤N\n\n1≤x_j,y_j≤N (1≤j≤Q)\n\nx_j≠y_j (1≤j≤Q)\n\nx_j≠K,y_j≠K (1≤j≤Q)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 b_1 c_1\n:\na_{N-1} b_{N-1} c_{N-1}\nQ K\nx_1 y_1\n:\nx_{Q} y_{Q}\n\nOutput\n\nPrint the responses to the queries in Q lines.\n\nIn the j-th line j(1≤j≤Q), print the response to the j-th query.\n\nSample Input 1\n\n5\n1 2 1\n1 3 1\n2 4 1\n3 5 1\n3 1\n2 4\n2 3\n4 5\n\nSample Output 1\n\n3\n2\n4\n\nThe shortest paths for the three queries are as follows:\n\nQuery 1: Vertex 2 → Vertex 1 → Vertex 2 → Vertex 4 : Length 1+1+1=3\n\nQuery 2: Vertex 2 → Vertex 1 → Vertex 3 : Length 1+1=2\n\nQuery 3: Vertex 4 → Vertex 2 → Vertex 1 → Vertex 3 → Vertex 5 : Length 1+1+1+1=4\n\nSample Input 2\n\n7\n1 2 1\n1 3 3\n1 4 5\n1 5 7\n1 6 9\n1 7 11\n3 2\n1 3\n4 5\n6 7\n\nSample Output 2\n\n5\n14\n22\n\nThe path for each query must pass Vertex K=2.\n\nSample Input 3\n\n10\n1 2 1000000000\n2 3 1000000000\n3 4 1000000000\n4 5 1000000000\n5 6 1000000000\n6 7 1000000000\n7 8 1000000000\n8 9 1000000000\n9 10 1000000000\n1 1\n9 10\n\nSample Output 3\n\n17000000000", "sample_input": "5\n1 2 1\n1 3 1\n2 4 1\n3 5 1\n3 1\n2 4\n2 3\n4 5\n"}, "reference_outputs": ["3\n2\n4\n"], "source_document_id": "p03634", "source_text": "Score : 400 points\n\nProblem Statement\n\nYou are given a tree with N vertices.\n\nHere, a tree is a kind of graph, and more specifically, a connected undirected graph with N-1 edges, where N is the number of its vertices.\n\nThe i-th edge (1≤i≤N-1) connects Vertices a_i and b_i, and has a length of c_i.\n\nYou are also given Q queries and an integer K. In the j-th query (1≤j≤Q):\n\nfind the length of the shortest path from Vertex x_j and Vertex y_j via Vertex K.\n\nConstraints\n\n3≤N≤10^5\n\n1≤a_i,b_i≤N (1≤i≤N-1)\n\n1≤c_i≤10^9 (1≤i≤N-1)\n\nThe given graph is a tree.\n\n1≤Q≤10^5\n\n1≤K≤N\n\n1≤x_j,y_j≤N (1≤j≤Q)\n\nx_j≠y_j (1≤j≤Q)\n\nx_j≠K,y_j≠K (1≤j≤Q)\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 b_1 c_1\n:\na_{N-1} b_{N-1} c_{N-1}\nQ K\nx_1 y_1\n:\nx_{Q} y_{Q}\n\nOutput\n\nPrint the responses to the queries in Q lines.\n\nIn the j-th line j(1≤j≤Q), print the response to the j-th query.\n\nSample Input 1\n\n5\n1 2 1\n1 3 1\n2 4 1\n3 5 1\n3 1\n2 4\n2 3\n4 5\n\nSample Output 1\n\n3\n2\n4\n\nThe shortest paths for the three queries are as follows:\n\nQuery 1: Vertex 2 → Vertex 1 → Vertex 2 → Vertex 4 : Length 1+1+1=3\n\nQuery 2: Vertex 2 → Vertex 1 → Vertex 3 : Length 1+1=2\n\nQuery 3: Vertex 4 → Vertex 2 → Vertex 1 → Vertex 3 → Vertex 5 : Length 1+1+1+1=4\n\nSample Input 2\n\n7\n1 2 1\n1 3 3\n1 4 5\n1 5 7\n1 6 9\n1 7 11\n3 2\n1 3\n4 5\n6 7\n\nSample Output 2\n\n5\n14\n22\n\nThe path for each query must pass Vertex K=2.\n\nSample Input 3\n\n10\n1 2 1000000000\n2 3 1000000000\n3 4 1000000000\n4 5 1000000000\n5 6 1000000000\n6 7 1000000000\n7 8 1000000000\n8 9 1000000000\n9 10 1000000000\n1 1\n9 10\n\nSample Output 3\n\n17000000000", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 179, "memory_kb": 26112}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s210315579", "group_id": "codeNet:p03635", "input_text": "open Printf\nopen Scanf\n\nlet () =\n let n, m = scanf \"%d %d \" (fun x y -> (x-1, y-1)) in\n printf \"%d\\n\" (n * m)\n", "language": "OCaml", "metadata": {"date": 1502120868, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03635.html", "problem_id": "p03635", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03635/input.txt", "sample_output_relpath": "derived/input_output/data/p03635/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03635/OCaml/s210315579.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s210315579", "user_id": "u388783188"}, "prompt_components": {"gold_output": "6\n", "input_to_evaluate": "open Printf\nopen Scanf\n\nlet () =\n let n, m = scanf \"%d %d \" (fun x y -> (x-1, y-1)) in\n printf \"%d\\n\" (n * m)\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nIn K-city, there are n streets running east-west, and m streets running north-south. Each street running east-west and each street running north-south cross each other. We will call the smallest area that is surrounded by four streets a block. How many blocks there are in K-city?\n\nConstraints\n\n2 ≤ n, m ≤ 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nn m\n\nOutput\n\nPrint the number of blocks in K-city.\n\nSample Input 1\n\n3 4\n\nSample Output 1\n\n6\n\nThere are six blocks, as shown below:\n\nSample Input 2\n\n2 2\n\nSample Output 2\n\n1\n\nThere are one block, as shown below:", "sample_input": "3 4\n"}, "reference_outputs": ["6\n"], "source_document_id": "p03635", "source_text": "Score : 100 points\n\nProblem Statement\n\nIn K-city, there are n streets running east-west, and m streets running north-south. Each street running east-west and each street running north-south cross each other. We will call the smallest area that is surrounded by four streets a block. How many blocks there are in K-city?\n\nConstraints\n\n2 ≤ n, m ≤ 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nn m\n\nOutput\n\nPrint the number of blocks in K-city.\n\nSample Input 1\n\n3 4\n\nSample Output 1\n\n6\n\nThere are six blocks, as shown below:\n\nSample Input 2\n\n2 2\n\nSample Output 2\n\n1\n\nThere are one block, as shown below:", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s907543537", "group_id": "codeNet:p03636", "input_text": "let () =\n Scanf.scanf \"%s\\n\" @@ fun s ->\n let len = String.length s in\n Printf.printf \"%c%s%c\\n\" s.[0] (string_of_int (len-2)) s.[len-1]", "language": "OCaml", "metadata": {"date": 1600790107, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p03636.html", "problem_id": "p03636", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03636/input.txt", "sample_output_relpath": "derived/input_output/data/p03636/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03636/OCaml/s907543537.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s907543537", "user_id": "u307426615"}, "prompt_components": {"gold_output": "i18n\n", "input_to_evaluate": "let () =\n Scanf.scanf \"%s\\n\" @@ fun s ->\n let len = String.length s in\n Printf.printf \"%c%s%c\\n\" s.[0] (string_of_int (len-2)) s.[len-1]", "problem_context": "Score : 200 points\n\nProblem Statement\n\nThe word internationalization is sometimes abbreviated to i18n.\nThis comes from the fact that there are 18 letters between the first i and the last n.\n\nYou are given a string s of length at least 3 consisting of lowercase English letters.\nAbbreviate s in the same way.\n\nConstraints\n\n3 ≤ |s| ≤ 100 (|s| denotes the length of s.)\n\ns consists of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\ns\n\nOutput\n\nPrint the abbreviation of s.\n\nSample Input 1\n\ninternationalization\n\nSample Output 1\n\ni18n\n\nSample Input 2\n\nsmiles\n\nSample Output 2\n\ns4s\n\nSample Input 3\n\nxyz\n\nSample Output 3\n\nx1z", "sample_input": "internationalization\n"}, "reference_outputs": ["i18n\n"], "source_document_id": "p03636", "source_text": "Score : 200 points\n\nProblem Statement\n\nThe word internationalization is sometimes abbreviated to i18n.\nThis comes from the fact that there are 18 letters between the first i and the last n.\n\nYou are given a string s of length at least 3 consisting of lowercase English letters.\nAbbreviate s in the same way.\n\nConstraints\n\n3 ≤ |s| ≤ 100 (|s| denotes the length of s.)\n\ns consists of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\ns\n\nOutput\n\nPrint the abbreviation of s.\n\nSample Input 1\n\ninternationalization\n\nSample Output 1\n\ni18n\n\nSample Input 2\n\nsmiles\n\nSample Output 2\n\ns4s\n\nSample Input 3\n\nxyz\n\nSample Output 3\n\nx1z", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 6, "memory_kb": 3788}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s443247714", "group_id": "codeNet:p03636", "input_text": "let () =\n let s = read_line () in\n let n = String.length s in\n Printf.printf \"%c%d%c\\n\" s.[0] (n - 2) s.[n-1]", "language": "OCaml", "metadata": {"date": 1502067869, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03636.html", "problem_id": "p03636", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03636/input.txt", "sample_output_relpath": "derived/input_output/data/p03636/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03636/OCaml/s443247714.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s443247714", "user_id": "u322845568"}, "prompt_components": {"gold_output": "i18n\n", "input_to_evaluate": "let () =\n let s = read_line () in\n let n = String.length s in\n Printf.printf \"%c%d%c\\n\" s.[0] (n - 2) s.[n-1]", "problem_context": "Score : 200 points\n\nProblem Statement\n\nThe word internationalization is sometimes abbreviated to i18n.\nThis comes from the fact that there are 18 letters between the first i and the last n.\n\nYou are given a string s of length at least 3 consisting of lowercase English letters.\nAbbreviate s in the same way.\n\nConstraints\n\n3 ≤ |s| ≤ 100 (|s| denotes the length of s.)\n\ns consists of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\ns\n\nOutput\n\nPrint the abbreviation of s.\n\nSample Input 1\n\ninternationalization\n\nSample Output 1\n\ni18n\n\nSample Input 2\n\nsmiles\n\nSample Output 2\n\ns4s\n\nSample Input 3\n\nxyz\n\nSample Output 3\n\nx1z", "sample_input": "internationalization\n"}, "reference_outputs": ["i18n\n"], "source_document_id": "p03636", "source_text": "Score : 200 points\n\nProblem Statement\n\nThe word internationalization is sometimes abbreviated to i18n.\nThis comes from the fact that there are 18 letters between the first i and the last n.\n\nYou are given a string s of length at least 3 consisting of lowercase English letters.\nAbbreviate s in the same way.\n\nConstraints\n\n3 ≤ |s| ≤ 100 (|s| denotes the length of s.)\n\ns consists of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\ns\n\nOutput\n\nPrint the abbreviation of s.\n\nSample Input 1\n\ninternationalization\n\nSample Output 1\n\ni18n\n\nSample Input 2\n\nsmiles\n\nSample Output 2\n\ns4s\n\nSample Input 3\n\nxyz\n\nSample Output 3\n\nx1z", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s405031788", "group_id": "codeNet:p03637", "input_text": "let () =\n let n = Scanf.scanf \"%d \" (fun n -> n) in\n let a = Array.init n (fun _ -> Scanf.scanf \"%d \" (fun i -> i)) in\n let (e, o) = Array.fold_left (fun (x, y) e -> if e mod 2 = 0 then (x + 1, y) else (x, y + 1)) (0, 0) a in\n print_endline (if e = 0 || e = o || e <= o + 2 then \"No\" else \"Yes\")", "language": "OCaml", "metadata": {"date": 1502069630, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03637.html", "problem_id": "p03637", "resource_group": "low_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/OCaml/s405031788.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s405031788", "user_id": "u322845568"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "let () =\n let n = Scanf.scanf \"%d \" (fun n -> n) in\n let a = Array.init n (fun _ -> Scanf.scanf \"%d \" (fun i -> i)) in\n let (e, o) = Array.fold_left (fun (x, y) e -> if e mod 2 = 0 then (x + 1, y) else (x, y + 1)) (0, 0) a in\n print_endline (if e = 0 || e = o || e <= o + 2 then \"No\" else \"Yes\")", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 34, "memory_kb": 5504}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s453211221", "group_id": "codeNet:p03638", "input_text": "open Scanf\nopen Printf\nopen String;;\n\n(* sscanf (read_line ()) \"%d %d\" \n (fun x y -> printf \"%d\" ((x-1)*(y-1)));; *)\n\n\n\n(* let abb s = (sub s 0 1) \n ^ (string_of_int (length s - 2))\n ^ (sub s (length s - 1) 1);;\n\nsscanf (read_line ()) \"%s\"\n (fun s -> printf \"%s\" (abb s));; *)\n\n(*\n\nlet judge l =\n let len = List.length l in\n let f l = List.fold_left \n (fun (x,l') y -> if y mod 4==0 then (x+1,l') else (x,y::l')) (0,[]) l in\n let g l = List.fold_left (fun x y -> x + if y mod 2!=0 then 1 else 0) 0 l in\n let (four, fourl) = f l in\n four >= len/2 || g fourl <= four\n\nlet usage n = \n let list = ref [] in\n for i = 1 to n do\n list := (scanf (if i < n then \"%d \" else \"%d\") (fun x -> x))::!list\n done; !list;;\n\nsscanf (read_line ()) \"%d\" \n (fun x -> printf \"%s\" (if judge (usage x) then \"Yes\" else \"No\"));;\n\n*)\n\nlet usage n = \n let list = ref [] in\n for i = 1 to n do\n list := (scanf (if i < n then \"%d \" else \"%d\") (fun x -> x))::!list\n done; List.rev !list;;\n\nlet rec print_list = function\n [x] -> print_endline (string_of_int x)\n | x::xs -> print_string ((string_of_int x) ^ \" \"); print_list xs\n\nand print_ll = function\n [] -> ()\n | x::xs -> print_list x; print_ll xs;;\n\nlet rec make_list ini = function\n 0 -> []\n | n -> ini :: make_list ini (n-1);;\n\nlet make_line l =\n let rec make col = function\n [] -> []\n | x::xs -> make_list col x :: make (col+1) xs\n in List.concat (make 1 l);;\n\nlet rec take n = function\n [] -> []\n | x :: rest when n = 0 -> [] \n | x :: rest -> x :: take (n-1) rest;;\n\nlet rec drop n = function\n [] -> []\n | x :: rest when n <= 0 -> x :: drop (n-1) rest \n | x :: rest -> drop (n-1) rest;;\n\nlet rec proc m n = function\n _ when n <= 0 || m <= 0 -> []\n | [] -> []\n | l when m mod 2 = 0 -> List.rev (take n l) :: proc (m-1) n (drop n l)\n | l when m mod 2 = 1 -> take n l :: proc (m-1) n (drop n l);;\n\nsscanf (read_line ()) \"%d %d\" (fun m n ->\n scanf \"%d\" (fun x -> print_ll (proc m n (usage x))));;\n\n\n\n\n", "language": "OCaml", "metadata": {"date": 1503960949, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03638.html", "problem_id": "p03638", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03638/input.txt", "sample_output_relpath": "derived/input_output/data/p03638/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03638/OCaml/s453211221.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s453211221", "user_id": "u470717435"}, "prompt_components": {"gold_output": "1 1\n2 3\n", "input_to_evaluate": "open Scanf\nopen Printf\nopen String;;\n\n(* sscanf (read_line ()) \"%d %d\" \n (fun x y -> printf \"%d\" ((x-1)*(y-1)));; *)\n\n\n\n(* let abb s = (sub s 0 1) \n ^ (string_of_int (length s - 2))\n ^ (sub s (length s - 1) 1);;\n\nsscanf (read_line ()) \"%s\"\n (fun s -> printf \"%s\" (abb s));; *)\n\n(*\n\nlet judge l =\n let len = List.length l in\n let f l = List.fold_left \n (fun (x,l') y -> if y mod 4==0 then (x+1,l') else (x,y::l')) (0,[]) l in\n let g l = List.fold_left (fun x y -> x + if y mod 2!=0 then 1 else 0) 0 l in\n let (four, fourl) = f l in\n four >= len/2 || g fourl <= four\n\nlet usage n = \n let list = ref [] in\n for i = 1 to n do\n list := (scanf (if i < n then \"%d \" else \"%d\") (fun x -> x))::!list\n done; !list;;\n\nsscanf (read_line ()) \"%d\" \n (fun x -> printf \"%s\" (if judge (usage x) then \"Yes\" else \"No\"));;\n\n*)\n\nlet usage n = \n let list = ref [] in\n for i = 1 to n do\n list := (scanf (if i < n then \"%d \" else \"%d\") (fun x -> x))::!list\n done; List.rev !list;;\n\nlet rec print_list = function\n [x] -> print_endline (string_of_int x)\n | x::xs -> print_string ((string_of_int x) ^ \" \"); print_list xs\n\nand print_ll = function\n [] -> ()\n | x::xs -> print_list x; print_ll xs;;\n\nlet rec make_list ini = function\n 0 -> []\n | n -> ini :: make_list ini (n-1);;\n\nlet make_line l =\n let rec make col = function\n [] -> []\n | x::xs -> make_list col x :: make (col+1) xs\n in List.concat (make 1 l);;\n\nlet rec take n = function\n [] -> []\n | x :: rest when n = 0 -> [] \n | x :: rest -> x :: take (n-1) rest;;\n\nlet rec drop n = function\n [] -> []\n | x :: rest when n <= 0 -> x :: drop (n-1) rest \n | x :: rest -> drop (n-1) rest;;\n\nlet rec proc m n = function\n _ when n <= 0 || m <= 0 -> []\n | [] -> []\n | l when m mod 2 = 0 -> List.rev (take n l) :: proc (m-1) n (drop n l)\n | l when m mod 2 = 1 -> take n l :: proc (m-1) n (drop n l);;\n\nsscanf (read_line ()) \"%d %d\" (fun m n ->\n scanf \"%d\" (fun x -> print_ll (proc m n (usage x))));;\n\n\n\n\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nWe have a grid with H rows and W columns of squares.\nSnuke is painting these squares in colors 1, 2, ..., N.\nHere, the following conditions should be satisfied:\n\nFor each i (1 ≤ i ≤ N), there are exactly a_i squares painted in Color i. Here, a_1 + a_2 + ... + a_N = H W.\n\nFor each i (1 ≤ i ≤ N), the squares painted in Color i are 4-connected. That is, every square painted in Color i can be reached from every square painted in Color i by repeatedly traveling to a horizontally or vertically adjacent square painted in Color i.\n\nFind a way to paint the squares so that the conditions are satisfied.\nIt can be shown that a solution always exists.\n\nConstraints\n\n1 ≤ H, W ≤ 100\n\n1 ≤ N ≤ H W\n\na_i ≥ 1\n\na_1 + a_2 + ... + a_N = H W\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\nN\na_1 a_2 ... a_N\n\nOutput\n\nPrint one way to paint the squares that satisfies the conditions.\nOutput in the following format:\n\nc_{1 1} ... c_{1 W}\n:\nc_{H 1} ... c_{H W}\n\nHere, c_{i j} is the color of the square at the i-th row from the top and j-th column from the left.\n\nSample Input 1\n\n2 2\n3\n2 1 1\n\nSample Output 1\n\n1 1\n2 3\n\nBelow is an example of an invalid solution:\n\n1 2\n3 1\n\nThis is because the squares painted in Color 1 are not 4-connected.\n\nSample Input 2\n\n3 5\n5\n1 2 3 4 5\n\nSample Output 2\n\n1 4 4 4 3\n2 5 4 5 3\n2 5 5 5 3\n\nSample Input 3\n\n1 1\n1\n1\n\nSample Output 3\n\n1", "sample_input": "2 2\n3\n2 1 1\n"}, "reference_outputs": ["1 1\n2 3\n"], "source_document_id": "p03638", "source_text": "Score : 400 points\n\nProblem Statement\n\nWe have a grid with H rows and W columns of squares.\nSnuke is painting these squares in colors 1, 2, ..., N.\nHere, the following conditions should be satisfied:\n\nFor each i (1 ≤ i ≤ N), there are exactly a_i squares painted in Color i. Here, a_1 + a_2 + ... + a_N = H W.\n\nFor each i (1 ≤ i ≤ N), the squares painted in Color i are 4-connected. That is, every square painted in Color i can be reached from every square painted in Color i by repeatedly traveling to a horizontally or vertically adjacent square painted in Color i.\n\nFind a way to paint the squares so that the conditions are satisfied.\nIt can be shown that a solution always exists.\n\nConstraints\n\n1 ≤ H, W ≤ 100\n\n1 ≤ N ≤ H W\n\na_i ≥ 1\n\na_1 + a_2 + ... + a_N = H W\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\nN\na_1 a_2 ... a_N\n\nOutput\n\nPrint one way to paint the squares that satisfies the conditions.\nOutput in the following format:\n\nc_{1 1} ... c_{1 W}\n:\nc_{H 1} ... c_{H W}\n\nHere, c_{i j} is the color of the square at the i-th row from the top and j-th column from the left.\n\nSample Input 1\n\n2 2\n3\n2 1 1\n\nSample Output 1\n\n1 1\n2 3\n\nBelow is an example of an invalid solution:\n\n1 2\n3 1\n\nThis is because the squares painted in Color 1 are not 4-connected.\n\nSample Input 2\n\n3 5\n5\n1 2 3 4 5\n\nSample Output 2\n\n1 4 4 4 3\n2 5 4 5 3\n2 5 5 5 3\n\nSample Input 3\n\n1 1\n1\n1\n\nSample Output 3\n\n1", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2031, "cpu_time_ms": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s026673214", "group_id": "codeNet:p03640", "input_text": "let rec foldn f a = function\n | 0 -> a\n | n -> foldn f (f a) (n - 1)\n\nlet () =\n let h, w = Scanf.scanf \"%d %d\\n\" (fun h w -> h, w) in\n let n = Scanf.scanf \"%d\\n\" (fun n -> n) in\n let as_ = Array.init n (fun i -> Scanf.scanf \"%d \" (fun a -> (i + 1, a))) in\n Array.fold_left (fun (acc, current, current_sum) (i, a) ->\n let c = Char.chr (i + Char.code '0') in\n if w <= current_sum + a then\n foldn (fun xs -> [String.make w c] :: xs)\n ((String.make (w - current_sum) c :: current) :: acc)\n ((current_sum + a) / w - 1), [String.make (current_sum + a - w) c], (current_sum + a - w) mod w\n else (acc, String.make a c :: current, a + current_sum)) ([], [], 0) as_\n |> (fun (acc, _, _) -> acc)\n |> List.fold_left (fun (acc, b) a -> ((if b then List.rev a else a) :: acc, not b)) ([], true)\n |> fst\n |> List.map (String.concat \"\")\n |> List.iter print_endline", "language": "OCaml", "metadata": {"date": 1510469591, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03640.html", "problem_id": "p03640", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03640/input.txt", "sample_output_relpath": "derived/input_output/data/p03640/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03640/OCaml/s026673214.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s026673214", "user_id": "u504158101"}, "prompt_components": {"gold_output": "1 1\n2 3\n", "input_to_evaluate": "let rec foldn f a = function\n | 0 -> a\n | n -> foldn f (f a) (n - 1)\n\nlet () =\n let h, w = Scanf.scanf \"%d %d\\n\" (fun h w -> h, w) in\n let n = Scanf.scanf \"%d\\n\" (fun n -> n) in\n let as_ = Array.init n (fun i -> Scanf.scanf \"%d \" (fun a -> (i + 1, a))) in\n Array.fold_left (fun (acc, current, current_sum) (i, a) ->\n let c = Char.chr (i + Char.code '0') in\n if w <= current_sum + a then\n foldn (fun xs -> [String.make w c] :: xs)\n ((String.make (w - current_sum) c :: current) :: acc)\n ((current_sum + a) / w - 1), [String.make (current_sum + a - w) c], (current_sum + a - w) mod w\n else (acc, String.make a c :: current, a + current_sum)) ([], [], 0) as_\n |> (fun (acc, _, _) -> acc)\n |> List.fold_left (fun (acc, b) a -> ((if b then List.rev a else a) :: acc, not b)) ([], true)\n |> fst\n |> List.map (String.concat \"\")\n |> List.iter print_endline", "problem_context": "Score : 400 points\n\nProblem Statement\n\nWe have a grid with H rows and W columns of squares.\nSnuke is painting these squares in colors 1, 2, ..., N.\nHere, the following conditions should be satisfied:\n\nFor each i (1 ≤ i ≤ N), there are exactly a_i squares painted in Color i. Here, a_1 + a_2 + ... + a_N = H W.\n\nFor each i (1 ≤ i ≤ N), the squares painted in Color i are 4-connected. That is, every square painted in Color i can be reached from every square painted in Color i by repeatedly traveling to a horizontally or vertically adjacent square painted in Color i.\n\nFind a way to paint the squares so that the conditions are satisfied.\nIt can be shown that a solution always exists.\n\nConstraints\n\n1 ≤ H, W ≤ 100\n\n1 ≤ N ≤ H W\n\na_i ≥ 1\n\na_1 + a_2 + ... + a_N = H W\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\nN\na_1 a_2 ... a_N\n\nOutput\n\nPrint one way to paint the squares that satisfies the conditions.\nOutput in the following format:\n\nc_{1 1} ... c_{1 W}\n:\nc_{H 1} ... c_{H W}\n\nHere, c_{i j} is the color of the square at the i-th row from the top and j-th column from the left.\n\nSample Input 1\n\n2 2\n3\n2 1 1\n\nSample Output 1\n\n1 1\n2 3\n\nBelow is an example of an invalid solution:\n\n1 2\n3 1\n\nThis is because the squares painted in Color 1 are not 4-connected.\n\nSample Input 2\n\n3 5\n5\n1 2 3 4 5\n\nSample Output 2\n\n1 4 4 4 3\n2 5 4 5 3\n2 5 5 5 3\n\nSample Input 3\n\n1 1\n1\n1\n\nSample Output 3\n\n1", "sample_input": "2 2\n3\n2 1 1\n"}, "reference_outputs": ["1 1\n2 3\n"], "source_document_id": "p03640", "source_text": "Score : 400 points\n\nProblem Statement\n\nWe have a grid with H rows and W columns of squares.\nSnuke is painting these squares in colors 1, 2, ..., N.\nHere, the following conditions should be satisfied:\n\nFor each i (1 ≤ i ≤ N), there are exactly a_i squares painted in Color i. Here, a_1 + a_2 + ... + a_N = H W.\n\nFor each i (1 ≤ i ≤ N), the squares painted in Color i are 4-connected. That is, every square painted in Color i can be reached from every square painted in Color i by repeatedly traveling to a horizontally or vertically adjacent square painted in Color i.\n\nFind a way to paint the squares so that the conditions are satisfied.\nIt can be shown that a solution always exists.\n\nConstraints\n\n1 ≤ H, W ≤ 100\n\n1 ≤ N ≤ H W\n\na_i ≥ 1\n\na_1 + a_2 + ... + a_N = H W\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\nN\na_1 a_2 ... a_N\n\nOutput\n\nPrint one way to paint the squares that satisfies the conditions.\nOutput in the following format:\n\nc_{1 1} ... c_{1 W}\n:\nc_{H 1} ... c_{H W}\n\nHere, c_{i j} is the color of the square at the i-th row from the top and j-th column from the left.\n\nSample Input 1\n\n2 2\n3\n2 1 1\n\nSample Output 1\n\n1 1\n2 3\n\nBelow is an example of an invalid solution:\n\n1 2\n3 1\n\nThis is because the squares painted in Color 1 are not 4-connected.\n\nSample Input 2\n\n3 5\n5\n1 2 3 4 5\n\nSample Output 2\n\n1 4 4 4 3\n2 5 4 5 3\n2 5 5 5 3\n\nSample Input 3\n\n1 1\n1\n1\n\nSample Output 3\n\n1", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 887, "cpu_time_ms": 4, "memory_kb": 4736}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s762627422", "group_id": "codeNet:p03643", "input_text": "let () = Printf.printf \"ABC%d\\n\" (read_int ())", "language": "OCaml", "metadata": {"date": 1524603954, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03643.html", "problem_id": "p03643", "resource_group": "low_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/OCaml/s762627422.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s762627422", "user_id": "u987869509"}, "prompt_components": {"gold_output": "ABC100\n", "input_to_evaluate": "let () = Printf.printf \"ABC%d\\n\" (read_int ())", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s880317581", "group_id": "codeNet:p03643", "input_text": "let () = read_int () |> Printf.printf \"ABC%d\\n\"", "language": "OCaml", "metadata": {"date": 1501376512, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03643.html", "problem_id": "p03643", "resource_group": "low_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/OCaml/s880317581.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s880317581", "user_id": "u322845568"}, "prompt_components": {"gold_output": "ABC100\n", "input_to_evaluate": "let () = read_int () |> Printf.printf \"ABC%d\\n\"", "problem_context": "Score : 100 points\n\nProblem Statement\n\nThis contest, AtCoder Beginner Contest, is abbreviated as ABC.\n\nWhen we refer to a specific round of ABC, a three-digit number is appended after ABC. For example, ABC680 is the 680th round of ABC.\n\nWhat is the abbreviation for the N-th round of ABC? Write a program to output the answer.\n\nConstraints\n\n100 ≤ N ≤ 999\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the abbreviation for the N-th round of ABC.\n\nSample Input 1\n\n100\n\nSample Output 1\n\nABC100\n\nThe 100th round of ABC is ABC100.\n\nSample Input 2\n\n425\n\nSample Output 2\n\nABC425\n\nSample Input 3\n\n999\n\nSample Output 3\n\nABC999", "sample_input": "100\n"}, "reference_outputs": ["ABC100\n"], "source_document_id": "p03643", "source_text": "Score : 100 points\n\nProblem Statement\n\nThis contest, AtCoder Beginner Contest, is abbreviated as ABC.\n\nWhen we refer to a specific round of ABC, a three-digit number is appended after ABC. For example, ABC680 is the 680th round of ABC.\n\nWhat is the abbreviation for the N-th round of ABC? Write a program to output the answer.\n\nConstraints\n\n100 ≤ N ≤ 999\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the abbreviation for the N-th round of ABC.\n\nSample Input 1\n\n100\n\nSample Output 1\n\nABC100\n\nThe 100th round of ABC is ABC100.\n\nSample Input 2\n\n425\n\nSample Output 2\n\nABC425\n\nSample Input 3\n\n999\n\nSample Output 3\n\nABC999", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 2432}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s213827843", "group_id": "codeNet:p03644", "input_text": "let () =\n let n = read_int () in\n let rec doit x =\n let y = 2 * x in\n if y > n then x\n else doit y in\n doit 1 |> Printf.printf \"%d\\n\"", "language": "OCaml", "metadata": {"date": 1501450286, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03644.html", "problem_id": "p03644", "resource_group": "low_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/OCaml/s213827843.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s213827843", "user_id": "u322845568"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "let () =\n let n = read_int () in\n let rec doit x =\n let y = 2 * x in\n if y > n then x\n else doit y in\n doit 1 |> Printf.printf \"%d\\n\"", "problem_context": "Score : 200 points\n\nProblem Statement\n\nTakahashi loves numbers divisible by 2.\n\nYou are given a positive integer N. Among the integers between 1 and N (inclusive), find the one that can be divisible by 2 for the most number of times. The solution is always unique.\n\nHere, the number of times an integer can be divisible by 2, is how many times the integer can be divided by 2 without remainder.\n\nFor example,\n\n6 can be divided by 2 once: 6 -> 3.\n\n8 can be divided by 2 three times: 8 -> 4 -> 2 -> 1.\n\n3 can be divided by 2 zero times.\n\nConstraints\n\n1 ≤ N ≤ 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n7\n\nSample Output 1\n\n4\n\n4 can be divided by 2 twice, which is the most number of times among 1, 2, ..., 7.\n\nSample Input 2\n\n32\n\nSample Output 2\n\n32\n\nSample Input 3\n\n1\n\nSample Output 3\n\n1\n\nSample Input 4\n\n100\n\nSample Output 4\n\n64", "sample_input": "7\n"}, "reference_outputs": ["4\n"], "source_document_id": "p03644", "source_text": "Score : 200 points\n\nProblem Statement\n\nTakahashi loves numbers divisible by 2.\n\nYou are given a positive integer N. Among the integers between 1 and N (inclusive), find the one that can be divisible by 2 for the most number of times. The solution is always unique.\n\nHere, the number of times an integer can be divisible by 2, is how many times the integer can be divided by 2 without remainder.\n\nFor example,\n\n6 can be divided by 2 once: 6 -> 3.\n\n8 can be divided by 2 three times: 8 -> 4 -> 2 -> 1.\n\n3 can be divided by 2 zero times.\n\nConstraints\n\n1 ≤ N ≤ 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n7\n\nSample Output 1\n\n4\n\n4 can be divided by 2 twice, which is the most number of times among 1, 2, ..., 7.\n\nSample Input 2\n\n32\n\nSample Output 2\n\n32\n\nSample Input 3\n\n1\n\nSample Output 3\n\n1\n\nSample Input 4\n\n100\n\nSample Output 4\n\n64", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s221679763", "group_id": "codeNet:p03645", "input_text": "module IntSet = Set.Make (struct\n type t = int\n let compare = (-)\nend)\n\nlet read_ns () = Scanf.scanf \"%d %d \" (fun x y -> (x, y))\n\nlet () =\n let (n, m) = read_ns () in\n let g = Array.make n IntSet.empty in\n for _ = 1 to m do\n let (a, b) = read_ns () in\n let (a, b) = (a - 1, b - 1) in\n g.(a) <- IntSet.add b g.(a);\n g.(b) <- IntSet.add a g.(b);\n done;\n print_endline\n (if IntSet.is_empty (IntSet.inter g.(0) g.(n - 1)) then \"IMPOSSIBLE\"\n else \"POSSIBLE\")", "language": "OCaml", "metadata": {"date": 1501435880, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03645.html", "problem_id": "p03645", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03645/input.txt", "sample_output_relpath": "derived/input_output/data/p03645/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03645/OCaml/s221679763.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s221679763", "user_id": "u322845568"}, "prompt_components": {"gold_output": "POSSIBLE\n", "input_to_evaluate": "module IntSet = Set.Make (struct\n type t = int\n let compare = (-)\nend)\n\nlet read_ns () = Scanf.scanf \"%d %d \" (fun x y -> (x, y))\n\nlet () =\n let (n, m) = read_ns () in\n let g = Array.make n IntSet.empty in\n for _ = 1 to m do\n let (a, b) = read_ns () in\n let (a, b) = (a - 1, b - 1) in\n g.(a) <- IntSet.add b g.(a);\n g.(b) <- IntSet.add a g.(b);\n done;\n print_endline\n (if IntSet.is_empty (IntSet.inter g.(0) g.(n - 1)) then \"IMPOSSIBLE\"\n else \"POSSIBLE\")", "problem_context": "Score : 300 points\n\nProblem Statement\n\nIn Takahashi Kingdom, there is an archipelago of N islands, called Takahashi Islands.\nFor convenience, we will call them Island 1, Island 2, ..., Island N.\n\nThere are M kinds of regular boat services between these islands.\nEach service connects two islands. The i-th service connects Island a_i and Island b_i.\n\nCat Snuke is on Island 1 now, and wants to go to Island N.\nHowever, it turned out that there is no boat service from Island 1 to Island N, so he wants to know whether it is possible to go to Island N by using two boat services.\n\nHelp him.\n\nConstraints\n\n3 ≤ N ≤ 200 000\n\n1 ≤ M ≤ 200 000\n\n1 ≤ a_i < b_i ≤ N\n\n(a_i, b_i) \\neq (1, N)\n\nIf i \\neq j, (a_i, b_i) \\neq (a_j, b_j).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\na_1 b_1\na_2 b_2\n:\na_M b_M\n\nOutput\n\nIf it is possible to go to Island N by using two boat services, print POSSIBLE; otherwise, print IMPOSSIBLE.\n\nSample Input 1\n\n3 2\n1 2\n2 3\n\nSample Output 1\n\nPOSSIBLE\n\nSample Input 2\n\n4 3\n1 2\n2 3\n3 4\n\nSample Output 2\n\nIMPOSSIBLE\n\nYou have to use three boat services to get to Island 4.\n\nSample Input 3\n\n100000 1\n1 99999\n\nSample Output 3\n\nIMPOSSIBLE\n\nSample Input 4\n\n5 5\n1 3\n4 5\n2 3\n2 4\n1 4\n\nSample Output 4\n\nPOSSIBLE\n\nYou can get to Island 5 by using two boat services: Island 1 -> Island 4 -> Island 5.", "sample_input": "3 2\n1 2\n2 3\n"}, "reference_outputs": ["POSSIBLE\n"], "source_document_id": "p03645", "source_text": "Score : 300 points\n\nProblem Statement\n\nIn Takahashi Kingdom, there is an archipelago of N islands, called Takahashi Islands.\nFor convenience, we will call them Island 1, Island 2, ..., Island N.\n\nThere are M kinds of regular boat services between these islands.\nEach service connects two islands. The i-th service connects Island a_i and Island b_i.\n\nCat Snuke is on Island 1 now, and wants to go to Island N.\nHowever, it turned out that there is no boat service from Island 1 to Island N, so he wants to know whether it is possible to go to Island N by using two boat services.\n\nHelp him.\n\nConstraints\n\n3 ≤ N ≤ 200 000\n\n1 ≤ M ≤ 200 000\n\n1 ≤ a_i < b_i ≤ N\n\n(a_i, b_i) \\neq (1, N)\n\nIf i \\neq j, (a_i, b_i) \\neq (a_j, b_j).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\na_1 b_1\na_2 b_2\n:\na_M b_M\n\nOutput\n\nIf it is possible to go to Island N by using two boat services, print POSSIBLE; otherwise, print IMPOSSIBLE.\n\nSample Input 1\n\n3 2\n1 2\n2 3\n\nSample Output 1\n\nPOSSIBLE\n\nSample Input 2\n\n4 3\n1 2\n2 3\n3 4\n\nSample Output 2\n\nIMPOSSIBLE\n\nYou have to use three boat services to get to Island 4.\n\nSample Input 3\n\n100000 1\n1 99999\n\nSample Output 3\n\nIMPOSSIBLE\n\nSample Input 4\n\n5 5\n1 3\n4 5\n2 3\n2 4\n1 4\n\nSample Output 4\n\nPOSSIBLE\n\nYou can get to Island 5 by using two boat services: Island 1 -> Island 4 -> Island 5.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 480, "cpu_time_ms": 355, "memory_kb": 31744}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s641656662", "group_id": "codeNet:p03645", "input_text": "let read_ns () = Scanf.scanf \"%d %d \" (fun x y -> (x, y))\n\nlet bfs g goal =\n let que = Queue.create () in\n Queue.push 0 que;\n let rec doit depth reach_p =\n if reach_p && (depth = 2 || depth = 0) then \"POSSIBLE\"\n else if Queue.is_empty que || depth > 2 then \"IMPOSSIBLE\"\n else begin\n let n = Queue.pop que in\n let p = ref false in\n List.iter (fun e ->\n Queue.push e que; if e = goal then p := true)\n g.(n);\n doit (depth + 1) !p\n end in\n doit 0 false\n\nlet () =\n let (n, m) = read_ns () in\n let g = Array.make n [] in\n for _ = 0 to m - 1 do\n let (a, b) = read_ns () in\n let (a, b) = (a - 1, b - 1) in\n g.(a) <- b :: g.(a);\n g.(b) <- a :: g.(b);\n done;\n bfs g (n - 1) |> print_endline", "language": "OCaml", "metadata": {"date": 1501380266, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03645.html", "problem_id": "p03645", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03645/input.txt", "sample_output_relpath": "derived/input_output/data/p03645/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03645/OCaml/s641656662.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s641656662", "user_id": "u322845568"}, "prompt_components": {"gold_output": "POSSIBLE\n", "input_to_evaluate": "let read_ns () = Scanf.scanf \"%d %d \" (fun x y -> (x, y))\n\nlet bfs g goal =\n let que = Queue.create () in\n Queue.push 0 que;\n let rec doit depth reach_p =\n if reach_p && (depth = 2 || depth = 0) then \"POSSIBLE\"\n else if Queue.is_empty que || depth > 2 then \"IMPOSSIBLE\"\n else begin\n let n = Queue.pop que in\n let p = ref false in\n List.iter (fun e ->\n Queue.push e que; if e = goal then p := true)\n g.(n);\n doit (depth + 1) !p\n end in\n doit 0 false\n\nlet () =\n let (n, m) = read_ns () in\n let g = Array.make n [] in\n for _ = 0 to m - 1 do\n let (a, b) = read_ns () in\n let (a, b) = (a - 1, b - 1) in\n g.(a) <- b :: g.(a);\n g.(b) <- a :: g.(b);\n done;\n bfs g (n - 1) |> print_endline", "problem_context": "Score : 300 points\n\nProblem Statement\n\nIn Takahashi Kingdom, there is an archipelago of N islands, called Takahashi Islands.\nFor convenience, we will call them Island 1, Island 2, ..., Island N.\n\nThere are M kinds of regular boat services between these islands.\nEach service connects two islands. The i-th service connects Island a_i and Island b_i.\n\nCat Snuke is on Island 1 now, and wants to go to Island N.\nHowever, it turned out that there is no boat service from Island 1 to Island N, so he wants to know whether it is possible to go to Island N by using two boat services.\n\nHelp him.\n\nConstraints\n\n3 ≤ N ≤ 200 000\n\n1 ≤ M ≤ 200 000\n\n1 ≤ a_i < b_i ≤ N\n\n(a_i, b_i) \\neq (1, N)\n\nIf i \\neq j, (a_i, b_i) \\neq (a_j, b_j).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\na_1 b_1\na_2 b_2\n:\na_M b_M\n\nOutput\n\nIf it is possible to go to Island N by using two boat services, print POSSIBLE; otherwise, print IMPOSSIBLE.\n\nSample Input 1\n\n3 2\n1 2\n2 3\n\nSample Output 1\n\nPOSSIBLE\n\nSample Input 2\n\n4 3\n1 2\n2 3\n3 4\n\nSample Output 2\n\nIMPOSSIBLE\n\nYou have to use three boat services to get to Island 4.\n\nSample Input 3\n\n100000 1\n1 99999\n\nSample Output 3\n\nIMPOSSIBLE\n\nSample Input 4\n\n5 5\n1 3\n4 5\n2 3\n2 4\n1 4\n\nSample Output 4\n\nPOSSIBLE\n\nYou can get to Island 5 by using two boat services: Island 1 -> Island 4 -> Island 5.", "sample_input": "3 2\n1 2\n2 3\n"}, "reference_outputs": ["POSSIBLE\n"], "source_document_id": "p03645", "source_text": "Score : 300 points\n\nProblem Statement\n\nIn Takahashi Kingdom, there is an archipelago of N islands, called Takahashi Islands.\nFor convenience, we will call them Island 1, Island 2, ..., Island N.\n\nThere are M kinds of regular boat services between these islands.\nEach service connects two islands. The i-th service connects Island a_i and Island b_i.\n\nCat Snuke is on Island 1 now, and wants to go to Island N.\nHowever, it turned out that there is no boat service from Island 1 to Island N, so he wants to know whether it is possible to go to Island N by using two boat services.\n\nHelp him.\n\nConstraints\n\n3 ≤ N ≤ 200 000\n\n1 ≤ M ≤ 200 000\n\n1 ≤ a_i < b_i ≤ N\n\n(a_i, b_i) \\neq (1, N)\n\nIf i \\neq j, (a_i, b_i) \\neq (a_j, b_j).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\na_1 b_1\na_2 b_2\n:\na_M b_M\n\nOutput\n\nIf it is possible to go to Island N by using two boat services, print POSSIBLE; otherwise, print IMPOSSIBLE.\n\nSample Input 1\n\n3 2\n1 2\n2 3\n\nSample Output 1\n\nPOSSIBLE\n\nSample Input 2\n\n4 3\n1 2\n2 3\n3 4\n\nSample Output 2\n\nIMPOSSIBLE\n\nYou have to use three boat services to get to Island 4.\n\nSample Input 3\n\n100000 1\n1 99999\n\nSample Output 3\n\nIMPOSSIBLE\n\nSample Input 4\n\n5 5\n1 3\n4 5\n2 3\n2 4\n1 4\n\nSample Output 4\n\nPOSSIBLE\n\nYou can get to Island 5 by using two boat services: Island 1 -> Island 4 -> Island 5.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 747, "cpu_time_ms": 170, "memory_kb": 16128}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s172608746", "group_id": "codeNet:p03647", "input_text": "Scanf.scanf \"%d %d\" (fun n m ->\n let s = Array.make 210000 0 in\n for i = 1 to m do\n Scanf.scanf \" %d %d\" (fun a b ->\n if a = 1 then s.(b) <- s.(b) lor 1;\n if b = 1 then s.(a) <- s.(a) lor 1;\n if a = n then s.(b) <- s.(b) lor 2;\n if b = n then s.(a) <- s.(a) lor 2;\n )\n done;\n let a = Array.fold_left (fun acc v -> if v = 3 then true else acc) false s in\n print_endline @@ if a then \"POSSIBLE\" else \"IMPOSSIBLE\"\n)", "language": "OCaml", "metadata": {"date": 1592620240, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p03647.html", "problem_id": "p03647", "resource_group": "low_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/OCaml/s172608746.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s172608746", "user_id": "u342443598"}, "prompt_components": {"gold_output": "POSSIBLE\n", "input_to_evaluate": "Scanf.scanf \"%d %d\" (fun n m ->\n let s = Array.make 210000 0 in\n for i = 1 to m do\n Scanf.scanf \" %d %d\" (fun a b ->\n if a = 1 then s.(b) <- s.(b) lor 1;\n if b = 1 then s.(a) <- s.(a) lor 1;\n if a = n then s.(b) <- s.(b) lor 2;\n if b = n then s.(a) <- s.(a) lor 2;\n )\n done;\n let a = Array.fold_left (fun acc v -> if v = 3 then true else acc) false s in\n print_endline @@ if a then \"POSSIBLE\" else \"IMPOSSIBLE\"\n)", "problem_context": "Score : 300 points\n\nProblem Statement\n\nIn Takahashi Kingdom, there is an archipelago of N islands, called Takahashi Islands.\nFor convenience, we will call them Island 1, Island 2, ..., Island N.\n\nThere are M kinds of regular boat services between these islands.\nEach service connects two islands. The i-th service connects Island a_i and Island b_i.\n\nCat Snuke is on Island 1 now, and wants to go to Island N.\nHowever, it turned out that there is no boat service from Island 1 to Island N, so he wants to know whether it is possible to go to Island N by using two boat services.\n\nHelp him.\n\nConstraints\n\n3 ≤ N ≤ 200 000\n\n1 ≤ M ≤ 200 000\n\n1 ≤ a_i < b_i ≤ N\n\n(a_i, b_i) \\neq (1, N)\n\nIf i \\neq j, (a_i, b_i) \\neq (a_j, b_j).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\na_1 b_1\na_2 b_2\n:\na_M b_M\n\nOutput\n\nIf it is possible to go to Island N by using two boat services, print POSSIBLE; otherwise, print IMPOSSIBLE.\n\nSample Input 1\n\n3 2\n1 2\n2 3\n\nSample Output 1\n\nPOSSIBLE\n\nSample Input 2\n\n4 3\n1 2\n2 3\n3 4\n\nSample Output 2\n\nIMPOSSIBLE\n\nYou have to use three boat services to get to Island 4.\n\nSample Input 3\n\n100000 1\n1 99999\n\nSample Output 3\n\nIMPOSSIBLE\n\nSample Input 4\n\n5 5\n1 3\n4 5\n2 3\n2 4\n1 4\n\nSample Output 4\n\nPOSSIBLE\n\nYou can get to Island 5 by using two boat services: Island 1 -> Island 4 -> Island 5.", "sample_input": "3 2\n1 2\n2 3\n"}, "reference_outputs": ["POSSIBLE\n"], "source_document_id": "p03647", "source_text": "Score : 300 points\n\nProblem Statement\n\nIn Takahashi Kingdom, there is an archipelago of N islands, called Takahashi Islands.\nFor convenience, we will call them Island 1, Island 2, ..., Island N.\n\nThere are M kinds of regular boat services between these islands.\nEach service connects two islands. The i-th service connects Island a_i and Island b_i.\n\nCat Snuke is on Island 1 now, and wants to go to Island N.\nHowever, it turned out that there is no boat service from Island 1 to Island N, so he wants to know whether it is possible to go to Island N by using two boat services.\n\nHelp him.\n\nConstraints\n\n3 ≤ N ≤ 200 000\n\n1 ≤ M ≤ 200 000\n\n1 ≤ a_i < b_i ≤ N\n\n(a_i, b_i) \\neq (1, N)\n\nIf i \\neq j, (a_i, b_i) \\neq (a_j, b_j).\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\na_1 b_1\na_2 b_2\n:\na_M b_M\n\nOutput\n\nIf it is possible to go to Island N by using two boat services, print POSSIBLE; otherwise, print IMPOSSIBLE.\n\nSample Input 1\n\n3 2\n1 2\n2 3\n\nSample Output 1\n\nPOSSIBLE\n\nSample Input 2\n\n4 3\n1 2\n2 3\n3 4\n\nSample Output 2\n\nIMPOSSIBLE\n\nYou have to use three boat services to get to Island 4.\n\nSample Input 3\n\n100000 1\n1 99999\n\nSample Output 3\n\nIMPOSSIBLE\n\nSample Input 4\n\n5 5\n1 3\n4 5\n2 3\n2 4\n1 4\n\nSample Output 4\n\nPOSSIBLE\n\nYou can get to Island 5 by using two boat services: Island 1 -> Island 4 -> Island 5.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 485, "cpu_time_ms": 64, "memory_kb": 7456}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s924517147", "group_id": "codeNet:p03657", "input_text": "let a, b = Scanf.sscanf (read_line ()) \"%d %d\" (fun a b -> (a, b))\n \nlet () = if a mod 3 = 0 || b mod 3 = 0 || (a+b) mod 3 = 0 then\n print_endline \"Possible\"\nelse\n print_endline \"Impossible\"", "language": "OCaml", "metadata": {"date": 1589946945, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03657.html", "problem_id": "p03657", "resource_group": "low_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/OCaml/s924517147.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s924517147", "user_id": "u173515518"}, "prompt_components": {"gold_output": "Possible\n", "input_to_evaluate": "let a, b = Scanf.sscanf (read_line ()) \"%d %d\" (fun a b -> (a, b))\n \nlet () = if a mod 3 = 0 || b mod 3 = 0 || (a+b) mod 3 = 0 then\n print_endline \"Possible\"\nelse\n print_endline \"Impossible\"", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s517653458", "group_id": "codeNet:p03657", "input_text": "let _ = Scanf.sscanf (read_line ()) \"%d %d\" (fun a b ->\n if a mod 3 = 0 || b mod 3 = 0 || a+b mod 3 = 0 then \"Possible\" else \"Impossible\"\n) |> print_endline", "language": "OCaml", "metadata": {"date": 1584323086, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03657.html", "problem_id": "p03657", "resource_group": "low_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/OCaml/s517653458.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s517653458", "user_id": "u511870776"}, "prompt_components": {"gold_output": "Possible\n", "input_to_evaluate": "let _ = Scanf.sscanf (read_line ()) \"%d %d\" (fun a b ->\n if a mod 3 = 0 || b mod 3 = 0 || a+b mod 3 = 0 then \"Possible\" else \"Impossible\"\n) |> print_endline", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s414286050", "group_id": "codeNet:p03657", "input_text": "let () =\n let (a, b) = Scanf.scanf \"%d %d\" (fun a b -> (a, b)) in\n print_endline\n (if List.exists (fun e -> e mod 3 = 0) [a; b; a + b] then \"Possible\"\n else \"Impossible\")", "language": "OCaml", "metadata": {"date": 1501355636, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03657.html", "problem_id": "p03657", "resource_group": "low_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/OCaml/s414286050.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s414286050", "user_id": "u322845568"}, "prompt_components": {"gold_output": "Possible\n", "input_to_evaluate": "let () =\n let (a, b) = Scanf.scanf \"%d %d\" (fun a b -> (a, b)) in\n print_endline\n (if List.exists (fun e -> e mod 3 = 0) [a; b; a + b] then \"Possible\"\n else \"Impossible\")", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 2432}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s561316939", "group_id": "codeNet:p03658", "input_text": "let () =\n let n, k = Scanf.scanf \"%d %d\" (fun n k -> n, k) in\n let a = Array.init n (fun _ -> Scanf.scanf \" %d\" (fun x -> x)) in\n Array.sort (fun x y -> y - x) a;\n Array.sub a 0 k |> Array.fold_left (+) 0\n |> Printf.printf \"%d\\n\"\n", "language": "OCaml", "metadata": {"date": 1519792046, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03658.html", "problem_id": "p03658", "resource_group": "low_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/OCaml/s561316939.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s561316939", "user_id": "u798181098"}, "prompt_components": {"gold_output": "12\n", "input_to_evaluate": "let () =\n let n, k = Scanf.scanf \"%d %d\" (fun n k -> n, k) in\n let a = Array.init n (fun _ -> Scanf.scanf \" %d\" (fun x -> x)) in\n Array.sort (fun x y -> y - x) a;\n Array.sub a 0 k |> Array.fold_left (+) 0\n |> Printf.printf \"%d\\n\"\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nSnuke has N sticks.\nThe length of the i-th stick is l_i.\n\nSnuke is making a snake toy by joining K of the sticks together.\n\nThe length of the toy is represented by the sum of the individual sticks that compose it.\nFind the maximum possible length of the toy.\n\nConstraints\n\n1 \\leq K \\leq N \\leq 50\n\n1 \\leq l_i \\leq 50\n\nl_i is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nl_1 l_2 l_3 ... l_{N}\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n5 3\n1 2 3 4 5\n\nSample Output 1\n\n12\n\nYou can make a toy of length 12 by joining the sticks of lengths 3, 4 and 5, which is the maximum possible length.\n\nSample Input 2\n\n15 14\n50 26 27 21 41 7 42 35 7 5 5 36 39 1 45\n\nSample Output 2\n\n386", "sample_input": "5 3\n1 2 3 4 5\n"}, "reference_outputs": ["12\n"], "source_document_id": "p03658", "source_text": "Score : 200 points\n\nProblem Statement\n\nSnuke has N sticks.\nThe length of the i-th stick is l_i.\n\nSnuke is making a snake toy by joining K of the sticks together.\n\nThe length of the toy is represented by the sum of the individual sticks that compose it.\nFind the maximum possible length of the toy.\n\nConstraints\n\n1 \\leq K \\leq N \\leq 50\n\n1 \\leq l_i \\leq 50\n\nl_i is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN K\nl_1 l_2 l_3 ... l_{N}\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n5 3\n1 2 3 4 5\n\nSample Output 1\n\n12\n\nYou can make a toy of length 12 by joining the sticks of lengths 3, 4 and 5, which is the maximum possible length.\n\nSample Input 2\n\n15 14\n50 26 27 21 41 7 42 35 7 5 5 36 39 1 45\n\nSample Output 2\n\n386", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s292455445", "group_id": "codeNet:p03659", "input_text": "Scanf.scanf \"%d\" (fun n ->\n let a = Array.init n (fun _ -> Scanf.scanf \" %d\" (fun a -> a)) in\n let total = Array.fold_left (+) 0 a in\n let rec loop i acc best =\n if i = n - 1 then best else\n let acc = acc + a.(i) in\n loop (i + 1) acc (min best (abs (total - acc * 2)))\n in\n loop 0 0 max_int |> Printf.printf \"%d\\n\"\n)", "language": "OCaml", "metadata": {"date": 1584507192, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03659.html", "problem_id": "p03659", "resource_group": "low_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/OCaml/s292455445.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s292455445", "user_id": "u342443598"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "Scanf.scanf \"%d\" (fun n ->\n let a = Array.init n (fun _ -> Scanf.scanf \" %d\" (fun a -> a)) in\n let total = Array.fold_left (+) 0 a in\n let rec loop i acc best =\n if i = n - 1 then best else\n let acc = acc + a.(i) in\n loop (i + 1) acc (min best (abs (total - acc * 2)))\n in\n loop 0 0 max_int |> Printf.printf \"%d\\n\"\n)", "problem_context": "Score : 300 points\n\nProblem Statement\n\nSnuke and Raccoon have a heap of N cards. The i-th card from the top has the integer a_i written on it.\n\nThey will share these cards.\nFirst, Snuke will take some number of cards from the top of the heap, then Raccoon will take all the remaining cards.\nHere, both Snuke and Raccoon have to take at least one card.\n\nLet the sum of the integers on Snuke's cards and Raccoon's cards be x and y, respectively.\nThey would like to minimize |x-y|.\nFind the minimum possible value of |x-y|.\n\nConstraints\n\n2 \\leq N \\leq 2 \\times 10^5\n\n-10^{9} \\leq a_i \\leq 10^{9}\n\na_i is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 ... a_{N}\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n6\n1 2 3 4 5 6\n\nSample Output 1\n\n1\n\nIf Snuke takes four cards from the top, and Raccoon takes the remaining two cards, x=10, y=11, and thus |x-y|=1. This is the minimum possible value.\n\nSample Input 2\n\n2\n10 -10\n\nSample Output 2\n\n20\n\nSnuke can only take one card from the top, and Raccoon can only take the remaining one card. In this case, x=10, y=-10, and thus |x-y|=20.", "sample_input": "6\n1 2 3 4 5 6\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03659", "source_text": "Score : 300 points\n\nProblem Statement\n\nSnuke and Raccoon have a heap of N cards. The i-th card from the top has the integer a_i written on it.\n\nThey will share these cards.\nFirst, Snuke will take some number of cards from the top of the heap, then Raccoon will take all the remaining cards.\nHere, both Snuke and Raccoon have to take at least one card.\n\nLet the sum of the integers on Snuke's cards and Raccoon's cards be x and y, respectively.\nThey would like to minimize |x-y|.\nFind the minimum possible value of |x-y|.\n\nConstraints\n\n2 \\leq N \\leq 2 \\times 10^5\n\n-10^{9} \\leq a_i \\leq 10^{9}\n\na_i is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 ... a_{N}\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n6\n1 2 3 4 5 6\n\nSample Output 1\n\n1\n\nIf Snuke takes four cards from the top, and Raccoon takes the remaining two cards, x=10, y=11, and thus |x-y|=1. This is the minimum possible value.\n\nSample Input 2\n\n2\n10 -10\n\nSample Output 2\n\n20\n\nSnuke can only take one card from the top, and Raccoon can only take the remaining one card. In this case, x=10, y=-10, and thus |x-y|=20.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 360, "cpu_time_ms": 58, "memory_kb": 6144}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s206257567", "group_id": "codeNet:p03659", "input_text": "let () =\n let n = read_int () in\n let a = Array.init n (fun _ -> Scanf.scanf \"%d \" (fun i -> i)) in\n let z = Array.fold_left (+) 0 a in\n let ans = ref max_int in\n for i = 0 to n - 2 do\n let t = abs (z - 2 * a.(i)) in\n if t < !ans then ans := t;\n done;\n Printf.printf \"%d\\n\" !ans", "language": "OCaml", "metadata": {"date": 1501357693, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03659.html", "problem_id": "p03659", "resource_group": "low_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/OCaml/s206257567.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s206257567", "user_id": "u322845568"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "let () =\n let n = read_int () in\n let a = Array.init n (fun _ -> Scanf.scanf \"%d \" (fun i -> i)) in\n let z = Array.fold_left (+) 0 a in\n let ans = ref max_int in\n for i = 0 to n - 2 do\n let t = abs (z - 2 * a.(i)) in\n if t < !ans then ans := t;\n done;\n Printf.printf \"%d\\n\" !ans", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 56, "memory_kb": 5888}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s008010977", "group_id": "codeNet:p03660", "input_text": "module DirectedGraph\n (* 道の表現 *)\n (Path : sig\n type t\n (* 辺の名前 *)\n type edge\n (* 長さ0の道 *)\n val nil : t\n (* 道の後ろに辺を付け足した道 *)\n val snoc : t -> edge -> t\n end) :\nsig\n (* BFSにより,重みのないグラフの最短経路を求める *)\n val bfs :\n (* 頂点数(Hashtblを用いるので目安程度) *)\n int ->\n (* 辺の名前が付いた隣接リスト *)\n ('v -> ('v * Path.edge) list) ->\n (* 始点 *)\n 'v ->\n (* 最短経路を返す関数 辿り着けなければNoneを返す) *)\n ('v -> Path.t option)\nend = struct\n let rec bfs_aux es d frontier t =\n try Some (Hashtbl.find d t) with\n | Not_found ->\n match !frontier with\n | [] -> None\n | _ :: _ ->\n frontier := List.fold_right (fun u ->\n List.fold_right (fun (v, e) frontier ->\n if Hashtbl.mem d v\n then frontier\n else (Hashtbl.add d v (Path.snoc (Hashtbl.find d u) e); v :: frontier))\n (es u)) !frontier [];\n bfs_aux es d frontier t\n\n (*\n * 終点に辿り着いた時点で探索を切り上げるが,\n * 戻り値の関数を覚えておくと,途中まで探索した結果が再利用される\n * (#trace bfs_aux すると分かりやすい)\n *)\n let bfs n es s =\n let d = Hashtbl.create n in\n Hashtbl.add d s Path.nil;\n let frontier = ref [s] in\n bfs_aux es d frontier\nend\n\n(* 配列版素集合データ構造 *)\nmodule RawUnionFind : sig\n type t\n type class_\n\n (* n要素の素集合データ構造を作る *)\n val make : int -> t\n (* 要素がどの集合に属するか調べる *)\n (* 要素は0からn-1の整数である必要がある *)\n val find : t -> int -> class_\n (* 与えられた要素が属する集合同士を合併する *)\n val unite : t -> int -> int -> unit\n\n val compare_class : class_ -> class_ -> int\nend = struct\n type t = { rank : int array; parent : int array }\n type class_ = int\n\n let make n =\n { rank = Array.make n 0;\n parent = Array.init n (fun c -> c) }\n\n let rec find uf x =\n if x = uf.parent.(x) then x\n else begin\n let y = find uf uf.parent.(x) in\n uf.parent.(x) <- y; y\n end\n\n let unite uf i j =\n let x = find uf i in\n let y = find uf j in\n if x <> y then begin\n if uf.rank.(x) < uf.rank.(y) then uf.parent.(x) <- y\n else begin\n uf.parent.(y) <- x;\n if uf.rank.(x) = uf.rank.(y) then\n uf.rank.(x) <- 1 + uf.rank.(x)\n end\n end\n\n let compare_class = compare\nend\n\nmodule G = DirectedGraph (struct\n type t = int list\n type edge = int\n let nil = []\n let snoc t e = e :: t\nend)\n\nlet () = Scanf.scanf \"%d\\n\" @@ fun n ->\n let abs = Array.init (n - 1) @@ fun _ ->\n Scanf.scanf \"%d %d\\n\" @@ fun a b -> a, b in\n let es = Array.make n [] in\n Array.iteri (fun i (a, b) ->\n es.(a - 1) <- (b - 1, i) :: es.(a - 1);\n es.(b - 1) <- (a - 1, i) :: es.(b - 1)) abs;\n let (Some route) = G.bfs n (fun v -> es.(v)) 0 (n - 1) in\n let i = List.nth route (List.length route / 2) in\n let uf = RawUnionFind.make n in\n Array.iteri (fun j (a, b) ->\n if i <> j then RawUnionFind.unite uf (a - 1) (b - 1)) abs;\n print_endline @@\n if\n List.length (List.filter (fun i ->\n RawUnionFind.compare_class (RawUnionFind.find uf 0) (RawUnionFind.find uf i) = 0)\n @@ Array.to_list @@ Array.init n @@ fun i -> i)\n < List.length (List.filter (fun i ->\n RawUnionFind.compare_class (RawUnionFind.find uf (n - 1)) (RawUnionFind.find uf i) = 0)\n @@ Array.to_list @@ Array.init n @@ fun i -> i)\n then \"Snuke\" else \"Fennec\"", "language": "OCaml", "metadata": {"date": 1531751565, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03660.html", "problem_id": "p03660", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03660/input.txt", "sample_output_relpath": "derived/input_output/data/p03660/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03660/OCaml/s008010977.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s008010977", "user_id": "u504158101"}, "prompt_components": {"gold_output": "Fennec\n", "input_to_evaluate": "module DirectedGraph\n (* 道の表現 *)\n (Path : sig\n type t\n (* 辺の名前 *)\n type edge\n (* 長さ0の道 *)\n val nil : t\n (* 道の後ろに辺を付け足した道 *)\n val snoc : t -> edge -> t\n end) :\nsig\n (* BFSにより,重みのないグラフの最短経路を求める *)\n val bfs :\n (* 頂点数(Hashtblを用いるので目安程度) *)\n int ->\n (* 辺の名前が付いた隣接リスト *)\n ('v -> ('v * Path.edge) list) ->\n (* 始点 *)\n 'v ->\n (* 最短経路を返す関数 辿り着けなければNoneを返す) *)\n ('v -> Path.t option)\nend = struct\n let rec bfs_aux es d frontier t =\n try Some (Hashtbl.find d t) with\n | Not_found ->\n match !frontier with\n | [] -> None\n | _ :: _ ->\n frontier := List.fold_right (fun u ->\n List.fold_right (fun (v, e) frontier ->\n if Hashtbl.mem d v\n then frontier\n else (Hashtbl.add d v (Path.snoc (Hashtbl.find d u) e); v :: frontier))\n (es u)) !frontier [];\n bfs_aux es d frontier t\n\n (*\n * 終点に辿り着いた時点で探索を切り上げるが,\n * 戻り値の関数を覚えておくと,途中まで探索した結果が再利用される\n * (#trace bfs_aux すると分かりやすい)\n *)\n let bfs n es s =\n let d = Hashtbl.create n in\n Hashtbl.add d s Path.nil;\n let frontier = ref [s] in\n bfs_aux es d frontier\nend\n\n(* 配列版素集合データ構造 *)\nmodule RawUnionFind : sig\n type t\n type class_\n\n (* n要素の素集合データ構造を作る *)\n val make : int -> t\n (* 要素がどの集合に属するか調べる *)\n (* 要素は0からn-1の整数である必要がある *)\n val find : t -> int -> class_\n (* 与えられた要素が属する集合同士を合併する *)\n val unite : t -> int -> int -> unit\n\n val compare_class : class_ -> class_ -> int\nend = struct\n type t = { rank : int array; parent : int array }\n type class_ = int\n\n let make n =\n { rank = Array.make n 0;\n parent = Array.init n (fun c -> c) }\n\n let rec find uf x =\n if x = uf.parent.(x) then x\n else begin\n let y = find uf uf.parent.(x) in\n uf.parent.(x) <- y; y\n end\n\n let unite uf i j =\n let x = find uf i in\n let y = find uf j in\n if x <> y then begin\n if uf.rank.(x) < uf.rank.(y) then uf.parent.(x) <- y\n else begin\n uf.parent.(y) <- x;\n if uf.rank.(x) = uf.rank.(y) then\n uf.rank.(x) <- 1 + uf.rank.(x)\n end\n end\n\n let compare_class = compare\nend\n\nmodule G = DirectedGraph (struct\n type t = int list\n type edge = int\n let nil = []\n let snoc t e = e :: t\nend)\n\nlet () = Scanf.scanf \"%d\\n\" @@ fun n ->\n let abs = Array.init (n - 1) @@ fun _ ->\n Scanf.scanf \"%d %d\\n\" @@ fun a b -> a, b in\n let es = Array.make n [] in\n Array.iteri (fun i (a, b) ->\n es.(a - 1) <- (b - 1, i) :: es.(a - 1);\n es.(b - 1) <- (a - 1, i) :: es.(b - 1)) abs;\n let (Some route) = G.bfs n (fun v -> es.(v)) 0 (n - 1) in\n let i = List.nth route (List.length route / 2) in\n let uf = RawUnionFind.make n in\n Array.iteri (fun j (a, b) ->\n if i <> j then RawUnionFind.unite uf (a - 1) (b - 1)) abs;\n print_endline @@\n if\n List.length (List.filter (fun i ->\n RawUnionFind.compare_class (RawUnionFind.find uf 0) (RawUnionFind.find uf i) = 0)\n @@ Array.to_list @@ Array.init n @@ fun i -> i)\n < List.length (List.filter (fun i ->\n RawUnionFind.compare_class (RawUnionFind.find uf (n - 1)) (RawUnionFind.find uf i) = 0)\n @@ Array.to_list @@ Array.init n @@ fun i -> i)\n then \"Snuke\" else \"Fennec\"", "problem_context": "Score : 400 points\n\nProblem Statement\n\nFennec and Snuke are playing a board game.\n\nOn the board, there are N cells numbered 1 through N, and N-1 roads, each connecting two cells. Cell a_i is adjacent to Cell b_i through the i-th road. Every cell can be reached from every other cell by repeatedly traveling to an adjacent cell. In terms of graph theory, the graph formed by the cells and the roads is a tree.\n\nInitially, Cell 1 is painted black, and Cell N is painted white. The other cells are not yet colored.\nFennec (who goes first) and Snuke (who goes second) alternately paint an uncolored cell.\nMore specifically, each player performs the following action in her/his turn:\n\nFennec: selects an uncolored cell that is adjacent to a black cell, and paints it black.\n\nSnuke: selects an uncolored cell that is adjacent to a white cell, and paints it white.\n\nA player loses when she/he cannot paint a cell. Determine the winner of the game when Fennec and Snuke play optimally.\n\nConstraints\n\n2 \\leq N \\leq 10^5\n\n1 \\leq a_i, b_i \\leq N\n\nThe given graph is a tree.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 b_1\n:\na_{N-1} b_{N-1}\n\nOutput\n\nIf Fennec wins, print Fennec; if Snuke wins, print Snuke.\n\nSample Input 1\n\n7\n3 6\n1 2\n3 1\n7 4\n5 7\n1 4\n\nSample Output 1\n\nFennec\n\nFor example, if Fennec first paints Cell 2 black, she will win regardless of Snuke's moves.\n\nSample Input 2\n\n4\n1 4\n4 2\n2 3\n\nSample Output 2\n\nSnuke", "sample_input": "7\n3 6\n1 2\n3 1\n7 4\n5 7\n1 4\n"}, "reference_outputs": ["Fennec\n"], "source_document_id": "p03660", "source_text": "Score : 400 points\n\nProblem Statement\n\nFennec and Snuke are playing a board game.\n\nOn the board, there are N cells numbered 1 through N, and N-1 roads, each connecting two cells. Cell a_i is adjacent to Cell b_i through the i-th road. Every cell can be reached from every other cell by repeatedly traveling to an adjacent cell. In terms of graph theory, the graph formed by the cells and the roads is a tree.\n\nInitially, Cell 1 is painted black, and Cell N is painted white. The other cells are not yet colored.\nFennec (who goes first) and Snuke (who goes second) alternately paint an uncolored cell.\nMore specifically, each player performs the following action in her/his turn:\n\nFennec: selects an uncolored cell that is adjacent to a black cell, and paints it black.\n\nSnuke: selects an uncolored cell that is adjacent to a white cell, and paints it white.\n\nA player loses when she/he cannot paint a cell. Determine the winner of the game when Fennec and Snuke play optimally.\n\nConstraints\n\n2 \\leq N \\leq 10^5\n\n1 \\leq a_i, b_i \\leq N\n\nThe given graph is a tree.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 b_1\n:\na_{N-1} b_{N-1}\n\nOutput\n\nIf Fennec wins, print Fennec; if Snuke wins, print Snuke.\n\nSample Input 1\n\n7\n3 6\n1 2\n3 1\n7 4\n5 7\n1 4\n\nSample Output 1\n\nFennec\n\nFor example, if Fennec first paints Cell 2 black, she will win regardless of Snuke's moves.\n\nSample Input 2\n\n4\n1 4\n4 2\n2 3\n\nSample Output 2\n\nSnuke", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 3697, "cpu_time_ms": 158, "memory_kb": 34556}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s920810450", "group_id": "codeNet:p03662", "input_text": "module IntSet = Set.Make (struct type t = int let compare = compare end)\n\nlet rec solve e us vs =\n IntSet.exists (fun v ->\n List.exists (fun v' ->\n not (IntSet.mem v' vs) &&\n not (IntSet.mem v' us) &&\n not (solve e (IntSet.add v' vs) us)) (e v)) vs\n\nlet () =\n let n = Scanf.scanf \"%d\\n\" (fun n -> n) in\n let abs = Array.init (n - 1)\n (fun _ -> Scanf.scanf \"%d %d\\n\" (fun a b -> a, b)) in \n solve\n (let e = Array.make n [] in\n Array.iter (fun (a, b) ->\n e.(a - 1) <- b - 1 :: e.(a - 1);\n e.(b - 1) <- a - 1 :: e.(b - 1)) abs;\n fun v -> e.(v))\n (IntSet.singleton (n - 1))\n (IntSet.singleton 0)\n |> (function true -> \"Fennec\" | false -> \"Snuke\")\n |> print_endline", "language": "OCaml", "metadata": {"date": 1500169678, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03662.html", "problem_id": "p03662", "resource_group": "low_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/OCaml/s920810450.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s920810450", "user_id": "u504158101"}, "prompt_components": {"gold_output": "Fennec\n", "input_to_evaluate": "module IntSet = Set.Make (struct type t = int let compare = compare end)\n\nlet rec solve e us vs =\n IntSet.exists (fun v ->\n List.exists (fun v' ->\n not (IntSet.mem v' vs) &&\n not (IntSet.mem v' us) &&\n not (solve e (IntSet.add v' vs) us)) (e v)) vs\n\nlet () =\n let n = Scanf.scanf \"%d\\n\" (fun n -> n) in\n let abs = Array.init (n - 1)\n (fun _ -> Scanf.scanf \"%d %d\\n\" (fun a b -> a, b)) in \n solve\n (let e = Array.make n [] in\n Array.iter (fun (a, b) ->\n e.(a - 1) <- b - 1 :: e.(a - 1);\n e.(b - 1) <- a - 1 :: e.(b - 1)) abs;\n fun v -> e.(v))\n (IntSet.singleton (n - 1))\n (IntSet.singleton 0)\n |> (function true -> \"Fennec\" | false -> \"Snuke\")\n |> print_endline", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 716, "cpu_time_ms": 2104, "memory_kb": 18320}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s923228969", "group_id": "codeNet:p03671", "input_text": "let () = Scanf.scanf \"%d %d %d\" (fun a b c -> a+b+c-max a (max b c)) |> Printf.printf \"%d\\n\"\n", "language": "OCaml", "metadata": {"date": 1519659675, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03671.html", "problem_id": "p03671", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03671/input.txt", "sample_output_relpath": "derived/input_output/data/p03671/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03671/OCaml/s923228969.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s923228969", "user_id": "u798181098"}, "prompt_components": {"gold_output": "1300\n", "input_to_evaluate": "let () = Scanf.scanf \"%d %d %d\" (fun a b c -> a+b+c-max a (max b c)) |> Printf.printf \"%d\\n\"\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nSnuke is buying a bicycle.\nThe bicycle of his choice does not come with a bell, so he has to buy one separately.\n\nHe has very high awareness of safety, and decides to buy two bells, one for each hand.\n\nThe store sells three kinds of bells for the price of a, b and c yen (the currency of Japan), respectively.\nFind the minimum total price of two different bells.\n\nConstraints\n\n1 \\leq a,b,c \\leq 10000\n\na, b and c are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\na b c\n\nOutput\n\nPrint the minimum total price of two different bells.\n\nSample Input 1\n\n700 600 780\n\nSample Output 1\n\n1300\n\nBuying a 700-yen bell and a 600-yen bell costs 1300 yen.\n\nBuying a 700-yen bell and a 780-yen bell costs 1480 yen.\n\nBuying a 600-yen bell and a 780-yen bell costs 1380 yen.\n\nThe minimum among these is 1300 yen.\n\nSample Input 2\n\n10000 10000 10000\n\nSample Output 2\n\n20000\n\nBuying any two bells costs 20000 yen.", "sample_input": "700 600 780\n"}, "reference_outputs": ["1300\n"], "source_document_id": "p03671", "source_text": "Score : 100 points\n\nProblem Statement\n\nSnuke is buying a bicycle.\nThe bicycle of his choice does not come with a bell, so he has to buy one separately.\n\nHe has very high awareness of safety, and decides to buy two bells, one for each hand.\n\nThe store sells three kinds of bells for the price of a, b and c yen (the currency of Japan), respectively.\nFind the minimum total price of two different bells.\n\nConstraints\n\n1 \\leq a,b,c \\leq 10000\n\na, b and c are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\na b c\n\nOutput\n\nPrint the minimum total price of two different bells.\n\nSample Input 1\n\n700 600 780\n\nSample Output 1\n\n1300\n\nBuying a 700-yen bell and a 600-yen bell costs 1300 yen.\n\nBuying a 700-yen bell and a 780-yen bell costs 1480 yen.\n\nBuying a 600-yen bell and a 780-yen bell costs 1380 yen.\n\nThe minimum among these is 1300 yen.\n\nSample Input 2\n\n10000 10000 10000\n\nSample Output 2\n\n20000\n\nBuying any two bells costs 20000 yen.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s010213064", "group_id": "codeNet:p03673", "input_text": "let n = Scanf.scanf \" %d\" (+) 0\nlet a_s = Array.init n @@ fun _ -> Scanf.scanf \" %d\" (+) 0\nlet ps = [|[]; []|]\nlet _ = Array.iteri (fun i a -> ps.(i mod 2) <- a :: ps.(i mod 2)) a_s;\n List.(ps.(1 - n mod 2) @ rev @@ ps.(n mod 2) |> iteri (fun i n -> Printf.printf (if i = 0 then \"%d\" else \" %d\") n)); print_newline ()", "language": "OCaml", "metadata": {"date": 1569298354, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03673.html", "problem_id": "p03673", "resource_group": "low_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/OCaml/s010213064.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s010213064", "user_id": "u732304692"}, "prompt_components": {"gold_output": "4 2 1 3\n", "input_to_evaluate": "let n = Scanf.scanf \" %d\" (+) 0\nlet a_s = Array.init n @@ fun _ -> Scanf.scanf \" %d\" (+) 0\nlet ps = [|[]; []|]\nlet _ = Array.iteri (fun i a -> ps.(i mod 2) <- a :: ps.(i mod 2)) a_s;\n List.(ps.(1 - n mod 2) @ rev @@ ps.(n mod 2) |> iteri (fun i n -> Printf.printf (if i = 0 then \"%d\" else \" %d\") n)); print_newline ()", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 134, "memory_kb": 17152}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s086806430", "group_id": "codeNet:p03673", "input_text": "let n = Scanf.scanf \"%d\" (fun x -> x)\nlet a = Array.init n (fun _ -> Scanf.scanf \" %d\" (fun x -> x))\nlet () =\n for i = 0 to (n-1)/2 do\n Printf.printf \"%d \" a.(n-1-2*i)\n done;\n let o = n mod 2 in\n for i = 0 to n/2-1 do\n Printf.printf \"%d \" a.(2*i + o)\n done;\n print_newline ()", "language": "OCaml", "metadata": {"date": 1528055348, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03673.html", "problem_id": "p03673", "resource_group": "low_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/OCaml/s086806430.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s086806430", "user_id": "u798181098"}, "prompt_components": {"gold_output": "4 2 1 3\n", "input_to_evaluate": "let n = Scanf.scanf \"%d\" (fun x -> x)\nlet a = Array.init n (fun _ -> Scanf.scanf \" %d\" (fun x -> x))\nlet () =\n for i = 0 to (n-1)/2 do\n Printf.printf \"%d \" a.(n-1-2*i)\n done;\n let o = n mod 2 in\n for i = 0 to n/2-1 do\n Printf.printf \"%d \" a.(2*i + o)\n done;\n print_newline ()", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 287, "cpu_time_ms": 103, "memory_kb": 8064}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s395709134", "group_id": "codeNet:p03679", "input_text": "let x, a, b = Scanf.scanf \" %d %d %d\" @@ fun a b c -> a, b, c\nlet _ = print_endline @@ if a >= b then \"delicious\" else if b - a <= x then \"safe\" else \"dangerous\"", "language": "OCaml", "metadata": {"date": 1562412923, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03679.html", "problem_id": "p03679", "resource_group": "low_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/OCaml/s395709134.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s395709134", "user_id": "u732304692"}, "prompt_components": {"gold_output": "safe\n", "input_to_evaluate": "let x, a, b = Scanf.scanf \" %d %d %d\" @@ fun a b c -> a, b, c\nlet _ = print_endline @@ if a >= b then \"delicious\" else if b - a <= x then \"safe\" else \"dangerous\"", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s471693450", "group_id": "codeNet:p03680", "input_text": "let n = Scanf.scanf \" %d\" (+) 0\nlet a_s = Array.init n @@ fun _ -> Scanf.scanf \" %d\" pred\nlet j = ref 0\nlet _ = for i = 1 to n do j := a_s.(!j); if !j = 1 then (Printf.printf \"%d\\n\" i; exit 0) done; print_endline \"-1\"", "language": "OCaml", "metadata": {"date": 1565638395, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03680.html", "problem_id": "p03680", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03680/input.txt", "sample_output_relpath": "derived/input_output/data/p03680/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03680/OCaml/s471693450.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s471693450", "user_id": "u732304692"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "let n = Scanf.scanf \" %d\" (+) 0\nlet a_s = Array.init n @@ fun _ -> Scanf.scanf \" %d\" pred\nlet j = ref 0\nlet _ = for i = 1 to n do j := a_s.(!j); if !j = 1 then (Printf.printf \"%d\\n\" i; exit 0) done; print_endline \"-1\"", "problem_context": "Score : 200 points\n\nProblem Statement\n\nTakahashi wants to gain muscle, and decides to work out at AtCoder Gym.\n\nThe exercise machine at the gym has N buttons, and exactly one of the buttons is lighten up.\nThese buttons are numbered 1 through N.\nWhen Button i is lighten up and you press it, the light is turned off, and then Button a_i will be lighten up. It is possible that i=a_i.\nWhen Button i is not lighten up, nothing will happen by pressing it.\n\nInitially, Button 1 is lighten up. Takahashi wants to quit pressing buttons when Button 2 is lighten up.\n\nDetermine whether this is possible. If the answer is positive, find the minimum number of times he needs to press buttons.\n\nConstraints\n\n2 ≤ N ≤ 10^5\n\n1 ≤ a_i ≤ N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1\na_2\n:\na_N\n\nOutput\n\nPrint -1 if it is impossible to lighten up Button 2.\nOtherwise, print the minimum number of times we need to press buttons in order to lighten up Button 2.\n\nSample Input 1\n\n3\n3\n1\n2\n\nSample Output 1\n\n2\n\nPress Button 1, then Button 3.\n\nSample Input 2\n\n4\n3\n4\n1\n2\n\nSample Output 2\n\n-1\n\nPressing Button 1 lightens up Button 3, and vice versa, so Button 2 will never be lighten up.\n\nSample Input 3\n\n5\n3\n3\n4\n2\n4\n\nSample Output 3\n\n3", "sample_input": "3\n3\n1\n2\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03680", "source_text": "Score : 200 points\n\nProblem Statement\n\nTakahashi wants to gain muscle, and decides to work out at AtCoder Gym.\n\nThe exercise machine at the gym has N buttons, and exactly one of the buttons is lighten up.\nThese buttons are numbered 1 through N.\nWhen Button i is lighten up and you press it, the light is turned off, and then Button a_i will be lighten up. It is possible that i=a_i.\nWhen Button i is not lighten up, nothing will happen by pressing it.\n\nInitially, Button 1 is lighten up. Takahashi wants to quit pressing buttons when Button 2 is lighten up.\n\nDetermine whether this is possible. If the answer is positive, find the minimum number of times he needs to press buttons.\n\nConstraints\n\n2 ≤ N ≤ 10^5\n\n1 ≤ a_i ≤ N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1\na_2\n:\na_N\n\nOutput\n\nPrint -1 if it is impossible to lighten up Button 2.\nOtherwise, print the minimum number of times we need to press buttons in order to lighten up Button 2.\n\nSample Input 1\n\n3\n3\n1\n2\n\nSample Output 1\n\n2\n\nPress Button 1, then Button 3.\n\nSample Input 2\n\n4\n3\n4\n1\n2\n\nSample Output 2\n\n-1\n\nPressing Button 1 lightens up Button 3, and vice versa, so Button 2 will never be lighten up.\n\nSample Input 3\n\n5\n3\n3\n4\n2\n4\n\nSample Output 3\n\n3", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 26, "memory_kb": 5504}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s607298980", "group_id": "codeNet:p03680", "input_text": "module Int = struct\n type t = int\n let compare = compare\nend\nmodule Ints = Set.Make(Int)\n\nlet id x = x\nlet n = Scanf.scanf \"%d\\n\" id\nlet ar = Array.init n (fun _ -> Scanf.scanf \"%d \" id)\n\nlet rec f i ans s =\n let a = ar.(i-1) in\n if Ints.mem a s then -1\n else if a = 2 then succ ans\n else f a (succ ans) (Ints.add a s)\n\nlet () =\n f 1 0 Ints.empty |> Printf.printf \"%d\\n\"", "language": "OCaml", "metadata": {"date": 1524806506, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03680.html", "problem_id": "p03680", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03680/input.txt", "sample_output_relpath": "derived/input_output/data/p03680/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03680/OCaml/s607298980.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s607298980", "user_id": "u987869509"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "module Int = struct\n type t = int\n let compare = compare\nend\nmodule Ints = Set.Make(Int)\n\nlet id x = x\nlet n = Scanf.scanf \"%d\\n\" id\nlet ar = Array.init n (fun _ -> Scanf.scanf \"%d \" id)\n\nlet rec f i ans s =\n let a = ar.(i-1) in\n if Ints.mem a s then -1\n else if a = 2 then succ ans\n else f a (succ ans) (Ints.add a s)\n\nlet () =\n f 1 0 Ints.empty |> Printf.printf \"%d\\n\"", "problem_context": "Score : 200 points\n\nProblem Statement\n\nTakahashi wants to gain muscle, and decides to work out at AtCoder Gym.\n\nThe exercise machine at the gym has N buttons, and exactly one of the buttons is lighten up.\nThese buttons are numbered 1 through N.\nWhen Button i is lighten up and you press it, the light is turned off, and then Button a_i will be lighten up. It is possible that i=a_i.\nWhen Button i is not lighten up, nothing will happen by pressing it.\n\nInitially, Button 1 is lighten up. Takahashi wants to quit pressing buttons when Button 2 is lighten up.\n\nDetermine whether this is possible. If the answer is positive, find the minimum number of times he needs to press buttons.\n\nConstraints\n\n2 ≤ N ≤ 10^5\n\n1 ≤ a_i ≤ N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1\na_2\n:\na_N\n\nOutput\n\nPrint -1 if it is impossible to lighten up Button 2.\nOtherwise, print the minimum number of times we need to press buttons in order to lighten up Button 2.\n\nSample Input 1\n\n3\n3\n1\n2\n\nSample Output 1\n\n2\n\nPress Button 1, then Button 3.\n\nSample Input 2\n\n4\n3\n4\n1\n2\n\nSample Output 2\n\n-1\n\nPressing Button 1 lightens up Button 3, and vice versa, so Button 2 will never be lighten up.\n\nSample Input 3\n\n5\n3\n3\n4\n2\n4\n\nSample Output 3\n\n3", "sample_input": "3\n3\n1\n2\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03680", "source_text": "Score : 200 points\n\nProblem Statement\n\nTakahashi wants to gain muscle, and decides to work out at AtCoder Gym.\n\nThe exercise machine at the gym has N buttons, and exactly one of the buttons is lighten up.\nThese buttons are numbered 1 through N.\nWhen Button i is lighten up and you press it, the light is turned off, and then Button a_i will be lighten up. It is possible that i=a_i.\nWhen Button i is not lighten up, nothing will happen by pressing it.\n\nInitially, Button 1 is lighten up. Takahashi wants to quit pressing buttons when Button 2 is lighten up.\n\nDetermine whether this is possible. If the answer is positive, find the minimum number of times he needs to press buttons.\n\nConstraints\n\n2 ≤ N ≤ 10^5\n\n1 ≤ a_i ≤ N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1\na_2\n:\na_N\n\nOutput\n\nPrint -1 if it is impossible to lighten up Button 2.\nOtherwise, print the minimum number of times we need to press buttons in order to lighten up Button 2.\n\nSample Input 1\n\n3\n3\n1\n2\n\nSample Output 1\n\n2\n\nPress Button 1, then Button 3.\n\nSample Input 2\n\n4\n3\n4\n1\n2\n\nSample Output 2\n\n-1\n\nPressing Button 1 lightens up Button 3, and vice versa, so Button 2 will never be lighten up.\n\nSample Input 3\n\n5\n3\n3\n4\n2\n4\n\nSample Output 3\n\n3", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 377, "cpu_time_ms": 128, "memory_kb": 10496}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s168088641", "group_id": "codeNet:p03680", "input_text": "let id x = x\nlet n = Scanf.scanf \"%d\\n\" id\n\nlet array = Array.init n (fun _ -> (Scanf.scanf \"%d\\n\") id)\n\nlet rec solve n cnt list =\n if n = 1 then cnt else\n if List.mem n list then -1 else\n solve (array.(n) - 1) (cnt + 1) ((array.(n) - 1) :: list)\n\nlet ans = solve 0 0 []\n \nlet () =\n Printf.printf \"%d\\n\" ans", "language": "OCaml", "metadata": {"date": 1498354116, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03680.html", "problem_id": "p03680", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03680/input.txt", "sample_output_relpath": "derived/input_output/data/p03680/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03680/OCaml/s168088641.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s168088641", "user_id": "u735499035"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "let id x = x\nlet n = Scanf.scanf \"%d\\n\" id\n\nlet array = Array.init n (fun _ -> (Scanf.scanf \"%d\\n\") id)\n\nlet rec solve n cnt list =\n if n = 1 then cnt else\n if List.mem n list then -1 else\n solve (array.(n) - 1) (cnt + 1) ((array.(n) - 1) :: list)\n\nlet ans = solve 0 0 []\n \nlet () =\n Printf.printf \"%d\\n\" ans", "problem_context": "Score : 200 points\n\nProblem Statement\n\nTakahashi wants to gain muscle, and decides to work out at AtCoder Gym.\n\nThe exercise machine at the gym has N buttons, and exactly one of the buttons is lighten up.\nThese buttons are numbered 1 through N.\nWhen Button i is lighten up and you press it, the light is turned off, and then Button a_i will be lighten up. It is possible that i=a_i.\nWhen Button i is not lighten up, nothing will happen by pressing it.\n\nInitially, Button 1 is lighten up. Takahashi wants to quit pressing buttons when Button 2 is lighten up.\n\nDetermine whether this is possible. If the answer is positive, find the minimum number of times he needs to press buttons.\n\nConstraints\n\n2 ≤ N ≤ 10^5\n\n1 ≤ a_i ≤ N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1\na_2\n:\na_N\n\nOutput\n\nPrint -1 if it is impossible to lighten up Button 2.\nOtherwise, print the minimum number of times we need to press buttons in order to lighten up Button 2.\n\nSample Input 1\n\n3\n3\n1\n2\n\nSample Output 1\n\n2\n\nPress Button 1, then Button 3.\n\nSample Input 2\n\n4\n3\n4\n1\n2\n\nSample Output 2\n\n-1\n\nPressing Button 1 lightens up Button 3, and vice versa, so Button 2 will never be lighten up.\n\nSample Input 3\n\n5\n3\n3\n4\n2\n4\n\nSample Output 3\n\n3", "sample_input": "3\n3\n1\n2\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03680", "source_text": "Score : 200 points\n\nProblem Statement\n\nTakahashi wants to gain muscle, and decides to work out at AtCoder Gym.\n\nThe exercise machine at the gym has N buttons, and exactly one of the buttons is lighten up.\nThese buttons are numbered 1 through N.\nWhen Button i is lighten up and you press it, the light is turned off, and then Button a_i will be lighten up. It is possible that i=a_i.\nWhen Button i is not lighten up, nothing will happen by pressing it.\n\nInitially, Button 1 is lighten up. Takahashi wants to quit pressing buttons when Button 2 is lighten up.\n\nDetermine whether this is possible. If the answer is positive, find the minimum number of times he needs to press buttons.\n\nConstraints\n\n2 ≤ N ≤ 10^5\n\n1 ≤ a_i ≤ N\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1\na_2\n:\na_N\n\nOutput\n\nPrint -1 if it is impossible to lighten up Button 2.\nOtherwise, print the minimum number of times we need to press buttons in order to lighten up Button 2.\n\nSample Input 1\n\n3\n3\n1\n2\n\nSample Output 1\n\n2\n\nPress Button 1, then Button 3.\n\nSample Input 2\n\n4\n3\n4\n1\n2\n\nSample Output 2\n\n-1\n\nPressing Button 1 lightens up Button 3, and vice versa, so Button 2 will never be lighten up.\n\nSample Input 3\n\n5\n3\n3\n4\n2\n4\n\nSample Output 3\n\n3", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 25, "memory_kb": 5376}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s334961146", "group_id": "codeNet:p03681", "input_text": "let () =\n let i = 1000000007 in\n let fact a =\n let rec fact_aux x tmp =\n if x = 1 then tmp mod i else fact_aux (x - 1) (tmp * x mod i)\n in\n fact_aux a 1\n in\n let f n m = fact n mod i * fact m mod i in\n let dogs, monkeys = Scanf.scanf \"%d %d\" (fun x y -> (x, y)) in\n ( match abs (dogs - monkeys) with\n | 0 -> f dogs monkeys * 2 mod i\n | 1 -> f dogs monkeys mod i\n | _ -> 0 )\n |> Printf.printf \"%d\\n\"", "language": "OCaml", "metadata": {"date": 1521781124, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03681.html", "problem_id": "p03681", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03681/input.txt", "sample_output_relpath": "derived/input_output/data/p03681/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03681/OCaml/s334961146.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s334961146", "user_id": "u987869509"}, "prompt_components": {"gold_output": "8\n", "input_to_evaluate": "let () =\n let i = 1000000007 in\n let fact a =\n let rec fact_aux x tmp =\n if x = 1 then tmp mod i else fact_aux (x - 1) (tmp * x mod i)\n in\n fact_aux a 1\n in\n let f n m = fact n mod i * fact m mod i in\n let dogs, monkeys = Scanf.scanf \"%d %d\" (fun x y -> (x, y)) in\n ( match abs (dogs - monkeys) with\n | 0 -> f dogs monkeys * 2 mod i\n | 1 -> f dogs monkeys mod i\n | _ -> 0 )\n |> Printf.printf \"%d\\n\"", "problem_context": "Score : 300 points\n\nProblem Statement\n\nSnuke has N dogs and M monkeys. He wants them to line up in a row.\n\nAs a Japanese saying goes, these dogs and monkeys are on bad terms. (\"ken'en no naka\", literally \"the relationship of dogs and monkeys\", means a relationship of mutual hatred.) Snuke is trying to reconsile them, by arranging the animals so that there are neither two adjacent dogs nor two adjacent monkeys.\n\nHow many such arrangements there are? Find the count modulo 10^9+7 (since animals cannot understand numbers larger than that).\nHere, dogs and monkeys are both distinguishable. Also, two arrangements that result from reversing each other are distinguished.\n\nConstraints\n\n1 ≤ N,M ≤ 10^5\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\n\nOutput\n\nPrint the number of possible arrangements, modulo 10^9+7.\n\nSample Input 1\n\n2 2\n\nSample Output 1\n\n8\n\nWe will denote the dogs by A and B, and the monkeys by C and D. There are eight possible arrangements: ACBD, ADBC, BCAD, BDAC, CADB, CBDA, DACB and DBCA.\n\nSample Input 2\n\n3 2\n\nSample Output 2\n\n12\n\nSample Input 3\n\n1 8\n\nSample Output 3\n\n0\n\nSample Input 4\n\n100000 100000\n\nSample Output 4\n\n530123477", "sample_input": "2 2\n"}, "reference_outputs": ["8\n"], "source_document_id": "p03681", "source_text": "Score : 300 points\n\nProblem Statement\n\nSnuke has N dogs and M monkeys. He wants them to line up in a row.\n\nAs a Japanese saying goes, these dogs and monkeys are on bad terms. (\"ken'en no naka\", literally \"the relationship of dogs and monkeys\", means a relationship of mutual hatred.) Snuke is trying to reconsile them, by arranging the animals so that there are neither two adjacent dogs nor two adjacent monkeys.\n\nHow many such arrangements there are? Find the count modulo 10^9+7 (since animals cannot understand numbers larger than that).\nHere, dogs and monkeys are both distinguishable. Also, two arrangements that result from reversing each other are distinguished.\n\nConstraints\n\n1 ≤ N,M ≤ 10^5\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\n\nOutput\n\nPrint the number of possible arrangements, modulo 10^9+7.\n\nSample Input 1\n\n2 2\n\nSample Output 1\n\n8\n\nWe will denote the dogs by A and B, and the monkeys by C and D. There are eight possible arrangements: ACBD, ADBC, BCAD, BDAC, CADB, CBDA, DACB and DBCA.\n\nSample Input 2\n\n3 2\n\nSample Output 2\n\n12\n\nSample Input 3\n\n1 8\n\nSample Output 3\n\n0\n\nSample Input 4\n\n100000 100000\n\nSample Output 4\n\n530123477", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 2, "memory_kb": 2432}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s924329109", "group_id": "codeNet:p03682", "input_text": "let init n = Array.make n (-1)\n\nlet rec find x p =\n if p.(x) < 0 then x else begin\n let x' = find p.(x) p in p.(x) <- x'; x'\n end\n\nlet unite x y p =\n let x', y' = find x p, find y p in\n if x' = y' then () else\n if p.(x') < p.(y') then (p.(y') <- x)\n else begin\n if p.(x') = p.(y') then p.(y') <- p.(y') - 1;\n p.(x') <- y'\n end\n\nlet same x y p = find x p = find y p\n\nlet () =\n Scanf.scanf \"%d\" @@ fun n ->\n let cs = Array.init n (fun _ -> Scanf.scanf \" %d %d\" (fun x y -> x, y)) in\n let xs, ys =\n Array.mapi (fun i (x,_) -> (x,i)) cs, Array.mapi (fun i (_,y) -> (y,i)) cs in\n\n Array.sort compare xs; Array.sort compare ys;\n\n let edges = Array.concat [\n Array.init (n-1) (fun i ->\n let (x0,i), (x1,j) = xs.(i+1), xs.(i) in (x0-x1, i, j));\n Array.init (n-1) (fun i ->\n let (y0,i), (y1,j) = ys.(i+1), ys.(i) in (y0-y1, i, j));\n ] in\n Array.sort compare edges;\n\n let uf = Array.make n (-1) in\n Array.fold_left (fun sw (d, i, j) ->\n if same i j uf then sw\n else (unite i j uf; sw+d)) 0 edges\n |> Printf.printf \"%d\\n\"\n", "language": "OCaml", "metadata": {"date": 1532611232, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03682.html", "problem_id": "p03682", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03682/input.txt", "sample_output_relpath": "derived/input_output/data/p03682/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03682/OCaml/s924329109.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s924329109", "user_id": "u798181098"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "let init n = Array.make n (-1)\n\nlet rec find x p =\n if p.(x) < 0 then x else begin\n let x' = find p.(x) p in p.(x) <- x'; x'\n end\n\nlet unite x y p =\n let x', y' = find x p, find y p in\n if x' = y' then () else\n if p.(x') < p.(y') then (p.(y') <- x)\n else begin\n if p.(x') = p.(y') then p.(y') <- p.(y') - 1;\n p.(x') <- y'\n end\n\nlet same x y p = find x p = find y p\n\nlet () =\n Scanf.scanf \"%d\" @@ fun n ->\n let cs = Array.init n (fun _ -> Scanf.scanf \" %d %d\" (fun x y -> x, y)) in\n let xs, ys =\n Array.mapi (fun i (x,_) -> (x,i)) cs, Array.mapi (fun i (_,y) -> (y,i)) cs in\n\n Array.sort compare xs; Array.sort compare ys;\n\n let edges = Array.concat [\n Array.init (n-1) (fun i ->\n let (x0,i), (x1,j) = xs.(i+1), xs.(i) in (x0-x1, i, j));\n Array.init (n-1) (fun i ->\n let (y0,i), (y1,j) = ys.(i+1), ys.(i) in (y0-y1, i, j));\n ] in\n Array.sort compare edges;\n\n let uf = Array.make n (-1) in\n Array.fold_left (fun sw (d, i, j) ->\n if same i j uf then sw\n else (unite i j uf; sw+d)) 0 edges\n |> Printf.printf \"%d\\n\"\n", "problem_context": "Score : 500 points\n\nProblem Statement\n\nThere are N towns on a plane. The i-th town is located at the coordinates (x_i,y_i). There may be more than one town at the same coordinates.\n\nYou can build a road between two towns at coordinates (a,b) and (c,d) for a cost of min(|a-c|,|b-d|) yen (the currency of Japan). It is not possible to build other types of roads.\n\nYour objective is to build roads so that it will be possible to travel between every pair of towns by traversing roads. At least how much money is necessary to achieve this?\n\nConstraints\n\n2 ≤ N ≤ 10^5\n\n0 ≤ x_i,y_i ≤ 10^9\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nx_1 y_1\nx_2 y_2\n:\nx_N y_N\n\nOutput\n\nPrint the minimum necessary amount of money in order to build roads so that it will be possible to travel between every pair of towns by traversing roads.\n\nSample Input 1\n\n3\n1 5\n3 9\n7 8\n\nSample Output 1\n\n3\n\nBuild a road between Towns 1 and 2, and another between Towns 2 and 3. The total cost is 2+1=3 yen.\n\nSample Input 2\n\n6\n8 3\n4 9\n12 19\n18 1\n13 5\n7 6\n\nSample Output 2\n\n8", "sample_input": "3\n1 5\n3 9\n7 8\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03682", "source_text": "Score : 500 points\n\nProblem Statement\n\nThere are N towns on a plane. The i-th town is located at the coordinates (x_i,y_i). There may be more than one town at the same coordinates.\n\nYou can build a road between two towns at coordinates (a,b) and (c,d) for a cost of min(|a-c|,|b-d|) yen (the currency of Japan). It is not possible to build other types of roads.\n\nYour objective is to build roads so that it will be possible to travel between every pair of towns by traversing roads. At least how much money is necessary to achieve this?\n\nConstraints\n\n2 ≤ N ≤ 10^5\n\n0 ≤ x_i,y_i ≤ 10^9\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nx_1 y_1\nx_2 y_2\n:\nx_N y_N\n\nOutput\n\nPrint the minimum necessary amount of money in order to build roads so that it will be possible to travel between every pair of towns by traversing roads.\n\nSample Input 1\n\n3\n1 5\n3 9\n7 8\n\nSample Output 1\n\n3\n\nBuild a road between Towns 1 and 2, and another between Towns 2 and 3. The total cost is 2+1=3 yen.\n\nSample Input 2\n\n6\n8 3\n4 9\n12 19\n18 1\n13 5\n7 6\n\nSample Output 2\n\n8", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1062, "cpu_time_ms": 500, "memory_kb": 25472}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s571219627", "group_id": "codeNet:p03687", "input_text": "Scanf.scanf \"%s\" (fun s ->\n let h = Array.make 26 false in\n String.iter (fun c -> h.(int_of_char c - 97) <- true) s;\n let rec chl c s cnt =\n let n = String.length s in\n let rec loop i =\n if i = n then true else\n if s.[i] = c then loop (i + 1) else false\n in\n if loop 0 then cnt else\n let s = String.init (n - 1) (fun i ->\n if s.[i] = c || s.[i + 1] = c then c else s.[i])\n in\n chl c s (cnt + 1)\n in\n let rec loop i acc =\n if i = 26 then acc else\n if h.(i) then loop (i + 1) (min acc (chl (char_of_int (i + 97)) s 0))\n else loop (i + 1) acc\n in\n loop 0 max_int |> Printf.printf \"%d\\n\"\n)", "language": "OCaml", "metadata": {"date": 1595474814, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p03687.html", "problem_id": "p03687", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03687/input.txt", "sample_output_relpath": "derived/input_output/data/p03687/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03687/OCaml/s571219627.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s571219627", "user_id": "u342443598"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "Scanf.scanf \"%s\" (fun s ->\n let h = Array.make 26 false in\n String.iter (fun c -> h.(int_of_char c - 97) <- true) s;\n let rec chl c s cnt =\n let n = String.length s in\n let rec loop i =\n if i = n then true else\n if s.[i] = c then loop (i + 1) else false\n in\n if loop 0 then cnt else\n let s = String.init (n - 1) (fun i ->\n if s.[i] = c || s.[i + 1] = c then c else s.[i])\n in\n chl c s (cnt + 1)\n in\n let rec loop i acc =\n if i = 26 then acc else\n if h.(i) then loop (i + 1) (min acc (chl (char_of_int (i + 97)) s 0))\n else loop (i + 1) acc\n in\n loop 0 max_int |> Printf.printf \"%d\\n\"\n)", "problem_context": "Score : 300 points\n\nProblem Statement\n\nSnuke can change a string t of length N into a string t' of length N - 1 under the following rule:\n\nFor each i (1 ≤ i ≤ N - 1), the i-th character of t' must be either the i-th or (i + 1)-th character of t.\n\nThere is a string s consisting of lowercase English letters.\nSnuke's objective is to apply the above operation to s repeatedly so that all the characters in s are the same.\nFind the minimum necessary number of operations.\n\nConstraints\n\n1 ≤ |s| ≤ 100\n\ns consists of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\ns\n\nOutput\n\nPrint the minimum necessary number of operations to achieve the objective.\n\nSample Input 1\n\nserval\n\nSample Output 1\n\n3\n\nOne solution is: serval → srvvl → svvv → vvv.\n\nSample Input 2\n\njackal\n\nSample Output 2\n\n2\n\nOne solution is: jackal → aacaa → aaaa.\n\nSample Input 3\n\nzzz\n\nSample Output 3\n\n0\n\nAll the characters in s are the same from the beginning.\n\nSample Input 4\n\nwhbrjpjyhsrywlqjxdbrbaomnw\n\nSample Output 4\n\n8\n\nIn 8 operations, he can change s to rrrrrrrrrrrrrrrrrr.", "sample_input": "serval\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03687", "source_text": "Score : 300 points\n\nProblem Statement\n\nSnuke can change a string t of length N into a string t' of length N - 1 under the following rule:\n\nFor each i (1 ≤ i ≤ N - 1), the i-th character of t' must be either the i-th or (i + 1)-th character of t.\n\nThere is a string s consisting of lowercase English letters.\nSnuke's objective is to apply the above operation to s repeatedly so that all the characters in s are the same.\nFind the minimum necessary number of operations.\n\nConstraints\n\n1 ≤ |s| ≤ 100\n\ns consists of lowercase English letters.\n\nInput\n\nInput is given from Standard Input in the following format:\n\ns\n\nOutput\n\nPrint the minimum necessary number of operations to achieve the objective.\n\nSample Input 1\n\nserval\n\nSample Output 1\n\n3\n\nOne solution is: serval → srvvl → svvv → vvv.\n\nSample Input 2\n\njackal\n\nSample Output 2\n\n2\n\nOne solution is: jackal → aacaa → aaaa.\n\nSample Input 3\n\nzzz\n\nSample Output 3\n\n0\n\nAll the characters in s are the same from the beginning.\n\nSample Input 4\n\nwhbrjpjyhsrywlqjxdbrbaomnw\n\nSample Output 4\n\n8\n\nIn 8 operations, he can change s to rrrrrrrrrrrrrrrrrr.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 747, "cpu_time_ms": 10, "memory_kb": 3916}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s758031908", "group_id": "codeNet:p03688", "input_text": "print_endline @@\n Scanf.scanf \"%d\" @@ fun n ->\n let a = Array.init n (fun _ -> Scanf.scanf \" %d\" ((+) 0)) in\n Array.sort (-) a;\n let l, r = a.(0), a.(n-1) in\n if r-l >= 2 then \"No\" else\n if l = r then\n if n = l + 1 || n >= 2 * l then \"Yes\" else \"No\"\n else\n (* l+1 = r *)\n let lc = Array.fold_left (fun s x -> s + a.(n-1) - x) 0 a in\n let rc = n - lc in\n if lc < l && rc >= 2 * (r-lc) then \"Yes\" else \"No\"", "language": "OCaml", "metadata": {"date": 1534925765, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03688.html", "problem_id": "p03688", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03688/input.txt", "sample_output_relpath": "derived/input_output/data/p03688/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03688/OCaml/s758031908.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s758031908", "user_id": "u798181098"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "print_endline @@\n Scanf.scanf \"%d\" @@ fun n ->\n let a = Array.init n (fun _ -> Scanf.scanf \" %d\" ((+) 0)) in\n Array.sort (-) a;\n let l, r = a.(0), a.(n-1) in\n if r-l >= 2 then \"No\" else\n if l = r then\n if n = l + 1 || n >= 2 * l then \"Yes\" else \"No\"\n else\n (* l+1 = r *)\n let lc = Array.fold_left (fun s x -> s + a.(n-1) - x) 0 a in\n let rc = n - lc in\n if lc < l && rc >= 2 * (r-lc) then \"Yes\" else \"No\"", "problem_context": "Score : 700 points\n\nProblem Statement\n\nThere are N cats.\nWe number them from 1 through N.\n\nEach of the cats wears a hat.\nCat i says: \"there are exactly a_i different colors among the N - 1 hats worn by the cats except me.\"\n\nDetermine whether there exists a sequence of colors of the hats that is consistent with the remarks of the cats.\n\nConstraints\n\n2 ≤ N ≤ 10^5\n\n1 ≤ a_i ≤ N-1\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 ... a_N\n\nOutput\n\nPrint Yes if there exists a sequence of colors of the hats that is consistent with the remarks of the cats; print No otherwise.\n\nSample Input 1\n\n3\n1 2 2\n\nSample Output 1\n\nYes\n\nFor example, if cat 1, 2 and 3 wears red, blue and blue hats, respectively, it is consistent with the remarks of the cats.\n\nSample Input 2\n\n3\n1 1 2\n\nSample Output 2\n\nNo\n\nFrom the remark of cat 1, we can see that cat 2 and 3 wear hats of the same color.\nAlso, from the remark of cat 2, we can see that cat 1 and 3 wear hats of the same color.\nTherefore, cat 1 and 2 wear hats of the same color, which contradicts the remark of cat 3.\n\nSample Input 3\n\n5\n4 3 4 3 4\n\nSample Output 3\n\nNo\n\nSample Input 4\n\n3\n2 2 2\n\nSample Output 4\n\nYes\n\nSample Input 5\n\n4\n2 2 2 2\n\nSample Output 5\n\nYes\n\nSample Input 6\n\n5\n3 3 3 3 3\n\nSample Output 6\n\nNo", "sample_input": "3\n1 2 2\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03688", "source_text": "Score : 700 points\n\nProblem Statement\n\nThere are N cats.\nWe number them from 1 through N.\n\nEach of the cats wears a hat.\nCat i says: \"there are exactly a_i different colors among the N - 1 hats worn by the cats except me.\"\n\nDetermine whether there exists a sequence of colors of the hats that is consistent with the remarks of the cats.\n\nConstraints\n\n2 ≤ N ≤ 10^5\n\n1 ≤ a_i ≤ N-1\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 ... a_N\n\nOutput\n\nPrint Yes if there exists a sequence of colors of the hats that is consistent with the remarks of the cats; print No otherwise.\n\nSample Input 1\n\n3\n1 2 2\n\nSample Output 1\n\nYes\n\nFor example, if cat 1, 2 and 3 wears red, blue and blue hats, respectively, it is consistent with the remarks of the cats.\n\nSample Input 2\n\n3\n1 1 2\n\nSample Output 2\n\nNo\n\nFrom the remark of cat 1, we can see that cat 2 and 3 wear hats of the same color.\nAlso, from the remark of cat 2, we can see that cat 1 and 3 wear hats of the same color.\nTherefore, cat 1 and 2 wear hats of the same color, which contradicts the remark of cat 3.\n\nSample Input 3\n\n5\n4 3 4 3 4\n\nSample Output 3\n\nNo\n\nSample Input 4\n\n3\n2 2 2\n\nSample Output 4\n\nYes\n\nSample Input 5\n\n4\n2 2 2 2\n\nSample Output 5\n\nYes\n\nSample Input 6\n\n5\n3 3 3 3 3\n\nSample Output 6\n\nNo", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 418, "cpu_time_ms": 52, "memory_kb": 5376}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s289677032", "group_id": "codeNet:p03693", "input_text": "let result = Scanf.scanf \"%d %d %d\\n\" (fun x y z -> if (10*y+z) mod 4 = 0 then \"YES\" else \"NO\") ;;\nprint_endline result;;", "language": "OCaml", "metadata": {"date": 1497222720, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03693.html", "problem_id": "p03693", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03693/input.txt", "sample_output_relpath": "derived/input_output/data/p03693/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03693/OCaml/s289677032.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s289677032", "user_id": "u161156777"}, "prompt_components": {"gold_output": "YES\n", "input_to_evaluate": "let result = Scanf.scanf \"%d %d %d\\n\" (fun x y z -> if (10*y+z) mod 4 = 0 then \"YES\" else \"NO\") ;;\nprint_endline result;;", "problem_context": "Score : 100 points\n\nProblem Statement\n\nAtCoDeer has three cards, one red, one green and one blue.\n\nAn integer between 1 and 9 (inclusive) is written on each card: r on the red card, g on the green card and b on the blue card.\n\nWe will arrange the cards in the order red, green and blue from left to right, and read them as a three-digit integer.\n\nIs this integer a multiple of 4?\n\nConstraints\n\n1 ≤ r, g, b ≤ 9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nr g b\n\nOutput\n\nIf the three-digit integer is a multiple of 4, print YES (case-sensitive); otherwise, print NO.\n\nSample Input 1\n\n4 3 2\n\nSample Output 1\n\nYES\n\n432 is a multiple of 4, and thus YES should be printed.\n\nSample Input 2\n\n2 3 4\n\nSample Output 2\n\nNO\n\n234 is not a multiple of 4, and thus NO should be printed.", "sample_input": "4 3 2\n"}, "reference_outputs": ["YES\n"], "source_document_id": "p03693", "source_text": "Score : 100 points\n\nProblem Statement\n\nAtCoDeer has three cards, one red, one green and one blue.\n\nAn integer between 1 and 9 (inclusive) is written on each card: r on the red card, g on the green card and b on the blue card.\n\nWe will arrange the cards in the order red, green and blue from left to right, and read them as a three-digit integer.\n\nIs this integer a multiple of 4?\n\nConstraints\n\n1 ≤ r, g, b ≤ 9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nr g b\n\nOutput\n\nIf the three-digit integer is a multiple of 4, print YES (case-sensitive); otherwise, print NO.\n\nSample Input 1\n\n4 3 2\n\nSample Output 1\n\nYES\n\n432 is a multiple of 4, and thus YES should be printed.\n\nSample Input 2\n\n2 3 4\n\nSample Output 2\n\nNO\n\n234 is not a multiple of 4, and thus NO should be printed.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s346475075", "group_id": "codeNet:p03693", "input_text": "let result = Scanf.scanf \" %d %d %d/n\" (fun x y z -> if 10*y+z mod 4 = 0 then true else false) ;;\nmatch result with\n| true -> print_endline \"YES\";\n| false -> print_endline \"NO\";", "language": "OCaml", "metadata": {"date": 1497221154, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03693.html", "problem_id": "p03693", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03693/input.txt", "sample_output_relpath": "derived/input_output/data/p03693/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03693/OCaml/s346475075.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s346475075", "user_id": "u161156777"}, "prompt_components": {"gold_output": "YES\n", "input_to_evaluate": "let result = Scanf.scanf \" %d %d %d/n\" (fun x y z -> if 10*y+z mod 4 = 0 then true else false) ;;\nmatch result with\n| true -> print_endline \"YES\";\n| false -> print_endline \"NO\";", "problem_context": "Score : 100 points\n\nProblem Statement\n\nAtCoDeer has three cards, one red, one green and one blue.\n\nAn integer between 1 and 9 (inclusive) is written on each card: r on the red card, g on the green card and b on the blue card.\n\nWe will arrange the cards in the order red, green and blue from left to right, and read them as a three-digit integer.\n\nIs this integer a multiple of 4?\n\nConstraints\n\n1 ≤ r, g, b ≤ 9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nr g b\n\nOutput\n\nIf the three-digit integer is a multiple of 4, print YES (case-sensitive); otherwise, print NO.\n\nSample Input 1\n\n4 3 2\n\nSample Output 1\n\nYES\n\n432 is a multiple of 4, and thus YES should be printed.\n\nSample Input 2\n\n2 3 4\n\nSample Output 2\n\nNO\n\n234 is not a multiple of 4, and thus NO should be printed.", "sample_input": "4 3 2\n"}, "reference_outputs": ["YES\n"], "source_document_id": "p03693", "source_text": "Score : 100 points\n\nProblem Statement\n\nAtCoDeer has three cards, one red, one green and one blue.\n\nAn integer between 1 and 9 (inclusive) is written on each card: r on the red card, g on the green card and b on the blue card.\n\nWe will arrange the cards in the order red, green and blue from left to right, and read them as a three-digit integer.\n\nIs this integer a multiple of 4?\n\nConstraints\n\n1 ≤ r, g, b ≤ 9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nr g b\n\nOutput\n\nIf the three-digit integer is a multiple of 4, print YES (case-sensitive); otherwise, print NO.\n\nSample Input 1\n\n4 3 2\n\nSample Output 1\n\nYES\n\n432 is a multiple of 4, and thus YES should be printed.\n\nSample Input 2\n\n2 3 4\n\nSample Output 2\n\nNO\n\n234 is not a multiple of 4, and thus NO should be printed.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s499332395", "group_id": "codeNet:p03694", "input_text": "Scanf.scanf \"%d\" @@ fun n ->\n let a_s = Array.init n @@ fun i -> Scanf.scanf \" %d\" @@ (+) 0 in\n Array.sort compare a_s;\n a_s.(Array.length a_s - 1) - a_s.(0) |> Printf.printf \"%d\\n\"", "language": "OCaml", "metadata": {"date": 1558383426, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03694.html", "problem_id": "p03694", "resource_group": "low_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/OCaml/s499332395.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s499332395", "user_id": "u732304692"}, "prompt_components": {"gold_output": "7\n", "input_to_evaluate": "Scanf.scanf \"%d\" @@ fun n ->\n let a_s = Array.init n @@ fun i -> Scanf.scanf \" %d\" @@ (+) 0 in\n Array.sort compare a_s;\n a_s.(Array.length a_s - 1) - a_s.(0) |> Printf.printf \"%d\\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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 184, "cpu_time_ms": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s460652111", "group_id": "codeNet:p03695", "input_text": "let () = Scanf.scanf \"%d\\n\" @@ fun n ->\n let as_, bs =\n List.partition (( <= ) 3200) @@\n Array.to_list @@\n Array.init n @@ fun _ ->\n Scanf.scanf \"%d \" @@ fun a -> a in\n let x = List.length as_ in\n let y =\n List.length @@\n List.sort_uniq compare @@\n List.map (fun a -> a / 400) bs in\n Printf.printf \"%d %d\\n\" (max (min 1 x) y) (x + y)", "language": "OCaml", "metadata": {"date": 1538590623, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03695.html", "problem_id": "p03695", "resource_group": "low_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/OCaml/s460652111.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s460652111", "user_id": "u504158101"}, "prompt_components": {"gold_output": "2 2\n", "input_to_evaluate": "let () = Scanf.scanf \"%d\\n\" @@ fun n ->\n let as_, bs =\n List.partition (( <= ) 3200) @@\n Array.to_list @@\n Array.init n @@ fun _ ->\n Scanf.scanf \"%d \" @@ fun a -> a in\n let x = List.length as_ in\n let y =\n List.length @@\n List.sort_uniq compare @@\n List.map (fun a -> a / 400) bs in\n Printf.printf \"%d %d\\n\" (max (min 1 x) y) (x + y)", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 360, "cpu_time_ms": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s411751913", "group_id": "codeNet:p03695", "input_text": "open Str\nopen List\n\nlet get_int () = int_of_string (read_line ());;\n\nlet rec to_int sep =\n match sep with \n | [] -> []\n | a :: b -> \n (int_of_string a) :: (to_int b);;\n\nlet rec to_color rates =\n match rates with\n | [] -> []\n | fst :: rst -> (fst / 400) :: (to_color rst)\n\nlet rec print_int_arr arr =\n match arr with\n | [] -> ()\n | fst :: rst -> Printf.printf \"%d\\n\" fst; print_int_arr rst;;\n\nlet get_int_arr () = \n to_int (Str.split (Str.regexp \" \") (read_line ()));;\n\nlet main =\n let _ = read_line () in\n let a = to_color (get_int_arr ()) in\n let const = List.length (List.sort_uniq (fun x y -> x - y) (List.filter (fun b -> b < 8) a)) in\n let change = List.length (List.filter (fun b -> b > 7) a) in\n \n Printf.printf \"%d \" const;\n Printf.printf \"%d\\n\" (if const + change < 9 then const + change else 8);\n", "language": "OCaml", "metadata": {"date": 1531321447, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03695.html", "problem_id": "p03695", "resource_group": "low_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/OCaml/s411751913.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s411751913", "user_id": "u605917063"}, "prompt_components": {"gold_output": "2 2\n", "input_to_evaluate": "open Str\nopen List\n\nlet get_int () = int_of_string (read_line ());;\n\nlet rec to_int sep =\n match sep with \n | [] -> []\n | a :: b -> \n (int_of_string a) :: (to_int b);;\n\nlet rec to_color rates =\n match rates with\n | [] -> []\n | fst :: rst -> (fst / 400) :: (to_color rst)\n\nlet rec print_int_arr arr =\n match arr with\n | [] -> ()\n | fst :: rst -> Printf.printf \"%d\\n\" fst; print_int_arr rst;;\n\nlet get_int_arr () = \n to_int (Str.split (Str.regexp \" \") (read_line ()));;\n\nlet main =\n let _ = read_line () in\n let a = to_color (get_int_arr ()) in\n let const = List.length (List.sort_uniq (fun x y -> x - y) (List.filter (fun b -> b < 8) a)) in\n let change = List.length (List.filter (fun b -> b > 7) a) in\n \n Printf.printf \"%d \" const;\n Printf.printf \"%d\\n\" (if const + change < 9 then const + change else 8);\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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s835966548", "group_id": "codeNet:p03696", "input_text": "open Str\n \nlet () =\n let _ = read_line () in\n let s = split (regexp \"\") (read_line ()) in\n let f (l, st) x =\n match st with\n [] -> if x = \")\" then (l+1, []) else (l, [\"(\"])\n | y :: ys -> if x = \")\" && y = \"(\" then (l, ys) else (l, \"(\"::y::ys) in\n let (l, r) = List.fold_left f (0,[]) s in\n String.make l '(' ^ String.concat \"\" s ^ String.make (List.length r) ')' |> print_endline\n", "language": "OCaml", "metadata": {"date": 1497148213, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03696.html", "problem_id": "p03696", "resource_group": "low_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/OCaml/s835966548.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s835966548", "user_id": "u388783188"}, "prompt_components": {"gold_output": "(())\n", "input_to_evaluate": "open Str\n \nlet () =\n let _ = read_line () in\n let s = split (regexp \"\") (read_line ()) in\n let f (l, st) x =\n match st with\n [] -> if x = \")\" then (l+1, []) else (l, [\"(\"])\n | y :: ys -> if x = \")\" && y = \"(\" then (l, ys) else (l, \"(\"::y::ys) in\n let (l, r) = List.fold_left f (0,[]) s in\n String.make l '(' ^ String.concat \"\" s ^ String.make (List.length r) ')' |> print_endline\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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 402, "cpu_time_ms": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s261528536", "group_id": "codeNet:p03697", "input_text": "let f a b =\n let s = a + b in\n if s >= 10 then print_endline \"error\"\n else Printf.printf \"%d\\n\" s\n\nlet () = Scanf.scanf \"%d %d\" f", "language": "OCaml", "metadata": {"date": 1524966747, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03697.html", "problem_id": "p03697", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03697/input.txt", "sample_output_relpath": "derived/input_output/data/p03697/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03697/OCaml/s261528536.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s261528536", "user_id": "u987869509"}, "prompt_components": {"gold_output": "9\n", "input_to_evaluate": "let f a b =\n let s = a + b in\n if s >= 10 then print_endline \"error\"\n else Printf.printf \"%d\\n\" s\n\nlet () = Scanf.scanf \"%d %d\" f", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou are given two integers A and B as the input. Output the value of A + B.\n\nHowever, if A + B is 10 or greater, output error instead.\n\nConstraints\n\nA and B are integers.\n\n1 ≤ A, B ≤ 9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nIf A + B is 10 or greater, print the string error (case-sensitive); otherwise, print the value of A + B.\n\nSample Input 1\n\n6 3\n\nSample Output 1\n\n9\n\nSample Input 2\n\n6 4\n\nSample Output 2\n\nerror", "sample_input": "6 3\n"}, "reference_outputs": ["9\n"], "source_document_id": "p03697", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou are given two integers A and B as the input. Output the value of A + B.\n\nHowever, if A + B is 10 or greater, output error instead.\n\nConstraints\n\nA and B are integers.\n\n1 ≤ A, B ≤ 9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nIf A + B is 10 or greater, print the string error (case-sensitive); otherwise, print the value of A + B.\n\nSample Input 1\n\n6 3\n\nSample Output 1\n\n9\n\nSample Input 2\n\n6 4\n\nSample Output 2\n\nerror", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s772004739", "group_id": "codeNet:p03699", "input_text": "let id x = x\nlet n = Scanf.scanf \"%d\\n\" id\n \nlet array = Array.init n (fun _ -> Scanf.scanf \"%d\\n\" id)\nlet () = Array.sort compare array\nlet l = Array.length array\n \nlet rec pl i =\n if i = l then 0 else\n array.(i) + pl (i+1)\n \nlet rec func max i =\n if i = l then 0 else\n if ((max - array.(i)) mod 10 <> 0) then max - array.(i) else\n func max (i+1)\n \nlet m = pl 0 \nlet ans = if m mod 10 <> 0 then m else func (pl 0) 0\n \nlet () =\n Printf.printf \"%d\\n\" ans", "language": "OCaml", "metadata": {"date": 1496547605, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03699.html", "problem_id": "p03699", "resource_group": "low_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/OCaml/s772004739.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s772004739", "user_id": "u735499035"}, "prompt_components": {"gold_output": "25\n", "input_to_evaluate": "let id x = x\nlet n = Scanf.scanf \"%d\\n\" id\n \nlet array = Array.init n (fun _ -> Scanf.scanf \"%d\\n\" id)\nlet () = Array.sort compare array\nlet l = Array.length array\n \nlet rec pl i =\n if i = l then 0 else\n array.(i) + pl (i+1)\n \nlet rec func max i =\n if i = l then 0 else\n if ((max - array.(i)) mod 10 <> 0) then max - array.(i) else\n func max (i+1)\n \nlet m = pl 0 \nlet ans = if m mod 10 <> 0 then m else func (pl 0) 0\n \nlet () =\n Printf.printf \"%d\\n\" ans", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s046599841", "group_id": "codeNet:p03699", "input_text": "let id x = x\nlet n = Scanf.scanf \"%d\\n\" id\n \nlet array = Array.init n (fun _ -> Scanf.scanf \"%d\\n\" id)\nlet l = Array.length array\n \nlet rec pl i =\n if i = l then 0 else\n array.(i) + pl (i+1)\n \nlet rec func max i =\n if i = l then 0 else\n if ((max - array.(i)) mod 10 <> 0) then max - array.(i) else\n func max (i+1)\n\nlet m = pl 0 \nlet ans = if m mod 10 <> 0 then m else func (pl 0) 0\n\nlet () =\n Array.sort compare array;\n Printf.printf \"%d\\n\" ans", "language": "OCaml", "metadata": {"date": 1496542412, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03699.html", "problem_id": "p03699", "resource_group": "low_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/OCaml/s046599841.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s046599841", "user_id": "u735499035"}, "prompt_components": {"gold_output": "25\n", "input_to_evaluate": "let id x = x\nlet n = Scanf.scanf \"%d\\n\" id\n \nlet array = Array.init n (fun _ -> Scanf.scanf \"%d\\n\" id)\nlet l = Array.length array\n \nlet rec pl i =\n if i = l then 0 else\n array.(i) + pl (i+1)\n \nlet rec func max i =\n if i = l then 0 else\n if ((max - array.(i)) mod 10 <> 0) then max - array.(i) else\n func max (i+1)\n\nlet m = pl 0 \nlet ans = if m mod 10 <> 0 then m else func (pl 0) 0\n\nlet () =\n Array.sort compare array;\n Printf.printf \"%d\\n\" ans", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 471, "cpu_time_ms": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s678677579", "group_id": "codeNet:p03700", "input_text": "let id x = x\nlet (n,a,b) = Scanf.scanf \"%d %d %d\\n\" (fun n a b -> (n,a,b))\n \nlet array = Array.init n (fun _ -> Scanf.scanf \"%d\\n\" id)\nlet () = Array.sort compare array\nlet l = Array.length array\n\nlet max = array.(l-1) / b\n\nlet rec func1 tmid i m =\n if i = l then m else\n let x = array.(i) - b*tmid in\n if x < 0 then func1 tmid (i+1) m\n else if x mod (a-b) = 0 then func1 tmid (i+1) (m + x/(a-b))\n else func1 tmid (i+1) (m + 1+x/(a-b))\n\nlet rec func tmin tmax =\n let tmid = (tmax + tmin) / 2 in\n let tsuika = func1 tmid 0 0 in\n if tsuika <= tmid then (if tmax - tmin = 1 then tmin else func tmin tmid)\n else (if tmax - tmin = 1 then tmax else func tmid tmax)\n\nlet ans = if max <= 1 then 1 else func 1 max\n\nlet () =\n Printf.printf \"%d\\n\" ans", "language": "OCaml", "metadata": {"date": 1496629846, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03700.html", "problem_id": "p03700", "resource_group": "low_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/OCaml/s678677579.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s678677579", "user_id": "u735499035"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "let id x = x\nlet (n,a,b) = Scanf.scanf \"%d %d %d\\n\" (fun n a b -> (n,a,b))\n \nlet array = Array.init n (fun _ -> Scanf.scanf \"%d\\n\" id)\nlet () = Array.sort compare array\nlet l = Array.length array\n\nlet max = array.(l-1) / b\n\nlet rec func1 tmid i m =\n if i = l then m else\n let x = array.(i) - b*tmid in\n if x < 0 then func1 tmid (i+1) m\n else if x mod (a-b) = 0 then func1 tmid (i+1) (m + x/(a-b))\n else func1 tmid (i+1) (m + 1+x/(a-b))\n\nlet rec func tmin tmax =\n let tmid = (tmax + tmin) / 2 in\n let tsuika = func1 tmid 0 0 in\n if tsuika <= tmid then (if tmax - tmin = 1 then tmin else func tmin tmid)\n else (if tmax - tmin = 1 then tmax else func tmid tmax)\n\nlet ans = if max <= 1 then 1 else func 1 max\n\nlet () =\n Printf.printf \"%d\\n\" ans", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 758, "cpu_time_ms": 148, "memory_kb": 5120}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s018162237", "group_id": "codeNet:p03711", "input_text": "let () = Scanf.scanf \"%d %d\\n\" \n\t(fun x y -> let l = [4;6;9;11] in\n Printf.printf \"%s\\n\"\n (if List.mem x l && List.mem y l || x = 2 && y = 2 || x <> 2 && y <> 2 && not (List.mem x l || List.mem y l) \n then \"Yes\" else \"No\"))", "language": "OCaml", "metadata": {"date": 1582403843, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03711.html", "problem_id": "p03711", "resource_group": "low_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/OCaml/s018162237.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s018162237", "user_id": "u307426615"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "let () = Scanf.scanf \"%d %d\\n\" \n\t(fun x y -> let l = [4;6;9;11] in\n Printf.printf \"%s\\n\"\n (if List.mem x l && List.mem y l || x = 2 && y = 2 || x <> 2 && y <> 2 && not (List.mem x l || List.mem y l) \n then \"Yes\" else \"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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 2, "memory_kb": 4480}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s537049062", "group_id": "codeNet:p03711", "input_text": "let g x = if List.mem x [4;6;9;11] then 1 else (if List.mem x [2] then 2 else 3);;\nlet calc a b = if g a=g b then \"Yes\" else \"No\";;\nScanf.scanf \"%d %d\" calc\n|> Printf.printf \"%s\\n\"", "language": "OCaml", "metadata": {"date": 1561000892, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03711.html", "problem_id": "p03711", "resource_group": "low_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/OCaml/s537049062.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s537049062", "user_id": "u635974378"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "let g x = if List.mem x [4;6;9;11] then 1 else (if List.mem x [2] then 2 else 3);;\nlet calc a b = if g a=g b then \"Yes\" else \"No\";;\nScanf.scanf \"%d %d\" calc\n|> Printf.printf \"%s\\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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s894323384", "group_id": "codeNet:p03712", "input_text": "let h, w = Scanf.scanf \" %d %d\" @@ fun a b -> a, b\nlet a_ss = Array.init h @@ fun _ -> Scanf.scanf \" %s\" @@ fun s -> s\nlet s = String.make (w + 2) '#'\nlet _ = print_endline s; Array.iter (Printf.printf \"#%s#\\n\") a_ss; print_endline s", "language": "OCaml", "metadata": {"date": 1564827456, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03712.html", "problem_id": "p03712", "resource_group": "low_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/OCaml/s894323384.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s894323384", "user_id": "u732304692"}, "prompt_components": {"gold_output": "#####\n#abc#\n#arc#\n#####\n", "input_to_evaluate": "let h, w = Scanf.scanf \" %d %d\" @@ fun a b -> a, b\nlet a_ss = Array.init h @@ fun _ -> Scanf.scanf \" %s\" @@ fun s -> s\nlet s = String.make (w + 2) '#'\nlet _ = print_endline s; Array.iter (Printf.printf \"#%s#\\n\") a_ss; print_endline s", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 512}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s265462461", "group_id": "codeNet:p03712", "input_text": "let () =\n let h, w = Scanf.scanf \"%d %d\" (fun h w -> h, w) in\n let a = Array.init h (fun _ -> Scanf.scanf \" %s\" (fun s -> s)) in\n String.init (w+2) (fun _ -> '#') |> print_endline;\n Array.iter (Printf.printf \"#%s#\\n\") a;\n String.init (w+2) (fun _ -> '#') |> print_endline\n", "language": "OCaml", "metadata": {"date": 1519790093, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03712.html", "problem_id": "p03712", "resource_group": "low_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/OCaml/s265462461.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s265462461", "user_id": "u798181098"}, "prompt_components": {"gold_output": "#####\n#abc#\n#arc#\n#####\n", "input_to_evaluate": "let () =\n let h, w = Scanf.scanf \"%d %d\" (fun h w -> h, w) in\n let a = Array.init h (fun _ -> Scanf.scanf \" %s\" (fun s -> s)) in\n String.init (w+2) (fun _ -> '#') |> print_endline;\n Array.iter (Printf.printf \"#%s#\\n\") a;\n String.init (w+2) (fun _ -> '#') |> print_endline\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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 512}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s821174335", "group_id": "codeNet:p03713", "input_text": "let diff3 a b c = max a (max b c) - min a (min b c)\nlet calc a b =\n let sub_calc s0 a' b' =\n let d0 = diff3 s0 (a'/2*b') ((a'-a'/2)*b') in\n let d1 = diff3 s0 (b'/2*a') ((b'-b'/2)*a') in\n min d0 d1\n in\n [ sub_calc (a/3*b) (a-a/3) b;\n sub_calc ((a+3)/3*b) (a-(a+3)/3) b;\n sub_calc (b/3*a) a (b-b/3);\n sub_calc ((b+3)/3*a) a (b-(b+3)/3);\n ] |> List.fold_left min 1010101010101010\nlet h, w = Scanf.scanf \"%d %d\" (fun x y -> x, y)\nlet () = calc h w |> Printf.printf \"%d\\n\"\n", "language": "OCaml", "metadata": {"date": 1528051970, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03713.html", "problem_id": "p03713", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03713/input.txt", "sample_output_relpath": "derived/input_output/data/p03713/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03713/OCaml/s821174335.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s821174335", "user_id": "u798181098"}, "prompt_components": {"gold_output": "0\n", "input_to_evaluate": "let diff3 a b c = max a (max b c) - min a (min b c)\nlet calc a b =\n let sub_calc s0 a' b' =\n let d0 = diff3 s0 (a'/2*b') ((a'-a'/2)*b') in\n let d1 = diff3 s0 (b'/2*a') ((b'-b'/2)*a') in\n min d0 d1\n in\n [ sub_calc (a/3*b) (a-a/3) b;\n sub_calc ((a+3)/3*b) (a-(a+3)/3) b;\n sub_calc (b/3*a) a (b-b/3);\n sub_calc ((b+3)/3*a) a (b-(b+3)/3);\n ] |> List.fold_left min 1010101010101010\nlet h, w = Scanf.scanf \"%d %d\" (fun x y -> x, y)\nlet () = calc h w |> Printf.printf \"%d\\n\"\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nThere is a bar of chocolate with a height of H blocks and a width of W blocks.\nSnuke is dividing this bar into exactly three pieces.\nHe can only cut the bar along borders of blocks, and the shape of each piece must be a rectangle.\n\nSnuke is trying to divide the bar as evenly as possible.\nMore specifically, he is trying to minimize S_{max} - S_{min}, where S_{max} is the area (the number of blocks contained) of the largest piece, and S_{min} is the area of the smallest piece.\nFind the minimum possible value of S_{max} - S_{min}.\n\nConstraints\n\n2 ≤ H, W ≤ 10^5\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\n\nOutput\n\nPrint the minimum possible value of S_{max} - S_{min}.\n\nSample Input 1\n\n3 5\n\nSample Output 1\n\n0\n\nIn the division below, S_{max} - S_{min} = 5 - 5 = 0.\n\nSample Input 2\n\n4 5\n\nSample Output 2\n\n2\n\nIn the division below, S_{max} - S_{min} = 8 - 6 = 2.\n\nSample Input 3\n\n5 5\n\nSample Output 3\n\n4\n\nIn the division below, S_{max} - S_{min} = 10 - 6 = 4.\n\nSample Input 4\n\n100000 2\n\nSample Output 4\n\n1\n\nSample Input 5\n\n100000 100000\n\nSample Output 5\n\n50000", "sample_input": "3 5\n"}, "reference_outputs": ["0\n"], "source_document_id": "p03713", "source_text": "Score : 400 points\n\nProblem Statement\n\nThere is a bar of chocolate with a height of H blocks and a width of W blocks.\nSnuke is dividing this bar into exactly three pieces.\nHe can only cut the bar along borders of blocks, and the shape of each piece must be a rectangle.\n\nSnuke is trying to divide the bar as evenly as possible.\nMore specifically, he is trying to minimize S_{max} - S_{min}, where S_{max} is the area (the number of blocks contained) of the largest piece, and S_{min} is the area of the smallest piece.\nFind the minimum possible value of S_{max} - S_{min}.\n\nConstraints\n\n2 ≤ H, W ≤ 10^5\n\nInput\n\nInput is given from Standard Input in the following format:\n\nH W\n\nOutput\n\nPrint the minimum possible value of S_{max} - S_{min}.\n\nSample Input 1\n\n3 5\n\nSample Output 1\n\n0\n\nIn the division below, S_{max} - S_{min} = 5 - 5 = 0.\n\nSample Input 2\n\n4 5\n\nSample Output 2\n\n2\n\nIn the division below, S_{max} - S_{min} = 8 - 6 = 2.\n\nSample Input 3\n\n5 5\n\nSample Output 3\n\n4\n\nIn the division below, S_{max} - S_{min} = 10 - 6 = 4.\n\nSample Input 4\n\n100000 2\n\nSample Output 4\n\n1\n\nSample Input 5\n\n100000 100000\n\nSample Output 5\n\n50000", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 490, "cpu_time_ms": 1, "memory_kb": 2432}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s079445749", "group_id": "codeNet:p03718", "input_text": "module DirectedGraph\n (* 道の表現 *)\n (Path : sig\n type t\n (* 辺の名前 *)\n type edge\n (* 長さ0の道 *)\n val nil : t\n (* 道の後ろに辺を付け足した道 *)\n val snoc : t -> edge -> t\n end) :\nsig\n (* BFSにより,重みのないグラフの最短経路を求める *)\n val bfs :\n (* 頂点数(Hashtblを用いるので目安程度) *)\n int ->\n (* 辺の名前が付いた隣接リスト *)\n ('v -> ('v * Path.edge) list) ->\n (* 始点 *)\n 'v ->\n (* 最短経路を返す関数 辿り着けなければNoneを返す) *)\n ('v -> Path.t option)\nend = struct\n let rec bfs_aux es d frontier t =\n try Some (Hashtbl.find d t) with\n | Not_found ->\n match !frontier with\n | [] -> None\n | _ :: _ ->\n frontier := List.fold_right (fun u ->\n List.fold_right (fun (v, e) frontier ->\n if Hashtbl.mem d v\n then frontier\n else (Hashtbl.add d v (Path.snoc (Hashtbl.find d u) e); v :: frontier))\n (es u)) !frontier [];\n bfs_aux es d frontier t\n\n (*\n * 終点に辿り着いた時点で探索を切り上げるが,\n * 戻り値の関数を覚えておくと,途中まで探索した結果が再利用される\n * (#trace bfs_aux すると分かりやすい)\n *)\n let bfs n es s =\n let d = Hashtbl.create n in\n Hashtbl.add d s Path.nil;\n let frontier = ref [s] in\n bfs_aux es d frontier\nend\n\nmodule FlowNetwork\n (* 流量 *)\n (Flow : sig\n type t\n val inf : t\n val zero : t\n val ( + ) : t -> t -> t\n val ( - ) : t -> t -> t\n val compare : t -> t -> int\n end) :\nsig\n val max_flow :\n (* 頂点の数(Hashtblを用いるので目安程度) *)\n int ->\n (* 各辺とその逆辺の容量 *)\n ('v * 'v * Flow.t * Flow.t) list ->\n (* 始点 *)\n 'v ->\n (* 終点 *)\n 'v ->\n (* 最大フロー *)\n Flow.t\nend =\nstruct\n module G = DirectedGraph (struct\n type t = int\n type edge = unit\n let nil = 0\n let snoc t _ = t + 1\n end)\n\n (* 増加パスをDFSで探し,流せるだけ流していく *)\n let rec dfs capacity add_edge iter level v t f =\n if v = t then f\n else begin\n let rec find () =\n match Hashtbl.find iter v with\n | exception Not_found -> Flow.zero\n | (u, i) ->\n Hashtbl.remove iter v;\n (* capacity i <= 0 *)\n if Flow.compare (capacity i) Flow.zero <= 0 || level u <= level v then find ()\n else begin\n let d = dfs capacity add_edge iter level u t @@\n (* min f (capacity i) *)\n if Flow.compare f (capacity i) <= 0 then f else capacity i in\n (* d <= 0 *)\n if Flow.compare d Flow.zero <= 0 then find ()\n else (add_edge i d; d)\n end in find ()\n end\n\n let max_flow n es s t =\n assert (s <> t);\n (* 各辺に流せる流量 *)\n let capacity = Array.make (2 * List.length es) Flow.zero in\n (* 逆辺を張りつつ,隣接リスト形式に変換 *)\n let adj = Hashtbl.create n in\n List.iteri (fun i (u, v, c, c') ->\n (* 各辺は番号で管理する *)\n Hashtbl.add adj u (v, 2 * i);\n (* 容量はcapacityを見てほしい *)\n capacity.(2 * i) <- c;\n (* 逆辺 *)\n Hashtbl.add adj v (u, 2 * i + 1);\n capacity.(2 * i + 1) <- c') es;\n (* 番号iの辺にcだけフローを流す *)\n let add_edge i c =\n let open Flow in\n capacity.(i) <- capacity.(i) - c;\n (* 逆辺 *)\n capacity.(i lxor 1) <- capacity.(i lxor 1) + c in\n let rec outer flow =\n let level = G.bfs n (fun v ->\n List.concat @@ List.map (fun (u, i) ->\n if Flow.compare capacity.(i) Flow.zero <= 0 then []\n else [(u, ())]) @@ Hashtbl.find_all adj v) s in\n if level t = None then flow\n else\n let iter = Hashtbl.copy adj in\n let rec inner flow =\n let f = dfs (fun i -> capacity.(i)) add_edge iter level s t Flow.inf in\n if Flow.compare f Flow.zero <= 0 then flow\n else inner (Flow.( + ) flow f) in\n outer @@ inner flow in\n outer Flow.zero\nend\n\nmodule G = FlowNetwork (struct\n include Pervasives\n type t = int\n let zero = 0\n let inf = max_int\nend)\n\nlet () = Scanf.scanf \"%d %d\\n\" @@ fun h w ->\n let ass = Array.init h @@ fun _ -> Scanf.scanf \"%s\\n\" @@ fun s -> s in\n let yxs =\n List.concat @@ Array.to_list @@ Array.init h @@ fun y ->\n Array.to_list @@ Array.init w @@ fun x -> y, x in\n let [(sy, sx); (ty, tx)] =\n List.map (fun c ->\n List.find (fun (y, x) -> ass.(y).[x] = c) yxs) ['S'; 'T'] in\n Printf.printf \"%d\\n\" @@\n if sy = ty || sx = tx then -1\n else G.max_flow (2 + h + w)\n (List.concat @@ List.map (fun (y, x) ->\n match ass.(y).[x] with\n | '.' -> []\n | 'S' -> [(`Source, `Col x, 1, 0); (`Source, `Row y, 1, 0)]\n | 'T' -> [(`Sink, `Col x, 0, 1); (`Sink, `Row y, 0, 1)]\n | 'o' -> [(`Col x, `Row y, 1, 1)]) yxs) `Source `Sink\n", "language": "OCaml", "metadata": {"date": 1546558411, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03718.html", "problem_id": "p03718", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03718/input.txt", "sample_output_relpath": "derived/input_output/data/p03718/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03718/OCaml/s079445749.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s079445749", "user_id": "u504158101"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "module DirectedGraph\n (* 道の表現 *)\n (Path : sig\n type t\n (* 辺の名前 *)\n type edge\n (* 長さ0の道 *)\n val nil : t\n (* 道の後ろに辺を付け足した道 *)\n val snoc : t -> edge -> t\n end) :\nsig\n (* BFSにより,重みのないグラフの最短経路を求める *)\n val bfs :\n (* 頂点数(Hashtblを用いるので目安程度) *)\n int ->\n (* 辺の名前が付いた隣接リスト *)\n ('v -> ('v * Path.edge) list) ->\n (* 始点 *)\n 'v ->\n (* 最短経路を返す関数 辿り着けなければNoneを返す) *)\n ('v -> Path.t option)\nend = struct\n let rec bfs_aux es d frontier t =\n try Some (Hashtbl.find d t) with\n | Not_found ->\n match !frontier with\n | [] -> None\n | _ :: _ ->\n frontier := List.fold_right (fun u ->\n List.fold_right (fun (v, e) frontier ->\n if Hashtbl.mem d v\n then frontier\n else (Hashtbl.add d v (Path.snoc (Hashtbl.find d u) e); v :: frontier))\n (es u)) !frontier [];\n bfs_aux es d frontier t\n\n (*\n * 終点に辿り着いた時点で探索を切り上げるが,\n * 戻り値の関数を覚えておくと,途中まで探索した結果が再利用される\n * (#trace bfs_aux すると分かりやすい)\n *)\n let bfs n es s =\n let d = Hashtbl.create n in\n Hashtbl.add d s Path.nil;\n let frontier = ref [s] in\n bfs_aux es d frontier\nend\n\nmodule FlowNetwork\n (* 流量 *)\n (Flow : sig\n type t\n val inf : t\n val zero : t\n val ( + ) : t -> t -> t\n val ( - ) : t -> t -> t\n val compare : t -> t -> int\n end) :\nsig\n val max_flow :\n (* 頂点の数(Hashtblを用いるので目安程度) *)\n int ->\n (* 各辺とその逆辺の容量 *)\n ('v * 'v * Flow.t * Flow.t) list ->\n (* 始点 *)\n 'v ->\n (* 終点 *)\n 'v ->\n (* 最大フロー *)\n Flow.t\nend =\nstruct\n module G = DirectedGraph (struct\n type t = int\n type edge = unit\n let nil = 0\n let snoc t _ = t + 1\n end)\n\n (* 増加パスをDFSで探し,流せるだけ流していく *)\n let rec dfs capacity add_edge iter level v t f =\n if v = t then f\n else begin\n let rec find () =\n match Hashtbl.find iter v with\n | exception Not_found -> Flow.zero\n | (u, i) ->\n Hashtbl.remove iter v;\n (* capacity i <= 0 *)\n if Flow.compare (capacity i) Flow.zero <= 0 || level u <= level v then find ()\n else begin\n let d = dfs capacity add_edge iter level u t @@\n (* min f (capacity i) *)\n if Flow.compare f (capacity i) <= 0 then f else capacity i in\n (* d <= 0 *)\n if Flow.compare d Flow.zero <= 0 then find ()\n else (add_edge i d; d)\n end in find ()\n end\n\n let max_flow n es s t =\n assert (s <> t);\n (* 各辺に流せる流量 *)\n let capacity = Array.make (2 * List.length es) Flow.zero in\n (* 逆辺を張りつつ,隣接リスト形式に変換 *)\n let adj = Hashtbl.create n in\n List.iteri (fun i (u, v, c, c') ->\n (* 各辺は番号で管理する *)\n Hashtbl.add adj u (v, 2 * i);\n (* 容量はcapacityを見てほしい *)\n capacity.(2 * i) <- c;\n (* 逆辺 *)\n Hashtbl.add adj v (u, 2 * i + 1);\n capacity.(2 * i + 1) <- c') es;\n (* 番号iの辺にcだけフローを流す *)\n let add_edge i c =\n let open Flow in\n capacity.(i) <- capacity.(i) - c;\n (* 逆辺 *)\n capacity.(i lxor 1) <- capacity.(i lxor 1) + c in\n let rec outer flow =\n let level = G.bfs n (fun v ->\n List.concat @@ List.map (fun (u, i) ->\n if Flow.compare capacity.(i) Flow.zero <= 0 then []\n else [(u, ())]) @@ Hashtbl.find_all adj v) s in\n if level t = None then flow\n else\n let iter = Hashtbl.copy adj in\n let rec inner flow =\n let f = dfs (fun i -> capacity.(i)) add_edge iter level s t Flow.inf in\n if Flow.compare f Flow.zero <= 0 then flow\n else inner (Flow.( + ) flow f) in\n outer @@ inner flow in\n outer Flow.zero\nend\n\nmodule G = FlowNetwork (struct\n include Pervasives\n type t = int\n let zero = 0\n let inf = max_int\nend)\n\nlet () = Scanf.scanf \"%d %d\\n\" @@ fun h w ->\n let ass = Array.init h @@ fun _ -> Scanf.scanf \"%s\\n\" @@ fun s -> s in\n let yxs =\n List.concat @@ Array.to_list @@ Array.init h @@ fun y ->\n Array.to_list @@ Array.init w @@ fun x -> y, x in\n let [(sy, sx); (ty, tx)] =\n List.map (fun c ->\n List.find (fun (y, x) -> ass.(y).[x] = c) yxs) ['S'; 'T'] in\n Printf.printf \"%d\\n\" @@\n if sy = ty || sx = tx then -1\n else G.max_flow (2 + h + w)\n (List.concat @@ List.map (fun (y, x) ->\n match ass.(y).[x] with\n | '.' -> []\n | 'S' -> [(`Source, `Col x, 1, 0); (`Source, `Row y, 1, 0)]\n | 'T' -> [(`Sink, `Col x, 0, 1); (`Sink, `Row y, 0, 1)]\n | 'o' -> [(`Col x, `Row y, 1, 1)]) yxs) `Source `Sink\n", "problem_context": "Score : 800 points\n\nProblem Statement\n\nThere is a pond with a rectangular shape.\nThe pond is divided into a grid with H rows and W columns of squares.\nWe will denote the square at the i-th row from the top and j-th column from the left by (i,\\ j).\n\nSome of the squares in the pond contains a lotus leaf floating on the water.\nOn one of those leaves, S, there is a frog trying to get to another leaf T.\nThe state of square (i,\\ j) is given to you by a character a_{ij}, as follows:\n\n. : A square without a leaf.\n\no : A square with a leaf floating on the water.\n\nS : A square with the leaf S.\n\nT : A square with the leaf T.\n\nThe frog will repeatedly perform the following action to get to the leaf T: \"jump to a leaf that is in the same row or the same column as the leaf where the frog is currently located.\"\n\nSnuke is trying to remove some of the leaves, other than S and T, so that the frog cannot get to the leaf T.\nDetermine whether this objective is achievable. If it is achievable, find the minimum necessary number of leaves to remove.\n\nConstraints\n\n2 ≤ H, W ≤ 100\n\na_{ij} is ., o, S or T.\n\nThere is exactly one S among a_{ij}.\n\nThere is exactly one T among a_{ij}.\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\nIf the objective is achievable, print the minimum necessary number of leaves to remove.\nOtherwise, print -1 instead.\n\nSample Input 1\n\n3 3\nS.o\n.o.\no.T\n\nSample Output 1\n\n2\n\nRemove the upper-right and lower-left leaves.\n\nSample Input 2\n\n3 4\nS...\n.oo.\n...T\n\nSample Output 2\n\n0\n\nSample Input 3\n\n4 3\n.S.\n.o.\n.o.\n.T.\n\nSample Output 3\n\n-1\n\nSample Input 4\n\n10 10\n.o...o..o.\n....o.....\n....oo.oo.\n..oooo..o.\n....oo....\n..o..o....\no..o....So\no....T....\n....o.....\n........oo\n\nSample Output 4\n\n5", "sample_input": "3 3\nS.o\n.o.\no.T\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03718", "source_text": "Score : 800 points\n\nProblem Statement\n\nThere is a pond with a rectangular shape.\nThe pond is divided into a grid with H rows and W columns of squares.\nWe will denote the square at the i-th row from the top and j-th column from the left by (i,\\ j).\n\nSome of the squares in the pond contains a lotus leaf floating on the water.\nOn one of those leaves, S, there is a frog trying to get to another leaf T.\nThe state of square (i,\\ j) is given to you by a character a_{ij}, as follows:\n\n. : A square without a leaf.\n\no : A square with a leaf floating on the water.\n\nS : A square with the leaf S.\n\nT : A square with the leaf T.\n\nThe frog will repeatedly perform the following action to get to the leaf T: \"jump to a leaf that is in the same row or the same column as the leaf where the frog is currently located.\"\n\nSnuke is trying to remove some of the leaves, other than S and T, so that the frog cannot get to the leaf T.\nDetermine whether this objective is achievable. If it is achievable, find the minimum necessary number of leaves to remove.\n\nConstraints\n\n2 ≤ H, W ≤ 100\n\na_{ij} is ., o, S or T.\n\nThere is exactly one S among a_{ij}.\n\nThere is exactly one T among a_{ij}.\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\nIf the objective is achievable, print the minimum necessary number of leaves to remove.\nOtherwise, print -1 instead.\n\nSample Input 1\n\n3 3\nS.o\n.o.\no.T\n\nSample Output 1\n\n2\n\nRemove the upper-right and lower-left leaves.\n\nSample Input 2\n\n3 4\nS...\n.oo.\n...T\n\nSample Output 2\n\n0\n\nSample Input 3\n\n4 3\n.S.\n.o.\n.o.\n.T.\n\nSample Output 3\n\n-1\n\nSample Input 4\n\n10 10\n.o...o..o.\n....o.....\n....oo.oo.\n..oooo..o.\n....oo....\n..o..o....\no..o....So\no....T....\n....o.....\n........oo\n\nSample Output 4\n\n5", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 5063, "cpu_time_ms": 17, "memory_kb": 6912}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s487923907", "group_id": "codeNet:p03719", "input_text": "let solve (a : int) (b : int) (c : int) : string = if c >= a && c <= b then \"Yes\" else \"No\"\n\nlet () = Printf.printf \"%s\\n\" (Scanf.scanf \"%d %d %d\" solve)", "language": "OCaml", "metadata": {"date": 1496649014, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03719.html", "problem_id": "p03719", "resource_group": "low_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/OCaml/s487923907.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s487923907", "user_id": "u877969392"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "let solve (a : int) (b : int) (c : int) : string = if c >= a && c <= b then \"Yes\" else \"No\"\n\nlet () = Printf.printf \"%s\\n\" (Scanf.scanf \"%d %d %d\" solve)", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s735219026", "group_id": "codeNet:p03720", "input_text": "let () =\n let n, m = Scanf.scanf \"%d %d\" (fun n m -> n, m) in\n let es = Array.init m (fun _ -> Scanf.scanf \" %d %d\" (fun a b -> a-1, b-1)) in\n Array.init n (fun i ->\n Array.map (fun (a, b) -> if i = a || i = b then 1 else 0) es |> Array.fold_left (+) 0)\n |> Array.iter (Printf.printf \"%d\\n\")\n", "language": "OCaml", "metadata": {"date": 1519789887, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03720.html", "problem_id": "p03720", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03720/input.txt", "sample_output_relpath": "derived/input_output/data/p03720/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03720/OCaml/s735219026.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s735219026", "user_id": "u798181098"}, "prompt_components": {"gold_output": "2\n2\n1\n1\n", "input_to_evaluate": "let () =\n let n, m = Scanf.scanf \"%d %d\" (fun n m -> n, m) in\n let es = Array.init m (fun _ -> Scanf.scanf \" %d %d\" (fun a b -> a-1, b-1)) in\n Array.init n (fun i ->\n Array.map (fun (a, b) -> if i = a || i = b then 1 else 0) es |> Array.fold_left (+) 0)\n |> Array.iter (Printf.printf \"%d\\n\")\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nThere are N cities and M roads.\nThe i-th road (1≤i≤M) connects two cities a_i and b_i (1≤a_i,b_i≤N) bidirectionally.\nThere may be more than one road that connects the same pair of two cities.\nFor each city, how many roads are connected to the city?\n\nConstraints\n\n2≤N,M≤50\n\n1≤a_i,b_i≤N\n\na_i ≠ b_i\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\na_1 b_1\n:\na_M b_M\n\nOutput\n\nPrint the answer in N lines.\nIn the i-th line (1≤i≤N), print the number of roads connected to city i.\n\nSample Input 1\n\n4 3\n1 2\n2 3\n1 4\n\nSample Output 1\n\n2\n2\n1\n1\n\nCity 1 is connected to the 1-st and 3-rd roads.\n\nCity 2 is connected to the 1-st and 2-nd roads.\n\nCity 3 is connected to the 2-nd road.\n\nCity 4 is connected to the 3-rd road.\n\nSample Input 2\n\n2 5\n1 2\n2 1\n1 2\n2 1\n1 2\n\nSample Output 2\n\n5\n5\n\nSample Input 3\n\n8 8\n1 2\n3 4\n1 5\n2 8\n3 7\n5 2\n4 1\n6 8\n\nSample Output 3\n\n3\n3\n2\n2\n2\n1\n1\n2", "sample_input": "4 3\n1 2\n2 3\n1 4\n"}, "reference_outputs": ["2\n2\n1\n1\n"], "source_document_id": "p03720", "source_text": "Score : 200 points\n\nProblem Statement\n\nThere are N cities and M roads.\nThe i-th road (1≤i≤M) connects two cities a_i and b_i (1≤a_i,b_i≤N) bidirectionally.\nThere may be more than one road that connects the same pair of two cities.\nFor each city, how many roads are connected to the city?\n\nConstraints\n\n2≤N,M≤50\n\n1≤a_i,b_i≤N\n\na_i ≠ b_i\n\nAll input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\na_1 b_1\n:\na_M b_M\n\nOutput\n\nPrint the answer in N lines.\nIn the i-th line (1≤i≤N), print the number of roads connected to city i.\n\nSample Input 1\n\n4 3\n1 2\n2 3\n1 4\n\nSample Output 1\n\n2\n2\n1\n1\n\nCity 1 is connected to the 1-st and 3-rd roads.\n\nCity 2 is connected to the 1-st and 2-nd roads.\n\nCity 3 is connected to the 2-nd road.\n\nCity 4 is connected to the 3-rd road.\n\nSample Input 2\n\n2 5\n1 2\n2 1\n1 2\n2 1\n1 2\n\nSample Output 2\n\n5\n5\n\nSample Input 3\n\n8 8\n1 2\n3 4\n1 5\n2 8\n3 7\n5 2\n4 1\n6 8\n\nSample Output 3\n\n3\n3\n2\n2\n2\n1\n1\n2", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s753440372", "group_id": "codeNet:p03721", "input_text": "let n, k = Scanf.scanf \" %d %d\" @@ fun a b -> a, b\nlet ab_s = Array.init n @@ fun _ -> Scanf.scanf \" %d %d\" @@ fun a b -> a, b\nlet _ = Array.(sort compare ab_s; fold_left (fun r (a, b) -> if r + b >= k then (Printf.printf \"%d\\n\" a; exit 0); r + b) 0 ab_s)", "language": "OCaml", "metadata": {"date": 1570112979, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03721.html", "problem_id": "p03721", "resource_group": "low_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/OCaml/s753440372.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s753440372", "user_id": "u732304692"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "let n, k = Scanf.scanf \" %d %d\" @@ fun a b -> a, b\nlet ab_s = Array.init n @@ fun _ -> Scanf.scanf \" %d %d\" @@ fun a b -> a, b\nlet _ = Array.(sort compare ab_s; fold_left (fun r (a, b) -> if r + b >= k then (Printf.printf \"%d\\n\" a; exit 0); r + b) 0 ab_s)", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 135, "memory_kb": 6784}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s142987296", "group_id": "codeNet:p03721", "input_text": "open Batteries\nlet n, k = Scanf.scanf \"%d %d\" (fun x y -> x, y)\nlet arr = Array.make 100010 0\nlet () =\n (1--n) |> Enum.iter begin fun _ ->\n Scanf.scanf \" %d %d\" (fun a b -> arr.(a) <- arr.(a) + b)\n end;\n (1--n) |> Enum.iter begin fun i ->\n arr.(i) <- arr.(i) + arr.(i-1)\n end;\n Array.findi (fun v -> v >= k) arr\n |> Printf.printf \"%d\\n\"", "language": "OCaml", "metadata": {"date": 1528050337, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03721.html", "problem_id": "p03721", "resource_group": "low_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/OCaml/s142987296.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s142987296", "user_id": "u798181098"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "open Batteries\nlet n, k = Scanf.scanf \"%d %d\" (fun x y -> x, y)\nlet arr = Array.make 100010 0\nlet () =\n (1--n) |> Enum.iter begin fun _ ->\n Scanf.scanf \" %d %d\" (fun a b -> arr.(a) <- arr.(a) + b)\n end;\n (1--n) |> Enum.iter begin fun i ->\n arr.(i) <- arr.(i) + arr.(i-1)\n end;\n Array.findi (fun v -> v >= k) arr\n |> Printf.printf \"%d\\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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 348, "cpu_time_ms": 52, "memory_kb": 5760}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s028867741", "group_id": "codeNet:p03722", "input_text": "let rec fold_n n f v = if n <= 0 then v else fold_n (n-1) f (f v)\nlet inf = 10101010101010\n\nlet () =\n Scanf.scanf \"%d %d\" @@ fun n m ->\n let a = Array.init m (fun _ -> Scanf.scanf \" %d %d %d\" (fun a b c -> a-1,b-1,c)) in\n\n let reach = begin\n let g = Array.init n (fun _ -> []) in\n a |> Array.iter (fun (u,v,_) -> g.(v) <- u :: g.(v));\n let vis = Array.make n false in\n let rec f u =\n vis.(u) <- true;\n List.iter (fun v -> if not vis.(v) then f v) g.(u)\n in f 0;\n vis\n end in\n\n let sc = Array.make n (-inf) in sc.(0) <- 0;\n let mem = Array.make n false in\n let has_loop = true |> fold_n (2*n) (fun upd ->\n if not upd then false else begin\n Array.fill mem 0 n false;\n Array.fold_left (fun b (u,v,c) ->\n let b' = sc.(u) + c > sc.(v) in\n if b' then (mem.(v) <- true; sc.(v) <- sc.(u) + c);\n b || b'\n ) false a\n end)\n in\n let inf_loop = has_loop && begin\n Array.init n (fun i -> reach.(i) && mem.(i)) |> Array.fold_left (||) false\n end in\n\n if inf_loop then\n print_endline \"inf\"\n else\n Printf.printf \"%d\\n\" sc.(n-1)", "language": "OCaml", "metadata": {"date": 1532081598, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03722.html", "problem_id": "p03722", "resource_group": "low_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/OCaml/s028867741.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s028867741", "user_id": "u798181098"}, "prompt_components": {"gold_output": "7\n", "input_to_evaluate": "let rec fold_n n f v = if n <= 0 then v else fold_n (n-1) f (f v)\nlet inf = 10101010101010\n\nlet () =\n Scanf.scanf \"%d %d\" @@ fun n m ->\n let a = Array.init m (fun _ -> Scanf.scanf \" %d %d %d\" (fun a b c -> a-1,b-1,c)) in\n\n let reach = begin\n let g = Array.init n (fun _ -> []) in\n a |> Array.iter (fun (u,v,_) -> g.(v) <- u :: g.(v));\n let vis = Array.make n false in\n let rec f u =\n vis.(u) <- true;\n List.iter (fun v -> if not vis.(v) then f v) g.(u)\n in f 0;\n vis\n end in\n\n let sc = Array.make n (-inf) in sc.(0) <- 0;\n let mem = Array.make n false in\n let has_loop = true |> fold_n (2*n) (fun upd ->\n if not upd then false else begin\n Array.fill mem 0 n false;\n Array.fold_left (fun b (u,v,c) ->\n let b' = sc.(u) + c > sc.(v) in\n if b' then (mem.(v) <- true; sc.(v) <- sc.(u) + c);\n b || b'\n ) false a\n end)\n in\n let inf_loop = has_loop && begin\n Array.init n (fun i -> reach.(i) && mem.(i)) |> Array.fold_left (||) false\n end in\n\n if inf_loop then\n print_endline \"inf\"\n else\n Printf.printf \"%d\\n\" sc.(n-1)", "problem_context": "Score : 400 points\n\nProblem Statement\n\nThere is a directed graph with N vertices and M edges.\nThe i-th edge (1≤i≤M) points from vertex a_i to vertex b_i, and has a weight c_i.\nWe will play the following single-player game using this graph and a piece.\n\nInitially, the piece is placed at vertex 1, and the score of the player is set to 0.\nThe player can move the piece as follows:\n\nWhen the piece is placed at vertex a_i, move the piece along the i-th edge to vertex b_i. After this move, the score of the player is increased by c_i.\n\nThe player can end the game only when the piece is placed at vertex N.\nThe given graph guarantees that it is possible to traverse from vertex 1 to vertex N.\n\nWhen the player acts optimally to maximize the score at the end of the game, what will the score be?\nIf it is possible to increase the score indefinitely, print inf.\n\nConstraints\n\n2≤N≤1000\n\n1≤M≤min(N(N-1),2000)\n\n1≤a_i,b_i≤N (1≤i≤M)\n\na_i≠b_i (1≤i≤M)\n\na_i≠a_j or b_i≠b_j (1≤i\n d.(b) <- min d.(b) (d.(a) + c)) es\n done\n\nlet () =\n let n, m = Scanf.scanf \"%d %d\\n\" (fun n m -> n, m) in\n let abcs = Array.to_list @@ Array.init m (fun _ -> Scanf.scanf \"%d %d %d\\n\" (fun a b c -> a - 1, b - 1, -c)) in\n let d = Array.make n 1000000000000 in\n d.(0) <- 0;\n bellman_ford d abcs;\n if List.exists (fun (a, b, c) -> b = n - 1 && d.(a) + c < d.(b)) abcs then print_endline \"inf\"\n else Printf.printf \"%d\\n\" (-d.(n - 1))\n", "language": "OCaml", "metadata": {"date": 1494729631, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03722.html", "problem_id": "p03722", "resource_group": "low_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/OCaml/s047056308.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s047056308", "user_id": "u504158101"}, "prompt_components": {"gold_output": "7\n", "input_to_evaluate": "let bellman_ford d es =\n for i = 1 to Array.length d - 1 do\n List.iter (fun (a, b, c) ->\n d.(b) <- min d.(b) (d.(a) + c)) es\n done\n\nlet () =\n let n, m = Scanf.scanf \"%d %d\\n\" (fun n m -> n, m) in\n let abcs = Array.to_list @@ Array.init m (fun _ -> Scanf.scanf \"%d %d %d\\n\" (fun a b c -> a - 1, b - 1, -c)) in\n let d = Array.make n 1000000000000 in\n d.(0) <- 0;\n bellman_ford d abcs;\n if List.exists (fun (a, b, c) -> b = n - 1 && d.(a) + c < d.(b)) abcs then print_endline \"inf\"\n else Printf.printf \"%d\\n\" (-d.(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≤i (a,b,c))\n\nlet rec func a b c n =\n if (a mod 2) = 1 || (b mod 2) = 1 || (c mod 2) = 1 then n\n else\n func ((b+c)/2) ((a+c)/2) ((a+b)/2) (n+1)\n\nlet ans = if a = b && b = c then -1 else func a b c 0\n\nlet () =\n Printf.printf \"%d\\n\" ans", "language": "OCaml", "metadata": {"date": 1495830023, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03723.html", "problem_id": "p03723", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03723/input.txt", "sample_output_relpath": "derived/input_output/data/p03723/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03723/OCaml/s577585799.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s577585799", "user_id": "u735499035"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "let id x = x\nlet (a,b,c) = Scanf.scanf \"%d %d %d\\n\" (fun a b c -> (a,b,c))\n\nlet rec func a b c n =\n if (a mod 2) = 1 || (b mod 2) = 1 || (c mod 2) = 1 then n\n else\n func ((b+c)/2) ((a+c)/2) ((a+b)/2) (n+1)\n\nlet ans = if a = b && b = c then -1 else func a b c 0\n\nlet () =\n Printf.printf \"%d\\n\" ans", "problem_context": "Score : 300 points\n\nProblem Statement\n\nTakahashi, Aoki and Snuke love cookies. They have A, B and C cookies, respectively. Now, they will exchange those cookies by repeating the action below:\n\nEach person simultaneously divides his cookies in half and gives one half to each of the other two persons.\n\nThis action will be repeated until there is a person with odd number of cookies in hand.\n\nHow many times will they repeat this action?\nNote that the answer may not be finite.\n\nConstraints\n\n1 ≤ A,B,C ≤ 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C\n\nOutput\n\nPrint the number of times the action will be performed by the three people, if this number is finite.\nIf it is infinite, print -1 instead.\n\nSample Input 1\n\n4 12 20\n\nSample Output 1\n\n3\n\nInitially, Takahashi, Aoki and Snuke have 4, 12 and 20 cookies. Then,\n\nAfter the first action, they have 16, 12 and 8.\n\nAfter the second action, they have 10, 12 and 14.\n\nAfter the third action, they have 13, 12 and 11.\n\nNow, Takahashi and Snuke have odd number of cookies, and therefore the answer is 3.\n\nSample Input 2\n\n14 14 14\n\nSample Output 2\n\n-1\n\nSample Input 3\n\n454 414 444\n\nSample Output 3\n\n1", "sample_input": "4 12 20\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03723", "source_text": "Score : 300 points\n\nProblem Statement\n\nTakahashi, Aoki and Snuke love cookies. They have A, B and C cookies, respectively. Now, they will exchange those cookies by repeating the action below:\n\nEach person simultaneously divides his cookies in half and gives one half to each of the other two persons.\n\nThis action will be repeated until there is a person with odd number of cookies in hand.\n\nHow many times will they repeat this action?\nNote that the answer may not be finite.\n\nConstraints\n\n1 ≤ A,B,C ≤ 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C\n\nOutput\n\nPrint the number of times the action will be performed by the three people, if this number is finite.\nIf it is infinite, print -1 instead.\n\nSample Input 1\n\n4 12 20\n\nSample Output 1\n\n3\n\nInitially, Takahashi, Aoki and Snuke have 4, 12 and 20 cookies. Then,\n\nAfter the first action, they have 16, 12 and 8.\n\nAfter the second action, they have 10, 12 and 14.\n\nAfter the third action, they have 13, 12 and 11.\n\nNow, Takahashi and Snuke have odd number of cookies, and therefore the answer is 3.\n\nSample Input 2\n\n14 14 14\n\nSample Output 2\n\n-1\n\nSample Input 3\n\n454 414 444\n\nSample Output 3\n\n1", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 302, "cpu_time_ms": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s285542252", "group_id": "codeNet:p03724", "input_text": "Scanf.scanf \"%d %d\" (fun n m ->\n let hist = Array.make n 0 in\n for i = 1 to m do\n Scanf.scanf \" %d %d\" (fun a b ->\n hist.(a - 1) <- hist.(a - 1) lxor 1;\n hist.(b - 1) <- hist.(b - 1) lxor 1;\n )\n done;\n print_endline @@ if Array.fold_left (+) 0 hist = 0 then \"YES\" else \"NO\"\n)", "language": "OCaml", "metadata": {"date": 1597634803, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p03724.html", "problem_id": "p03724", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03724/input.txt", "sample_output_relpath": "derived/input_output/data/p03724/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03724/OCaml/s285542252.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s285542252", "user_id": "u342443598"}, "prompt_components": {"gold_output": "YES\n", "input_to_evaluate": "Scanf.scanf \"%d %d\" (fun n m ->\n let hist = Array.make n 0 in\n for i = 1 to m do\n Scanf.scanf \" %d %d\" (fun a b ->\n hist.(a - 1) <- hist.(a - 1) lxor 1;\n hist.(b - 1) <- hist.(b - 1) lxor 1;\n )\n done;\n print_endline @@ if Array.fold_left (+) 0 hist = 0 then \"YES\" else \"NO\"\n)", "problem_context": "Score : 500 points\n\nProblem Statement\n\nTakahashi is not good at problems about trees in programming contests, and Aoki is helping him practice.\n\nFirst, Takahashi created a tree with N vertices numbered 1 through N, and wrote 0 at each edge.\n\nThen, Aoki gave him M queries. The i-th of them is as follows:\n\nIncrement the number written at each edge along the path connecting vertices a_i and b_i, by one.\n\nAfter Takahashi executed all of the queries, he told Aoki that, for every edge, the written number became an even number.\nHowever, Aoki forgot to confirm that the graph Takahashi created was actually a tree, and it is possible that Takahashi made a mistake in creating a tree or executing queries.\n\nDetermine whether there exists a tree that has the property mentioned by Takahashi.\n\nConstraints\n\n2 ≤ N ≤ 10^5\n\n1 ≤ M ≤ 10^5\n\n1 ≤ a_i,b_i ≤ N\n\na_i ≠ b_i\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\na_1 b_1\n:\na_M b_M\n\nOutput\n\nPrint YES if there exists a tree that has the property mentioned by Takahashi; print NO otherwise.\n\nSample Input 1\n\n4 4\n1 2\n2 4\n1 3\n3 4\n\nSample Output 1\n\nYES\n\nFor example, Takahashi's graph has the property mentioned by him if it has the following edges: 1-2, 1-3 and 1-4.\nIn this case, the number written at every edge will become 2.\n\nSample Input 2\n\n5 5\n1 2\n3 5\n5 1\n3 4\n2 3\n\nSample Output 2\n\nNO", "sample_input": "4 4\n1 2\n2 4\n1 3\n3 4\n"}, "reference_outputs": ["YES\n"], "source_document_id": "p03724", "source_text": "Score : 500 points\n\nProblem Statement\n\nTakahashi is not good at problems about trees in programming contests, and Aoki is helping him practice.\n\nFirst, Takahashi created a tree with N vertices numbered 1 through N, and wrote 0 at each edge.\n\nThen, Aoki gave him M queries. The i-th of them is as follows:\n\nIncrement the number written at each edge along the path connecting vertices a_i and b_i, by one.\n\nAfter Takahashi executed all of the queries, he told Aoki that, for every edge, the written number became an even number.\nHowever, Aoki forgot to confirm that the graph Takahashi created was actually a tree, and it is possible that Takahashi made a mistake in creating a tree or executing queries.\n\nDetermine whether there exists a tree that has the property mentioned by Takahashi.\n\nConstraints\n\n2 ≤ N ≤ 10^5\n\n1 ≤ M ≤ 10^5\n\n1 ≤ a_i,b_i ≤ N\n\na_i ≠ b_i\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\na_1 b_1\n:\na_M b_M\n\nOutput\n\nPrint YES if there exists a tree that has the property mentioned by Takahashi; print NO otherwise.\n\nSample Input 1\n\n4 4\n1 2\n2 4\n1 3\n3 4\n\nSample Output 1\n\nYES\n\nFor example, Takahashi's graph has the property mentioned by him if it has the following edges: 1-2, 1-3 and 1-4.\nIn this case, the number written at every edge will become 2.\n\nSample Input 2\n\n5 5\n1 2\n3 5\n5 1\n3 4\n2 3\n\nSample Output 2\n\nNO", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 48, "memory_kb": 6628}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s722349601", "group_id": "codeNet:p03724", "input_text": "let (n, m) = Scanf.sscanf (read_line ()) \"%d %d\" @@ fun n m -> (n, m)\nlet ab = Array.init m @@ fun _ -> Scanf.sscanf (read_line ()) \"%d %d\" @@ fun a b -> (a, b)\n\nlet cnt = Array.make 10_001 0\n\nlet () =\n Array.iter (fun (a, b) ->\n cnt.(a) <- cnt.(a) + 1;\n cnt.(b) <- cnt.(b) + 1\n ) ab;\n print_endline @@ if cnt \n |> Array.map (fun cnt -> cnt mod 2 = 0)\n |> Array.fold_left (&&) true \n then \"YES\" else \"NO\"", "language": "OCaml", "metadata": {"date": 1592434729, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03724.html", "problem_id": "p03724", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03724/input.txt", "sample_output_relpath": "derived/input_output/data/p03724/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03724/OCaml/s722349601.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s722349601", "user_id": "u811309788"}, "prompt_components": {"gold_output": "YES\n", "input_to_evaluate": "let (n, m) = Scanf.sscanf (read_line ()) \"%d %d\" @@ fun n m -> (n, m)\nlet ab = Array.init m @@ fun _ -> Scanf.sscanf (read_line ()) \"%d %d\" @@ fun a b -> (a, b)\n\nlet cnt = Array.make 10_001 0\n\nlet () =\n Array.iter (fun (a, b) ->\n cnt.(a) <- cnt.(a) + 1;\n cnt.(b) <- cnt.(b) + 1\n ) ab;\n print_endline @@ if cnt \n |> Array.map (fun cnt -> cnt mod 2 = 0)\n |> Array.fold_left (&&) true \n then \"YES\" else \"NO\"", "problem_context": "Score : 500 points\n\nProblem Statement\n\nTakahashi is not good at problems about trees in programming contests, and Aoki is helping him practice.\n\nFirst, Takahashi created a tree with N vertices numbered 1 through N, and wrote 0 at each edge.\n\nThen, Aoki gave him M queries. The i-th of them is as follows:\n\nIncrement the number written at each edge along the path connecting vertices a_i and b_i, by one.\n\nAfter Takahashi executed all of the queries, he told Aoki that, for every edge, the written number became an even number.\nHowever, Aoki forgot to confirm that the graph Takahashi created was actually a tree, and it is possible that Takahashi made a mistake in creating a tree or executing queries.\n\nDetermine whether there exists a tree that has the property mentioned by Takahashi.\n\nConstraints\n\n2 ≤ N ≤ 10^5\n\n1 ≤ M ≤ 10^5\n\n1 ≤ a_i,b_i ≤ N\n\na_i ≠ b_i\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\na_1 b_1\n:\na_M b_M\n\nOutput\n\nPrint YES if there exists a tree that has the property mentioned by Takahashi; print NO otherwise.\n\nSample Input 1\n\n4 4\n1 2\n2 4\n1 3\n3 4\n\nSample Output 1\n\nYES\n\nFor example, Takahashi's graph has the property mentioned by him if it has the following edges: 1-2, 1-3 and 1-4.\nIn this case, the number written at every edge will become 2.\n\nSample Input 2\n\n5 5\n1 2\n3 5\n5 1\n3 4\n2 3\n\nSample Output 2\n\nNO", "sample_input": "4 4\n1 2\n2 4\n1 3\n3 4\n"}, "reference_outputs": ["YES\n"], "source_document_id": "p03724", "source_text": "Score : 500 points\n\nProblem Statement\n\nTakahashi is not good at problems about trees in programming contests, and Aoki is helping him practice.\n\nFirst, Takahashi created a tree with N vertices numbered 1 through N, and wrote 0 at each edge.\n\nThen, Aoki gave him M queries. The i-th of them is as follows:\n\nIncrement the number written at each edge along the path connecting vertices a_i and b_i, by one.\n\nAfter Takahashi executed all of the queries, he told Aoki that, for every edge, the written number became an even number.\nHowever, Aoki forgot to confirm that the graph Takahashi created was actually a tree, and it is possible that Takahashi made a mistake in creating a tree or executing queries.\n\nDetermine whether there exists a tree that has the property mentioned by Takahashi.\n\nConstraints\n\n2 ≤ N ≤ 10^5\n\n1 ≤ M ≤ 10^5\n\n1 ≤ a_i,b_i ≤ N\n\na_i ≠ b_i\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN M\na_1 b_1\n:\na_M b_M\n\nOutput\n\nPrint YES if there exists a tree that has the property mentioned by Takahashi; print NO otherwise.\n\nSample Input 1\n\n4 4\n1 2\n2 4\n1 3\n3 4\n\nSample Output 1\n\nYES\n\nFor example, Takahashi's graph has the property mentioned by him if it has the following edges: 1-2, 1-3 and 1-4.\nIn this case, the number written at every edge will become 2.\n\nSample Input 2\n\n5 5\n1 2\n3 5\n5 1\n3 4\n2 3\n\nSample Output 2\n\nNO", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 422, "cpu_time_ms": 65, "memory_kb": 6784}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s848878928", "group_id": "codeNet:p03729", "input_text": "open Scanf\nopen Printf\nopen String\n\nlet () = scanf \"%s %s %s\" (fun a b c-> if a.[(length a) - 1] = b.[0] && b.[(length b) - 1] = c.[0]\n then \"YES\" else \"NO\"\n ) |> printf \"%s\\n\"", "language": "OCaml", "metadata": {"date": 1595972003, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p03729.html", "problem_id": "p03729", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03729/input.txt", "sample_output_relpath": "derived/input_output/data/p03729/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03729/OCaml/s848878928.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s848878928", "user_id": "u272377260"}, "prompt_components": {"gold_output": "YES\n", "input_to_evaluate": "open Scanf\nopen Printf\nopen String\n\nlet () = scanf \"%s %s %s\" (fun a b c-> if a.[(length a) - 1] = b.[0] && b.[(length b) - 1] = c.[0]\n then \"YES\" else \"NO\"\n ) |> printf \"%s\\n\"", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou are given three strings A, B and C. Check whether they form a word chain.\n\nMore formally, determine whether both of the following are true:\n\nThe last character in A and the initial character in B are the same.\n\nThe last character in B and the initial character in C are the same.\n\nIf both are true, print YES. Otherwise, print NO.\n\nConstraints\n\nA, B and C are all composed of lowercase English letters (a - z).\n\n1 ≤ |A|, |B|, |C| ≤ 10, where |A|, |B| and |C| are the lengths of A, B and C, respectively.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C\n\nOutput\n\nPrint YES or NO.\n\nSample Input 1\n\nrng gorilla apple\n\nSample Output 1\n\nYES\n\nThey form a word chain.\n\nSample Input 2\n\nyakiniku unagi sushi\n\nSample Output 2\n\nNO\n\nA and B form a word chain, but B and C do not.\n\nSample Input 3\n\na a a\n\nSample Output 3\n\nYES\n\nSample Input 4\n\naaaaaaaaab aaaaaaaaaa aaaaaaaaab\n\nSample Output 4\n\nNO", "sample_input": "rng gorilla apple\n"}, "reference_outputs": ["YES\n"], "source_document_id": "p03729", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou are given three strings A, B and C. Check whether they form a word chain.\n\nMore formally, determine whether both of the following are true:\n\nThe last character in A and the initial character in B are the same.\n\nThe last character in B and the initial character in C are the same.\n\nIf both are true, print YES. Otherwise, print NO.\n\nConstraints\n\nA, B and C are all composed of lowercase English letters (a - z).\n\n1 ≤ |A|, |B|, |C| ≤ 10, where |A|, |B| and |C| are the lengths of A, B and C, respectively.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C\n\nOutput\n\nPrint YES or NO.\n\nSample Input 1\n\nrng gorilla apple\n\nSample Output 1\n\nYES\n\nThey form a word chain.\n\nSample Input 2\n\nyakiniku unagi sushi\n\nSample Output 2\n\nNO\n\nA and B form a word chain, but B and C do not.\n\nSample Input 3\n\na a a\n\nSample Output 3\n\nYES\n\nSample Input 4\n\naaaaaaaaab aaaaaaaaaa aaaaaaaaab\n\nSample Output 4\n\nNO", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 7, "memory_kb": 3736}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s901198490", "group_id": "codeNet:p03730", "input_text": "let () =\n let a, b, c = Scanf.scanf \"%d %d %d\" (fun a b c -> (a, b, c)) in\n let rec f tmp =\n let x = tmp mod b in\n match x with 0 -> \"NO\" | y when y = c -> \"YES\" | _ -> f (tmp + a)\n in\n f a |> print_endline", "language": "OCaml", "metadata": {"date": 1521922766, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03730.html", "problem_id": "p03730", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03730/input.txt", "sample_output_relpath": "derived/input_output/data/p03730/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03730/OCaml/s901198490.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s901198490", "user_id": "u987869509"}, "prompt_components": {"gold_output": "YES\n", "input_to_evaluate": "let () =\n let a, b, c = Scanf.scanf \"%d %d %d\" (fun a b c -> (a, b, c)) in\n let rec f tmp =\n let x = tmp mod b in\n match x with 0 -> \"NO\" | y when y = c -> \"YES\" | _ -> f (tmp + a)\n in\n f a |> print_endline", "problem_context": "Score : 200 points\n\nProblem Statement\n\nWe ask you to select some number of positive integers, and calculate the sum of them.\n\nIt is allowed to select as many integers as you like, and as large integers as you wish.\nYou have to follow these, however: each selected integer needs to be a multiple of A, and you need to select at least one integer.\n\nYour objective is to make the sum congruent to C modulo B.\nDetermine whether this is possible.\n\nIf the objective is achievable, print YES. Otherwise, print NO.\n\nConstraints\n\n1 ≤ A ≤ 100\n\n1 ≤ B ≤ 100\n\n0 ≤ C < B\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C\n\nOutput\n\nPrint YES or NO.\n\nSample Input 1\n\n7 5 1\n\nSample Output 1\n\nYES\n\nFor example, if you select 7 and 14, the sum 21 is congruent to 1 modulo 5.\n\nSample Input 2\n\n2 2 1\n\nSample Output 2\n\nNO\n\nThe sum of even numbers, no matter how many, is never odd.\n\nSample Input 3\n\n1 100 97\n\nSample Output 3\n\nYES\n\nYou can select 97, since you may select multiples of 1, that is, all integers.\n\nSample Input 4\n\n40 98 58\n\nSample Output 4\n\nYES\n\nSample Input 5\n\n77 42 36\n\nSample Output 5\n\nNO", "sample_input": "7 5 1\n"}, "reference_outputs": ["YES\n"], "source_document_id": "p03730", "source_text": "Score : 200 points\n\nProblem Statement\n\nWe ask you to select some number of positive integers, and calculate the sum of them.\n\nIt is allowed to select as many integers as you like, and as large integers as you wish.\nYou have to follow these, however: each selected integer needs to be a multiple of A, and you need to select at least one integer.\n\nYour objective is to make the sum congruent to C modulo B.\nDetermine whether this is possible.\n\nIf the objective is achievable, print YES. Otherwise, print NO.\n\nConstraints\n\n1 ≤ A ≤ 100\n\n1 ≤ B ≤ 100\n\n0 ≤ C < B\n\nInput\n\nInput is given from Standard Input in the following format:\n\nA B C\n\nOutput\n\nPrint YES or NO.\n\nSample Input 1\n\n7 5 1\n\nSample Output 1\n\nYES\n\nFor example, if you select 7 and 14, the sum 21 is congruent to 1 modulo 5.\n\nSample Input 2\n\n2 2 1\n\nSample Output 2\n\nNO\n\nThe sum of even numbers, no matter how many, is never odd.\n\nSample Input 3\n\n1 100 97\n\nSample Output 3\n\nYES\n\nYou can select 97, since you may select multiples of 1, that is, all integers.\n\nSample Input 4\n\n40 98 58\n\nSample Output 4\n\nYES\n\nSample Input 5\n\n77 42 36\n\nSample Output 5\n\nNO", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 216, "cpu_time_ms": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s468463542", "group_id": "codeNet:p03732", "input_text": "let lim = 330\nlet () =\n Scanf.scanf \"%d %d\" @@ fun n ww ->\n let a = Array.init n (fun _ -> Scanf.scanf \" %d %d\" (fun x y -> x, y)) in\n let w0 = fst a.(0) in\n\n let dp = Array.make_matrix lim (n+1) 0 in\n a |> Array.iter (fun (w, v) ->\n let w = w - w0 in\n for i = lim-1 downto w do\n for j = n downto 1 do\n if i + j * w0 <= ww then\n dp.(i).(j) <- max dp.(i).(j) (dp.(i-w).(j-1) + v)\n done done);\n\n Array.fold_left (Array.fold_left max) 0 dp\n |> Printf.printf \"%d\\n\"", "language": "OCaml", "metadata": {"date": 1532079388, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03732.html", "problem_id": "p03732", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03732/input.txt", "sample_output_relpath": "derived/input_output/data/p03732/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03732/OCaml/s468463542.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s468463542", "user_id": "u798181098"}, "prompt_components": {"gold_output": "11\n", "input_to_evaluate": "let lim = 330\nlet () =\n Scanf.scanf \"%d %d\" @@ fun n ww ->\n let a = Array.init n (fun _ -> Scanf.scanf \" %d %d\" (fun x y -> x, y)) in\n let w0 = fst a.(0) in\n\n let dp = Array.make_matrix lim (n+1) 0 in\n a |> Array.iter (fun (w, v) ->\n let w = w - w0 in\n for i = lim-1 downto w do\n for j = n downto 1 do\n if i + j * w0 <= ww then\n dp.(i).(j) <- max dp.(i).(j) (dp.(i-w).(j-1) + v)\n done done);\n\n Array.fold_left (Array.fold_left max) 0 dp\n |> Printf.printf \"%d\\n\"", "problem_context": "Score : 400 points\n\nProblem Statement\n\nYou have N items and a bag of strength W.\nThe i-th item has a weight of w_i and a value of v_i.\n\nYou will select some of the items and put them in the bag.\nHere, the total weight of the selected items needs to be at most W.\n\nYour objective is to maximize the total value of the selected items.\n\nConstraints\n\n1 ≤ N ≤ 100\n\n1 ≤ W ≤ 10^9\n\n1 ≤ w_i ≤ 10^9\n\nFor each i = 2,3,...,N, w_1 ≤ w_i ≤ w_1 + 3.\n\n1 ≤ v_i ≤ 10^7\n\nW, each w_i and v_i are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN W\nw_1 v_1\nw_2 v_2\n:\nw_N v_N\n\nOutput\n\nPrint the maximum possible total value of the selected items.\n\nSample Input 1\n\n4 6\n2 1\n3 4\n4 10\n3 4\n\nSample Output 1\n\n11\n\nThe first and third items should be selected.\n\nSample Input 2\n\n4 6\n2 1\n3 7\n4 10\n3 6\n\nSample Output 2\n\n13\n\nThe second and fourth items should be selected.\n\nSample Input 3\n\n4 10\n1 100\n1 100\n1 100\n1 100\n\nSample Output 3\n\n400\n\nYou can take everything.\n\nSample Input 4\n\n4 1\n10 100\n10 100\n10 100\n10 100\n\nSample Output 4\n\n0\n\nYou can take nothing.", "sample_input": "4 6\n2 1\n3 4\n4 10\n3 4\n"}, "reference_outputs": ["11\n"], "source_document_id": "p03732", "source_text": "Score : 400 points\n\nProblem Statement\n\nYou have N items and a bag of strength W.\nThe i-th item has a weight of w_i and a value of v_i.\n\nYou will select some of the items and put them in the bag.\nHere, the total weight of the selected items needs to be at most W.\n\nYour objective is to maximize the total value of the selected items.\n\nConstraints\n\n1 ≤ N ≤ 100\n\n1 ≤ W ≤ 10^9\n\n1 ≤ w_i ≤ 10^9\n\nFor each i = 2,3,...,N, w_1 ≤ w_i ≤ w_1 + 3.\n\n1 ≤ v_i ≤ 10^7\n\nW, each w_i and v_i are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN W\nw_1 v_1\nw_2 v_2\n:\nw_N v_N\n\nOutput\n\nPrint the maximum possible total value of the selected items.\n\nSample Input 1\n\n4 6\n2 1\n3 4\n4 10\n3 4\n\nSample Output 1\n\n11\n\nThe first and third items should be selected.\n\nSample Input 2\n\n4 6\n2 1\n3 7\n4 10\n3 6\n\nSample Output 2\n\n13\n\nThe second and fourth items should be selected.\n\nSample Input 3\n\n4 10\n1 100\n1 100\n1 100\n1 100\n\nSample Output 3\n\n400\n\nYou can take everything.\n\nSample Input 4\n\n4 1\n10 100\n10 100\n10 100\n10 100\n\nSample Output 4\n\n0\n\nYou can take nothing.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 498, "cpu_time_ms": 43, "memory_kb": 2432}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s033401970", "group_id": "codeNet:p03733", "input_text": "Scanf.scanf \"%d %d\" (fun n t ->\n let rec loop i prev acc =\n if i = n then acc + t else\n let ti = Scanf.scanf \" %d\" (fun t -> t) in\n let acc = if prev + t <= ti then acc + t else acc + ti - prev in\n loop (i + 1) ti acc\n in\n loop 0 0 0 |> Printf.printf \"%d\\n\"\n)", "language": "OCaml", "metadata": {"date": 1585027432, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03733.html", "problem_id": "p03733", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03733/input.txt", "sample_output_relpath": "derived/input_output/data/p03733/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03733/OCaml/s033401970.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s033401970", "user_id": "u342443598"}, "prompt_components": {"gold_output": "7\n", "input_to_evaluate": "Scanf.scanf \"%d %d\" (fun n t ->\n let rec loop i prev acc =\n if i = n then acc + t else\n let ti = Scanf.scanf \" %d\" (fun t -> t) in\n let acc = if prev + t <= ti then acc + t else acc + ti - prev in\n loop (i + 1) ti acc\n in\n loop 0 0 0 |> Printf.printf \"%d\\n\"\n)", "problem_context": "Score : 300 points\n\nProblem Statement\n\nIn a public bath, there is a shower which emits water for T seconds when the switch is pushed.\n\nIf the switch is pushed when the shower is already emitting water, from that moment it will be emitting water for T seconds.\nNote that it does not mean that the shower emits water for T additional seconds.\n\nN people will push the switch while passing by the shower.\nThe i-th person will push the switch t_i seconds after the first person pushes it.\n\nHow long will the shower emit water in total?\n\nConstraints\n\n1 ≤ N ≤ 200,000\n\n1 ≤ T ≤ 10^9\n\n0 = t_1 < t_2 < t_3 < , ..., < t_{N-1} < t_N ≤ 10^9\n\nT and each t_i are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN T\nt_1 t_2 ... t_N\n\nOutput\n\nAssume that the shower will emit water for a total of X seconds. Print X.\n\nSample Input 1\n\n2 4\n0 3\n\nSample Output 1\n\n7\n\nThree seconds after the first person pushes the water, the switch is pushed again and the shower emits water for four more seconds, for a total of seven seconds.\n\nSample Input 2\n\n2 4\n0 5\n\nSample Output 2\n\n8\n\nOne second after the shower stops emission of water triggered by the first person, the switch is pushed again.\n\nSample Input 3\n\n4 1000000000\n0 1000 1000000 1000000000\n\nSample Output 3\n\n2000000000\n\nSample Input 4\n\n1 1\n0\n\nSample Output 4\n\n1\n\nSample Input 5\n\n9 10\n0 3 5 7 100 110 200 300 311\n\nSample Output 5\n\n67", "sample_input": "2 4\n0 3\n"}, "reference_outputs": ["7\n"], "source_document_id": "p03733", "source_text": "Score : 300 points\n\nProblem Statement\n\nIn a public bath, there is a shower which emits water for T seconds when the switch is pushed.\n\nIf the switch is pushed when the shower is already emitting water, from that moment it will be emitting water for T seconds.\nNote that it does not mean that the shower emits water for T additional seconds.\n\nN people will push the switch while passing by the shower.\nThe i-th person will push the switch t_i seconds after the first person pushes it.\n\nHow long will the shower emit water in total?\n\nConstraints\n\n1 ≤ N ≤ 200,000\n\n1 ≤ T ≤ 10^9\n\n0 = t_1 < t_2 < t_3 < , ..., < t_{N-1} < t_N ≤ 10^9\n\nT and each t_i are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN T\nt_1 t_2 ... t_N\n\nOutput\n\nAssume that the shower will emit water for a total of X seconds. Print X.\n\nSample Input 1\n\n2 4\n0 3\n\nSample Output 1\n\n7\n\nThree seconds after the first person pushes the water, the switch is pushed again and the shower emits water for four more seconds, for a total of seven seconds.\n\nSample Input 2\n\n2 4\n0 5\n\nSample Output 2\n\n8\n\nOne second after the shower stops emission of water triggered by the first person, the switch is pushed again.\n\nSample Input 3\n\n4 1000000000\n0 1000 1000000 1000000000\n\nSample Output 3\n\n2000000000\n\nSample Input 4\n\n1 1\n0\n\nSample Output 4\n\n1\n\nSample Input 5\n\n9 10\n0 3 5 7 100 110 200 300 311\n\nSample Output 5\n\n67", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 308, "cpu_time_ms": 57, "memory_kb": 2688}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s538927799", "group_id": "codeNet:p03734", "input_text": "module M = Map.Make (struct type t = int let compare = compare end) ;;\n\nScanf.scanf \"%d %d\" (fun n w ->\n let vw = Array.init n (fun _ -> Scanf.scanf \" %d %d\" (fun w v -> w, v)) in\n let map = Array.fold_left (fun map (w0, v0) ->\n M.fold (fun ww vv newmap ->\n let key = ww + w0 in\n if key <= w then (\n try\n let v1 = M.find key newmap in\n if v1 < vv + v0 then M.add key (vv + v0) newmap else newmap\n with _ ->\n M.add key (vv + v0) newmap\n ) else newmap\n ) map map\n ) (M.add 0 0 M.empty) vw\n in\n M.fold (fun _ vv acc -> max vv acc) map 0 |> Printf.printf \"%d\\n\"\n)", "language": "OCaml", "metadata": {"date": 1585028706, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03734.html", "problem_id": "p03734", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03734/input.txt", "sample_output_relpath": "derived/input_output/data/p03734/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03734/OCaml/s538927799.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s538927799", "user_id": "u342443598"}, "prompt_components": {"gold_output": "11\n", "input_to_evaluate": "module M = Map.Make (struct type t = int let compare = compare end) ;;\n\nScanf.scanf \"%d %d\" (fun n w ->\n let vw = Array.init n (fun _ -> Scanf.scanf \" %d %d\" (fun w v -> w, v)) in\n let map = Array.fold_left (fun map (w0, v0) ->\n M.fold (fun ww vv newmap ->\n let key = ww + w0 in\n if key <= w then (\n try\n let v1 = M.find key newmap in\n if v1 < vv + v0 then M.add key (vv + v0) newmap else newmap\n with _ ->\n M.add key (vv + v0) newmap\n ) else newmap\n ) map map\n ) (M.add 0 0 M.empty) vw\n in\n M.fold (fun _ vv acc -> max vv acc) map 0 |> Printf.printf \"%d\\n\"\n)", "problem_context": "Score : 400 points\n\nProblem Statement\n\nYou have N items and a bag of strength W.\nThe i-th item has a weight of w_i and a value of v_i.\n\nYou will select some of the items and put them in the bag.\nHere, the total weight of the selected items needs to be at most W.\n\nYour objective is to maximize the total value of the selected items.\n\nConstraints\n\n1 ≤ N ≤ 100\n\n1 ≤ W ≤ 10^9\n\n1 ≤ w_i ≤ 10^9\n\nFor each i = 2,3,...,N, w_1 ≤ w_i ≤ w_1 + 3.\n\n1 ≤ v_i ≤ 10^7\n\nW, each w_i and v_i are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN W\nw_1 v_1\nw_2 v_2\n:\nw_N v_N\n\nOutput\n\nPrint the maximum possible total value of the selected items.\n\nSample Input 1\n\n4 6\n2 1\n3 4\n4 10\n3 4\n\nSample Output 1\n\n11\n\nThe first and third items should be selected.\n\nSample Input 2\n\n4 6\n2 1\n3 7\n4 10\n3 6\n\nSample Output 2\n\n13\n\nThe second and fourth items should be selected.\n\nSample Input 3\n\n4 10\n1 100\n1 100\n1 100\n1 100\n\nSample Output 3\n\n400\n\nYou can take everything.\n\nSample Input 4\n\n4 1\n10 100\n10 100\n10 100\n10 100\n\nSample Output 4\n\n0\n\nYou can take nothing.", "sample_input": "4 6\n2 1\n3 4\n4 10\n3 4\n"}, "reference_outputs": ["11\n"], "source_document_id": "p03734", "source_text": "Score : 400 points\n\nProblem Statement\n\nYou have N items and a bag of strength W.\nThe i-th item has a weight of w_i and a value of v_i.\n\nYou will select some of the items and put them in the bag.\nHere, the total weight of the selected items needs to be at most W.\n\nYour objective is to maximize the total value of the selected items.\n\nConstraints\n\n1 ≤ N ≤ 100\n\n1 ≤ W ≤ 10^9\n\n1 ≤ w_i ≤ 10^9\n\nFor each i = 2,3,...,N, w_1 ≤ w_i ≤ w_1 + 3.\n\n1 ≤ v_i ≤ 10^7\n\nW, each w_i and v_i are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN W\nw_1 v_1\nw_2 v_2\n:\nw_N v_N\n\nOutput\n\nPrint the maximum possible total value of the selected items.\n\nSample Input 1\n\n4 6\n2 1\n3 4\n4 10\n3 4\n\nSample Output 1\n\n11\n\nThe first and third items should be selected.\n\nSample Input 2\n\n4 6\n2 1\n3 7\n4 10\n3 6\n\nSample Output 2\n\n13\n\nThe second and fourth items should be selected.\n\nSample Input 3\n\n4 10\n1 100\n1 100\n1 100\n1 100\n\nSample Output 3\n\n400\n\nYou can take everything.\n\nSample Input 4\n\n4 1\n10 100\n10 100\n10 100\n10 100\n\nSample Output 4\n\n0\n\nYou can take nothing.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 708, "cpu_time_ms": 31, "memory_kb": 5248}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s551924538", "group_id": "codeNet:p03735", "input_text": "let () = Scanf.scanf \"%d\\n\" @@ fun n ->\n let xys = Array.init n @@ fun _ -> Scanf.scanf \"%d %d\\n\" @@ fun x y -> x, y in\n let rmax = Array.fold_right (fun (x, y) -> max @@ max x y) xys min_int in\n let bmin = Array.fold_right (fun (x, y) -> min @@ min x y) xys max_int in\n let (rmin, bmax) = Array.fold_left (fun (rmin, bmax) (x, y) ->\n if x <= y\n then (min rmin y, max bmax x)\n else (min rmin x, max bmax y)) (max_int, min_int) xys in\n Printf.printf \"%d\\n\" @@ (rmax - rmin) * (bmax - bmin)\n\n", "language": "OCaml", "metadata": {"date": 1539658135, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03735.html", "problem_id": "p03735", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03735/input.txt", "sample_output_relpath": "derived/input_output/data/p03735/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03735/OCaml/s551924538.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s551924538", "user_id": "u504158101"}, "prompt_components": {"gold_output": "15\n", "input_to_evaluate": "let () = Scanf.scanf \"%d\\n\" @@ fun n ->\n let xys = Array.init n @@ fun _ -> Scanf.scanf \"%d %d\\n\" @@ fun x y -> x, y in\n let rmax = Array.fold_right (fun (x, y) -> max @@ max x y) xys min_int in\n let bmin = Array.fold_right (fun (x, y) -> min @@ min x y) xys max_int in\n let (rmin, bmax) = Array.fold_left (fun (rmin, bmax) (x, y) ->\n if x <= y\n then (min rmin y, max bmax x)\n else (min rmin x, max bmax y)) (max_int, min_int) xys in\n Printf.printf \"%d\\n\" @@ (rmax - rmin) * (bmax - bmin)\n\n", "problem_context": "Score : 700 points\n\nProblem Statement\n\nThere are N bags, each containing two white balls. The i-th box contains two balls with integers x_i and y_i written on them, respectively.\n\nFor each of these bags, you will paint one of the balls red, and paint the other blue.\n\nAfterwards, the 2N balls will be classified according to color.\n\nThen, we will define the following:\n\nR_{max}: the maximum integer written on a ball painted in red\n\nR_{min}: the minimum integer written on a ball painted in red\n\nB_{max}: the maximum integer written on a ball painted in blue\n\nB_{min}: the minimum integer written on a ball painted in blue\n\nFind the minimum possible value of (R_{max} - R_{min}) \\times (B_{max} - B_{min}).\n\nConstraints\n\n1 ≤ N ≤ 200,000\n\n1 ≤ x_i, y_i ≤ 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nx_1 y_1\nx_2 y_2\n:\nx_N y_N\n\nOutput\n\nPrint the minimum possible value.\n\nSample Input 1\n\n3\n1 2\n3 4\n5 6\n\nSample Output 1\n\n15\n\nThe optimal solution is to paint the balls with x_1, x_2, y_3 red, and paint the balls with y_1, y_2, x_3 blue.\n\nSample Input 2\n\n3\n1010 10\n1000 1\n20 1020\n\nSample Output 2\n\n380\n\nSample Input 3\n\n2\n1 1\n1000000000 1000000000\n\nSample Output 3\n\n999999998000000001", "sample_input": "3\n1 2\n3 4\n5 6\n"}, "reference_outputs": ["15\n"], "source_document_id": "p03735", "source_text": "Score : 700 points\n\nProblem Statement\n\nThere are N bags, each containing two white balls. The i-th box contains two balls with integers x_i and y_i written on them, respectively.\n\nFor each of these bags, you will paint one of the balls red, and paint the other blue.\n\nAfterwards, the 2N balls will be classified according to color.\n\nThen, we will define the following:\n\nR_{max}: the maximum integer written on a ball painted in red\n\nR_{min}: the minimum integer written on a ball painted in red\n\nB_{max}: the maximum integer written on a ball painted in blue\n\nB_{min}: the minimum integer written on a ball painted in blue\n\nFind the minimum possible value of (R_{max} - R_{min}) \\times (B_{max} - B_{min}).\n\nConstraints\n\n1 ≤ N ≤ 200,000\n\n1 ≤ x_i, y_i ≤ 10^9\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nx_1 y_1\nx_2 y_2\n:\nx_N y_N\n\nOutput\n\nPrint the minimum possible value.\n\nSample Input 1\n\n3\n1 2\n3 4\n5 6\n\nSample Output 1\n\n15\n\nThe optimal solution is to paint the balls with x_1, x_2, y_3 red, and paint the balls with y_1, y_2, x_3 blue.\n\nSample Input 2\n\n3\n1010 10\n1000 1\n20 1020\n\nSample Output 2\n\n380\n\nSample Input 3\n\n2\n1 1\n1000000000 1000000000\n\nSample Output 3\n\n999999998000000001", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 154, "memory_kb": 9600}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s424030545", "group_id": "codeNet:p03737", "input_text": "let () = Scanf.scanf \"%s %s %s\" @@ fun s1 s2 s3 ->\n Printf.printf \"%c%c%c\\n\"\n (Char.uppercase s1.[0])\n (Char.uppercase s2.[0])\n (Char.uppercase s3.[0])\n", "language": "OCaml", "metadata": {"date": 1530681344, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03737.html", "problem_id": "p03737", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03737/input.txt", "sample_output_relpath": "derived/input_output/data/p03737/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03737/OCaml/s424030545.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s424030545", "user_id": "u504158101"}, "prompt_components": {"gold_output": "ABC\n", "input_to_evaluate": "let () = Scanf.scanf \"%s %s %s\" @@ fun s1 s2 s3 ->\n Printf.printf \"%c%c%c\\n\"\n (Char.uppercase s1.[0])\n (Char.uppercase s2.[0])\n (Char.uppercase s3.[0])\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou are given three words s_1, s_2 and s_3, each composed of lowercase English letters, with spaces in between.\nPrint the acronym formed from the uppercased initial letters of the words.\n\nConstraints\n\ns_1, s_2 and s_3 are composed of lowercase English letters.\n\n1 ≤ |s_i| ≤ 10 (1≤i≤3)\n\nInput\n\nInput is given from Standard Input in the following format:\n\ns_1 s_2 s_3\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\natcoder beginner contest\n\nSample Output 1\n\nABC\n\nThe initial letters of atcoder, beginner and contest are a, b and c. Uppercase and concatenate them to obtain ABC.\n\nSample Input 2\n\nresident register number\n\nSample Output 2\n\nRRN\n\nSample Input 3\n\nk nearest neighbor\n\nSample Output 3\n\nKNN\n\nSample Input 4\n\nasync layered coding\n\nSample Output 4\n\nALC", "sample_input": "atcoder beginner contest\n"}, "reference_outputs": ["ABC\n"], "source_document_id": "p03737", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou are given three words s_1, s_2 and s_3, each composed of lowercase English letters, with spaces in between.\nPrint the acronym formed from the uppercased initial letters of the words.\n\nConstraints\n\ns_1, s_2 and s_3 are composed of lowercase English letters.\n\n1 ≤ |s_i| ≤ 10 (1≤i≤3)\n\nInput\n\nInput is given from Standard Input in the following format:\n\ns_1 s_2 s_3\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\natcoder beginner contest\n\nSample Output 1\n\nABC\n\nThe initial letters of atcoder, beginner and contest are a, b and c. Uppercase and concatenate them to obtain ABC.\n\nSample Input 2\n\nresident register number\n\nSample Output 2\n\nRRN\n\nSample Input 3\n\nk nearest neighbor\n\nSample Output 3\n\nKNN\n\nSample Input 4\n\nasync layered coding\n\nSample Output 4\n\nALC", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 2432}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s396001586", "group_id": "codeNet:p03737", "input_text": "open Printf\nopen Scanf\n\nlet () =\n let sl = scanf \"%s %s %s\\n\" (fun x y z -> [x;y;z]) in\n String.init 3 (fun i -> Char.uppercase (List.nth sl i).[0]) |> printf \"%s\\n\"\n", "language": "OCaml", "metadata": {"date": 1495156271, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03737.html", "problem_id": "p03737", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03737/input.txt", "sample_output_relpath": "derived/input_output/data/p03737/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03737/OCaml/s396001586.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s396001586", "user_id": "u388783188"}, "prompt_components": {"gold_output": "ABC\n", "input_to_evaluate": "open Printf\nopen Scanf\n\nlet () =\n let sl = scanf \"%s %s %s\\n\" (fun x y z -> [x;y;z]) in\n String.init 3 (fun i -> Char.uppercase (List.nth sl i).[0]) |> printf \"%s\\n\"\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou are given three words s_1, s_2 and s_3, each composed of lowercase English letters, with spaces in between.\nPrint the acronym formed from the uppercased initial letters of the words.\n\nConstraints\n\ns_1, s_2 and s_3 are composed of lowercase English letters.\n\n1 ≤ |s_i| ≤ 10 (1≤i≤3)\n\nInput\n\nInput is given from Standard Input in the following format:\n\ns_1 s_2 s_3\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\natcoder beginner contest\n\nSample Output 1\n\nABC\n\nThe initial letters of atcoder, beginner and contest are a, b and c. Uppercase and concatenate them to obtain ABC.\n\nSample Input 2\n\nresident register number\n\nSample Output 2\n\nRRN\n\nSample Input 3\n\nk nearest neighbor\n\nSample Output 3\n\nKNN\n\nSample Input 4\n\nasync layered coding\n\nSample Output 4\n\nALC", "sample_input": "atcoder beginner contest\n"}, "reference_outputs": ["ABC\n"], "source_document_id": "p03737", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou are given three words s_1, s_2 and s_3, each composed of lowercase English letters, with spaces in between.\nPrint the acronym formed from the uppercased initial letters of the words.\n\nConstraints\n\ns_1, s_2 and s_3 are composed of lowercase English letters.\n\n1 ≤ |s_i| ≤ 10 (1≤i≤3)\n\nInput\n\nInput is given from Standard Input in the following format:\n\ns_1 s_2 s_3\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\natcoder beginner contest\n\nSample Output 1\n\nABC\n\nThe initial letters of atcoder, beginner and contest are a, b and c. Uppercase and concatenate them to obtain ABC.\n\nSample Input 2\n\nresident register number\n\nSample Output 2\n\nRRN\n\nSample Input 3\n\nk nearest neighbor\n\nSample Output 3\n\nKNN\n\nSample Input 4\n\nasync layered coding\n\nSample Output 4\n\nALC", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s551695998", "group_id": "codeNet:p03738", "input_text": "let a, b = Scanf.scanf \" %s %s\" @@ fun a b -> a, b\nlet n, m = String.length a, String.length b\nlet _ = print_endline @@\n if n < m then \"LESS\" else if n > m then \"GREATER\"\n else if a < b then \"LESS\" else if a > b then \"GREATER\" else \"EQUAL\"", "language": "OCaml", "metadata": {"date": 1562220097, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03738.html", "problem_id": "p03738", "resource_group": "low_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/OCaml/s551695998.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s551695998", "user_id": "u732304692"}, "prompt_components": {"gold_output": "GREATER\n", "input_to_evaluate": "let a, b = Scanf.scanf \" %s %s\" @@ fun a b -> a, b\nlet n, m = String.length a, String.length b\nlet _ = print_endline @@\n if n < m then \"LESS\" else if n > m then \"GREATER\"\n else if a < b then \"LESS\" else if a > b then \"GREATER\" else \"EQUAL\"", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 2432}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s736310484", "group_id": "codeNet:p03738", "input_text": "let () = Scanf.scanf \"%s\\n%s\" @@ fun a b ->\n if String.length a < String.length b then print_endline \"LESS\"\n else if String.length a > String.length b then print_endline \"GREATER\"\n else\n try\n Array.init (String.length a) (fun i -> Char.code b.[i] - Char.code a.[i])\n |> Array.to_list\n |> List.find (( <> ) 0)\n |> (fun d -> if 0 < d then \"LESS\" else \"GREATER\")\n |> print_endline\n with Not_found -> print_endline \"EQUAL\"\n", "language": "OCaml", "metadata": {"date": 1530681674, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03738.html", "problem_id": "p03738", "resource_group": "low_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/OCaml/s736310484.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s736310484", "user_id": "u504158101"}, "prompt_components": {"gold_output": "GREATER\n", "input_to_evaluate": "let () = Scanf.scanf \"%s\\n%s\" @@ fun a b ->\n if String.length a < String.length b then print_endline \"LESS\"\n else if String.length a > String.length b then print_endline \"GREATER\"\n else\n try\n Array.init (String.length a) (fun i -> Char.code b.[i] - Char.code a.[i])\n |> Array.to_list\n |> List.find (( <> ) 0)\n |> (fun d -> if 0 < d then \"LESS\" else \"GREATER\")\n |> print_endline\n with Not_found -> print_endline \"EQUAL\"\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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 453, "cpu_time_ms": 1, "memory_kb": 2432}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s495689888", "group_id": "codeNet:p03739", "input_text": "(* O(n) *)\nlet n = Scanf.scanf \" %d\" @@ (+) 0\nlet a_s = Array.init n @@ fun _ -> Scanf.scanf \" %d\" @@ (+) 0\nlet ans = ref max_int\nlet _ =\n for m = 0 to 1 do\n let sum = ref a_s.(0) in\n let c = ref 0 in\n if a_s.(0) > 0 then if m = 0 then (sum := -1; c := abs !sum + 1) else ()\n else if m = 1 then (sum := 1; c := abs !sum + 1);\n for i = 1 to n - 1 do\n if i mod 2 = m then\n (sum := !sum + a_s.(i);\n if !sum >= 0 then (c := !c + abs !sum + 1; sum := -1))\n else\n (sum := !sum + a_s.(i);\n if !sum <= 0 then (c := !c + abs !sum + 1; sum := 1))\n done;\n ans := min !ans !c\n done;\n Printf.printf \"%d\\n\" !ans", "language": "OCaml", "metadata": {"date": 1560237101, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03739.html", "problem_id": "p03739", "resource_group": "low_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/OCaml/s495689888.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s495689888", "user_id": "u732304692"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "(* O(n) *)\nlet n = Scanf.scanf \" %d\" @@ (+) 0\nlet a_s = Array.init n @@ fun _ -> Scanf.scanf \" %d\" @@ (+) 0\nlet ans = ref max_int\nlet _ =\n for m = 0 to 1 do\n let sum = ref a_s.(0) in\n let c = ref 0 in\n if a_s.(0) > 0 then if m = 0 then (sum := -1; c := abs !sum + 1) else ()\n else if m = 1 then (sum := 1; c := abs !sum + 1);\n for i = 1 to n - 1 do\n if i mod 2 = m then\n (sum := !sum + a_s.(i);\n if !sum >= 0 then (c := !c + abs !sum + 1; sum := -1))\n else\n (sum := !sum + a_s.(i);\n if !sum <= 0 then (c := !c + abs !sum + 1; sum := 1))\n done;\n ans := min !ans !c\n done;\n Printf.printf \"%d\\n\" !ans", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 34, "memory_kb": 5248}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s909593471", "group_id": "codeNet:p03745", "input_text": "let () =\n let n = Scanf.scanf \"%d\\n\" (fun n -> n) in\n let as_ = Array.init n (fun _ -> Scanf.scanf \"%d \" (fun a -> a)) in\n Array.to_list as_\n |> (fun (h :: t) ->\n List.fold_left (fun (acc, a, dir) a' ->\n if dir = 0 || compare a a' = dir then (acc, a', compare a a')\n else (1 + acc, a', 0)) (1, h, 0) t)\n |> (fun (acc, _, _) -> acc)\n |> Printf.printf \"%d\\n\"", "language": "OCaml", "metadata": {"date": 1507372985, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03745.html", "problem_id": "p03745", "resource_group": "low_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/OCaml/s909593471.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s909593471", "user_id": "u504158101"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "let () =\n let n = Scanf.scanf \"%d\\n\" (fun n -> n) in\n let as_ = Array.init n (fun _ -> Scanf.scanf \"%d \" (fun a -> a)) in\n Array.to_list as_\n |> (fun (h :: t) ->\n List.fold_left (fun (acc, a, dir) a' ->\n if dir = 0 || compare a a' = dir then (acc, a', compare a a')\n else (1 + acc, a', 0)) (1, h, 0) t)\n |> (fun (acc, _, _) -> acc)\n |> Printf.printf \"%d\\n\"", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou are given an array A of length N.\nYour task is to divide it into several contiguous subarrays.\nHere, all subarrays obtained must be sorted in either non-decreasing or non-increasing order.\nAt least how many subarrays do you need to divide A into?\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq A_i \\leq 10^9\n\nEach A_i is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the minimum possible number of subarrays after division of A.\n\nSample Input 1\n\n6\n1 2 3 2 2 1\n\nSample Output 1\n\n2\n\nOne optimal solution is to divide the array into [1,2,3] and [2,2,1].\n\nSample Input 2\n\n9\n1 2 1 2 1 2 1 2 1\n\nSample Output 2\n\n5\n\nSample Input 3\n\n7\n1 2 3 2 1 999999999 1000000000\n\nSample Output 3\n\n3", "sample_input": "6\n1 2 3 2 2 1\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03745", "source_text": "Score : 300 points\n\nProblem Statement\n\nYou are given an array A of length N.\nYour task is to divide it into several contiguous subarrays.\nHere, all subarrays obtained must be sorted in either non-decreasing or non-increasing order.\nAt least how many subarrays do you need to divide A into?\n\nConstraints\n\n1 \\leq N \\leq 10^5\n\n1 \\leq A_i \\leq 10^9\n\nEach A_i is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the minimum possible number of subarrays after division of A.\n\nSample Input 1\n\n6\n1 2 3 2 2 1\n\nSample Output 1\n\n2\n\nOne optimal solution is to divide the array into [1,2,3] and [2,2,1].\n\nSample Input 2\n\n9\n1 2 1 2 1 2 1 2 1\n\nSample Output 2\n\n5\n\nSample Input 3\n\n7\n1 2 3 2 1 999999999 1000000000\n\nSample Output 3\n\n3", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 375, "cpu_time_ms": 34, "memory_kb": 6272}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s343363903", "group_id": "codeNet:p03752", "input_text": "open Batteries\nmodule EnumL = Enum.Labels\nmodule ListL = List.Labels\nmodule ArrayL = Array.Labels\n\nlet dbg0 x = Printf.eprintf \"[debug]%s\\n\" @@ dump x\nlet dbg1 x = dbg0 x; x\n\nlet id = identity\n\nlet (++) n m = List.range n `To m\nlet (++-) n m = if n >= m then List.range n `Downto m else []\nlet (++^) n m = if n < m then List.range n `To (pred m) else []\n\nlet scan fmt = Scanf.sscanf (read_line ()) fmt\n\nlet scan_lines n fmt f =\n if n = 0 then []\n else List.map (fun _ -> scan fmt f) (1 ++ n)\n\nlet scan_list ?sep cnv =\n let line = read_line () in\n (match sep with\n | None -> List.map String.of_char @@ String.to_list line\n | Some sep -> String.split_on_char sep line)\n |> List.map cnv\n\nlet scan_array ?sep cnv = Array.of_list @@ scan_list ?sep cnv\n\nlet scan_matrix n m e ?sep conv =\n let arr = Array.make_matrix n m e in\n ListL.iter (0 ++^ n)\n ~f:(fun i -> arr.(i) <- Array.of_list @@ scan_list ?sep conv);\n arr\n\nlet atoi c = Char.code c - Char.code '0'\n\nlet rec powerset = function\n | [] -> [[]]\n | hd::tl ->\n let pws = powerset tl in\n pws @ ListL.map pws ~f:(fun pw -> hd::pw)\n\nlet permutations l =\n let rec interleave x = function\n | [] -> [[x]]\n | (hd::tl) as l ->\n (x::l) :: (interleave x tl |> ListL.map ~f:(fun l -> hd::l)) in\n let rec aux = function\n | [] -> [[]]\n | a::rest ->\n aux rest |> ListL.map ~f:(interleave a) |> List.concat in\n aux l\n\nlet intersection l =\n EnumL.filter ~f:(fun x -> EnumL.exists ~f:((=) x) @@ Enum.clone l)\n\nlet zip l m =\n let n = min (List.length l) (List.length m) in\n List.combine (List.take n l) (List.take n m)\n\nlet lower_bound n f =\n let rec aux l u =\n if u - l > 1 then\n let m = (l + u) / 2 in\n if f m then aux l m\n else aux m u\n else u in aux (-1) n\n\nlet between n x m = n <= x && x < m\n\nlet (n,k) = scan \"%d %d\" Tuple2.make\nlet arr = scan_array ~sep:' ' Int.of_string\n\nlet () =\n let sets = powerset (0++^n)\n |> ListL.filter ~f:(fun l -> List.length l = k)\n |> ListL.map ~f:(List.sort Int.compare) in\n ListL.map sets ~f:(fun set ->\n let hd = List.hd set in\n let height = Array.sub arr 0 hd |> ArrayL.fold_left ~init:0 ~f:max in\n ListL.fold_left set ~init:(height, 0)\n ~f:(fun (pred, n) i ->\n if pred < arr.(i) then (arr.(i), n) else (pred+1, n + pred+1 - arr.(i))))\n |> List.map Tuple2.second\n |> List.min\n |> Printf.printf \"%d\\n\"\n", "language": "OCaml", "metadata": {"date": 1591414625, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03752.html", "problem_id": "p03752", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03752/input.txt", "sample_output_relpath": "derived/input_output/data/p03752/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03752/OCaml/s343363903.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s343363903", "user_id": "u802614675"}, "prompt_components": {"gold_output": "1541\n", "input_to_evaluate": "open Batteries\nmodule EnumL = Enum.Labels\nmodule ListL = List.Labels\nmodule ArrayL = Array.Labels\n\nlet dbg0 x = Printf.eprintf \"[debug]%s\\n\" @@ dump x\nlet dbg1 x = dbg0 x; x\n\nlet id = identity\n\nlet (++) n m = List.range n `To m\nlet (++-) n m = if n >= m then List.range n `Downto m else []\nlet (++^) n m = if n < m then List.range n `To (pred m) else []\n\nlet scan fmt = Scanf.sscanf (read_line ()) fmt\n\nlet scan_lines n fmt f =\n if n = 0 then []\n else List.map (fun _ -> scan fmt f) (1 ++ n)\n\nlet scan_list ?sep cnv =\n let line = read_line () in\n (match sep with\n | None -> List.map String.of_char @@ String.to_list line\n | Some sep -> String.split_on_char sep line)\n |> List.map cnv\n\nlet scan_array ?sep cnv = Array.of_list @@ scan_list ?sep cnv\n\nlet scan_matrix n m e ?sep conv =\n let arr = Array.make_matrix n m e in\n ListL.iter (0 ++^ n)\n ~f:(fun i -> arr.(i) <- Array.of_list @@ scan_list ?sep conv);\n arr\n\nlet atoi c = Char.code c - Char.code '0'\n\nlet rec powerset = function\n | [] -> [[]]\n | hd::tl ->\n let pws = powerset tl in\n pws @ ListL.map pws ~f:(fun pw -> hd::pw)\n\nlet permutations l =\n let rec interleave x = function\n | [] -> [[x]]\n | (hd::tl) as l ->\n (x::l) :: (interleave x tl |> ListL.map ~f:(fun l -> hd::l)) in\n let rec aux = function\n | [] -> [[]]\n | a::rest ->\n aux rest |> ListL.map ~f:(interleave a) |> List.concat in\n aux l\n\nlet intersection l =\n EnumL.filter ~f:(fun x -> EnumL.exists ~f:((=) x) @@ Enum.clone l)\n\nlet zip l m =\n let n = min (List.length l) (List.length m) in\n List.combine (List.take n l) (List.take n m)\n\nlet lower_bound n f =\n let rec aux l u =\n if u - l > 1 then\n let m = (l + u) / 2 in\n if f m then aux l m\n else aux m u\n else u in aux (-1) n\n\nlet between n x m = n <= x && x < m\n\nlet (n,k) = scan \"%d %d\" Tuple2.make\nlet arr = scan_array ~sep:' ' Int.of_string\n\nlet () =\n let sets = powerset (0++^n)\n |> ListL.filter ~f:(fun l -> List.length l = k)\n |> ListL.map ~f:(List.sort Int.compare) in\n ListL.map sets ~f:(fun set ->\n let hd = List.hd set in\n let height = Array.sub arr 0 hd |> ArrayL.fold_left ~init:0 ~f:max in\n ListL.fold_left set ~init:(height, 0)\n ~f:(fun (pred, n) i ->\n if pred < arr.(i) then (arr.(i), n) else (pred+1, n + pred+1 - arr.(i))))\n |> List.map Tuple2.second\n |> List.min\n |> Printf.printf \"%d\\n\"\n", "problem_context": "Max Score: 350 Points\n\nProblem Statement\n\nThere are N buildings along the line. The i-th building from the left is colored in color i, and its height is currently a_i meters.\n\nChokudai is a mayor of the city, and he loves colorful thigs. And now he wants to see at least K buildings from the left.\n\nYou can increase height of buildings, but it costs 1 yens to increase 1 meters. It means you cannot make building that height is not integer.\n\nYou cannot decrease height of buildings.\n\nCalculate the minimum cost of satisfying Chokudai's objective.\n\nNote: \"Building i can see from the left\" means there are no j exists that (height of building j) ≥ (height of building i) and j < i.\n\nInput Format\n\nN K\na_1 a_2 a_3 ... a_N\n\nOutput Format\n\nPrint the minimum cost in one line. In the end put a line break.\n\nConstraints\n\n1 ≤ K ≤ N ≤ 15\n\n1 ≤ a_i ≤ 10^9\n\nScoring\n\nSubtask 1 [120 points]\n\nN = K\n\nSubtask 2 [90 points]\n\nN ≤ 5\n\na_i ≤ 7\n\nSubtask 3 [140 points]\n\nThere are no additional constraints.\n\nSample Input 1\n\n5 5\n3949 3774 3598 3469 3424\n\nSample Output 1\n\n1541\n\nThe optimal solution is (height of buildings from the left) = [3949, 3950, 3951, 3952, 3953].\n\nSample Input 2\n\n5 3\n7 4 2 6 4\n\nSample Output 2\n\n7\n\nThe optimal solution is (height of buildings from the left) = [7, 8, 2, 9, 4].", "sample_input": "5 5\n3949 3774 3598 3469 3424\n"}, "reference_outputs": ["1541\n"], "source_document_id": "p03752", "source_text": "Max Score: 350 Points\n\nProblem Statement\n\nThere are N buildings along the line. The i-th building from the left is colored in color i, and its height is currently a_i meters.\n\nChokudai is a mayor of the city, and he loves colorful thigs. And now he wants to see at least K buildings from the left.\n\nYou can increase height of buildings, but it costs 1 yens to increase 1 meters. It means you cannot make building that height is not integer.\n\nYou cannot decrease height of buildings.\n\nCalculate the minimum cost of satisfying Chokudai's objective.\n\nNote: \"Building i can see from the left\" means there are no j exists that (height of building j) ≥ (height of building i) and j < i.\n\nInput Format\n\nN K\na_1 a_2 a_3 ... a_N\n\nOutput Format\n\nPrint the minimum cost in one line. In the end put a line break.\n\nConstraints\n\n1 ≤ K ≤ N ≤ 15\n\n1 ≤ a_i ≤ 10^9\n\nScoring\n\nSubtask 1 [120 points]\n\nN = K\n\nSubtask 2 [90 points]\n\nN ≤ 5\n\na_i ≤ 7\n\nSubtask 3 [140 points]\n\nThere are no additional constraints.\n\nSample Input 1\n\n5 5\n3949 3774 3598 3469 3424\n\nSample Output 1\n\n1541\n\nThe optimal solution is (height of buildings from the left) = [3949, 3950, 3951, 3952, 3953].\n\nSample Input 2\n\n5 3\n7 4 2 6 4\n\nSample Output 2\n\n7\n\nThe optimal solution is (height of buildings from the left) = [7, 8, 2, 9, 4].", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2409, "cpu_time_ms": 9, "memory_kb": 7040}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s168233975", "group_id": "codeNet:p03752", "input_text": "let _ =\n let nk = List.map int_of_string @@ Str.split (Str.regexp \"[ \\t]+\") (read_line ()) in\n let hs = List.map int_of_string @@ Str.split (Str.regexp \"[ \\t]+\") (read_line ()) in\n let rec f ph ls acc =\n match ls with\n [] -> acc\n | (h::t) -> if (ph + 1) <= h then f h t acc else f (ph + 1) t (acc + ph + 1 - h) in\n print_endline @@ string_of_int @@ f (List.hd hs) (List.tl hs) 0\n", "language": "OCaml", "metadata": {"date": 1491790157, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03752.html", "problem_id": "p03752", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03752/input.txt", "sample_output_relpath": "derived/input_output/data/p03752/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03752/OCaml/s168233975.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s168233975", "user_id": "u388783188"}, "prompt_components": {"gold_output": "1541\n", "input_to_evaluate": "let _ =\n let nk = List.map int_of_string @@ Str.split (Str.regexp \"[ \\t]+\") (read_line ()) in\n let hs = List.map int_of_string @@ Str.split (Str.regexp \"[ \\t]+\") (read_line ()) in\n let rec f ph ls acc =\n match ls with\n [] -> acc\n | (h::t) -> if (ph + 1) <= h then f h t acc else f (ph + 1) t (acc + ph + 1 - h) in\n print_endline @@ string_of_int @@ f (List.hd hs) (List.tl hs) 0\n", "problem_context": "Max Score: 350 Points\n\nProblem Statement\n\nThere are N buildings along the line. The i-th building from the left is colored in color i, and its height is currently a_i meters.\n\nChokudai is a mayor of the city, and he loves colorful thigs. And now he wants to see at least K buildings from the left.\n\nYou can increase height of buildings, but it costs 1 yens to increase 1 meters. It means you cannot make building that height is not integer.\n\nYou cannot decrease height of buildings.\n\nCalculate the minimum cost of satisfying Chokudai's objective.\n\nNote: \"Building i can see from the left\" means there are no j exists that (height of building j) ≥ (height of building i) and j < i.\n\nInput Format\n\nN K\na_1 a_2 a_3 ... a_N\n\nOutput Format\n\nPrint the minimum cost in one line. In the end put a line break.\n\nConstraints\n\n1 ≤ K ≤ N ≤ 15\n\n1 ≤ a_i ≤ 10^9\n\nScoring\n\nSubtask 1 [120 points]\n\nN = K\n\nSubtask 2 [90 points]\n\nN ≤ 5\n\na_i ≤ 7\n\nSubtask 3 [140 points]\n\nThere are no additional constraints.\n\nSample Input 1\n\n5 5\n3949 3774 3598 3469 3424\n\nSample Output 1\n\n1541\n\nThe optimal solution is (height of buildings from the left) = [3949, 3950, 3951, 3952, 3953].\n\nSample Input 2\n\n5 3\n7 4 2 6 4\n\nSample Output 2\n\n7\n\nThe optimal solution is (height of buildings from the left) = [7, 8, 2, 9, 4].", "sample_input": "5 5\n3949 3774 3598 3469 3424\n"}, "reference_outputs": ["1541\n"], "source_document_id": "p03752", "source_text": "Max Score: 350 Points\n\nProblem Statement\n\nThere are N buildings along the line. The i-th building from the left is colored in color i, and its height is currently a_i meters.\n\nChokudai is a mayor of the city, and he loves colorful thigs. And now he wants to see at least K buildings from the left.\n\nYou can increase height of buildings, but it costs 1 yens to increase 1 meters. It means you cannot make building that height is not integer.\n\nYou cannot decrease height of buildings.\n\nCalculate the minimum cost of satisfying Chokudai's objective.\n\nNote: \"Building i can see from the left\" means there are no j exists that (height of building j) ≥ (height of building i) and j < i.\n\nInput Format\n\nN K\na_1 a_2 a_3 ... a_N\n\nOutput Format\n\nPrint the minimum cost in one line. In the end put a line break.\n\nConstraints\n\n1 ≤ K ≤ N ≤ 15\n\n1 ≤ a_i ≤ 10^9\n\nScoring\n\nSubtask 1 [120 points]\n\nN = K\n\nSubtask 2 [90 points]\n\nN ≤ 5\n\na_i ≤ 7\n\nSubtask 3 [140 points]\n\nThere are no additional constraints.\n\nSample Input 1\n\n5 5\n3949 3774 3598 3469 3424\n\nSample Output 1\n\n1541\n\nThe optimal solution is (height of buildings from the left) = [3949, 3950, 3951, 3952, 3953].\n\nSample Input 2\n\n5 3\n7 4 2 6 4\n\nSample Output 2\n\n7\n\nThe optimal solution is (height of buildings from the left) = [7, 8, 2, 9, 4].", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 394, "cpu_time_ms": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s308392998", "group_id": "codeNet:p03759", "input_text": "Scanf.sscanf (read_line ()) \"%d %d %d\" (fun a b c ->\n if b-a=c-b then print_string \"YES\"\n else print_string \"NO\"\n);;\n", "language": "OCaml", "metadata": {"date": 1492539604, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03759.html", "problem_id": "p03759", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03759/input.txt", "sample_output_relpath": "derived/input_output/data/p03759/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03759/OCaml/s308392998.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s308392998", "user_id": "u762921614"}, "prompt_components": {"gold_output": "YES\n", "input_to_evaluate": "Scanf.sscanf (read_line ()) \"%d %d %d\" (fun a b c ->\n if b-a=c-b then print_string \"YES\"\n else print_string \"NO\"\n);;\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nThree poles stand evenly spaced along a line. Their heights are a, b and c meters, from left to right.\nWe will call the arrangement of the poles beautiful if the tops of the poles lie on the same line, that is, b-a = c-b.\n\nDetermine whether the arrangement of the poles is beautiful.\n\nConstraints\n\n1 \\leq a,b,c \\leq 100\n\na, b and c are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\na b c\n\nOutput\n\nPrint YES if the arrangement of the poles is beautiful; print NO otherwise.\n\nSample Input 1\n\n2 4 6\n\nSample Output 1\n\nYES\n\nSince 4-2 = 6-4, this arrangement of poles is beautiful.\n\nSample Input 2\n\n2 5 6\n\nSample Output 2\n\nNO\n\nSince 5-2 \\neq 6-5, this arrangement of poles is not beautiful.\n\nSample Input 3\n\n3 2 1\n\nSample Output 3\n\nYES\n\nSince 1-2 = 2-3, this arrangement of poles is beautiful.", "sample_input": "2 4 6\n"}, "reference_outputs": ["YES\n"], "source_document_id": "p03759", "source_text": "Score : 100 points\n\nProblem Statement\n\nThree poles stand evenly spaced along a line. Their heights are a, b and c meters, from left to right.\nWe will call the arrangement of the poles beautiful if the tops of the poles lie on the same line, that is, b-a = c-b.\n\nDetermine whether the arrangement of the poles is beautiful.\n\nConstraints\n\n1 \\leq a,b,c \\leq 100\n\na, b and c are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\na b c\n\nOutput\n\nPrint YES if the arrangement of the poles is beautiful; print NO otherwise.\n\nSample Input 1\n\n2 4 6\n\nSample Output 1\n\nYES\n\nSince 4-2 = 6-4, this arrangement of poles is beautiful.\n\nSample Input 2\n\n2 5 6\n\nSample Output 2\n\nNO\n\nSince 5-2 \\neq 6-5, this arrangement of poles is not beautiful.\n\nSample Input 3\n\n3 2 1\n\nSample Output 3\n\nYES\n\nSince 1-2 = 2-3, this arrangement of poles is beautiful.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s560417018", "group_id": "codeNet:p03760", "input_text": "let () =\n\tlet o = read_line () in\n\tlet e = read_line () in\n\tlet o_len = String.length o in\n\tlet e_len = String.length e in\n\tfor i = 0 to e_len - 1 do\n\t\tprint_char o.[i];\n\t\tprint_char e.[i]\n\tdone;\n\tif o_len > e_len then begin\n\t\tprint_char o.[o_len - 1];\n\t\tprint_newline ()\n\tend else\n\t\tprint_newline ()\n", "language": "OCaml", "metadata": {"date": 1491784082, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03760.html", "problem_id": "p03760", "resource_group": "low_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/OCaml/s560417018.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s560417018", "user_id": "u420267469"}, "prompt_components": {"gold_output": "xaybzc\n", "input_to_evaluate": "let () =\n\tlet o = read_line () in\n\tlet e = read_line () in\n\tlet o_len = String.length o in\n\tlet e_len = String.length e in\n\tfor i = 0 to e_len - 1 do\n\t\tprint_char o.[i];\n\t\tprint_char e.[i]\n\tdone;\n\tif o_len > e_len then begin\n\t\tprint_char o.[o_len - 1];\n\t\tprint_newline ()\n\tend else\n\t\tprint_newline ()\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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s429748613", "group_id": "codeNet:p03762", "input_text": "let c = 1000000007\n\nlet ans n m =\n let rec sum i n s =\n if i = n then s\n else\n let x = Scanf.scanf \" %d\" (fun x -> x) in\n sum (i + 1) n ((s + (2 * i - n + 1) * x mod c) mod c)\n in\n sum 0 n 0 * sum 0 m 0 mod c\n\nlet () = Scanf.scanf \"%d %d\" (fun n m -> print_int (ans n m))\n", "language": "OCaml", "metadata": {"date": 1585955641, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03762.html", "problem_id": "p03762", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03762/input.txt", "sample_output_relpath": "derived/input_output/data/p03762/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03762/OCaml/s429748613.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s429748613", "user_id": "u752907799"}, "prompt_components": {"gold_output": "60\n", "input_to_evaluate": "let c = 1000000007\n\nlet ans n m =\n let rec sum i n s =\n if i = n then s\n else\n let x = Scanf.scanf \" %d\" (fun x -> x) in\n sum (i + 1) n ((s + (2 * i - n + 1) * x mod c) mod c)\n in\n sum 0 n 0 * sum 0 m 0 mod c\n\nlet () = Scanf.scanf \"%d %d\" (fun n m -> print_int (ans n m))\n", "problem_context": "Score : 500 points\n\nProblem Statement\n\nOn a two-dimensional plane, there are m lines drawn parallel to the x axis, and n lines drawn parallel to the y axis.\nAmong the lines parallel to the x axis, the i-th from the bottom is represented by y = y_i.\nSimilarly, among the lines parallel to the y axis, the i-th from the left is represented by x = x_i.\n\nFor every rectangle that is formed by these lines, find its area, and print the total area modulo 10^9+7.\n\nThat is, for every quadruple (i,j,k,l) satisfying 1\\leq i < j\\leq n and 1\\leq k < l\\leq m, find the area of the rectangle formed by the lines x=x_i, x=x_j, y=y_k and y=y_l, and print the sum of these areas modulo 10^9+7.\n\nConstraints\n\n2 \\leq n,m \\leq 10^5\n\n-10^9 \\leq x_1 < ... < x_n \\leq 10^9\n\n-10^9 \\leq y_1 < ... < y_m \\leq 10^9\n\nx_i and y_i are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nn m\nx_1 x_2 ... x_n\ny_1 y_2 ... y_m\n\nOutput\n\nPrint the total area of the rectangles, modulo 10^9+7.\n\nSample Input 1\n\n3 3\n1 3 4\n1 3 6\n\nSample Output 1\n\n60\n\nThe following figure illustrates this input:\n\nThe total area of the nine rectangles A, B, ..., I shown in the following figure, is 60.\n\nSample Input 2\n\n6 5\n-790013317 -192321079 95834122 418379342 586260100 802780784\n-253230108 193944314 363756450 712662868 735867677\n\nSample Output 2\n\n835067060", "sample_input": "3 3\n1 3 4\n1 3 6\n"}, "reference_outputs": ["60\n"], "source_document_id": "p03762", "source_text": "Score : 500 points\n\nProblem Statement\n\nOn a two-dimensional plane, there are m lines drawn parallel to the x axis, and n lines drawn parallel to the y axis.\nAmong the lines parallel to the x axis, the i-th from the bottom is represented by y = y_i.\nSimilarly, among the lines parallel to the y axis, the i-th from the left is represented by x = x_i.\n\nFor every rectangle that is formed by these lines, find its area, and print the total area modulo 10^9+7.\n\nThat is, for every quadruple (i,j,k,l) satisfying 1\\leq i < j\\leq n and 1\\leq k < l\\leq m, find the area of the rectangle formed by the lines x=x_i, x=x_j, y=y_k and y=y_l, and print the sum of these areas modulo 10^9+7.\n\nConstraints\n\n2 \\leq n,m \\leq 10^5\n\n-10^9 \\leq x_1 < ... < x_n \\leq 10^9\n\n-10^9 \\leq y_1 < ... < y_m \\leq 10^9\n\nx_i and y_i are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nn m\nx_1 x_2 ... x_n\ny_1 y_2 ... y_m\n\nOutput\n\nPrint the total area of the rectangles, modulo 10^9+7.\n\nSample Input 1\n\n3 3\n1 3 4\n1 3 6\n\nSample Output 1\n\n60\n\nThe following figure illustrates this input:\n\nThe total area of the nine rectangles A, B, ..., I shown in the following figure, is 60.\n\nSample Input 2\n\n6 5\n-790013317 -192321079 95834122 418379342 586260100 802780784\n-253230108 193944314 363756450 712662868 735867677\n\nSample Output 2\n\n835067060", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 57, "memory_kb": 4736}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s353956393", "group_id": "codeNet:p03764", "input_text": "let n = 1000000007\nlet ( *^ ) x y = x * y mod n\n\nlet () =\n let n, m = Scanf.scanf \"%d %d\\n\" (fun n m -> n, m) in\n let xs = Array.init n (fun _ -> Scanf.scanf \"%d \" (fun x -> x)) in\n let ys = Array.init m (fun _ -> Scanf.scanf \"%d \" (fun y -> y)) in\n Printf.printf \"%d\\n\" @@ (xs.(n - 1) - xs.(0)) *^ (ys.(m - 1) - ys.(0)) *^ (n - 1) *^ (m - 1)", "language": "OCaml", "metadata": {"date": 1510511134, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03764.html", "problem_id": "p03764", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03764/input.txt", "sample_output_relpath": "derived/input_output/data/p03764/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03764/OCaml/s353956393.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s353956393", "user_id": "u504158101"}, "prompt_components": {"gold_output": "60\n", "input_to_evaluate": "let n = 1000000007\nlet ( *^ ) x y = x * y mod n\n\nlet () =\n let n, m = Scanf.scanf \"%d %d\\n\" (fun n m -> n, m) in\n let xs = Array.init n (fun _ -> Scanf.scanf \"%d \" (fun x -> x)) in\n let ys = Array.init m (fun _ -> Scanf.scanf \"%d \" (fun y -> y)) in\n Printf.printf \"%d\\n\" @@ (xs.(n - 1) - xs.(0)) *^ (ys.(m - 1) - ys.(0)) *^ (n - 1) *^ (m - 1)", "problem_context": "Score : 500 points\n\nProblem Statement\n\nOn a two-dimensional plane, there are m lines drawn parallel to the x axis, and n lines drawn parallel to the y axis.\nAmong the lines parallel to the x axis, the i-th from the bottom is represented by y = y_i.\nSimilarly, among the lines parallel to the y axis, the i-th from the left is represented by x = x_i.\n\nFor every rectangle that is formed by these lines, find its area, and print the total area modulo 10^9+7.\n\nThat is, for every quadruple (i,j,k,l) satisfying 1\\leq i < j\\leq n and 1\\leq k < l\\leq m, find the area of the rectangle formed by the lines x=x_i, x=x_j, y=y_k and y=y_l, and print the sum of these areas modulo 10^9+7.\n\nConstraints\n\n2 \\leq n,m \\leq 10^5\n\n-10^9 \\leq x_1 < ... < x_n \\leq 10^9\n\n-10^9 \\leq y_1 < ... < y_m \\leq 10^9\n\nx_i and y_i are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nn m\nx_1 x_2 ... x_n\ny_1 y_2 ... y_m\n\nOutput\n\nPrint the total area of the rectangles, modulo 10^9+7.\n\nSample Input 1\n\n3 3\n1 3 4\n1 3 6\n\nSample Output 1\n\n60\n\nThe following figure illustrates this input:\n\nThe total area of the nine rectangles A, B, ..., I shown in the following figure, is 60.\n\nSample Input 2\n\n6 5\n-790013317 -192321079 95834122 418379342 586260100 802780784\n-253230108 193944314 363756450 712662868 735867677\n\nSample Output 2\n\n835067060", "sample_input": "3 3\n1 3 4\n1 3 6\n"}, "reference_outputs": ["60\n"], "source_document_id": "p03764", "source_text": "Score : 500 points\n\nProblem Statement\n\nOn a two-dimensional plane, there are m lines drawn parallel to the x axis, and n lines drawn parallel to the y axis.\nAmong the lines parallel to the x axis, the i-th from the bottom is represented by y = y_i.\nSimilarly, among the lines parallel to the y axis, the i-th from the left is represented by x = x_i.\n\nFor every rectangle that is formed by these lines, find its area, and print the total area modulo 10^9+7.\n\nThat is, for every quadruple (i,j,k,l) satisfying 1\\leq i < j\\leq n and 1\\leq k < l\\leq m, find the area of the rectangle formed by the lines x=x_i, x=x_j, y=y_k and y=y_l, and print the sum of these areas modulo 10^9+7.\n\nConstraints\n\n2 \\leq n,m \\leq 10^5\n\n-10^9 \\leq x_1 < ... < x_n \\leq 10^9\n\n-10^9 \\leq y_1 < ... < y_m \\leq 10^9\n\nx_i and y_i are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nn m\nx_1 x_2 ... x_n\ny_1 y_2 ... y_m\n\nOutput\n\nPrint the total area of the rectangles, modulo 10^9+7.\n\nSample Input 1\n\n3 3\n1 3 4\n1 3 6\n\nSample Output 1\n\n60\n\nThe following figure illustrates this input:\n\nThe total area of the nine rectangles A, B, ..., I shown in the following figure, is 60.\n\nSample Input 2\n\n6 5\n-790013317 -192321079 95834122 418379342 586260100 802780784\n-253230108 193944314 363756450 712662868 735867677\n\nSample Output 2\n\n835067060", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 62, "memory_kb": 6016}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s772005293", "group_id": "codeNet:p03767", "input_text": "let () =\n let n = Scanf.scanf \"%d\\n\" (fun n -> n) in\n let as_ = Array.init (3 * n) (fun _ -> Scanf.scanf \"%d \" (fun n -> n)) in\n Array.sort (fun x y -> compare y x) as_;\n Printf.printf \"%d\\n\" (Array.fold_left ( + ) 0 (Array.init n (fun i -> as_.(2 * i + 1))))", "language": "OCaml", "metadata": {"date": 1507523373, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03767.html", "problem_id": "p03767", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03767/input.txt", "sample_output_relpath": "derived/input_output/data/p03767/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03767/OCaml/s772005293.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s772005293", "user_id": "u504158101"}, "prompt_components": {"gold_output": "10\n", "input_to_evaluate": "let () =\n let n = Scanf.scanf \"%d\\n\" (fun n -> n) in\n let as_ = Array.init (3 * n) (fun _ -> Scanf.scanf \"%d \" (fun n -> n)) in\n Array.sort (fun x y -> compare y x) as_;\n Printf.printf \"%d\\n\" (Array.fold_left ( + ) 0 (Array.init n (fun i -> as_.(2 * i + 1))))", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere are 3N participants in AtCoder Group Contest.\nThe strength of the i-th participant is represented by an integer a_i.\nThey will form N teams, each consisting of three participants.\nNo participant may belong to multiple teams.\n\nThe strength of a team is defined as the second largest strength among its members.\nFor example, a team of participants of strength 1, 5, 2 has a strength 2, and a team of three participants of strength 3, 2, 3 has a strength 3.\n\nFind the maximum possible sum of the strengths of N teams.\n\nConstraints\n\n1 ≤ N ≤ 10^5\n\n1 ≤ a_i ≤ 10^{9}\n\na_i are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 ... a_{3N}\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n2\n5 2 8 5 1 5\n\nSample Output 1\n\n10\n\nThe following is one formation of teams that maximizes the sum of the strengths of teams:\n\nTeam 1: consists of the first, fourth and fifth participants.\n\nTeam 2: consists of the second, third and sixth participants.\n\nSample Input 2\n\n10\n1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000\n\nSample Output 2\n\n10000000000\n\nThe sum of the strengths can be quite large.", "sample_input": "2\n5 2 8 5 1 5\n"}, "reference_outputs": ["10\n"], "source_document_id": "p03767", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere are 3N participants in AtCoder Group Contest.\nThe strength of the i-th participant is represented by an integer a_i.\nThey will form N teams, each consisting of three participants.\nNo participant may belong to multiple teams.\n\nThe strength of a team is defined as the second largest strength among its members.\nFor example, a team of participants of strength 1, 5, 2 has a strength 2, and a team of three participants of strength 3, 2, 3 has a strength 3.\n\nFind the maximum possible sum of the strengths of N teams.\n\nConstraints\n\n1 ≤ N ≤ 10^5\n\n1 ≤ a_i ≤ 10^{9}\n\na_i are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\na_1 a_2 ... a_{3N}\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n2\n5 2 8 5 1 5\n\nSample Output 1\n\n10\n\nThe following is one formation of teams that maximizes the sum of the strengths of teams:\n\nTeam 1: consists of the first, fourth and fifth participants.\n\nTeam 2: consists of the second, third and sixth participants.\n\nSample Input 2\n\n10\n1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000\n\nSample Output 2\n\n10000000000\n\nThe sum of the strengths can be quite large.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 263, "cpu_time_ms": 198, "memory_kb": 6400}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s921722847", "group_id": "codeNet:p03768", "input_text": "let fst3 (a,b,c) = a\nlet () = Scanf.scanf \"%d %d\" @@ fun n m ->\n let es = Array.init m (fun _ -> Scanf.scanf \" %d %d\" @@ fun a b -> a-1, b-1) in\n Scanf.scanf \" %d\" @@ fun q ->\n\n let qa =\n let t = Array.init 11 (fun _ -> []) in\n for i = 0 to q-1 do\n Scanf.scanf \" %d %d %d\" @@ fun v d c ->\n t.(10-d) <- (i, v-1, c) :: t.(10-d)\n done;\n Array.map List.rev t\n in\n\n let cl = Array.make n (0, 0, 0) in\n qa.(0) |> List.iter (fun (i, v, c) -> cl.(v) <- i, c, 0);\n for r = 1 to 10 do\n Array.sort (fun (a,b) (c,d) ->\n min (fst3 cl.(a)) (fst3 cl.(b)) - min (fst3 cl.(c)) (fst3 cl.(d))) es;\n Array.iter (fun (u, v) ->\n let iu, cu, ru = cl.(u) in\n let iv, cv, rv = cl.(v) in\n if iu > iv && ru > -r then cl.(v) <- (iu, cu, ru-1);\n if iv > iu && rv > -r then cl.(u) <- (iv, cv, rv-1);\n ) es;\n qa.(r) |> List.iter (fun (i, v, c) -> cl.(v) <- max cl.(v) (i, c, -r));\n done;\n\n Array.iter (fun (_, c, _) -> Printf.printf \"%d\\n\" c) cl", "language": "OCaml", "metadata": {"date": 1534597757, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03768.html", "problem_id": "p03768", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03768/input.txt", "sample_output_relpath": "derived/input_output/data/p03768/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03768/OCaml/s921722847.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s921722847", "user_id": "u798181098"}, "prompt_components": {"gold_output": "2\n2\n2\n2\n2\n1\n0\n", "input_to_evaluate": "let fst3 (a,b,c) = a\nlet () = Scanf.scanf \"%d %d\" @@ fun n m ->\n let es = Array.init m (fun _ -> Scanf.scanf \" %d %d\" @@ fun a b -> a-1, b-1) in\n Scanf.scanf \" %d\" @@ fun q ->\n\n let qa =\n let t = Array.init 11 (fun _ -> []) in\n for i = 0 to q-1 do\n Scanf.scanf \" %d %d %d\" @@ fun v d c ->\n t.(10-d) <- (i, v-1, c) :: t.(10-d)\n done;\n Array.map List.rev t\n in\n\n let cl = Array.make n (0, 0, 0) in\n qa.(0) |> List.iter (fun (i, v, c) -> cl.(v) <- i, c, 0);\n for r = 1 to 10 do\n Array.sort (fun (a,b) (c,d) ->\n min (fst3 cl.(a)) (fst3 cl.(b)) - min (fst3 cl.(c)) (fst3 cl.(d))) es;\n Array.iter (fun (u, v) ->\n let iu, cu, ru = cl.(u) in\n let iv, cv, rv = cl.(v) in\n if iu > iv && ru > -r then cl.(v) <- (iu, cu, ru-1);\n if iv > iu && rv > -r then cl.(u) <- (iv, cv, rv-1);\n ) es;\n qa.(r) |> List.iter (fun (i, v, c) -> cl.(v) <- max cl.(v) (i, c, -r));\n done;\n\n Array.iter (fun (_, c, _) -> Printf.printf \"%d\\n\" c) cl", "problem_context": "Score : 700 points\n\nProblem Statement\n\nSquid loves painting vertices in graphs.\n\nThere is a simple undirected graph consisting of N vertices numbered 1 through N, and M edges.\nInitially, all the vertices are painted in color 0. The i-th edge bidirectionally connects two vertices a_i and b_i. The length of every edge is 1.\n\nSquid performed Q operations on this graph. In the i-th operation, he repaints all the vertices within a distance of d_i from vertex v_i, in color c_i.\n\nFind the color of each vertex after the Q operations.\n\nConstraints\n\n1 ≤ N,M,Q ≤ 10^5\n\n1 ≤ a_i,b_i,v_i ≤ N\n\na_i ≠ b_i\n\n0 ≤ d_i ≤ 10\n\n1 ≤ c_i ≤10^5\n\nd_i and c_i are all integers.\n\nThere are no self-loops or multiple edges in the given graph.\n\nPartial Score\n\n200 points will be awarded for passing the testset satisfying 1 ≤ N,M,Q ≤ 2{,}000.\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}\nQ\nv_1 d_1 c_1\n:\nv_{Q} d_{Q} c_{Q}\n\nOutput\n\nPrint the answer in N lines.\nIn the i-th line, print the color of vertex i after the Q operations.\n\nSample Input 1\n\n7 7\n1 2\n1 3\n1 4\n4 5\n5 6\n5 7\n2 3\n2\n6 1 1\n1 2 2\n\nSample Output 1\n\n2\n2\n2\n2\n2\n1\n0\n\nInitially, each vertex is painted in color 0.\nIn the first operation, vertices 5 and 6 are repainted in color 1.\nIn the second operation, vertices 1, 2, 3, 4 and 5 are repainted in color 2.\n\nSample Input 2\n\n14 10\n1 4\n5 7\n7 11\n4 10\n14 7\n14 3\n6 14\n8 11\n5 13\n8 3\n8\n8 6 2\n9 7 85\n6 9 3\n6 7 5\n10 3 1\n12 9 4\n9 6 6\n8 2 3\n\nSample Output 2\n\n1\n0\n3\n1\n5\n5\n3\n3\n6\n1\n3\n4\n5\n3\n\nThe given graph may not be connected.", "sample_input": "7 7\n1 2\n1 3\n1 4\n4 5\n5 6\n5 7\n2 3\n2\n6 1 1\n1 2 2\n"}, "reference_outputs": ["2\n2\n2\n2\n2\n1\n0\n"], "source_document_id": "p03768", "source_text": "Score : 700 points\n\nProblem Statement\n\nSquid loves painting vertices in graphs.\n\nThere is a simple undirected graph consisting of N vertices numbered 1 through N, and M edges.\nInitially, all the vertices are painted in color 0. The i-th edge bidirectionally connects two vertices a_i and b_i. The length of every edge is 1.\n\nSquid performed Q operations on this graph. In the i-th operation, he repaints all the vertices within a distance of d_i from vertex v_i, in color c_i.\n\nFind the color of each vertex after the Q operations.\n\nConstraints\n\n1 ≤ N,M,Q ≤ 10^5\n\n1 ≤ a_i,b_i,v_i ≤ N\n\na_i ≠ b_i\n\n0 ≤ d_i ≤ 10\n\n1 ≤ c_i ≤10^5\n\nd_i and c_i are all integers.\n\nThere are no self-loops or multiple edges in the given graph.\n\nPartial Score\n\n200 points will be awarded for passing the testset satisfying 1 ≤ N,M,Q ≤ 2{,}000.\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}\nQ\nv_1 d_1 c_1\n:\nv_{Q} d_{Q} c_{Q}\n\nOutput\n\nPrint the answer in N lines.\nIn the i-th line, print the color of vertex i after the Q operations.\n\nSample Input 1\n\n7 7\n1 2\n1 3\n1 4\n4 5\n5 6\n5 7\n2 3\n2\n6 1 1\n1 2 2\n\nSample Output 1\n\n2\n2\n2\n2\n2\n1\n0\n\nInitially, each vertex is painted in color 0.\nIn the first operation, vertices 5 and 6 are repainted in color 1.\nIn the second operation, vertices 1, 2, 3, 4 and 5 are repainted in color 2.\n\nSample Input 2\n\n14 10\n1 4\n5 7\n7 11\n4 10\n14 7\n14 3\n6 14\n8 11\n5 13\n8 3\n8\n8 6 2\n9 7 85\n6 9 3\n6 7 5\n10 3 1\n12 9 4\n9 6 6\n8 2 3\n\nSample Output 2\n\n1\n0\n3\n1\n5\n5\n3\n3\n6\n1\n3\n4\n5\n3\n\nThe given graph may not be connected.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 982, "cpu_time_ms": 1831, "memory_kb": 28416}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s632052216", "group_id": "codeNet:p03773", "input_text": "Scanf.scanf \"%d %d\" (fun a b -> print_int ((a + b) mod 24))\n", "language": "OCaml", "metadata": {"date": 1585933213, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03773.html", "problem_id": "p03773", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03773/input.txt", "sample_output_relpath": "derived/input_output/data/p03773/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03773/OCaml/s632052216.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s632052216", "user_id": "u752907799"}, "prompt_components": {"gold_output": "21\n", "input_to_evaluate": "Scanf.scanf \"%d %d\" (fun a b -> print_int ((a + b) mod 24))\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nDolphin loves programming contests. Today, he will take part in a contest in AtCoder.\n\nIn this country, 24-hour clock is used. For example, 9:00 p.m. is referred to as \"21 o'clock\".\n\nThe current time is A o'clock, and a contest will begin in exactly B hours.\nWhen will the contest begin? Answer in 24-hour time.\n\nConstraints\n\n0 \\leq A,B \\leq 23\n\nA and B are integers.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the hour of the starting time of the contest in 24-hour time.\n\nSample Input 1\n\n9 12\n\nSample Output 1\n\n21\n\nIn this input, the current time is 9 o'clock, and 12 hours later it will be 21 o'clock in 24-hour time.\n\nSample Input 2\n\n19 0\n\nSample Output 2\n\n19\n\nThe contest has just started.\n\nSample Input 3\n\n23 2\n\nSample Output 3\n\n1\n\nThe contest will begin at 1 o'clock the next day.", "sample_input": "9 12\n"}, "reference_outputs": ["21\n"], "source_document_id": "p03773", "source_text": "Score : 100 points\n\nProblem Statement\n\nDolphin loves programming contests. Today, he will take part in a contest in AtCoder.\n\nIn this country, 24-hour clock is used. For example, 9:00 p.m. is referred to as \"21 o'clock\".\n\nThe current time is A o'clock, and a contest will begin in exactly B hours.\nWhen will the contest begin? Answer in 24-hour time.\n\nConstraints\n\n0 \\leq A,B \\leq 23\n\nA and B are integers.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the hour of the starting time of the contest in 24-hour time.\n\nSample Input 1\n\n9 12\n\nSample Output 1\n\n21\n\nIn this input, the current time is 9 o'clock, and 12 hours later it will be 21 o'clock in 24-hour time.\n\nSample Input 2\n\n19 0\n\nSample Output 2\n\n19\n\nThe contest has just started.\n\nSample Input 3\n\n23 2\n\nSample Output 3\n\n1\n\nThe contest will begin at 1 o'clock the next day.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 2, "memory_kb": 4480}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s614763050", "group_id": "codeNet:p03773", "input_text": "Scanf.scanf \"%d %d\" @@ fun a b -> Printf.printf \"%d\\n\" @@ (a + b) mod 24", "language": "OCaml", "metadata": {"date": 1579035972, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03773.html", "problem_id": "p03773", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03773/input.txt", "sample_output_relpath": "derived/input_output/data/p03773/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03773/OCaml/s614763050.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s614763050", "user_id": "u732304692"}, "prompt_components": {"gold_output": "21\n", "input_to_evaluate": "Scanf.scanf \"%d %d\" @@ fun a b -> Printf.printf \"%d\\n\" @@ (a + b) mod 24", "problem_context": "Score : 100 points\n\nProblem Statement\n\nDolphin loves programming contests. Today, he will take part in a contest in AtCoder.\n\nIn this country, 24-hour clock is used. For example, 9:00 p.m. is referred to as \"21 o'clock\".\n\nThe current time is A o'clock, and a contest will begin in exactly B hours.\nWhen will the contest begin? Answer in 24-hour time.\n\nConstraints\n\n0 \\leq A,B \\leq 23\n\nA and B are integers.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the hour of the starting time of the contest in 24-hour time.\n\nSample Input 1\n\n9 12\n\nSample Output 1\n\n21\n\nIn this input, the current time is 9 o'clock, and 12 hours later it will be 21 o'clock in 24-hour time.\n\nSample Input 2\n\n19 0\n\nSample Output 2\n\n19\n\nThe contest has just started.\n\nSample Input 3\n\n23 2\n\nSample Output 3\n\n1\n\nThe contest will begin at 1 o'clock the next day.", "sample_input": "9 12\n"}, "reference_outputs": ["21\n"], "source_document_id": "p03773", "source_text": "Score : 100 points\n\nProblem Statement\n\nDolphin loves programming contests. Today, he will take part in a contest in AtCoder.\n\nIn this country, 24-hour clock is used. For example, 9:00 p.m. is referred to as \"21 o'clock\".\n\nThe current time is A o'clock, and a contest will begin in exactly B hours.\nWhen will the contest begin? Answer in 24-hour time.\n\nConstraints\n\n0 \\leq A,B \\leq 23\n\nA and B are integers.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the hour of the starting time of the contest in 24-hour time.\n\nSample Input 1\n\n9 12\n\nSample Output 1\n\n21\n\nIn this input, the current time is 9 o'clock, and 12 hours later it will be 21 o'clock in 24-hour time.\n\nSample Input 2\n\n19 0\n\nSample Output 2\n\n19\n\nThe contest has just started.\n\nSample Input 3\n\n23 2\n\nSample Output 3\n\n1\n\nThe contest will begin at 1 o'clock the next day.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s264875319", "group_id": "codeNet:p03773", "input_text": "let () = Scanf.scanf \"%d %d\" (fun a b -> (a+b) mod 24) |> Printf.printf \"%d\\n\"\n", "language": "OCaml", "metadata": {"date": 1519658435, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03773.html", "problem_id": "p03773", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03773/input.txt", "sample_output_relpath": "derived/input_output/data/p03773/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03773/OCaml/s264875319.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s264875319", "user_id": "u798181098"}, "prompt_components": {"gold_output": "21\n", "input_to_evaluate": "let () = Scanf.scanf \"%d %d\" (fun a b -> (a+b) mod 24) |> Printf.printf \"%d\\n\"\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nDolphin loves programming contests. Today, he will take part in a contest in AtCoder.\n\nIn this country, 24-hour clock is used. For example, 9:00 p.m. is referred to as \"21 o'clock\".\n\nThe current time is A o'clock, and a contest will begin in exactly B hours.\nWhen will the contest begin? Answer in 24-hour time.\n\nConstraints\n\n0 \\leq A,B \\leq 23\n\nA and B are integers.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the hour of the starting time of the contest in 24-hour time.\n\nSample Input 1\n\n9 12\n\nSample Output 1\n\n21\n\nIn this input, the current time is 9 o'clock, and 12 hours later it will be 21 o'clock in 24-hour time.\n\nSample Input 2\n\n19 0\n\nSample Output 2\n\n19\n\nThe contest has just started.\n\nSample Input 3\n\n23 2\n\nSample Output 3\n\n1\n\nThe contest will begin at 1 o'clock the next day.", "sample_input": "9 12\n"}, "reference_outputs": ["21\n"], "source_document_id": "p03773", "source_text": "Score : 100 points\n\nProblem Statement\n\nDolphin loves programming contests. Today, he will take part in a contest in AtCoder.\n\nIn this country, 24-hour clock is used. For example, 9:00 p.m. is referred to as \"21 o'clock\".\n\nThe current time is A o'clock, and a contest will begin in exactly B hours.\nWhen will the contest begin? Answer in 24-hour time.\n\nConstraints\n\n0 \\leq A,B \\leq 23\n\nA and B are integers.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nA B\n\nOutput\n\nPrint the hour of the starting time of the contest in 24-hour time.\n\nSample Input 1\n\n9 12\n\nSample Output 1\n\n21\n\nIn this input, the current time is 9 o'clock, and 12 hours later it will be 21 o'clock in 24-hour time.\n\nSample Input 2\n\n19 0\n\nSample Output 2\n\n19\n\nThe contest has just started.\n\nSample Input 3\n\n23 2\n\nSample Output 3\n\n1\n\nThe contest will begin at 1 o'clock the next day.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s018323825", "group_id": "codeNet:p03774", "input_text": "Scanf.scanf \"%d %d\" (fun n m ->\n let ab = Array.init n (fun _ -> Scanf.scanf \" %d %d\" (fun a b -> a, b)) in\n let cd = Array.init m (fun _ -> Scanf.scanf \" %d %d\" (fun a b -> a, b)) in\n for i = 0 to n - 1 do\n let x, y = ab.(i) in\n let rec loop j mip mid =\n if j = m then mip else\n let w, h = cd.(j) in\n let d = abs (x - w) + abs (y - h) in\n if d < mid then loop (j + 1) (j + 1) d\n else loop (j + 1) mip mid\n in\n Printf.printf \"%d\\n\" @@ loop 0 0 max_int\n done\n)", "language": "OCaml", "metadata": {"date": 1591582487, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03774.html", "problem_id": "p03774", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03774/input.txt", "sample_output_relpath": "derived/input_output/data/p03774/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03774/OCaml/s018323825.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s018323825", "user_id": "u342443598"}, "prompt_components": {"gold_output": "2\n1\n", "input_to_evaluate": "Scanf.scanf \"%d %d\" (fun n m ->\n let ab = Array.init n (fun _ -> Scanf.scanf \" %d %d\" (fun a b -> a, b)) in\n let cd = Array.init m (fun _ -> Scanf.scanf \" %d %d\" (fun a b -> a, b)) in\n for i = 0 to n - 1 do\n let x, y = ab.(i) in\n let rec loop j mip mid =\n if j = m then mip else\n let w, h = cd.(j) in\n let d = abs (x - w) + abs (y - h) in\n if d < mid then loop (j + 1) (j + 1) d\n else loop (j + 1) mip mid\n in\n Printf.printf \"%d\\n\" @@ loop 0 0 max_int\n done\n)", "problem_context": "Score : 200 points\n\nProblem Statement\n\nThere are N students and M checkpoints on the xy-plane.\n\nThe coordinates of the i-th student (1 \\leq i \\leq N) is (a_i,b_i), and the coordinates of the checkpoint numbered j (1 \\leq j \\leq M) is (c_j,d_j).\n\nWhen the teacher gives a signal, each student has to go to the nearest checkpoint measured in Manhattan distance.\n\nThe Manhattan distance between two points (x_1,y_1) and (x_2,y_2) is |x_1-x_2|+|y_1-y_2|.\n\nHere, |x| denotes the absolute value of x.\n\nIf there are multiple nearest checkpoints for a student, he/she will select the checkpoint with the smallest index.\n\nWhich checkpoint will each student go to?\n\nConstraints\n\n1 \\leq N,M \\leq 50\n\n-10^8 \\leq a_i,b_i,c_j,d_j \\leq 10^8\n\nAll input values are integers.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN M\na_1 b_1\n:\na_N b_N\nc_1 d_1\n:\nc_M d_M\n\nOutput\n\nPrint N lines.\n\nThe i-th line (1 \\leq i \\leq N) should contain the index of the checkpoint for the i-th student to go.\n\nSample Input 1\n\n2 2\n2 0\n0 0\n-1 0\n1 0\n\nSample Output 1\n\n2\n1\n\nThe Manhattan distance between the first student and each checkpoint is:\n\nFor checkpoint 1: |2-(-1)|+|0-0|=3\n\nFor checkpoint 2: |2-1|+|0-0|=1\n\nThe nearest checkpoint is checkpoint 2. Thus, the first line in the output should contain 2.\n\nThe Manhattan distance between the second student and each checkpoint is:\n\nFor checkpoint 1: |0-(-1)|+|0-0|=1\n\nFor checkpoint 2: |0-1|+|0-0|=1\n\nWhen there are multiple nearest checkpoints, the student will go to the checkpoint with the smallest index. Thus, the second line in the output should contain 1.\n\nSample Input 2\n\n3 4\n10 10\n-10 -10\n3 3\n1 2\n2 3\n3 5\n3 5\n\nSample Output 2\n\n3\n1\n2\n\nThere can be multiple checkpoints at the same coordinates.\n\nSample Input 3\n\n5 5\n-100000000 -100000000\n-100000000 100000000\n100000000 -100000000\n100000000 100000000\n0 0\n0 0\n100000000 100000000\n100000000 -100000000\n-100000000 100000000\n-100000000 -100000000\n\nSample Output 3\n\n5\n4\n3\n2\n1", "sample_input": "2 2\n2 0\n0 0\n-1 0\n1 0\n"}, "reference_outputs": ["2\n1\n"], "source_document_id": "p03774", "source_text": "Score : 200 points\n\nProblem Statement\n\nThere are N students and M checkpoints on the xy-plane.\n\nThe coordinates of the i-th student (1 \\leq i \\leq N) is (a_i,b_i), and the coordinates of the checkpoint numbered j (1 \\leq j \\leq M) is (c_j,d_j).\n\nWhen the teacher gives a signal, each student has to go to the nearest checkpoint measured in Manhattan distance.\n\nThe Manhattan distance between two points (x_1,y_1) and (x_2,y_2) is |x_1-x_2|+|y_1-y_2|.\n\nHere, |x| denotes the absolute value of x.\n\nIf there are multiple nearest checkpoints for a student, he/she will select the checkpoint with the smallest index.\n\nWhich checkpoint will each student go to?\n\nConstraints\n\n1 \\leq N,M \\leq 50\n\n-10^8 \\leq a_i,b_i,c_j,d_j \\leq 10^8\n\nAll input values are integers.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN M\na_1 b_1\n:\na_N b_N\nc_1 d_1\n:\nc_M d_M\n\nOutput\n\nPrint N lines.\n\nThe i-th line (1 \\leq i \\leq N) should contain the index of the checkpoint for the i-th student to go.\n\nSample Input 1\n\n2 2\n2 0\n0 0\n-1 0\n1 0\n\nSample Output 1\n\n2\n1\n\nThe Manhattan distance between the first student and each checkpoint is:\n\nFor checkpoint 1: |2-(-1)|+|0-0|=3\n\nFor checkpoint 2: |2-1|+|0-0|=1\n\nThe nearest checkpoint is checkpoint 2. Thus, the first line in the output should contain 2.\n\nThe Manhattan distance between the second student and each checkpoint is:\n\nFor checkpoint 1: |0-(-1)|+|0-0|=1\n\nFor checkpoint 2: |0-1|+|0-0|=1\n\nWhen there are multiple nearest checkpoints, the student will go to the checkpoint with the smallest index. Thus, the second line in the output should contain 1.\n\nSample Input 2\n\n3 4\n10 10\n-10 -10\n3 3\n1 2\n2 3\n3 5\n3 5\n\nSample Output 2\n\n3\n1\n2\n\nThere can be multiple checkpoints at the same coordinates.\n\nSample Input 3\n\n5 5\n-100000000 -100000000\n-100000000 100000000\n100000000 -100000000\n100000000 100000000\n0 0\n0 0\n100000000 100000000\n100000000 -100000000\n-100000000 100000000\n-100000000 -100000000\n\nSample Output 3\n\n5\n4\n3\n2\n1", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s695799640", "group_id": "codeNet:p03774", "input_text": "let () = Scanf.scanf \"%d %d\\n\" @@ fun n m ->\n let abs_ = Array.init n @@ fun _ -> Scanf.scanf \"%d %d\\n\" @@ fun a b -> a, b in\n let cds = Array.init m @@ fun _ -> Scanf.scanf \"%d %d\\n\" @@ fun c d -> c, d in\n Array.iter (fun (a, b) ->\n Array.init m (fun i -> i)\n |> Array.fold_left (fun j i ->\n if abs (a - fst cds.(i)) + abs (b - snd cds.(i)) < abs (a - fst cds.(j)) + abs (b - snd cds.(j)) then i\n else j) 0\n |> ( + ) 1\n |> Printf.printf \"%d\\n\") abs_\n", "language": "OCaml", "metadata": {"date": 1530682291, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03774.html", "problem_id": "p03774", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03774/input.txt", "sample_output_relpath": "derived/input_output/data/p03774/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03774/OCaml/s695799640.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s695799640", "user_id": "u504158101"}, "prompt_components": {"gold_output": "2\n1\n", "input_to_evaluate": "let () = Scanf.scanf \"%d %d\\n\" @@ fun n m ->\n let abs_ = Array.init n @@ fun _ -> Scanf.scanf \"%d %d\\n\" @@ fun a b -> a, b in\n let cds = Array.init m @@ fun _ -> Scanf.scanf \"%d %d\\n\" @@ fun c d -> c, d in\n Array.iter (fun (a, b) ->\n Array.init m (fun i -> i)\n |> Array.fold_left (fun j i ->\n if abs (a - fst cds.(i)) + abs (b - snd cds.(i)) < abs (a - fst cds.(j)) + abs (b - snd cds.(j)) then i\n else j) 0\n |> ( + ) 1\n |> Printf.printf \"%d\\n\") abs_\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nThere are N students and M checkpoints on the xy-plane.\n\nThe coordinates of the i-th student (1 \\leq i \\leq N) is (a_i,b_i), and the coordinates of the checkpoint numbered j (1 \\leq j \\leq M) is (c_j,d_j).\n\nWhen the teacher gives a signal, each student has to go to the nearest checkpoint measured in Manhattan distance.\n\nThe Manhattan distance between two points (x_1,y_1) and (x_2,y_2) is |x_1-x_2|+|y_1-y_2|.\n\nHere, |x| denotes the absolute value of x.\n\nIf there are multiple nearest checkpoints for a student, he/she will select the checkpoint with the smallest index.\n\nWhich checkpoint will each student go to?\n\nConstraints\n\n1 \\leq N,M \\leq 50\n\n-10^8 \\leq a_i,b_i,c_j,d_j \\leq 10^8\n\nAll input values are integers.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN M\na_1 b_1\n:\na_N b_N\nc_1 d_1\n:\nc_M d_M\n\nOutput\n\nPrint N lines.\n\nThe i-th line (1 \\leq i \\leq N) should contain the index of the checkpoint for the i-th student to go.\n\nSample Input 1\n\n2 2\n2 0\n0 0\n-1 0\n1 0\n\nSample Output 1\n\n2\n1\n\nThe Manhattan distance between the first student and each checkpoint is:\n\nFor checkpoint 1: |2-(-1)|+|0-0|=3\n\nFor checkpoint 2: |2-1|+|0-0|=1\n\nThe nearest checkpoint is checkpoint 2. Thus, the first line in the output should contain 2.\n\nThe Manhattan distance between the second student and each checkpoint is:\n\nFor checkpoint 1: |0-(-1)|+|0-0|=1\n\nFor checkpoint 2: |0-1|+|0-0|=1\n\nWhen there are multiple nearest checkpoints, the student will go to the checkpoint with the smallest index. Thus, the second line in the output should contain 1.\n\nSample Input 2\n\n3 4\n10 10\n-10 -10\n3 3\n1 2\n2 3\n3 5\n3 5\n\nSample Output 2\n\n3\n1\n2\n\nThere can be multiple checkpoints at the same coordinates.\n\nSample Input 3\n\n5 5\n-100000000 -100000000\n-100000000 100000000\n100000000 -100000000\n100000000 100000000\n0 0\n0 0\n100000000 100000000\n100000000 -100000000\n-100000000 100000000\n-100000000 -100000000\n\nSample Output 3\n\n5\n4\n3\n2\n1", "sample_input": "2 2\n2 0\n0 0\n-1 0\n1 0\n"}, "reference_outputs": ["2\n1\n"], "source_document_id": "p03774", "source_text": "Score : 200 points\n\nProblem Statement\n\nThere are N students and M checkpoints on the xy-plane.\n\nThe coordinates of the i-th student (1 \\leq i \\leq N) is (a_i,b_i), and the coordinates of the checkpoint numbered j (1 \\leq j \\leq M) is (c_j,d_j).\n\nWhen the teacher gives a signal, each student has to go to the nearest checkpoint measured in Manhattan distance.\n\nThe Manhattan distance between two points (x_1,y_1) and (x_2,y_2) is |x_1-x_2|+|y_1-y_2|.\n\nHere, |x| denotes the absolute value of x.\n\nIf there are multiple nearest checkpoints for a student, he/she will select the checkpoint with the smallest index.\n\nWhich checkpoint will each student go to?\n\nConstraints\n\n1 \\leq N,M \\leq 50\n\n-10^8 \\leq a_i,b_i,c_j,d_j \\leq 10^8\n\nAll input values are integers.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN M\na_1 b_1\n:\na_N b_N\nc_1 d_1\n:\nc_M d_M\n\nOutput\n\nPrint N lines.\n\nThe i-th line (1 \\leq i \\leq N) should contain the index of the checkpoint for the i-th student to go.\n\nSample Input 1\n\n2 2\n2 0\n0 0\n-1 0\n1 0\n\nSample Output 1\n\n2\n1\n\nThe Manhattan distance between the first student and each checkpoint is:\n\nFor checkpoint 1: |2-(-1)|+|0-0|=3\n\nFor checkpoint 2: |2-1|+|0-0|=1\n\nThe nearest checkpoint is checkpoint 2. Thus, the first line in the output should contain 2.\n\nThe Manhattan distance between the second student and each checkpoint is:\n\nFor checkpoint 1: |0-(-1)|+|0-0|=1\n\nFor checkpoint 2: |0-1|+|0-0|=1\n\nWhen there are multiple nearest checkpoints, the student will go to the checkpoint with the smallest index. Thus, the second line in the output should contain 1.\n\nSample Input 2\n\n3 4\n10 10\n-10 -10\n3 3\n1 2\n2 3\n3 5\n3 5\n\nSample Output 2\n\n3\n1\n2\n\nThere can be multiple checkpoints at the same coordinates.\n\nSample Input 3\n\n5 5\n-100000000 -100000000\n-100000000 100000000\n100000000 -100000000\n100000000 100000000\n0 0\n0 0\n100000000 100000000\n100000000 -100000000\n-100000000 100000000\n-100000000 -100000000\n\nSample Output 3\n\n5\n4\n3\n2\n1", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 480, "cpu_time_ms": 1, "memory_kb": 512}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s967528330", "group_id": "codeNet:p03774", "input_text": "let dist a b c d = abs(a-c)+abs(b-d) in\nScanf.scanf \"%d %d \" @@ fun n m ->\n let a = Array.make n 0 in\n let b = Array.make n 0 in\n for i=0 to n-1 do\n Scanf.scanf \"%d %d \" @@ fun ai bi ->\n a.(i) <- ai;\n b.(i) <- bi\n done;\n let c = Array.make m 0 in\n let d = Array.make m 0 in\n for j=0 to m-1 do\n Scanf.scanf \"%d %d \" @@ fun cj dj ->\n c.(j) <- cj;\n d.(j) <- dj\n done;\n for i=0 to n-1 do\n let min = ref max_int in \n let index = ref 0 in\n for j=0 to m-1 do\n let distance = dist a.(i) b.(i) c.(j) d.(j) in \n if !min > distance then (\n min := distance; index := j\n )\n done;\n Printf.printf \"%d\\n\" (!index+1)\n done\n", "language": "OCaml", "metadata": {"date": 1491100005, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03774.html", "problem_id": "p03774", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03774/input.txt", "sample_output_relpath": "derived/input_output/data/p03774/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03774/OCaml/s967528330.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s967528330", "user_id": "u231540466"}, "prompt_components": {"gold_output": "2\n1\n", "input_to_evaluate": "let dist a b c d = abs(a-c)+abs(b-d) in\nScanf.scanf \"%d %d \" @@ fun n m ->\n let a = Array.make n 0 in\n let b = Array.make n 0 in\n for i=0 to n-1 do\n Scanf.scanf \"%d %d \" @@ fun ai bi ->\n a.(i) <- ai;\n b.(i) <- bi\n done;\n let c = Array.make m 0 in\n let d = Array.make m 0 in\n for j=0 to m-1 do\n Scanf.scanf \"%d %d \" @@ fun cj dj ->\n c.(j) <- cj;\n d.(j) <- dj\n done;\n for i=0 to n-1 do\n let min = ref max_int in \n let index = ref 0 in\n for j=0 to m-1 do\n let distance = dist a.(i) b.(i) c.(j) d.(j) in \n if !min > distance then (\n min := distance; index := j\n )\n done;\n Printf.printf \"%d\\n\" (!index+1)\n done\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nThere are N students and M checkpoints on the xy-plane.\n\nThe coordinates of the i-th student (1 \\leq i \\leq N) is (a_i,b_i), and the coordinates of the checkpoint numbered j (1 \\leq j \\leq M) is (c_j,d_j).\n\nWhen the teacher gives a signal, each student has to go to the nearest checkpoint measured in Manhattan distance.\n\nThe Manhattan distance between two points (x_1,y_1) and (x_2,y_2) is |x_1-x_2|+|y_1-y_2|.\n\nHere, |x| denotes the absolute value of x.\n\nIf there are multiple nearest checkpoints for a student, he/she will select the checkpoint with the smallest index.\n\nWhich checkpoint will each student go to?\n\nConstraints\n\n1 \\leq N,M \\leq 50\n\n-10^8 \\leq a_i,b_i,c_j,d_j \\leq 10^8\n\nAll input values are integers.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN M\na_1 b_1\n:\na_N b_N\nc_1 d_1\n:\nc_M d_M\n\nOutput\n\nPrint N lines.\n\nThe i-th line (1 \\leq i \\leq N) should contain the index of the checkpoint for the i-th student to go.\n\nSample Input 1\n\n2 2\n2 0\n0 0\n-1 0\n1 0\n\nSample Output 1\n\n2\n1\n\nThe Manhattan distance between the first student and each checkpoint is:\n\nFor checkpoint 1: |2-(-1)|+|0-0|=3\n\nFor checkpoint 2: |2-1|+|0-0|=1\n\nThe nearest checkpoint is checkpoint 2. Thus, the first line in the output should contain 2.\n\nThe Manhattan distance between the second student and each checkpoint is:\n\nFor checkpoint 1: |0-(-1)|+|0-0|=1\n\nFor checkpoint 2: |0-1|+|0-0|=1\n\nWhen there are multiple nearest checkpoints, the student will go to the checkpoint with the smallest index. Thus, the second line in the output should contain 1.\n\nSample Input 2\n\n3 4\n10 10\n-10 -10\n3 3\n1 2\n2 3\n3 5\n3 5\n\nSample Output 2\n\n3\n1\n2\n\nThere can be multiple checkpoints at the same coordinates.\n\nSample Input 3\n\n5 5\n-100000000 -100000000\n-100000000 100000000\n100000000 -100000000\n100000000 100000000\n0 0\n0 0\n100000000 100000000\n100000000 -100000000\n-100000000 100000000\n-100000000 -100000000\n\nSample Output 3\n\n5\n4\n3\n2\n1", "sample_input": "2 2\n2 0\n0 0\n-1 0\n1 0\n"}, "reference_outputs": ["2\n1\n"], "source_document_id": "p03774", "source_text": "Score : 200 points\n\nProblem Statement\n\nThere are N students and M checkpoints on the xy-plane.\n\nThe coordinates of the i-th student (1 \\leq i \\leq N) is (a_i,b_i), and the coordinates of the checkpoint numbered j (1 \\leq j \\leq M) is (c_j,d_j).\n\nWhen the teacher gives a signal, each student has to go to the nearest checkpoint measured in Manhattan distance.\n\nThe Manhattan distance between two points (x_1,y_1) and (x_2,y_2) is |x_1-x_2|+|y_1-y_2|.\n\nHere, |x| denotes the absolute value of x.\n\nIf there are multiple nearest checkpoints for a student, he/she will select the checkpoint with the smallest index.\n\nWhich checkpoint will each student go to?\n\nConstraints\n\n1 \\leq N,M \\leq 50\n\n-10^8 \\leq a_i,b_i,c_j,d_j \\leq 10^8\n\nAll input values are integers.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN M\na_1 b_1\n:\na_N b_N\nc_1 d_1\n:\nc_M d_M\n\nOutput\n\nPrint N lines.\n\nThe i-th line (1 \\leq i \\leq N) should contain the index of the checkpoint for the i-th student to go.\n\nSample Input 1\n\n2 2\n2 0\n0 0\n-1 0\n1 0\n\nSample Output 1\n\n2\n1\n\nThe Manhattan distance between the first student and each checkpoint is:\n\nFor checkpoint 1: |2-(-1)|+|0-0|=3\n\nFor checkpoint 2: |2-1|+|0-0|=1\n\nThe nearest checkpoint is checkpoint 2. Thus, the first line in the output should contain 2.\n\nThe Manhattan distance between the second student and each checkpoint is:\n\nFor checkpoint 1: |0-(-1)|+|0-0|=1\n\nFor checkpoint 2: |0-1|+|0-0|=1\n\nWhen there are multiple nearest checkpoints, the student will go to the checkpoint with the smallest index. Thus, the second line in the output should contain 1.\n\nSample Input 2\n\n3 4\n10 10\n-10 -10\n3 3\n1 2\n2 3\n3 5\n3 5\n\nSample Output 2\n\n3\n1\n2\n\nThere can be multiple checkpoints at the same coordinates.\n\nSample Input 3\n\n5 5\n-100000000 -100000000\n-100000000 100000000\n100000000 -100000000\n100000000 100000000\n0 0\n0 0\n100000000 100000000\n100000000 -100000000\n-100000000 100000000\n-100000000 -100000000\n\nSample Output 3\n\n5\n4\n3\n2\n1", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 679, "cpu_time_ms": 1, "memory_kb": 512}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s651140255", "group_id": "codeNet:p03775", "input_text": "let () = Scanf.scanf \"%d\" @@ fun n ->\n Array.init (int_of_float (ceil @@ sqrt @@ float_of_int n)) (fun a ->\n if n mod (a + 1) = 0 then max (a + 1) (n / (a + 1))\n else max_int)\n |> Array.fold_left min max_int\n |> (fun a -> Printf.printf \"%d\\n\" @@ succ @@ int_of_float @@ log (float_of_int a) /. log 10.)\n", "language": "OCaml", "metadata": {"date": 1530759847, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03775.html", "problem_id": "p03775", "resource_group": "low_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/OCaml/s651140255.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s651140255", "user_id": "u504158101"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "let () = Scanf.scanf \"%d\" @@ fun n ->\n Array.init (int_of_float (ceil @@ sqrt @@ float_of_int n)) (fun a ->\n if n mod (a + 1) = 0 then max (a + 1) (n / (a + 1))\n else max_int)\n |> Array.fold_left min max_int\n |> (fun a -> Printf.printf \"%d\\n\" @@ succ @@ int_of_float @@ log (float_of_int a) /. log 10.)\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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 312, "cpu_time_ms": 5, "memory_kb": 2944}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s968307171", "group_id": "codeNet:p03776", "input_text": "let dp = Array.make_matrix (50 + 1) (50 + 1) ~-1\nlet rec c n k = if dp.(n).(k) > -1 then dp.(n).(k) else (dp.(n).(k) <- if n < k then 0 else if n = k then 1 else if k = 0 then 1 else c (n - 1) (k - 1) + c (n - 1) k; dp.(n).(k))\nlet n, a, b = Scanf.scanf \" %d %d %d\" @@ fun a b c -> a, b - 1, c - 1\nlet vs = Array.init n @@ fun _ -> Scanf.scanf \" %d\" (+) 0\nlet m = Array.(sort (fun x y -> y - x) vs; vs.(0))\nlet k = ref (b + 1)\nlet f = Array.fold_left (fun c v -> if v = vs.(!k) then c + 1 else c) 0\nlet _ = Array.(iteri (fun i v -> if a <= i && i < !k && v < m then k := i) vs; if a < !k then decr k; let t = f vs in\n Printf.printf \"%.6f\\n%d\\n\" (float (sub vs 0 (!k + 1) |> fold_left (+) 0) /. (float !k +. 1.)) @@ if vs.(!k) = m then let s = ref 0 in for i = a + 1 to b + 1 do s := !s + c t i done; !s else c t (f (sub vs 0 (!k + 1))))", "language": "OCaml", "metadata": {"date": 1583417078, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03776.html", "problem_id": "p03776", "resource_group": "low_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/OCaml/s968307171.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s968307171", "user_id": "u732304692"}, "prompt_components": {"gold_output": "4.500000\n1\n", "input_to_evaluate": "let dp = Array.make_matrix (50 + 1) (50 + 1) ~-1\nlet rec c n k = if dp.(n).(k) > -1 then dp.(n).(k) else (dp.(n).(k) <- if n < k then 0 else if n = k then 1 else if k = 0 then 1 else c (n - 1) (k - 1) + c (n - 1) k; dp.(n).(k))\nlet n, a, b = Scanf.scanf \" %d %d %d\" @@ fun a b c -> a, b - 1, c - 1\nlet vs = Array.init n @@ fun _ -> Scanf.scanf \" %d\" (+) 0\nlet m = Array.(sort (fun x y -> y - x) vs; vs.(0))\nlet k = ref (b + 1)\nlet f = Array.fold_left (fun c v -> if v = vs.(!k) then c + 1 else c) 0\nlet _ = Array.(iteri (fun i v -> if a <= i && i < !k && v < m then k := i) vs; if a < !k then decr k; let t = f vs in\n Printf.printf \"%.6f\\n%d\\n\" (float (sub vs 0 (!k + 1) |> fold_left (+) 0) /. (float !k +. 1.)) @@ if vs.(!k) = m then let s = ref 0 in for i = a + 1 to b + 1 do s := !s + c t i done; !s else c t (f (sub vs 0 (!k + 1))))", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 837, "cpu_time_ms": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s346829893", "group_id": "codeNet:p03777", "input_text": "let id x = x\nlet (a,b) = Scanf.scanf \"%c %c\" (fun a b -> (a,b))\n\nlet not_b = if b = 'H' then 'D' else 'H'\n\nlet ans = if a = 'H' then b else not_b\n\nlet () = Printf.printf \"%c\\n\" ans", "language": "OCaml", "metadata": {"date": 1489885636, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03777.html", "problem_id": "p03777", "resource_group": "low_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/OCaml/s346829893.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s346829893", "user_id": "u735499035"}, "prompt_components": {"gold_output": "H\n", "input_to_evaluate": "let id x = x\nlet (a,b) = Scanf.scanf \"%c %c\" (fun a b -> (a,b))\n\nlet not_b = if b = 'H' then 'D' else 'H'\n\nlet ans = if a = 'H' then b else not_b\n\nlet () = Printf.printf \"%c\\n\" ans", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s910306121", "group_id": "codeNet:p03778", "input_text": "Scanf.scanf \"%d %d %d\" (fun w a b -> print_int (max 0 (abs (a - b) - w)))", "language": "OCaml", "metadata": {"date": 1585892247, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03778.html", "problem_id": "p03778", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03778/input.txt", "sample_output_relpath": "derived/input_output/data/p03778/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03778/OCaml/s910306121.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s910306121", "user_id": "u752907799"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "Scanf.scanf \"%d %d %d\" (fun w a b -> print_int (max 0 (abs (a - b) - w)))", "problem_context": "Score : 200 points\n\nProblem Statement\n\nAtCoDeer the deer found two rectangles lying on the table, each with height 1 and width W.\nIf we consider the surface of the desk as a two-dimensional plane, the first rectangle covers the vertical range of [0,1] and the horizontal range of [a,a+W], and the second rectangle covers the vertical range of [1,2] and the horizontal range of [b,b+W], as shown in the following figure:\n\nAtCoDeer will move the second rectangle horizontally so that it connects with the first rectangle.\nFind the minimum distance it needs to be moved.\n\nConstraints\n\nAll input values are integers.\n\n1≤W≤10^5\n\n1≤a,b≤10^5\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nW a b\n\nOutput\n\nPrint the minimum distance the second rectangle needs to be moved.\n\nSample Input 1\n\n3 2 6\n\nSample Output 1\n\n1\n\nThis input corresponds to the figure in the statement. In this case, the second rectangle should be moved to the left by a distance of 1.\n\nSample Input 2\n\n3 1 3\n\nSample Output 2\n\n0\n\nThe rectangles are already connected, and thus no move is needed.\n\nSample Input 3\n\n5 10 1\n\nSample Output 3\n\n4", "sample_input": "3 2 6\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03778", "source_text": "Score : 200 points\n\nProblem Statement\n\nAtCoDeer the deer found two rectangles lying on the table, each with height 1 and width W.\nIf we consider the surface of the desk as a two-dimensional plane, the first rectangle covers the vertical range of [0,1] and the horizontal range of [a,a+W], and the second rectangle covers the vertical range of [1,2] and the horizontal range of [b,b+W], as shown in the following figure:\n\nAtCoDeer will move the second rectangle horizontally so that it connects with the first rectangle.\nFind the minimum distance it needs to be moved.\n\nConstraints\n\nAll input values are integers.\n\n1≤W≤10^5\n\n1≤a,b≤10^5\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nW a b\n\nOutput\n\nPrint the minimum distance the second rectangle needs to be moved.\n\nSample Input 1\n\n3 2 6\n\nSample Output 1\n\n1\n\nThis input corresponds to the figure in the statement. In this case, the second rectangle should be moved to the left by a distance of 1.\n\nSample Input 2\n\n3 1 3\n\nSample Output 2\n\n0\n\nThe rectangles are already connected, and thus no move is needed.\n\nSample Input 3\n\n5 10 1\n\nSample Output 3\n\n4", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s211707560", "group_id": "codeNet:p03778", "input_text": "Scanf.scanf \"%d %d %d\" @@ fun w a b -> Printf.printf \"%d\\n\" @@ max 0 @@ -w + if a <= b then b - a else a - b", "language": "OCaml", "metadata": {"date": 1578138782, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03778.html", "problem_id": "p03778", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03778/input.txt", "sample_output_relpath": "derived/input_output/data/p03778/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03778/OCaml/s211707560.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s211707560", "user_id": "u732304692"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "Scanf.scanf \"%d %d %d\" @@ fun w a b -> Printf.printf \"%d\\n\" @@ max 0 @@ -w + if a <= b then b - a else a - b", "problem_context": "Score : 200 points\n\nProblem Statement\n\nAtCoDeer the deer found two rectangles lying on the table, each with height 1 and width W.\nIf we consider the surface of the desk as a two-dimensional plane, the first rectangle covers the vertical range of [0,1] and the horizontal range of [a,a+W], and the second rectangle covers the vertical range of [1,2] and the horizontal range of [b,b+W], as shown in the following figure:\n\nAtCoDeer will move the second rectangle horizontally so that it connects with the first rectangle.\nFind the minimum distance it needs to be moved.\n\nConstraints\n\nAll input values are integers.\n\n1≤W≤10^5\n\n1≤a,b≤10^5\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nW a b\n\nOutput\n\nPrint the minimum distance the second rectangle needs to be moved.\n\nSample Input 1\n\n3 2 6\n\nSample Output 1\n\n1\n\nThis input corresponds to the figure in the statement. In this case, the second rectangle should be moved to the left by a distance of 1.\n\nSample Input 2\n\n3 1 3\n\nSample Output 2\n\n0\n\nThe rectangles are already connected, and thus no move is needed.\n\nSample Input 3\n\n5 10 1\n\nSample Output 3\n\n4", "sample_input": "3 2 6\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03778", "source_text": "Score : 200 points\n\nProblem Statement\n\nAtCoDeer the deer found two rectangles lying on the table, each with height 1 and width W.\nIf we consider the surface of the desk as a two-dimensional plane, the first rectangle covers the vertical range of [0,1] and the horizontal range of [a,a+W], and the second rectangle covers the vertical range of [1,2] and the horizontal range of [b,b+W], as shown in the following figure:\n\nAtCoDeer will move the second rectangle horizontally so that it connects with the first rectangle.\nFind the minimum distance it needs to be moved.\n\nConstraints\n\nAll input values are integers.\n\n1≤W≤10^5\n\n1≤a,b≤10^5\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nW a b\n\nOutput\n\nPrint the minimum distance the second rectangle needs to be moved.\n\nSample Input 1\n\n3 2 6\n\nSample Output 1\n\n1\n\nThis input corresponds to the figure in the statement. In this case, the second rectangle should be moved to the left by a distance of 1.\n\nSample Input 2\n\n3 1 3\n\nSample Output 2\n\n0\n\nThe rectangles are already connected, and thus no move is needed.\n\nSample Input 3\n\n5 10 1\n\nSample Output 3\n\n4", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s719883831", "group_id": "codeNet:p03778", "input_text": "Scanf.scanf\"%d %d %d\"@@fun w a b->print_int@@max(abs(a-b)-w)0", "language": "OCaml", "metadata": {"date": 1540428482, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03778.html", "problem_id": "p03778", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03778/input.txt", "sample_output_relpath": "derived/input_output/data/p03778/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03778/OCaml/s719883831.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s719883831", "user_id": "u481480055"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "Scanf.scanf\"%d %d %d\"@@fun w a b->print_int@@max(abs(a-b)-w)0", "problem_context": "Score : 200 points\n\nProblem Statement\n\nAtCoDeer the deer found two rectangles lying on the table, each with height 1 and width W.\nIf we consider the surface of the desk as a two-dimensional plane, the first rectangle covers the vertical range of [0,1] and the horizontal range of [a,a+W], and the second rectangle covers the vertical range of [1,2] and the horizontal range of [b,b+W], as shown in the following figure:\n\nAtCoDeer will move the second rectangle horizontally so that it connects with the first rectangle.\nFind the minimum distance it needs to be moved.\n\nConstraints\n\nAll input values are integers.\n\n1≤W≤10^5\n\n1≤a,b≤10^5\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nW a b\n\nOutput\n\nPrint the minimum distance the second rectangle needs to be moved.\n\nSample Input 1\n\n3 2 6\n\nSample Output 1\n\n1\n\nThis input corresponds to the figure in the statement. In this case, the second rectangle should be moved to the left by a distance of 1.\n\nSample Input 2\n\n3 1 3\n\nSample Output 2\n\n0\n\nThe rectangles are already connected, and thus no move is needed.\n\nSample Input 3\n\n5 10 1\n\nSample Output 3\n\n4", "sample_input": "3 2 6\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03778", "source_text": "Score : 200 points\n\nProblem Statement\n\nAtCoDeer the deer found two rectangles lying on the table, each with height 1 and width W.\nIf we consider the surface of the desk as a two-dimensional plane, the first rectangle covers the vertical range of [0,1] and the horizontal range of [a,a+W], and the second rectangle covers the vertical range of [1,2] and the horizontal range of [b,b+W], as shown in the following figure:\n\nAtCoDeer will move the second rectangle horizontally so that it connects with the first rectangle.\nFind the minimum distance it needs to be moved.\n\nConstraints\n\nAll input values are integers.\n\n1≤W≤10^5\n\n1≤a,b≤10^5\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nW a b\n\nOutput\n\nPrint the minimum distance the second rectangle needs to be moved.\n\nSample Input 1\n\n3 2 6\n\nSample Output 1\n\n1\n\nThis input corresponds to the figure in the statement. In this case, the second rectangle should be moved to the left by a distance of 1.\n\nSample Input 2\n\n3 1 3\n\nSample Output 2\n\n0\n\nThe rectangles are already connected, and thus no move is needed.\n\nSample Input 3\n\n5 10 1\n\nSample Output 3\n\n4", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s220094681", "group_id": "codeNet:p03778", "input_text": "let () =\n Scanf.scanf \"%d %d %d\" (fun w a b ->\n (max a b) - (min a b) - w |> max 0 |> Printf.printf \"%d\\n\")", "language": "OCaml", "metadata": {"date": 1525946530, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03778.html", "problem_id": "p03778", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03778/input.txt", "sample_output_relpath": "derived/input_output/data/p03778/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03778/OCaml/s220094681.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s220094681", "user_id": "u987869509"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "let () =\n Scanf.scanf \"%d %d %d\" (fun w a b ->\n (max a b) - (min a b) - w |> max 0 |> Printf.printf \"%d\\n\")", "problem_context": "Score : 200 points\n\nProblem Statement\n\nAtCoDeer the deer found two rectangles lying on the table, each with height 1 and width W.\nIf we consider the surface of the desk as a two-dimensional plane, the first rectangle covers the vertical range of [0,1] and the horizontal range of [a,a+W], and the second rectangle covers the vertical range of [1,2] and the horizontal range of [b,b+W], as shown in the following figure:\n\nAtCoDeer will move the second rectangle horizontally so that it connects with the first rectangle.\nFind the minimum distance it needs to be moved.\n\nConstraints\n\nAll input values are integers.\n\n1≤W≤10^5\n\n1≤a,b≤10^5\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nW a b\n\nOutput\n\nPrint the minimum distance the second rectangle needs to be moved.\n\nSample Input 1\n\n3 2 6\n\nSample Output 1\n\n1\n\nThis input corresponds to the figure in the statement. In this case, the second rectangle should be moved to the left by a distance of 1.\n\nSample Input 2\n\n3 1 3\n\nSample Output 2\n\n0\n\nThe rectangles are already connected, and thus no move is needed.\n\nSample Input 3\n\n5 10 1\n\nSample Output 3\n\n4", "sample_input": "3 2 6\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03778", "source_text": "Score : 200 points\n\nProblem Statement\n\nAtCoDeer the deer found two rectangles lying on the table, each with height 1 and width W.\nIf we consider the surface of the desk as a two-dimensional plane, the first rectangle covers the vertical range of [0,1] and the horizontal range of [a,a+W], and the second rectangle covers the vertical range of [1,2] and the horizontal range of [b,b+W], as shown in the following figure:\n\nAtCoDeer will move the second rectangle horizontally so that it connects with the first rectangle.\nFind the minimum distance it needs to be moved.\n\nConstraints\n\nAll input values are integers.\n\n1≤W≤10^5\n\n1≤a,b≤10^5\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nW a b\n\nOutput\n\nPrint the minimum distance the second rectangle needs to be moved.\n\nSample Input 1\n\n3 2 6\n\nSample Output 1\n\n1\n\nThis input corresponds to the figure in the statement. In this case, the second rectangle should be moved to the left by a distance of 1.\n\nSample Input 2\n\n3 1 3\n\nSample Output 2\n\n0\n\nThe rectangles are already connected, and thus no move is needed.\n\nSample Input 3\n\n5 10 1\n\nSample Output 3\n\n4", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s396206283", "group_id": "codeNet:p03779", "input_text": "let solve n =\n let rec aux i sum =\n if sum >= n then i else aux (succ i) (sum + i + 1) in\n aux 1 1\n\nlet () = read_int () |> solve |> Printf.printf \"%d\\n\"", "language": "OCaml", "metadata": {"date": 1525948950, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03779.html", "problem_id": "p03779", "resource_group": "low_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/OCaml/s396206283.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s396206283", "user_id": "u987869509"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "let solve n =\n let rec aux i sum =\n if sum >= n then i else aux (succ i) (sum + i + 1) in\n aux 1 1\n\nlet () = read_int () |> solve |> Printf.printf \"%d\\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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s161169132", "group_id": "codeNet:p03779", "input_text": "let id x = x\nlet x = Scanf.scanf \"%d\" id\n\nlet rec func x i cnt =\n if x <= (i + cnt) then cnt else func x (i + cnt) (cnt + 1)\n \nlet ans = func x 0 1\n\nlet () = Printf.printf \"%d\\n\" ans", "language": "OCaml", "metadata": {"date": 1489890082, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03779.html", "problem_id": "p03779", "resource_group": "low_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/OCaml/s161169132.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s161169132", "user_id": "u735499035"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "let id x = x\nlet x = Scanf.scanf \"%d\" id\n\nlet rec func x i cnt =\n if x <= (i + cnt) then cnt else func x (i + cnt) (cnt + 1)\n \nlet ans = func x 0 1\n\nlet () = Printf.printf \"%d\\n\" ans", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s237143681", "group_id": "codeNet:p03780", "input_text": "open Printf open Scanf\nopen Array\n\nlet binary_search ng ok f = let d = if ng < ok then 1 else -1 in\n let rec f0 ng ok =\n if abs (ok - ng) <= 1 then ok\n else let mid = ng + (ok - ng) / 2 in if f mid then f0 ng mid else f0 mid ok\n in f0 (ng-d) (ok+d)\n\nlet () = scanf \" %d %d\" @@ fun n k ->\n let a = init n (fun _ -> scanf \" %d\" @@ fun v -> v) in\n sort compare a;\n print_int @@ binary_search 0 (n-1) (fun i ->\n let u = a.(i) in\n if u >= k then true\n else (\n let f = ref false in\n let dp = make (k+1) false in\n iteri (fun j v ->\n if j=i then ()\n else (\n for w=k downto 1 do\n if dp.(w) then (\n if k-u <= w+v && w+v < k then\n f := true\n else if w+v < k then\n dp.(w+v) <- true\n )\n done;\n if v\n let a = init n (fun _ -> scanf \" %d\" @@ fun v -> v) in\n sort compare a;\n print_int @@ binary_search 0 (n-1) (fun i ->\n let u = a.(i) in\n if u >= k then true\n else (\n let f = ref false in\n let dp = make (k+1) false in\n iteri (fun j v ->\n if j=i then ()\n else (\n for w=k downto 1 do\n if dp.(w) then (\n if k-u <= w+v && w+v < k then\n f := true\n else if w+v < k then\n dp.(w+v) <- true\n )\n done;\n if v\n let as_ = Array.init (n + 1) @@ function\n | 0 -> 0\n | _ -> Scanf.scanf \"%d \" @@ fun a -> a in\n Array.sort compare as_;\n let bs = Array.make k false in\n bs.(0) <- true;\n Printf.printf \"%d\\n\" @@ upper_bound 0 (n + 1) @@ fun i ->\n if k <= as_.(i) then false\n else begin\n Array.fill bs 1 (k - 1) false;\n Array.iteri (fun j a ->\n if i <> j then\n for a' = k - 1 downto a do\n bs.(a') <- bs.(a') || bs.(a' - a)\n done) as_;\n try\n for a = k - as_.(i) to k - 1 do\n if bs.(a) then raise Not_found\n done; true\n with Not_found -> false\n end\n", "language": "OCaml", "metadata": {"date": 1532909491, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03782.html", "problem_id": "p03782", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03782/input.txt", "sample_output_relpath": "derived/input_output/data/p03782/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03782/OCaml/s627208889.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s627208889", "user_id": "u504158101"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "let rec upper_bound l r p =\n if r <= 1 + l\n then l\n else let m = (l + r) / 2 in\n if p m \n then upper_bound m r p\n else upper_bound l m p\n\nlet () = Scanf.scanf \"%d %d\\n\" @@ fun n k ->\n let as_ = Array.init (n + 1) @@ function\n | 0 -> 0\n | _ -> Scanf.scanf \"%d \" @@ fun a -> a in\n Array.sort compare as_;\n let bs = Array.make k false in\n bs.(0) <- true;\n Printf.printf \"%d\\n\" @@ upper_bound 0 (n + 1) @@ fun i ->\n if k <= as_.(i) then false\n else begin\n Array.fill bs 1 (k - 1) false;\n Array.iteri (fun j a ->\n if i <> j then\n for a' = k - 1 downto a do\n bs.(a') <- bs.(a') || bs.(a' - a)\n done) as_;\n try\n for a = k - as_.(i) to k - 1 do\n if bs.(a) then raise Not_found\n done; true\n with Not_found -> false\n end\n", "problem_context": "Score : 600 points\n\nProblem Statement\n\nAtCoDeer the deer has N cards with positive integers written on them. The number on the i-th card (1≤i≤N) is a_i.\nBecause he loves big numbers, he calls a subset of the cards good when the sum of the numbers written on the cards in the subset, is K or greater.\n\nThen, for each card i, he judges whether it is unnecessary or not, as follows:\n\nIf, for any good subset of the cards containing card i, the set that can be obtained by eliminating card i from the subset is also good, card i is unnecessary.\n\nOtherwise, card i is NOT unnecessary.\n\nFind the number of the unnecessary cards. Here, he judges each card independently, and he does not throw away cards that turn out to be unnecessary.\n\nConstraints\n\nAll input values are integers.\n\n1≤N≤5000\n\n1≤K≤5000\n\n1≤a_i≤10^9 (1≤i≤N)\n\nPartial Score\n\n300 points will be awarded for passing the test set satisfying N,K≤400.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN K\na_1 a_2 ... a_N\n\nOutput\n\nPrint the number of the unnecessary cards.\n\nSample Input 1\n\n3 6\n1 4 3\n\nSample Output 1\n\n1\n\nThere are two good sets: {2,3} and {1,2,3}.\n\nCard 1 is only contained in {1,2,3}, and this set without card 1, {2,3}, is also good. Thus, card 1 is unnecessary.\n\nFor card 2, a good set {2,3} without card 2, {3}, is not good. Thus, card 2 is NOT unnecessary.\n\nNeither is card 3 for a similar reason, hence the answer is 1.\n\nSample Input 2\n\n5 400\n3 1 4 1 5\n\nSample Output 2\n\n5\n\nIn this case, there is no good set. Therefore, all the cards are unnecessary.\n\nSample Input 3\n\n6 20\n10 4 3 10 25 2\n\nSample Output 3\n\n3", "sample_input": "3 6\n1 4 3\n"}, "reference_outputs": ["1\n"], "source_document_id": "p03782", "source_text": "Score : 600 points\n\nProblem Statement\n\nAtCoDeer the deer has N cards with positive integers written on them. The number on the i-th card (1≤i≤N) is a_i.\nBecause he loves big numbers, he calls a subset of the cards good when the sum of the numbers written on the cards in the subset, is K or greater.\n\nThen, for each card i, he judges whether it is unnecessary or not, as follows:\n\nIf, for any good subset of the cards containing card i, the set that can be obtained by eliminating card i from the subset is also good, card i is unnecessary.\n\nOtherwise, card i is NOT unnecessary.\n\nFind the number of the unnecessary cards. Here, he judges each card independently, and he does not throw away cards that turn out to be unnecessary.\n\nConstraints\n\nAll input values are integers.\n\n1≤N≤5000\n\n1≤K≤5000\n\n1≤a_i≤10^9 (1≤i≤N)\n\nPartial Score\n\n300 points will be awarded for passing the test set satisfying N,K≤400.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN K\na_1 a_2 ... a_N\n\nOutput\n\nPrint the number of the unnecessary cards.\n\nSample Input 1\n\n3 6\n1 4 3\n\nSample Output 1\n\n1\n\nThere are two good sets: {2,3} and {1,2,3}.\n\nCard 1 is only contained in {1,2,3}, and this set without card 1, {2,3}, is also good. Thus, card 1 is unnecessary.\n\nFor card 2, a good set {2,3} without card 2, {3}, is not good. Thus, card 2 is NOT unnecessary.\n\nNeither is card 3 for a similar reason, hence the answer is 1.\n\nSample Input 2\n\n5 400\n3 1 4 1 5\n\nSample Output 2\n\n5\n\nIn this case, there is no good set. Therefore, all the cards are unnecessary.\n\nSample Input 3\n\n6 20\n10 4 3 10 25 2\n\nSample Output 3\n\n3", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 831, "cpu_time_ms": 540, "memory_kb": 4480}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s174154537", "group_id": "codeNet:p03783", "input_text": "let rec upper_bound l r p =\n if r <= 1 + l\n then l\n else let m = (l + r) / 2 in\n if p m \n then upper_bound m r p\n else upper_bound l m p\n\nlet () = Scanf.scanf \"%d\\n\" @@ fun n ->\n let lrs = Array.init n @@ fun _ -> Scanf.scanf \"%d %d\\n\" @@ fun l r -> l, r in\n let f x = Array.fold_right (fun (l, r) -> ( + ) @@\n if x < l then l - x\n else if r < x then x - r\n else 0) lrs 0 in\n Printf.printf \"%d\\n\" @@ f @@ upper_bound\n (Array.fold_right (fun (l, _) -> min l) lrs max_int)\n (Array.fold_right (fun (_, r) -> max r) lrs 0 + 1) @@ fun x -> f (x - 1) >= f x\n\n", "language": "OCaml", "metadata": {"date": 1537586844, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03783.html", "problem_id": "p03783", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03783/input.txt", "sample_output_relpath": "derived/input_output/data/p03783/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03783/OCaml/s174154537.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s174154537", "user_id": "u504158101"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "let rec upper_bound l r p =\n if r <= 1 + l\n then l\n else let m = (l + r) / 2 in\n if p m \n then upper_bound m r p\n else upper_bound l m p\n\nlet () = Scanf.scanf \"%d\\n\" @@ fun n ->\n let lrs = Array.init n @@ fun _ -> Scanf.scanf \"%d %d\\n\" @@ fun l r -> l, r in\n let f x = Array.fold_right (fun (l, r) -> ( + ) @@\n if x < l then l - x\n else if r < x then x - r\n else 0) lrs 0 in\n Printf.printf \"%d\\n\" @@ f @@ upper_bound\n (Array.fold_right (fun (l, _) -> min l) lrs max_int)\n (Array.fold_right (fun (_, r) -> max r) lrs 0 + 1) @@ fun x -> f (x - 1) >= f x\n\n", "problem_context": "Score : 1000 points\n\nProblem Statement\n\nAtCoDeer the deer found N rectangle lying on the table, each with height 1.\nIf we consider the surface of the desk as a two-dimensional plane, the i-th rectangle i(1≤i≤N) covers the vertical range of [i-1,i] and the horizontal range of [l_i,r_i], as shown in the following figure:\n\nAtCoDeer will move these rectangles horizontally so that all the rectangles are connected.\nFor each rectangle, the cost to move it horizontally by a distance of x, is x.\nFind the minimum cost to achieve connectivity.\nIt can be proved that this value is always an integer under the constraints of the problem.\n\nConstraints\n\nAll input values are integers.\n\n1≤N≤10^5\n\n1≤l_i n, c, k) in\n let ts = Array.init n (fun _ -> Scanf.scanf \"%d \" (fun n -> n)) in\n Array.sort compare ts;\n Array.fold_left (fun (acc, i, j) t ->\n if ts.(i) + k < t then (acc + 1, j, j + 1)\n else if c <= j - i then (acc + 1, i + c, j + 1)\n else (acc, i, j + 1)) (0, 0, 0) ts\n |> (fun (acc, _, _) -> Printf.printf \"%d\\n\" (1 + acc))", "language": "OCaml", "metadata": {"date": 1507525853, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03785.html", "problem_id": "p03785", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03785/input.txt", "sample_output_relpath": "derived/input_output/data/p03785/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03785/OCaml/s187920129.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s187920129", "user_id": "u504158101"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "let () =\n let n, c, k = Scanf.scanf \"%d %d %d\\n\" (fun n c k -> n, c, k) in\n let ts = Array.init n (fun _ -> Scanf.scanf \"%d \" (fun n -> n)) in\n Array.sort compare ts;\n Array.fold_left (fun (acc, i, j) t ->\n if ts.(i) + k < t then (acc + 1, j, j + 1)\n else if c <= j - i then (acc + 1, i + c, j + 1)\n else (acc, i, j + 1)) (0, 0, 0) ts\n |> (fun (acc, _, _) -> Printf.printf \"%d\\n\" (1 + acc))", "problem_context": "Score : 300 points\n\nProblem Statement\n\nEvery day, N passengers arrive at Takahashi Airport.\nThe i-th passenger arrives at time T_i.\n\nEvery passenger arrived at Takahashi airport travels to the city by bus. Each bus can accommodate up to C passengers.\nNaturally, a passenger cannot take a bus that departs earlier than the airplane arrives at the airport.\nAlso, a passenger will get angry if he/she is still unable to take a bus K units of time after the arrival of the airplane.\nFor that reason, it is necessary to arrange buses so that the i-th passenger can take a bus departing at time between T_i and T_i + K (inclusive).\n\nWhen setting the departure times for buses under this condition, find the minimum required number of buses.\nHere, the departure time for each bus does not need to be an integer, and there may be multiple buses that depart at the same time.\n\nConstraints\n\n2 \\leq N \\leq 100000\n\n1 \\leq C \\leq 10^9\n\n1 \\leq K \\leq 10^9\n\n1 \\leq T_i \\leq 10^9\n\nC, K and T_i are integers.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN C K\nT_1\nT_2\n:\nT_N\n\nOutput\n\nPrint the minimum required number of buses.\n\nSample Input 1\n\n5 3 5\n1\n2\n3\n6\n12\n\nSample Output 1\n\n3\n\nFor example, the following three buses are enough:\n\nA bus departing at time 4.5, that carries the passengers arriving at time 2 and 3.\n\nA bus departing at time 6, that carries the passengers arriving at time 1 and 6.\n\nA bus departing at time 12, that carries the passenger arriving at time 12.\n\nSample Input 2\n\n6 3 3\n7\n6\n2\n8\n10\n6\n\nSample Output 2\n\n3", "sample_input": "5 3 5\n1\n2\n3\n6\n12\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03785", "source_text": "Score : 300 points\n\nProblem Statement\n\nEvery day, N passengers arrive at Takahashi Airport.\nThe i-th passenger arrives at time T_i.\n\nEvery passenger arrived at Takahashi airport travels to the city by bus. Each bus can accommodate up to C passengers.\nNaturally, a passenger cannot take a bus that departs earlier than the airplane arrives at the airport.\nAlso, a passenger will get angry if he/she is still unable to take a bus K units of time after the arrival of the airplane.\nFor that reason, it is necessary to arrange buses so that the i-th passenger can take a bus departing at time between T_i and T_i + K (inclusive).\n\nWhen setting the departure times for buses under this condition, find the minimum required number of buses.\nHere, the departure time for each bus does not need to be an integer, and there may be multiple buses that depart at the same time.\n\nConstraints\n\n2 \\leq N \\leq 100000\n\n1 \\leq C \\leq 10^9\n\n1 \\leq K \\leq 10^9\n\n1 \\leq T_i \\leq 10^9\n\nC, K and T_i are integers.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN C K\nT_1\nT_2\n:\nT_N\n\nOutput\n\nPrint the minimum required number of buses.\n\nSample Input 1\n\n5 3 5\n1\n2\n3\n6\n12\n\nSample Output 1\n\n3\n\nFor example, the following three buses are enough:\n\nA bus departing at time 4.5, that carries the passengers arriving at time 2 and 3.\n\nA bus departing at time 6, that carries the passengers arriving at time 1 and 6.\n\nA bus departing at time 12, that carries the passenger arriving at time 12.\n\nSample Input 2\n\n6 3 3\n7\n6\n2\n8\n10\n6\n\nSample Output 2\n\n3", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 79, "memory_kb": 4736}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s258415310", "group_id": "codeNet:p03786", "input_text": "let id x = x\nlet n = Scanf.scanf \"%d\\n\" id\n \nlet repeat f =\n let rec loop acc = function\n | 0 -> List.rev acc\n | n -> loop (f () :: acc) (n-1) in\n loop []\n\nlet alist = repeat (fun () -> Scanf.scanf \"%d \" id) n\nlet len = List.length alist\n\nlet rec del_i i l =\n match l with\n | [] -> []\n | h::t when i = 0 -> t\n | h::t -> h :: del_i (i-1) t\n\n\nlet rec del x l =\n match l with\n | [] -> []\n | h::t when h = x -> t\n | h::t -> h :: del x t\n\n \nlet check' alist =\n let rec check1 i ans =\n if i = len then ans else check2 (del_i i alist) (List.nth alist i) ans i\n\n and check2 alist' x ans i =\n match alist' with\n | [] -> check1 (i+1) (ans+1)\n | alist' ->\n if List.exists (fun y -> y <= 2*x) alist' then\n\tlet x' = (List.find (fun y -> y <= 2*x) alist') in\n\tcheck2 (del x' alist') (x + x') ans i\n else check1 (i+1) ans\nin check1 0 0\n\nlet ans = check' alist\n\nlet () = Printf.printf \"%d\\n\" ans\n", "language": "OCaml", "metadata": {"date": 1489375258, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03786.html", "problem_id": "p03786", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03786/input.txt", "sample_output_relpath": "derived/input_output/data/p03786/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03786/OCaml/s258415310.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s258415310", "user_id": "u735499035"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "let id x = x\nlet n = Scanf.scanf \"%d\\n\" id\n \nlet repeat f =\n let rec loop acc = function\n | 0 -> List.rev acc\n | n -> loop (f () :: acc) (n-1) in\n loop []\n\nlet alist = repeat (fun () -> Scanf.scanf \"%d \" id) n\nlet len = List.length alist\n\nlet rec del_i i l =\n match l with\n | [] -> []\n | h::t when i = 0 -> t\n | h::t -> h :: del_i (i-1) t\n\n\nlet rec del x l =\n match l with\n | [] -> []\n | h::t when h = x -> t\n | h::t -> h :: del x t\n\n \nlet check' alist =\n let rec check1 i ans =\n if i = len then ans else check2 (del_i i alist) (List.nth alist i) ans i\n\n and check2 alist' x ans i =\n match alist' with\n | [] -> check1 (i+1) (ans+1)\n | alist' ->\n if List.exists (fun y -> y <= 2*x) alist' then\n\tlet x' = (List.find (fun y -> y <= 2*x) alist') in\n\tcheck2 (del x' alist') (x + x') ans i\n else check1 (i+1) ans\nin check1 0 0\n\nlet ans = check' alist\n\nlet () = Printf.printf \"%d\\n\" ans\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nSnuke found N strange creatures.\nEach creature has a fixed color and size. The color and size of the i-th creature are represented by i and A_i, respectively.\n\nEvery creature can absorb another creature whose size is at most twice the size of itself.\nWhen a creature of size A and color B absorbs another creature of size C and color D (C \\leq 2 \\times A), they will merge into one creature of size A+C and color B.\nHere, depending on the sizes of two creatures, it is possible that both of them can absorb the other.\n\nSnuke has been watching these creatures merge over and over and ultimately become one creature.\nFind the number of the possible colors of this creature.\n\nConstraints\n\n2 \\leq N \\leq 100000\n\n1 \\leq A_i \\leq 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\nPrint the number of the possible colors of the last remaining creature after the N creatures repeatedly merge and ultimately become one creature.\n\nSample Input 1\n\n3\n3 1 4\n\nSample Output 1\n\n2\n\nThe possible colors of the last remaining creature are colors 1 and 3.\nFor example, when the creature of color 3 absorbs the creature of color 2, then the creature of color 1 absorbs the creature of color 3, the color of the last remaining creature will be color 1.\n\nSample Input 2\n\n5\n1 1 1 1 1\n\nSample Output 2\n\n5\n\nThere may be multiple creatures of the same size.\n\nSample Input 3\n\n6\n40 1 30 2 7 20\n\nSample Output 3\n\n4", "sample_input": "3\n3 1 4\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03786", "source_text": "Score : 400 points\n\nProblem Statement\n\nSnuke found N strange creatures.\nEach creature has a fixed color and size. The color and size of the i-th creature are represented by i and A_i, respectively.\n\nEvery creature can absorb another creature whose size is at most twice the size of itself.\nWhen a creature of size A and color B absorbs another creature of size C and color D (C \\leq 2 \\times A), they will merge into one creature of size A+C and color B.\nHere, depending on the sizes of two creatures, it is possible that both of them can absorb the other.\n\nSnuke has been watching these creatures merge over and over and ultimately become one creature.\nFind the number of the possible colors of this creature.\n\nConstraints\n\n2 \\leq N \\leq 100000\n\n1 \\leq A_i \\leq 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\nPrint the number of the possible colors of the last remaining creature after the N creatures repeatedly merge and ultimately become one creature.\n\nSample Input 1\n\n3\n3 1 4\n\nSample Output 1\n\n2\n\nThe possible colors of the last remaining creature are colors 1 and 3.\nFor example, when the creature of color 3 absorbs the creature of color 2, then the creature of color 1 absorbs the creature of color 3, the color of the last remaining creature will be color 1.\n\nSample Input 2\n\n5\n1 1 1 1 1\n\nSample Output 2\n\n5\n\nThere may be multiple creatures of the same size.\n\nSample Input 3\n\n6\n40 1 30 2 7 20\n\nSample Output 3\n\n4", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 924, "cpu_time_ms": 2104, "memory_kb": 18996}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s105284336", "group_id": "codeNet:p03795", "input_text": "open Scanf\nopen Printf\n\nlet () = scanf \"%d\" (fun n-> n * 800 - (n / 15) * 200\n ) |> printf \"%d\\n\"", "language": "OCaml", "metadata": {"date": 1595974498, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p03795.html", "problem_id": "p03795", "resource_group": "low_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/OCaml/s105284336.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s105284336", "user_id": "u272377260"}, "prompt_components": {"gold_output": "15800\n", "input_to_evaluate": "open Scanf\nopen Printf\n\nlet () = scanf \"%d\" (fun n-> n * 800 - (n / 15) * 200\n ) |> printf \"%d\\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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 6, "memory_kb": 3844}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s233360006", "group_id": "codeNet:p03795", "input_text": "let () = Scanf.scanf \"%d\" (fun n -> 800 * n - 200 * (n / 15)) |> Printf.printf \"%d\\n\"\n", "language": "OCaml", "metadata": {"date": 1519658242, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03795.html", "problem_id": "p03795", "resource_group": "low_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/OCaml/s233360006.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s233360006", "user_id": "u798181098"}, "prompt_components": {"gold_output": "15800\n", "input_to_evaluate": "let () = Scanf.scanf \"%d\" (fun n -> 800 * n - 200 * (n / 15)) |> Printf.printf \"%d\\n\"\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nSnuke has a favorite restaurant.\n\nThe price of any meal served at the restaurant is 800 yen (the currency of Japan), and each time a customer orders 15 meals, the restaurant pays 200 yen back to the customer.\n\nSo far, Snuke has ordered N meals at the restaurant.\nLet the amount of money Snuke has paid to the restaurant be x yen, and let the amount of money the restaurant has paid back to Snuke be y yen.\nFind x-y.\n\nConstraints\n\n1 ≤ N ≤ 100\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n20\n\nSample Output 1\n\n15800\n\nSo far, Snuke has paid 16000 yen, and the restaurant has paid back 200 yen. Thus, the answer is 15800.\n\nSample Input 2\n\n60\n\nSample Output 2\n\n47200\n\nSnuke has paid 48000 yen for 60 meals, and the restaurant has paid back 800 yen.", "sample_input": "20\n"}, "reference_outputs": ["15800\n"], "source_document_id": "p03795", "source_text": "Score : 100 points\n\nProblem Statement\n\nSnuke has a favorite restaurant.\n\nThe price of any meal served at the restaurant is 800 yen (the currency of Japan), and each time a customer orders 15 meals, the restaurant pays 200 yen back to the customer.\n\nSo far, Snuke has ordered N meals at the restaurant.\nLet the amount of money Snuke has paid to the restaurant be x yen, and let the amount of money the restaurant has paid back to Snuke be y yen.\nFind x-y.\n\nConstraints\n\n1 ≤ N ≤ 100\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n20\n\nSample Output 1\n\n15800\n\nSo far, Snuke has paid 16000 yen, and the restaurant has paid back 200 yen. Thus, the answer is 15800.\n\nSample Input 2\n\n60\n\nSample Output 2\n\n47200\n\nSnuke has paid 48000 yen for 60 meals, and the restaurant has paid back 800 yen.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s255159825", "group_id": "codeNet:p03796", "input_text": "let rec f n a = if n <= 1 then a else f (n - 1) (n * a mod 1000000007)\nlet _ = Printf.printf \"%d\\n\" @@ f (read_int ()) 1", "language": "OCaml", "metadata": {"date": 1579132307, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03796.html", "problem_id": "p03796", "resource_group": "low_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/OCaml/s255159825.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s255159825", "user_id": "u732304692"}, "prompt_components": {"gold_output": "6\n", "input_to_evaluate": "let rec f n a = if n <= 1 then a else f (n - 1) (n * a mod 1000000007)\nlet _ = Printf.printf \"%d\\n\" @@ f (read_int ()) 1", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 2, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s743856468", "group_id": "codeNet:p03797", "input_text": "Scanf.scanf \" %d %d\"@@fun n m->print_int@@if n*2>m then m/2 else n+(m-n*2)/4", "language": "OCaml", "metadata": {"date": 1540247854, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03797.html", "problem_id": "p03797", "resource_group": "low_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/OCaml/s743856468.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s743856468", "user_id": "u481480055"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "Scanf.scanf \" %d %d\"@@fun n m->print_int@@if n*2>m then m/2 else n+(m-n*2)/4", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s305210527", "group_id": "codeNet:p03798", "input_text": "let string_to_list str =\n let rec loop i limit =\n if i = limit then []\n else (String.get str i) :: (loop (i + 1) limit)\n in\n loop 0 (String.length str)\n\n\nlet fwd arr_length n = if n = (arr_length - 1) then 0 else n+1\nlet prev arr_length n = if n = 0 then arr_length - 1 else n-1\nlet flip c = if c = 'S' then 'W' else 'S'\nlet print_chars arr = Array.iter (fun x -> Printf.printf \"%c\" x) arr; Printf.printf \"\\n\"\n \nlet fill arr arr_length n by =\n if (arr.(n) == 'S' && by = 'o') || (arr.(n) == 'W' && by = 'x') then\n begin\n arr.(fwd arr_length n) <- arr.(prev arr_length n);\n end\n else\n begin\n arr.(fwd arr_length n) <- flip arr.(prev arr_length n);\n end \n\nlet rec extend answers ans_length cursor ret = match answers with\n | [] -> ret\n | 'o'::rest ->\n fill ret ans_length cursor 'o';\n extend rest ans_length (cursor+1) ret\n | 'x'::rest ->\n fill ret ans_length cursor 'x';\n extend rest ans_length (cursor+1) ret\n | _ -> ret\n\nlet check arr arr_length by n =\n if (arr.(n) == 'S' && by = 'o') || (arr.(n) == 'W' && by = 'x') then\n arr.(fwd arr_length n) = arr.(prev arr_length n)\n else\n arr.(fwd arr_length n) <> arr.(prev arr_length n)\n\nlet make_list f t step =\n let rec make_list_inner c t lst =\n if c >= t then lst else make_list_inner (c+step) t (c::lst)\n in\n List.rev (make_list_inner f t [])\n\nlet check_all pos_ans length pairs =\n let checks = List.map (fun (x,y) -> check pos_ans length y x) pairs in\n List.fold_left (fun x y -> x && y) true checks\n\nlet array_make length a b =\n let ret = (Array.make length a) in\n ret.(length - 1) <- b;\n ret\n\nlet solve str =\n let str_list = (string_to_list str) in\n let length = List.length str_list in\n let pairs = List.combine (make_list 0 length 1) str_list in\n let pos_ans = extend str_list length 0 (array_make length 'S' 'S') in\n if check_all pos_ans length pairs then pos_ans else\n let pos_ans = extend str_list length 0 (array_make length 'S' 'W') in\n if check_all pos_ans length pairs then pos_ans else\n let pos_ans = extend str_list length 0 (array_make length 'W' 'W') in\n if check_all pos_ans length pairs then pos_ans else\n let pos_ans = extend str_list length 0 (array_make length 'W' 'S') in\n if check_all pos_ans length pairs then pos_ans else\n [||]\n \nlet () =\n let _ = read_int() in\n let str = read_line () in\n let ans = solve str in\n if ans = [||] then\n Printf.printf (\"-1\")\n else\n Array.iter (fun x -> Printf.printf \"%c\" x) ans;\n Printf.printf \"\\n\"\n;;\n", "language": "OCaml", "metadata": {"date": 1487475928, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03798.html", "problem_id": "p03798", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03798/input.txt", "sample_output_relpath": "derived/input_output/data/p03798/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03798/OCaml/s305210527.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s305210527", "user_id": "u980152513"}, "prompt_components": {"gold_output": "SSSWWS\n", "input_to_evaluate": "let string_to_list str =\n let rec loop i limit =\n if i = limit then []\n else (String.get str i) :: (loop (i + 1) limit)\n in\n loop 0 (String.length str)\n\n\nlet fwd arr_length n = if n = (arr_length - 1) then 0 else n+1\nlet prev arr_length n = if n = 0 then arr_length - 1 else n-1\nlet flip c = if c = 'S' then 'W' else 'S'\nlet print_chars arr = Array.iter (fun x -> Printf.printf \"%c\" x) arr; Printf.printf \"\\n\"\n \nlet fill arr arr_length n by =\n if (arr.(n) == 'S' && by = 'o') || (arr.(n) == 'W' && by = 'x') then\n begin\n arr.(fwd arr_length n) <- arr.(prev arr_length n);\n end\n else\n begin\n arr.(fwd arr_length n) <- flip arr.(prev arr_length n);\n end \n\nlet rec extend answers ans_length cursor ret = match answers with\n | [] -> ret\n | 'o'::rest ->\n fill ret ans_length cursor 'o';\n extend rest ans_length (cursor+1) ret\n | 'x'::rest ->\n fill ret ans_length cursor 'x';\n extend rest ans_length (cursor+1) ret\n | _ -> ret\n\nlet check arr arr_length by n =\n if (arr.(n) == 'S' && by = 'o') || (arr.(n) == 'W' && by = 'x') then\n arr.(fwd arr_length n) = arr.(prev arr_length n)\n else\n arr.(fwd arr_length n) <> arr.(prev arr_length n)\n\nlet make_list f t step =\n let rec make_list_inner c t lst =\n if c >= t then lst else make_list_inner (c+step) t (c::lst)\n in\n List.rev (make_list_inner f t [])\n\nlet check_all pos_ans length pairs =\n let checks = List.map (fun (x,y) -> check pos_ans length y x) pairs in\n List.fold_left (fun x y -> x && y) true checks\n\nlet array_make length a b =\n let ret = (Array.make length a) in\n ret.(length - 1) <- b;\n ret\n\nlet solve str =\n let str_list = (string_to_list str) in\n let length = List.length str_list in\n let pairs = List.combine (make_list 0 length 1) str_list in\n let pos_ans = extend str_list length 0 (array_make length 'S' 'S') in\n if check_all pos_ans length pairs then pos_ans else\n let pos_ans = extend str_list length 0 (array_make length 'S' 'W') in\n if check_all pos_ans length pairs then pos_ans else\n let pos_ans = extend str_list length 0 (array_make length 'W' 'W') in\n if check_all pos_ans length pairs then pos_ans else\n let pos_ans = extend str_list length 0 (array_make length 'W' 'S') in\n if check_all pos_ans length pairs then pos_ans else\n [||]\n \nlet () =\n let _ = read_int() in\n let str = read_line () in\n let ans = solve str in\n if ans = [||] then\n Printf.printf (\"-1\")\n else\n Array.iter (fun x -> Printf.printf \"%c\" x) ans;\n Printf.printf \"\\n\"\n;;\n", "problem_context": "Score : 500 points\n\nProblem Statement\n\nSnuke, who loves animals, built a zoo.\n\nThere are N animals in this zoo. They are conveniently numbered 1 through N, and arranged in a circle.\nThe animal numbered i (2≤i≤N-1) is adjacent to the animals numbered i-1 and i+1. Also, the animal numbered 1 is adjacent to the animals numbered 2 and N, and the animal numbered N is adjacent to the animals numbered N-1 and 1.\n\nThere are two kinds of animals in this zoo: honest sheep that only speak the truth, and lying wolves that only tell lies.\n\nSnuke cannot tell the difference between these two species, and asked each animal the following question: \"Are your neighbors of the same species?\" The animal numbered i answered s_i. Here, if s_i is o, the animal said that the two neighboring animals are of the same species, and if s_i is x, the animal said that the two neighboring animals are of different species.\n\nMore formally, a sheep answered o if the two neighboring animals are both sheep or both wolves, and answered x otherwise.\nSimilarly, a wolf answered x if the two neighboring animals are both sheep or both wolves, and answered o otherwise.\n\nSnuke is wondering whether there is a valid assignment of species to the animals that is consistent with these responses. If there is such an assignment, show one such assignment. Otherwise, print -1.\n\nConstraints\n\n3 ≤ N ≤ 10^{5}\n\ns is a string of length N consisting of o and x.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\ns\n\nOutput\n\nIf there does not exist an valid assignment that is consistent with s, print -1.\nOtherwise, print an string t in the following format. The output is considered correct if the assignment described by t is consistent with s.\n\nt is a string of length N consisting of S and W.\n\nIf t_i is S, it indicates that the animal numbered i is a sheep. If t_i is W, it indicates that the animal numbered i is a wolf.\n\nSample Input 1\n\n6\nooxoox\n\nSample Output 1\n\nSSSWWS\n\nFor example, if the animals numbered 1, 2, 3, 4, 5 and 6 are respectively a sheep, sheep, sheep, wolf, wolf, and sheep, it is consistent with their responses. Besides, there is another valid assignment of species: a wolf, sheep, wolf, sheep, wolf and wolf.\n\nLet us remind you: if the neiboring animals are of the same species, a sheep answers o and a wolf answers x. If the neiboring animals are of different species, a sheep answers x and a wolf answers o.\n\nSample Input 2\n\n3\noox\n\nSample Output 2\n\n-1\n\nPrint -1 if there is no valid assignment of species.\n\nSample Input 3\n\n10\noxooxoxoox\n\nSample Output 3\n\nSSWWSSSWWS", "sample_input": "6\nooxoox\n"}, "reference_outputs": ["SSSWWS\n"], "source_document_id": "p03798", "source_text": "Score : 500 points\n\nProblem Statement\n\nSnuke, who loves animals, built a zoo.\n\nThere are N animals in this zoo. They are conveniently numbered 1 through N, and arranged in a circle.\nThe animal numbered i (2≤i≤N-1) is adjacent to the animals numbered i-1 and i+1. Also, the animal numbered 1 is adjacent to the animals numbered 2 and N, and the animal numbered N is adjacent to the animals numbered N-1 and 1.\n\nThere are two kinds of animals in this zoo: honest sheep that only speak the truth, and lying wolves that only tell lies.\n\nSnuke cannot tell the difference between these two species, and asked each animal the following question: \"Are your neighbors of the same species?\" The animal numbered i answered s_i. Here, if s_i is o, the animal said that the two neighboring animals are of the same species, and if s_i is x, the animal said that the two neighboring animals are of different species.\n\nMore formally, a sheep answered o if the two neighboring animals are both sheep or both wolves, and answered x otherwise.\nSimilarly, a wolf answered x if the two neighboring animals are both sheep or both wolves, and answered o otherwise.\n\nSnuke is wondering whether there is a valid assignment of species to the animals that is consistent with these responses. If there is such an assignment, show one such assignment. Otherwise, print -1.\n\nConstraints\n\n3 ≤ N ≤ 10^{5}\n\ns is a string of length N consisting of o and x.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\ns\n\nOutput\n\nIf there does not exist an valid assignment that is consistent with s, print -1.\nOtherwise, print an string t in the following format. The output is considered correct if the assignment described by t is consistent with s.\n\nt is a string of length N consisting of S and W.\n\nIf t_i is S, it indicates that the animal numbered i is a sheep. If t_i is W, it indicates that the animal numbered i is a wolf.\n\nSample Input 1\n\n6\nooxoox\n\nSample Output 1\n\nSSSWWS\n\nFor example, if the animals numbered 1, 2, 3, 4, 5 and 6 are respectively a sheep, sheep, sheep, wolf, wolf, and sheep, it is consistent with their responses. Besides, there is another valid assignment of species: a wolf, sheep, wolf, sheep, wolf and wolf.\n\nLet us remind you: if the neiboring animals are of the same species, a sheep answers o and a wolf answers x. If the neiboring animals are of different species, a sheep answers x and a wolf answers o.\n\nSample Input 2\n\n3\noox\n\nSample Output 2\n\n-1\n\nPrint -1 if there is no valid assignment of species.\n\nSample Input 3\n\n10\noxooxoxoox\n\nSample Output 3\n\nSSWWSSSWWS", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 2549, "cpu_time_ms": 68, "memory_kb": 24960}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s722497396", "group_id": "codeNet:p03804", "input_text": "(* unihernandez22\n * https://atcoder.jp/contests/abc054/tasks/abc054_b\n * implementation\n * *)\n\nScanf.scanf \"%d %d\\n\" @@ fun n m ->\n let a = Array.init n @@ fun _ -> Scanf.scanf \"%s\\n\" @@ fun s -> s in\n let b = Array.init m @@ fun _ -> Scanf.scanf \"%s\\n\" @@ fun s -> s in\n\n let valid = ref true in\n let ans = ref \"No\\n\" in\n for i = 0 to n-m do\n for j = 0 to n-m do\n valid := true;\n for y = 0 to m-1 do\n if String.sub a.(i+y) j m <> b.(y) then\n valid := false;\n done;\n if !valid then\n ans := \"Yes\\n\";\n done;\n done;\n print_string !ans;;\n\n", "language": "OCaml", "metadata": {"date": 1593842751, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p03804.html", "problem_id": "p03804", "resource_group": "low_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/OCaml/s722497396.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s722497396", "user_id": "u878654696"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "(* unihernandez22\n * https://atcoder.jp/contests/abc054/tasks/abc054_b\n * implementation\n * *)\n\nScanf.scanf \"%d %d\\n\" @@ fun n m ->\n let a = Array.init n @@ fun _ -> Scanf.scanf \"%s\\n\" @@ fun s -> s in\n let b = Array.init m @@ fun _ -> Scanf.scanf \"%s\\n\" @@ fun s -> s in\n\n let valid = ref true in\n let ans = ref \"No\\n\" in\n for i = 0 to n-m do\n for j = 0 to n-m do\n valid := true;\n for y = 0 to m-1 do\n if String.sub a.(i+y) j m <> b.(y) then\n valid := false;\n done;\n if !valid then\n ans := \"Yes\\n\";\n done;\n done;\n print_string !ans;;\n\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nYou are given an image A composed of N rows and N columns of pixels, and a template image B composed of M rows and M columns of pixels.\n\nA pixel is the smallest element of an image, and in this problem it is a square of size 1×1.\n\nAlso, the given images are binary images, and the color of each pixel is either white or black.\n\nIn the input, every pixel is represented by a character: . corresponds to a white pixel, and # corresponds to a black pixel.\n\nThe image A is given as N strings A_1,...,A_N.\n\nThe j-th character in the string A_i corresponds to the pixel at the i-th row and j-th column of the image A (1≦i,j≦N).\n\nSimilarly, the template image B is given as M strings B_1,...,B_M.\n\nThe j-th character in the string B_i corresponds to the pixel at the i-th row and j-th column of the template image B (1≦i,j≦M).\n\nDetermine whether the template image B is contained in the image A when only parallel shifts can be applied to the images.\n\nConstraints\n\n1≦M≦N≦50\n\nA_i is a string of length N consisting of # and ..\n\nB_i is a string of length M consisting of # and ..\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN M\nA_1\nA_2\n:\nA_N\nB_1\nB_2\n:\nB_M\n\nOutput\n\nPrint Yes if the template image B is contained in the image A. Print No otherwise.\n\nSample Input 1\n\n3 2\n#.#\n.#.\n#.#\n#.\n.#\n\nSample Output 1\n\nYes\n\nThe template image B is identical to the upper-left 2 × 2 subimage and the lower-right 2 × 2 subimage of A. Thus, the output should be Yes.\n\nSample Input 2\n\n4 1\n....\n....\n....\n....\n#\n\nSample Output 2\n\nNo\n\nThe template image B, composed of a black pixel, is not contained in the image A composed of white pixels.", "sample_input": "3 2\n#.#\n.#.\n#.#\n#.\n.#\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03804", "source_text": "Score : 200 points\n\nProblem Statement\n\nYou are given an image A composed of N rows and N columns of pixels, and a template image B composed of M rows and M columns of pixels.\n\nA pixel is the smallest element of an image, and in this problem it is a square of size 1×1.\n\nAlso, the given images are binary images, and the color of each pixel is either white or black.\n\nIn the input, every pixel is represented by a character: . corresponds to a white pixel, and # corresponds to a black pixel.\n\nThe image A is given as N strings A_1,...,A_N.\n\nThe j-th character in the string A_i corresponds to the pixel at the i-th row and j-th column of the image A (1≦i,j≦N).\n\nSimilarly, the template image B is given as M strings B_1,...,B_M.\n\nThe j-th character in the string B_i corresponds to the pixel at the i-th row and j-th column of the template image B (1≦i,j≦M).\n\nDetermine whether the template image B is contained in the image A when only parallel shifts can be applied to the images.\n\nConstraints\n\n1≦M≦N≦50\n\nA_i is a string of length N consisting of # and ..\n\nB_i is a string of length M consisting of # and ..\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN M\nA_1\nA_2\n:\nA_N\nB_1\nB_2\n:\nB_M\n\nOutput\n\nPrint Yes if the template image B is contained in the image A. Print No otherwise.\n\nSample Input 1\n\n3 2\n#.#\n.#.\n#.#\n#.\n.#\n\nSample Output 1\n\nYes\n\nThe template image B is identical to the upper-left 2 × 2 subimage and the lower-right 2 × 2 subimage of A. Thus, the output should be Yes.\n\nSample Input 2\n\n4 1\n....\n....\n....\n....\n#\n\nSample Output 2\n\nNo\n\nThe template image B, composed of a black pixel, is not contained in the image A composed of white pixels.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 664, "cpu_time_ms": 8, "memory_kb": 4272}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s309880812", "group_id": "codeNet:p03804", "input_text": "Scanf.scanf \"%d %d\" (fun n m ->\n let a = Array.init n (fun _ -> Scanf.scanf \" %s\" (fun a -> a)) in\n let b = Array.init m (fun _ -> Scanf.scanf \" %s\" (fun a -> a)) in\n\n let o = n - m in\n let rec loop_oy oy =\n let rec loop_ox ox =\n let rec loop_y y =\n let rec loop_x x =\n if x = m then true else\n if a.(oy + y).[ox + x] <> b.(y).[x] then false\n else loop_x (x + 1)\n in\n if y = m then true else\n if loop_x 0 then loop_y (y + 1) else false\n in\n if ox > o then false else\n if loop_y 0 then true else loop_ox (ox + 1)\n in\n if oy > o then false else\n if loop_ox 0 then true else loop_oy (oy + 1)\n in\n print_endline @@ if loop_oy 0 then \"Yes\" else \"No\"\n)", "language": "OCaml", "metadata": {"date": 1592277296, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03804.html", "problem_id": "p03804", "resource_group": "low_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/OCaml/s309880812.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s309880812", "user_id": "u342443598"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "Scanf.scanf \"%d %d\" (fun n m ->\n let a = Array.init n (fun _ -> Scanf.scanf \" %s\" (fun a -> a)) in\n let b = Array.init m (fun _ -> Scanf.scanf \" %s\" (fun a -> a)) in\n\n let o = n - m in\n let rec loop_oy oy =\n let rec loop_ox ox =\n let rec loop_y y =\n let rec loop_x x =\n if x = m then true else\n if a.(oy + y).[ox + x] <> b.(y).[x] then false\n else loop_x (x + 1)\n in\n if y = m then true else\n if loop_x 0 then loop_y (y + 1) else false\n in\n if ox > o then false else\n if loop_y 0 then true else loop_ox (ox + 1)\n in\n if oy > o then false else\n if loop_ox 0 then true else loop_oy (oy + 1)\n in\n print_endline @@ if loop_oy 0 then \"Yes\" else \"No\"\n)", "problem_context": "Score : 200 points\n\nProblem Statement\n\nYou are given an image A composed of N rows and N columns of pixels, and a template image B composed of M rows and M columns of pixels.\n\nA pixel is the smallest element of an image, and in this problem it is a square of size 1×1.\n\nAlso, the given images are binary images, and the color of each pixel is either white or black.\n\nIn the input, every pixel is represented by a character: . corresponds to a white pixel, and # corresponds to a black pixel.\n\nThe image A is given as N strings A_1,...,A_N.\n\nThe j-th character in the string A_i corresponds to the pixel at the i-th row and j-th column of the image A (1≦i,j≦N).\n\nSimilarly, the template image B is given as M strings B_1,...,B_M.\n\nThe j-th character in the string B_i corresponds to the pixel at the i-th row and j-th column of the template image B (1≦i,j≦M).\n\nDetermine whether the template image B is contained in the image A when only parallel shifts can be applied to the images.\n\nConstraints\n\n1≦M≦N≦50\n\nA_i is a string of length N consisting of # and ..\n\nB_i is a string of length M consisting of # and ..\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN M\nA_1\nA_2\n:\nA_N\nB_1\nB_2\n:\nB_M\n\nOutput\n\nPrint Yes if the template image B is contained in the image A. Print No otherwise.\n\nSample Input 1\n\n3 2\n#.#\n.#.\n#.#\n#.\n.#\n\nSample Output 1\n\nYes\n\nThe template image B is identical to the upper-left 2 × 2 subimage and the lower-right 2 × 2 subimage of A. Thus, the output should be Yes.\n\nSample Input 2\n\n4 1\n....\n....\n....\n....\n#\n\nSample Output 2\n\nNo\n\nThe template image B, composed of a black pixel, is not contained in the image A composed of white pixels.", "sample_input": "3 2\n#.#\n.#.\n#.#\n#.\n.#\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03804", "source_text": "Score : 200 points\n\nProblem Statement\n\nYou are given an image A composed of N rows and N columns of pixels, and a template image B composed of M rows and M columns of pixels.\n\nA pixel is the smallest element of an image, and in this problem it is a square of size 1×1.\n\nAlso, the given images are binary images, and the color of each pixel is either white or black.\n\nIn the input, every pixel is represented by a character: . corresponds to a white pixel, and # corresponds to a black pixel.\n\nThe image A is given as N strings A_1,...,A_N.\n\nThe j-th character in the string A_i corresponds to the pixel at the i-th row and j-th column of the image A (1≦i,j≦N).\n\nSimilarly, the template image B is given as M strings B_1,...,B_M.\n\nThe j-th character in the string B_i corresponds to the pixel at the i-th row and j-th column of the template image B (1≦i,j≦M).\n\nDetermine whether the template image B is contained in the image A when only parallel shifts can be applied to the images.\n\nConstraints\n\n1≦M≦N≦50\n\nA_i is a string of length N consisting of # and ..\n\nB_i is a string of length M consisting of # and ..\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN M\nA_1\nA_2\n:\nA_N\nB_1\nB_2\n:\nB_M\n\nOutput\n\nPrint Yes if the template image B is contained in the image A. Print No otherwise.\n\nSample Input 1\n\n3 2\n#.#\n.#.\n#.#\n#.\n.#\n\nSample Output 1\n\nYes\n\nThe template image B is identical to the upper-left 2 × 2 subimage and the lower-right 2 × 2 subimage of A. Thus, the output should be Yes.\n\nSample Input 2\n\n4 1\n....\n....\n....\n....\n#\n\nSample Output 2\n\nNo\n\nThe template image B, composed of a black pixel, is not contained in the image A composed of white pixels.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 877, "cpu_time_ms": 1, "memory_kb": 512}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s954843611", "group_id": "codeNet:p03805", "input_text": "let n, m = Scanf.scanf \"%d %d\\n\" (fun n m -> n, m)\nlet edge = Array.make (n + 1) []\n\nlet rec load_graph i =\n if i < m then\n Scanf.scanf \"%d %d\\n\" (fun a b ->\n edge.(a) <- b :: edge.(a);\n edge.(b) <- a :: edge.(b);\n load_graph (i + 1)\n )\n\nlet rec ans v exists rest =\n if rest = 0 then 1\n else\n let rec f ret = function\n [] -> ret\n | u :: l ->\n if exists.(u) then (\n let copy = Array.init (n + 1) (fun i -> exists.(i)) in\n copy.(u) <- false;\n f (ret + ans u copy (rest - 1)) l\n ) else f ret l\n in f 0 edge.(v)\n\nlet () =\n load_graph 0;\n let exists = Array.make (n + 1) true in\n exists.(1) <- false;\n print_int (ans 1 exists (n - 1))\n", "language": "OCaml", "metadata": {"date": 1585671333, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03805.html", "problem_id": "p03805", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03805/input.txt", "sample_output_relpath": "derived/input_output/data/p03805/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03805/OCaml/s954843611.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s954843611", "user_id": "u752907799"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "let n, m = Scanf.scanf \"%d %d\\n\" (fun n m -> n, m)\nlet edge = Array.make (n + 1) []\n\nlet rec load_graph i =\n if i < m then\n Scanf.scanf \"%d %d\\n\" (fun a b ->\n edge.(a) <- b :: edge.(a);\n edge.(b) <- a :: edge.(b);\n load_graph (i + 1)\n )\n\nlet rec ans v exists rest =\n if rest = 0 then 1\n else\n let rec f ret = function\n [] -> ret\n | u :: l ->\n if exists.(u) then (\n let copy = Array.init (n + 1) (fun i -> exists.(i)) in\n copy.(u) <- false;\n f (ret + ans u copy (rest - 1)) l\n ) else f ret l\n in f 0 edge.(v)\n\nlet () =\n load_graph 0;\n let exists = Array.make (n + 1) true in\n exists.(1) <- false;\n print_int (ans 1 exists (n - 1))\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nYou are given an undirected unweighted graph with N vertices and M edges that contains neither self-loops nor double edges.\n\nHere, a self-loop is an edge where a_i = b_i (1≤i≤M), and double edges are two edges where (a_i,b_i)=(a_j,b_j) or (a_i,b_i)=(b_j,a_j) (1≤i\n let x = Array.init n (fun _ -> Scanf.scanf \" %d %d %d\" (fun a b c -> a,b,c)) in\n let dp = Array.make_matrix (lim+1) (lim+1) inf in\n dp.(0).(0) <- 0;\n x |> Array.iter (fun (a,b,c) ->\n for i = 400 downto a do\n for j = 400 downto b do\n dp.(i).(j) <- min dp.(i).(j) (dp.(i-a).(j-b) + c)\n done done);\n Array.init (lim / max ma mb) (fun i -> dp.((i+1)*ma).((i+1)*mb))\n |> Array.fold_left min inf\n |> fun c -> Printf.printf \"%d\\n\" (if c = inf then -1 else c)", "language": "OCaml", "metadata": {"date": 1531996974, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03806.html", "problem_id": "p03806", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03806/input.txt", "sample_output_relpath": "derived/input_output/data/p03806/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03806/OCaml/s979481626.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s979481626", "user_id": "u798181098"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "let lim, inf = 400, 10101010101010\nlet () =\n Scanf.scanf \"%d %d %d\" @@ fun n ma mb ->\n let x = Array.init n (fun _ -> Scanf.scanf \" %d %d %d\" (fun a b c -> a,b,c)) in\n let dp = Array.make_matrix (lim+1) (lim+1) inf in\n dp.(0).(0) <- 0;\n x |> Array.iter (fun (a,b,c) ->\n for i = 400 downto a do\n for j = 400 downto b do\n dp.(i).(j) <- min dp.(i).(j) (dp.(i-a).(j-b) + c)\n done done);\n Array.init (lim / max ma mb) (fun i -> dp.((i+1)*ma).((i+1)*mb))\n |> Array.fold_left min inf\n |> fun c -> Printf.printf \"%d\\n\" (if c = inf then -1 else c)", "problem_context": "Score : 400 points\n\nProblem Statement\n\nDolphin is planning to generate a small amount of a certain chemical substance C.\n\nIn order to generate the substance C, he must prepare a solution which is a mixture of two substances A and B in the ratio of M_a:M_b.\n\nHe does not have any stock of chemicals, however, so he will purchase some chemicals at a local pharmacy.\n\nThe pharmacy sells N kinds of chemicals. For each kind of chemical, there is exactly one package of that chemical in stock.\n\nThe package of chemical i contains a_i grams of the substance A and b_i grams of the substance B, and is sold for c_i yen (the currency of Japan).\n\nDolphin will purchase some of these packages. For some reason, he must use all contents of the purchased packages to generate the substance C.\n\nFind the minimum amount of money required to generate the substance C.\n\nIf it is not possible to generate the substance C by purchasing any combination of packages at the pharmacy, report that fact.\n\nConstraints\n\n1≦N≦40\n\n1≦a_i,b_i≦10\n\n1≦c_i≦100\n\n1≦M_a,M_b≦10\n\ngcd(M_a,M_b)=1\n\na_i, b_i, c_i, M_a and M_b are integers.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN M_a M_b\na_1 b_1 c_1\na_2 b_2 c_2\n:\na_N b_N c_N\n\nOutput\n\nPrint the minimum amount of money required to generate the substance C. If it is not possible to generate the substance C, print -1 instead.\n\nSample Input 1\n\n3 1 1\n1 2 1\n2 1 2\n3 3 10\n\nSample Output 1\n\n3\n\nThe amount of money spent will be minimized by purchasing the packages of chemicals 1 and 2.\n\nIn this case, the mixture of the purchased chemicals will contain 3 grams of the substance A and 3 grams of the substance B, which are in the desired ratio: 3:3=1:1.\n\nThe total price of these packages is 3 yen.\n\nSample Input 2\n\n1 1 10\n10 10 10\n\nSample Output 2\n\n-1\n\nThe ratio 1:10 of the two substances A and B cannot be satisfied by purchasing any combination of the packages. Thus, the output should be -1.", "sample_input": "3 1 1\n1 2 1\n2 1 2\n3 3 10\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03806", "source_text": "Score : 400 points\n\nProblem Statement\n\nDolphin is planning to generate a small amount of a certain chemical substance C.\n\nIn order to generate the substance C, he must prepare a solution which is a mixture of two substances A and B in the ratio of M_a:M_b.\n\nHe does not have any stock of chemicals, however, so he will purchase some chemicals at a local pharmacy.\n\nThe pharmacy sells N kinds of chemicals. For each kind of chemical, there is exactly one package of that chemical in stock.\n\nThe package of chemical i contains a_i grams of the substance A and b_i grams of the substance B, and is sold for c_i yen (the currency of Japan).\n\nDolphin will purchase some of these packages. For some reason, he must use all contents of the purchased packages to generate the substance C.\n\nFind the minimum amount of money required to generate the substance C.\n\nIf it is not possible to generate the substance C by purchasing any combination of packages at the pharmacy, report that fact.\n\nConstraints\n\n1≦N≦40\n\n1≦a_i,b_i≦10\n\n1≦c_i≦100\n\n1≦M_a,M_b≦10\n\ngcd(M_a,M_b)=1\n\na_i, b_i, c_i, M_a and M_b are integers.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN M_a M_b\na_1 b_1 c_1\na_2 b_2 c_2\n:\na_N b_N c_N\n\nOutput\n\nPrint the minimum amount of money required to generate the substance C. If it is not possible to generate the substance C, print -1 instead.\n\nSample Input 1\n\n3 1 1\n1 2 1\n2 1 2\n3 3 10\n\nSample Output 1\n\n3\n\nThe amount of money spent will be minimized by purchasing the packages of chemicals 1 and 2.\n\nIn this case, the mixture of the purchased chemicals will contain 3 grams of the substance A and 3 grams of the substance B, which are in the desired ratio: 3:3=1:1.\n\nThe total price of these packages is 3 yen.\n\nSample Input 2\n\n1 1 10\n10 10 10\n\nSample Output 2\n\n-1\n\nThe ratio 1:10 of the two substances A and B cannot be satisfied by purchasing any combination of the packages. Thus, the output should be -1.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 564, "cpu_time_ms": 83, "memory_kb": 3584}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s060564126", "group_id": "codeNet:p03807", "input_text": "Scanf.scanf \"%d\" (fun n ->\n let a = Array.init n (fun _ -> Scanf.scanf \" %d\" (fun a -> a)) in\n print_endline @@ if Array.fold_left (fun acc v -> acc + v mod 2) 0 a mod 2 = 0 then \"YES\" else \"NO\"\n)", "language": "OCaml", "metadata": {"date": 1596506535, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p03807.html", "problem_id": "p03807", "resource_group": "low_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/OCaml/s060564126.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s060564126", "user_id": "u342443598"}, "prompt_components": {"gold_output": "YES\n", "input_to_evaluate": "Scanf.scanf \"%d\" (fun n ->\n let a = Array.init n (fun _ -> Scanf.scanf \" %d\" (fun a -> a)) in\n print_endline @@ if Array.fold_left (fun acc v -> acc + v mod 2) 0 a mod 2 = 0 then \"YES\" else \"NO\"\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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 41, "memory_kb": 6624}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s672330294", "group_id": "codeNet:p03807", "input_text": "(* O(n) *)\nlet n = Scanf.scanf \" %d\" @@ (+) 0\nlet a_s = Array.init n @@ fun _ -> Scanf.scanf \" %d\" @@ (+) 0\nlet oc = ref 0\nlet _ =\n Array.iter (fun a -> if a mod 2 = 1 then incr oc) a_s;\n print_endline @@ if !oc mod 2 = 0 then \"YES\" else \"NO\"", "language": "OCaml", "metadata": {"date": 1560605357, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03807.html", "problem_id": "p03807", "resource_group": "low_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/OCaml/s672330294.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s672330294", "user_id": "u732304692"}, "prompt_components": {"gold_output": "YES\n", "input_to_evaluate": "(* O(n) *)\nlet n = Scanf.scanf \" %d\" @@ (+) 0\nlet a_s = Array.init n @@ fun _ -> Scanf.scanf \" %d\" @@ (+) 0\nlet oc = ref 0\nlet _ =\n Array.iter (fun a -> if a mod 2 = 1 then incr oc) a_s;\n print_endline @@ if !oc mod 2 = 0 then \"YES\" else \"NO\"", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 33, "memory_kb": 5248}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s355020761", "group_id": "codeNet:p03807", "input_text": "let id x = x\nlet id' x = 1\nlet n = Scanf.scanf \"%d\\n\" id\n\nlet g = (fun () -> Scanf.scanf \"%d\\n\" id)\n \nlet repeat f =\n let rec loop acc = function\n | 0 -> List.rev acc\n | n -> loop (f () :: acc) (n - 1) in\n loop []\n \nlet r = repeat (fun () -> Scanf.scanf \"%d \" id) n\n \nlet rec check = function\n | [a] -> true\n | a :: rest ->\n match rest with\n | [b] -> if (a mod 2) = (b mod 2) then true else false\n | b :: rest2 ->\n\tmatch rest2 with\n\t| c :: rest3 -> if (a mod 2) = (b mod 2) then check ((a+b) :: rest2) else\n\t if (a mod 2) = (c mod 2) then check ((a+c) :: b :: rest3) else check ((b+c) :: a :: rest3)\n\nlet ansbool = check r\n\nlet ans = if ansbool = true then \"YES\" else \"NO\"\n \nlet () = Printf.printf \"%s\\n\" ans\n", "language": "OCaml", "metadata": {"date": 1486265481, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03807.html", "problem_id": "p03807", "resource_group": "low_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/OCaml/s355020761.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s355020761", "user_id": "u735499035"}, "prompt_components": {"gold_output": "YES\n", "input_to_evaluate": "let id x = x\nlet id' x = 1\nlet n = Scanf.scanf \"%d\\n\" id\n\nlet g = (fun () -> Scanf.scanf \"%d\\n\" id)\n \nlet repeat f =\n let rec loop acc = function\n | 0 -> List.rev acc\n | n -> loop (f () :: acc) (n - 1) in\n loop []\n \nlet r = repeat (fun () -> Scanf.scanf \"%d \" id) n\n \nlet rec check = function\n | [a] -> true\n | a :: rest ->\n match rest with\n | [b] -> if (a mod 2) = (b mod 2) then true else false\n | b :: rest2 ->\n\tmatch rest2 with\n\t| c :: rest3 -> if (a mod 2) = (b mod 2) then check ((a+b) :: rest2) else\n\t if (a mod 2) = (c mod 2) then check ((a+c) :: b :: rest3) else check ((b+c) :: a :: rest3)\n\nlet ansbool = check r\n\nlet ans = if ansbool = true then \"YES\" else \"NO\"\n \nlet () = Printf.printf \"%s\\n\" ans\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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 739, "cpu_time_ms": 46, "memory_kb": 7296}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s506315825", "group_id": "codeNet:p03808", "input_text": "open Printf open Scanf\nlet ident v = v\nlet max_listi ls = \n\tlet rec f0 i l v vi = match l with\n\t| [] -> (v,vi)\n\t| h::t ->\n\t\tif (h > v)\n\t\t\tthen f0 (i+1) t h i\n\t\t\telse f0 (i+1) t v vi\n\tin f0 0 ls min_int (-1)\nlet () =\n\tlet n = scanf \" %d\" ident\n\tin let ar = Array.init n (fun _ -> Scanf.scanf \" %d\" (fun v -> v))\n\tin\n\tlet f = ref true\n\tin\n\twhile !f do\n\t\tlet (vmax,imax) = max_listi (Array.to_list ar)\n\t\tin\n\t\t(* printf \"%d,%d\\n\" vmax imax; *)\n\t\tfor i=0 to n-1 do\n\t\t\tlet r =\n\t\t\t\tif i=imax then ar.(i) - n\n\t\t\t\telse ar.(i) - ((i - imax + 2*n) mod n)\n\t\t\tin ar.(i) <- r;\n\t\t\tif r<=0 then f := false;\n\t\tdone;\n\tdone;\n\tArray.fold_left (fun u v -> (\n\t\t(* printf \"%d,\" v; *)\n\t\t(u && v=0))) true ar\n\t|> (fun v -> if v then \"YES\" else \"NO\")\n\t|> printf \"%s\\n\"\t", "language": "OCaml", "metadata": {"date": 1531551644, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03808.html", "problem_id": "p03808", "resource_group": "low_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/OCaml/s506315825.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s506315825", "user_id": "u481480055"}, "prompt_components": {"gold_output": "YES\n", "input_to_evaluate": "open Printf open Scanf\nlet ident v = v\nlet max_listi ls = \n\tlet rec f0 i l v vi = match l with\n\t| [] -> (v,vi)\n\t| h::t ->\n\t\tif (h > v)\n\t\t\tthen f0 (i+1) t h i\n\t\t\telse f0 (i+1) t v vi\n\tin f0 0 ls min_int (-1)\nlet () =\n\tlet n = scanf \" %d\" ident\n\tin let ar = Array.init n (fun _ -> Scanf.scanf \" %d\" (fun v -> v))\n\tin\n\tlet f = ref true\n\tin\n\twhile !f do\n\t\tlet (vmax,imax) = max_listi (Array.to_list ar)\n\t\tin\n\t\t(* printf \"%d,%d\\n\" vmax imax; *)\n\t\tfor i=0 to n-1 do\n\t\t\tlet r =\n\t\t\t\tif i=imax then ar.(i) - n\n\t\t\t\telse ar.(i) - ((i - imax + 2*n) mod n)\n\t\t\tin ar.(i) <- r;\n\t\t\tif r<=0 then f := false;\n\t\tdone;\n\tdone;\n\tArray.fold_left (fun u v -> (\n\t\t(* printf \"%d,\" v; *)\n\t\t(u && v=0))) true ar\n\t|> (fun v -> if v then \"YES\" else \"NO\")\n\t|> printf \"%s\\n\"\t", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 743, "cpu_time_ms": 2104, "memory_kb": 13360}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s110269363", "group_id": "codeNet:p03813", "input_text": "let () =\n let x = Scanf.scanf \"%d \" (fun a -> a) in\n Printf.printf \"%s\\n\" (if x < 1200 then \"ABC\" else \"ARC\")", "language": "OCaml", "metadata": {"date": 1526214587, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03813.html", "problem_id": "p03813", "resource_group": "low_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/OCaml/s110269363.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s110269363", "user_id": "u139013163"}, "prompt_components": {"gold_output": "ABC\n", "input_to_evaluate": "let () =\n let x = Scanf.scanf \"%d \" (fun a -> a) in\n Printf.printf \"%s\\n\" (if x < 1200 then \"ABC\" else \"ARC\")", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s467406073", "group_id": "codeNet:p03816", "input_text": "let n = read_int ()\n\nlet arr = Array.make 100001 0\n\nlet rec f i odd even =\n if i = n then (odd, even)\n else\n let j = Scanf.scanf \" %d\" (fun a -> a) in\n if 0 = arr.(j) then (ignore (arr.(j) <- 1); f (i+1) (odd + 1) even)\n else if 1 = arr.(j) then (ignore (arr.(j) <- 2); f (i + 1) (odd - 1) (even + 1))\n else (ignore (arr.(j) <- 1); f (i + 1) (odd + 1) (even - 1))\n \nlet odd, even = f 0 0 0\n\nlet () = print_int (odd + even / 2 * 2)", "language": "OCaml", "metadata": {"date": 1585598362, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03816.html", "problem_id": "p03816", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03816/input.txt", "sample_output_relpath": "derived/input_output/data/p03816/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03816/OCaml/s467406073.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s467406073", "user_id": "u752907799"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "let n = read_int ()\n\nlet arr = Array.make 100001 0\n\nlet rec f i odd even =\n if i = n then (odd, even)\n else\n let j = Scanf.scanf \" %d\" (fun a -> a) in\n if 0 = arr.(j) then (ignore (arr.(j) <- 1); f (i+1) (odd + 1) even)\n else if 1 = arr.(j) then (ignore (arr.(j) <- 2); f (i + 1) (odd - 1) (even + 1))\n else (ignore (arr.(j) <- 1); f (i + 1) (odd + 1) (even - 1))\n \nlet odd, even = f 0 0 0\n\nlet () = print_int (odd + even / 2 * 2)", "problem_context": "Score : 400 points\n\nProblem Statement\n\nSnuke has decided to play a game using cards.\nHe has a deck consisting of N cards. On the i-th card from the top, an integer A_i is written.\n\nHe will perform the operation described below zero or more times, so that the values written on the remaining cards will be pairwise distinct. Find the maximum possible number of remaining cards. Here, N is odd, which guarantees that at least one card can be kept.\n\nOperation: Take out three arbitrary cards from the deck. Among those three cards, eat two: one with the largest value, and another with the smallest value. Then, return the remaining one card to the deck.\n\nConstraints\n\n3 ≦ N ≦ 10^{5}\n\nN is odd.\n\n1 ≦ A_i ≦ 10^{5}\n\nA_i is an integer.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\nA_1 A_2 A_3 ... A_{N}\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n5\n1 2 1 3 7\n\nSample Output 1\n\n3\n\nOne optimal solution is to perform the operation once, taking out two cards with 1 and one card with 2. One card with 1 and another with 2 will be eaten, and the remaining card with 1 will be returned to deck. Then, the values written on the remaining cards in the deck will be pairwise distinct: 1, 3 and 7.\n\nSample Input 2\n\n15\n1 3 5 2 1 3 2 8 8 6 2 6 11 1 1\n\nSample Output 2\n\n7", "sample_input": "5\n1 2 1 3 7\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03816", "source_text": "Score : 400 points\n\nProblem Statement\n\nSnuke has decided to play a game using cards.\nHe has a deck consisting of N cards. On the i-th card from the top, an integer A_i is written.\n\nHe will perform the operation described below zero or more times, so that the values written on the remaining cards will be pairwise distinct. Find the maximum possible number of remaining cards. Here, N is odd, which guarantees that at least one card can be kept.\n\nOperation: Take out three arbitrary cards from the deck. Among those three cards, eat two: one with the largest value, and another with the smallest value. Then, return the remaining one card to the deck.\n\nConstraints\n\n3 ≦ N ≦ 10^{5}\n\nN is odd.\n\n1 ≦ A_i ≦ 10^{5}\n\nA_i is an integer.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\nA_1 A_2 A_3 ... A_{N}\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n5\n1 2 1 3 7\n\nSample Output 1\n\n3\n\nOne optimal solution is to perform the operation once, taking out two cards with 1 and one card with 2. One card with 1 and another with 2 will be eaten, and the remaining card with 1 will be returned to deck. Then, the values written on the remaining cards in the deck will be pairwise distinct: 1, 3 and 7.\n\nSample Input 2\n\n15\n1 3 5 2 1 3 2 8 8 6 2 6 11 1 1\n\nSample Output 2\n\n7", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 26, "memory_kb": 5376}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s183895803", "group_id": "codeNet:p03817", "input_text": "let () = Scanf.scanf \"%d\" (fun x ->\n Printf.printf \"%d\\n\" @@ x / 11 * 2 + if 6 < x mod 11 then 2 else 1)", "language": "OCaml", "metadata": {"date": 1510514719, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03817.html", "problem_id": "p03817", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03817/input.txt", "sample_output_relpath": "derived/input_output/data/p03817/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03817/OCaml/s183895803.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s183895803", "user_id": "u504158101"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "let () = Scanf.scanf \"%d\" (fun x ->\n Printf.printf \"%d\\n\" @@ x / 11 * 2 + if 6 < x mod 11 then 2 else 1)", "problem_context": "Score : 300 points\n\nProblem Statement\n\nSnuke has decided to play with a six-sided die. Each of its six sides shows an integer 1 through 6, and two numbers on opposite sides always add up to 7.\n\nSnuke will first put the die on the table with an arbitrary side facing upward, then repeatedly perform the following operation:\n\nOperation: Rotate the die 90° toward one of the following directions: left, right, front (the die will come closer) and back (the die will go farther). Then, obtain y points where y is the number written in the side facing upward.\n\nFor example, let us consider the situation where the side showing 1 faces upward, the near side shows 5 and the right side shows 4, as illustrated in the figure.\nIf the die is rotated toward the right as shown in the figure, the side showing 3 will face upward.\nBesides, the side showing 4 will face upward if the die is rotated toward the left, the side showing 2 will face upward if the die is rotated toward the front, and the side showing 5 will face upward if the die is rotated toward the back.\n\nFind the minimum number of operation Snuke needs to perform in order to score at least x points in total.\n\nConstraints\n\n1 ≦ x ≦ 10^{15}\n\nx is an integer.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nx\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n7\n\nSample Output 1\n\n2\n\nSample Input 2\n\n149696127901\n\nSample Output 2\n\n27217477801", "sample_input": "7\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03817", "source_text": "Score : 300 points\n\nProblem Statement\n\nSnuke has decided to play with a six-sided die. Each of its six sides shows an integer 1 through 6, and two numbers on opposite sides always add up to 7.\n\nSnuke will first put the die on the table with an arbitrary side facing upward, then repeatedly perform the following operation:\n\nOperation: Rotate the die 90° toward one of the following directions: left, right, front (the die will come closer) and back (the die will go farther). Then, obtain y points where y is the number written in the side facing upward.\n\nFor example, let us consider the situation where the side showing 1 faces upward, the near side shows 5 and the right side shows 4, as illustrated in the figure.\nIf the die is rotated toward the right as shown in the figure, the side showing 3 will face upward.\nBesides, the side showing 4 will face upward if the die is rotated toward the left, the side showing 2 will face upward if the die is rotated toward the front, and the side showing 5 will face upward if the die is rotated toward the back.\n\nFind the minimum number of operation Snuke needs to perform in order to score at least x points in total.\n\nConstraints\n\n1 ≦ x ≦ 10^{15}\n\nx is an integer.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nx\n\nOutput\n\nPrint the answer.\n\nSample Input 1\n\n7\n\nSample Output 1\n\n2\n\nSample Input 2\n\n149696127901\n\nSample Output 2\n\n27217477801", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s197421279", "group_id": "codeNet:p03821", "input_text": "Scanf.scanf \"%d\" (fun n ->\n let ab = Array.init n (fun _ -> Scanf.scanf \" %d %d\" (fun a b -> a, b)) in\n\n let rec loop i acc =\n if i < 0 then acc else\n let a, b = ab.(i) in\n let c = (a + acc + b - 1) / b * b - a - acc in\n loop (i - 1) (acc + c)\n in\n loop (n - 1) 0 |> Printf.printf \"%d\\n\"\n)", "language": "OCaml", "metadata": {"date": 1595386893, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p03821.html", "problem_id": "p03821", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03821/input.txt", "sample_output_relpath": "derived/input_output/data/p03821/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03821/OCaml/s197421279.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s197421279", "user_id": "u342443598"}, "prompt_components": {"gold_output": "7\n", "input_to_evaluate": "Scanf.scanf \"%d\" (fun n ->\n let ab = Array.init n (fun _ -> Scanf.scanf \" %d %d\" (fun a b -> a, b)) in\n\n let rec loop i acc =\n if i < 0 then acc else\n let a, b = ab.(i) in\n let c = (a + acc + b - 1) / b * b - a - acc in\n loop (i - 1) (acc + c)\n in\n loop (n - 1) 0 |> Printf.printf \"%d\\n\"\n)", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere are an integer sequence A_1,...,A_N consisting of N terms, and N buttons.\nWhen the i-th (1 ≦ i ≦ N) button is pressed, the values of the i terms from the first through the i-th are all incremented by 1.\n\nThere is also another integer sequence B_1,...,B_N. Takahashi will push the buttons some number of times so that for every i, A_i will be a multiple of B_i.\n\nFind the minimum number of times Takahashi will press the buttons.\n\nConstraints\n\nAll input values are integers.\n\n1 ≦ N ≦ 10^5\n\n0 ≦ A_i ≦ 10^9(1 ≦ i ≦ N)\n\n1 ≦ B_i ≦ 10^9(1 ≦ i ≦ N)\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\nA_1 B_1\n:\nA_N B_N\n\nOutput\n\nPrint an integer representing the minimum number of times Takahashi will press the buttons.\n\nSample Input 1\n\n3\n3 5\n2 7\n9 4\n\nSample Output 1\n\n7\n\nPress the first button twice, the second button twice and the third button three times.\n\nSample Input 2\n\n7\n3 1\n4 1\n5 9\n2 6\n5 3\n5 8\n9 7\n\nSample Output 2\n\n22", "sample_input": "3\n3 5\n2 7\n9 4\n"}, "reference_outputs": ["7\n"], "source_document_id": "p03821", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere are an integer sequence A_1,...,A_N consisting of N terms, and N buttons.\nWhen the i-th (1 ≦ i ≦ N) button is pressed, the values of the i terms from the first through the i-th are all incremented by 1.\n\nThere is also another integer sequence B_1,...,B_N. Takahashi will push the buttons some number of times so that for every i, A_i will be a multiple of B_i.\n\nFind the minimum number of times Takahashi will press the buttons.\n\nConstraints\n\nAll input values are integers.\n\n1 ≦ N ≦ 10^5\n\n0 ≦ A_i ≦ 10^9(1 ≦ i ≦ N)\n\n1 ≦ B_i ≦ 10^9(1 ≦ i ≦ N)\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\nA_1 B_1\n:\nA_N B_N\n\nOutput\n\nPrint an integer representing the minimum number of times Takahashi will press the buttons.\n\nSample Input 1\n\n3\n3 5\n2 7\n9 4\n\nSample Output 1\n\n7\n\nPress the first button twice, the second button twice and the third button three times.\n\nSample Input 2\n\n7\n3 1\n4 1\n5 9\n2 6\n5 3\n5 8\n9 7\n\nSample Output 2\n\n22", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 60, "memory_kb": 9320}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s669033389", "group_id": "codeNet:p03822", "input_text": "module type OrderedType =\n sig\n type t\n val compare: t -> t -> int\n end\n\ntype z = Z_\ntype 'n s = S_ : 'n -> 'n s\ntype _ nat =\n | Z : z nat\n | S : 'n nat -> 'n s nat\n\ntype (_, _) le =\n | LeEq : ('n, 'n) le\n | LeS : ('n, 'm) le -> ('n, 'm s) le\n\nlet rec le_n_s : type n m. (n, m) le -> (n s, m s) le = function\n | LeEq -> LeEq\n | LeS hle -> LeS (le_n_s hle)\n\nlet rec le_0_n : type n. n nat -> (z, n) le = function\n | Z -> LeEq\n | S n -> LeS (le_0_n n)\n\nlet rec le_ge_dec : type n m. n nat -> m nat -> [ `InL of (n, m) le | `InR of (m, n) le ] =\n fun n m ->\n match n, m with\n | Z, _ -> `InL (le_0_n m)\n | _, Z -> `InR (le_0_n n)\n | S n', S m' ->\n begin match le_ge_dec n' m' with\n | `InL hle -> `InL (le_n_s hle)\n | `InR hge -> `InR (le_n_s hge)\n end\n\nmodule type HEAP = sig\n type elt\n type t\n\n val empty : t\n val singleton : elt -> t\n val merge : t -> t -> t\n val insert : elt -> t -> t\n val find_min : t -> elt option\n val delete_min : t -> t option\nend\n\nmodule BinomialHeap (O : OrderedType) : HEAP with type elt = O.t = struct\n type elt = O.t\n\n type 'n tree = Node of elt * 'n tree_vector\n and _ tree_vector =\n | TNil : z tree_vector\n | TCons : 'n tree * 'n tree_vector -> 'n s tree_vector\n\n type _ tree_opt_vector =\n | TONil : z tree_opt_vector\n | TOCons : 'n tree option * 'n tree_opt_vector -> 'n s tree_opt_vector\n\n type t = T : 'n nat * 'n tree_opt_vector -> t\n\n let rec tree_opt_vector_of_tree_vector : type n. n tree_vector -> n tree_opt_vector = function\n | TNil -> TONil\n | TCons (t, tv) -> TOCons (Some t, tree_opt_vector_of_tree_vector tv)\n\n let merge_tree (Node (e1, ts1) as t1) (Node (e2, ts2) as t2) =\n if O.compare e1 e2 < 0 then Node (e1, TCons (t2, ts1))\n else Node (e2, TCons (t1, ts2))\n\n let rec merge_tree_opt_vector : type n. n tree_opt_vector -> n tree_opt_vector -> n tree_opt_vector * n tree option = fun tov1 tov2 ->\n match tov1, tov2 with\n | TONil, TONil -> (TONil, None)\n | TOCons (to1, tov1'), TOCons (to2, tov2') ->\n let (tov12, to3) = merge_tree_opt_vector tov1' tov2' in\n begin match to1, to2, to3 with\n | _, None, None -> (TOCons (to1, tov12), None)\n | None, _, None -> (TOCons (to2, tov12), None)\n | None, None, _ -> (TOCons (to3, tov12), None)\n | _, Some t2, Some t3 -> (TOCons (to1, tov12), Some (merge_tree t2 t3))\n | Some t1, _, Some t3 -> (TOCons (to2, tov12), Some (merge_tree t1 t3))\n | Some t1, Some t2, _ -> (TOCons (to3, tov12), Some (merge_tree t1 t2))\n end\n\n let delete_min_tree_opt_vector_aux1 tov = function\n | None -> None\n | Some (Node (e, tv)) -> \n Some (e, fun () ->\n let (tov', to0) = merge_tree_opt_vector tov (tree_opt_vector_of_tree_vector tv) in\n TOCons (to0, tov'))\n\n let delete_min_tree_opt_vector_aux2 to0 = function\n | None -> None\n | Some (e, tov) -> Some (e, fun () -> TOCons (to0, tov ()))\n\n let rec delete_min_tree_opt_vector : type n. n tree_opt_vector -> (elt * (unit -> n tree_opt_vector)) option = function\n | TONil -> None\n | TOCons (to0, tov) ->\n begin match delete_min_tree_opt_vector_aux1 tov to0, delete_min_tree_opt_vector_aux2 to0 (delete_min_tree_opt_vector tov) with\n | None, None -> None\n | (Some _ as result1), None -> result1\n | None, (Some _ as result2) -> result2\n | (Some (e1, _) as result1), (Some (e2, _) as result2) ->\n if O.compare e1 e2 < 0 then result1\n else result2\n end\n\n let rec padding : type n m. n tree_opt_vector -> (n, m) le -> m tree_opt_vector = fun t hle ->\n match hle with\n | LeEq -> t\n | LeS hle' -> TOCons (None, padding t hle')\n\n let empty = T (Z, TONil)\n let singleton e = T (S Z, TOCons (Some (Node (e, TNil)), TONil))\n\n let merge (T (n1, tov1)) (T (n2, tov2)) =\n match le_ge_dec n1 n2 with\n | `InL hle ->\n begin match merge_tree_opt_vector (padding tov1 hle) tov2 with\n | tov', None -> T (n2, tov')\n | tov', (Some _ as to0) -> T (S n2, TOCons (to0, tov'))\n end\n | `InR hgt ->\n begin match merge_tree_opt_vector tov1 (padding tov2 hgt) with\n | tov', None -> T (n1, tov')\n | tov', (Some _ as to0) -> T (S n1, TOCons (to0, tov'))\n end\n\n let insert e t = merge (singleton e) t\n\n let find_min (T (_, tov)) =\n match delete_min_tree_opt_vector tov with\n | None -> None\n | Some (e, _) -> Some e\n\n let delete_min (T (n, tov)) =\n match delete_min_tree_opt_vector tov with\n | None -> None\n | Some (_, tov') ->\n begin match n, tov' () with\n | S n', TOCons (None, tov'') -> Some (T (n', tov''))\n | _, tov'' -> Some (T (n, tov''))\n end\nend\n\nmodule IntHeap = BinomialHeap (struct\n type t = int\n let compare = compare\nend)\n\nlet rec balance ts =\n let Some d = IntHeap.find_min ts in\n let Some ts' = IntHeap.delete_min ts in\n match IntHeap.find_min ts' with\n | None -> d\n | Some d' ->\n let Some ts'' = IntHeap.delete_min ts' in\n balance (IntHeap.insert (1 + max d d') ts'')\n\nlet rec make_tournament losers winner =\n List.map (make_tournament losers) (losers winner)\n |> List.fold_left (fun s d -> IntHeap.insert d s) (IntHeap.singleton 0)\n |> balance\n\nlet () =\n let n = Scanf.scanf \"%d\\n\" (fun n -> n) in\n let as_ = Array.init (n - 1) (fun _ -> Scanf.scanf \"%d\\n\" (fun a -> a)) in\n let losers = Array.make n [] in\n Array.iteri (fun i a ->\n losers.(a - 1) <- i + 1 :: losers.(a - 1)) as_;\n Printf.printf \"%d\\n\" (make_tournament (fun i -> losers.(i)) 0)\n", "language": "OCaml", "metadata": {"date": 1485143910, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03822.html", "problem_id": "p03822", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03822/input.txt", "sample_output_relpath": "derived/input_output/data/p03822/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03822/OCaml/s669033389.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s669033389", "user_id": "u504158101"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "module type OrderedType =\n sig\n type t\n val compare: t -> t -> int\n end\n\ntype z = Z_\ntype 'n s = S_ : 'n -> 'n s\ntype _ nat =\n | Z : z nat\n | S : 'n nat -> 'n s nat\n\ntype (_, _) le =\n | LeEq : ('n, 'n) le\n | LeS : ('n, 'm) le -> ('n, 'm s) le\n\nlet rec le_n_s : type n m. (n, m) le -> (n s, m s) le = function\n | LeEq -> LeEq\n | LeS hle -> LeS (le_n_s hle)\n\nlet rec le_0_n : type n. n nat -> (z, n) le = function\n | Z -> LeEq\n | S n -> LeS (le_0_n n)\n\nlet rec le_ge_dec : type n m. n nat -> m nat -> [ `InL of (n, m) le | `InR of (m, n) le ] =\n fun n m ->\n match n, m with\n | Z, _ -> `InL (le_0_n m)\n | _, Z -> `InR (le_0_n n)\n | S n', S m' ->\n begin match le_ge_dec n' m' with\n | `InL hle -> `InL (le_n_s hle)\n | `InR hge -> `InR (le_n_s hge)\n end\n\nmodule type HEAP = sig\n type elt\n type t\n\n val empty : t\n val singleton : elt -> t\n val merge : t -> t -> t\n val insert : elt -> t -> t\n val find_min : t -> elt option\n val delete_min : t -> t option\nend\n\nmodule BinomialHeap (O : OrderedType) : HEAP with type elt = O.t = struct\n type elt = O.t\n\n type 'n tree = Node of elt * 'n tree_vector\n and _ tree_vector =\n | TNil : z tree_vector\n | TCons : 'n tree * 'n tree_vector -> 'n s tree_vector\n\n type _ tree_opt_vector =\n | TONil : z tree_opt_vector\n | TOCons : 'n tree option * 'n tree_opt_vector -> 'n s tree_opt_vector\n\n type t = T : 'n nat * 'n tree_opt_vector -> t\n\n let rec tree_opt_vector_of_tree_vector : type n. n tree_vector -> n tree_opt_vector = function\n | TNil -> TONil\n | TCons (t, tv) -> TOCons (Some t, tree_opt_vector_of_tree_vector tv)\n\n let merge_tree (Node (e1, ts1) as t1) (Node (e2, ts2) as t2) =\n if O.compare e1 e2 < 0 then Node (e1, TCons (t2, ts1))\n else Node (e2, TCons (t1, ts2))\n\n let rec merge_tree_opt_vector : type n. n tree_opt_vector -> n tree_opt_vector -> n tree_opt_vector * n tree option = fun tov1 tov2 ->\n match tov1, tov2 with\n | TONil, TONil -> (TONil, None)\n | TOCons (to1, tov1'), TOCons (to2, tov2') ->\n let (tov12, to3) = merge_tree_opt_vector tov1' tov2' in\n begin match to1, to2, to3 with\n | _, None, None -> (TOCons (to1, tov12), None)\n | None, _, None -> (TOCons (to2, tov12), None)\n | None, None, _ -> (TOCons (to3, tov12), None)\n | _, Some t2, Some t3 -> (TOCons (to1, tov12), Some (merge_tree t2 t3))\n | Some t1, _, Some t3 -> (TOCons (to2, tov12), Some (merge_tree t1 t3))\n | Some t1, Some t2, _ -> (TOCons (to3, tov12), Some (merge_tree t1 t2))\n end\n\n let delete_min_tree_opt_vector_aux1 tov = function\n | None -> None\n | Some (Node (e, tv)) -> \n Some (e, fun () ->\n let (tov', to0) = merge_tree_opt_vector tov (tree_opt_vector_of_tree_vector tv) in\n TOCons (to0, tov'))\n\n let delete_min_tree_opt_vector_aux2 to0 = function\n | None -> None\n | Some (e, tov) -> Some (e, fun () -> TOCons (to0, tov ()))\n\n let rec delete_min_tree_opt_vector : type n. n tree_opt_vector -> (elt * (unit -> n tree_opt_vector)) option = function\n | TONil -> None\n | TOCons (to0, tov) ->\n begin match delete_min_tree_opt_vector_aux1 tov to0, delete_min_tree_opt_vector_aux2 to0 (delete_min_tree_opt_vector tov) with\n | None, None -> None\n | (Some _ as result1), None -> result1\n | None, (Some _ as result2) -> result2\n | (Some (e1, _) as result1), (Some (e2, _) as result2) ->\n if O.compare e1 e2 < 0 then result1\n else result2\n end\n\n let rec padding : type n m. n tree_opt_vector -> (n, m) le -> m tree_opt_vector = fun t hle ->\n match hle with\n | LeEq -> t\n | LeS hle' -> TOCons (None, padding t hle')\n\n let empty = T (Z, TONil)\n let singleton e = T (S Z, TOCons (Some (Node (e, TNil)), TONil))\n\n let merge (T (n1, tov1)) (T (n2, tov2)) =\n match le_ge_dec n1 n2 with\n | `InL hle ->\n begin match merge_tree_opt_vector (padding tov1 hle) tov2 with\n | tov', None -> T (n2, tov')\n | tov', (Some _ as to0) -> T (S n2, TOCons (to0, tov'))\n end\n | `InR hgt ->\n begin match merge_tree_opt_vector tov1 (padding tov2 hgt) with\n | tov', None -> T (n1, tov')\n | tov', (Some _ as to0) -> T (S n1, TOCons (to0, tov'))\n end\n\n let insert e t = merge (singleton e) t\n\n let find_min (T (_, tov)) =\n match delete_min_tree_opt_vector tov with\n | None -> None\n | Some (e, _) -> Some e\n\n let delete_min (T (n, tov)) =\n match delete_min_tree_opt_vector tov with\n | None -> None\n | Some (_, tov') ->\n begin match n, tov' () with\n | S n', TOCons (None, tov'') -> Some (T (n', tov''))\n | _, tov'' -> Some (T (n, tov''))\n end\nend\n\nmodule IntHeap = BinomialHeap (struct\n type t = int\n let compare = compare\nend)\n\nlet rec balance ts =\n let Some d = IntHeap.find_min ts in\n let Some ts' = IntHeap.delete_min ts in\n match IntHeap.find_min ts' with\n | None -> d\n | Some d' ->\n let Some ts'' = IntHeap.delete_min ts' in\n balance (IntHeap.insert (1 + max d d') ts'')\n\nlet rec make_tournament losers winner =\n List.map (make_tournament losers) (losers winner)\n |> List.fold_left (fun s d -> IntHeap.insert d s) (IntHeap.singleton 0)\n |> balance\n\nlet () =\n let n = Scanf.scanf \"%d\\n\" (fun n -> n) in\n let as_ = Array.init (n - 1) (fun _ -> Scanf.scanf \"%d\\n\" (fun a -> a)) in\n let losers = Array.make n [] in\n Array.iteri (fun i a ->\n losers.(a - 1) <- i + 1 :: losers.(a - 1)) as_;\n Printf.printf \"%d\\n\" (make_tournament (fun i -> losers.(i)) 0)\n", "problem_context": "Score : 800 points\n\nProblem Statement\n\nN contestants participated in a competition. The total of N-1 matches were played in a knockout tournament.\nFor some reasons, the tournament may not be \"fair\" for all the contestants.\nThat is, the number of the matches that must be played in order to win the championship may be different for each contestant. The structure of the tournament is formally described at the end of this statement.\n\nAfter each match, there were always one winner and one loser. The last contestant standing was declared the champion.\n\nFigure: an example of a tournament\n\nFor convenience, the contestants were numbered 1 through N. The contestant numbered 1 was the champion, and the contestant numbered i(2 ≦ i ≦ N) was defeated in a match against the contestant numbered a_i.\n\nWe will define the depth of the tournament as the maximum number of the matches that must be played in order to win the championship over all the contestants.\n\nFind the minimum possible depth of the tournament.\n\nThe formal description of the structure of the tournament is as follows. In the i-th match, one of the following played against each other:\n\nTwo predetermined contestants\n\nOne predetermined contestant and the winner of the j-th match, where j(j (d, t, IntMap.remove d ts)\n | (d, t :: tt) -> (d, t, IntMap.add d tt ts) in\n match IntMap.min_binding ts' with\n | d', [t'] ->\n let ts'' = IntMap.remove d' ts' in\n let d'' = 1 + max d d' in\n balance (IntMap.add d'' (Node (t, t') :: try IntMap.find d'' ts'' with Not_found -> []) ts'')\n | d', t' :: tt ->\n let ts'' = IntMap.add d' tt ts' in\n let d'' = 1 + max d d' in\n balance (IntMap.add d'' (Node (t, t') :: try IntMap.find d'' ts'' with Not_found -> []) ts'')\n | exception Not_found -> (d, t)\n\nlet rec make_tournament losers winner =\n List.map (make_tournament losers) (losers winner)\n |> List.fold_left (fun s (d, t) ->\n IntMap.add d (t :: try IntMap.find d s with Not_found -> []) s)\n (IntMap.singleton 0 [Leaf winner])\n |> balance\n\nlet () =\n let n = Scanf.scanf \"%d\\n\" (fun n -> n) in\n let as_ = Array.init (n - 1) (fun _ -> Scanf.scanf \"%d\\n\" (fun a -> a)) in\n let losers = Array.make n [] in\n Array.iteri (fun i a ->\n losers.(a - 1) <- i + 1 :: losers.(a - 1)) as_;\n Printf.printf \"%d\\n\" @@ fst @@ make_tournament (fun i -> losers.(i)) 0\n", "language": "OCaml", "metadata": {"date": 1485142692, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03822.html", "problem_id": "p03822", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03822/input.txt", "sample_output_relpath": "derived/input_output/data/p03822/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03822/OCaml/s439519525.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s439519525", "user_id": "u504158101"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "type t = Node of t * t | Leaf of int\n\nmodule IntMap = Map.Make (struct\n type t = int\n let compare = compare\nend)\n\nlet rec balance ts =\n let d, t, ts' =\n match IntMap.min_binding ts with\n | (d, [t]) -> (d, t, IntMap.remove d ts)\n | (d, t :: tt) -> (d, t, IntMap.add d tt ts) in\n match IntMap.min_binding ts' with\n | d', [t'] ->\n let ts'' = IntMap.remove d' ts' in\n let d'' = 1 + max d d' in\n balance (IntMap.add d'' (Node (t, t') :: try IntMap.find d'' ts'' with Not_found -> []) ts'')\n | d', t' :: tt ->\n let ts'' = IntMap.add d' tt ts' in\n let d'' = 1 + max d d' in\n balance (IntMap.add d'' (Node (t, t') :: try IntMap.find d'' ts'' with Not_found -> []) ts'')\n | exception Not_found -> (d, t)\n\nlet rec make_tournament losers winner =\n List.map (make_tournament losers) (losers winner)\n |> List.fold_left (fun s (d, t) ->\n IntMap.add d (t :: try IntMap.find d s with Not_found -> []) s)\n (IntMap.singleton 0 [Leaf winner])\n |> balance\n\nlet () =\n let n = Scanf.scanf \"%d\\n\" (fun n -> n) in\n let as_ = Array.init (n - 1) (fun _ -> Scanf.scanf \"%d\\n\" (fun a -> a)) in\n let losers = Array.make n [] in\n Array.iteri (fun i a ->\n losers.(a - 1) <- i + 1 :: losers.(a - 1)) as_;\n Printf.printf \"%d\\n\" @@ fst @@ make_tournament (fun i -> losers.(i)) 0\n", "problem_context": "Score : 800 points\n\nProblem Statement\n\nN contestants participated in a competition. The total of N-1 matches were played in a knockout tournament.\nFor some reasons, the tournament may not be \"fair\" for all the contestants.\nThat is, the number of the matches that must be played in order to win the championship may be different for each contestant. The structure of the tournament is formally described at the end of this statement.\n\nAfter each match, there were always one winner and one loser. The last contestant standing was declared the champion.\n\nFigure: an example of a tournament\n\nFor convenience, the contestants were numbered 1 through N. The contestant numbered 1 was the champion, and the contestant numbered i(2 ≦ i ≦ N) was defeated in a match against the contestant numbered a_i.\n\nWe will define the depth of the tournament as the maximum number of the matches that must be played in order to win the championship over all the contestants.\n\nFind the minimum possible depth of the tournament.\n\nThe formal description of the structure of the tournament is as follows. In the i-th match, one of the following played against each other:\n\nTwo predetermined contestants\n\nOne predetermined contestant and the winner of the j-th match, where j(j\n Printf.printf \"%d\\n\" @@ max (a * b) (c * d)\n)", "language": "OCaml", "metadata": {"date": 1597895477, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p03826.html", "problem_id": "p03826", "resource_group": "low_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/OCaml/s561918726.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s561918726", "user_id": "u342443598"}, "prompt_components": {"gold_output": "15\n", "input_to_evaluate": "Scanf.scanf \"%d %d %d %d\" (fun a b c d ->\n Printf.printf \"%d\\n\" @@ max (a * b) (c * d)\n)", "problem_context": "Score : 100 points\n\nProblem Statement\n\nThere are two rectangles.\nThe lengths of the vertical sides of the first rectangle are A, and the lengths of the horizontal sides of the first rectangle are B.\nThe lengths of the vertical sides of the second rectangle are C, and the lengths of the horizontal sides of the second rectangle are D.\n\nPrint the area of the rectangle with the larger area.\nIf the two rectangles have equal areas, print that area.\n\nConstraints\n\nAll input values are integers.\n\n1≤A≤10^4\n\n1≤B≤10^4\n\n1≤C≤10^4\n\n1≤D≤10^4\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nA B C D\n\nOutput\n\nPrint the area of the rectangle with the larger area.\nIf the two rectangles have equal areas, print that area.\n\nSample Input 1\n\n3 5 2 7\n\nSample Output 1\n\n15\n\nThe first rectangle has an area of 3×5=15, and the second rectangle has an area of 2×7=14.\nThus, the output should be 15, the larger area.\n\nSample Input 2\n\n100 600 200 300\n\nSample Output 2\n\n60000", "sample_input": "3 5 2 7\n"}, "reference_outputs": ["15\n"], "source_document_id": "p03826", "source_text": "Score : 100 points\n\nProblem Statement\n\nThere are two rectangles.\nThe lengths of the vertical sides of the first rectangle are A, and the lengths of the horizontal sides of the first rectangle are B.\nThe lengths of the vertical sides of the second rectangle are C, and the lengths of the horizontal sides of the second rectangle are D.\n\nPrint the area of the rectangle with the larger area.\nIf the two rectangles have equal areas, print that area.\n\nConstraints\n\nAll input values are integers.\n\n1≤A≤10^4\n\n1≤B≤10^4\n\n1≤C≤10^4\n\n1≤D≤10^4\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nA B C D\n\nOutput\n\nPrint the area of the rectangle with the larger area.\nIf the two rectangles have equal areas, print that area.\n\nSample Input 1\n\n3 5 2 7\n\nSample Output 1\n\n15\n\nThe first rectangle has an area of 3×5=15, and the second rectangle has an area of 2×7=14.\nThus, the output should be 15, the larger area.\n\nSample Input 2\n\n100 600 200 300\n\nSample Output 2\n\n60000", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 4, "memory_kb": 3844}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s042582667", "group_id": "codeNet:p03827", "input_text": "let (|>) x f = f x ;;\nlet n = Scanf.scanf \"%d\\n\" (fun n -> n) ;;\nlet s = Scanf.scanf \"%s\\n\" (fun s -> s) ;;\n\nlet string_to_list str =\n let id_to_int c =\n if c = 'I' then 1\n else -1\n in\n let rec loop idx arr=\n if idx = -1 then arr\n else loop (idx-1) ((id_to_int (String.get str idx))::arr)\n in\n loop (n-1) []\n;;\n\nlet solve arr =\n let rec sim ma v arr = \n match arr with\n | [] -> ma\n | h::t ->\n let w = v + h in\n let new_max = max ma w in\n sim new_max w t\n in\n sim 0 0 arr\n;;\n\nlet () =\n s\n |> string_to_list\n |> solve\n |> Printf.printf \"%d\\n\"\n", "language": "OCaml", "metadata": {"date": 1531111338, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03827.html", "problem_id": "p03827", "resource_group": "low_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/OCaml/s042582667.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s042582667", "user_id": "u957084285"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "let (|>) x f = f x ;;\nlet n = Scanf.scanf \"%d\\n\" (fun n -> n) ;;\nlet s = Scanf.scanf \"%s\\n\" (fun s -> s) ;;\n\nlet string_to_list str =\n let id_to_int c =\n if c = 'I' then 1\n else -1\n in\n let rec loop idx arr=\n if idx = -1 then arr\n else loop (idx-1) ((id_to_int (String.get str idx))::arr)\n in\n loop (n-1) []\n;;\n\nlet solve arr =\n let rec sim ma v arr = \n match arr with\n | [] -> ma\n | h::t ->\n let w = v + h in\n let new_max = max ma w in\n sim new_max w t\n in\n sim 0 0 arr\n;;\n\nlet () =\n s\n |> string_to_list\n |> solve\n |> Printf.printf \"%d\\n\"\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nYou have an integer variable x.\nInitially, x=0.\n\nSome person gave you a string S of length N, and using the string you performed the following operation N times.\nIn the i-th operation, you incremented the value of x by 1 if S_i=I, and decremented the value of x by 1 if S_i=D.\n\nFind the maximum value taken by x during the operations (including before the first operation, and after the last operation).\n\nConstraints\n\n1≤N≤100\n\n|S|=N\n\nNo characters except I and D occur in S.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\nS\n\nOutput\n\nPrint the maximum value taken by x during the operations.\n\nSample Input 1\n\n5\nIIDID\n\nSample Output 1\n\n2\n\nAfter each operation, the value of x becomes 1, 2, 1, 2 and 1, respectively. Thus, the output should be 2, the maximum value.\n\nSample Input 2\n\n7\nDDIDDII\n\nSample Output 2\n\n0\n\nThe initial value x=0 is the maximum value taken by x, thus the output should be 0.", "sample_input": "5\nIIDID\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03827", "source_text": "Score : 200 points\n\nProblem Statement\n\nYou have an integer variable x.\nInitially, x=0.\n\nSome person gave you a string S of length N, and using the string you performed the following operation N times.\nIn the i-th operation, you incremented the value of x by 1 if S_i=I, and decremented the value of x by 1 if S_i=D.\n\nFind the maximum value taken by x during the operations (including before the first operation, and after the last operation).\n\nConstraints\n\n1≤N≤100\n\n|S|=N\n\nNo characters except I and D occur in S.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\nS\n\nOutput\n\nPrint the maximum value taken by x during the operations.\n\nSample Input 1\n\n5\nIIDID\n\nSample Output 1\n\n2\n\nAfter each operation, the value of x becomes 1, 2, 1, 2 and 1, respectively. Thus, the output should be 2, the maximum value.\n\nSample Input 2\n\n7\nDDIDDII\n\nSample Output 2\n\n0\n\nThe initial value x=0 is the maximum value taken by x, thus the output should be 0.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 589, "cpu_time_ms": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s171670581", "group_id": "codeNet:p03827", "input_text": "let n = read_int ()\nlet s = read_line ()\n\nlet rec f maxim now str =\n let len = String.length str in\n if len = 0 then maxim\n else if str.[0] = 'I' then\n f (max maxim (now + 1)) (now + 1) (String.sub str 1 (len - 1))\n else f maxim (now - 1) (String.sub str 1 (len - 1))\n\nlet () = f 0 0 s |> Printf.printf \"%d\\n\"", "language": "OCaml", "metadata": {"date": 1522382189, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03827.html", "problem_id": "p03827", "resource_group": "low_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/OCaml/s171670581.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s171670581", "user_id": "u987869509"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "let n = read_int ()\nlet s = read_line ()\n\nlet rec f maxim now str =\n let len = String.length str in\n if len = 0 then maxim\n else if str.[0] = 'I' then\n f (max maxim (now + 1)) (now + 1) (String.sub str 1 (len - 1))\n else f maxim (now - 1) (String.sub str 1 (len - 1))\n\nlet () = f 0 0 s |> Printf.printf \"%d\\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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 316, "cpu_time_ms": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s951142298", "group_id": "codeNet:p03827", "input_text": "let id a = a\nlet n = Scanf.scanf \"%d\\n\" id\nlet repeat f =\n let rec loop acc = function\n | 0 -> List.rev acc\n | n -> loop (f () :: acc) (n-1) in\n loop []\n\nlet r = repeat (fun () -> Scanf.scanf \"%c\" id) n\n\nlet rec ans x list = function\n | [] -> list\n | a :: rest ->\n match a with\n | 'I' -> ans (x+1) ((x+1) :: list) rest\n | 'D' -> ans (x-1) ((x-1) :: list) rest\n | _ -> ans x (x :: list) rest\n\nlet anslist = ans 0 [] r \n\nlet rec maxlist l x =\n match l with\n | [] -> x\n | a :: rest -> if a > x then maxlist rest a else maxlist rest x\n \nlet saidai = maxlist anslist 0\n\t\nlet () = Printf.printf \"%d\\n\" saidai\n", "language": "OCaml", "metadata": {"date": 1485651489, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03827.html", "problem_id": "p03827", "resource_group": "low_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/OCaml/s951142298.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s951142298", "user_id": "u735499035"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "let id a = a\nlet n = Scanf.scanf \"%d\\n\" id\nlet repeat f =\n let rec loop acc = function\n | 0 -> List.rev acc\n | n -> loop (f () :: acc) (n-1) in\n loop []\n\nlet r = repeat (fun () -> Scanf.scanf \"%c\" id) n\n\nlet rec ans x list = function\n | [] -> list\n | a :: rest ->\n match a with\n | 'I' -> ans (x+1) ((x+1) :: list) rest\n | 'D' -> ans (x-1) ((x-1) :: list) rest\n | _ -> ans x (x :: list) rest\n\nlet anslist = ans 0 [] r \n\nlet rec maxlist l x =\n match l with\n | [] -> x\n | a :: rest -> if a > x then maxlist rest a else maxlist rest x\n \nlet saidai = maxlist anslist 0\n\t\nlet () = Printf.printf \"%d\\n\" saidai\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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 634, "cpu_time_ms": 3, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s029891267", "group_id": "codeNet:p03828", "input_text": "(* O(n^2 log n) *)\nlet n = read_int ()\nlet is_prime n =\n if n <= 1 then false\n else\n let rec loop i =\n if i * i > n then true\n else if n mod i = 0 then false\n else loop @@ i + 1 in\n loop 2\nlet rec div_count n i = if n mod i <> 0 then 0 else 1 + div_count (n / i) i\nlet ans = ref 1\nlet _ =\n for i = 2 to n do\n if is_prime i then \n let c = ref 0 in\n for j = 2 to n do c := !c + div_count j i done;\n ans := !ans * (!c + 1) mod 1_000_000_007 done;\n Printf.printf \"%d\\n\" @@ !ans", "language": "OCaml", "metadata": {"date": 1561501330, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03828.html", "problem_id": "p03828", "resource_group": "low_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/OCaml/s029891267.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s029891267", "user_id": "u732304692"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "(* O(n^2 log n) *)\nlet n = read_int ()\nlet is_prime n =\n if n <= 1 then false\n else\n let rec loop i =\n if i * i > n then true\n else if n mod i = 0 then false\n else loop @@ i + 1 in\n loop 2\nlet rec div_count n i = if n mod i <> 0 then 0 else 1 + div_count (n / i) i\nlet ans = ref 1\nlet _ =\n for i = 2 to n do\n if is_prime i then \n let c = ref 0 in\n for j = 2 to n do c := !c + div_count j i done;\n ans := !ans * (!c + 1) mod 1_000_000_007 done;\n Printf.printf \"%d\\n\" @@ !ans", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 516, "cpu_time_ms": 4, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s215926402", "group_id": "codeNet:p03831", "input_text": "let () =\n let n, a, b = Scanf.scanf \"%d %d %d\\n\" (fun n a b -> n, a, b) in\n let xs = Array.init n (fun _ -> Scanf.scanf \"%d \" (fun x -> x)) in\n Array.init (n - 1) (fun i -> min b (a * (xs.(i + 1) - xs.(i))))\n |> Array.fold_left ( + ) 0\n |> Printf.printf \"%d\\n\"", "language": "OCaml", "metadata": {"date": 1510520267, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03831.html", "problem_id": "p03831", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03831/input.txt", "sample_output_relpath": "derived/input_output/data/p03831/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03831/OCaml/s215926402.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s215926402", "user_id": "u504158101"}, "prompt_components": {"gold_output": "11\n", "input_to_evaluate": "let () =\n let n, a, b = Scanf.scanf \"%d %d %d\\n\" (fun n a b -> n, a, b) in\n let xs = Array.init n (fun _ -> Scanf.scanf \"%d \" (fun x -> x)) in\n Array.init (n - 1) (fun i -> min b (a * (xs.(i + 1) - xs.(i))))\n |> Array.fold_left ( + ) 0\n |> Printf.printf \"%d\\n\"", "problem_context": "Score : 500 points\n\nProblem Statement\n\nThere are N towns on a line running east-west.\nThe towns are numbered 1 through N, in order from west to east.\nEach point on the line has a one-dimensional coordinate, and a point that is farther east has a greater coordinate value.\nThe coordinate of town i is X_i.\n\nYou are now at town 1, and you want to visit all the other towns.\nYou have two ways to travel:\n\nWalk on the line.\nYour fatigue level increases by A each time you travel a distance of 1, regardless of direction.\n\nTeleport to any location of your choice.\nYour fatigue level increases by B, regardless of the distance covered.\n\nFind the minimum possible total increase of your fatigue level when you visit all the towns in these two ways.\n\nConstraints\n\nAll input values are integers.\n\n2≤N≤10^5\n\n1≤X_i≤10^9\n\nFor all i(1≤i≤N-1), X_i x) in\n let a = String.sub s 0 5 in\n let b = String.sub s 6 7 in\n let c = String.sub s 13 5 in\n Printf.printf \"%s\\n\" (a ^ \" \" ^ b ^ \" \" ^ c)\n", "language": "OCaml", "metadata": {"date": 1582122511, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03834.html", "problem_id": "p03834", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03834/input.txt", "sample_output_relpath": "derived/input_output/data/p03834/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03834/OCaml/s510934512.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s510934512", "user_id": "u307426615"}, "prompt_components": {"gold_output": "happy newyear enjoy\n", "input_to_evaluate": "let () = \n let s = Scanf.scanf \"%s\\n\" (fun x -> x) in\n let a = String.sub s 0 5 in\n let b = String.sub s 6 7 in\n let c = String.sub s 13 5 in\n Printf.printf \"%s\\n\" (a ^ \" \" ^ b ^ \" \" ^ c)\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nAs a New Year's gift, Dolphin received a string s of length 19.\n\nThe string s has the following format: [five lowercase English letters],[seven lowercase English letters],[five lowercase English letters].\n\nDolphin wants to convert the comma-separated string s into a space-separated string.\n\nWrite a program to perform the conversion for him.\n\nConstraints\n\nThe length of s is 19.\n\nThe sixth and fourteenth characters in s are ,.\n\nThe other characters in s are lowercase English letters.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\ns\n\nOutput\n\nPrint the string after the conversion.\n\nSample Input 1\n\nhappy,newyear,enjoy\n\nSample Output 1\n\nhappy newyear enjoy\n\nReplace all the commas in happy,newyear,enjoy with spaces to obtain happy newyear enjoy.\n\nSample Input 2\n\nhaiku,atcoder,tasks\n\nSample Output 2\n\nhaiku atcoder tasks\n\nSample Input 3\n\nabcde,fghihgf,edcba\n\nSample Output 3\n\nabcde fghihgf edcba", "sample_input": "happy,newyear,enjoy\n"}, "reference_outputs": ["happy newyear enjoy\n"], "source_document_id": "p03834", "source_text": "Score : 100 points\n\nProblem Statement\n\nAs a New Year's gift, Dolphin received a string s of length 19.\n\nThe string s has the following format: [five lowercase English letters],[seven lowercase English letters],[five lowercase English letters].\n\nDolphin wants to convert the comma-separated string s into a space-separated string.\n\nWrite a program to perform the conversion for him.\n\nConstraints\n\nThe length of s is 19.\n\nThe sixth and fourteenth characters in s are ,.\n\nThe other characters in s are lowercase English letters.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\ns\n\nOutput\n\nPrint the string after the conversion.\n\nSample Input 1\n\nhappy,newyear,enjoy\n\nSample Output 1\n\nhappy newyear enjoy\n\nReplace all the commas in happy,newyear,enjoy with spaces to obtain happy newyear enjoy.\n\nSample Input 2\n\nhaiku,atcoder,tasks\n\nSample Output 2\n\nhaiku atcoder tasks\n\nSample Input 3\n\nabcde,fghihgf,edcba\n\nSample Output 3\n\nabcde fghihgf edcba", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 2, "memory_kb": 512}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s772593634", "group_id": "codeNet:p03834", "input_text": "let s = read_line ()\nlet _ = String.map (function ',' -> ' ' | c -> c) s |> print_endline", "language": "OCaml", "metadata": {"date": 1565184541, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03834.html", "problem_id": "p03834", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03834/input.txt", "sample_output_relpath": "derived/input_output/data/p03834/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03834/OCaml/s772593634.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s772593634", "user_id": "u732304692"}, "prompt_components": {"gold_output": "happy newyear enjoy\n", "input_to_evaluate": "let s = read_line ()\nlet _ = String.map (function ',' -> ' ' | c -> c) s |> print_endline", "problem_context": "Score : 100 points\n\nProblem Statement\n\nAs a New Year's gift, Dolphin received a string s of length 19.\n\nThe string s has the following format: [five lowercase English letters],[seven lowercase English letters],[five lowercase English letters].\n\nDolphin wants to convert the comma-separated string s into a space-separated string.\n\nWrite a program to perform the conversion for him.\n\nConstraints\n\nThe length of s is 19.\n\nThe sixth and fourteenth characters in s are ,.\n\nThe other characters in s are lowercase English letters.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\ns\n\nOutput\n\nPrint the string after the conversion.\n\nSample Input 1\n\nhappy,newyear,enjoy\n\nSample Output 1\n\nhappy newyear enjoy\n\nReplace all the commas in happy,newyear,enjoy with spaces to obtain happy newyear enjoy.\n\nSample Input 2\n\nhaiku,atcoder,tasks\n\nSample Output 2\n\nhaiku atcoder tasks\n\nSample Input 3\n\nabcde,fghihgf,edcba\n\nSample Output 3\n\nabcde fghihgf edcba", "sample_input": "happy,newyear,enjoy\n"}, "reference_outputs": ["happy newyear enjoy\n"], "source_document_id": "p03834", "source_text": "Score : 100 points\n\nProblem Statement\n\nAs a New Year's gift, Dolphin received a string s of length 19.\n\nThe string s has the following format: [five lowercase English letters],[seven lowercase English letters],[five lowercase English letters].\n\nDolphin wants to convert the comma-separated string s into a space-separated string.\n\nWrite a program to perform the conversion for him.\n\nConstraints\n\nThe length of s is 19.\n\nThe sixth and fourteenth characters in s are ,.\n\nThe other characters in s are lowercase English letters.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\ns\n\nOutput\n\nPrint the string after the conversion.\n\nSample Input 1\n\nhappy,newyear,enjoy\n\nSample Output 1\n\nhappy newyear enjoy\n\nReplace all the commas in happy,newyear,enjoy with spaces to obtain happy newyear enjoy.\n\nSample Input 2\n\nhaiku,atcoder,tasks\n\nSample Output 2\n\nhaiku atcoder tasks\n\nSample Input 3\n\nabcde,fghihgf,edcba\n\nSample Output 3\n\nabcde fghihgf edcba", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 2432}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s734032931", "group_id": "codeNet:p03834", "input_text": "let s = Scanf.scanf \"%s \" (fun a -> a) in\nPrintf.printf \"%s\\n\" (Str.global_replace (Str.regexp \",\") \" \" s)", "language": "OCaml", "metadata": {"date": 1526212834, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03834.html", "problem_id": "p03834", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03834/input.txt", "sample_output_relpath": "derived/input_output/data/p03834/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03834/OCaml/s734032931.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s734032931", "user_id": "u139013163"}, "prompt_components": {"gold_output": "happy newyear enjoy\n", "input_to_evaluate": "let s = Scanf.scanf \"%s \" (fun a -> a) in\nPrintf.printf \"%s\\n\" (Str.global_replace (Str.regexp \",\") \" \" s)", "problem_context": "Score : 100 points\n\nProblem Statement\n\nAs a New Year's gift, Dolphin received a string s of length 19.\n\nThe string s has the following format: [five lowercase English letters],[seven lowercase English letters],[five lowercase English letters].\n\nDolphin wants to convert the comma-separated string s into a space-separated string.\n\nWrite a program to perform the conversion for him.\n\nConstraints\n\nThe length of s is 19.\n\nThe sixth and fourteenth characters in s are ,.\n\nThe other characters in s are lowercase English letters.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\ns\n\nOutput\n\nPrint the string after the conversion.\n\nSample Input 1\n\nhappy,newyear,enjoy\n\nSample Output 1\n\nhappy newyear enjoy\n\nReplace all the commas in happy,newyear,enjoy with spaces to obtain happy newyear enjoy.\n\nSample Input 2\n\nhaiku,atcoder,tasks\n\nSample Output 2\n\nhaiku atcoder tasks\n\nSample Input 3\n\nabcde,fghihgf,edcba\n\nSample Output 3\n\nabcde fghihgf edcba", "sample_input": "happy,newyear,enjoy\n"}, "reference_outputs": ["happy newyear enjoy\n"], "source_document_id": "p03834", "source_text": "Score : 100 points\n\nProblem Statement\n\nAs a New Year's gift, Dolphin received a string s of length 19.\n\nThe string s has the following format: [five lowercase English letters],[seven lowercase English letters],[five lowercase English letters].\n\nDolphin wants to convert the comma-separated string s into a space-separated string.\n\nWrite a program to perform the conversion for him.\n\nConstraints\n\nThe length of s is 19.\n\nThe sixth and fourteenth characters in s are ,.\n\nThe other characters in s are lowercase English letters.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\ns\n\nOutput\n\nPrint the string after the conversion.\n\nSample Input 1\n\nhappy,newyear,enjoy\n\nSample Output 1\n\nhappy newyear enjoy\n\nReplace all the commas in happy,newyear,enjoy with spaces to obtain happy newyear enjoy.\n\nSample Input 2\n\nhaiku,atcoder,tasks\n\nSample Output 2\n\nhaiku atcoder tasks\n\nSample Input 3\n\nabcde,fghihgf,edcba\n\nSample Output 3\n\nabcde fghihgf edcba", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s411540707", "group_id": "codeNet:p03836", "input_text": "let dx, dy = Scanf.scanf \"%d %d %d %d\" (fun w x y z -> y-w, z-x)\nlet p n c = Array.init n (fun _ -> Printf.printf \"%c\" c) |> ignore\nlet () =\n p dx 'R';\n p dy 'U';\n p dx 'L';\n p (dy+1) 'D';\n p (dx+1) 'R';\n p (dy+1) 'U';\n p 1 'L';\n p 1 'U';\n p (dx+1) 'L';\n p (dy+1) 'D';\n p 1 'R';\n print_newline ()", "language": "OCaml", "metadata": {"date": 1527968935, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03836.html", "problem_id": "p03836", "resource_group": "low_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/OCaml/s411540707.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s411540707", "user_id": "u798181098"}, "prompt_components": {"gold_output": "UURDDLLUUURRDRDDDLLU\n", "input_to_evaluate": "let dx, dy = Scanf.scanf \"%d %d %d %d\" (fun w x y z -> y-w, z-x)\nlet p n c = Array.init n (fun _ -> Printf.printf \"%c\" c) |> ignore\nlet () =\n p dx 'R';\n p dy 'U';\n p dx 'L';\n p (dy+1) 'D';\n p (dx+1) 'R';\n p (dy+1) 'U';\n p 1 'L';\n p 1 'U';\n p (dx+1) 'L';\n p (dy+1) 'D';\n p 1 'R';\n print_newline ()", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 308, "cpu_time_ms": 2, "memory_kb": 2560}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s550060922", "group_id": "codeNet:p03837", "input_text": "type 'a set =\n | Empty\n | Singleton of 'a\n | Union of 'a set * 'a set\n\nmodule IntSet = Set.Make (struct\n type t = int\n let compare = compare\nend)\n\nlet rec make_intset acc = function\n | Empty -> acc\n | Singleton x -> IntSet.add x acc\n | Union (s, t) -> make_intset (make_intset acc s) t\n\nlet warshall_floyd ( + ) min n d =\n for i = 0 to n - 1 do\n for j = 0 to n - 1 do\n for k = 0 to n - 1 do\n d.(j).(k) <- min d.(j).(k) (d.(j).(i) + d.(i).(k))\n done\n done\n done\n\nlet () =\n let n, m = Scanf.scanf \"%d %d\\n\" (fun n m -> n, m) in\n let dp = Array.make_matrix n n (infinity, Empty) in\n for i = 0 to n - 1 do\n dp.(i).(i) <- (0., Empty)\n done;\n for i = 0 to m - 1 do\n Scanf.scanf \"%d %d %d\\n\" (fun a b c ->\n dp.(a - 1).(b - 1) <- (float_of_int c, Singleton i);\n dp.(b - 1).(a - 1) <- (float_of_int c, Singleton i))\n done;\n warshall_floyd\n (fun (d, es) (d', es') -> (d +. d', Union (es, es')))\n (fun (d, es) (d', es') ->\n match compare d d' with\n | -1 -> (d, es)\n | 0 -> (d, Union (es, es'))\n | 1 -> (d', es')) n dp;\n Array.map (fun dp ->\n Array.map snd dp\n |> Array.fold_left (fun s t -> Union (s, t)) Empty) dp\n |> Array.fold_left (fun s t -> Union (s, t)) Empty\n |> make_intset IntSet.empty\n |> IntSet.cardinal\n |> (fun n -> Printf.printf \"%d\\n\" (m - n))", "language": "OCaml", "metadata": {"date": 1515130001, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03837.html", "problem_id": "p03837", "resource_group": "low_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/OCaml/s550060922.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s550060922", "user_id": "u504158101"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "type 'a set =\n | Empty\n | Singleton of 'a\n | Union of 'a set * 'a set\n\nmodule IntSet = Set.Make (struct\n type t = int\n let compare = compare\nend)\n\nlet rec make_intset acc = function\n | Empty -> acc\n | Singleton x -> IntSet.add x acc\n | Union (s, t) -> make_intset (make_intset acc s) t\n\nlet warshall_floyd ( + ) min n d =\n for i = 0 to n - 1 do\n for j = 0 to n - 1 do\n for k = 0 to n - 1 do\n d.(j).(k) <- min d.(j).(k) (d.(j).(i) + d.(i).(k))\n done\n done\n done\n\nlet () =\n let n, m = Scanf.scanf \"%d %d\\n\" (fun n m -> n, m) in\n let dp = Array.make_matrix n n (infinity, Empty) in\n for i = 0 to n - 1 do\n dp.(i).(i) <- (0., Empty)\n done;\n for i = 0 to m - 1 do\n Scanf.scanf \"%d %d %d\\n\" (fun a b c ->\n dp.(a - 1).(b - 1) <- (float_of_int c, Singleton i);\n dp.(b - 1).(a - 1) <- (float_of_int c, Singleton i))\n done;\n warshall_floyd\n (fun (d, es) (d', es') -> (d +. d', Union (es, es')))\n (fun (d, es) (d', es') ->\n match compare d d' with\n | -1 -> (d, es)\n | 0 -> (d, Union (es, es'))\n | 1 -> (d', es')) n dp;\n Array.map (fun dp ->\n Array.map snd dp\n |> Array.fold_left (fun s t -> Union (s, t)) Empty) dp\n |> Array.fold_left (fun s t -> Union (s, t)) Empty\n |> make_intset IntSet.empty\n |> IntSet.cardinal\n |> (fun n -> Printf.printf \"%d\\n\" (m - n))", "problem_context": "Score : 400 points\n\nProblem Statement\n\nYou are given an undirected connected weighted graph with N vertices and M edges that contains neither self-loops nor double edges.\n\nThe i-th (1≤i≤M) edge connects vertex a_i and vertex b_i with a distance of c_i.\n\nHere, a self-loop is an edge where a_i = b_i (1≤i≤M), and double edges are two edges where (a_i,b_i)=(a_j,b_j) or (a_i,b_i)=(b_j,a_j) (1≤i\n [ if x <= y then y - x else max_int;\n if -x <= y then 1 + x + y else max_int;\n if x <= -y then 1 - x - y else max_int;\n if -x <= -y then 2 + x - y else max_int ])\n |> List.fold_left min max_int\n |> Printf.printf \"%d\\n\"\n\n", "language": "OCaml", "metadata": {"date": 1515478531, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03838.html", "problem_id": "p03838", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03838/input.txt", "sample_output_relpath": "derived/input_output/data/p03838/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03838/OCaml/s778859532.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s778859532", "user_id": "u504158101"}, "prompt_components": {"gold_output": "10\n", "input_to_evaluate": "let () =\n Scanf.scanf \"%d %d\" (fun x y ->\n [ if x <= y then y - x else max_int;\n if -x <= y then 1 + x + y else max_int;\n if x <= -y then 1 - x - y else max_int;\n if -x <= -y then 2 + x - y else max_int ])\n |> List.fold_left min max_int\n |> Printf.printf \"%d\\n\"\n\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nSnuke has a calculator. It has a display and two buttons.\n\nInitially, the display shows an integer x.\nSnuke wants to change this value into another integer y, by pressing the following two buttons some number of times in arbitrary order:\n\nButton A: When pressed, the value on the display is incremented by 1.\n\nButton B: When pressed, the sign of the value on the display is reversed.\n\nFind the minimum number of times Snuke needs to press the buttons to achieve his objective.\nIt can be shown that the objective is always achievable regardless of the values of the integers x and y.\n\nConstraints\n\nx and y are integers.\n\n|x|, |y| ≤ 10^9\n\nx and y are different.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nx y\n\nOutput\n\nPrint the minimum number of times Snuke needs to press the buttons to achieve his objective.\n\nSample Input 1\n\n10 20\n\nSample Output 1\n\n10\n\nPress button A ten times.\n\nSample Input 2\n\n10 -10\n\nSample Output 2\n\n1\n\nPress button B once.\n\nSample Input 3\n\n-10 -20\n\nSample Output 3\n\n12\n\nPress the buttons as follows:\n\nPress button B once.\n\nPress button A ten times.\n\nPress button B once.", "sample_input": "10 20\n"}, "reference_outputs": ["10\n"], "source_document_id": "p03838", "source_text": "Score : 300 points\n\nProblem Statement\n\nSnuke has a calculator. It has a display and two buttons.\n\nInitially, the display shows an integer x.\nSnuke wants to change this value into another integer y, by pressing the following two buttons some number of times in arbitrary order:\n\nButton A: When pressed, the value on the display is incremented by 1.\n\nButton B: When pressed, the sign of the value on the display is reversed.\n\nFind the minimum number of times Snuke needs to press the buttons to achieve his objective.\nIt can be shown that the objective is always achievable regardless of the values of the integers x and y.\n\nConstraints\n\nx and y are integers.\n\n|x|, |y| ≤ 10^9\n\nx and y are different.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nx y\n\nOutput\n\nPrint the minimum number of times Snuke needs to press the buttons to achieve his objective.\n\nSample Input 1\n\n10 20\n\nSample Output 1\n\n10\n\nPress button A ten times.\n\nSample Input 2\n\n10 -10\n\nSample Output 2\n\n1\n\nPress button B once.\n\nSample Input 3\n\n-10 -20\n\nSample Output 3\n\n12\n\nPress the buttons as follows:\n\nPress button B once.\n\nPress button A ten times.\n\nPress button B once.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 284, "cpu_time_ms": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s711164920", "group_id": "codeNet:p03844", "input_text": "open Printf\nopen Scanf\n\nlet solve a op b =\n if op = '+' then a + b else a - b\n\nlet () =\n scanf \"%d %c %d\" solve |> printf \"%d\\n\"\n", "language": "OCaml", "metadata": {"date": 1583273240, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03844.html", "problem_id": "p03844", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03844/input.txt", "sample_output_relpath": "derived/input_output/data/p03844/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03844/OCaml/s711164920.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s711164920", "user_id": "u388783188"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "open Printf\nopen Scanf\n\nlet solve a op b =\n if op = '+' then a + b else a - b\n\nlet () =\n scanf \"%d %c %d\" solve |> printf \"%d\\n\"\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nJoisino wants to evaluate the formula \"A op B\".\nHere, A and B are integers, and the binary operator op is either + or -.\nYour task is to evaluate the formula instead of her.\n\nConstraints\n\n1≦A,B≦10^9\n\nop is either + or -.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nA op B\n\nOutput\n\nEvaluate the formula and print the result.\n\nSample Input 1\n\n1 + 2\n\nSample Output 1\n\n3\n\nSince 1 + 2 = 3, the output should be 3.\n\nSample Input 2\n\n5 - 7\n\nSample Output 2\n\n-2", "sample_input": "1 + 2\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03844", "source_text": "Score : 100 points\n\nProblem Statement\n\nJoisino wants to evaluate the formula \"A op B\".\nHere, A and B are integers, and the binary operator op is either + or -.\nYour task is to evaluate the formula instead of her.\n\nConstraints\n\n1≦A,B≦10^9\n\nop is either + or -.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nA op B\n\nOutput\n\nEvaluate the formula and print the result.\n\nSample Input 1\n\n1 + 2\n\nSample Output 1\n\n3\n\nSince 1 + 2 = 3, the output should be 3.\n\nSample Input 2\n\n5 - 7\n\nSample Output 2\n\n-2", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s136750791", "group_id": "codeNet:p03844", "input_text": "let () =\n Scanf.scanf \"%d %s %d\" \n (fun a op b -> (if op = \"+\" then a + b else a - b))\n |> Printf.printf \"%d\\n\"", "language": "OCaml", "metadata": {"date": 1522535957, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03844.html", "problem_id": "p03844", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03844/input.txt", "sample_output_relpath": "derived/input_output/data/p03844/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03844/OCaml/s136750791.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s136750791", "user_id": "u987869509"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "let () =\n Scanf.scanf \"%d %s %d\" \n (fun a op b -> (if op = \"+\" then a + b else a - b))\n |> Printf.printf \"%d\\n\"", "problem_context": "Score : 100 points\n\nProblem Statement\n\nJoisino wants to evaluate the formula \"A op B\".\nHere, A and B are integers, and the binary operator op is either + or -.\nYour task is to evaluate the formula instead of her.\n\nConstraints\n\n1≦A,B≦10^9\n\nop is either + or -.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nA op B\n\nOutput\n\nEvaluate the formula and print the result.\n\nSample Input 1\n\n1 + 2\n\nSample Output 1\n\n3\n\nSince 1 + 2 = 3, the output should be 3.\n\nSample Input 2\n\n5 - 7\n\nSample Output 2\n\n-2", "sample_input": "1 + 2\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03844", "source_text": "Score : 100 points\n\nProblem Statement\n\nJoisino wants to evaluate the formula \"A op B\".\nHere, A and B are integers, and the binary operator op is either + or -.\nYour task is to evaluate the formula instead of her.\n\nConstraints\n\n1≦A,B≦10^9\n\nop is either + or -.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nA op B\n\nOutput\n\nEvaluate the formula and print the result.\n\nSample Input 1\n\n1 + 2\n\nSample Output 1\n\n3\n\nSince 1 + 2 = 3, the output should be 3.\n\nSample Input 2\n\n5 - 7\n\nSample Output 2\n\n-2", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s600714164", "group_id": "codeNet:p03844", "input_text": "let a, op, b = Scanf.scanf \"%d %s %d\\n\" (fun a b c -> a, b, c)\nlet calc = function\n | \"+\" -> (+)\n | \"-\" -> (-)\n | _ -> failwith \"hoge\"\n \nlet () =\n let op = calc op in\n print_endline @@ string_of_int (op a b)", "language": "OCaml", "metadata": {"date": 1483035035, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03844.html", "problem_id": "p03844", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03844/input.txt", "sample_output_relpath": "derived/input_output/data/p03844/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03844/OCaml/s600714164.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s600714164", "user_id": "u098968285"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "let a, op, b = Scanf.scanf \"%d %s %d\\n\" (fun a b c -> a, b, c)\nlet calc = function\n | \"+\" -> (+)\n | \"-\" -> (-)\n | _ -> failwith \"hoge\"\n \nlet () =\n let op = calc op in\n print_endline @@ string_of_int (op a b)", "problem_context": "Score : 100 points\n\nProblem Statement\n\nJoisino wants to evaluate the formula \"A op B\".\nHere, A and B are integers, and the binary operator op is either + or -.\nYour task is to evaluate the formula instead of her.\n\nConstraints\n\n1≦A,B≦10^9\n\nop is either + or -.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nA op B\n\nOutput\n\nEvaluate the formula and print the result.\n\nSample Input 1\n\n1 + 2\n\nSample Output 1\n\n3\n\nSince 1 + 2 = 3, the output should be 3.\n\nSample Input 2\n\n5 - 7\n\nSample Output 2\n\n-2", "sample_input": "1 + 2\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03844", "source_text": "Score : 100 points\n\nProblem Statement\n\nJoisino wants to evaluate the formula \"A op B\".\nHere, A and B are integers, and the binary operator op is either + or -.\nYour task is to evaluate the formula instead of her.\n\nConstraints\n\n1≦A,B≦10^9\n\nop is either + or -.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nA op B\n\nOutput\n\nEvaluate the formula and print the result.\n\nSample Input 1\n\n1 + 2\n\nSample Output 1\n\n3\n\nSince 1 + 2 = 3, the output should be 3.\n\nSample Input 2\n\n5 - 7\n\nSample Output 2\n\n-2", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 2, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s593332910", "group_id": "codeNet:p03845", "input_text": "let () =\n let xs = Scanf.scanf \"%d\" (fun n -> Array.init n (fun _ -> Scanf.scanf \" %d\" (fun x -> x))) in\n let total = Array.fold_left (+) 0 xs in\n Scanf.scanf \" %d\" (fun m -> Array.init m (fun _ -> Scanf.scanf \" %d %d\" (fun p u -> (p, u))))\n |> Array.iter (fun (p, u) -> Printf.printf \"%d\\n\" (total + (u-xs.(p-1))))\n", "language": "OCaml", "metadata": {"date": 1540078143, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03845.html", "problem_id": "p03845", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03845/input.txt", "sample_output_relpath": "derived/input_output/data/p03845/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03845/OCaml/s593332910.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s593332910", "user_id": "u638902622"}, "prompt_components": {"gold_output": "6\n9\n", "input_to_evaluate": "let () =\n let xs = Scanf.scanf \"%d\" (fun n -> Array.init n (fun _ -> Scanf.scanf \" %d\" (fun x -> x))) in\n let total = Array.fold_left (+) 0 xs in\n Scanf.scanf \" %d\" (fun m -> Array.init m (fun _ -> Scanf.scanf \" %d %d\" (fun p u -> (p, u))))\n |> Array.iter (fun (p, u) -> Printf.printf \"%d\\n\" (total + (u-xs.(p-1))))\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nJoisino is about to compete in the final round of a certain programming competition.\nIn this contest, there are N problems, numbered 1 through N.\nJoisino knows that it takes her T_i seconds to solve problem i(1≦i≦N).\n\nAlso, there are M kinds of drinks offered to the contestants, numbered 1 through M.\nIf Joisino takes drink i(1≦i≦M), her brain will be stimulated and the time it takes for her to solve problem P_i will become X_i seconds.\nIt does not affect the time to solve the other problems.\n\nA contestant is allowed to take exactly one of the drinks before the start of the contest.\nFor each drink, Joisino wants to know how many seconds it takes her to solve all the problems if she takes that drink.\nHere, assume that the time it takes her to solve all the problems is equal to the sum of the time it takes for her to solve individual problems.\nYour task is to write a program to calculate it instead of her.\n\nConstraints\n\nAll input values are integers.\n\n1≦N≦100\n\n1≦T_i≦10^5\n\n1≦M≦100\n\n1≦P_i≦N\n\n1≦X_i≦10^5\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\nT_1 T_2 ... T_N\nM\nP_1 X_1\nP_2 X_2\n:\nP_M X_M\n\nOutput\n\nFor each drink, calculate how many seconds it takes Joisino to solve all the problems if she takes that drink, and print the results, one per line.\n\nSample Input 1\n\n3\n2 1 4\n2\n1 1\n2 3\n\nSample Output 1\n\n6\n9\n\nIf Joisino takes drink 1, the time it takes her to solve each problem will be 1, 1 and 4 seconds, respectively, totaling 6 seconds.\n\nIf Joisino takes drink 2, the time it takes her to solve each problem will be 2, 3 and 4 seconds, respectively, totaling 9 seconds.\n\nSample Input 2\n\n5\n7 2 3 8 5\n3\n4 2\n1 7\n4 13\n\nSample Output 2\n\n19\n25\n30", "sample_input": "3\n2 1 4\n2\n1 1\n2 3\n"}, "reference_outputs": ["6\n9\n"], "source_document_id": "p03845", "source_text": "Score : 200 points\n\nProblem Statement\n\nJoisino is about to compete in the final round of a certain programming competition.\nIn this contest, there are N problems, numbered 1 through N.\nJoisino knows that it takes her T_i seconds to solve problem i(1≦i≦N).\n\nAlso, there are M kinds of drinks offered to the contestants, numbered 1 through M.\nIf Joisino takes drink i(1≦i≦M), her brain will be stimulated and the time it takes for her to solve problem P_i will become X_i seconds.\nIt does not affect the time to solve the other problems.\n\nA contestant is allowed to take exactly one of the drinks before the start of the contest.\nFor each drink, Joisino wants to know how many seconds it takes her to solve all the problems if she takes that drink.\nHere, assume that the time it takes her to solve all the problems is equal to the sum of the time it takes for her to solve individual problems.\nYour task is to write a program to calculate it instead of her.\n\nConstraints\n\nAll input values are integers.\n\n1≦N≦100\n\n1≦T_i≦10^5\n\n1≦M≦100\n\n1≦P_i≦N\n\n1≦X_i≦10^5\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\nT_1 T_2 ... T_N\nM\nP_1 X_1\nP_2 X_2\n:\nP_M X_M\n\nOutput\n\nFor each drink, calculate how many seconds it takes Joisino to solve all the problems if she takes that drink, and print the results, one per line.\n\nSample Input 1\n\n3\n2 1 4\n2\n1 1\n2 3\n\nSample Output 1\n\n6\n9\n\nIf Joisino takes drink 1, the time it takes her to solve each problem will be 1, 1 and 4 seconds, respectively, totaling 6 seconds.\n\nIf Joisino takes drink 2, the time it takes her to solve each problem will be 2, 3 and 4 seconds, respectively, totaling 9 seconds.\n\nSample Input 2\n\n5\n7 2 3 8 5\n3\n4 2\n1 7\n4 13\n\nSample Output 2\n\n19\n25\n30", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 512}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s034856411", "group_id": "codeNet:p03845", "input_text": "let id x = x\n\nlet t = Array.init (Scanf.scanf \"%d \" id) (fun _ -> Scanf.scanf \"%d \" id)\n\nlet px =\n Array.init (Scanf.scanf \"%d \" id) (fun _ ->\n Scanf.scanf \"%d %d \" (fun p x -> (p, x)) )\n\n\nlet sum = Array.fold_left ( + ) 0 t\n\nlet () =\n Array.iter (fun (p, x) -> sum - (t.(p - 1) - x) |> Printf.printf \"%d\\n\") px\n", "language": "OCaml", "metadata": {"date": 1527329916, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03845.html", "problem_id": "p03845", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03845/input.txt", "sample_output_relpath": "derived/input_output/data/p03845/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03845/OCaml/s034856411.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s034856411", "user_id": "u987869509"}, "prompt_components": {"gold_output": "6\n9\n", "input_to_evaluate": "let id x = x\n\nlet t = Array.init (Scanf.scanf \"%d \" id) (fun _ -> Scanf.scanf \"%d \" id)\n\nlet px =\n Array.init (Scanf.scanf \"%d \" id) (fun _ ->\n Scanf.scanf \"%d %d \" (fun p x -> (p, x)) )\n\n\nlet sum = Array.fold_left ( + ) 0 t\n\nlet () =\n Array.iter (fun (p, x) -> sum - (t.(p - 1) - x) |> Printf.printf \"%d\\n\") px\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nJoisino is about to compete in the final round of a certain programming competition.\nIn this contest, there are N problems, numbered 1 through N.\nJoisino knows that it takes her T_i seconds to solve problem i(1≦i≦N).\n\nAlso, there are M kinds of drinks offered to the contestants, numbered 1 through M.\nIf Joisino takes drink i(1≦i≦M), her brain will be stimulated and the time it takes for her to solve problem P_i will become X_i seconds.\nIt does not affect the time to solve the other problems.\n\nA contestant is allowed to take exactly one of the drinks before the start of the contest.\nFor each drink, Joisino wants to know how many seconds it takes her to solve all the problems if she takes that drink.\nHere, assume that the time it takes her to solve all the problems is equal to the sum of the time it takes for her to solve individual problems.\nYour task is to write a program to calculate it instead of her.\n\nConstraints\n\nAll input values are integers.\n\n1≦N≦100\n\n1≦T_i≦10^5\n\n1≦M≦100\n\n1≦P_i≦N\n\n1≦X_i≦10^5\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\nT_1 T_2 ... T_N\nM\nP_1 X_1\nP_2 X_2\n:\nP_M X_M\n\nOutput\n\nFor each drink, calculate how many seconds it takes Joisino to solve all the problems if she takes that drink, and print the results, one per line.\n\nSample Input 1\n\n3\n2 1 4\n2\n1 1\n2 3\n\nSample Output 1\n\n6\n9\n\nIf Joisino takes drink 1, the time it takes her to solve each problem will be 1, 1 and 4 seconds, respectively, totaling 6 seconds.\n\nIf Joisino takes drink 2, the time it takes her to solve each problem will be 2, 3 and 4 seconds, respectively, totaling 9 seconds.\n\nSample Input 2\n\n5\n7 2 3 8 5\n3\n4 2\n1 7\n4 13\n\nSample Output 2\n\n19\n25\n30", "sample_input": "3\n2 1 4\n2\n1 1\n2 3\n"}, "reference_outputs": ["6\n9\n"], "source_document_id": "p03845", "source_text": "Score : 200 points\n\nProblem Statement\n\nJoisino is about to compete in the final round of a certain programming competition.\nIn this contest, there are N problems, numbered 1 through N.\nJoisino knows that it takes her T_i seconds to solve problem i(1≦i≦N).\n\nAlso, there are M kinds of drinks offered to the contestants, numbered 1 through M.\nIf Joisino takes drink i(1≦i≦M), her brain will be stimulated and the time it takes for her to solve problem P_i will become X_i seconds.\nIt does not affect the time to solve the other problems.\n\nA contestant is allowed to take exactly one of the drinks before the start of the contest.\nFor each drink, Joisino wants to know how many seconds it takes her to solve all the problems if she takes that drink.\nHere, assume that the time it takes her to solve all the problems is equal to the sum of the time it takes for her to solve individual problems.\nYour task is to write a program to calculate it instead of her.\n\nConstraints\n\nAll input values are integers.\n\n1≦N≦100\n\n1≦T_i≦10^5\n\n1≦M≦100\n\n1≦P_i≦N\n\n1≦X_i≦10^5\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\nT_1 T_2 ... T_N\nM\nP_1 X_1\nP_2 X_2\n:\nP_M X_M\n\nOutput\n\nFor each drink, calculate how many seconds it takes Joisino to solve all the problems if she takes that drink, and print the results, one per line.\n\nSample Input 1\n\n3\n2 1 4\n2\n1 1\n2 3\n\nSample Output 1\n\n6\n9\n\nIf Joisino takes drink 1, the time it takes her to solve each problem will be 1, 1 and 4 seconds, respectively, totaling 6 seconds.\n\nIf Joisino takes drink 2, the time it takes her to solve each problem will be 2, 3 and 4 seconds, respectively, totaling 9 seconds.\n\nSample Input 2\n\n5\n7 2 3 8 5\n3\n4 2\n1 7\n4 13\n\nSample Output 2\n\n19\n25\n30", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 512}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s052685481", "group_id": "codeNet:p03846", "input_text": "let n = read_int ()\nlet cs, ds = Array.(make n 0, make n 0)\nlet rec f n a = if n <= 0 then a else f (n - 1) (2 * a mod 1000000007)\nlet _ = for _ = 1 to n do Scanf.scanf \" %d\" @@ fun a -> cs.(a) <- cs.(a) + 1 done; for i = 1 to n / 2 do ds.(n mod 2 + 2 * i - 1) <- 2 done; ds.(0) <- n mod 2; Printf.printf \"%d\\n\" @@ if cs = ds then f (n / 2) 1 else 0", "language": "OCaml", "metadata": {"date": 1579956766, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03846.html", "problem_id": "p03846", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03846/input.txt", "sample_output_relpath": "derived/input_output/data/p03846/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03846/OCaml/s052685481.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s052685481", "user_id": "u732304692"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "let n = read_int ()\nlet cs, ds = Array.(make n 0, make n 0)\nlet rec f n a = if n <= 0 then a else f (n - 1) (2 * a mod 1000000007)\nlet _ = for _ = 1 to n do Scanf.scanf \" %d\" @@ fun a -> cs.(a) <- cs.(a) + 1 done; for i = 1 to n / 2 do ds.(n mod 2 + 2 * i - 1) <- 2 done; ds.(0) <- n mod 2; Printf.printf \"%d\\n\" @@ if cs = ds then f (n / 2) 1 else 0", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere are N people, conveniently numbered 1 through N.\nThey were standing in a row yesterday, but now they are unsure of the order in which they were standing.\nHowever, each person remembered the following fact: the absolute difference of the number of the people who were standing to the left of that person, and the number of the people who were standing to the right of that person.\nAccording to their reports, the difference above for person i is A_i.\n\nBased on these reports, find the number of the possible orders in which they were standing.\nSince it can be extremely large, print the answer modulo 10^9+7.\nNote that the reports may be incorrect and thus there may be no consistent order.\nIn such a case, print 0.\n\nConstraints\n\n1≦N≦10^5\n\n0≦A_i≦N-1\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the number of the possible orders in which they were standing, modulo 10^9+7.\n\nSample Input 1\n\n5\n2 4 4 0 2\n\nSample Output 1\n\n4\n\nThere are four possible orders, as follows:\n\n2,1,4,5,3\n\n2,5,4,1,3\n\n3,1,4,5,2\n\n3,5,4,1,2\n\nSample Input 2\n\n7\n6 4 0 2 4 0 2\n\nSample Output 2\n\n0\n\nAny order would be inconsistent with the reports, thus the answer is 0.\n\nSample Input 3\n\n8\n7 5 1 1 7 3 5 3\n\nSample Output 3\n\n16", "sample_input": "5\n2 4 4 0 2\n"}, "reference_outputs": ["4\n"], "source_document_id": "p03846", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere are N people, conveniently numbered 1 through N.\nThey were standing in a row yesterday, but now they are unsure of the order in which they were standing.\nHowever, each person remembered the following fact: the absolute difference of the number of the people who were standing to the left of that person, and the number of the people who were standing to the right of that person.\nAccording to their reports, the difference above for person i is A_i.\n\nBased on these reports, find the number of the possible orders in which they were standing.\nSince it can be extremely large, print the answer modulo 10^9+7.\nNote that the reports may be incorrect and thus there may be no consistent order.\nIn such a case, print 0.\n\nConstraints\n\n1≦N≦10^5\n\n0≦A_i≦N-1\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the number of the possible orders in which they were standing, modulo 10^9+7.\n\nSample Input 1\n\n5\n2 4 4 0 2\n\nSample Output 1\n\n4\n\nThere are four possible orders, as follows:\n\n2,1,4,5,3\n\n2,5,4,1,3\n\n3,1,4,5,2\n\n3,5,4,1,2\n\nSample Input 2\n\n7\n6 4 0 2 4 0 2\n\nSample Output 2\n\n0\n\nAny order would be inconsistent with the reports, thus the answer is 0.\n\nSample Input 3\n\n8\n7 5 1 1 7 3 5 3\n\nSample Output 3\n\n16", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 349, "cpu_time_ms": 26, "memory_kb": 5632}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s461058242", "group_id": "codeNet:p03848", "input_text": "let rec power ( * ) one m = function\n | 0 -> one\n | n when n mod 2 = 0 ->\n power ( * ) one (m * m) (n / 2)\n | n ->\n m * power ( * ) one m (n - 1)\n\nlet () =\n let n = Scanf.scanf \"%d\\n\" (fun n -> n) in\n let as_ = Array.init n (fun _ -> Scanf.scanf \"%d \" (fun a -> a)) in\n Array.sort compare as_;\n if\n n mod 2 = 0 && as_ = Array.init n (fun i -> (i + 1) - i mod 2) ||\n n mod 2 = 1 && as_ = Array.init n (fun i -> (i + 1) - (i + 1) mod 2)\n then Printf.printf \"%d\\n\" @@ power (fun n m -> n * m mod 1000000007) 1 2 (n / 2)\n else print_endline \"0\"", "language": "OCaml", "metadata": {"date": 1501579570, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03848.html", "problem_id": "p03848", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03848/input.txt", "sample_output_relpath": "derived/input_output/data/p03848/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03848/OCaml/s461058242.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s461058242", "user_id": "u504158101"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "let rec power ( * ) one m = function\n | 0 -> one\n | n when n mod 2 = 0 ->\n power ( * ) one (m * m) (n / 2)\n | n ->\n m * power ( * ) one m (n - 1)\n\nlet () =\n let n = Scanf.scanf \"%d\\n\" (fun n -> n) in\n let as_ = Array.init n (fun _ -> Scanf.scanf \"%d \" (fun a -> a)) in\n Array.sort compare as_;\n if\n n mod 2 = 0 && as_ = Array.init n (fun i -> (i + 1) - i mod 2) ||\n n mod 2 = 1 && as_ = Array.init n (fun i -> (i + 1) - (i + 1) mod 2)\n then Printf.printf \"%d\\n\" @@ power (fun n m -> n * m mod 1000000007) 1 2 (n / 2)\n else print_endline \"0\"", "problem_context": "Score : 300 points\n\nProblem Statement\n\nThere are N people, conveniently numbered 1 through N.\nThey were standing in a row yesterday, but now they are unsure of the order in which they were standing.\nHowever, each person remembered the following fact: the absolute difference of the number of the people who were standing to the left of that person, and the number of the people who were standing to the right of that person.\nAccording to their reports, the difference above for person i is A_i.\n\nBased on these reports, find the number of the possible orders in which they were standing.\nSince it can be extremely large, print the answer modulo 10^9+7.\nNote that the reports may be incorrect and thus there may be no consistent order.\nIn such a case, print 0.\n\nConstraints\n\n1≦N≦10^5\n\n0≦A_i≦N-1\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the number of the possible orders in which they were standing, modulo 10^9+7.\n\nSample Input 1\n\n5\n2 4 4 0 2\n\nSample Output 1\n\n4\n\nThere are four possible orders, as follows:\n\n2,1,4,5,3\n\n2,5,4,1,3\n\n3,1,4,5,2\n\n3,5,4,1,2\n\nSample Input 2\n\n7\n6 4 0 2 4 0 2\n\nSample Output 2\n\n0\n\nAny order would be inconsistent with the reports, thus the answer is 0.\n\nSample Input 3\n\n8\n7 5 1 1 7 3 5 3\n\nSample Output 3\n\n16", "sample_input": "5\n2 4 4 0 2\n"}, "reference_outputs": ["4\n"], "source_document_id": "p03848", "source_text": "Score : 300 points\n\nProblem Statement\n\nThere are N people, conveniently numbered 1 through N.\nThey were standing in a row yesterday, but now they are unsure of the order in which they were standing.\nHowever, each person remembered the following fact: the absolute difference of the number of the people who were standing to the left of that person, and the number of the people who were standing to the right of that person.\nAccording to their reports, the difference above for person i is A_i.\n\nBased on these reports, find the number of the possible orders in which they were standing.\nSince it can be extremely large, print the answer modulo 10^9+7.\nNote that the reports may be incorrect and thus there may be no consistent order.\nIn such a case, print 0.\n\nConstraints\n\n1≦N≦10^5\n\n0≦A_i≦N-1\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\nA_1 A_2 ... A_N\n\nOutput\n\nPrint the number of the possible orders in which they were standing, modulo 10^9+7.\n\nSample Input 1\n\n5\n2 4 4 0 2\n\nSample Output 1\n\n4\n\nThere are four possible orders, as follows:\n\n2,1,4,5,3\n\n2,5,4,1,3\n\n3,1,4,5,2\n\n3,5,4,1,2\n\nSample Input 2\n\n7\n6 4 0 2 4 0 2\n\nSample Output 2\n\n0\n\nAny order would be inconsistent with the reports, thus the answer is 0.\n\nSample Input 3\n\n8\n7 5 1 1 7 3 5 3\n\nSample Output 3\n\n16", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 73, "memory_kb": 6144}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s526414906", "group_id": "codeNet:p03852", "input_text": "print_endline @@ match read_line () with\n| \"a\" | \"e\" | \"i\" | \"o\" | \"u\" -> \"vowel\"\n| _ -> \"consonant\"", "language": "OCaml", "metadata": {"date": 1596511510, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p03852.html", "problem_id": "p03852", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03852/input.txt", "sample_output_relpath": "derived/input_output/data/p03852/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03852/OCaml/s526414906.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s526414906", "user_id": "u342443598"}, "prompt_components": {"gold_output": "vowel\n", "input_to_evaluate": "print_endline @@ match read_line () with\n| \"a\" | \"e\" | \"i\" | \"o\" | \"u\" -> \"vowel\"\n| _ -> \"consonant\"", "problem_context": "Score : 100 points\n\nProblem Statement\n\nGiven a lowercase English letter c, determine whether it is a vowel. Here, there are five vowels in the English alphabet: a, e, i, o and u.\n\nConstraints\n\nc is a lowercase English letter.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nc\n\nOutput\n\nIf c is a vowel, print vowel. Otherwise, print consonant.\n\nSample Input 1\n\na\n\nSample Output 1\n\nvowel\n\nSince a is a vowel, print vowel.\n\nSample Input 2\n\nz\n\nSample Output 2\n\nconsonant\n\nSample Input 3\n\ns\n\nSample Output 3\n\nconsonant", "sample_input": "a\n"}, "reference_outputs": ["vowel\n"], "source_document_id": "p03852", "source_text": "Score : 100 points\n\nProblem Statement\n\nGiven a lowercase English letter c, determine whether it is a vowel. Here, there are five vowels in the English alphabet: a, e, i, o and u.\n\nConstraints\n\nc is a lowercase English letter.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nc\n\nOutput\n\nIf c is a vowel, print vowel. Otherwise, print consonant.\n\nSample Input 1\n\na\n\nSample Output 1\n\nvowel\n\nSince a is a vowel, print vowel.\n\nSample Input 2\n\nz\n\nSample Output 2\n\nconsonant\n\nSample Input 3\n\ns\n\nSample Output 3\n\nconsonant", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 3544}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s704289119", "group_id": "codeNet:p03852", "input_text": "let () = Scanf.scanf \"%c\" (fun c -> if String.contains \"aeiou\" c then \"vowel\" else \"consonant\")\n|> print_endline\n", "language": "OCaml", "metadata": {"date": 1519657197, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03852.html", "problem_id": "p03852", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03852/input.txt", "sample_output_relpath": "derived/input_output/data/p03852/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03852/OCaml/s704289119.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s704289119", "user_id": "u798181098"}, "prompt_components": {"gold_output": "vowel\n", "input_to_evaluate": "let () = Scanf.scanf \"%c\" (fun c -> if String.contains \"aeiou\" c then \"vowel\" else \"consonant\")\n|> print_endline\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nGiven a lowercase English letter c, determine whether it is a vowel. Here, there are five vowels in the English alphabet: a, e, i, o and u.\n\nConstraints\n\nc is a lowercase English letter.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nc\n\nOutput\n\nIf c is a vowel, print vowel. Otherwise, print consonant.\n\nSample Input 1\n\na\n\nSample Output 1\n\nvowel\n\nSince a is a vowel, print vowel.\n\nSample Input 2\n\nz\n\nSample Output 2\n\nconsonant\n\nSample Input 3\n\ns\n\nSample Output 3\n\nconsonant", "sample_input": "a\n"}, "reference_outputs": ["vowel\n"], "source_document_id": "p03852", "source_text": "Score : 100 points\n\nProblem Statement\n\nGiven a lowercase English letter c, determine whether it is a vowel. Here, there are five vowels in the English alphabet: a, e, i, o and u.\n\nConstraints\n\nc is a lowercase English letter.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nc\n\nOutput\n\nIf c is a vowel, print vowel. Otherwise, print consonant.\n\nSample Input 1\n\na\n\nSample Output 1\n\nvowel\n\nSince a is a vowel, print vowel.\n\nSample Input 2\n\nz\n\nSample Output 2\n\nconsonant\n\nSample Input 3\n\ns\n\nSample Output 3\n\nconsonant", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s390405630", "group_id": "codeNet:p03853", "input_text": "let h, w = Scanf.scanf \" %d %d\" @@ fun a b -> a, b\nlet _ = Array.init h @@ fun _ -> Scanf.scanf \" %s\" @@ fun s -> Printf.printf \"%s\\n%s\\n\" s s", "language": "OCaml", "metadata": {"date": 1572079334, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03853.html", "problem_id": "p03853", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03853/input.txt", "sample_output_relpath": "derived/input_output/data/p03853/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03853/OCaml/s390405630.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s390405630", "user_id": "u732304692"}, "prompt_components": {"gold_output": "*.\n*.\n.*\n.*\n", "input_to_evaluate": "let h, w = Scanf.scanf \" %d %d\" @@ fun a b -> a, b\nlet _ = Array.init h @@ fun _ -> Scanf.scanf \" %s\" @@ fun s -> Printf.printf \"%s\\n%s\\n\" s s", "problem_context": "Score : 200 points\n\nProblem Statement\n\nThere is an image with a height of H pixels and a width of W pixels. Each of the pixels is represented by either . or *. The character representing the pixel at the i-th row from the top and the j-th column from the left, is denoted by C_{i,j}.\n\nExtend this image vertically so that its height is doubled. That is, print a image with a height of 2H pixels and a width of W pixels where the pixel at the i-th row and j-th column is equal to C_{(i+1)/2,j} (the result of division is rounded down).\n\nConstraints\n\n1≦H, W≦100\n\nC_{i,j} is either . or *.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nH W\nC_{1,1}...C_{1,W}\n:\nC_{H,1}...C_{H,W}\n\nOutput\n\nPrint the extended image.\n\nSample Input 1\n\n2 2\n*.\n.*\n\nSample Output 1\n\n*.\n*.\n.*\n.*\n\nSample Input 2\n\n1 4\n***.\n\nSample Output 2\n\n***.\n***.\n\nSample Input 3\n\n9 20\n.....***....***.....\n....*...*..*...*....\n...*.....**.....*...\n...*.....*......*...\n....*.....*....*....\n.....**..*...**.....\n.......*..*.*.......\n........**.*........\n.........**.........\n\nSample Output 3\n\n.....***....***.....\n.....***....***.....\n....*...*..*...*....\n....*...*..*...*....\n...*.....**.....*...\n...*.....**.....*...\n...*.....*......*...\n...*.....*......*...\n....*.....*....*....\n....*.....*....*....\n.....**..*...**.....\n.....**..*...**.....\n.......*..*.*.......\n.......*..*.*.......\n........**.*........\n........**.*........\n.........**.........\n.........**.........", "sample_input": "2 2\n*.\n.*\n"}, "reference_outputs": ["*.\n*.\n.*\n.*\n"], "source_document_id": "p03853", "source_text": "Score : 200 points\n\nProblem Statement\n\nThere is an image with a height of H pixels and a width of W pixels. Each of the pixels is represented by either . or *. The character representing the pixel at the i-th row from the top and the j-th column from the left, is denoted by C_{i,j}.\n\nExtend this image vertically so that its height is doubled. That is, print a image with a height of 2H pixels and a width of W pixels where the pixel at the i-th row and j-th column is equal to C_{(i+1)/2,j} (the result of division is rounded down).\n\nConstraints\n\n1≦H, W≦100\n\nC_{i,j} is either . or *.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nH W\nC_{1,1}...C_{1,W}\n:\nC_{H,1}...C_{H,W}\n\nOutput\n\nPrint the extended image.\n\nSample Input 1\n\n2 2\n*.\n.*\n\nSample Output 1\n\n*.\n*.\n.*\n.*\n\nSample Input 2\n\n1 4\n***.\n\nSample Output 2\n\n***.\n***.\n\nSample Input 3\n\n9 20\n.....***....***.....\n....*...*..*...*....\n...*.....**.....*...\n...*.....*......*...\n....*.....*....*....\n.....**..*...**.....\n.......*..*.*.......\n........**.*........\n.........**.........\n\nSample Output 3\n\n.....***....***.....\n.....***....***.....\n....*...*..*...*....\n....*...*..*...*....\n...*.....**.....*...\n...*.....**.....*...\n...*.....*......*...\n...*.....*......*...\n....*.....*....*....\n....*.....*....*....\n.....**..*...**.....\n.....**..*...**.....\n.......*..*.*.......\n.......*..*.*.......\n........**.*........\n........**.*........\n.........**.........\n.........**.........", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 512}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s746401236", "group_id": "codeNet:p03855", "input_text": "Scanf.scanf \"%d %d %d\" (fun n k l ->\n let rec root arr x =\n if x = arr.(x) then x else (\n let r = root arr arr.(x) in\n arr.(x) <- r;\n r\n )\n in\n\n let merge arr count x y =\n if root arr x <> root arr y then (\n count.(arr.(x)) <- count.(arr.(x)) + count.(arr.(y));\n arr.(arr.(y)) <- arr.(x);\n )\n in\n\n let road = Array.init n (fun i -> i) in\n let train = Array.init n (fun i -> i) in\n let road_count = Array.make n 1 in\n let train_count = Array.make n 1 in\n \n for i = 1 to k do\n Scanf.scanf \" %d %d\" (fun p q ->\n let p = p - 1 in\n let q = q - 1 in\n merge road road_count p q\n )\n done;\n for i = 1 to l do\n Scanf.scanf \" %d %d\" (fun p q ->\n let p = p - 1 in\n let q = q - 1 in\n merge train train_count p q\n )\n done;\n let module M = Map.Make (struct type t = int let compare = compare end) in\n let rec loop i map =\n if i = n then map else\n let r = root road i in\n let t = root train i in\n let key = r * n + t in\n let map = M.add key (1 + try M.find key map with _ -> 0) map in\n loop (i + 1) map\n in\n let map = loop 0 M.empty in\n\n for i = 0 to n - 1 do\n let r = root road i in\n let t = root train i in\n let key = r * n + t in\n Printf.printf \"%d \" @@ M.find key map\n done;\n print_newline ()\n)", "language": "OCaml", "metadata": {"date": 1598654223, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p03855.html", "problem_id": "p03855", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03855/input.txt", "sample_output_relpath": "derived/input_output/data/p03855/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03855/OCaml/s746401236.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s746401236", "user_id": "u342443598"}, "prompt_components": {"gold_output": "1 2 2 1\n", "input_to_evaluate": "Scanf.scanf \"%d %d %d\" (fun n k l ->\n let rec root arr x =\n if x = arr.(x) then x else (\n let r = root arr arr.(x) in\n arr.(x) <- r;\n r\n )\n in\n\n let merge arr count x y =\n if root arr x <> root arr y then (\n count.(arr.(x)) <- count.(arr.(x)) + count.(arr.(y));\n arr.(arr.(y)) <- arr.(x);\n )\n in\n\n let road = Array.init n (fun i -> i) in\n let train = Array.init n (fun i -> i) in\n let road_count = Array.make n 1 in\n let train_count = Array.make n 1 in\n \n for i = 1 to k do\n Scanf.scanf \" %d %d\" (fun p q ->\n let p = p - 1 in\n let q = q - 1 in\n merge road road_count p q\n )\n done;\n for i = 1 to l do\n Scanf.scanf \" %d %d\" (fun p q ->\n let p = p - 1 in\n let q = q - 1 in\n merge train train_count p q\n )\n done;\n let module M = Map.Make (struct type t = int let compare = compare end) in\n let rec loop i map =\n if i = n then map else\n let r = root road i in\n let t = root train i in\n let key = r * n + t in\n let map = M.add key (1 + try M.find key map with _ -> 0) map in\n loop (i + 1) map\n in\n let map = loop 0 M.empty in\n\n for i = 0 to n - 1 do\n let r = root road i in\n let t = root train i in\n let key = r * n + t in\n Printf.printf \"%d \" @@ M.find key map\n done;\n print_newline ()\n)", "problem_context": "Score : 400 points\n\nProblem Statement\n\nThere are N cities. There are also K roads and L railways, extending between the cities.\nThe i-th road bidirectionally connects the p_i-th and q_i-th cities, and the i-th railway bidirectionally connects the r_i-th and s_i-th cities.\nNo two roads connect the same pair of cities. Similarly, no two railways connect the same pair of cities.\n\nWe will say city A and B are connected by roads if city B is reachable from city A by traversing some number of roads. Here, any city is considered to be connected to itself by roads.\nWe will also define connectivity by railways similarly.\n\nFor each city, find the number of the cities connected to that city by both roads and railways.\n\nConstraints\n\n2 ≦ N ≦ 2*10^5\n\n1 ≦ K, L≦ 10^5\n\n1 ≦ p_i, q_i, r_i, s_i ≦ N\n\np_i < q_i\n\nr_i < s_i\n\nWhen i ≠ j, (p_i, q_i) ≠ (p_j, q_j)\n\nWhen i ≠ j, (r_i, s_i) ≠ (r_j, s_j)\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN K L\np_1 q_1\n:\np_K q_K\nr_1 s_1\n:\nr_L s_L\n\nOutput\n\nPrint N integers. The i-th of them should represent the number of the cities connected to the i-th city by both roads and railways.\n\nSample Input 1\n\n4 3 1\n1 2\n2 3\n3 4\n2 3\n\nSample Output 1\n\n1 2 2 1\n\nAll the four cities are connected to each other by roads.\n\nBy railways, only the second and third cities are connected. Thus, the answers for the cities are 1, 2, 2 and 1, respectively.\n\nSample Input 2\n\n4 2 2\n1 2\n2 3\n1 4\n2 3\n\nSample Output 2\n\n1 2 2 1\n\nSample Input 3\n\n7 4 4\n1 2\n2 3\n2 5\n6 7\n3 5\n4 5\n3 4\n6 7\n\nSample Output 3\n\n1 1 2 1 2 2 2", "sample_input": "4 3 1\n1 2\n2 3\n3 4\n2 3\n"}, "reference_outputs": ["1 2 2 1\n"], "source_document_id": "p03855", "source_text": "Score : 400 points\n\nProblem Statement\n\nThere are N cities. There are also K roads and L railways, extending between the cities.\nThe i-th road bidirectionally connects the p_i-th and q_i-th cities, and the i-th railway bidirectionally connects the r_i-th and s_i-th cities.\nNo two roads connect the same pair of cities. Similarly, no two railways connect the same pair of cities.\n\nWe will say city A and B are connected by roads if city B is reachable from city A by traversing some number of roads. Here, any city is considered to be connected to itself by roads.\nWe will also define connectivity by railways similarly.\n\nFor each city, find the number of the cities connected to that city by both roads and railways.\n\nConstraints\n\n2 ≦ N ≦ 2*10^5\n\n1 ≦ K, L≦ 10^5\n\n1 ≦ p_i, q_i, r_i, s_i ≦ N\n\np_i < q_i\n\nr_i < s_i\n\nWhen i ≠ j, (p_i, q_i) ≠ (p_j, q_j)\n\nWhen i ≠ j, (r_i, s_i) ≠ (r_j, s_j)\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN K L\np_1 q_1\n:\np_K q_K\nr_1 s_1\n:\nr_L s_L\n\nOutput\n\nPrint N integers. The i-th of them should represent the number of the cities connected to the i-th city by both roads and railways.\n\nSample Input 1\n\n4 3 1\n1 2\n2 3\n3 4\n2 3\n\nSample Output 1\n\n1 2 2 1\n\nAll the four cities are connected to each other by roads.\n\nBy railways, only the second and third cities are connected. Thus, the answers for the cities are 1, 2, 2 and 1, respectively.\n\nSample Input 2\n\n4 2 2\n1 2\n2 3\n1 4\n2 3\n\nSample Output 2\n\n1 2 2 1\n\nSample Input 3\n\n7 4 4\n1 2\n2 3\n2 5\n6 7\n3 5\n4 5\n3 4\n6 7\n\nSample Output 3\n\n1 1 2 1 2 2 2", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1533, "cpu_time_ms": 244, "memory_kb": 18104}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s604753936", "group_id": "codeNet:p03860", "input_text": "let _, s = Scanf.scanf \" %s %s\" @@ fun a b -> a, b\nlet _ = Printf.printf \"A%cC\\n\" @@ Char.uppercase s.[0]", "language": "OCaml", "metadata": {"date": 1565186578, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03860.html", "problem_id": "p03860", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03860/input.txt", "sample_output_relpath": "derived/input_output/data/p03860/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03860/OCaml/s604753936.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s604753936", "user_id": "u732304692"}, "prompt_components": {"gold_output": "ABC\n", "input_to_evaluate": "let _, s = Scanf.scanf \" %s %s\" @@ fun a b -> a, b\nlet _ = Printf.printf \"A%cC\\n\" @@ Char.uppercase s.[0]", "problem_context": "Score : 100 points\n\nProblem Statement\n\nSnuke is going to open a contest named \"AtCoder s Contest\".\nHere, s is a string of length 1 or greater, where the first character is an uppercase English letter, and the second and subsequent characters are lowercase English letters.\n\nSnuke has decided to abbreviate the name of the contest as \"AxC\".\nHere, x is the uppercase English letter at the beginning of s.\n\nGiven the name of the contest, print the abbreviation of the name.\n\nConstraints\n\nThe length of s is between 1 and 100, inclusive.\n\nThe first character in s is an uppercase English letter.\n\nThe second and subsequent characters in s are lowercase English letters.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nAtCoder s Contest\n\nOutput\n\nPrint the abbreviation of the name of the contest.\n\nSample Input 1\n\nAtCoder Beginner Contest\n\nSample Output 1\n\nABC\n\nThe contest in which you are participating now.\n\nSample Input 2\n\nAtCoder Snuke Contest\n\nSample Output 2\n\nASC\n\nThis contest does not actually exist.\n\nSample Input 3\n\nAtCoder X Contest\n\nSample Output 3\n\nAXC", "sample_input": "AtCoder Beginner Contest\n"}, "reference_outputs": ["ABC\n"], "source_document_id": "p03860", "source_text": "Score : 100 points\n\nProblem Statement\n\nSnuke is going to open a contest named \"AtCoder s Contest\".\nHere, s is a string of length 1 or greater, where the first character is an uppercase English letter, and the second and subsequent characters are lowercase English letters.\n\nSnuke has decided to abbreviate the name of the contest as \"AxC\".\nHere, x is the uppercase English letter at the beginning of s.\n\nGiven the name of the contest, print the abbreviation of the name.\n\nConstraints\n\nThe length of s is between 1 and 100, inclusive.\n\nThe first character in s is an uppercase English letter.\n\nThe second and subsequent characters in s are lowercase English letters.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nAtCoder s Contest\n\nOutput\n\nPrint the abbreviation of the name of the contest.\n\nSample Input 1\n\nAtCoder Beginner Contest\n\nSample Output 1\n\nABC\n\nThe contest in which you are participating now.\n\nSample Input 2\n\nAtCoder Snuke Contest\n\nSample Output 2\n\nASC\n\nThis contest does not actually exist.\n\nSample Input 3\n\nAtCoder X Contest\n\nSample Output 3\n\nAXC", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s754988310", "group_id": "codeNet:p03861", "input_text": "let f n x = match n with\n\t| -1 -> 0\n\t| n -> n / x + 1\n\nlet _ =\n\tScanf.scanf \"%d %d %d\" (fun a b x -> f b x - f (a - 1) x) |> Printf.printf \"%d\"", "language": "OCaml", "metadata": {"date": 1481149103, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03861.html", "problem_id": "p03861", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03861/input.txt", "sample_output_relpath": "derived/input_output/data/p03861/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03861/OCaml/s754988310.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s754988310", "user_id": "u604818425"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "let f n x = match n with\n\t| -1 -> 0\n\t| n -> n / x + 1\n\nlet _ =\n\tScanf.scanf \"%d %d %d\" (fun a b x -> f b x - f (a - 1) x) |> Printf.printf \"%d\"", "problem_context": "Score : 200 points\n\nProblem Statement\n\nYou are given nonnegative integers a and b (a ≤ b), and a positive integer x.\nAmong the integers between a and b, inclusive, how many are divisible by x?\n\nConstraints\n\n0 ≤ a ≤ b ≤ 10^{18}\n\n1 ≤ x ≤ 10^{18}\n\nInput\n\nThe input is given from Standard Input in the following format:\n\na b x\n\nOutput\n\nPrint the number of the integers between a and b, inclusive, that are divisible by x.\n\nSample Input 1\n\n4 8 2\n\nSample Output 1\n\n3\n\nThere are three integers between 4 and 8, inclusive, that are divisible by 2: 4, 6 and 8.\n\nSample Input 2\n\n0 5 1\n\nSample Output 2\n\n6\n\nThere are six integers between 0 and 5, inclusive, that are divisible by 1: 0, 1, 2, 3, 4 and 5.\n\nSample Input 3\n\n9 9 2\n\nSample Output 3\n\n0\n\nThere are no integer between 9 and 9, inclusive, that is divisible by 2.\n\nSample Input 4\n\n1 1000000000000000000 3\n\nSample Output 4\n\n333333333333333333\n\nWatch out for integer overflows.", "sample_input": "4 8 2\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03861", "source_text": "Score : 200 points\n\nProblem Statement\n\nYou are given nonnegative integers a and b (a ≤ b), and a positive integer x.\nAmong the integers between a and b, inclusive, how many are divisible by x?\n\nConstraints\n\n0 ≤ a ≤ b ≤ 10^{18}\n\n1 ≤ x ≤ 10^{18}\n\nInput\n\nThe input is given from Standard Input in the following format:\n\na b x\n\nOutput\n\nPrint the number of the integers between a and b, inclusive, that are divisible by x.\n\nSample Input 1\n\n4 8 2\n\nSample Output 1\n\n3\n\nThere are three integers between 4 and 8, inclusive, that are divisible by 2: 4, 6 and 8.\n\nSample Input 2\n\n0 5 1\n\nSample Output 2\n\n6\n\nThere are six integers between 0 and 5, inclusive, that are divisible by 1: 0, 1, 2, 3, 4 and 5.\n\nSample Input 3\n\n9 9 2\n\nSample Output 3\n\n0\n\nThere are no integer between 9 and 9, inclusive, that is divisible by 2.\n\nSample Input 4\n\n1 1000000000000000000 3\n\nSample Output 4\n\n333333333333333333\n\nWatch out for integer overflows.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 3, "memory_kb": 512}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s546788596", "group_id": "codeNet:p03862", "input_text": "let rec eat x lst = match lst with\n\t| a::b::xs -> if a + b > x\n\t\t\t\t\tthen\n\t\t\t\t\t\tlet dcl = a + b - x in\n\t\t\t\t\t\tdcl + eat x (a::b-dcl::xs)\n\t\t\t\t\telse\n\t\t\t\t\t\teat x (b::xs)\n\t| _::xs -> 0\n\t| [] -> 0\n\nlet _ =\n\tlet f = Scanf.scanf \"%d %d\\n\" (fun x y -> eat y) in\n\tread_line () |> Str.split (Str.regexp \" \") |> List.map(fun x -> int_of_string x)|> f |> Printf.printf \"%d\"\n", "language": "OCaml", "metadata": {"date": 1480910588, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03862.html", "problem_id": "p03862", "resource_group": "low_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/OCaml/s546788596.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s546788596", "user_id": "u604818425"}, "prompt_components": {"gold_output": "1\n", "input_to_evaluate": "let rec eat x lst = match lst with\n\t| a::b::xs -> if a + b > x\n\t\t\t\t\tthen\n\t\t\t\t\t\tlet dcl = a + b - x in\n\t\t\t\t\t\tdcl + eat x (a::b-dcl::xs)\n\t\t\t\t\telse\n\t\t\t\t\t\teat x (b::xs)\n\t| _::xs -> 0\n\t| [] -> 0\n\nlet _ =\n\tlet f = Scanf.scanf \"%d %d\\n\" (fun x y -> eat y) in\n\tread_line () |> Str.split (Str.regexp \" \") |> List.map(fun x -> int_of_string x)|> f |> Printf.printf \"%d\"\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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 360, "cpu_time_ms": 61, "memory_kb": 16768}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s036680938", "group_id": "codeNet:p03863", "input_text": "Scanf.scanf \"%s\" (fun s ->\n let n = String.length s in\n print_endline @@ if (n mod 2 = 1) = (s.[0] = s.[n - 1]) then \"Second\" else \"First\"\n)", "language": "OCaml", "metadata": {"date": 1600230502, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p03863.html", "problem_id": "p03863", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03863/input.txt", "sample_output_relpath": "derived/input_output/data/p03863/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03863/OCaml/s036680938.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s036680938", "user_id": "u342443598"}, "prompt_components": {"gold_output": "Second\n", "input_to_evaluate": "Scanf.scanf \"%s\" (fun s ->\n let n = String.length s in\n print_endline @@ if (n mod 2 = 1) = (s.[0] = s.[n - 1]) then \"Second\" else \"First\"\n)", "problem_context": "Score : 500 points\n\nProblem Statement\n\nThere is a string s of length 3 or greater.\nNo two neighboring characters in s are equal.\n\nTakahashi and Aoki will play a game against each other.\nThe two players alternately performs the following operation, Takahashi going first:\n\nRemove one of the characters in s, excluding both ends. However, a character cannot be removed if removal of the character would result in two neighboring equal characters in s.\n\nThe player who becomes unable to perform the operation, loses the game. Determine which player will win when the two play optimally.\n\nConstraints\n\n3 ≤ |s| ≤ 10^5\n\ns consists of lowercase English letters.\n\nNo two neighboring characters in s are equal.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\ns\n\nOutput\n\nIf Takahashi will win, print First. If Aoki will win, print Second.\n\nSample Input 1\n\naba\n\nSample Output 1\n\nSecond\n\nTakahashi, who goes first, cannot perform the operation, since removal of the b, which is the only character not at either ends of s, would result in s becoming aa, with two as neighboring.\n\nSample Input 2\n\nabc\n\nSample Output 2\n\nFirst\n\nWhen Takahashi removes b from s, it becomes ac.\nThen, Aoki cannot perform the operation, since there is no character in s, excluding both ends.\n\nSample Input 3\n\nabcab\n\nSample Output 3\n\nFirst", "sample_input": "aba\n"}, "reference_outputs": ["Second\n"], "source_document_id": "p03863", "source_text": "Score : 500 points\n\nProblem Statement\n\nThere is a string s of length 3 or greater.\nNo two neighboring characters in s are equal.\n\nTakahashi and Aoki will play a game against each other.\nThe two players alternately performs the following operation, Takahashi going first:\n\nRemove one of the characters in s, excluding both ends. However, a character cannot be removed if removal of the character would result in two neighboring equal characters in s.\n\nThe player who becomes unable to perform the operation, loses the game. Determine which player will win when the two play optimally.\n\nConstraints\n\n3 ≤ |s| ≤ 10^5\n\ns consists of lowercase English letters.\n\nNo two neighboring characters in s are equal.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\ns\n\nOutput\n\nIf Takahashi will win, print First. If Aoki will win, print Second.\n\nSample Input 1\n\naba\n\nSample Output 1\n\nSecond\n\nTakahashi, who goes first, cannot perform the operation, since removal of the b, which is the only character not at either ends of s, would result in s becoming aa, with two as neighboring.\n\nSample Input 2\n\nabc\n\nSample Output 2\n\nFirst\n\nWhen Takahashi removes b from s, it becomes ac.\nThen, Aoki cannot perform the operation, since there is no character in s, excluding both ends.\n\nSample Input 3\n\nabcab\n\nSample Output 3\n\nFirst", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 15, "memory_kb": 4116}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s478680262", "group_id": "codeNet:p03880", "input_text": "module IntMap = Map.Make (struct\n type t = int\n let compare = compare\nend)\n\nlet () = Scanf.scanf \"%d\\n\" @@ fun n ->\n let as_ = Array.init n @@ fun _ -> Scanf.scanf \"%d\\n\" @@ fun a -> a in\n Array.to_list as_\n |> List.map (fun a -> a lxor (a - 1))\n |> List.sort_uniq compare\n |> List.fold_left (fun m a ->\n IntMap.fold (fun x n m ->\n IntMap.add (x lxor a)\n (min (1 + n) @@\n try IntMap.find (x lxor a lxor (a - 1)) m\n with Not_found -> max_int) m) m m)\n (IntMap.singleton (Array.fold_left ( lxor ) 0 as_) 0)\n |> fun m ->\n Printf.printf \"%d\\n\" @@\n try IntMap.find 0 m with Not_found -> -1\n", "language": "OCaml", "metadata": {"date": 1535943770, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03880.html", "problem_id": "p03880", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03880/input.txt", "sample_output_relpath": "derived/input_output/data/p03880/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03880/OCaml/s478680262.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s478680262", "user_id": "u504158101"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "module IntMap = Map.Make (struct\n type t = int\n let compare = compare\nend)\n\nlet () = Scanf.scanf \"%d\\n\" @@ fun n ->\n let as_ = Array.init n @@ fun _ -> Scanf.scanf \"%d\\n\" @@ fun a -> a in\n Array.to_list as_\n |> List.map (fun a -> a lxor (a - 1))\n |> List.sort_uniq compare\n |> List.fold_left (fun m a ->\n IntMap.fold (fun x n m ->\n IntMap.add (x lxor a)\n (min (1 + n) @@\n try IntMap.find (x lxor a lxor (a - 1)) m\n with Not_found -> max_int) m) m m)\n (IntMap.singleton (Array.fold_left ( lxor ) 0 as_) 0)\n |> fun m ->\n Printf.printf \"%d\\n\" @@\n try IntMap.find 0 m with Not_found -> -1\n", "problem_context": "Score : 500 points\n\nProblem Statement\n\n#nck {\nwidth: 30px;\nheight: auto;\n}\n\nA cheetah and a cheater are going to play the game of Nim.\nIn this game they use N piles of stones.\nInitially the i-th pile contains a_i stones.\nThe players take turns alternately, and the cheetah plays first.\nIn each turn, the player chooses one of the piles, and takes one or more stones from the pile.\nThe player who can't make a move loses.\n\nHowever, before the game starts, the cheater wants to cheat a bit to make sure that he can win regardless of the moves by the cheetah.\nFrom each pile, the cheater takes zero or one stone and eats it before the game.\nIn case there are multiple ways to guarantee his winning, he wants to minimize the number of stones he eats.\n\nCompute the number of stones the cheater will eat.\nIn case there is no way for the cheater to win the game even with the cheating, print -1 instead.\n\nConstraints\n\n1 ≤ N ≤ 10^5\n\n2 ≤ a_i ≤ 10^9\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 answer.\n\nSample Input 1\n\n3\n2\n3\n4\n\nSample Output 1\n\n3\n\nThe only way for the cheater to win the game is to take stones from all piles and eat them.\n\nSample Input 2\n\n3\n100\n100\n100\n\nSample Output 2\n\n-1", "sample_input": "3\n2\n3\n4\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03880", "source_text": "Score : 500 points\n\nProblem Statement\n\n#nck {\nwidth: 30px;\nheight: auto;\n}\n\nA cheetah and a cheater are going to play the game of Nim.\nIn this game they use N piles of stones.\nInitially the i-th pile contains a_i stones.\nThe players take turns alternately, and the cheetah plays first.\nIn each turn, the player chooses one of the piles, and takes one or more stones from the pile.\nThe player who can't make a move loses.\n\nHowever, before the game starts, the cheater wants to cheat a bit to make sure that he can win regardless of the moves by the cheetah.\nFrom each pile, the cheater takes zero or one stone and eats it before the game.\nIn case there are multiple ways to guarantee his winning, he wants to minimize the number of stones he eats.\n\nCompute the number of stones the cheater will eat.\nIn case there is no way for the cheater to win the game even with the cheating, print -1 instead.\n\nConstraints\n\n1 ≤ N ≤ 10^5\n\n2 ≤ a_i ≤ 10^9\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 answer.\n\nSample Input 1\n\n3\n2\n3\n4\n\nSample Output 1\n\n3\n\nThe only way for the cheater to win the game is to take stones from all piles and eat them.\n\nSample Input 2\n\n3\n100\n100\n100\n\nSample Output 2\n\n-1", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 651, "cpu_time_ms": 2107, "memory_kb": 118972}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s918862036", "group_id": "codeNet:p03889", "input_text": "let s = read_line ()\nlet f s = String.(init (length s) @@ fun i -> s.[length s - i - 1])\nlet _ = print_endline @@ if s = String.map (function 'b' -> 'd' | 'd' -> 'b' | 'p' -> 'q' | 'q' -> 'p' | c -> c) @@ f s then \"Yes\" else \"No\"", "language": "OCaml", "metadata": {"date": 1566236000, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03889.html", "problem_id": "p03889", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03889/input.txt", "sample_output_relpath": "derived/input_output/data/p03889/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03889/OCaml/s918862036.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s918862036", "user_id": "u732304692"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "let s = read_line ()\nlet f s = String.(init (length s) @@ fun i -> s.[length s - i - 1])\nlet _ = print_endline @@ if s = String.map (function 'b' -> 'd' | 'd' -> 'b' | 'p' -> 'q' | 'q' -> 'p' | c -> c) @@ f s then \"Yes\" else \"No\"", "problem_context": "Score : 100 points\n\nProblem Statement\n\nYou are given a string S consisting of letters b, d, p and q.\nDetermine whether S is a mirror string.\n\nHere, a mirror string is a string S such that the following sequence of operations on S results in the same string S:\n\nReverse the order of the characters in S.\n\nReplace each occurrence of b by d, d by b, p by q, and q by p, simultaneously.\n\nConstraints\n\n1 \\leq |S| \\leq 10^5\n\nS consists of letters b, d, p, and q.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nS\n\nOutput\n\nIf S is a mirror string, print Yes. Otherwise, print No.\n\nSample Input 1\n\npdbq\n\nSample Output 1\n\nYes\n\nSample Input 2\n\nppqb\n\nSample Output 2\n\nNo", "sample_input": "pdbq\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03889", "source_text": "Score : 100 points\n\nProblem Statement\n\nYou are given a string S consisting of letters b, d, p and q.\nDetermine whether S is a mirror string.\n\nHere, a mirror string is a string S such that the following sequence of operations on S results in the same string S:\n\nReverse the order of the characters in S.\n\nReplace each occurrence of b by d, d by b, p by q, and q by p, simultaneously.\n\nConstraints\n\n1 \\leq |S| \\leq 10^5\n\nS consists of letters b, d, p, and q.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nS\n\nOutput\n\nIf S is a mirror string, print Yes. Otherwise, print No.\n\nSample Input 1\n\npdbq\n\nSample Output 1\n\nYes\n\nSample Input 2\n\nppqb\n\nSample Output 2\n\nNo", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 4, "memory_kb": 2816}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s722009687", "group_id": "codeNet:p03909", "input_text": "Scanf.scanf \"%d %d\" (fun h w ->\n let rec loop i acc =\n let rec loop2 j acc =\n if j = w then acc else\n let acc = Scanf.scanf \" %s\" (fun s ->\n if s = \"snuke\" then Printf.sprintf \"%c%d\" \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\".[j] i else acc)\n in\n loop2 (j + 1) acc\n in\n if i > h then acc else loop (i + 1) (loop2 0 acc)\n in\n print_endline @@ loop 1 \"\"\n)", "language": "OCaml", "metadata": {"date": 1588290043, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03909.html", "problem_id": "p03909", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03909/input.txt", "sample_output_relpath": "derived/input_output/data/p03909/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03909/OCaml/s722009687.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s722009687", "user_id": "u342443598"}, "prompt_components": {"gold_output": "H6\n", "input_to_evaluate": "Scanf.scanf \"%d %d\" (fun h w ->\n let rec loop i acc =\n let rec loop2 j acc =\n if j = w then acc else\n let acc = Scanf.scanf \" %s\" (fun s ->\n if s = \"snuke\" then Printf.sprintf \"%c%d\" \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\".[j] i else acc)\n in\n loop2 (j + 1) acc\n in\n if i > h then acc else loop (i + 1) (loop2 0 acc)\n in\n print_endline @@ loop 1 \"\"\n)", "problem_context": "Score : 100 points\n\nProblem Statement\n\nThere is a grid with H rows and W columns.\n\nThe square at the i-th row and j-th column contains a string S_{i,j} of length 5.\n\nThe rows are labeled with the numbers from 1 through H, and the columns are labeled with the uppercase English letters from A through the W-th letter of the alphabet.\n\nExactly one of the squares in the grid contains the string snuke. Find this square and report its location.\n\nFor example, the square at the 6-th row and 8-th column should be reported as H6.\n\nConstraints\n\n1≦H, W≦26\n\nThe length of S_{i,j} is 5.\n\nS_{i,j} consists of lowercase English letters (a-z).\n\nExactly one of the given strings is equal to snuke.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nH W\nS_{1,1} S_{1,2} ... S_{1,W}\nS_{2,1} S_{2,2} ... S_{2,W}\n:\nS_{H,1} S_{H,2} ... S_{H,W}\n\nOutput\n\nPrint the labels of the row and the column of the square containing the string snuke, with no space inbetween.\n\nSample Input 1\n\n15 10\nsnake snake snake snake snake snake snake snake snake snake\nsnake snake snake snake snake snake snake snake snake snake\nsnake snake snake snake snake snake snake snake snake snake\nsnake snake snake snake snake snake snake snake snake snake\nsnake snake snake snake snake snake snake snake snake snake\nsnake snake snake snake snake snake snake snuke snake snake\nsnake snake snake snake snake snake snake snake snake snake\nsnake snake snake snake snake snake snake snake snake snake\nsnake snake snake snake snake snake snake snake snake snake\nsnake snake snake snake snake snake snake snake snake snake\nsnake snake snake snake snake snake snake snake snake snake\nsnake snake snake snake snake snake snake snake snake snake\nsnake snake snake snake snake snake snake snake snake snake\nsnake snake snake snake snake snake snake snake snake snake\nsnake snake snake snake snake snake snake snake snake snake\n\nSample Output 1\n\nH6\n\nSample Input 2\n\n1 1\nsnuke\n\nSample Output 2\n\nA1", "sample_input": "15 10\nsnake snake snake snake snake snake snake snake snake snake\nsnake snake snake snake snake snake snake snake snake snake\nsnake snake snake snake snake snake snake snake snake snake\nsnake snake snake snake snake snake snake snake snake snake\nsnake snake snake snake snake snake snake snake snake snake\nsnake snake snake snake snake snake snake snuke snake snake\nsnake snake snake snake snake snake snake snake snake snake\nsnake snake snake snake snake snake snake snake snake snake\nsnake snake snake snake snake snake snake snake snake snake\nsnake snake snake snake snake snake snake snake snake snake\nsnake snake snake snake snake snake snake snake snake snake\nsnake snake snake snake snake snake snake snake snake snake\nsnake snake snake snake snake snake snake snake snake snake\nsnake snake snake snake snake snake snake snake snake snake\nsnake snake snake snake snake snake snake snake snake snake\n"}, "reference_outputs": ["H6\n"], "source_document_id": "p03909", "source_text": "Score : 100 points\n\nProblem Statement\n\nThere is a grid with H rows and W columns.\n\nThe square at the i-th row and j-th column contains a string S_{i,j} of length 5.\n\nThe rows are labeled with the numbers from 1 through H, and the columns are labeled with the uppercase English letters from A through the W-th letter of the alphabet.\n\nExactly one of the squares in the grid contains the string snuke. Find this square and report its location.\n\nFor example, the square at the 6-th row and 8-th column should be reported as H6.\n\nConstraints\n\n1≦H, W≦26\n\nThe length of S_{i,j} is 5.\n\nS_{i,j} consists of lowercase English letters (a-z).\n\nExactly one of the given strings is equal to snuke.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nH W\nS_{1,1} S_{1,2} ... S_{1,W}\nS_{2,1} S_{2,2} ... S_{2,W}\n:\nS_{H,1} S_{H,2} ... S_{H,W}\n\nOutput\n\nPrint the labels of the row and the column of the square containing the string snuke, with no space inbetween.\n\nSample Input 1\n\n15 10\nsnake snake snake snake snake snake snake snake snake snake\nsnake snake snake snake snake snake snake snake snake snake\nsnake snake snake snake snake snake snake snake snake snake\nsnake snake snake snake snake snake snake snake snake snake\nsnake snake snake snake snake snake snake snake snake snake\nsnake snake snake snake snake snake snake snuke snake snake\nsnake snake snake snake snake snake snake snake snake snake\nsnake snake snake snake snake snake snake snake snake snake\nsnake snake snake snake snake snake snake snake snake snake\nsnake snake snake snake snake snake snake snake snake snake\nsnake snake snake snake snake snake snake snake snake snake\nsnake snake snake snake snake snake snake snake snake snake\nsnake snake snake snake snake snake snake snake snake snake\nsnake snake snake snake snake snake snake snake snake snake\nsnake snake snake snake snake snake snake snake snake snake\n\nSample Output 1\n\nH6\n\nSample Input 2\n\n1 1\nsnuke\n\nSample Output 2\n\nA1", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 2432}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s669569139", "group_id": "codeNet:p03911", "input_text": "Scanf.scanf \"%d %d\" (fun n m ->\n let link = Array.make m [] in\n for i = 0 to n - 1 do\n Scanf.scanf \" %d\" (fun k ->\n for j = 1 to k do\n Scanf.scanf \" %d\" (fun l ->\n let l = l - 1 in\n link.(l) <- i :: link.(l)\n )\n done\n )\n done;\n let par = Array.init n (fun i -> i) in\n let rec root x =\n if x = par.(x) then x else\n let r = root par.(x) in\n let () = par.(x) <- r in\n r\n in\n let merge a b =\n if root a <> root b then (\n par.(par.(b)) <- par.(a)\n )\n in\n Array.iter (fun l ->\n match l with\n | [] -> ()\n | hd :: tl -> List.iter (fun v -> merge hd v) tl\n ) link;\n let rec loop i =\n if i = n then \"YES\" else\n if root 0 = root i then loop (i + 1) else \"NO\"\n in\n print_endline @@ loop 0\n)", "language": "OCaml", "metadata": {"date": 1588301788, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03911.html", "problem_id": "p03911", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03911/input.txt", "sample_output_relpath": "derived/input_output/data/p03911/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03911/OCaml/s669569139.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s669569139", "user_id": "u342443598"}, "prompt_components": {"gold_output": "YES\n", "input_to_evaluate": "Scanf.scanf \"%d %d\" (fun n m ->\n let link = Array.make m [] in\n for i = 0 to n - 1 do\n Scanf.scanf \" %d\" (fun k ->\n for j = 1 to k do\n Scanf.scanf \" %d\" (fun l ->\n let l = l - 1 in\n link.(l) <- i :: link.(l)\n )\n done\n )\n done;\n let par = Array.init n (fun i -> i) in\n let rec root x =\n if x = par.(x) then x else\n let r = root par.(x) in\n let () = par.(x) <- r in\n r\n in\n let merge a b =\n if root a <> root b then (\n par.(par.(b)) <- par.(a)\n )\n in\n Array.iter (fun l ->\n match l with\n | [] -> ()\n | hd :: tl -> List.iter (fun v -> merge hd v) tl\n ) link;\n let rec loop i =\n if i = n then \"YES\" else\n if root 0 = root i then loop (i + 1) else \"NO\"\n in\n print_endline @@ loop 0\n)", "problem_context": "Score : 400 points\n\nProblem Statement\n\nOn a planet far, far away, M languages are spoken. They are conveniently numbered 1 through M.\n\nFor CODE FESTIVAL 20XX held on this planet, N participants gathered from all over the planet.\n\nThe i-th (1≦i≦N) participant can speak K_i languages numbered L_{i,1}, L_{i,2}, ..., L_{i,{}K_i}.\n\nTwo participants A and B can communicate with each other if and only if one of the following conditions is satisfied:\n\nThere exists a language that both A and B can speak.\n\nThere exists a participant X that both A and B can communicate with.\n\nDetermine whether all N participants can communicate with all other participants.\n\nConstraints\n\n2≦N≦10^5\n\n1≦M≦10^5\n\n1≦K_i≦M\n\n(The sum of all K_i)≦10^5\n\n1≦L_{i,j}≦M\n\nL_{i,1}, L_{i,2}, ..., L_{i,{}K_i} are pairwise distinct.\n\nPartial Score\n\n200 points will be awarded for passing the test set satisfying the following: N≦1000, M≦1000 and (The sum of all K_i)≦1000.\n\nAdditional 200 points will be awarded for passing the test set without additional constraints.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN M\nK_1 L_{1,1} L_{1,2} ... L_{1,{}K_1}\nK_2 L_{2,1} L_{2,2} ... L_{2,{}K_2}\n:\nK_N L_{N,1} L_{N,2} ... L_{N,{}K_N}\n\nOutput\n\nIf all N participants can communicate with all other participants, print YES. Otherwise, print NO.\n\nSample Input 1\n\n4 6\n3 1 2 3\n2 4 2\n2 4 6\n1 6\n\nSample Output 1\n\nYES\n\nAny two participants can communicate with each other, as follows:\n\nParticipants 1 and 2: both can speak language 2.\n\nParticipants 2 and 3: both can speak language 4.\n\nParticipants 1 and 3: both can communicate with participant 2.\n\nParticipants 3 and 4: both can speak language 6.\n\nParticipants 2 and 4: both can communicate with participant 3.\n\nParticipants 1 and 4: both can communicate with participant 2.\n\nNote that there can be languages spoken by no participant.\n\nSample Input 2\n\n4 4\n2 1 2\n2 1 2\n1 3\n2 4 3\n\nSample Output 2\n\nNO\n\nFor example, participants 1 and 3 cannot communicate with each other.", "sample_input": "4 6\n3 1 2 3\n2 4 2\n2 4 6\n1 6\n"}, "reference_outputs": ["YES\n"], "source_document_id": "p03911", "source_text": "Score : 400 points\n\nProblem Statement\n\nOn a planet far, far away, M languages are spoken. They are conveniently numbered 1 through M.\n\nFor CODE FESTIVAL 20XX held on this planet, N participants gathered from all over the planet.\n\nThe i-th (1≦i≦N) participant can speak K_i languages numbered L_{i,1}, L_{i,2}, ..., L_{i,{}K_i}.\n\nTwo participants A and B can communicate with each other if and only if one of the following conditions is satisfied:\n\nThere exists a language that both A and B can speak.\n\nThere exists a participant X that both A and B can communicate with.\n\nDetermine whether all N participants can communicate with all other participants.\n\nConstraints\n\n2≦N≦10^5\n\n1≦M≦10^5\n\n1≦K_i≦M\n\n(The sum of all K_i)≦10^5\n\n1≦L_{i,j}≦M\n\nL_{i,1}, L_{i,2}, ..., L_{i,{}K_i} are pairwise distinct.\n\nPartial Score\n\n200 points will be awarded for passing the test set satisfying the following: N≦1000, M≦1000 and (The sum of all K_i)≦1000.\n\nAdditional 200 points will be awarded for passing the test set without additional constraints.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN M\nK_1 L_{1,1} L_{1,2} ... L_{1,{}K_1}\nK_2 L_{2,1} L_{2,2} ... L_{2,{}K_2}\n:\nK_N L_{N,1} L_{N,2} ... L_{N,{}K_N}\n\nOutput\n\nIf all N participants can communicate with all other participants, print YES. Otherwise, print NO.\n\nSample Input 1\n\n4 6\n3 1 2 3\n2 4 2\n2 4 6\n1 6\n\nSample Output 1\n\nYES\n\nAny two participants can communicate with each other, as follows:\n\nParticipants 1 and 2: both can speak language 2.\n\nParticipants 2 and 3: both can speak language 4.\n\nParticipants 1 and 3: both can communicate with participant 2.\n\nParticipants 3 and 4: both can speak language 6.\n\nParticipants 2 and 4: both can communicate with participant 3.\n\nParticipants 1 and 4: both can communicate with participant 2.\n\nNote that there can be languages spoken by no participant.\n\nSample Input 2\n\n4 4\n2 1 2\n2 1 2\n1 3\n2 4 3\n\nSample Output 2\n\nNO\n\nFor example, participants 1 and 3 cannot communicate with each other.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 925, "cpu_time_ms": 57, "memory_kb": 7168}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s951020860", "group_id": "codeNet:p03912", "input_text": "Scanf.scanf \"%d %d\" (fun n m ->\n let hist = Array.make 100001 0 in\n let modgrp = Array.make m 0 in\n for i = 1 to n do\n Scanf.scanf \" %d\" (fun x ->\n hist.(x) <- hist.(x) + 1;\n modgrp.(x mod m) <- modgrp.(x mod m) + 1;\n )\n done;\n let calc1 i = modgrp.(i) / 2 in\n let calc2 i j =\n let i, j = if modgrp.(i) <= modgrp.(j) then i, j else j, i in\n let rest = modgrp.(j) - modgrp.(i) in\n\n let rec loop k acc =\n if k > 100000 then acc else\n let acc = acc + hist.(k) / 2 in\n if acc >= rest then rest else loop (k + m) acc\n in\n let acc1 = loop j 0 in\n acc1 + modgrp.(i)\n in\n let rec loop i acc =\n if i * 2 > m then acc else\n let acc = if i = 0 || i * 2 = m then acc + calc1 i\n else acc + calc2 i (m - i)\n in\n loop (i + 1) acc\n in\n loop 0 0 |> Printf.printf \"%d\\n\"\n)", "language": "OCaml", "metadata": {"date": 1588305070, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03912.html", "problem_id": "p03912", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03912/input.txt", "sample_output_relpath": "derived/input_output/data/p03912/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03912/OCaml/s951020860.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s951020860", "user_id": "u342443598"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "Scanf.scanf \"%d %d\" (fun n m ->\n let hist = Array.make 100001 0 in\n let modgrp = Array.make m 0 in\n for i = 1 to n do\n Scanf.scanf \" %d\" (fun x ->\n hist.(x) <- hist.(x) + 1;\n modgrp.(x mod m) <- modgrp.(x mod m) + 1;\n )\n done;\n let calc1 i = modgrp.(i) / 2 in\n let calc2 i j =\n let i, j = if modgrp.(i) <= modgrp.(j) then i, j else j, i in\n let rest = modgrp.(j) - modgrp.(i) in\n\n let rec loop k acc =\n if k > 100000 then acc else\n let acc = acc + hist.(k) / 2 in\n if acc >= rest then rest else loop (k + m) acc\n in\n let acc1 = loop j 0 in\n acc1 + modgrp.(i)\n in\n let rec loop i acc =\n if i * 2 > m then acc else\n let acc = if i = 0 || i * 2 = m then acc + calc1 i\n else acc + calc2 i (m - i)\n in\n loop (i + 1) acc\n in\n loop 0 0 |> Printf.printf \"%d\\n\"\n)", "problem_context": "Score : 700 points\n\nProblem Statement\n\nTakahashi is playing with N cards.\n\nThe i-th card has an integer X_i on it.\n\nTakahashi is trying to create as many pairs of cards as possible satisfying one of the following conditions:\n\nThe integers on the two cards are the same.\n\nThe sum of the integers on the two cards is a multiple of M.\n\nFind the maximum number of pairs that can be created.\n\nNote that a card cannot be used in more than one pair.\n\nConstraints\n\n2≦N≦10^5\n\n1≦M≦10^5\n\n1≦X_i≦10^5\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN M\nX_1 X_2 ... X_N\n\nOutput\n\nPrint the maximum number of pairs that can be created.\n\nSample Input 1\n\n7 5\n3 1 4 1 5 9 2\n\nSample Output 1\n\n3\n\nThree pairs (3,2), (1,4) and (1,9) can be created.\n\nIt is possible to create pairs (3,2) and (1,1), but the number of pairs is not maximized with this.\n\nSample Input 2\n\n15 10\n1 5 6 10 11 11 11 20 21 25 25 26 99 99 99\n\nSample Output 2\n\n6", "sample_input": "7 5\n3 1 4 1 5 9 2\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03912", "source_text": "Score : 700 points\n\nProblem Statement\n\nTakahashi is playing with N cards.\n\nThe i-th card has an integer X_i on it.\n\nTakahashi is trying to create as many pairs of cards as possible satisfying one of the following conditions:\n\nThe integers on the two cards are the same.\n\nThe sum of the integers on the two cards is a multiple of M.\n\nFind the maximum number of pairs that can be created.\n\nNote that a card cannot be used in more than one pair.\n\nConstraints\n\n2≦N≦10^5\n\n1≦M≦10^5\n\n1≦X_i≦10^5\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN M\nX_1 X_2 ... X_N\n\nOutput\n\nPrint the maximum number of pairs that can be created.\n\nSample Input 1\n\n7 5\n3 1 4 1 5 9 2\n\nSample Output 1\n\n3\n\nThree pairs (3,2), (1,4) and (1,9) can be created.\n\nIt is possible to create pairs (3,2) and (1,1), but the number of pairs is not maximized with this.\n\nSample Input 2\n\n15 10\n1 5 6 10 11 11 11 20 21 25 25 26 99 99 99\n\nSample Output 2\n\n6", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 986, "cpu_time_ms": 28, "memory_kb": 5760}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s878670791", "group_id": "codeNet:p03921", "input_text": "(* 配列版素集合データ構造 *)\nmodule RawUnionFind : sig\n type t\n type class_\n\n (* n要素の素集合データ構造を作る *)\n val make : int -> t\n (* 要素がどの集合に属するか調べる *)\n (* 要素は0からn-1の整数である必要がある *)\n val find : t -> int -> class_\n (* 与えられた要素が属する集合同士を合併する *)\n val unite : t -> int -> int -> unit\n\n val compare_class : class_ -> class_ -> int\nend = struct\n type t = { rank : int array; parent : int array }\n type class_ = int\n\n let make n =\n { rank = Array.make n 0;\n parent = Array.init n (fun c -> c) }\n\n let rec find uf x =\n if x = uf.parent.(x) then x\n else begin\n let y = find uf uf.parent.(x) in\n uf.parent.(x) <- y; y\n end\n\n let unite uf i j =\n let x = find uf i in\n let y = find uf j in\n if x <> y then begin\n if uf.rank.(x) < uf.rank.(y) then uf.parent.(x) <- y\n else begin\n uf.parent.(y) <- x;\n if uf.rank.(x) = uf.rank.(y) then\n uf.rank.(x) <- 1 + uf.rank.(x)\n end\n end\n\n let compare_class = compare\nend\n\nlet () = Scanf.scanf \"%d %d\\n\" @@ fun n m ->\n let ls = Array.make m [] in\n for i = 0 to n - 1 do\n Scanf.scanf \"%d \" @@ fun k ->\n for j = 0 to k - 1 do\n Scanf.scanf \"%d \" @@ fun l ->\n ls.(l - 1) <- i :: ls.(l - 1)\n done\n done;\n let uf = RawUnionFind.make n in\n Array.iter (function\n | [] -> ()\n | x :: xs -> List.iter (RawUnionFind.unite uf x) xs) ls;\n print_endline @@\n if\n List.for_all (fun x ->\n RawUnionFind.compare_class\n (RawUnionFind.find uf 0)\n (RawUnionFind.find uf x) = 0) @@\n Array.to_list @@\n Array.init n @@ fun i -> i\n then \"YES\"\n else \"NO\"\n\n", "language": "OCaml", "metadata": {"date": 1534785758, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03921.html", "problem_id": "p03921", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03921/input.txt", "sample_output_relpath": "derived/input_output/data/p03921/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03921/OCaml/s878670791.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s878670791", "user_id": "u504158101"}, "prompt_components": {"gold_output": "YES\n", "input_to_evaluate": "(* 配列版素集合データ構造 *)\nmodule RawUnionFind : sig\n type t\n type class_\n\n (* n要素の素集合データ構造を作る *)\n val make : int -> t\n (* 要素がどの集合に属するか調べる *)\n (* 要素は0からn-1の整数である必要がある *)\n val find : t -> int -> class_\n (* 与えられた要素が属する集合同士を合併する *)\n val unite : t -> int -> int -> unit\n\n val compare_class : class_ -> class_ -> int\nend = struct\n type t = { rank : int array; parent : int array }\n type class_ = int\n\n let make n =\n { rank = Array.make n 0;\n parent = Array.init n (fun c -> c) }\n\n let rec find uf x =\n if x = uf.parent.(x) then x\n else begin\n let y = find uf uf.parent.(x) in\n uf.parent.(x) <- y; y\n end\n\n let unite uf i j =\n let x = find uf i in\n let y = find uf j in\n if x <> y then begin\n if uf.rank.(x) < uf.rank.(y) then uf.parent.(x) <- y\n else begin\n uf.parent.(y) <- x;\n if uf.rank.(x) = uf.rank.(y) then\n uf.rank.(x) <- 1 + uf.rank.(x)\n end\n end\n\n let compare_class = compare\nend\n\nlet () = Scanf.scanf \"%d %d\\n\" @@ fun n m ->\n let ls = Array.make m [] in\n for i = 0 to n - 1 do\n Scanf.scanf \"%d \" @@ fun k ->\n for j = 0 to k - 1 do\n Scanf.scanf \"%d \" @@ fun l ->\n ls.(l - 1) <- i :: ls.(l - 1)\n done\n done;\n let uf = RawUnionFind.make n in\n Array.iter (function\n | [] -> ()\n | x :: xs -> List.iter (RawUnionFind.unite uf x) xs) ls;\n print_endline @@\n if\n List.for_all (fun x ->\n RawUnionFind.compare_class\n (RawUnionFind.find uf 0)\n (RawUnionFind.find uf x) = 0) @@\n Array.to_list @@\n Array.init n @@ fun i -> i\n then \"YES\"\n else \"NO\"\n\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nOn a planet far, far away, M languages are spoken. They are conveniently numbered 1 through M.\n\nFor CODE FESTIVAL 20XX held on this planet, N participants gathered from all over the planet.\n\nThe i-th (1≦i≦N) participant can speak K_i languages numbered L_{i,1}, L_{i,2}, ..., L_{i,{}K_i}.\n\nTwo participants A and B can communicate with each other if and only if one of the following conditions is satisfied:\n\nThere exists a language that both A and B can speak.\n\nThere exists a participant X that both A and B can communicate with.\n\nDetermine whether all N participants can communicate with all other participants.\n\nConstraints\n\n2≦N≦10^5\n\n1≦M≦10^5\n\n1≦K_i≦M\n\n(The sum of all K_i)≦10^5\n\n1≦L_{i,j}≦M\n\nL_{i,1}, L_{i,2}, ..., L_{i,{}K_i} are pairwise distinct.\n\nPartial Score\n\n200 points will be awarded for passing the test set satisfying the following: N≦1000, M≦1000 and (The sum of all K_i)≦1000.\n\nAdditional 200 points will be awarded for passing the test set without additional constraints.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN M\nK_1 L_{1,1} L_{1,2} ... L_{1,{}K_1}\nK_2 L_{2,1} L_{2,2} ... L_{2,{}K_2}\n:\nK_N L_{N,1} L_{N,2} ... L_{N,{}K_N}\n\nOutput\n\nIf all N participants can communicate with all other participants, print YES. Otherwise, print NO.\n\nSample Input 1\n\n4 6\n3 1 2 3\n2 4 2\n2 4 6\n1 6\n\nSample Output 1\n\nYES\n\nAny two participants can communicate with each other, as follows:\n\nParticipants 1 and 2: both can speak language 2.\n\nParticipants 2 and 3: both can speak language 4.\n\nParticipants 1 and 3: both can communicate with participant 2.\n\nParticipants 3 and 4: both can speak language 6.\n\nParticipants 2 and 4: both can communicate with participant 3.\n\nParticipants 1 and 4: both can communicate with participant 2.\n\nNote that there can be languages spoken by no participant.\n\nSample Input 2\n\n4 4\n2 1 2\n2 1 2\n1 3\n2 4 3\n\nSample Output 2\n\nNO\n\nFor example, participants 1 and 3 cannot communicate with each other.", "sample_input": "4 6\n3 1 2 3\n2 4 2\n2 4 6\n1 6\n"}, "reference_outputs": ["YES\n"], "source_document_id": "p03921", "source_text": "Score : 400 points\n\nProblem Statement\n\nOn a planet far, far away, M languages are spoken. They are conveniently numbered 1 through M.\n\nFor CODE FESTIVAL 20XX held on this planet, N participants gathered from all over the planet.\n\nThe i-th (1≦i≦N) participant can speak K_i languages numbered L_{i,1}, L_{i,2}, ..., L_{i,{}K_i}.\n\nTwo participants A and B can communicate with each other if and only if one of the following conditions is satisfied:\n\nThere exists a language that both A and B can speak.\n\nThere exists a participant X that both A and B can communicate with.\n\nDetermine whether all N participants can communicate with all other participants.\n\nConstraints\n\n2≦N≦10^5\n\n1≦M≦10^5\n\n1≦K_i≦M\n\n(The sum of all K_i)≦10^5\n\n1≦L_{i,j}≦M\n\nL_{i,1}, L_{i,2}, ..., L_{i,{}K_i} are pairwise distinct.\n\nPartial Score\n\n200 points will be awarded for passing the test set satisfying the following: N≦1000, M≦1000 and (The sum of all K_i)≦1000.\n\nAdditional 200 points will be awarded for passing the test set without additional constraints.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN M\nK_1 L_{1,1} L_{1,2} ... L_{1,{}K_1}\nK_2 L_{2,1} L_{2,2} ... L_{2,{}K_2}\n:\nK_N L_{N,1} L_{N,2} ... L_{N,{}K_N}\n\nOutput\n\nIf all N participants can communicate with all other participants, print YES. Otherwise, print NO.\n\nSample Input 1\n\n4 6\n3 1 2 3\n2 4 2\n2 4 6\n1 6\n\nSample Output 1\n\nYES\n\nAny two participants can communicate with each other, as follows:\n\nParticipants 1 and 2: both can speak language 2.\n\nParticipants 2 and 3: both can speak language 4.\n\nParticipants 1 and 3: both can communicate with participant 2.\n\nParticipants 3 and 4: both can speak language 6.\n\nParticipants 2 and 4: both can communicate with participant 3.\n\nParticipants 1 and 4: both can communicate with participant 2.\n\nNote that there can be languages spoken by no participant.\n\nSample Input 2\n\n4 4\n2 1 2\n2 1 2\n1 3\n2 4 3\n\nSample Output 2\n\nNO\n\nFor example, participants 1 and 3 cannot communicate with each other.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1748, "cpu_time_ms": 65, "memory_kb": 10240}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s044113466", "group_id": "codeNet:p03937", "input_text": "Scanf.scanf \"%d %d\" (fun h w ->\n let a = Array.init h (fun _ -> Scanf.scanf \" %s\" (fun s -> s)) in \n\n let rec loop x y f =\n let xf = x < w - 1 && a.(y).[x + 1] = '#' in\n let yf = y < h - 1 && a.(y + 1).[x] = '#' in\n let zf = x > 0 && a.(y).[x - 1] = '#' in\n let wf = y > 0 && a.(y - 1).[x] = '#' in\n if xf && yf then false else\n if f = 0 && wf then false else\n if f = 1 && zf then false else\n if xf then loop (x + 1) y 0 else\n if yf then loop x (y + 1) 1 else\n if x = w - 1 && y = h - 1 then true else\n false\n\n in\n print_endline @@ if loop 0 0 3 then \"Possible\" else \"Impossible\"\n)", "language": "OCaml", "metadata": {"date": 1589857097, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03937.html", "problem_id": "p03937", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03937/input.txt", "sample_output_relpath": "derived/input_output/data/p03937/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03937/OCaml/s044113466.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s044113466", "user_id": "u342443598"}, "prompt_components": {"gold_output": "Possible\n", "input_to_evaluate": "Scanf.scanf \"%d %d\" (fun h w ->\n let a = Array.init h (fun _ -> Scanf.scanf \" %s\" (fun s -> s)) in \n\n let rec loop x y f =\n let xf = x < w - 1 && a.(y).[x + 1] = '#' in\n let yf = y < h - 1 && a.(y + 1).[x] = '#' in\n let zf = x > 0 && a.(y).[x - 1] = '#' in\n let wf = y > 0 && a.(y - 1).[x] = '#' in\n if xf && yf then false else\n if f = 0 && wf then false else\n if f = 1 && zf then false else\n if xf then loop (x + 1) y 0 else\n if yf then loop x (y + 1) 1 else\n if x = w - 1 && y = h - 1 then true else\n false\n\n in\n print_endline @@ if loop 0 0 3 then \"Possible\" else \"Impossible\"\n)", "problem_context": "Score : 200 points\n\nProblem Statement\n\n#nck {\nwidth: 30px;\nheight: auto;\n}\n\nWe have a grid of H rows and W columns. Initially, there is a stone in the top left cell. Shik is trying to move the stone to the bottom right cell. In each step, he can move the stone one cell to its left, up, right, or down (if such cell exists). It is possible that the stone visits a cell multiple times (including the bottom right and the top left cell).\n\nYou are given a matrix of characters a_{ij} (1 \\leq i \\leq H, 1 \\leq j \\leq W). After Shik completes all moving actions, a_{ij} is # if the stone had ever located at the i-th row and the j-th column during the process of moving. Otherwise, a_{ij} is .. Please determine whether it is possible that Shik only uses right and down moves in all steps.\n\nConstraints\n\n2 \\leq H, W \\leq 8\n\na_{i,j} is either # or ..\n\nThere exists a valid sequence of moves for Shik to generate the map a.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nH W\na_{11}a_{12}...a_{1W}\n:\na_{H1}a_{H2}...a_{HW}\n\nOutput\n\nIf it is possible that Shik only uses right and down moves, print Possible. Otherwise, print Impossible.\n\nSample Input 1\n\n4 5\n##...\n.##..\n..##.\n...##\n\nSample Output 1\n\nPossible\n\nThe matrix can be generated by a 7-move sequence: right, down, right, down, right, down, and right.\n\nSample Input 2\n\n5 3\n###\n..#\n###\n#..\n###\n\nSample Output 2\n\nImpossible\n\nSample Input 3\n\n4 5\n##...\n.###.\n.###.\n...##\n\nSample Output 3\n\nImpossible", "sample_input": "4 5\n##...\n.##..\n..##.\n...##\n"}, "reference_outputs": ["Possible\n"], "source_document_id": "p03937", "source_text": "Score : 200 points\n\nProblem Statement\n\n#nck {\nwidth: 30px;\nheight: auto;\n}\n\nWe have a grid of H rows and W columns. Initially, there is a stone in the top left cell. Shik is trying to move the stone to the bottom right cell. In each step, he can move the stone one cell to its left, up, right, or down (if such cell exists). It is possible that the stone visits a cell multiple times (including the bottom right and the top left cell).\n\nYou are given a matrix of characters a_{ij} (1 \\leq i \\leq H, 1 \\leq j \\leq W). After Shik completes all moving actions, a_{ij} is # if the stone had ever located at the i-th row and the j-th column during the process of moving. Otherwise, a_{ij} is .. Please determine whether it is possible that Shik only uses right and down moves in all steps.\n\nConstraints\n\n2 \\leq H, W \\leq 8\n\na_{i,j} is either # or ..\n\nThere exists a valid sequence of moves for Shik to generate the map a.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nH W\na_{11}a_{12}...a_{1W}\n:\na_{H1}a_{H2}...a_{HW}\n\nOutput\n\nIf it is possible that Shik only uses right and down moves, print Possible. Otherwise, print Impossible.\n\nSample Input 1\n\n4 5\n##...\n.##..\n..##.\n...##\n\nSample Output 1\n\nPossible\n\nThe matrix can be generated by a 7-move sequence: right, down, right, down, right, down, and right.\n\nSample Input 2\n\n5 3\n###\n..#\n###\n#..\n###\n\nSample Output 2\n\nImpossible\n\nSample Input 3\n\n4 5\n##...\n.###.\n.###.\n...##\n\nSample Output 3\n\nImpossible", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 706, "cpu_time_ms": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s270138945", "group_id": "codeNet:p03943", "input_text": "open Batteries\nlet () =\n let a,b,c = Scanf.scanf \"%d %d %d \" (fun a b c -> a,b,c) in\n let lst = List.sort compare [a;b;c] in\n Printf.printf \"%s\\n\" @@\n if List.nth lst 2 = ((List.nth lst 0) + (List.nth lst 1)) then \"Yes\" else \"No\"\n", "language": "OCaml", "metadata": {"date": 1529165181, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03943.html", "problem_id": "p03943", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03943/input.txt", "sample_output_relpath": "derived/input_output/data/p03943/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03943/OCaml/s270138945.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s270138945", "user_id": "u139013163"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "open Batteries\nlet () =\n let a,b,c = Scanf.scanf \"%d %d %d \" (fun a b c -> a,b,c) in\n let lst = List.sort compare [a;b;c] in\n Printf.printf \"%s\\n\" @@\n if List.nth lst 2 = ((List.nth lst 0) + (List.nth lst 1)) then \"Yes\" else \"No\"\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nTwo students of AtCoder Kindergarten are fighting over candy packs.\n\nThere are three candy packs, each of which contains a, b, and c candies, respectively.\n\nTeacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible.\n\nNote that Evi cannot take candies out of the packs, and the whole contents of each pack must be given to one of the students.\n\nConstraints\n\n1 ≦ a, b, c ≦ 100\n\nInput\n\nThe input is given from Standard Input in the following format:\n\na b c\n\nOutput\n\nIf it is possible to distribute the packs so that each student gets the same number of candies, print Yes. Otherwise, print No.\n\nSample Input 1\n\n10 30 20\n\nSample Output 1\n\nYes\n\nGive the pack with 30 candies to one student, and give the two packs with 10 and 20 candies to the other. Then, each gets 30 candies.\n\nSample Input 2\n\n30 30 100\n\nSample Output 2\n\nNo\n\nIn this case, the student who gets the pack with 100 candies always has more candies than the other.\n\nNote that every pack must be given to one of them.\n\nSample Input 3\n\n56 25 31\n\nSample Output 3\n\nYes", "sample_input": "10 30 20\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03943", "source_text": "Score : 100 points\n\nProblem Statement\n\nTwo students of AtCoder Kindergarten are fighting over candy packs.\n\nThere are three candy packs, each of which contains a, b, and c candies, respectively.\n\nTeacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible.\n\nNote that Evi cannot take candies out of the packs, and the whole contents of each pack must be given to one of the students.\n\nConstraints\n\n1 ≦ a, b, c ≦ 100\n\nInput\n\nThe input is given from Standard Input in the following format:\n\na b c\n\nOutput\n\nIf it is possible to distribute the packs so that each student gets the same number of candies, print Yes. Otherwise, print No.\n\nSample Input 1\n\n10 30 20\n\nSample Output 1\n\nYes\n\nGive the pack with 30 candies to one student, and give the two packs with 10 and 20 candies to the other. Then, each gets 30 candies.\n\nSample Input 2\n\n30 30 100\n\nSample Output 2\n\nNo\n\nIn this case, the student who gets the pack with 100 candies always has more candies than the other.\n\nNote that every pack must be given to one of them.\n\nSample Input 3\n\n56 25 31\n\nSample Output 3\n\nYes", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 2, "memory_kb": 1024}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s285267473", "group_id": "codeNet:p03943", "input_text": "let solve l =\n let sl = List.sort compare l in\n match sl with\n a :: b :: c :: _ -> if a + b = c then \"Yes\" else \"No\"\n | _ -> \"\"\n\nlet () =\n Printf.printf \"%s\\n\" @@ Scanf.scanf \"%d %d %d\\n\" (fun x y z -> solve [x;y;z])\n\n", "language": "OCaml", "metadata": {"date": 1494959974, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03943.html", "problem_id": "p03943", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03943/input.txt", "sample_output_relpath": "derived/input_output/data/p03943/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03943/OCaml/s285267473.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s285267473", "user_id": "u388783188"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "let solve l =\n let sl = List.sort compare l in\n match sl with\n a :: b :: c :: _ -> if a + b = c then \"Yes\" else \"No\"\n | _ -> \"\"\n\nlet () =\n Printf.printf \"%s\\n\" @@ Scanf.scanf \"%d %d %d\\n\" (fun x y z -> solve [x;y;z])\n\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nTwo students of AtCoder Kindergarten are fighting over candy packs.\n\nThere are three candy packs, each of which contains a, b, and c candies, respectively.\n\nTeacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible.\n\nNote that Evi cannot take candies out of the packs, and the whole contents of each pack must be given to one of the students.\n\nConstraints\n\n1 ≦ a, b, c ≦ 100\n\nInput\n\nThe input is given from Standard Input in the following format:\n\na b c\n\nOutput\n\nIf it is possible to distribute the packs so that each student gets the same number of candies, print Yes. Otherwise, print No.\n\nSample Input 1\n\n10 30 20\n\nSample Output 1\n\nYes\n\nGive the pack with 30 candies to one student, and give the two packs with 10 and 20 candies to the other. Then, each gets 30 candies.\n\nSample Input 2\n\n30 30 100\n\nSample Output 2\n\nNo\n\nIn this case, the student who gets the pack with 100 candies always has more candies than the other.\n\nNote that every pack must be given to one of them.\n\nSample Input 3\n\n56 25 31\n\nSample Output 3\n\nYes", "sample_input": "10 30 20\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03943", "source_text": "Score : 100 points\n\nProblem Statement\n\nTwo students of AtCoder Kindergarten are fighting over candy packs.\n\nThere are three candy packs, each of which contains a, b, and c candies, respectively.\n\nTeacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible.\n\nNote that Evi cannot take candies out of the packs, and the whole contents of each pack must be given to one of the students.\n\nConstraints\n\n1 ≦ a, b, c ≦ 100\n\nInput\n\nThe input is given from Standard Input in the following format:\n\na b c\n\nOutput\n\nIf it is possible to distribute the packs so that each student gets the same number of candies, print Yes. Otherwise, print No.\n\nSample Input 1\n\n10 30 20\n\nSample Output 1\n\nYes\n\nGive the pack with 30 candies to one student, and give the two packs with 10 and 20 candies to the other. Then, each gets 30 candies.\n\nSample Input 2\n\n30 30 100\n\nSample Output 2\n\nNo\n\nIn this case, the student who gets the pack with 100 candies always has more candies than the other.\n\nNote that every pack must be given to one of them.\n\nSample Input 3\n\n56 25 31\n\nSample Output 3\n\nYes", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s793622735", "group_id": "codeNet:p03951", "input_text": "Scanf.scanf \"%d %s %s\" (fun n s t ->\n let rec loop dup =\n if dup = 0 then dup else\n let rec loop2 a b =\n if b < 0 then dup else\n if s.[a] = t.[b] then loop2 (a - 1) (b - 1)\n else loop (dup - 1)\n in\n loop2 (n - 1) (dup - 1)\n in\n let dup = loop n in\n Printf.printf \"%d\\n\" (n * 2 - dup)\n)", "language": "OCaml", "metadata": {"date": 1589510425, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03951.html", "problem_id": "p03951", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03951/input.txt", "sample_output_relpath": "derived/input_output/data/p03951/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03951/OCaml/s793622735.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s793622735", "user_id": "u342443598"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "Scanf.scanf \"%d %s %s\" (fun n s t ->\n let rec loop dup =\n if dup = 0 then dup else\n let rec loop2 a b =\n if b < 0 then dup else\n if s.[a] = t.[b] then loop2 (a - 1) (b - 1)\n else loop (dup - 1)\n in\n loop2 (n - 1) (dup - 1)\n in\n let dup = loop n in\n Printf.printf \"%d\\n\" (n * 2 - dup)\n)", "problem_context": "Score : 200 points\n\nProblem Statement\n\nSnuke is interested in strings that satisfy the following conditions:\n\nThe length of the string is at least N.\n\nThe first N characters equal to the string s.\n\nThe last N characters equal to the string t.\n\nFind the length of the shortest string that satisfies the conditions.\n\nConstraints\n\n1≤N≤100\n\nThe lengths of s and t are both N.\n\ns and t consist of lowercase English letters.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\ns\nt\n\nOutput\n\nPrint the length of the shortest string that satisfies the conditions.\n\nSample Input 1\n\n3\nabc\ncde\n\nSample Output 1\n\n5\n\nThe shortest string is abcde.\n\nSample Input 2\n\n1\na\nz\n\nSample Output 2\n\n2\n\nThe shortest string is az.\n\nSample Input 3\n\n4\nexpr\nexpr\n\nSample Output 3\n\n4\n\nThe shortest string is expr.", "sample_input": "3\nabc\ncde\n"}, "reference_outputs": ["5\n"], "source_document_id": "p03951", "source_text": "Score : 200 points\n\nProblem Statement\n\nSnuke is interested in strings that satisfy the following conditions:\n\nThe length of the string is at least N.\n\nThe first N characters equal to the string s.\n\nThe last N characters equal to the string t.\n\nFind the length of the shortest string that satisfies the conditions.\n\nConstraints\n\n1≤N≤100\n\nThe lengths of s and t are both N.\n\ns and t consist of lowercase English letters.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\ns\nt\n\nOutput\n\nPrint the length of the shortest string that satisfies the conditions.\n\nSample Input 1\n\n3\nabc\ncde\n\nSample Output 1\n\n5\n\nThe shortest string is abcde.\n\nSample Input 2\n\n1\na\nz\n\nSample Output 2\n\n2\n\nThe shortest string is az.\n\nSample Input 3\n\n4\nexpr\nexpr\n\nSample Output 3\n\n4\n\nThe shortest string is expr.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 390, "cpu_time_ms": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s915810432", "group_id": "codeNet:p03951", "input_text": "let () =\n\tlet n = read_int () in\n\tlet s = read_line () in\n\tlet t = read_line () in\n\tlet rec loop s t n =\n\t\tif n = 0 then 0\n\t\telse if Str.last_chars s n = Str.first_chars t n then n\n\t\telse loop s t (n - 1)\n\tin\n\tloop s t n\n\t|> ( - ) (n * 2)\n\t|> print_int\n\t|> print_newline\n", "language": "OCaml", "metadata": {"date": 1477794205, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03951.html", "problem_id": "p03951", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03951/input.txt", "sample_output_relpath": "derived/input_output/data/p03951/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03951/OCaml/s915810432.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s915810432", "user_id": "u420267469"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "let () =\n\tlet n = read_int () in\n\tlet s = read_line () in\n\tlet t = read_line () in\n\tlet rec loop s t n =\n\t\tif n = 0 then 0\n\t\telse if Str.last_chars s n = Str.first_chars t n then n\n\t\telse loop s t (n - 1)\n\tin\n\tloop s t n\n\t|> ( - ) (n * 2)\n\t|> print_int\n\t|> print_newline\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nSnuke is interested in strings that satisfy the following conditions:\n\nThe length of the string is at least N.\n\nThe first N characters equal to the string s.\n\nThe last N characters equal to the string t.\n\nFind the length of the shortest string that satisfies the conditions.\n\nConstraints\n\n1≤N≤100\n\nThe lengths of s and t are both N.\n\ns and t consist of lowercase English letters.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\ns\nt\n\nOutput\n\nPrint the length of the shortest string that satisfies the conditions.\n\nSample Input 1\n\n3\nabc\ncde\n\nSample Output 1\n\n5\n\nThe shortest string is abcde.\n\nSample Input 2\n\n1\na\nz\n\nSample Output 2\n\n2\n\nThe shortest string is az.\n\nSample Input 3\n\n4\nexpr\nexpr\n\nSample Output 3\n\n4\n\nThe shortest string is expr.", "sample_input": "3\nabc\ncde\n"}, "reference_outputs": ["5\n"], "source_document_id": "p03951", "source_text": "Score : 200 points\n\nProblem Statement\n\nSnuke is interested in strings that satisfy the following conditions:\n\nThe length of the string is at least N.\n\nThe first N characters equal to the string s.\n\nThe last N characters equal to the string t.\n\nFind the length of the shortest string that satisfies the conditions.\n\nConstraints\n\n1≤N≤100\n\nThe lengths of s and t are both N.\n\ns and t consist of lowercase English letters.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\ns\nt\n\nOutput\n\nPrint the length of the shortest string that satisfies the conditions.\n\nSample Input 1\n\n3\nabc\ncde\n\nSample Output 1\n\n5\n\nThe shortest string is abcde.\n\nSample Input 2\n\n1\na\nz\n\nSample Output 2\n\n2\n\nThe shortest string is az.\n\nSample Input 3\n\n4\nexpr\nexpr\n\nSample Output 3\n\n4\n\nThe shortest string is expr.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 2, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s837950889", "group_id": "codeNet:p03957", "input_text": "let () =\n let s = read_line () in\n print_endline @@\n match\n List.find (fun i -> s.[i] = 'C') @@\n Array.to_list @@\n Array.init (String.length s) @@\n fun i -> i\n with\n | exception Not_found -> \"No\"\n | i ->\n if \n List.exists (( = ) 'F') @@\n Array.to_list @@\n Array.init (String.length s - i - 1) @@\n fun j -> s.[i + j + 1]\n then \"Yes\"\n else \"No\"\n", "language": "OCaml", "metadata": {"date": 1534970140, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03957.html", "problem_id": "p03957", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03957/input.txt", "sample_output_relpath": "derived/input_output/data/p03957/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03957/OCaml/s837950889.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s837950889", "user_id": "u504158101"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "let () =\n let s = read_line () in\n print_endline @@\n match\n List.find (fun i -> s.[i] = 'C') @@\n Array.to_list @@\n Array.init (String.length s) @@\n fun i -> i\n with\n | exception Not_found -> \"No\"\n | i ->\n if \n List.exists (( = ) 'F') @@\n Array.to_list @@\n Array.init (String.length s - i - 1) @@\n fun j -> s.[i + j + 1]\n then \"Yes\"\n else \"No\"\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nThis contest is CODEFESTIVAL, which can be shortened to the string CF by deleting some characters.\n\nMr. Takahashi, full of curiosity, wondered if he could obtain CF from other strings in the same way.\n\nYou are given a string s consisting of uppercase English letters.\nDetermine whether the string CF can be obtained from the string s by deleting some characters.\n\nConstraints\n\n2 ≤ |s| ≤ 100\n\nAll characters in s are uppercase English letters (A-Z).\n\nInput\n\nThe input is given from Standard Input in the following format:\n\ns\n\nOutput\n\nPrint Yes if the string CF can be obtained from the string s by deleting some characters.\nOtherwise print No.\n\nSample Input 1\n\nCODEFESTIVAL\n\nSample Output 1\n\nYes\n\nCF is obtained by deleting characters other than the first character C and the fifth character F.\n\nSample Input 2\n\nFESTIVALCODE\n\nSample Output 2\n\nNo\n\nFC can be obtained but CF cannot be obtained because you cannot change the order of the characters.\n\nSample Input 3\n\nCF\n\nSample Output 3\n\nYes\n\nIt is also possible not to delete any characters.\n\nSample Input 4\n\nFCF\n\nSample Output 4\n\nYes\n\nCF is obtained by deleting the first character.", "sample_input": "CODEFESTIVAL\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p03957", "source_text": "Score : 100 points\n\nProblem Statement\n\nThis contest is CODEFESTIVAL, which can be shortened to the string CF by deleting some characters.\n\nMr. Takahashi, full of curiosity, wondered if he could obtain CF from other strings in the same way.\n\nYou are given a string s consisting of uppercase English letters.\nDetermine whether the string CF can be obtained from the string s by deleting some characters.\n\nConstraints\n\n2 ≤ |s| ≤ 100\n\nAll characters in s are uppercase English letters (A-Z).\n\nInput\n\nThe input is given from Standard Input in the following format:\n\ns\n\nOutput\n\nPrint Yes if the string CF can be obtained from the string s by deleting some characters.\nOtherwise print No.\n\nSample Input 1\n\nCODEFESTIVAL\n\nSample Output 1\n\nYes\n\nCF is obtained by deleting characters other than the first character C and the fifth character F.\n\nSample Input 2\n\nFESTIVALCODE\n\nSample Output 2\n\nNo\n\nFC can be obtained but CF cannot be obtained because you cannot change the order of the characters.\n\nSample Input 3\n\nCF\n\nSample Output 3\n\nYes\n\nIt is also possible not to delete any characters.\n\nSample Input 4\n\nFCF\n\nSample Output 4\n\nYes\n\nCF is obtained by deleting the first character.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 416, "cpu_time_ms": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s649352284", "group_id": "codeNet:p03958", "input_text": "let k, t = Scanf.scanf \" %d %d\" @@ fun a b -> a, b\nlet a_s = Array.init t @@ fun _ -> Scanf.scanf \" %d\" (+) 0\nlet m, s = Array.(fold_left max a_s.(0) a_s, fold_left (+) 0 a_s)\nlet _ = Printf.printf \"%d\\n\" @@ max 0 @@ 2 * m - s - 1", "language": "OCaml", "metadata": {"date": 1570904950, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03958.html", "problem_id": "p03958", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03958/input.txt", "sample_output_relpath": "derived/input_output/data/p03958/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03958/OCaml/s649352284.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s649352284", "user_id": "u732304692"}, "prompt_components": {"gold_output": "0\n", "input_to_evaluate": "let k, t = Scanf.scanf \" %d %d\" @@ fun a b -> a, b\nlet a_s = Array.init t @@ fun _ -> Scanf.scanf \" %d\" (+) 0\nlet m, s = Array.(fold_left max a_s.(0) a_s, fold_left (+) 0 a_s)\nlet _ = Printf.printf \"%d\\n\" @@ max 0 @@ 2 * m - s - 1", "problem_context": "Score : 200 points\n\nProblem Statement\n\nThere are K pieces of cakes.\nMr. Takahashi would like to eat one cake per day, taking K days to eat them all.\n\nThere are T types of cake, and the number of the cakes of type i (1 ≤ i ≤ T) is a_i.\n\nEating the same type of cake two days in a row would be no fun,\nso Mr. Takahashi would like to decide the order for eating cakes that minimizes the number of days on which he has to eat the same type of cake as the day before.\n\nCompute the minimum number of days on which the same type of cake as the previous day will be eaten.\n\nConstraints\n\n1 ≤ K ≤ 10000\n\n1 ≤ T ≤ 100\n\n1 ≤ a_i ≤ 100\n\na_1 + a_2 + ... + a_T = K\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nK T\na_1 a_2 ... a_T\n\nOutput\n\nPrint the minimum number of days on which the same type of cake as the previous day will be eaten.\n\nSample Input 1\n\n7 3\n3 2 2\n\nSample Output 1\n\n0\n\nFor example, if Mr. Takahashi eats cakes in the order of 2, 1, 2, 3, 1, 3, 1, he can avoid eating the same type of cake as the previous day.\n\nSample Input 2\n\n6 3\n1 4 1\n\nSample Output 2\n\n1\n\nThere are 6 cakes.\nFor example, if Mr. Takahashi eats cakes in the order of 2, 3, 2, 2, 1, 2, he has to eat the same type of cake (i.e., type 2) as the previous day only on the fourth day.\nSince this is the minimum number, the answer is 1.\n\nSample Input 3\n\n100 1\n100\n\nSample Output 3\n\n99\n\nSince Mr. Takahashi has only one type of cake, he has no choice but to eat the same type of cake as the previous day from the second day and after.", "sample_input": "7 3\n3 2 2\n"}, "reference_outputs": ["0\n"], "source_document_id": "p03958", "source_text": "Score : 200 points\n\nProblem Statement\n\nThere are K pieces of cakes.\nMr. Takahashi would like to eat one cake per day, taking K days to eat them all.\n\nThere are T types of cake, and the number of the cakes of type i (1 ≤ i ≤ T) is a_i.\n\nEating the same type of cake two days in a row would be no fun,\nso Mr. Takahashi would like to decide the order for eating cakes that minimizes the number of days on which he has to eat the same type of cake as the day before.\n\nCompute the minimum number of days on which the same type of cake as the previous day will be eaten.\n\nConstraints\n\n1 ≤ K ≤ 10000\n\n1 ≤ T ≤ 100\n\n1 ≤ a_i ≤ 100\n\na_1 + a_2 + ... + a_T = K\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nK T\na_1 a_2 ... a_T\n\nOutput\n\nPrint the minimum number of days on which the same type of cake as the previous day will be eaten.\n\nSample Input 1\n\n7 3\n3 2 2\n\nSample Output 1\n\n0\n\nFor example, if Mr. Takahashi eats cakes in the order of 2, 1, 2, 3, 1, 3, 1, he can avoid eating the same type of cake as the previous day.\n\nSample Input 2\n\n6 3\n1 4 1\n\nSample Output 2\n\n1\n\nThere are 6 cakes.\nFor example, if Mr. Takahashi eats cakes in the order of 2, 3, 2, 2, 1, 2, he has to eat the same type of cake (i.e., type 2) as the previous day only on the fourth day.\nSince this is the minimum number, the answer is 1.\n\nSample Input 3\n\n100 1\n100\n\nSample Output 3\n\n99\n\nSince Mr. Takahashi has only one type of cake, he has no choice but to eat the same type of cake as the previous day from the second day and after.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 230, "cpu_time_ms": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s775700032", "group_id": "codeNet:p03962", "input_text": "let () = Scanf.scanf \"%d %d %d\" @@ fun a b c ->\n List.sort_uniq compare [a; b; c]\n |> List.length\n |> Printf.printf \"%d\\n\"", "language": "OCaml", "metadata": {"date": 1530669521, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03962.html", "problem_id": "p03962", "resource_group": "low_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/OCaml/s775700032.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s775700032", "user_id": "u504158101"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "let () = Scanf.scanf \"%d %d %d\" @@ fun a b c ->\n List.sort_uniq compare [a; b; c]\n |> List.length\n |> Printf.printf \"%d\\n\"", "problem_context": "Score : 100 points\n\nProblem Statement\n\nAtCoDeer the deer recently bought three paint cans.\nThe color of the one he bought two days ago is a, the color of the one he bought yesterday is b, and the color of the one he bought today is c.\nHere, the color of each paint can is represented by an integer between 1 and 100, inclusive.\n\nSince he is forgetful, he might have bought more than one paint can in the same color.\nCount the number of different kinds of colors of these paint cans and tell him.\n\nConstraints\n\n1≦a,b,c≦100\n\nInput\n\nThe input is given from Standard Input in the following format:\n\na b c\n\nOutput\n\nPrint the number of different kinds of colors of the paint cans.\n\nSample Input 1\n\n3 1 4\n\nSample Output 1\n\n3\n\nThree different colors: 1, 3, and 4.\n\nSample Input 2\n\n3 3 33\n\nSample Output 2\n\n2\n\nTwo different colors: 3 and 33.", "sample_input": "3 1 4\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03962", "source_text": "Score : 100 points\n\nProblem Statement\n\nAtCoDeer the deer recently bought three paint cans.\nThe color of the one he bought two days ago is a, the color of the one he bought yesterday is b, and the color of the one he bought today is c.\nHere, the color of each paint can is represented by an integer between 1 and 100, inclusive.\n\nSince he is forgetful, he might have bought more than one paint can in the same color.\nCount the number of different kinds of colors of these paint cans and tell him.\n\nConstraints\n\n1≦a,b,c≦100\n\nInput\n\nThe input is given from Standard Input in the following format:\n\na b c\n\nOutput\n\nPrint the number of different kinds of colors of the paint cans.\n\nSample Input 1\n\n3 1 4\n\nSample Output 1\n\n3\n\nThree different colors: 1, 3, and 4.\n\nSample Input 2\n\n3 3 33\n\nSample Output 2\n\n2\n\nTwo different colors: 3 and 33.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s343587069", "group_id": "codeNet:p03962", "input_text": "let () =\n let a,b,c = Scanf.scanf \"%d %d %d \" (fun a b c -> a,b,c) in\n Printf.printf \"%d\\n\" \n ([a;b;c] |> List.sort_uniq compare |> List.length)\n", "language": "OCaml", "metadata": {"date": 1528720463, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03962.html", "problem_id": "p03962", "resource_group": "low_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/OCaml/s343587069.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s343587069", "user_id": "u139013163"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "let () =\n let a,b,c = Scanf.scanf \"%d %d %d \" (fun a b c -> a,b,c) in\n Printf.printf \"%d\\n\" \n ([a;b;c] |> List.sort_uniq compare |> List.length)\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nAtCoDeer the deer recently bought three paint cans.\nThe color of the one he bought two days ago is a, the color of the one he bought yesterday is b, and the color of the one he bought today is c.\nHere, the color of each paint can is represented by an integer between 1 and 100, inclusive.\n\nSince he is forgetful, he might have bought more than one paint can in the same color.\nCount the number of different kinds of colors of these paint cans and tell him.\n\nConstraints\n\n1≦a,b,c≦100\n\nInput\n\nThe input is given from Standard Input in the following format:\n\na b c\n\nOutput\n\nPrint the number of different kinds of colors of the paint cans.\n\nSample Input 1\n\n3 1 4\n\nSample Output 1\n\n3\n\nThree different colors: 1, 3, and 4.\n\nSample Input 2\n\n3 3 33\n\nSample Output 2\n\n2\n\nTwo different colors: 3 and 33.", "sample_input": "3 1 4\n"}, "reference_outputs": ["3\n"], "source_document_id": "p03962", "source_text": "Score : 100 points\n\nProblem Statement\n\nAtCoDeer the deer recently bought three paint cans.\nThe color of the one he bought two days ago is a, the color of the one he bought yesterday is b, and the color of the one he bought today is c.\nHere, the color of each paint can is represented by an integer between 1 and 100, inclusive.\n\nSince he is forgetful, he might have bought more than one paint can in the same color.\nCount the number of different kinds of colors of these paint cans and tell him.\n\nConstraints\n\n1≦a,b,c≦100\n\nInput\n\nThe input is given from Standard Input in the following format:\n\na b c\n\nOutput\n\nPrint the number of different kinds of colors of the paint cans.\n\nSample Input 1\n\n3 1 4\n\nSample Output 1\n\n3\n\nThree different colors: 1, 3, and 4.\n\nSample Input 2\n\n3 3 33\n\nSample Output 2\n\n2\n\nTwo different colors: 3 and 33.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s504088368", "group_id": "codeNet:p03963", "input_text": "let rec p a n = if n <= 0 then 1 else a * p a (n-1)\nlet () = Scanf.scanf \"%d %d\" (fun n k -> k * p (k-1) (n-1)) |> Printf.printf \"%d\\n\"\n", "language": "OCaml", "metadata": {"date": 1519720654, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03963.html", "problem_id": "p03963", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03963/input.txt", "sample_output_relpath": "derived/input_output/data/p03963/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03963/OCaml/s504088368.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s504088368", "user_id": "u798181098"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "let rec p a n = if n <= 0 then 1 else a * p a (n-1)\nlet () = Scanf.scanf \"%d %d\" (fun n k -> k * p (k-1) (n-1)) |> Printf.printf \"%d\\n\"\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nThere are N balls placed in a row.\nAtCoDeer the deer is painting each of these in one of the K colors of his paint cans.\nFor aesthetic reasons, any two adjacent balls must be painted in different colors.\n\nFind the number of the possible ways to paint the balls.\n\nConstraints\n\n1≦N≦1000\n\n2≦K≦1000\n\nThe correct answer is at most 2^{31}-1.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN K\n\nOutput\n\nPrint the number of the possible ways to paint the balls.\n\nSample Input 1\n\n2 2\n\nSample Output 1\n\n2\n\nWe will denote the colors by 0 and 1. There are two possible ways: we can either paint the left ball in color 0 and the right ball in color 1, or paint the left in color 1 and the right in color 0.\n\nSample Input 2\n\n1 10\n\nSample Output 2\n\n10\n\nSince there is only one ball, we can use any of the ten colors to paint it. Thus, the answer is ten.", "sample_input": "2 2\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03963", "source_text": "Score : 200 points\n\nProblem Statement\n\nThere are N balls placed in a row.\nAtCoDeer the deer is painting each of these in one of the K colors of his paint cans.\nFor aesthetic reasons, any two adjacent balls must be painted in different colors.\n\nFind the number of the possible ways to paint the balls.\n\nConstraints\n\n1≦N≦1000\n\n2≦K≦1000\n\nThe correct answer is at most 2^{31}-1.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN K\n\nOutput\n\nPrint the number of the possible ways to paint the balls.\n\nSample Input 1\n\n2 2\n\nSample Output 1\n\n2\n\nWe will denote the colors by 0 and 1. There are two possible ways: we can either paint the left ball in color 0 and the right ball in color 1, or paint the left in color 1 and the right in color 0.\n\nSample Input 2\n\n1 10\n\nSample Output 2\n\n10\n\nSince there is only one ball, we can use any of the ten colors to paint it. Thus, the answer is ten.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s897733691", "group_id": "codeNet:p03964", "input_text": "let tas = Array.init (read_int ()) @@ fun _ -> Scanf.scanf \" %d %d\" @@ fun a b -> a, b\nlet x, y = Array.fold_left (fun (x, y) (t, a) -> let k = max ((x + t - 1) / t) ((y + a - 1) / a) in k * t, k * a) tas.(0) tas\nlet _ = Printf.printf \"%d\\n\" @@ x + y", "language": "OCaml", "metadata": {"date": 1583212052, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03964.html", "problem_id": "p03964", "resource_group": "low_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/OCaml/s897733691.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s897733691", "user_id": "u732304692"}, "prompt_components": {"gold_output": "10\n", "input_to_evaluate": "let tas = Array.init (read_int ()) @@ fun _ -> Scanf.scanf \" %d %d\" @@ fun a b -> a, b\nlet x, y = Array.fold_left (fun (x, y) (t, a) -> let k = max ((x + t - 1) / t) ((y + a - 1) / a) in k * t, k * a) tas.(0) tas\nlet _ = Printf.printf \"%d\\n\" @@ x + y", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 2, "memory_kb": 1024}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s540806344", "group_id": "codeNet:p03964", "input_text": "open Batteries\n\nlet solve (a, b) (x, y) =\n let ratio = max ((a-1) / x+1) ((b-1) / y+1) in\n (x*ratio, y*ratio)\n\nlet () =\n IO.lines_of stdin\n |> Enum.skip 1\n |> Enum.map (fun l -> Scanf.sscanf l \"%d %d\" (fun x y -> (x, y)))\n |> Enum.fold solve (1, 1)\n |> fun (x, y) -> Int.print stdout (x + y)\n", "language": "OCaml", "metadata": {"date": 1477906906, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03964.html", "problem_id": "p03964", "resource_group": "low_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/OCaml/s540806344.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s540806344", "user_id": "u372610492"}, "prompt_components": {"gold_output": "10\n", "input_to_evaluate": "open Batteries\n\nlet solve (a, b) (x, y) =\n let ratio = max ((a-1) / x+1) ((b-1) / y+1) in\n (x*ratio, y*ratio)\n\nlet () =\n IO.lines_of stdin\n |> Enum.skip 1\n |> Enum.map (fun l -> Scanf.sscanf l \"%d %d\" (fun x y -> (x, y)))\n |> Enum.fold solve (1, 1)\n |> fun (x, y) -> Int.print stdout (x + y)\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nAtCoDeer the deer is seeing a quick report of election results on TV.\nTwo candidates are standing for the election: Takahashi and Aoki.\nThe report shows the ratio of the current numbers of votes the two candidates have obtained, but not the actual numbers of votes.\nAtCoDeer has checked the report N times, and when he checked it for the i-th (1≦i≦N) time, the ratio was T_i:A_i.\nIt is known that each candidate had at least one vote when he checked the report for the first time.\n\nFind the minimum possible total number of votes obtained by the two candidates when he checked the report for the N-th time.\nIt can be assumed that the number of votes obtained by each candidate never decreases.\n\nConstraints\n\n1≦N≦1000\n\n1≦T_i,A_i≦1000 (1≦i≦N)\n\nT_i and A_i (1≦i≦N) are coprime.\n\nIt is guaranteed that the correct answer is at most 10^{18}.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\nT_1 A_1\nT_2 A_2\n:\nT_N A_N\n\nOutput\n\nPrint the minimum possible total number of votes obtained by Takahashi and Aoki when AtCoDeer checked the report for the N-th time.\n\nSample Input 1\n\n3\n2 3\n1 1\n3 2\n\nSample Output 1\n\n10\n\nWhen the numbers of votes obtained by the two candidates change as 2,3 → 3,3 → 6,4, the total number of votes at the end is 10, which is the minimum possible number.\n\nSample Input 2\n\n4\n1 1\n1 1\n1 5\n1 100\n\nSample Output 2\n\n101\n\nIt is possible that neither candidate obtained a vote between the moment when he checked the report, and the moment when he checked it for the next time.\n\nSample Input 3\n\n5\n3 10\n48 17\n31 199\n231 23\n3 2\n\nSample Output 3\n\n6930", "sample_input": "3\n2 3\n1 1\n3 2\n"}, "reference_outputs": ["10\n"], "source_document_id": "p03964", "source_text": "Score : 300 points\n\nProblem Statement\n\nAtCoDeer the deer is seeing a quick report of election results on TV.\nTwo candidates are standing for the election: Takahashi and Aoki.\nThe report shows the ratio of the current numbers of votes the two candidates have obtained, but not the actual numbers of votes.\nAtCoDeer has checked the report N times, and when he checked it for the i-th (1≦i≦N) time, the ratio was T_i:A_i.\nIt is known that each candidate had at least one vote when he checked the report for the first time.\n\nFind the minimum possible total number of votes obtained by the two candidates when he checked the report for the N-th time.\nIt can be assumed that the number of votes obtained by each candidate never decreases.\n\nConstraints\n\n1≦N≦1000\n\n1≦T_i,A_i≦1000 (1≦i≦N)\n\nT_i and A_i (1≦i≦N) are coprime.\n\nIt is guaranteed that the correct answer is at most 10^{18}.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\nT_1 A_1\nT_2 A_2\n:\nT_N A_N\n\nOutput\n\nPrint the minimum possible total number of votes obtained by Takahashi and Aoki when AtCoDeer checked the report for the N-th time.\n\nSample Input 1\n\n3\n2 3\n1 1\n3 2\n\nSample Output 1\n\n10\n\nWhen the numbers of votes obtained by the two candidates change as 2,3 → 3,3 → 6,4, the total number of votes at the end is 10, which is the minimum possible number.\n\nSample Input 2\n\n4\n1 1\n1 1\n1 5\n1 100\n\nSample Output 2\n\n101\n\nIt is possible that neither candidate obtained a vote between the moment when he checked the report, and the moment when he checked it for the next time.\n\nSample Input 3\n\n5\n3 10\n48 17\n31 199\n231 23\n3 2\n\nSample Output 3\n\n6930", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 7, "memory_kb": 2944}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s820511209", "group_id": "codeNet:p03965", "input_text": "let list_of_str s = let rec f i = if i >= String.length s then [] else s.[i] :: f (i+1) in f 0\nlet f v c = if c = 'g' then v+1 else v-1\nlet () =\n let r = Scanf.scanf \"%s\" list_of_str |> List.fold_left f 0 in\n Printf.printf \"%d\\n\" (r/2)", "language": "OCaml", "metadata": {"date": 1531974274, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03965.html", "problem_id": "p03965", "resource_group": "low_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/OCaml/s820511209.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s820511209", "user_id": "u798181098"}, "prompt_components": {"gold_output": "0\n", "input_to_evaluate": "let list_of_str s = let rec f i = if i >= String.length s then [] else s.[i] :: f (i+1) in f 0\nlet f v c = if c = 'g' then v+1 else v-1\nlet () =\n let r = Scanf.scanf \"%s\" list_of_str |> List.fold_left f 0 in\n Printf.printf \"%d\\n\" (r/2)", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 10, "memory_kb": 9472}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s313673856", "group_id": "codeNet:p03966", "input_text": "Scanf.scanf \"%d\" (fun n ->\n let ta = Array.init n (fun _ -> Scanf.scanf \" %d %d\" (fun t a -> t, a)) in\n\n let rec loop i t a =\n if i = n then Printf.printf \"%d\\n\" (t + a) else\n let t1, a1 = ta.(i) in\n\n let t2 = (t + t1 - 1) / t1 * t1 in\n let a2 = t2 / t1 * a1 in\n\n let a3 = (a + a1 - 1) / a1 * a1 in\n let t3 = a3 / a1 * t1 in\n\n if t2 >= t && a2 >= a then (\n if t3 >= t && a3 >= a then (\n if t2 < t3 then loop (i + 1) t2 a2\n else loop (i + 1) t3 a3\n ) else loop (i + 1) t2 a2\n ) else loop (i + 1) t3 a3\n in\n loop 1 (fst ta.(0)) (snd ta.(0))\n)", "language": "OCaml", "metadata": {"date": 1595560813, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p03966.html", "problem_id": "p03966", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03966/input.txt", "sample_output_relpath": "derived/input_output/data/p03966/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03966/OCaml/s313673856.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s313673856", "user_id": "u342443598"}, "prompt_components": {"gold_output": "10\n", "input_to_evaluate": "Scanf.scanf \"%d\" (fun n ->\n let ta = Array.init n (fun _ -> Scanf.scanf \" %d %d\" (fun t a -> t, a)) in\n\n let rec loop i t a =\n if i = n then Printf.printf \"%d\\n\" (t + a) else\n let t1, a1 = ta.(i) in\n\n let t2 = (t + t1 - 1) / t1 * t1 in\n let a2 = t2 / t1 * a1 in\n\n let a3 = (a + a1 - 1) / a1 * a1 in\n let t3 = a3 / a1 * t1 in\n\n if t2 >= t && a2 >= a then (\n if t3 >= t && a3 >= a then (\n if t2 < t3 then loop (i + 1) t2 a2\n else loop (i + 1) t3 a3\n ) else loop (i + 1) t2 a2\n ) else loop (i + 1) t3 a3\n in\n loop 1 (fst ta.(0)) (snd ta.(0))\n)", "problem_context": "Score : 300 points\n\nProblem Statement\n\nAtCoDeer the deer is seeing a quick report of election results on TV.\nTwo candidates are standing for the election: Takahashi and Aoki.\nThe report shows the ratio of the current numbers of votes the two candidates have obtained, but not the actual numbers of votes.\nAtCoDeer has checked the report N times, and when he checked it for the i-th (1≦i≦N) time, the ratio was T_i:A_i.\nIt is known that each candidate had at least one vote when he checked the report for the first time.\n\nFind the minimum possible total number of votes obtained by the two candidates when he checked the report for the N-th time.\nIt can be assumed that the number of votes obtained by each candidate never decreases.\n\nConstraints\n\n1≦N≦1000\n\n1≦T_i,A_i≦1000 (1≦i≦N)\n\nT_i and A_i (1≦i≦N) are coprime.\n\nIt is guaranteed that the correct answer is at most 10^{18}.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\nT_1 A_1\nT_2 A_2\n:\nT_N A_N\n\nOutput\n\nPrint the minimum possible total number of votes obtained by Takahashi and Aoki when AtCoDeer checked the report for the N-th time.\n\nSample Input 1\n\n3\n2 3\n1 1\n3 2\n\nSample Output 1\n\n10\n\nWhen the numbers of votes obtained by the two candidates change as 2,3 → 3,3 → 6,4, the total number of votes at the end is 10, which is the minimum possible number.\n\nSample Input 2\n\n4\n1 1\n1 1\n1 5\n1 100\n\nSample Output 2\n\n101\n\nIt is possible that neither candidate obtained a vote between the moment when he checked the report, and the moment when he checked it for the next time.\n\nSample Input 3\n\n5\n3 10\n48 17\n31 199\n231 23\n3 2\n\nSample Output 3\n\n6930", "sample_input": "3\n2 3\n1 1\n3 2\n"}, "reference_outputs": ["10\n"], "source_document_id": "p03966", "source_text": "Score : 300 points\n\nProblem Statement\n\nAtCoDeer the deer is seeing a quick report of election results on TV.\nTwo candidates are standing for the election: Takahashi and Aoki.\nThe report shows the ratio of the current numbers of votes the two candidates have obtained, but not the actual numbers of votes.\nAtCoDeer has checked the report N times, and when he checked it for the i-th (1≦i≦N) time, the ratio was T_i:A_i.\nIt is known that each candidate had at least one vote when he checked the report for the first time.\n\nFind the minimum possible total number of votes obtained by the two candidates when he checked the report for the N-th time.\nIt can be assumed that the number of votes obtained by each candidate never decreases.\n\nConstraints\n\n1≦N≦1000\n\n1≦T_i,A_i≦1000 (1≦i≦N)\n\nT_i and A_i (1≦i≦N) are coprime.\n\nIt is guaranteed that the correct answer is at most 10^{18}.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\nT_1 A_1\nT_2 A_2\n:\nT_N A_N\n\nOutput\n\nPrint the minimum possible total number of votes obtained by Takahashi and Aoki when AtCoDeer checked the report for the N-th time.\n\nSample Input 1\n\n3\n2 3\n1 1\n3 2\n\nSample Output 1\n\n10\n\nWhen the numbers of votes obtained by the two candidates change as 2,3 → 3,3 → 6,4, the total number of votes at the end is 10, which is the minimum possible number.\n\nSample Input 2\n\n4\n1 1\n1 1\n1 5\n1 100\n\nSample Output 2\n\n101\n\nIt is possible that neither candidate obtained a vote between the moment when he checked the report, and the moment when he checked it for the next time.\n\nSample Input 3\n\n5\n3 10\n48 17\n31 199\n231 23\n3 2\n\nSample Output 3\n\n6930", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 715, "cpu_time_ms": 6, "memory_kb": 4232}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s072227553", "group_id": "codeNet:p03970", "input_text": "Scanf.scanf \"%s\" (fun s ->\n let rec loop i acc =\n if i = 16 then acc else\n let acc = if s.[i] <> \"CODEFESTIVAL2016\".[i] then acc + 1 else acc in\n loop (i + 1) acc\n in\n loop 0 0 |> Printf.printf \"%d\\n\"\n)", "language": "OCaml", "metadata": {"date": 1593830126, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p03970.html", "problem_id": "p03970", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03970/input.txt", "sample_output_relpath": "derived/input_output/data/p03970/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03970/OCaml/s072227553.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s072227553", "user_id": "u342443598"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "Scanf.scanf \"%s\" (fun s ->\n let rec loop i acc =\n if i = 16 then acc else\n let acc = if s.[i] <> \"CODEFESTIVAL2016\".[i] then acc + 1 else acc in\n loop (i + 1) acc\n in\n loop 0 0 |> Printf.printf \"%d\\n\"\n)", "problem_context": "Score : 100 points\n\nProblem Statement\n\nCODE FESTIVAL 2016 is going to be held. For the occasion, Mr. Takahashi decided to make a signboard.\n\nHe intended to write CODEFESTIVAL2016 on it, but he mistakenly wrote a different string S. Fortunately, the string he wrote was the correct length.\n\nSo Mr. Takahashi decided to perform an operation that replaces a certain character with another in the minimum number of iterations, changing the string to CODEFESTIVAL2016.\n\nFind the minimum number of iterations for the rewrite operation.\n\nConstraints\n\nS is 16 characters long.\n\nS consists of uppercase and lowercase alphabet letters and numerals.\n\nInput\n\nInputs are provided from Standard Input in the following form.\n\nS\n\nOutput\n\nOutput an integer representing the minimum number of iterations needed for the rewrite operation.\n\nSample Input 1\n\nC0DEFESTIVAL2O16\n\nSample Output 1\n\n2\n\nThe second character 0 must be changed to O and the 14th character O changed to 0.\n\nSample Input 2\n\nFESTIVAL2016CODE\n\nSample Output 2\n\n16", "sample_input": "C0DEFESTIVAL2O16\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03970", "source_text": "Score : 100 points\n\nProblem Statement\n\nCODE FESTIVAL 2016 is going to be held. For the occasion, Mr. Takahashi decided to make a signboard.\n\nHe intended to write CODEFESTIVAL2016 on it, but he mistakenly wrote a different string S. Fortunately, the string he wrote was the correct length.\n\nSo Mr. Takahashi decided to perform an operation that replaces a certain character with another in the minimum number of iterations, changing the string to CODEFESTIVAL2016.\n\nFind the minimum number of iterations for the rewrite operation.\n\nConstraints\n\nS is 16 characters long.\n\nS consists of uppercase and lowercase alphabet letters and numerals.\n\nInput\n\nInputs are provided from Standard Input in the following form.\n\nS\n\nOutput\n\nOutput an integer representing the minimum number of iterations needed for the rewrite operation.\n\nSample Input 1\n\nC0DEFESTIVAL2O16\n\nSample Output 1\n\n2\n\nThe second character 0 must be changed to O and the 14th character O changed to 0.\n\nSample Input 2\n\nFESTIVAL2016CODE\n\nSample Output 2\n\n16", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 240, "cpu_time_ms": 10, "memory_kb": 3820}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s118085749", "group_id": "codeNet:p03970", "input_text": "module String = struct\n include String\n let to_list s =\n let rec loop acc = function\n | 0 -> acc\n | n -> loop (s.[n - 1] :: acc) (n - 1) in\n loop [] (String.length s)\nend\n\nlet () =\n read_line ()\n |> String.to_list\n |> List.map2 ( <> ) (String.to_list \"CODEFESTIVAL2016\")\n |> List.filter (fun x -> x)\n |> List.length\n |> Printf.printf \"%d\\n\"", "language": "OCaml", "metadata": {"date": 1476123867, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03970.html", "problem_id": "p03970", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03970/input.txt", "sample_output_relpath": "derived/input_output/data/p03970/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03970/OCaml/s118085749.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s118085749", "user_id": "u504158101"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "module String = struct\n include String\n let to_list s =\n let rec loop acc = function\n | 0 -> acc\n | n -> loop (s.[n - 1] :: acc) (n - 1) in\n loop [] (String.length s)\nend\n\nlet () =\n read_line ()\n |> String.to_list\n |> List.map2 ( <> ) (String.to_list \"CODEFESTIVAL2016\")\n |> List.filter (fun x -> x)\n |> List.length\n |> Printf.printf \"%d\\n\"", "problem_context": "Score : 100 points\n\nProblem Statement\n\nCODE FESTIVAL 2016 is going to be held. For the occasion, Mr. Takahashi decided to make a signboard.\n\nHe intended to write CODEFESTIVAL2016 on it, but he mistakenly wrote a different string S. Fortunately, the string he wrote was the correct length.\n\nSo Mr. Takahashi decided to perform an operation that replaces a certain character with another in the minimum number of iterations, changing the string to CODEFESTIVAL2016.\n\nFind the minimum number of iterations for the rewrite operation.\n\nConstraints\n\nS is 16 characters long.\n\nS consists of uppercase and lowercase alphabet letters and numerals.\n\nInput\n\nInputs are provided from Standard Input in the following form.\n\nS\n\nOutput\n\nOutput an integer representing the minimum number of iterations needed for the rewrite operation.\n\nSample Input 1\n\nC0DEFESTIVAL2O16\n\nSample Output 1\n\n2\n\nThe second character 0 must be changed to O and the 14th character O changed to 0.\n\nSample Input 2\n\nFESTIVAL2016CODE\n\nSample Output 2\n\n16", "sample_input": "C0DEFESTIVAL2O16\n"}, "reference_outputs": ["2\n"], "source_document_id": "p03970", "source_text": "Score : 100 points\n\nProblem Statement\n\nCODE FESTIVAL 2016 is going to be held. For the occasion, Mr. Takahashi decided to make a signboard.\n\nHe intended to write CODEFESTIVAL2016 on it, but he mistakenly wrote a different string S. Fortunately, the string he wrote was the correct length.\n\nSo Mr. Takahashi decided to perform an operation that replaces a certain character with another in the minimum number of iterations, changing the string to CODEFESTIVAL2016.\n\nFind the minimum number of iterations for the rewrite operation.\n\nConstraints\n\nS is 16 characters long.\n\nS consists of uppercase and lowercase alphabet letters and numerals.\n\nInput\n\nInputs are provided from Standard Input in the following form.\n\nS\n\nOutput\n\nOutput an integer representing the minimum number of iterations needed for the rewrite operation.\n\nSample Input 1\n\nC0DEFESTIVAL2O16\n\nSample Output 1\n\n2\n\nThe second character 0 must be changed to O and the 14th character O changed to 0.\n\nSample Input 2\n\nFESTIVAL2016CODE\n\nSample Output 2\n\n16", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 2, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s509628731", "group_id": "codeNet:p03971", "input_text": "Scanf.scanf \"%d %d %d %s\" (fun n a b s ->\n let rec loop i pass passb =\n if i = n then () else\n if pass < a + b && s.[i] <> 'c' then (\n if s.[i] = 'a' then (print_endline \"Yes\"; loop (i + 1) (pass + 1) passb) else\n if passb < b then (print_endline \"Yes\"; loop (i + 1) (pass + 1) (passb + 1))\n else (print_endline \"No\"; loop (i + 1) pass passb)\n ) else (print_endline \"No\"; loop (i + 1) pass passb)\n in\n loop 0 0 0\n)", "language": "OCaml", "metadata": {"date": 1593830037, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p03971.html", "problem_id": "p03971", "resource_group": "low_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/OCaml/s509628731.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s509628731", "user_id": "u342443598"}, "prompt_components": {"gold_output": "Yes\nYes\nNo\nNo\nYes\nYes\nYes\nNo\nNo\nNo\n", "input_to_evaluate": "Scanf.scanf \"%d %d %d %s\" (fun n a b s ->\n let rec loop i pass passb =\n if i = n then () else\n if pass < a + b && s.[i] <> 'c' then (\n if s.[i] = 'a' then (print_endline \"Yes\"; loop (i + 1) (pass + 1) passb) else\n if passb < b then (print_endline \"Yes\"; loop (i + 1) (pass + 1) (passb + 1))\n else (print_endline \"No\"; loop (i + 1) pass passb)\n ) else (print_endline \"No\"; loop (i + 1) pass passb)\n in\n loop 0 0 0\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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 485, "cpu_time_ms": 169, "memory_kb": 4096}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s045137180", "group_id": "codeNet:p03971", "input_text": "let n, a, b, s = Scanf.scanf \" %d %d %d %s\" @@ fun a b c d -> a, b, c, d\nlet p, r = ref 0, ref 0\nlet _ = String.iter (fun c -> print_endline @@ if !p < a + b then if c = 'a' then (incr p; \"Yes\") else if c = 'b' then (incr r; if !r <= b then (incr p; \"Yes\") else \"No\") else \"No\" else \"No\") s", "language": "OCaml", "metadata": {"date": 1571017226, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03971.html", "problem_id": "p03971", "resource_group": "low_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/OCaml/s045137180.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s045137180", "user_id": "u732304692"}, "prompt_components": {"gold_output": "Yes\nYes\nNo\nNo\nYes\nYes\nYes\nNo\nNo\nNo\n", "input_to_evaluate": "let n, a, b, s = Scanf.scanf \" %d %d %d %s\" @@ fun a b c d -> a, b, c, d\nlet p, r = ref 0, ref 0\nlet _ = String.iter (fun c -> print_endline @@ if !p < a + b then if c = 'a' then (incr p; \"Yes\") else if c = 'b' then (incr r; if !r <= b then (incr p; \"Yes\") else \"No\") else \"No\" else \"No\") s", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 151, "memory_kb": 3200}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s090971517", "group_id": "codeNet:p03972", "input_text": "let () = Scanf.scanf \"%d %d\\n\" @@ fun w h ->\n begin\n Array.to_list (Array.init w (fun _ ->\n Scanf.scanf \"%d\\n\" (fun p -> (p, 2)))) @\n Array.to_list (Array.init h (fun _ ->\n Scanf.scanf \"%d\\n\" (fun q -> (q, 1))))\n end\n |> List.sort (fun (p, _) (q, _) -> compare p q)\n |> List.fold_left (fun (cost, (a, b)) -> function\n | (p, 2) ->\n (* p_i は,∀j. (i, j)と(i + 1, j)を結ぶコスト *)\n (cost + p * b, (a - 1, b))\n | (q, 1) ->\n (* q_j は,∀i. (i, j)と(i, j + 1)を結ぶコスト *)\n (cost + q * a, (a, b - 1))) (0, (w + 1, h + 1))\n |> fst\n |> Printf.printf \"%d\\n\"", "language": "OCaml", "metadata": {"date": 1526803216, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03972.html", "problem_id": "p03972", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03972/input.txt", "sample_output_relpath": "derived/input_output/data/p03972/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03972/OCaml/s090971517.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s090971517", "user_id": "u504158101"}, "prompt_components": {"gold_output": "29\n", "input_to_evaluate": "let () = Scanf.scanf \"%d %d\\n\" @@ fun w h ->\n begin\n Array.to_list (Array.init w (fun _ ->\n Scanf.scanf \"%d\\n\" (fun p -> (p, 2)))) @\n Array.to_list (Array.init h (fun _ ->\n Scanf.scanf \"%d\\n\" (fun q -> (q, 1))))\n end\n |> List.sort (fun (p, _) (q, _) -> compare p q)\n |> List.fold_left (fun (cost, (a, b)) -> function\n | (p, 2) ->\n (* p_i は,∀j. (i, j)と(i + 1, j)を結ぶコスト *)\n (cost + p * b, (a - 1, b))\n | (q, 1) ->\n (* q_j は,∀i. (i, j)と(i, j + 1)を結ぶコスト *)\n (cost + q * a, (a, b - 1))) (0, (w + 1, h + 1))\n |> fst\n |> Printf.printf \"%d\\n\"", "problem_context": "Score : 500 points\n\nProblem Statement\n\nOn an xy plane, in an area satisfying 0 ≤ x ≤ W, 0 ≤ y ≤ H, there is one house at each and every point where both x and y are integers.\n\nThere are unpaved roads between every pair of points for which either the x coordinates are equal and the difference between the y coordinates is 1, or the y coordinates are equal and the difference between the x coordinates is 1.\n\nThe cost of paving a road between houses on coordinates (i,j) and (i+1,j) is p_i for any value of j, while the cost of paving a road between houses on coordinates (i,j) and (i,j+1) is q_j for any value of i.\n\nMr. Takahashi wants to pave some of these roads and be able to travel between any two houses on paved roads only. Find the solution with the minimum total cost.\n\nConstraints\n\n1 ≦ W,H ≦ 10^5\n\n1 ≦ p_i ≦ 10^8(0 ≦ i ≦ W-1)\n\n1 ≦ q_j ≦ 10^8(0 ≦ j ≦ H-1)\n\np_i (0 ≦ i ≦ W−1) is an integer.\n\nq_j (0 ≦ j ≦ H−1) is an integer.\n\nInput\n\nInputs are provided from Standard Input in the following form.\n\nW H\np_0\n:\np_{W-1}\nq_0\n:\nq_{H-1}\n\nOutput\n\nOutput an integer representing the minimum total cost.\n\nSample Input 1\n\n2 2\n3\n5\n2\n7\n\nSample Output 1\n\n29\n\nIt is enough to pave the following eight roads.\n\nRoad connecting houses at (0,0) and (0,1)\n\nRoad connecting houses at (0,1) and (1,1)\n\nRoad connecting houses at (0,2) and (1,2)\n\nRoad connecting houses at (1,0) and (1,1)\n\nRoad connecting houses at (1,0) and (2,0)\n\nRoad connecting houses at (1,1) and (1,2)\n\nRoad connecting houses at (1,2) and (2,2)\n\nRoad connecting houses at (2,0) and (2,1)\n\nSample Input 2\n\n4 3\n2\n4\n8\n1\n2\n9\n3\n\nSample Output 2\n\n60", "sample_input": "2 2\n3\n5\n2\n7\n"}, "reference_outputs": ["29\n"], "source_document_id": "p03972", "source_text": "Score : 500 points\n\nProblem Statement\n\nOn an xy plane, in an area satisfying 0 ≤ x ≤ W, 0 ≤ y ≤ H, there is one house at each and every point where both x and y are integers.\n\nThere are unpaved roads between every pair of points for which either the x coordinates are equal and the difference between the y coordinates is 1, or the y coordinates are equal and the difference between the x coordinates is 1.\n\nThe cost of paving a road between houses on coordinates (i,j) and (i+1,j) is p_i for any value of j, while the cost of paving a road between houses on coordinates (i,j) and (i,j+1) is q_j for any value of i.\n\nMr. Takahashi wants to pave some of these roads and be able to travel between any two houses on paved roads only. Find the solution with the minimum total cost.\n\nConstraints\n\n1 ≦ W,H ≦ 10^5\n\n1 ≦ p_i ≦ 10^8(0 ≦ i ≦ W-1)\n\n1 ≦ q_j ≦ 10^8(0 ≦ j ≦ H-1)\n\np_i (0 ≦ i ≦ W−1) is an integer.\n\nq_j (0 ≦ j ≦ H−1) is an integer.\n\nInput\n\nInputs are provided from Standard Input in the following form.\n\nW H\np_0\n:\np_{W-1}\nq_0\n:\nq_{H-1}\n\nOutput\n\nOutput an integer representing the minimum total cost.\n\nSample Input 1\n\n2 2\n3\n5\n2\n7\n\nSample Output 1\n\n29\n\nIt is enough to pave the following eight roads.\n\nRoad connecting houses at (0,0) and (0,1)\n\nRoad connecting houses at (0,1) and (1,1)\n\nRoad connecting houses at (0,2) and (1,2)\n\nRoad connecting houses at (1,0) and (1,1)\n\nRoad connecting houses at (1,0) and (2,0)\n\nRoad connecting houses at (1,1) and (1,2)\n\nRoad connecting houses at (1,2) and (2,2)\n\nRoad connecting houses at (2,0) and (2,1)\n\nSample Input 2\n\n4 3\n2\n4\n8\n1\n2\n9\n3\n\nSample Output 2\n\n60", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 630, "cpu_time_ms": 205, "memory_kb": 28160}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s190411670", "group_id": "codeNet:p03986", "input_text": "let () =\n let x = read_line () in\n Array.init (String.length x) (fun i -> x.[i])\n |> Array.fold_left (fun (h, m) -> function\n | 'S' -> (h + 1, m)\n | 'T' -> (h - 1, min m (h - 1))) (0, 0)\n |> (fun (h, m) ->\n let offset = min 0 m in\n let correct = h - offset in\n Printf.printf \"%d\\n\" @@ correct - offset)", "language": "OCaml", "metadata": {"date": 1531412739, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03986.html", "problem_id": "p03986", "resource_group": "low_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/OCaml/s190411670.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s190411670", "user_id": "u504158101"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "let () =\n let x = read_line () in\n Array.init (String.length x) (fun i -> x.[i])\n |> Array.fold_left (fun (h, m) -> function\n | 'S' -> (h + 1, m)\n | 'T' -> (h - 1, min m (h - 1))) (0, 0)\n |> (fun (h, m) ->\n let offset = min 0 m in\n let correct = h - offset in\n Printf.printf \"%d\\n\" @@ correct - offset)", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 327, "cpu_time_ms": 8, "memory_kb": 6400}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s216066525", "group_id": "codeNet:p03987", "input_text": "module IntSet = Set.Make (struct\n type t = int\n let compare = compare\nend)\n\nlet () =\n let n = Scanf.scanf \"%d\\n\" (fun n -> n) in\n let as_ = Array.init n @@ fun i -> Scanf.scanf \"%d \" @@ fun a -> i, a in\n Array.to_list as_\n |> List.sort (fun (_, a) (_, a') -> compare a a')\n |> List.fold_left (fun (acc, s) (j, a) ->\n let (lt, _, gt) = IntSet.split j s in\n let i = try IntSet.max_elt lt with Not_found -> -1 in\n let k = try IntSet.min_elt gt with Not_found -> n in\n (acc + (k - j) * (j - i) * a, IntSet.add j s)) (0, IntSet.empty)\n |> fst\n |> Printf.printf \"%d\\n\"\n", "language": "OCaml", "metadata": {"date": 1529812051, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03987.html", "problem_id": "p03987", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03987/input.txt", "sample_output_relpath": "derived/input_output/data/p03987/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03987/OCaml/s216066525.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s216066525", "user_id": "u504158101"}, "prompt_components": {"gold_output": "9\n", "input_to_evaluate": "module IntSet = Set.Make (struct\n type t = int\n let compare = compare\nend)\n\nlet () =\n let n = Scanf.scanf \"%d\\n\" (fun n -> n) in\n let as_ = Array.init n @@ fun i -> Scanf.scanf \"%d \" @@ fun a -> i, a in\n Array.to_list as_\n |> List.sort (fun (_, a) (_, a') -> compare a a')\n |> List.fold_left (fun (acc, s) (j, a) ->\n let (lt, _, gt) = IntSet.split j s in\n let i = try IntSet.max_elt lt with Not_found -> -1 in\n let k = try IntSet.min_elt gt with Not_found -> n in\n (acc + (k - j) * (j - i) * a, IntSet.add j s)) (0, IntSet.empty)\n |> fst\n |> Printf.printf \"%d\\n\"\n", "problem_context": "Score : 400 points\n\nProblem Statement\n\nOne day, Snuke was given a permutation of length N, a_1, a_2, ..., a_N, from his friend.\n\nFind the following:\n\nConstraints\n\n1 ≦ N ≦ 200,000\n\n(a_1, a_2, ..., a_N) is a permutation of (1, 2, ..., N).\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\na_1 a_2 ... a_N\n\nOutput\n\nPrint the answer.\n\nNote that the answer may not fit into a 32-bit integer.\n\nSample Input 1\n\n3\n2 1 3\n\nSample Output 1\n\n9\n\nSample Input 2\n\n4\n1 3 2 4\n\nSample Output 2\n\n19\n\nSample Input 3\n\n8\n5 4 8 1 2 6 7 3\n\nSample Output 3\n\n85", "sample_input": "3\n2 1 3\n"}, "reference_outputs": ["9\n"], "source_document_id": "p03987", "source_text": "Score : 400 points\n\nProblem Statement\n\nOne day, Snuke was given a permutation of length N, a_1, a_2, ..., a_N, from his friend.\n\nFind the following:\n\nConstraints\n\n1 ≦ N ≦ 200,000\n\n(a_1, a_2, ..., a_N) is a permutation of (1, 2, ..., N).\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\na_1 a_2 ... a_N\n\nOutput\n\nPrint the answer.\n\nNote that the answer may not fit into a 32-bit integer.\n\nSample Input 1\n\n3\n2 1 3\n\nSample Output 1\n\n9\n\nSample Input 2\n\n4\n1 3 2 4\n\nSample Output 2\n\n19\n\nSample Input 3\n\n8\n5 4 8 1 2 6 7 3\n\nSample Output 3\n\n85", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 608, "cpu_time_ms": 620, "memory_kb": 24960}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s391720660", "group_id": "codeNet:p03988", "input_text": "let () = Scanf.scanf \"%d\\n\" @@ fun n ->\n let as_ = Array.init n @@ fun _ -> Scanf.scanf \"%d \" @@ fun a -> a in\n let d = Array.fold_left max min_int as_ in\n let count_as = Array.make n 0 in\n Array.iter (fun a -> count_as.(a) <- 1 + count_as.(a)) as_;\n print_endline @@\n if\n Array.fold_right (fun n -> ( && ) (n = 0))\n (Array.sub count_as 0 ((d + 1) / 2)) true &&\n count_as.((d + 1) / 2) = 1 + d mod 2 &&\n Array.fold_right (fun n -> ( && ) (1 < n))\n (Array.sub count_as ((d + 1) / 2 + 1) (d / 2)) true\n then \"Possible\"\n else \"Impossible\"\n", "language": "OCaml", "metadata": {"date": 1536818961, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03988.html", "problem_id": "p03988", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p03988/input.txt", "sample_output_relpath": "derived/input_output/data/p03988/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p03988/OCaml/s391720660.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s391720660", "user_id": "u504158101"}, "prompt_components": {"gold_output": "Possible\n", "input_to_evaluate": "let () = Scanf.scanf \"%d\\n\" @@ fun n ->\n let as_ = Array.init n @@ fun _ -> Scanf.scanf \"%d \" @@ fun a -> a in\n let d = Array.fold_left max min_int as_ in\n let count_as = Array.make n 0 in\n Array.iter (fun a -> count_as.(a) <- 1 + count_as.(a)) as_;\n print_endline @@\n if\n Array.fold_right (fun n -> ( && ) (n = 0))\n (Array.sub count_as 0 ((d + 1) / 2)) true &&\n count_as.((d + 1) / 2) = 1 + d mod 2 &&\n Array.fold_right (fun n -> ( && ) (1 < n))\n (Array.sub count_as ((d + 1) / 2 + 1) (d / 2)) true\n then \"Possible\"\n else \"Impossible\"\n", "problem_context": "Score : 700 points\n\nProblem Statement\n\nAoki loves numerical sequences and trees.\n\nOne day, Takahashi gave him an integer sequence of length N, a_1, a_2, ..., a_N, which made him want to construct a tree.\n\nAoki wants to construct a tree with N vertices numbered 1 through N, such that for each i = 1,2,...,N, the distance between vertex i and the farthest vertex from it is a_i, assuming that the length of each edge is 1.\n\nDetermine whether such a tree exists.\n\nConstraints\n\n2 ≦ N ≦ 100\n\n1 ≦ a_i ≦ N-1\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\na_1 a_2 ... a_N\n\nOutput\n\nIf there exists a tree that satisfies the condition, print Possible. Otherwise, print Impossible.\n\nSample Input 1\n\n5\n3 2 2 3 3\n\nSample Output 1\n\nPossible\n\nThe diagram above shows an example of a tree that satisfies the conditions. The red arrows show paths from each vertex to the farthest vertex from it.\n\nSample Input 2\n\n3\n1 1 2\n\nSample Output 2\n\nImpossible\n\nSample Input 3\n\n10\n1 2 2 2 2 2 2 2 2 2\n\nSample Output 3\n\nPossible\n\nSample Input 4\n\n10\n1 1 2 2 2 2 2 2 2 2\n\nSample Output 4\n\nImpossible\n\nSample Input 5\n\n6\n1 1 1 1 1 5\n\nSample Output 5\n\nImpossible\n\nSample Input 6\n\n5\n4 3 2 3 4\n\nSample Output 6\n\nPossible", "sample_input": "5\n3 2 2 3 3\n"}, "reference_outputs": ["Possible\n"], "source_document_id": "p03988", "source_text": "Score : 700 points\n\nProblem Statement\n\nAoki loves numerical sequences and trees.\n\nOne day, Takahashi gave him an integer sequence of length N, a_1, a_2, ..., a_N, which made him want to construct a tree.\n\nAoki wants to construct a tree with N vertices numbered 1 through N, such that for each i = 1,2,...,N, the distance between vertex i and the farthest vertex from it is a_i, assuming that the length of each edge is 1.\n\nDetermine whether such a tree exists.\n\nConstraints\n\n2 ≦ N ≦ 100\n\n1 ≦ a_i ≦ N-1\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\na_1 a_2 ... a_N\n\nOutput\n\nIf there exists a tree that satisfies the condition, print Possible. Otherwise, print Impossible.\n\nSample Input 1\n\n5\n3 2 2 3 3\n\nSample Output 1\n\nPossible\n\nThe diagram above shows an example of a tree that satisfies the conditions. The red arrows show paths from each vertex to the farthest vertex from it.\n\nSample Input 2\n\n3\n1 1 2\n\nSample Output 2\n\nImpossible\n\nSample Input 3\n\n10\n1 2 2 2 2 2 2 2 2 2\n\nSample Output 3\n\nPossible\n\nSample Input 4\n\n10\n1 1 2 2 2 2 2 2 2 2\n\nSample Output 4\n\nImpossible\n\nSample Input 5\n\n6\n1 1 1 1 1 5\n\nSample Output 5\n\nImpossible\n\nSample Input 6\n\n5\n4 3 2 3 4\n\nSample Output 6\n\nPossible", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s732902025", "group_id": "codeNet:p03992", "input_text": "let () =\n let s = read_line () in\n Printf.printf \"%s %s\\n\" (String.sub s 0 4) (String.sub s 4 8)\n", "language": "OCaml", "metadata": {"date": 1534824379, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03992.html", "problem_id": "p03992", "resource_group": "low_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/OCaml/s732902025.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s732902025", "user_id": "u504158101"}, "prompt_components": {"gold_output": "CODE FESTIVAL\n", "input_to_evaluate": "let () =\n let s = read_line () in\n Printf.printf \"%s %s\\n\" (String.sub s 0 4) (String.sub s 4 8)\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nThis contest is CODE FESTIVAL.\nHowever, Mr. Takahashi always writes it CODEFESTIVAL, omitting the single space between CODE and FESTIVAL.\n\nSo he has decided to make a program that puts the single space he omitted.\n\nYou are given a string s with 12 letters.\nOutput the string putting a single space between the first 4 letters and last 8 letters in the string s.\n\nConstraints\n\ns contains exactly 12 letters.\n\nAll letters in s are uppercase English letters.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\ns\n\nOutput\n\nPrint the string putting a single space between the first 4 letters and last 8 letters in the string s.\nPut a line break at the end.\n\nSample Input 1\n\nCODEFESTIVAL\n\nSample Output 1\n\nCODE FESTIVAL\n\nPutting a single space between the first 4 letters and last 8 letters in CODEFESTIVAL makes it CODE FESTIVAL.\n\nSample Input 2\n\nPOSTGRADUATE\n\nSample Output 2\n\nPOST GRADUATE\n\nSample Input 3\n\nABCDEFGHIJKL\n\nSample Output 3\n\nABCD EFGHIJKL", "sample_input": "CODEFESTIVAL\n"}, "reference_outputs": ["CODE FESTIVAL\n"], "source_document_id": "p03992", "source_text": "Score : 100 points\n\nProblem Statement\n\nThis contest is CODE FESTIVAL.\nHowever, Mr. Takahashi always writes it CODEFESTIVAL, omitting the single space between CODE and FESTIVAL.\n\nSo he has decided to make a program that puts the single space he omitted.\n\nYou are given a string s with 12 letters.\nOutput the string putting a single space between the first 4 letters and last 8 letters in the string s.\n\nConstraints\n\ns contains exactly 12 letters.\n\nAll letters in s are uppercase English letters.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\ns\n\nOutput\n\nPrint the string putting a single space between the first 4 letters and last 8 letters in the string s.\nPut a line break at the end.\n\nSample Input 1\n\nCODEFESTIVAL\n\nSample Output 1\n\nCODE FESTIVAL\n\nPutting a single space between the first 4 letters and last 8 letters in CODEFESTIVAL makes it CODE FESTIVAL.\n\nSample Input 2\n\nPOSTGRADUATE\n\nSample Output 2\n\nPOST GRADUATE\n\nSample Input 3\n\nABCDEFGHIJKL\n\nSample Output 3\n\nABCD EFGHIJKL", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s901670276", "group_id": "codeNet:p03993", "input_text": "let n = Scanf.scanf \" %d\" (+) 0\nlet a_s = Array.init n @@ fun _ -> Scanf.scanf \" %d\" pred\nlet c = ref 0\nlet _ = for i = 0 to n - 1 do if a_s.(a_s.(i)) = i then incr c done; Printf.printf \"%d\\n\" @@ !c / 2", "language": "OCaml", "metadata": {"date": 1564104133, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03993.html", "problem_id": "p03993", "resource_group": "low_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/OCaml/s901670276.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s901670276", "user_id": "u732304692"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "let n = Scanf.scanf \" %d\" (+) 0\nlet a_s = Array.init n @@ fun _ -> Scanf.scanf \" %d\" pred\nlet c = ref 0\nlet _ = for i = 0 to n - 1 do if a_s.(a_s.(i)) = i then incr c done; Printf.printf \"%d\\n\" @@ !c / 2", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 25, "memory_kb": 5248}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s439685821", "group_id": "codeNet:p03997", "input_text": "let a = read_int ()\nlet b = read_int ()\nlet h = read_int ()\nlet _ = Printf.printf \"%d\\n\" ((a+b)*h/2)", "language": "OCaml", "metadata": {"date": 1584367990, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03997.html", "problem_id": "p03997", "resource_group": "low_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/OCaml/s439685821.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s439685821", "user_id": "u511870776"}, "prompt_components": {"gold_output": "7\n", "input_to_evaluate": "let a = read_int ()\nlet b = read_int ()\nlet h = read_int ()\nlet _ = Printf.printf \"%d\\n\" ((a+b)*h/2)", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s678286963", "group_id": "codeNet:p03997", "input_text": "let () = Scanf.scanf \"%d %d %d\" (fun a b h -> (a+b)*h/2) |> Printf.printf \"%d\\n\"", "language": "OCaml", "metadata": {"date": 1560916608, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03997.html", "problem_id": "p03997", "resource_group": "low_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/OCaml/s678286963.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s678286963", "user_id": "u635974378"}, "prompt_components": {"gold_output": "7\n", "input_to_evaluate": "let () = Scanf.scanf \"%d %d %d\" (fun a b h -> (a+b)*h/2) |> Printf.printf \"%d\\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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s679401259", "group_id": "codeNet:p03999", "input_text": "(* O(2^|s|) *)\nlet s = read_line ()\nlet ds = Array.to_list @@ Array.init (String.length s) @@ fun i -> Char.code s.[i] - 48\nlet rec f sum n = function\n| [] -> sum + n\n| d :: r -> f (sum + n) d r + f sum (10 * n + d) r\nlet _ = f 0 (List.hd ds) (List.tl ds) |> Printf.printf \"%d\\n\"", "language": "OCaml", "metadata": {"date": 1562044569, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p03999.html", "problem_id": "p03999", "resource_group": "low_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/OCaml/s679401259.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s679401259", "user_id": "u732304692"}, "prompt_components": {"gold_output": "176\n", "input_to_evaluate": "(* O(2^|s|) *)\nlet s = read_line ()\nlet ds = Array.to_list @@ Array.init (String.length s) @@ fun i -> Char.code s.[i] - 48\nlet rec f sum n = function\n| [] -> sum + n\n| d :: r -> f (sum + n) d r + f sum (10 * n + d) r\nlet _ = f 0 (List.hd ds) (List.tl ds) |> Printf.printf \"%d\\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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s009628974", "group_id": "codeNet:p04000", "input_text": "Scanf.scanf \"%d %d %d\" (fun h w n ->\n let f a b = a lsl 30 + b in\n let module M = Map.Make (struct type t = int let compare = compare end) in\n\n let hist = Array.make 10 0 in\n hist.(0) <- (h - 2) * (w - 2);\n\n let rec loop i map =\n if i = n then hist else\n let map = Scanf.scanf \" %d %d\" (fun a b ->\n List.fold_left (fun map (vx, vy) ->\n let x = b + vx in\n let y = a + vy in\n if x > 1 && x < w && y > 1 && y < h then (\n let key = f x y in\n let v = try M.find key map with _ -> 0 in\n hist.(v) <- hist.(v) - 1;\n hist.(v + 1) <- hist.(v + 1) + 1;\n M.add key (v + 1) map\n ) else map\n ) map [ -1, -1; -1, 0; -1, 1; 0, -1; 0, 0; 0, 1; 1, -1; 1, 0; 1, 1 ]\n ) in\n loop (i + 1) map\n in\n Array.iter (Printf.printf \"%d\\n\") @@ loop 0 M.empty\n)", "language": "OCaml", "metadata": {"date": 1593659402, "filename_ext": "ml", "original_language": "OCaml (4.10.0)", "problem_description_relpath": "problem_descriptions/p04000.html", "problem_id": "p04000", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p04000/input.txt", "sample_output_relpath": "derived/input_output/data/p04000/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p04000/OCaml/s009628974.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s009628974", "user_id": "u342443598"}, "prompt_components": {"gold_output": "0\n0\n0\n2\n4\n0\n0\n0\n0\n0\n", "input_to_evaluate": "Scanf.scanf \"%d %d %d\" (fun h w n ->\n let f a b = a lsl 30 + b in\n let module M = Map.Make (struct type t = int let compare = compare end) in\n\n let hist = Array.make 10 0 in\n hist.(0) <- (h - 2) * (w - 2);\n\n let rec loop i map =\n if i = n then hist else\n let map = Scanf.scanf \" %d %d\" (fun a b ->\n List.fold_left (fun map (vx, vy) ->\n let x = b + vx in\n let y = a + vy in\n if x > 1 && x < w && y > 1 && y < h then (\n let key = f x y in\n let v = try M.find key map with _ -> 0 in\n hist.(v) <- hist.(v) - 1;\n hist.(v + 1) <- hist.(v + 1) + 1;\n M.add key (v + 1) map\n ) else map\n ) map [ -1, -1; -1, 0; -1, 1; 0, -1; 0, 0; 0, 1; 1, -1; 1, 0; 1, 1 ]\n ) in\n loop (i + 1) map\n in\n Array.iter (Printf.printf \"%d\\n\") @@ loop 0 M.empty\n)", "problem_context": "Score : 400 points\n\nProblem Statement\n\nWe have a grid with H rows and W columns. At first, all cells were painted white.\n\nSnuke painted N of these cells. The i-th ( 1 \\leq i \\leq N ) cell he painted is the cell at the a_i-th row and b_i-th column.\n\nCompute the following:\n\nFor each integer j ( 0 \\leq j \\leq 9 ), how many subrectangles of size 3×3 of the grid contains exactly j black cells, after Snuke painted N cells?\n\nConstraints\n\n3 \\leq H \\leq 10^9\n\n3 \\leq W \\leq 10^9\n\n0 \\leq N \\leq min(10^5,H×W)\n\n1 \\leq a_i \\leq H (1 \\leq i \\leq N)\n\n1 \\leq b_i \\leq W (1 \\leq i \\leq N)\n\n(a_i, b_i) \\neq (a_j, b_j) (i \\neq j)\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nH W N\na_1 b_1\n:\na_N b_N\n\nOutput\n\nPrint 10 lines.\nThe (j+1)-th ( 0 \\leq j \\leq 9 ) line should contain the number of the subrectangles of size 3×3 of the grid that contains exactly j black cells.\n\nSample Input 1\n\n4 5 8\n1 1\n1 4\n1 5\n2 3\n3 1\n3 2\n3 4\n4 4\n\nSample Output 1\n\n0\n0\n0\n2\n4\n0\n0\n0\n0\n0\n\nThere are six subrectangles of size 3×3. Two of them contain three black cells each, and the remaining four contain four black cells each.\n\nSample Input 2\n\n10 10 20\n1 1\n1 4\n1 9\n2 5\n3 10\n4 2\n4 7\n5 9\n6 4\n6 6\n6 7\n7 1\n7 3\n7 7\n8 1\n8 5\n8 10\n9 2\n10 4\n10 9\n\nSample Output 2\n\n4\n26\n22\n10\n2\n0\n0\n0\n0\n0\n\nSample Input 3\n\n1000000000 1000000000 0\n\nSample Output 3\n\n999999996000000004\n0\n0\n0\n0\n0\n0\n0\n0\n0", "sample_input": "4 5 8\n1 1\n1 4\n1 5\n2 3\n3 1\n3 2\n3 4\n4 4\n"}, "reference_outputs": ["0\n0\n0\n2\n4\n0\n0\n0\n0\n0\n"], "source_document_id": "p04000", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1011, "cpu_time_ms": 1351, "memory_kb": 70680}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s354843941", "group_id": "codeNet:p04005", "input_text": "let is_even n = (n mod 2 = 0)\n\nlet () =\n\tScanf.scanf \"%d %d %d\\n\" (fun a b c ->\n\t\tif List.exists is_even [a; b; c] then\n\t\t\tPrintf.printf \"0\\n\"\n\t\telse\n\t\t\tList.sort compare [a * b; b * c; c * a]\n\t\t\t|> List.hd\n\t\t\t|> Printf.printf \"%d\\n\"\n\t)\n", "language": "OCaml", "metadata": {"date": 1473038583, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p04005.html", "problem_id": "p04005", "resource_group": "low_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/OCaml/s354843941.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s354843941", "user_id": "u420267469"}, "prompt_components": {"gold_output": "9\n", "input_to_evaluate": "let is_even n = (n mod 2 = 0)\n\nlet () =\n\tScanf.scanf \"%d %d %d\\n\" (fun a b c ->\n\t\tif List.exists is_even [a; b; c] then\n\t\t\tPrintf.printf \"0\\n\"\n\t\telse\n\t\t\tList.sort compare [a * b; b * c; c * a]\n\t\t\t|> List.hd\n\t\t\t|> Printf.printf \"%d\\n\"\n\t)\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nWe have a rectangular parallelepiped of size A×B×C, built with blocks of size 1×1×1. Snuke will paint each of the A×B×C blocks either red or blue, so that:\n\nThere is at least one red block and at least one blue block.\n\nThe union of all red blocks forms a rectangular parallelepiped.\n\nThe union of all blue blocks forms a rectangular parallelepiped.\n\nSnuke wants to minimize the difference between the number of red blocks and the number of blue blocks. Find the minimum possible difference.\n\nConstraints\n\n2≤A,B,C≤10^9\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nA B C\n\nOutput\n\nPrint the minimum possible difference between the number of red blocks and the number of blue blocks.\n\nSample Input 1\n\n3 3 3\n\nSample Output 1\n\n9\n\nFor example, Snuke can paint the blocks as shown in the diagram below.\nThere are 9 red blocks and 18 blue blocks, thus the difference is 9.\n\nSample Input 2\n\n2 2 4\n\nSample Output 2\n\n0\n\nFor example, Snuke can paint the blocks as shown in the diagram below.\nThere are 8 red blocks and 8 blue blocks, thus the difference is 0.\n\nSample Input 3\n\n5 3 5\n\nSample Output 3\n\n15\n\nFor example, Snuke can paint the blocks as shown in the diagram below.\nThere are 45 red blocks and 30 blue blocks, thus the difference is 9.", "sample_input": "3 3 3\n"}, "reference_outputs": ["9\n"], "source_document_id": "p04005", "source_text": "Score : 200 points\n\nProblem Statement\n\nWe have a rectangular parallelepiped of size A×B×C, built with blocks of size 1×1×1. Snuke will paint each of the A×B×C blocks either red or blue, so that:\n\nThere is at least one red block and at least one blue block.\n\nThe union of all red blocks forms a rectangular parallelepiped.\n\nThe union of all blue blocks forms a rectangular parallelepiped.\n\nSnuke wants to minimize the difference between the number of red blocks and the number of blue blocks. Find the minimum possible difference.\n\nConstraints\n\n2≤A,B,C≤10^9\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nA B C\n\nOutput\n\nPrint the minimum possible difference between the number of red blocks and the number of blue blocks.\n\nSample Input 1\n\n3 3 3\n\nSample Output 1\n\n9\n\nFor example, Snuke can paint the blocks as shown in the diagram below.\nThere are 9 red blocks and 18 blue blocks, thus the difference is 9.\n\nSample Input 2\n\n2 2 4\n\nSample Output 2\n\n0\n\nFor example, Snuke can paint the blocks as shown in the diagram below.\nThere are 8 red blocks and 8 blue blocks, thus the difference is 0.\n\nSample Input 3\n\n5 3 5\n\nSample Output 3\n\n15\n\nFor example, Snuke can paint the blocks as shown in the diagram below.\nThere are 45 red blocks and 30 blue blocks, thus the difference is 9.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 4, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s071247540", "group_id": "codeNet:p04011", "input_text": "let () =\n\tlet n, k, x, y = Scanf.scanf \"%d\\n%d\\n%d\\n%d\\n\" (fun a b c d -> a,b,c,d) in\n Printf.printf \"%d\\n\" ((if n<=k then 0 else (n-k)*y) + n*x)", "language": "OCaml", "metadata": {"date": 1581950784, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p04011.html", "problem_id": "p04011", "resource_group": "low_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/OCaml/s071247540.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s071247540", "user_id": "u307426615"}, "prompt_components": {"gold_output": "48000\n", "input_to_evaluate": "let () =\n\tlet n, k, x, y = Scanf.scanf \"%d\\n%d\\n%d\\n%d\\n\" (fun a b c d -> a,b,c,d) in\n Printf.printf \"%d\\n\" ((if n<=k then 0 else (n-k)*y) + n*x)", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s329280273", "group_id": "codeNet:p04011", "input_text": "let n, k, x, y = Scanf.scanf \" %d %d %d %d\" @@ fun a b c d -> a, b, c, d\nlet _ = Printf.printf \"%d\\n\" @@ x * min n k + y * max 0 (n - k)", "language": "OCaml", "metadata": {"date": 1562595411, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p04011.html", "problem_id": "p04011", "resource_group": "low_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/OCaml/s329280273.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s329280273", "user_id": "u732304692"}, "prompt_components": {"gold_output": "48000\n", "input_to_evaluate": "let n, k, x, y = Scanf.scanf \" %d %d %d %d\" @@ fun a b c d -> a, b, c, d\nlet _ = Printf.printf \"%d\\n\" @@ x * min n k + y * max 0 (n - k)", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s682781978", "group_id": "codeNet:p04012", "input_text": "let w = read_line ()\nlet f s x = let n = ref 0 in String.iter (fun c -> if c = x then incr n) s; !n\nlet _ = String.iter (fun c -> if f w c mod 2 = 1 then (print_endline \"No\"; exit 0)) w; print_endline \"Yes\"", "language": "OCaml", "metadata": {"date": 1571100591, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p04012.html", "problem_id": "p04012", "resource_group": "low_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/OCaml/s682781978.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s682781978", "user_id": "u732304692"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "let w = read_line ()\nlet f s x = let n = ref 0 in String.iter (fun c -> if c = x then incr n) s; !n\nlet _ = String.iter (fun c -> if f w c mod 2 = 1 then (print_endline \"No\"; exit 0)) w; print_endline \"Yes\"", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s074013510", "group_id": "codeNet:p04012", "input_text": "let charl_of_string s =\n let rec exp i l =\n if i < 0 then l else exp (i - 1) (s.[i] :: l) in\n exp (String.length s - 1) []\n\nlet dp = Array.make 26 0\n\nlet calc c =\n let ind = (int_of_char 'a') - 97 in\n dp.(ind) <- dp.(ind) + 1\n\nlet flag = ref true\nlet cl =\n read_line ()\n |> charl_of_string\n |> List.map calc\n \nlet () =\n for i = 0 to 25 do\n if dp.(i) mod 2 = 1 then flag := false\n done;\n if !flag then print_endline \"Yes\"\n else print_endline \"No\"\n", "language": "OCaml", "metadata": {"date": 1473624270, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p04012.html", "problem_id": "p04012", "resource_group": "low_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/OCaml/s074013510.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s074013510", "user_id": "u098968285"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "let charl_of_string s =\n let rec exp i l =\n if i < 0 then l else exp (i - 1) (s.[i] :: l) in\n exp (String.length s - 1) []\n\nlet dp = Array.make 26 0\n\nlet calc c =\n let ind = (int_of_char 'a') - 97 in\n dp.(ind) <- dp.(ind) + 1\n\nlet flag = ref true\nlet cl =\n read_line ()\n |> charl_of_string\n |> List.map calc\n \nlet () =\n for i = 0 to 25 do\n if dp.(i) mod 2 = 1 then flag := false\n done;\n if !flag then print_endline \"Yes\"\n else print_endline \"No\"\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nLet w be a string consisting of lowercase letters.\nWe will call w beautiful if the following condition is satisfied:\n\nEach lowercase letter of the English alphabet occurs even number of times in w.\n\nYou are given the string w. Determine if w is beautiful.\n\nConstraints\n\n1 \\leq |w| \\leq 100\n\nw consists of lowercase letters (a-z).\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nw\n\nOutput\n\nPrint Yes if w is beautiful. Print No otherwise.\n\nSample Input 1\n\nabaccaba\n\nSample Output 1\n\nYes\n\na occurs four times, b occurs twice, c occurs twice and the other letters occur zero times.\n\nSample Input 2\n\nhthth\n\nSample Output 2\n\nNo", "sample_input": "abaccaba\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p04012", "source_text": "Score : 200 points\n\nProblem Statement\n\nLet w be a string consisting of lowercase letters.\nWe will call w beautiful if the following condition is satisfied:\n\nEach lowercase letter of the English alphabet occurs even number of times in w.\n\nYou are given the string w. Determine if w is beautiful.\n\nConstraints\n\n1 \\leq |w| \\leq 100\n\nw consists of lowercase letters (a-z).\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nw\n\nOutput\n\nPrint Yes if w is beautiful. Print No otherwise.\n\nSample Input 1\n\nabaccaba\n\nSample Output 1\n\nYes\n\na occurs four times, b occurs twice, c occurs twice and the other letters occur zero times.\n\nSample Input 2\n\nhthth\n\nSample Output 2\n\nNo", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 464, "cpu_time_ms": 4, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s641613654", "group_id": "codeNet:p04013", "input_text": "open Printf\nlet input_int_array n =\n\tArray.init n (fun _ -> Scanf.scanf \" %d\" (fun v -> v))\n\nlet get_int () = Scanf.scanf \" %d\" (fun v -> v)\nlet get_2_ints () = Scanf.scanf \" %d %d\" (fun u v -> u,v)\nlet get_3_ints () = Scanf.scanf \" %d %d %d\" (fun u v w -> u,v,w)\nlet get_4_ints () = Scanf.scanf \" %d %d %d %d\" (fun u v w x -> u,v,w,x)\nlet get_5_ints () = Scanf.scanf \" %d %d %d %d %d\" (fun u v w x y -> u,v,w,x,y)\n\nlet print_int_endline n = n |> string_of_int |> print_endline\n\nmodule Int64 = struct\n\tinclude Int64\n\tlet (+|) p q = Int64.add p q\n\tlet (-|) p q = Int64.sub p q\n\tlet ( *|) p q = Int64.mul p q\n\tlet (/|) p q = Int64.div p q\n\tlet (<|) p q = \n\t\tif Int64.compare p q < 0 then true \n\t\telse false\n\tlet (>|) p q = \n\t\tif Int64.compare p q > 0 then true\n\t\telse false\n\tlet (>=|) p q = not (p < q)\n\tlet (<=|) p q = not (p > q)\n\tlet labs p = if p <| 0L then -1L*|p else p\n\tlet (~|) p = Int64.of_int p\nend\nopen Int64\n\nlet () =\n let n,a = get_2_ints ()\n in let xl = input_int_array n |> Array.to_list\n in\n let rec f0 ls s c =\n let k = if c>0 && s = c*a then 1L else 0L in\n (* printf \"%2d %2d -- %2Ld\\n\" s c k; *)\n match ls with\n | [] -> k\n | h::t -> (\n if c>0 && s=c*a then\n f0 t h 1 +| f0 t 0 0 +| 1L\n else\n f0 t (h+s) (c+1) +| f0 t s c\n )\n in f0 xl 0 0 |> printf \"%Ld\\n\"", "language": "OCaml", "metadata": {"date": 1531020779, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p04013.html", "problem_id": "p04013", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p04013/input.txt", "sample_output_relpath": "derived/input_output/data/p04013/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p04013/OCaml/s641613654.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s641613654", "user_id": "u481480055"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "open Printf\nlet input_int_array n =\n\tArray.init n (fun _ -> Scanf.scanf \" %d\" (fun v -> v))\n\nlet get_int () = Scanf.scanf \" %d\" (fun v -> v)\nlet get_2_ints () = Scanf.scanf \" %d %d\" (fun u v -> u,v)\nlet get_3_ints () = Scanf.scanf \" %d %d %d\" (fun u v w -> u,v,w)\nlet get_4_ints () = Scanf.scanf \" %d %d %d %d\" (fun u v w x -> u,v,w,x)\nlet get_5_ints () = Scanf.scanf \" %d %d %d %d %d\" (fun u v w x y -> u,v,w,x,y)\n\nlet print_int_endline n = n |> string_of_int |> print_endline\n\nmodule Int64 = struct\n\tinclude Int64\n\tlet (+|) p q = Int64.add p q\n\tlet (-|) p q = Int64.sub p q\n\tlet ( *|) p q = Int64.mul p q\n\tlet (/|) p q = Int64.div p q\n\tlet (<|) p q = \n\t\tif Int64.compare p q < 0 then true \n\t\telse false\n\tlet (>|) p q = \n\t\tif Int64.compare p q > 0 then true\n\t\telse false\n\tlet (>=|) p q = not (p < q)\n\tlet (<=|) p q = not (p > q)\n\tlet labs p = if p <| 0L then -1L*|p else p\n\tlet (~|) p = Int64.of_int p\nend\nopen Int64\n\nlet () =\n let n,a = get_2_ints ()\n in let xl = input_int_array n |> Array.to_list\n in\n let rec f0 ls s c =\n let k = if c>0 && s = c*a then 1L else 0L in\n (* printf \"%2d %2d -- %2Ld\\n\" s c k; *)\n match ls with\n | [] -> k\n | h::t -> (\n if c>0 && s=c*a then\n f0 t h 1 +| f0 t 0 0 +| 1L\n else\n f0 t (h+s) (c+1) +| f0 t s c\n )\n in f0 xl 0 0 |> printf \"%Ld\\n\"", "problem_context": "Score : 300 points\n\nProblem Statement\n\nTak has N cards. On the i-th (1 \\leq i \\leq N) card is written an integer x_i.\nHe is selecting one or more cards from these N cards, so that the average of the integers written on the selected cards is exactly A.\nIn how many ways can he make his selection?\n\nConstraints\n\n1 \\leq N \\leq 50\n\n1 \\leq A \\leq 50\n\n1 \\leq x_i \\leq 50\n\nN,\\,A,\\,x_i are integers.\n\nPartial Score\n\n200 points will be awarded for passing the test set satisfying 1 \\leq N \\leq 16.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN A\nx_1 x_2 ... x_N\n\nOutput\n\nPrint the number of ways to select cards such that the average of the written integers is exactly A.\n\nSample Input 1\n\n4 8\n7 9 8 9\n\nSample Output 1\n\n5\n\nThe following are the 5 ways to select cards such that the average is 8:\n\nSelect the 3-rd card.\n\nSelect the 1-st and 2-nd cards.\n\nSelect the 1-st and 4-th cards.\n\nSelect the 1-st, 2-nd and 3-rd cards.\n\nSelect the 1-st, 3-rd and 4-th cards.\n\nSample Input 2\n\n3 8\n6 6 9\n\nSample Output 2\n\n0\n\nSample Input 3\n\n8 5\n3 6 2 8 7 6 5 9\n\nSample Output 3\n\n19\n\nSample Input 4\n\n33 3\n3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3\n\nSample Output 4\n\n8589934591\n\nThe answer may not fit into a 32-bit integer.", "sample_input": "4 8\n7 9 8 9\n"}, "reference_outputs": ["5\n"], "source_document_id": "p04013", "source_text": "Score : 300 points\n\nProblem Statement\n\nTak has N cards. On the i-th (1 \\leq i \\leq N) card is written an integer x_i.\nHe is selecting one or more cards from these N cards, so that the average of the integers written on the selected cards is exactly A.\nIn how many ways can he make his selection?\n\nConstraints\n\n1 \\leq N \\leq 50\n\n1 \\leq A \\leq 50\n\n1 \\leq x_i \\leq 50\n\nN,\\,A,\\,x_i are integers.\n\nPartial Score\n\n200 points will be awarded for passing the test set satisfying 1 \\leq N \\leq 16.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN A\nx_1 x_2 ... x_N\n\nOutput\n\nPrint the number of ways to select cards such that the average of the written integers is exactly A.\n\nSample Input 1\n\n4 8\n7 9 8 9\n\nSample Output 1\n\n5\n\nThe following are the 5 ways to select cards such that the average is 8:\n\nSelect the 3-rd card.\n\nSelect the 1-st and 2-nd cards.\n\nSelect the 1-st and 4-th cards.\n\nSelect the 1-st, 2-nd and 3-rd cards.\n\nSelect the 1-st, 3-rd and 4-th cards.\n\nSample Input 2\n\n3 8\n6 6 9\n\nSample Output 2\n\n0\n\nSample Input 3\n\n8 5\n3 6 2 8 7 6 5 9\n\nSample Output 3\n\n19\n\nSample Input 4\n\n33 3\n3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3\n\nSample Output 4\n\n8589934591\n\nThe answer may not fit into a 32-bit integer.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1319, "cpu_time_ms": 2103, "memory_kb": 4608}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s223339998", "group_id": "codeNet:p04015", "input_text": "Scanf.scanf \"%d %d\" (fun n aa ->\n let x = Array.init n (fun _ -> Scanf.scanf \" %d\" (fun x -> x - aa)) in\n let rec loop i a b c =\n if i = n then a, b, c else\n if x.(i) < 0 then loop (i + 1) (-x.(i) :: a) b c else\n if x.(i) > 0 then loop (i + 1) a b (x.(i) :: c) else\n loop (i + 1) a (b * 2) c\n in\n let a, b, c = loop 0 [] 1 [] in\n let build l =\n let arr = Array.make 2501 0 in\n arr.(0) <- 1;\n let rec loop = function\n | [] -> arr\n | hd :: tl ->\n for j = 2500 - hd downto 0 do\n arr.(hd + j) <- arr.(hd + j) + arr.(j)\n done;\n loop tl\n in\n loop l\n in\n let mi = build a in\n let pl = build c in\n let rec loop i acc =\n if i = 2501 then acc else\n loop (i + 1) (acc + mi.(i) * pl.(i) * b)\n in\n loop 0 (-1) |> Printf.printf \"%d\\n\"\n)", "language": "OCaml", "metadata": {"date": 1590649649, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p04015.html", "problem_id": "p04015", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p04015/input.txt", "sample_output_relpath": "derived/input_output/data/p04015/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p04015/OCaml/s223339998.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s223339998", "user_id": "u342443598"}, "prompt_components": {"gold_output": "5\n", "input_to_evaluate": "Scanf.scanf \"%d %d\" (fun n aa ->\n let x = Array.init n (fun _ -> Scanf.scanf \" %d\" (fun x -> x - aa)) in\n let rec loop i a b c =\n if i = n then a, b, c else\n if x.(i) < 0 then loop (i + 1) (-x.(i) :: a) b c else\n if x.(i) > 0 then loop (i + 1) a b (x.(i) :: c) else\n loop (i + 1) a (b * 2) c\n in\n let a, b, c = loop 0 [] 1 [] in\n let build l =\n let arr = Array.make 2501 0 in\n arr.(0) <- 1;\n let rec loop = function\n | [] -> arr\n | hd :: tl ->\n for j = 2500 - hd downto 0 do\n arr.(hd + j) <- arr.(hd + j) + arr.(j)\n done;\n loop tl\n in\n loop l\n in\n let mi = build a in\n let pl = build c in\n let rec loop i acc =\n if i = 2501 then acc else\n loop (i + 1) (acc + mi.(i) * pl.(i) * b)\n in\n loop 0 (-1) |> Printf.printf \"%d\\n\"\n)", "problem_context": "Score : 300 points\n\nProblem Statement\n\nTak has N cards. On the i-th (1 \\leq i \\leq N) card is written an integer x_i.\nHe is selecting one or more cards from these N cards, so that the average of the integers written on the selected cards is exactly A.\nIn how many ways can he make his selection?\n\nConstraints\n\n1 \\leq N \\leq 50\n\n1 \\leq A \\leq 50\n\n1 \\leq x_i \\leq 50\n\nN,\\,A,\\,x_i are integers.\n\nPartial Score\n\n200 points will be awarded for passing the test set satisfying 1 \\leq N \\leq 16.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN A\nx_1 x_2 ... x_N\n\nOutput\n\nPrint the number of ways to select cards such that the average of the written integers is exactly A.\n\nSample Input 1\n\n4 8\n7 9 8 9\n\nSample Output 1\n\n5\n\nThe following are the 5 ways to select cards such that the average is 8:\n\nSelect the 3-rd card.\n\nSelect the 1-st and 2-nd cards.\n\nSelect the 1-st and 4-th cards.\n\nSelect the 1-st, 2-nd and 3-rd cards.\n\nSelect the 1-st, 3-rd and 4-th cards.\n\nSample Input 2\n\n3 8\n6 6 9\n\nSample Output 2\n\n0\n\nSample Input 3\n\n8 5\n3 6 2 8 7 6 5 9\n\nSample Output 3\n\n19\n\nSample Input 4\n\n33 3\n3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3\n\nSample Output 4\n\n8589934591\n\nThe answer may not fit into a 32-bit integer.", "sample_input": "4 8\n7 9 8 9\n"}, "reference_outputs": ["5\n"], "source_document_id": "p04015", "source_text": "Score : 300 points\n\nProblem Statement\n\nTak has N cards. On the i-th (1 \\leq i \\leq N) card is written an integer x_i.\nHe is selecting one or more cards from these N cards, so that the average of the integers written on the selected cards is exactly A.\nIn how many ways can he make his selection?\n\nConstraints\n\n1 \\leq N \\leq 50\n\n1 \\leq A \\leq 50\n\n1 \\leq x_i \\leq 50\n\nN,\\,A,\\,x_i are integers.\n\nPartial Score\n\n200 points will be awarded for passing the test set satisfying 1 \\leq N \\leq 16.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN A\nx_1 x_2 ... x_N\n\nOutput\n\nPrint the number of ways to select cards such that the average of the written integers is exactly A.\n\nSample Input 1\n\n4 8\n7 9 8 9\n\nSample Output 1\n\n5\n\nThe following are the 5 ways to select cards such that the average is 8:\n\nSelect the 3-rd card.\n\nSelect the 1-st and 2-nd cards.\n\nSelect the 1-st and 4-th cards.\n\nSelect the 1-st, 2-nd and 3-rd cards.\n\nSelect the 1-st, 3-rd and 4-th cards.\n\nSample Input 2\n\n3 8\n6 6 9\n\nSample Output 2\n\n0\n\nSample Input 3\n\n8 5\n3 6 2 8 7 6 5 9\n\nSample Output 3\n\n19\n\nSample Input 4\n\n33 3\n3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3\n\nSample Output 4\n\n8589934591\n\nThe answer may not fit into a 32-bit integer.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 940, "cpu_time_ms": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s343000808", "group_id": "codeNet:p04016", "input_text": "let rec f acc b = function\n | 0 -> acc\n | n -> f (n mod b + acc) b (n / b)\nlet f = f 0\n\nlet () = Scanf.scanf \"%d %d\" @@ fun n s ->\n let r = int_of_float @@ sqrt @@ float_of_int n in\n if n < s\n then print_endline \"-1\"\n else if n = s\n then Printf.printf \"%d\\n\" (n + 1)\n else \n try\n Array.init r (( + ) 2)\n |> Array.to_list\n |> List.find (fun b -> f b n = s)\n |> Printf.printf \"%d\\n\"\n with Not_found ->\n try\n Array.init ((n - s) / (r - 1)) (( + ) 1)\n |> Array.to_list\n |> List.rev_map (fun p -> (n - s) / p + 1)\n |> List.filter (( <= ) 2)\n |> List.find (fun b -> f b n = s)\n |> Printf.printf \"%d\\n\"\n with _ -> print_endline \"-1\"", "language": "OCaml", "metadata": {"date": 1530341896, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p04016.html", "problem_id": "p04016", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p04016/input.txt", "sample_output_relpath": "derived/input_output/data/p04016/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p04016/OCaml/s343000808.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s343000808", "user_id": "u504158101"}, "prompt_components": {"gold_output": "10\n", "input_to_evaluate": "let rec f acc b = function\n | 0 -> acc\n | n -> f (n mod b + acc) b (n / b)\nlet f = f 0\n\nlet () = Scanf.scanf \"%d %d\" @@ fun n s ->\n let r = int_of_float @@ sqrt @@ float_of_int n in\n if n < s\n then print_endline \"-1\"\n else if n = s\n then Printf.printf \"%d\\n\" (n + 1)\n else \n try\n Array.init r (( + ) 2)\n |> Array.to_list\n |> List.find (fun b -> f b n = s)\n |> Printf.printf \"%d\\n\"\n with Not_found ->\n try\n Array.init ((n - s) / (r - 1)) (( + ) 1)\n |> Array.to_list\n |> List.rev_map (fun p -> (n - s) / p + 1)\n |> List.filter (( <= ) 2)\n |> List.find (fun b -> f b n = s)\n |> Printf.printf \"%d\\n\"\n with _ -> print_endline \"-1\"", "problem_context": "Score : 500 points\n\nProblem Statement\n\nFor integers b (b \\geq 2) and n (n \\geq 1), let the function f(b,n) be defined as follows:\n\nf(b,n) = n, when n < b\n\nf(b,n) = f(b,\\,{\\rm floor}(n / b)) + (n \\ {\\rm mod} \\ b), when n \\geq b\n\nHere, {\\rm floor}(n / b) denotes the largest integer not exceeding n / b,\nand n \\ {\\rm mod} \\ b denotes the remainder of n divided by b.\n\nLess formally, f(b,n) is equal to the sum of the digits of n written in base b.\nFor example, the following hold:\n\nf(10,\\,87654)=8+7+6+5+4=30\n\nf(100,\\,87654)=8+76+54=138\n\nYou are given integers n and s.\nDetermine if there exists an integer b (b \\geq 2) such that f(b,n)=s.\nIf the answer is positive, also find the smallest such b.\n\nConstraints\n\n1 \\leq n \\leq 10^{11}\n\n1 \\leq s \\leq 10^{11}\n\nn,\\,s are integers.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nn\ns\n\nOutput\n\nIf there exists an integer b (b \\geq 2) such that f(b,n)=s, print the smallest such b.\nIf such b does not exist, print -1 instead.\n\nSample Input 1\n\n87654\n30\n\nSample Output 1\n\n10\n\nSample Input 2\n\n87654\n138\n\nSample Output 2\n\n100\n\nSample Input 3\n\n87654\n45678\n\nSample Output 3\n\n-1\n\nSample Input 4\n\n31415926535\n1\n\nSample Output 4\n\n31415926535\n\nSample Input 5\n\n1\n31415926535\n\nSample Output 5\n\n-1", "sample_input": "87654\n30\n"}, "reference_outputs": ["10\n"], "source_document_id": "p04016", "source_text": "Score : 500 points\n\nProblem Statement\n\nFor integers b (b \\geq 2) and n (n \\geq 1), let the function f(b,n) be defined as follows:\n\nf(b,n) = n, when n < b\n\nf(b,n) = f(b,\\,{\\rm floor}(n / b)) + (n \\ {\\rm mod} \\ b), when n \\geq b\n\nHere, {\\rm floor}(n / b) denotes the largest integer not exceeding n / b,\nand n \\ {\\rm mod} \\ b denotes the remainder of n divided by b.\n\nLess formally, f(b,n) is equal to the sum of the digits of n written in base b.\nFor example, the following hold:\n\nf(10,\\,87654)=8+7+6+5+4=30\n\nf(100,\\,87654)=8+76+54=138\n\nYou are given integers n and s.\nDetermine if there exists an integer b (b \\geq 2) such that f(b,n)=s.\nIf the answer is positive, also find the smallest such b.\n\nConstraints\n\n1 \\leq n \\leq 10^{11}\n\n1 \\leq s \\leq 10^{11}\n\nn,\\,s are integers.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nn\ns\n\nOutput\n\nIf there exists an integer b (b \\geq 2) such that f(b,n)=s, print the smallest such b.\nIf such b does not exist, print -1 instead.\n\nSample Input 1\n\n87654\n30\n\nSample Output 1\n\n10\n\nSample Input 2\n\n87654\n138\n\nSample Output 2\n\n100\n\nSample Input 3\n\n87654\n45678\n\nSample Output 3\n\n-1\n\nSample Input 4\n\n31415926535\n1\n\nSample Output 4\n\n31415926535\n\nSample Input 5\n\n1\n31415926535\n\nSample Output 5\n\n-1", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 148, "memory_kb": 21280}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s471946062", "group_id": "codeNet:p04019", "input_text": "let s = read_line ()\nlet f c = if String.contains s c then 1 else 0\nlet _ = print_endline @@ if abs (f 'N' - f 'S') + abs (f 'E' - f 'W') = 0 then \"Yes\" else \"No\"", "language": "OCaml", "metadata": {"date": 1571726800, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p04019.html", "problem_id": "p04019", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p04019/input.txt", "sample_output_relpath": "derived/input_output/data/p04019/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p04019/OCaml/s471946062.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s471946062", "user_id": "u732304692"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "let s = read_line ()\nlet f c = if String.contains s c then 1 else 0\nlet _ = print_endline @@ if abs (f 'N' - f 'S') + abs (f 'E' - f 'W') = 0 then \"Yes\" else \"No\"", "problem_context": "Score : 200 points\n\nProblem Statement\n\nSnuke lives on an infinite two-dimensional plane. He is going on an N-day trip.\nAt the beginning of Day 1, he is at home. His plan is described in a string S of length N.\nOn Day i(1 ≦ i ≦ N), he will travel a positive distance in the following direction:\n\nNorth if the i-th letter of S is N\n\nWest if the i-th letter of S is W\n\nSouth if the i-th letter of S is S\n\nEast if the i-th letter of S is E\n\nHe has not decided each day's travel distance. Determine whether it is possible to set each day's travel distance so that he will be back at home at the end of Day N.\n\nConstraints\n\n1 ≦ | S | ≦ 1000\n\nS consists of the letters N, W, S, E.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint Yes if it is possible to set each day's travel distance so that he will be back at home at the end of Day N. Otherwise, print No.\n\nSample Input 1\n\nSENW\n\nSample Output 1\n\nYes\n\nIf Snuke travels a distance of 1 on each day, he will be back at home at the end of day 4.\n\nSample Input 2\n\nNSNNSNSN\n\nSample Output 2\n\nYes\n\nSample Input 3\n\nNNEW\n\nSample Output 3\n\nNo\n\nSample Input 4\n\nW\n\nSample Output 4\n\nNo", "sample_input": "SENW\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p04019", "source_text": "Score : 200 points\n\nProblem Statement\n\nSnuke lives on an infinite two-dimensional plane. He is going on an N-day trip.\nAt the beginning of Day 1, he is at home. His plan is described in a string S of length N.\nOn Day i(1 ≦ i ≦ N), he will travel a positive distance in the following direction:\n\nNorth if the i-th letter of S is N\n\nWest if the i-th letter of S is W\n\nSouth if the i-th letter of S is S\n\nEast if the i-th letter of S is E\n\nHe has not decided each day's travel distance. Determine whether it is possible to set each day's travel distance so that he will be back at home at the end of Day N.\n\nConstraints\n\n1 ≦ | S | ≦ 1000\n\nS consists of the letters N, W, S, E.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint Yes if it is possible to set each day's travel distance so that he will be back at home at the end of Day N. Otherwise, print No.\n\nSample Input 1\n\nSENW\n\nSample Output 1\n\nYes\n\nIf Snuke travels a distance of 1 on each day, he will be back at home at the end of day 4.\n\nSample Input 2\n\nNSNNSNSN\n\nSample Output 2\n\nYes\n\nSample Input 3\n\nNNEW\n\nSample Output 3\n\nNo\n\nSample Input 4\n\nW\n\nSample Output 4\n\nNo", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 162, "cpu_time_ms": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s579337637", "group_id": "codeNet:p04019", "input_text": "let encode = function\n |'N' -> 0x1\n |'S' -> 0x2\n |'E' -> 0x4\n |'W' -> 0x8\n | _ -> 0\n\nlet s = read_line ()\n\nlet rec solve acc i = if i = String.length s then acc else solve (acc lor encode s.[i]) (i+1)\n\nlet () = let r = solve 0 0 in\n let a = (r lxor (r lsr 1)) land 0x5 in\n print_string (if a = 0 then \"Yes\" else \"No\")", "language": "OCaml", "metadata": {"date": 1471911602, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p04019.html", "problem_id": "p04019", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p04019/input.txt", "sample_output_relpath": "derived/input_output/data/p04019/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p04019/OCaml/s579337637.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s579337637", "user_id": "u367021138"}, "prompt_components": {"gold_output": "Yes\n", "input_to_evaluate": "let encode = function\n |'N' -> 0x1\n |'S' -> 0x2\n |'E' -> 0x4\n |'W' -> 0x8\n | _ -> 0\n\nlet s = read_line ()\n\nlet rec solve acc i = if i = String.length s then acc else solve (acc lor encode s.[i]) (i+1)\n\nlet () = let r = solve 0 0 in\n let a = (r lxor (r lsr 1)) land 0x5 in\n print_string (if a = 0 then \"Yes\" else \"No\")", "problem_context": "Score : 200 points\n\nProblem Statement\n\nSnuke lives on an infinite two-dimensional plane. He is going on an N-day trip.\nAt the beginning of Day 1, he is at home. His plan is described in a string S of length N.\nOn Day i(1 ≦ i ≦ N), he will travel a positive distance in the following direction:\n\nNorth if the i-th letter of S is N\n\nWest if the i-th letter of S is W\n\nSouth if the i-th letter of S is S\n\nEast if the i-th letter of S is E\n\nHe has not decided each day's travel distance. Determine whether it is possible to set each day's travel distance so that he will be back at home at the end of Day N.\n\nConstraints\n\n1 ≦ | S | ≦ 1000\n\nS consists of the letters N, W, S, E.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint Yes if it is possible to set each day's travel distance so that he will be back at home at the end of Day N. Otherwise, print No.\n\nSample Input 1\n\nSENW\n\nSample Output 1\n\nYes\n\nIf Snuke travels a distance of 1 on each day, he will be back at home at the end of day 4.\n\nSample Input 2\n\nNSNNSNSN\n\nSample Output 2\n\nYes\n\nSample Input 3\n\nNNEW\n\nSample Output 3\n\nNo\n\nSample Input 4\n\nW\n\nSample Output 4\n\nNo", "sample_input": "SENW\n"}, "reference_outputs": ["Yes\n"], "source_document_id": "p04019", "source_text": "Score : 200 points\n\nProblem Statement\n\nSnuke lives on an infinite two-dimensional plane. He is going on an N-day trip.\nAt the beginning of Day 1, he is at home. His plan is described in a string S of length N.\nOn Day i(1 ≦ i ≦ N), he will travel a positive distance in the following direction:\n\nNorth if the i-th letter of S is N\n\nWest if the i-th letter of S is W\n\nSouth if the i-th letter of S is S\n\nEast if the i-th letter of S is E\n\nHe has not decided each day's travel distance. Determine whether it is possible to set each day's travel distance so that he will be back at home at the end of Day N.\n\nConstraints\n\n1 ≦ | S | ≦ 1000\n\nS consists of the letters N, W, S, E.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nS\n\nOutput\n\nPrint Yes if it is possible to set each day's travel distance so that he will be back at home at the end of Day N. Otherwise, print No.\n\nSample Input 1\n\nSENW\n\nSample Output 1\n\nYes\n\nIf Snuke travels a distance of 1 on each day, he will be back at home at the end of day 4.\n\nSample Input 2\n\nNSNNSNSN\n\nSample Output 2\n\nYes\n\nSample Input 3\n\nNNEW\n\nSample Output 3\n\nNo\n\nSample Input 4\n\nW\n\nSample Output 4\n\nNo", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 4, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s031465110", "group_id": "codeNet:p04020", "input_text": "Scanf.scanf \"%d\" (fun n ->\n let a = Array.init n (fun _ -> Scanf.scanf \" %d\" (fun a -> a)) in\n\n let rec loop i carry acc =\n if i = n then acc else\n if a.(i) = 0 then loop (i + 1) 0 acc else\n let t = (carry + a.(i)) / 2 in\n let carry = (carry + a.(i)) mod 2 in\n loop (i + 1) carry (acc + t)\n in\n loop 0 0 0 |> Printf.printf \"%d\\n\"\n)", "language": "OCaml", "metadata": {"date": 1588993305, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p04020.html", "problem_id": "p04020", "resource_group": "low_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/OCaml/s031465110.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s031465110", "user_id": "u342443598"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "Scanf.scanf \"%d\" (fun n ->\n let a = Array.init n (fun _ -> Scanf.scanf \" %d\" (fun a -> a)) in\n\n let rec loop i carry acc =\n if i = n then acc else\n if a.(i) = 0 then loop (i + 1) 0 acc else\n let t = (carry + a.(i)) / 2 in\n let carry = (carry + a.(i)) mod 2 in\n loop (i + 1) carry (acc + t)\n in\n loop 0 0 0 |> Printf.printf \"%d\\n\"\n)", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 32, "memory_kb": 5248}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s979504722", "group_id": "codeNet:p04026", "input_text": "let array_of_string s = Array.init (String.length s) (fun i -> s.[i])\n\nlet () =\n try\n read_line ()\n |> array_of_string\n |> (fun a ->\n Array.to_list (Array.init (Array.length a - 1) (fun i -> ((i + 1, i + 2), a.(i) = a.(i + 1)))) @\n Array.to_list (Array.init (Array.length a - 2) (fun i -> ((i + 1, i + 3), a.(i) = a.(i + 2)))))\n |> List.find (fun (_, b) -> b)\n |> (fun ((i, j), _) -> Printf.printf \"%d %d\\n\" i j)\n with Not_found -> print_endline \"-1 -1\"", "language": "OCaml", "metadata": {"date": 1510604551, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p04026.html", "problem_id": "p04026", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p04026/input.txt", "sample_output_relpath": "derived/input_output/data/p04026/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p04026/OCaml/s979504722.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s979504722", "user_id": "u504158101"}, "prompt_components": {"gold_output": "2 5\n", "input_to_evaluate": "let array_of_string s = Array.init (String.length s) (fun i -> s.[i])\n\nlet () =\n try\n read_line ()\n |> array_of_string\n |> (fun a ->\n Array.to_list (Array.init (Array.length a - 1) (fun i -> ((i + 1, i + 2), a.(i) = a.(i + 1)))) @\n Array.to_list (Array.init (Array.length a - 2) (fun i -> ((i + 1, i + 3), a.(i) = a.(i + 2)))))\n |> List.find (fun (_, b) -> b)\n |> (fun ((i, j), _) -> Printf.printf \"%d %d\\n\" i j)\n with Not_found -> print_endline \"-1 -1\"", "problem_context": "Score : 400 points\n\nProblem Statement\n\nGiven a string t, we will call it unbalanced if and only if the length of t is at least 2, and more than half of the letters in t are the same. For example, both voodoo and melee are unbalanced, while neither noon nor a is.\n\nYou are given a string s consisting of lowercase letters. Determine if there exists a (contiguous) substring of s that is unbalanced. If the answer is positive, show a position where such a substring occurs in s.\n\nConstraints\n\n2 ≦ |s| ≦ 10^5\n\ns consists of lowercase letters.\n\nPartial Score\n\n200 points will be awarded for passing the test set satisfying 2 ≦ N ≦ 100.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\ns\n\nOutput\n\nIf there exists no unbalanced substring of s, print -1 -1.\n\nIf there exists an unbalanced substring of s, let one such substring be s_a s_{a+1} ... s_{b} (1 ≦ a < b ≦ |s|), and print a b. If there exists more than one such substring, any of them will be accepted.\n\nSample Input 1\n\nneeded\n\nSample Output 1\n\n2 5\n\nThe string s_2 s_3 s_4 s_5 = eede is unbalanced. There are also other unbalanced substrings. For example, the output 2 6 will also be accepted.\n\nSample Input 2\n\natcoder\n\nSample Output 2\n\n-1 -1\n\nThe string atcoder contains no unbalanced substring.", "sample_input": "needed\n"}, "reference_outputs": ["2 5\n"], "source_document_id": "p04026", "source_text": "Score : 400 points\n\nProblem Statement\n\nGiven a string t, we will call it unbalanced if and only if the length of t is at least 2, and more than half of the letters in t are the same. For example, both voodoo and melee are unbalanced, while neither noon nor a is.\n\nYou are given a string s consisting of lowercase letters. Determine if there exists a (contiguous) substring of s that is unbalanced. If the answer is positive, show a position where such a substring occurs in s.\n\nConstraints\n\n2 ≦ |s| ≦ 10^5\n\ns consists of lowercase letters.\n\nPartial Score\n\n200 points will be awarded for passing the test set satisfying 2 ≦ N ≦ 100.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\ns\n\nOutput\n\nIf there exists no unbalanced substring of s, print -1 -1.\n\nIf there exists an unbalanced substring of s, let one such substring be s_a s_{a+1} ... s_{b} (1 ≦ a < b ≦ |s|), and print a b. If there exists more than one such substring, any of them will be accepted.\n\nSample Input 1\n\nneeded\n\nSample Output 1\n\n2 5\n\nThe string s_2 s_3 s_4 s_5 = eede is unbalanced. There are also other unbalanced substrings. For example, the output 2 6 will also be accepted.\n\nSample Input 2\n\natcoder\n\nSample Output 2\n\n-1 -1\n\nThe string atcoder contains no unbalanced substring.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 484, "cpu_time_ms": 50, "memory_kb": 23680}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s839491169", "group_id": "codeNet:p04029", "input_text": "let () = Scanf.scanf \"%d\" (fun a -> (a*(a+1))/2) |> Printf.printf \"%d\\n\"", "language": "OCaml", "metadata": {"date": 1560915691, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p04029.html", "problem_id": "p04029", "resource_group": "low_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/OCaml/s839491169.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s839491169", "user_id": "u635974378"}, "prompt_components": {"gold_output": "6\n", "input_to_evaluate": "let () = Scanf.scanf \"%d\" (fun a -> (a*(a+1))/2) |> Printf.printf \"%d\\n\"", "problem_context": "Score : 100 points\n\nProblem Statement\n\nThere are N children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give 1 candy to the first child in the line, 2 candies to the second child, ..., N candies to the N-th child. How many candies will be necessary in total?\n\nConstraints\n\n1≦N≦100\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the necessary number of candies in total.\n\nSample Input 1\n\n3\n\nSample Output 1\n\n6\n\nThe answer is 1+2+3=6.\n\nSample Input 2\n\n10\n\nSample Output 2\n\n55\n\nThe sum of the integers from 1 to 10 is 55.\n\nSample Input 3\n\n1\n\nSample Output 3\n\n1\n\nOnly one child. The answer is 1 in this case.", "sample_input": "3\n"}, "reference_outputs": ["6\n"], "source_document_id": "p04029", "source_text": "Score : 100 points\n\nProblem Statement\n\nThere are N children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give 1 candy to the first child in the line, 2 candies to the second child, ..., N candies to the N-th child. How many candies will be necessary in total?\n\nConstraints\n\n1≦N≦100\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the necessary number of candies in total.\n\nSample Input 1\n\n3\n\nSample Output 1\n\n6\n\nThe answer is 1+2+3=6.\n\nSample Input 2\n\n10\n\nSample Output 2\n\n55\n\nThe sum of the integers from 1 to 10 is 55.\n\nSample Input 3\n\n1\n\nSample Output 3\n\n1\n\nOnly one child. The answer is 1 in this case.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s266063353", "group_id": "codeNet:p04029", "input_text": "open Batteries\nopen Printf\nlet () =\n let n = Scanf.scanf \"%d \" (fun a -> a) in\n\n let rec aux n res =\n if n = 0 then res else\n aux (n-1) (res+n)\n in\n\n Printf.printf \"%d\\n\" @@\n aux n 0\n", "language": "OCaml", "metadata": {"date": 1529418763, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p04029.html", "problem_id": "p04029", "resource_group": "low_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/OCaml/s266063353.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s266063353", "user_id": "u139013163"}, "prompt_components": {"gold_output": "6\n", "input_to_evaluate": "open Batteries\nopen Printf\nlet () =\n let n = Scanf.scanf \"%d \" (fun a -> a) in\n\n let rec aux n res =\n if n = 0 then res else\n aux (n-1) (res+n)\n in\n\n Printf.printf \"%d\\n\" @@\n aux n 0\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nThere are N children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give 1 candy to the first child in the line, 2 candies to the second child, ..., N candies to the N-th child. How many candies will be necessary in total?\n\nConstraints\n\n1≦N≦100\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the necessary number of candies in total.\n\nSample Input 1\n\n3\n\nSample Output 1\n\n6\n\nThe answer is 1+2+3=6.\n\nSample Input 2\n\n10\n\nSample Output 2\n\n55\n\nThe sum of the integers from 1 to 10 is 55.\n\nSample Input 3\n\n1\n\nSample Output 3\n\n1\n\nOnly one child. The answer is 1 in this case.", "sample_input": "3\n"}, "reference_outputs": ["6\n"], "source_document_id": "p04029", "source_text": "Score : 100 points\n\nProblem Statement\n\nThere are N children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give 1 candy to the first child in the line, 2 candies to the second child, ..., N candies to the N-th child. How many candies will be necessary in total?\n\nConstraints\n\n1≦N≦100\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the necessary number of candies in total.\n\nSample Input 1\n\n3\n\nSample Output 1\n\n6\n\nThe answer is 1+2+3=6.\n\nSample Input 2\n\n10\n\nSample Output 2\n\n55\n\nThe sum of the integers from 1 to 10 is 55.\n\nSample Input 3\n\n1\n\nSample Output 3\n\n1\n\nOnly one child. The answer is 1 in this case.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 2, "memory_kb": 1152}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s625850988", "group_id": "codeNet:p04029", "input_text": "let solve n =\n n * (n+1) / 2\n\nlet () =\n let rec read () =\n try let ans = (Scanf.scanf \"%d\\n\" solve ) in\n Printf.printf \"%d\\n\" ans\n with End_of_file -> ()\n in\n read ()\n;;\n", "language": "OCaml", "metadata": {"date": 1487464199, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p04029.html", "problem_id": "p04029", "resource_group": "low_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/OCaml/s625850988.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s625850988", "user_id": "u980152513"}, "prompt_components": {"gold_output": "6\n", "input_to_evaluate": "let solve n =\n n * (n+1) / 2\n\nlet () =\n let rec read () =\n try let ans = (Scanf.scanf \"%d\\n\" solve ) in\n Printf.printf \"%d\\n\" ans\n with End_of_file -> ()\n in\n read ()\n;;\n", "problem_context": "Score : 100 points\n\nProblem Statement\n\nThere are N children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give 1 candy to the first child in the line, 2 candies to the second child, ..., N candies to the N-th child. How many candies will be necessary in total?\n\nConstraints\n\n1≦N≦100\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the necessary number of candies in total.\n\nSample Input 1\n\n3\n\nSample Output 1\n\n6\n\nThe answer is 1+2+3=6.\n\nSample Input 2\n\n10\n\nSample Output 2\n\n55\n\nThe sum of the integers from 1 to 10 is 55.\n\nSample Input 3\n\n1\n\nSample Output 3\n\n1\n\nOnly one child. The answer is 1 in this case.", "sample_input": "3\n"}, "reference_outputs": ["6\n"], "source_document_id": "p04029", "source_text": "Score : 100 points\n\nProblem Statement\n\nThere are N children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give 1 candy to the first child in the line, 2 candies to the second child, ..., N candies to the N-th child. How many candies will be necessary in total?\n\nConstraints\n\n1≦N≦100\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the necessary number of candies in total.\n\nSample Input 1\n\n3\n\nSample Output 1\n\n6\n\nThe answer is 1+2+3=6.\n\nSample Input 2\n\n10\n\nSample Output 2\n\n55\n\nThe sum of the integers from 1 to 10 is 55.\n\nSample Input 3\n\n1\n\nSample Output 3\n\n1\n\nOnly one child. The answer is 1 in this case.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s401547716", "group_id": "codeNet:p04031", "input_text": "let rec upper_bound l r p =\n if r <= 1 + l\n then l\n else let m = (l + r) / 2 in\n if p m \n then upper_bound m r p\n else upper_bound l m p\n\nlet () = Scanf.scanf \"%d\\n\" @@ fun n ->\n let as_ = Array.init n @@ fun _ ->\n Scanf.scanf \"%d \" @@ fun a -> a in\n let cost x =\n Array.fold_left ( + ) 0 @@\n Array.map (fun y -> (x - y) * (x - y)) as_ in\n Printf.printf \"%d\\n\" @@ cost @@ upper_bound (-100) 100 @@ fun i ->\n cost i - cost (i - 1) <= 0\n", "language": "OCaml", "metadata": {"date": 1530684813, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p04031.html", "problem_id": "p04031", "resource_group": "low_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/OCaml/s401547716.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s401547716", "user_id": "u504158101"}, "prompt_components": {"gold_output": "8\n", "input_to_evaluate": "let rec upper_bound l r p =\n if r <= 1 + l\n then l\n else let m = (l + r) / 2 in\n if p m \n then upper_bound m r p\n else upper_bound l m p\n\nlet () = Scanf.scanf \"%d\\n\" @@ fun n ->\n let as_ = Array.init n @@ fun _ ->\n Scanf.scanf \"%d \" @@ fun a -> a in\n let cost x =\n Array.fold_left ( + ) 0 @@\n Array.map (fun y -> (x - y) * (x - y)) as_ in\n Printf.printf \"%d\\n\" @@ cost @@ upper_bound (-100) 100 @@ fun i ->\n cost i - cost (i - 1) <= 0\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nEvi has N integers a_1,a_2,..,a_N. His objective is to have N equal integers by transforming some of them.\n\nHe may transform each integer at most once. Transforming an integer x into another integer y costs him (x-y)^2 dollars. Even if a_i=a_j (i≠j), he has to pay the cost separately for transforming each of them (See Sample 2).\n\nFind the minimum total cost to achieve his objective.\n\nConstraints\n\n1≦N≦100\n\n-100≦a_i≦100\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\na_1 a_2 ... a_N\n\nOutput\n\nPrint the minimum total cost to achieve Evi's objective.\n\nSample Input 1\n\n2\n4 8\n\nSample Output 1\n\n8\n\nTransforming the both into 6s will cost (4-6)^2+(8-6)^2=8 dollars, which is the minimum.\n\nSample Input 2\n\n3\n1 1 3\n\nSample Output 2\n\n3\n\nTransforming the all into 2s will cost (1-2)^2+(1-2)^2+(3-2)^2=3 dollars. Note that Evi has to pay (1-2)^2 dollar separately for transforming each of the two 1s.\n\nSample Input 3\n\n3\n4 2 5\n\nSample Output 3\n\n5\n\nLeaving the 4 as it is and transforming the 2 and the 5 into 4s will achieve the total cost of (2-4)^2+(5-4)^2=5 dollars, which is the minimum.\n\nSample Input 4\n\n4\n-100 -100 -100 -100\n\nSample Output 4\n\n0\n\nWithout transforming anything, Evi's objective is already achieved. Thus, the necessary cost is 0.", "sample_input": "2\n4 8\n"}, "reference_outputs": ["8\n"], "source_document_id": "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 471, "cpu_time_ms": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s738935126", "group_id": "codeNet:p04031", "input_text": "let cost_to_n list n =\n List.fold_left (fun x y -> x + y) 0 (List.map (fun x -> (n-x)*(n-x)) list)\n\nlet solve list =\n let rec aux list min_cost cto cfrom cnow =\n if cnow = cto then min_cost else\n let cur_cost = cost_to_n list cnow in\n aux list (min min_cost cur_cost) cto cfrom (cnow+1)\n in\n aux list max_int\n (List.fold_left (fun x y -> max x y) min_int list)\n (List.fold_left (fun x y -> min x y) max_int list)\n (List.fold_left (fun x y -> min x y) max_int list)\n \n\nlet read_list_of_int () =\n let rec read_list_of_int_inner lst =\n try let ans = (Scanf.scanf \"%d \" (fun x->x)) in\n read_list_of_int_inner (ans::lst)\n with End_of_file ->\n List.rev lst\n in\n read_list_of_int_inner []\n\nlet () =\n let _ = read_int() in\n let list = read_list_of_int () in\n let ans = solve list in\n Printf.printf \"%d\\n\" ans\n;;\n", "language": "OCaml", "metadata": {"date": 1487467368, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p04031.html", "problem_id": "p04031", "resource_group": "low_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/OCaml/s738935126.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s738935126", "user_id": "u980152513"}, "prompt_components": {"gold_output": "8\n", "input_to_evaluate": "let cost_to_n list n =\n List.fold_left (fun x y -> x + y) 0 (List.map (fun x -> (n-x)*(n-x)) list)\n\nlet solve list =\n let rec aux list min_cost cto cfrom cnow =\n if cnow = cto then min_cost else\n let cur_cost = cost_to_n list cnow in\n aux list (min min_cost cur_cost) cto cfrom (cnow+1)\n in\n aux list max_int\n (List.fold_left (fun x y -> max x y) min_int list)\n (List.fold_left (fun x y -> min x y) max_int list)\n (List.fold_left (fun x y -> min x y) max_int list)\n \n\nlet read_list_of_int () =\n let rec read_list_of_int_inner lst =\n try let ans = (Scanf.scanf \"%d \" (fun x->x)) in\n read_list_of_int_inner (ans::lst)\n with End_of_file ->\n List.rev lst\n in\n read_list_of_int_inner []\n\nlet () =\n let _ = read_int() in\n let list = read_list_of_int () in\n let ans = solve list in\n Printf.printf \"%d\\n\" ans\n;;\n", "problem_context": "Score : 200 points\n\nProblem Statement\n\nEvi has N integers a_1,a_2,..,a_N. His objective is to have N equal integers by transforming some of them.\n\nHe may transform each integer at most once. Transforming an integer x into another integer y costs him (x-y)^2 dollars. Even if a_i=a_j (i≠j), he has to pay the cost separately for transforming each of them (See Sample 2).\n\nFind the minimum total cost to achieve his objective.\n\nConstraints\n\n1≦N≦100\n\n-100≦a_i≦100\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN\na_1 a_2 ... a_N\n\nOutput\n\nPrint the minimum total cost to achieve Evi's objective.\n\nSample Input 1\n\n2\n4 8\n\nSample Output 1\n\n8\n\nTransforming the both into 6s will cost (4-6)^2+(8-6)^2=8 dollars, which is the minimum.\n\nSample Input 2\n\n3\n1 1 3\n\nSample Output 2\n\n3\n\nTransforming the all into 2s will cost (1-2)^2+(1-2)^2+(3-2)^2=3 dollars. Note that Evi has to pay (1-2)^2 dollar separately for transforming each of the two 1s.\n\nSample Input 3\n\n3\n4 2 5\n\nSample Output 3\n\n5\n\nLeaving the 4 as it is and transforming the 2 and the 5 into 4s will achieve the total cost of (2-4)^2+(5-4)^2=5 dollars, which is the minimum.\n\nSample Input 4\n\n4\n-100 -100 -100 -100\n\nSample Output 4\n\n0\n\nWithout transforming anything, Evi's objective is already achieved. Thus, the necessary cost is 0.", "sample_input": "2\n4 8\n"}, "reference_outputs": ["8\n"], "source_document_id": "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 864, "cpu_time_ms": 1, "memory_kb": 896}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s487072961", "group_id": "codeNet:p04034", "input_text": "Scanf.scanf \"%d %d\" (fun n m ->\n let balls = Array.make n 1 in\n let red = Array.make n false in\n red.(0) <- true;\n for i = 1 to m do\n Scanf.scanf \" %d %d\" (fun x y ->\n let x = x - 1 in let y = y - 1 in\n if red.(x) then (\n if balls.(x) = 1 then red.(x) <- false;\n red.(y) <- true\n );\n balls.(x) <- balls.(x) - 1;\n balls.(y) <- balls.(y) + 1;\n )\n done;\n Array.fold_left (fun acc v -> if v then acc + 1 else acc) 0 red |> Printf.printf \"%d\\n\"\n)", "language": "OCaml", "metadata": {"date": 1588648771, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p04034.html", "problem_id": "p04034", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p04034/input.txt", "sample_output_relpath": "derived/input_output/data/p04034/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p04034/OCaml/s487072961.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s487072961", "user_id": "u342443598"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "Scanf.scanf \"%d %d\" (fun n m ->\n let balls = Array.make n 1 in\n let red = Array.make n false in\n red.(0) <- true;\n for i = 1 to m do\n Scanf.scanf \" %d %d\" (fun x y ->\n let x = x - 1 in let y = y - 1 in\n if red.(x) then (\n if balls.(x) = 1 then red.(x) <- false;\n red.(y) <- true\n );\n balls.(x) <- balls.(x) - 1;\n balls.(y) <- balls.(y) + 1;\n )\n done;\n Array.fold_left (fun acc v -> if v then acc + 1 else acc) 0 red |> Printf.printf \"%d\\n\"\n)", "problem_context": "Problem Statement\n\nWe have N boxes, numbered 1 through N. At first, box 1 contains one red ball, and each of the other boxes contains one white ball.\n\nSnuke will perform the following M operations, one by one. In the i-th operation, he randomly picks one ball from box x_i, then he puts it into box y_i.\n\nFind the number of boxes that may contain the red ball after all operations are performed.\n\nConstraints\n\n2≤N≤10^5\n\n1≤M≤10^5\n\n1≤x_i,y_i≤N\n\nx_i≠y_i\n\nJust before the i-th operation is performed, box x_i contains at least 1 ball.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN M\nx_1 y_1\n:\nx_M y_M\n\nOutput\n\nPrint the number of boxes that may contain the red ball after all operations are performed.\n\nSample Input 1\n\n3 2\n1 2\n2 3\n\nSample Output 1\n\n2\n\nJust after the first operation, box 1 is empty, box 2 contains one red ball and one white ball, and box 3 contains one white ball.\n\nNow, consider the second operation. If Snuke picks the red ball from box 2, the red ball will go into box 3. If he picks the white ball instead, the red ball will stay in box 2.\nThus, the number of boxes that may contain the red ball after all operations, is 2.\n\nSample Input 2\n\n3 3\n1 2\n2 3\n2 3\n\nSample Output 2\n\n1\n\nAll balls will go into box 3.\n\nSample Input 3\n\n4 4\n1 2\n2 3\n4 1\n3 4\n\nSample Output 3\n\n3", "sample_input": "3 2\n1 2\n2 3\n"}, "reference_outputs": ["2\n"], "source_document_id": "p04034", "source_text": "Problem Statement\n\nWe have N boxes, numbered 1 through N. At first, box 1 contains one red ball, and each of the other boxes contains one white ball.\n\nSnuke will perform the following M operations, one by one. In the i-th operation, he randomly picks one ball from box x_i, then he puts it into box y_i.\n\nFind the number of boxes that may contain the red ball after all operations are performed.\n\nConstraints\n\n2≤N≤10^5\n\n1≤M≤10^5\n\n1≤x_i,y_i≤N\n\nx_i≠y_i\n\nJust before the i-th operation is performed, box x_i contains at least 1 ball.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN M\nx_1 y_1\n:\nx_M y_M\n\nOutput\n\nPrint the number of boxes that may contain the red ball after all operations are performed.\n\nSample Input 1\n\n3 2\n1 2\n2 3\n\nSample Output 1\n\n2\n\nJust after the first operation, box 1 is empty, box 2 contains one red ball and one white ball, and box 3 contains one white ball.\n\nNow, consider the second operation. If Snuke picks the red ball from box 2, the red ball will go into box 3. If he picks the white ball instead, the red ball will stay in box 2.\nThus, the number of boxes that may contain the red ball after all operations, is 2.\n\nSample Input 2\n\n3 3\n1 2\n2 3\n2 3\n\nSample Output 2\n\n1\n\nAll balls will go into box 3.\n\nSample Input 3\n\n4 4\n1 2\n2 3\n4 1\n3 4\n\nSample Output 3\n\n3", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 46, "memory_kb": 5888}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s570423569", "group_id": "codeNet:p04034", "input_text": "let n, m = Scanf.scanf \"%d %d \" (fun x y -> x, y)\n\nlet rec rev_read_ints accu = function\n | 0 -> accu\n | k -> rev_read_ints ((Scanf.scanf \"%d %d\\n\" (fun x y -> x-1, y-1)) :: accu) (k-1)\n\nlet xy = List.rev (rev_read_ints [] m)\n\nlet possible = Array.make n false\nlet () = possible.(0) <- true\n\nlet numbers = Array.make n 1\n\nlet rec solve = function\n | [] -> ()\n | (x, y) :: tl -> if possible.(x) then begin possible.(y) <- true; if numbers.(x) = 1 then possible.(x) <- false end;\n numbers.(x) <- numbers.(x) - 1; numbers.(y) <- numbers.(y) + 1; solve tl\n\nlet () = solve xy; print_int (Array.fold_left (fun x y -> x + (if y then 1 else 0)) 0 possible)", "language": "OCaml", "metadata": {"date": 1470186196, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p04034.html", "problem_id": "p04034", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p04034/input.txt", "sample_output_relpath": "derived/input_output/data/p04034/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p04034/OCaml/s570423569.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s570423569", "user_id": "u367021138"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "let n, m = Scanf.scanf \"%d %d \" (fun x y -> x, y)\n\nlet rec rev_read_ints accu = function\n | 0 -> accu\n | k -> rev_read_ints ((Scanf.scanf \"%d %d\\n\" (fun x y -> x-1, y-1)) :: accu) (k-1)\n\nlet xy = List.rev (rev_read_ints [] m)\n\nlet possible = Array.make n false\nlet () = possible.(0) <- true\n\nlet numbers = Array.make n 1\n\nlet rec solve = function\n | [] -> ()\n | (x, y) :: tl -> if possible.(x) then begin possible.(y) <- true; if numbers.(x) = 1 then possible.(x) <- false end;\n numbers.(x) <- numbers.(x) - 1; numbers.(y) <- numbers.(y) + 1; solve tl\n\nlet () = solve xy; print_int (Array.fold_left (fun x y -> x + (if y then 1 else 0)) 0 possible)", "problem_context": "Problem Statement\n\nWe have N boxes, numbered 1 through N. At first, box 1 contains one red ball, and each of the other boxes contains one white ball.\n\nSnuke will perform the following M operations, one by one. In the i-th operation, he randomly picks one ball from box x_i, then he puts it into box y_i.\n\nFind the number of boxes that may contain the red ball after all operations are performed.\n\nConstraints\n\n2≤N≤10^5\n\n1≤M≤10^5\n\n1≤x_i,y_i≤N\n\nx_i≠y_i\n\nJust before the i-th operation is performed, box x_i contains at least 1 ball.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN M\nx_1 y_1\n:\nx_M y_M\n\nOutput\n\nPrint the number of boxes that may contain the red ball after all operations are performed.\n\nSample Input 1\n\n3 2\n1 2\n2 3\n\nSample Output 1\n\n2\n\nJust after the first operation, box 1 is empty, box 2 contains one red ball and one white ball, and box 3 contains one white ball.\n\nNow, consider the second operation. If Snuke picks the red ball from box 2, the red ball will go into box 3. If he picks the white ball instead, the red ball will stay in box 2.\nThus, the number of boxes that may contain the red ball after all operations, is 2.\n\nSample Input 2\n\n3 3\n1 2\n2 3\n2 3\n\nSample Output 2\n\n1\n\nAll balls will go into box 3.\n\nSample Input 3\n\n4 4\n1 2\n2 3\n4 1\n3 4\n\nSample Output 3\n\n3", "sample_input": "3 2\n1 2\n2 3\n"}, "reference_outputs": ["2\n"], "source_document_id": "p04034", "source_text": "Problem Statement\n\nWe have N boxes, numbered 1 through N. At first, box 1 contains one red ball, and each of the other boxes contains one white ball.\n\nSnuke will perform the following M operations, one by one. In the i-th operation, he randomly picks one ball from box x_i, then he puts it into box y_i.\n\nFind the number of boxes that may contain the red ball after all operations are performed.\n\nConstraints\n\n2≤N≤10^5\n\n1≤M≤10^5\n\n1≤x_i,y_i≤N\n\nx_i≠y_i\n\nJust before the i-th operation is performed, box x_i contains at least 1 ball.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN M\nx_1 y_1\n:\nx_M y_M\n\nOutput\n\nPrint the number of boxes that may contain the red ball after all operations are performed.\n\nSample Input 1\n\n3 2\n1 2\n2 3\n\nSample Output 1\n\n2\n\nJust after the first operation, box 1 is empty, box 2 contains one red ball and one white ball, and box 3 contains one white ball.\n\nNow, consider the second operation. If Snuke picks the red ball from box 2, the red ball will go into box 3. If he picks the white ball instead, the red ball will stay in box 2.\nThus, the number of boxes that may contain the red ball after all operations, is 2.\n\nSample Input 2\n\n3 3\n1 2\n2 3\n2 3\n\nSample Output 2\n\n1\n\nAll balls will go into box 3.\n\nSample Input 3\n\n4 4\n1 2\n2 3\n4 1\n3 4\n\nSample Output 3\n\n3", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 655, "cpu_time_ms": 117, "memory_kb": 10880}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s127963293", "group_id": "codeNet:p04035", "input_text": "let n, l = Scanf.scanf \"%d %d\\n\" (fun x y -> x, y)\n\nlet rec read_ints acc = function\n | 0 -> List.rev acc\n | k -> read_ints (Scanf.scanf \"%d \" (fun x -> x) :: acc) (k-1)\n\nlet al = read_ints [] n\n\nlet rec solve i k = function\n | [] | _ :: [] -> Some ([], [])\n | hd0 :: ((hd1 :: tl1) as tl0) -> if k < l then None else\n if hd0 + hd1 >= l then\n match solve (i+1) k (hd0 + hd1 :: tl1) with\n | None -> None\n | Some (x, y) -> Some (x, (i :: y))\n else\n match solve (i+1) (k-hd0) tl0 with\n | None -> None\n | Some (x, y) -> Some ((i :: x), y)\n\nlet sum = List.fold_left (+) 0 al\n\nlet () =\n match solve 1 sum al with\n | None -> print_endline \"Impossible\"\n | Some (x, y) -> print_endline \"Possible\"; let p = List.iter (fun x -> print_int x; print_newline ()) in p x; p (List.rev y)", "language": "OCaml", "metadata": {"date": 1470188163, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p04035.html", "problem_id": "p04035", "resource_group": "low_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/OCaml/s127963293.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s127963293", "user_id": "u367021138"}, "prompt_components": {"gold_output": "Possible\n2\n1\n", "input_to_evaluate": "let n, l = Scanf.scanf \"%d %d\\n\" (fun x y -> x, y)\n\nlet rec read_ints acc = function\n | 0 -> List.rev acc\n | k -> read_ints (Scanf.scanf \"%d \" (fun x -> x) :: acc) (k-1)\n\nlet al = read_ints [] n\n\nlet rec solve i k = function\n | [] | _ :: [] -> Some ([], [])\n | hd0 :: ((hd1 :: tl1) as tl0) -> if k < l then None else\n if hd0 + hd1 >= l then\n match solve (i+1) k (hd0 + hd1 :: tl1) with\n | None -> None\n | Some (x, y) -> Some (x, (i :: y))\n else\n match solve (i+1) (k-hd0) tl0 with\n | None -> None\n | Some (x, y) -> Some ((i :: x), y)\n\nlet sum = List.fold_left (+) 0 al\n\nlet () =\n match solve 1 sum al with\n | None -> print_endline \"Impossible\"\n | Some (x, y) -> print_endline \"Possible\"; let p = List.iter (fun x -> print_int x; print_newline ()) in p x; p (List.rev y)", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 820, "cpu_time_ms": 868, "memory_kb": 13184}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s636501620", "group_id": "codeNet:p04035", "input_text": "let n, l = Scanf.scanf \"%d %d\\n\" (fun x y -> x, y)\n\nlet rec read_ints acc = function\n | 0 -> List.rev acc\n | k -> read_ints (Scanf.scanf \"%d \" (fun x -> x) :: acc) (k-1)\n\nlet al = read_ints [] n\n\nlet rec solve i k = function\n | [] -> Some []\n | _ :: [] -> Some []\n | hd0 :: ((hd1 :: tl1) as tl0) -> if k < l then None else\n match solve (i+1) (k-hd0) tl0 with\n | Some x -> Some (i :: x)\n | None -> if hd0 + hd1 < l then None else\n match solve (i+1) k (hd0 + hd1 :: tl1) with\n | None -> None\n | Some x -> Some (List.rev (i :: (List.rev x)))\n\nlet sum = List.fold_left (+) 0 al\n\nlet () =\n match solve 1 sum al with\n | None -> print_endline \"Impossible\"\n | Some x -> print_endline \"Possible\"; List.iter (fun x -> print_int x; print_newline ()) x", "language": "OCaml", "metadata": {"date": 1470185054, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p04035.html", "problem_id": "p04035", "resource_group": "low_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/OCaml/s636501620.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Time Limit Exceeded", "submission_id": "s636501620", "user_id": "u367021138"}, "prompt_components": {"gold_output": "Possible\n2\n1\n", "input_to_evaluate": "let n, l = Scanf.scanf \"%d %d\\n\" (fun x y -> x, y)\n\nlet rec read_ints acc = function\n | 0 -> List.rev acc\n | k -> read_ints (Scanf.scanf \"%d \" (fun x -> x) :: acc) (k-1)\n\nlet al = read_ints [] n\n\nlet rec solve i k = function\n | [] -> Some []\n | _ :: [] -> Some []\n | hd0 :: ((hd1 :: tl1) as tl0) -> if k < l then None else\n match solve (i+1) (k-hd0) tl0 with\n | Some x -> Some (i :: x)\n | None -> if hd0 + hd1 < l then None else\n match solve (i+1) k (hd0 + hd1 :: tl1) with\n | None -> None\n | Some x -> Some (List.rev (i :: (List.rev x)))\n\nlet sum = List.fold_left (+) 0 al\n\nlet () =\n match solve 1 sum al with\n | None -> print_endline \"Impossible\"\n | Some x -> print_endline \"Possible\"; List.iter (fun x -> print_int x; print_newline ()) x", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 772, "cpu_time_ms": 2106, "memory_kb": 14976}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s997734117", "group_id": "codeNet:p04037", "input_text": "let n = Scanf.scanf \"%d\\n\" (fun x -> x)\n\nlet rec read_ints acc = function\n | 0 -> acc\n | k -> read_ints (Scanf.scanf \" %d\" (fun x -> x) :: acc) (k-1)\n\nlet al = List.sort (fun x y -> compare y x) (read_ints [] n)\n\nlet rec solve i k = function\n | [] -> true\n | hd :: tl -> if hd > i then solve (i+1) (hd - i) tl else k lor (i - hd) mod 2 = 1\n\nlet () = print_endline (if solve 1 0 al then \"First\" else \"Second\")", "language": "OCaml", "metadata": {"date": 1470264463, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p04037.html", "problem_id": "p04037", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p04037/input.txt", "sample_output_relpath": "derived/input_output/data/p04037/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p04037/OCaml/s997734117.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s997734117", "user_id": "u367021138"}, "prompt_components": {"gold_output": "First\n", "input_to_evaluate": "let n = Scanf.scanf \"%d\\n\" (fun x -> x)\n\nlet rec read_ints acc = function\n | 0 -> acc\n | k -> read_ints (Scanf.scanf \" %d\" (fun x -> x) :: acc) (k-1)\n\nlet al = List.sort (fun x y -> compare y x) (read_ints [] n)\n\nlet rec solve i k = function\n | [] -> true\n | hd :: tl -> if hd > i then solve (i+1) (hd - i) tl else k lor (i - hd) mod 2 = 1\n\nlet () = print_endline (if solve 1 0 al then \"First\" else \"Second\")", "problem_context": "Problem Statement\n\nThere are N piles of candies on the table. The piles are numbered 1 through N. At first, pile i contains a_i candies.\n\nSnuke and Ciel are playing a game. They take alternating turns. Snuke goes first. In each turn, the current player must perform one of the following two operations:\n\nChoose a pile with the largest number of candies remaining, then eat all candies of that pile.\n\nFrom each pile with one or more candies remaining, eat one candy.\n\nThe player who eats the last candy on the table, loses the game. Determine which player will win if both players play the game optimally.\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 Snuke will win, print First. If Ciel will win, print Second.\n\nSample Input 1\n\n2\n1 3\n\nSample Output 1\n\nFirst\n\nAt the beginning of the game, pile 2 contains the most candies. If Snuke eats all candies of this pile, Ciel has no choice but to eat the last candy.\n\nSample Input 2\n\n3\n1 2 1\n\nSample Output 2\n\nFirst\n\nIf Snuke eats one candy from each pile, Ciel is again left with the last candy.\n\nSample Input 3\n\n3\n1 2 3\n\nSample Output 3\n\nSecond", "sample_input": "2\n1 3\n"}, "reference_outputs": ["First\n"], "source_document_id": "p04037", "source_text": "Problem Statement\n\nThere are N piles of candies on the table. The piles are numbered 1 through N. At first, pile i contains a_i candies.\n\nSnuke and Ciel are playing a game. They take alternating turns. Snuke goes first. In each turn, the current player must perform one of the following two operations:\n\nChoose a pile with the largest number of candies remaining, then eat all candies of that pile.\n\nFrom each pile with one or more candies remaining, eat one candy.\n\nThe player who eats the last candy on the table, loses the game. Determine which player will win if both players play the game optimally.\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 Snuke will win, print First. If Ciel will win, print Second.\n\nSample Input 1\n\n2\n1 3\n\nSample Output 1\n\nFirst\n\nAt the beginning of the game, pile 2 contains the most candies. If Snuke eats all candies of this pile, Ciel has no choice but to eat the last candy.\n\nSample Input 2\n\n3\n1 2 1\n\nSample Output 2\n\nFirst\n\nIf Snuke eats one candy from each pile, Ciel is again left with the last candy.\n\nSample Input 3\n\n3\n1 2 3\n\nSample Output 3\n\nSecond", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 132, "memory_kb": 9344}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s563434388", "group_id": "codeNet:p04038", "input_text": "let modulo = 1000000007\n\nlet ( +% ) a b = let c = a + b in if c > modulo then c - modulo else c\nlet ( -% ) a b = if a >= b then a - b else modulo + a - b\nlet ( *% ) a b = a * b mod modulo\n\nlet pow k =\n let rec aux accu k = function\n | 0 -> accu\n | n when n mod 2 = 0 -> aux accu (k *% k) (n/2)\n | n -> aux (accu *% k) (k *% k) (n/2) in\n aux 1 k\n\nlet inv k = pow k (modulo-2)\n\nlet n, k = Scanf.scanf \"%d %d\" (fun x y -> x, y)\n\nlet () = if k = 1 then begin print_int 1; exit 0 end\n\nlet smax = n * k\nlet factbl = Array.make (smax+1) 1\nlet ifactbl = Array.make (smax+1) 0\nlet () = for i = 1 to smax do factbl.(i) <- factbl.(i-1) *% i done;\n ifactbl.(smax) <- inv factbl.(smax);\n for i = smax-1 downto 0 do ifactbl.(i) <- ifactbl.(i+1) *% (i+1) done\n\nlet binom n k = factbl.(n) *% ifactbl.(k) *% ifactbl.(n-k)\n\n\nlet dp = Array.make (n+1) 0\n\nlet () = dp.(0) <- 1;\n for i = 0 to n-1 do for j = i+1 to n do\n dp.(j) <- dp.(j) +% dp.(j-1) *% binom (i+j*(k-1)-1) (k-2) done done;\n print_int (factbl.(n) *% dp.(n))", "language": "OCaml", "metadata": {"date": 1470262384, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p04038.html", "problem_id": "p04038", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p04038/input.txt", "sample_output_relpath": "derived/input_output/data/p04038/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p04038/OCaml/s563434388.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s563434388", "user_id": "u367021138"}, "prompt_components": {"gold_output": "4\n", "input_to_evaluate": "let modulo = 1000000007\n\nlet ( +% ) a b = let c = a + b in if c > modulo then c - modulo else c\nlet ( -% ) a b = if a >= b then a - b else modulo + a - b\nlet ( *% ) a b = a * b mod modulo\n\nlet pow k =\n let rec aux accu k = function\n | 0 -> accu\n | n when n mod 2 = 0 -> aux accu (k *% k) (n/2)\n | n -> aux (accu *% k) (k *% k) (n/2) in\n aux 1 k\n\nlet inv k = pow k (modulo-2)\n\nlet n, k = Scanf.scanf \"%d %d\" (fun x y -> x, y)\n\nlet () = if k = 1 then begin print_int 1; exit 0 end\n\nlet smax = n * k\nlet factbl = Array.make (smax+1) 1\nlet ifactbl = Array.make (smax+1) 0\nlet () = for i = 1 to smax do factbl.(i) <- factbl.(i-1) *% i done;\n ifactbl.(smax) <- inv factbl.(smax);\n for i = smax-1 downto 0 do ifactbl.(i) <- ifactbl.(i+1) *% (i+1) done\n\nlet binom n k = factbl.(n) *% ifactbl.(k) *% ifactbl.(n-k)\n\n\nlet dp = Array.make (n+1) 0\n\nlet () = dp.(0) <- 1;\n for i = 0 to n-1 do for j = i+1 to n do\n dp.(j) <- dp.(j) +% dp.(j-1) *% binom (i+j*(k-1)-1) (k-2) done done;\n print_int (factbl.(n) *% dp.(n))", "problem_context": "Problem Statement\n\nSnuke loves colorful balls. He has a total of N×K balls, K in each of his favorite N colors. The colors are numbered 1 through N.\n\nHe will arrange all of the balls in a row from left to right, in arbitrary order. Then, for each of the N colors, he will paint the leftmost ball of that color into color 0, a color different from any of the N original colors.\n\nAfter painting, how many sequences of the colors of the balls are possible? Find this number modulo 10^9+7.\n\nConstraints\n\n1≤N,K≤2,000\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN K\n\nOutput\n\nPrint the number of the possible sequences of the colors of the balls after painting, modulo 10^9+7.\n\nSample Input 1\n\n2 2\n\nSample Output 1\n\n4\n\nThe following 4 sequences are possible:\n\n(0,1,0,2)\n\n(0,0,1,2)\n\n(0,2,0,1)\n\n(0,0,2,1)\n\nSample Input 2\n\n3 1\n\nSample Output 2\n\n1\n\nThe following 1 sequence is possible:\n\n(0,0,0)\n\nSample Input 3\n\n2 3\n\nSample Output 3\n\n14\n\nSample Input 4\n\n2000 2000\n\nSample Output 4\n\n546381702", "sample_input": "2 2\n"}, "reference_outputs": ["4\n"], "source_document_id": "p04038", "source_text": "Problem Statement\n\nSnuke loves colorful balls. He has a total of N×K balls, K in each of his favorite N colors. The colors are numbered 1 through N.\n\nHe will arrange all of the balls in a row from left to right, in arbitrary order. Then, for each of the N colors, he will paint the leftmost ball of that color into color 0, a color different from any of the N original colors.\n\nAfter painting, how many sequences of the colors of the balls are possible? Find this number modulo 10^9+7.\n\nConstraints\n\n1≤N,K≤2,000\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN K\n\nOutput\n\nPrint the number of the possible sequences of the colors of the balls after painting, modulo 10^9+7.\n\nSample Input 1\n\n2 2\n\nSample Output 1\n\n4\n\nThe following 4 sequences are possible:\n\n(0,1,0,2)\n\n(0,0,1,2)\n\n(0,2,0,1)\n\n(0,0,2,1)\n\nSample Input 2\n\n3 1\n\nSample Output 2\n\n1\n\nThe following 1 sequence is possible:\n\n(0,0,0)\n\nSample Input 3\n\n2 3\n\nSample Output 3\n\n14\n\nSample Input 4\n\n2000 2000\n\nSample Output 4\n\n546381702", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1049, "cpu_time_ms": 454, "memory_kb": 63608}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s638588242", "group_id": "codeNet:p04039", "input_text": "\n\nlet read_ints =\n let rec aux acc = function\n | 0 -> acc\n | n -> aux ((Scanf.scanf \"%d \" (fun x -> x)) :: acc) (n-1) in\n aux []\n\n\n\nlet decimal =\n let rec aux acc = function\n | 0 -> acc\n | n -> aux ((n mod 10)::acc) (n/10) in\n aux []\n\n\nlet pow k =\n let rec aux accu k = function\n | 0 -> accu\n | n when n mod 2 = 0 -> aux accu (k*k) (n/2)\n | n -> aux (accu*k) (k*k) (n/2) in\n aux 1 k\n\n\n\n\nlet () =\n let n, k = Scanf.scanf \"%d %d\\n\" (fun x y -> (x, y)) in\n let l = List.sort compare (read_ints k) in\n let dl = decimal n in\n let rec solver = function\n | [] -> Some 0\n | hd :: tl -> if List.mem hd l then (if hd = 9 then None else (solver ((hd+1):: tl))) else\n match (solver tl) with\n | None -> (if hd = 9 then None else (solver ((hd+1):: tl)))\n | Some x -> Some (hd * (pow 10 (List.length tl)) + x) in\n let rec solve = function\n | [] -> 0\n | hd :: tl -> if List.mem hd l then (if hd = 9 then (solve (1::0::tl)) else (solve ((hd+1):: tl))) else\n match (solver tl) with\n | None -> (if hd = 9 then (solve (1::0::tl)) else (solve ((hd+1):: tl)))\n | Some x -> hd * (pow 10 (List.length tl)) + x in\n print_int (solve dl)\n", "language": "OCaml", "metadata": {"date": 1469325158, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p04039.html", "problem_id": "p04039", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p04039/input.txt", "sample_output_relpath": "derived/input_output/data/p04039/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p04039/OCaml/s638588242.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s638588242", "user_id": "u367021138"}, "prompt_components": {"gold_output": "2000\n", "input_to_evaluate": "\n\nlet read_ints =\n let rec aux acc = function\n | 0 -> acc\n | n -> aux ((Scanf.scanf \"%d \" (fun x -> x)) :: acc) (n-1) in\n aux []\n\n\n\nlet decimal =\n let rec aux acc = function\n | 0 -> acc\n | n -> aux ((n mod 10)::acc) (n/10) in\n aux []\n\n\nlet pow k =\n let rec aux accu k = function\n | 0 -> accu\n | n when n mod 2 = 0 -> aux accu (k*k) (n/2)\n | n -> aux (accu*k) (k*k) (n/2) in\n aux 1 k\n\n\n\n\nlet () =\n let n, k = Scanf.scanf \"%d %d\\n\" (fun x y -> (x, y)) in\n let l = List.sort compare (read_ints k) in\n let dl = decimal n in\n let rec solver = function\n | [] -> Some 0\n | hd :: tl -> if List.mem hd l then (if hd = 9 then None else (solver ((hd+1):: tl))) else\n match (solver tl) with\n | None -> (if hd = 9 then None else (solver ((hd+1):: tl)))\n | Some x -> Some (hd * (pow 10 (List.length tl)) + x) in\n let rec solve = function\n | [] -> 0\n | hd :: tl -> if List.mem hd l then (if hd = 9 then (solve (1::0::tl)) else (solve ((hd+1):: tl))) else\n match (solver tl) with\n | None -> (if hd = 9 then (solve (1::0::tl)) else (solve ((hd+1):: tl)))\n | Some x -> hd * (pow 10 (List.length tl)) + x in\n print_int (solve dl)\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": "p04039", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1261, "cpu_time_ms": 2101, "memory_kb": 2748}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s249572390", "group_id": "codeNet:p04043", "input_text": "let () =\n\tlet a, b, c = Scanf.scanf \"%d %d %d\\n\" (fun a b c -> a,b,c) in\n Printf.printf\n \t(if \n (a=5 && b=5 && c=7) || (a=5 && b=7 && c=5) || (a=7 && b=5 && c=5)\n then \"YES\" else \"NO\")", "language": "OCaml", "metadata": {"date": 1581950103, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p04043.html", "problem_id": "p04043", "resource_group": "low_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/OCaml/s249572390.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s249572390", "user_id": "u307426615"}, "prompt_components": {"gold_output": "YES\n", "input_to_evaluate": "let () =\n\tlet a, b, c = Scanf.scanf \"%d %d %d\\n\" (fun a b c -> a,b,c) in\n Printf.printf\n \t(if \n (a=5 && b=5 && c=7) || (a=5 && b=7 && c=5) || (a=7 && b=5 && c=5)\n then \"YES\" else \"NO\")", "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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s703961488", "group_id": "codeNet:p04043", "input_text": "let () = Scanf.scanf \"%s\" (fun s -> s==\"5 7 5\")\n|> (fun b -> if b then \"YES\" else \"NO\")\n|> Printf.printf \"%s\\n\"", "language": "OCaml", "metadata": {"date": 1560914240, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p04043.html", "problem_id": "p04043", "resource_group": "low_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/OCaml/s703961488.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s703961488", "user_id": "u635974378"}, "prompt_components": {"gold_output": "YES\n", "input_to_evaluate": "let () = Scanf.scanf \"%s\" (fun s -> s==\"5 7 5\")\n|> (fun b -> if b then \"YES\" else \"NO\")\n|> Printf.printf \"%s\\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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 1, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s127158353", "group_id": "codeNet:p04043", "input_text": "let contains num num_list =\n let str = string_of_int num\n and chr_list = List.map (fun x -> (string_of_int x).[0]) num_list in\n List.fold_left (fun x y -> x || (String.contains str y)) false chr_list\n\nlet unfold f init =\n let rec unfold_inner f init ret =\n match f init with\n Some (a, b) -> unfold_inner f b (a::ret)\n | None -> ret\n in\n unfold_inner f init []\n\nlet make_list from to_ step =\n let accum x =\n if x > to_ then None else Some (x, x + step)\n in\n List.rev @@ unfold accum from\n\nlet solve n proh =\n let cand = make_list n (10*n) 1 in\n List.fold_left (fun x y -> if contains x proh then y else x) n cand\n\nlet read_list_of_int () =\n let rec read_list_of_int_inner lst =\n try let ans = (Scanf.scanf \"%d \" (fun x->x)) in\n read_list_of_int_inner (ans::lst)\n with End_of_file ->\n List.rev lst\n in\n read_list_of_int_inner []\n\nlet () =\n let n, k = Scanf.scanf \"%d %d\\n\" (fun x y -> x,y) in\n let list = read_list_of_int () in\n let ans = solve n list in\n Printf.printf \"%d\\n\" ans\n;;\n", "language": "OCaml", "metadata": {"date": 1473302357, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p04043.html", "problem_id": "p04043", "resource_group": "low_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/OCaml/s127158353.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Runtime Error", "submission_id": "s127158353", "user_id": "u980152513"}, "prompt_components": {"gold_output": "YES\n", "input_to_evaluate": "let contains num num_list =\n let str = string_of_int num\n and chr_list = List.map (fun x -> (string_of_int x).[0]) num_list in\n List.fold_left (fun x y -> x || (String.contains str y)) false chr_list\n\nlet unfold f init =\n let rec unfold_inner f init ret =\n match f init with\n Some (a, b) -> unfold_inner f b (a::ret)\n | None -> ret\n in\n unfold_inner f init []\n\nlet make_list from to_ step =\n let accum x =\n if x > to_ then None else Some (x, x + step)\n in\n List.rev @@ unfold accum from\n\nlet solve n proh =\n let cand = make_list n (10*n) 1 in\n List.fold_left (fun x y -> if contains x proh then y else x) n cand\n\nlet read_list_of_int () =\n let rec read_list_of_int_inner lst =\n try let ans = (Scanf.scanf \"%d \" (fun x->x)) in\n read_list_of_int_inner (ans::lst)\n with End_of_file ->\n List.rev lst\n in\n read_list_of_int_inner []\n\nlet () =\n let n, k = Scanf.scanf \"%d %d\\n\" (fun x y -> x,y) in\n let list = read_list_of_int () in\n let ans = solve n list in\n Printf.printf \"%d\\n\" ans\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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1039, "cpu_time_ms": 4, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s170444793", "group_id": "codeNet:p04045", "input_text": "let n, k = Scanf.scanf \"%d %d\\n\" (fun a b -> a, b)\nlet ds = Array.init k (fun _ -> Scanf.scanf \"%c \" (fun x -> x))\n\nlet rec solve p =\n if (Array.fold_left (fun pre c ->\n pre || String.contains (string_of_int p) c) false ds)\n then solve (p + 1)\n else p\n\nlet () = solve n |> Printf.printf \"%d\\n\"", "language": "OCaml", "metadata": {"date": 1523135726, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p04045.html", "problem_id": "p04045", "resource_group": "low_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/OCaml/s170444793.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s170444793", "user_id": "u987869509"}, "prompt_components": {"gold_output": "2000\n", "input_to_evaluate": "let n, k = Scanf.scanf \"%d %d\\n\" (fun a b -> a, b)\nlet ds = Array.init k (fun _ -> Scanf.scanf \"%c \" (fun x -> x))\n\nlet rec solve p =\n if (Array.fold_left (fun pre c ->\n pre || String.contains (string_of_int p) c) false ds)\n then solve (p + 1)\n else p\n\nlet () = solve n |> Printf.printf \"%d\\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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 37, "memory_kb": 2560}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s796029091", "group_id": "codeNet:p04045", "input_text": "module IntSet = Set.Make (struct type t = int let compare = compare end)\n\nlet rec tabulate n f = \n let rec loop acc m =\n if m < n then loop (f m :: acc) (m + 1)\n else List.rev acc in\n loop [] 0\n\nlet rec solve ds = function\n | 0 -> (0, false)\n | n ->\n let m, n = n mod 10, n / 10 in\n if IntSet.mem m ds then\n match solve ds n with\n | (n, false) -> (10 * n + m, false)\n | (n, true) -> (10 * n + IntSet.min_elt ds, true)\n else\n tabulate 10 (fun n -> n)\n |> List.filter (fun n -> IntSet.mem n ds && m < n)\n |> (function\n | [] -> (10 * fst (solve ds (n + 1)) + IntSet.min_elt ds, true)\n | m :: _ ->\n match solve ds n with\n | (n, false) -> (10 * n + m, true)\n | (n, true) -> (10 * n + IntSet.min_elt ds, true))\n\nlet () =\n let n, k = Scanf.scanf \"%d %d\\n\" (fun n k -> n, k) in\n let ds =\n IntSet.diff\n (IntSet.of_list (tabulate 10 (fun k -> k)))\n (IntSet.of_list (tabulate k (fun _ -> Scanf.scanf \"%d \" (fun d -> d)))) in\n Printf.printf \"%d\\n\" (fst (solve ds n))\n", "language": "OCaml", "metadata": {"date": 1469325142, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p04045.html", "problem_id": "p04045", "resource_group": "low_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/OCaml/s796029091.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s796029091", "user_id": "u504158101"}, "prompt_components": {"gold_output": "2000\n", "input_to_evaluate": "module IntSet = Set.Make (struct type t = int let compare = compare end)\n\nlet rec tabulate n f = \n let rec loop acc m =\n if m < n then loop (f m :: acc) (m + 1)\n else List.rev acc in\n loop [] 0\n\nlet rec solve ds = function\n | 0 -> (0, false)\n | n ->\n let m, n = n mod 10, n / 10 in\n if IntSet.mem m ds then\n match solve ds n with\n | (n, false) -> (10 * n + m, false)\n | (n, true) -> (10 * n + IntSet.min_elt ds, true)\n else\n tabulate 10 (fun n -> n)\n |> List.filter (fun n -> IntSet.mem n ds && m < n)\n |> (function\n | [] -> (10 * fst (solve ds (n + 1)) + IntSet.min_elt ds, true)\n | m :: _ ->\n match solve ds n with\n | (n, false) -> (10 * n + m, true)\n | (n, true) -> (10 * n + IntSet.min_elt ds, true))\n\nlet () =\n let n, k = Scanf.scanf \"%d %d\\n\" (fun n k -> n, k) in\n let ds =\n IntSet.diff\n (IntSet.of_list (tabulate 10 (fun k -> k)))\n (IntSet.of_list (tabulate k (fun _ -> Scanf.scanf \"%d \" (fun d -> d)))) in\n Printf.printf \"%d\\n\" (fst (solve ds n))\n", "problem_context": "Score : 300 points\n\nProblem Statement\n\nIroha is very particular about numbers. There are K digits that she dislikes: D_1, D_2, ..., D_K.\n\nShe is shopping, and now paying at the cashier.\nHer total is N yen (the currency of Japan), thus she has to hand at least N yen to the cashier (and possibly receive the change).\n\nHowever, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.\n\nFind the amount of money that she will hand to the cashier.\n\nConstraints\n\n1 ≦ N < 10000\n\n1 ≦ K < 10\n\n0 ≦ D_1 < D_2 < … < D_K≦9\n\n\\{D_1,D_2,...,D_K\\} ≠ \\{1,2,3,4,5,6,7,8,9\\}\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN K\nD_1 D_2 … D_K\n\nOutput\n\nPrint the amount of money that Iroha will hand to the cashier.\n\nSample Input 1\n\n1000 8\n1 3 4 5 6 7 8 9\n\nSample Output 1\n\n2000\n\nShe dislikes all digits except 0 and 2.\n\nThe smallest integer equal to or greater than N=1000 whose decimal notation contains only 0 and 2, is 2000.\n\nSample Input 2\n\n9999 1\n0\n\nSample Output 2\n\n9999", "sample_input": "1000 8\n1 3 4 5 6 7 8 9\n"}, "reference_outputs": ["2000\n"], "source_document_id": "p04045", "source_text": "Score : 300 points\n\nProblem Statement\n\nIroha is very particular about numbers. There are K digits that she dislikes: D_1, D_2, ..., D_K.\n\nShe is shopping, and now paying at the cashier.\nHer total is N yen (the currency of Japan), thus she has to hand at least N yen to the cashier (and possibly receive the change).\n\nHowever, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.\n\nFind the amount of money that she will hand to the cashier.\n\nConstraints\n\n1 ≦ N < 10000\n\n1 ≦ K < 10\n\n0 ≦ D_1 < D_2 < … < D_K≦9\n\n\\{D_1,D_2,...,D_K\\} ≠ \\{1,2,3,4,5,6,7,8,9\\}\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN K\nD_1 D_2 … D_K\n\nOutput\n\nPrint the amount of money that Iroha will hand to the cashier.\n\nSample Input 1\n\n1000 8\n1 3 4 5 6 7 8 9\n\nSample Output 1\n\n2000\n\nShe dislikes all digits except 0 and 2.\n\nThe smallest integer equal to or greater than N=1000 whose decimal notation contains only 0 and 2, is 2000.\n\nSample Input 2\n\n9999 1\n0\n\nSample Output 2\n\n9999", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1105, "cpu_time_ms": 4, "memory_kb": 384}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s448155552", "group_id": "codeNet:p04047", "input_text": "\nlet rec input n xs\n = if n = 0 then\n xs\n else\n let l = Scanf.scanf \"%d \" (fun l -> l) in\n input (n-1) (l :: xs)\n\nlet rec solve xs n res\n = if n <= 0 then\n Printf.printf \"%d\\n\" res\n else\n solve xs (n-2) (res + (List.nth xs (n-1)))\n\nlet _ =\n let n = Scanf.scanf \"%d \" (fun n -> 2 * n) in\n let xs = input n [] in\n let xs = List.sort compare xs in\n let l = (List.length xs) - 1 in\n solve xs l 0\n", "language": "OCaml", "metadata": {"date": 1493478009, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p04047.html", "problem_id": "p04047", "resource_group": "low_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/OCaml/s448155552.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s448155552", "user_id": "u733618878"}, "prompt_components": {"gold_output": "3\n", "input_to_evaluate": "\nlet rec input n xs\n = if n = 0 then\n xs\n else\n let l = Scanf.scanf \"%d \" (fun l -> l) in\n input (n-1) (l :: xs)\n\nlet rec solve xs n res\n = if n <= 0 then\n Printf.printf \"%d\\n\" res\n else\n solve xs (n-2) (res + (List.nth xs (n-1)))\n\nlet _ =\n let n = Scanf.scanf \"%d \" (fun n -> 2 * n) in\n let xs = input n [] in\n let xs = List.sort compare xs in\n let l = (List.length xs) - 1 in\n solve xs l 0\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": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 464, "cpu_time_ms": 1, "memory_kb": 512}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s815038618", "group_id": "codeNet:p04049", "input_text": "let () = Scanf.scanf \"%d %d\\n\" @@ fun n k ->\n let abs = Array.init (n - 1) @@ fun _ ->\n Scanf.scanf \"%d %d\\n\" @@ fun a b -> a, b in\n let es = Array.make n [] in\n Array.iter (fun (a, b) ->\n es.(a - 1) <- b - 1 :: es.(a - 1);\n es.(b - 1) <- a - 1 :: es.(b - 1)) abs;\n let d = Array.make_matrix n n min_int in\n for s = 0 to n - 1 do\n let rec dfs v =\n List.iter (fun u ->\n if d.(s).(u) < 0 then \n (d.(s).(u) <- 1 + d.(s).(v); dfs u)) es.(v) in\n d.(s).(s) <- 0; dfs s\n done;\n Printf.printf \"%d\\n\" @@ Array.fold_left min max_int @@\n if k mod 2 = 0 then\n Array.init n @@ fun v ->\n Array.fold_left (fun acc u ->\n acc + (if k / 2 < d.(u).(v) then 1 else 0)) 0 @@\n Array.init n @@ fun u -> u\n else\n Array.map (fun (a, b) ->\n Array.fold_left (fun acc u ->\n acc + (if k / 2 < min d.(a - 1).(u) d.(b - 1).(u) then 1 else 0)) 0 @@\n Array.init n @@ fun u -> u) abs\n", "language": "OCaml", "metadata": {"date": 1535951191, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p04049.html", "problem_id": "p04049", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p04049/input.txt", "sample_output_relpath": "derived/input_output/data/p04049/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p04049/OCaml/s815038618.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s815038618", "user_id": "u504158101"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "let () = Scanf.scanf \"%d %d\\n\" @@ fun n k ->\n let abs = Array.init (n - 1) @@ fun _ ->\n Scanf.scanf \"%d %d\\n\" @@ fun a b -> a, b in\n let es = Array.make n [] in\n Array.iter (fun (a, b) ->\n es.(a - 1) <- b - 1 :: es.(a - 1);\n es.(b - 1) <- a - 1 :: es.(b - 1)) abs;\n let d = Array.make_matrix n n min_int in\n for s = 0 to n - 1 do\n let rec dfs v =\n List.iter (fun u ->\n if d.(s).(u) < 0 then \n (d.(s).(u) <- 1 + d.(s).(v); dfs u)) es.(v) in\n d.(s).(s) <- 0; dfs s\n done;\n Printf.printf \"%d\\n\" @@ Array.fold_left min max_int @@\n if k mod 2 = 0 then\n Array.init n @@ fun v ->\n Array.fold_left (fun acc u ->\n acc + (if k / 2 < d.(u).(v) then 1 else 0)) 0 @@\n Array.init n @@ fun u -> u\n else\n Array.map (fun (a, b) ->\n Array.fold_left (fun acc u ->\n acc + (if k / 2 < min d.(a - 1).(u) d.(b - 1).(u) then 1 else 0)) 0 @@\n Array.init n @@ fun u -> u) abs\n", "problem_context": "Score : 600 points\n\nProblem Statement\n\nGiven an undirected tree, let the distance between vertices u and v be the\nnumber of edges on the simple path from u to v.\nThe diameter of a tree is the maximum among the distances between any two vertices.\nWe will call a tree good if and only if its diameter is at most K.\n\nYou are given an undirected tree with N vertices numbered 1 through N.\nFor each i (1≦i≦N-1), there is an edge connecting vertices A_i and B_i.\n\nYou want to remove zero or more vertices from the tree, so that the resulting tree is good.\nWhen a vertex is removed, all incident edges will also be removed.\nThe resulting graph must be connected.\n\nFind the minimum number of vertices that you need to remove in order to produce a good tree.\n\nConstraints\n\n2≦N≦2000\n\n1≦K≦N-1\n\n1≦A_i≦N, 1≦B_i≦N\n\nThe graph defined by A_i and B_i is a tree.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN K\nA_1 B_1\nA_2 B_2\n:\nA_{N-1} B_{N-1}\n\nOutput\n\nPrint the minimum number of vertices that you need to remove in order to produce a good tree.\n\nSample Input 1\n\n6 2\n1 2\n3 2\n4 2\n1 6\n5 6\n\nSample Output 1\n\n2\n\nThe tree is shown below. Removing vertices 5 and 6 will result in a good tree with the diameter of 2.\n\nSample Input 2\n\n6 5\n1 2\n3 2\n4 2\n1 6\n5 6\n\nSample Output 2\n\n0\n\nSince the given tree is already good, you do not need to remove any vertex.", "sample_input": "6 2\n1 2\n3 2\n4 2\n1 6\n5 6\n"}, "reference_outputs": ["2\n"], "source_document_id": "p04049", "source_text": "Score : 600 points\n\nProblem Statement\n\nGiven an undirected tree, let the distance between vertices u and v be the\nnumber of edges on the simple path from u to v.\nThe diameter of a tree is the maximum among the distances between any two vertices.\nWe will call a tree good if and only if its diameter is at most K.\n\nYou are given an undirected tree with N vertices numbered 1 through N.\nFor each i (1≦i≦N-1), there is an edge connecting vertices A_i and B_i.\n\nYou want to remove zero or more vertices from the tree, so that the resulting tree is good.\nWhen a vertex is removed, all incident edges will also be removed.\nThe resulting graph must be connected.\n\nFind the minimum number of vertices that you need to remove in order to produce a good tree.\n\nConstraints\n\n2≦N≦2000\n\n1≦K≦N-1\n\n1≦A_i≦N, 1≦B_i≦N\n\nThe graph defined by A_i and B_i is a tree.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN K\nA_1 B_1\nA_2 B_2\n:\nA_{N-1} B_{N-1}\n\nOutput\n\nPrint the minimum number of vertices that you need to remove in order to produce a good tree.\n\nSample Input 1\n\n6 2\n1 2\n3 2\n4 2\n1 6\n5 6\n\nSample Output 1\n\n2\n\nThe tree is shown below. Removing vertices 5 and 6 will result in a good tree with the diameter of 2.\n\nSample Input 2\n\n6 5\n1 2\n3 2\n4 2\n1 6\n5 6\n\nSample Output 2\n\n0\n\nSince the given tree is already good, you do not need to remove any vertex.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 935, "cpu_time_ms": 313, "memory_kb": 66112}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s582926125", "group_id": "codeNet:p04049", "input_text": "let () = Scanf.scanf \"%d %d\\n\" @@ fun n k ->\n let es = Array.make n [] in\n for i = 0 to n - 2 do\n Scanf.scanf \"%d %d\\n\" @@ fun a b ->\n es.(a - 1) <- b - 1 :: es.(a - 1);\n es.(b - 1) <- a - 1 :: es.(b - 1);\n done;\n let d = Array.make_matrix n n min_int in\n for s = 0 to n - 1 do\n let rec dfs v =\n List.iter (fun u ->\n if d.(s).(u) < 0 then \n (d.(s).(u) <- 1 + d.(s).(v); dfs u)) es.(v) in\n d.(s).(s) <- 0; dfs s\n done;\n Printf.printf \"%d\\n\" @@ ( - ) n @@ Array.fold_left max min_int @@ Array.init n @@ fun u ->\n let (_, vs, ws) = Array.fold_left (fun (v, vs, ws) d ->\n (v + 1),\n (if k <> d then vs else v :: vs),\n (if k < d then ws else v :: ws)) (0, [], []) d.(u) in\n if\n List.exists (fun v ->\n List.exists (fun w ->\n k < d.(v).(w)) ws) vs\n then min_int\n else List.length ws\n", "language": "OCaml", "metadata": {"date": 1535950303, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p04049.html", "problem_id": "p04049", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p04049/input.txt", "sample_output_relpath": "derived/input_output/data/p04049/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p04049/OCaml/s582926125.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s582926125", "user_id": "u504158101"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "let () = Scanf.scanf \"%d %d\\n\" @@ fun n k ->\n let es = Array.make n [] in\n for i = 0 to n - 2 do\n Scanf.scanf \"%d %d\\n\" @@ fun a b ->\n es.(a - 1) <- b - 1 :: es.(a - 1);\n es.(b - 1) <- a - 1 :: es.(b - 1);\n done;\n let d = Array.make_matrix n n min_int in\n for s = 0 to n - 1 do\n let rec dfs v =\n List.iter (fun u ->\n if d.(s).(u) < 0 then \n (d.(s).(u) <- 1 + d.(s).(v); dfs u)) es.(v) in\n d.(s).(s) <- 0; dfs s\n done;\n Printf.printf \"%d\\n\" @@ ( - ) n @@ Array.fold_left max min_int @@ Array.init n @@ fun u ->\n let (_, vs, ws) = Array.fold_left (fun (v, vs, ws) d ->\n (v + 1),\n (if k <> d then vs else v :: vs),\n (if k < d then ws else v :: ws)) (0, [], []) d.(u) in\n if\n List.exists (fun v ->\n List.exists (fun w ->\n k < d.(v).(w)) ws) vs\n then min_int\n else List.length ws\n", "problem_context": "Score : 600 points\n\nProblem Statement\n\nGiven an undirected tree, let the distance between vertices u and v be the\nnumber of edges on the simple path from u to v.\nThe diameter of a tree is the maximum among the distances between any two vertices.\nWe will call a tree good if and only if its diameter is at most K.\n\nYou are given an undirected tree with N vertices numbered 1 through N.\nFor each i (1≦i≦N-1), there is an edge connecting vertices A_i and B_i.\n\nYou want to remove zero or more vertices from the tree, so that the resulting tree is good.\nWhen a vertex is removed, all incident edges will also be removed.\nThe resulting graph must be connected.\n\nFind the minimum number of vertices that you need to remove in order to produce a good tree.\n\nConstraints\n\n2≦N≦2000\n\n1≦K≦N-1\n\n1≦A_i≦N, 1≦B_i≦N\n\nThe graph defined by A_i and B_i is a tree.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN K\nA_1 B_1\nA_2 B_2\n:\nA_{N-1} B_{N-1}\n\nOutput\n\nPrint the minimum number of vertices that you need to remove in order to produce a good tree.\n\nSample Input 1\n\n6 2\n1 2\n3 2\n4 2\n1 6\n5 6\n\nSample Output 1\n\n2\n\nThe tree is shown below. Removing vertices 5 and 6 will result in a good tree with the diameter of 2.\n\nSample Input 2\n\n6 5\n1 2\n3 2\n4 2\n1 6\n5 6\n\nSample Output 2\n\n0\n\nSince the given tree is already good, you do not need to remove any vertex.", "sample_input": "6 2\n1 2\n3 2\n4 2\n1 6\n5 6\n"}, "reference_outputs": ["2\n"], "source_document_id": "p04049", "source_text": "Score : 600 points\n\nProblem Statement\n\nGiven an undirected tree, let the distance between vertices u and v be the\nnumber of edges on the simple path from u to v.\nThe diameter of a tree is the maximum among the distances between any two vertices.\nWe will call a tree good if and only if its diameter is at most K.\n\nYou are given an undirected tree with N vertices numbered 1 through N.\nFor each i (1≦i≦N-1), there is an edge connecting vertices A_i and B_i.\n\nYou want to remove zero or more vertices from the tree, so that the resulting tree is good.\nWhen a vertex is removed, all incident edges will also be removed.\nThe resulting graph must be connected.\n\nFind the minimum number of vertices that you need to remove in order to produce a good tree.\n\nConstraints\n\n2≦N≦2000\n\n1≦K≦N-1\n\n1≦A_i≦N, 1≦B_i≦N\n\nThe graph defined by A_i and B_i is a tree.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN K\nA_1 B_1\nA_2 B_2\n:\nA_{N-1} B_{N-1}\n\nOutput\n\nPrint the minimum number of vertices that you need to remove in order to produce a good tree.\n\nSample Input 1\n\n6 2\n1 2\n3 2\n4 2\n1 6\n5 6\n\nSample Output 1\n\n2\n\nThe tree is shown below. Removing vertices 5 and 6 will result in a good tree with the diameter of 2.\n\nSample Input 2\n\n6 5\n1 2\n3 2\n4 2\n1 6\n5 6\n\nSample Output 2\n\n0\n\nSince the given tree is already good, you do not need to remove any vertex.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 871, "cpu_time_ms": 2105, "memory_kb": 41408}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s100815250", "group_id": "codeNet:p04049", "input_text": "let (n, k) = Scanf.scanf \"%d %d\\n\" (fun n k -> (n, k))\n\nlet repeat f =\n let rec loop acc = function\n | 0 -> List.rev acc\n | n -> loop (f () :: acc) (n - 1) in\n loop []\n\nlet edges = repeat (fun () -> Scanf.scanf \"%d %d\\n\" (fun a b -> (a-1, b-1))) (n-1)\n\nlet al = Array.make n []\n\nlet maxarea r =\n let rec area i j = function\n | 0 -> 1\n | r -> List.fold_left (fun a k -> a + (if k = i then 0 else area j k (r-1))) 1 al.(j) in\n let rec aux accu = function\n | 0 -> accu\n | k -> aux (max (area (k-1) (k-1) (r/2)) accu) (k-1) in\n if r mod 2 = 0 then aux 0 n\n else List.fold_left (fun a (i,j) -> max a ((area i j (r/2)) + (area j i (r/2)))) 0 edges\n\nlet () =\n List.iter (fun (a,b) -> al.(a) <- b :: al.(a); al.(b) <- a :: al.(b)) edges;\n print_int (n-(maxarea k))", "language": "OCaml", "metadata": {"date": 1468780351, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p04049.html", "problem_id": "p04049", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p04049/input.txt", "sample_output_relpath": "derived/input_output/data/p04049/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p04049/OCaml/s100815250.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Accepted", "submission_id": "s100815250", "user_id": "u367021138"}, "prompt_components": {"gold_output": "2\n", "input_to_evaluate": "let (n, k) = Scanf.scanf \"%d %d\\n\" (fun n k -> (n, k))\n\nlet repeat f =\n let rec loop acc = function\n | 0 -> List.rev acc\n | n -> loop (f () :: acc) (n - 1) in\n loop []\n\nlet edges = repeat (fun () -> Scanf.scanf \"%d %d\\n\" (fun a b -> (a-1, b-1))) (n-1)\n\nlet al = Array.make n []\n\nlet maxarea r =\n let rec area i j = function\n | 0 -> 1\n | r -> List.fold_left (fun a k -> a + (if k = i then 0 else area j k (r-1))) 1 al.(j) in\n let rec aux accu = function\n | 0 -> accu\n | k -> aux (max (area (k-1) (k-1) (r/2)) accu) (k-1) in\n if r mod 2 = 0 then aux 0 n\n else List.fold_left (fun a (i,j) -> max a ((area i j (r/2)) + (area j i (r/2)))) 0 edges\n\nlet () =\n List.iter (fun (a,b) -> al.(a) <- b :: al.(a); al.(b) <- a :: al.(b)) edges;\n print_int (n-(maxarea k))", "problem_context": "Score : 600 points\n\nProblem Statement\n\nGiven an undirected tree, let the distance between vertices u and v be the\nnumber of edges on the simple path from u to v.\nThe diameter of a tree is the maximum among the distances between any two vertices.\nWe will call a tree good if and only if its diameter is at most K.\n\nYou are given an undirected tree with N vertices numbered 1 through N.\nFor each i (1≦i≦N-1), there is an edge connecting vertices A_i and B_i.\n\nYou want to remove zero or more vertices from the tree, so that the resulting tree is good.\nWhen a vertex is removed, all incident edges will also be removed.\nThe resulting graph must be connected.\n\nFind the minimum number of vertices that you need to remove in order to produce a good tree.\n\nConstraints\n\n2≦N≦2000\n\n1≦K≦N-1\n\n1≦A_i≦N, 1≦B_i≦N\n\nThe graph defined by A_i and B_i is a tree.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN K\nA_1 B_1\nA_2 B_2\n:\nA_{N-1} B_{N-1}\n\nOutput\n\nPrint the minimum number of vertices that you need to remove in order to produce a good tree.\n\nSample Input 1\n\n6 2\n1 2\n3 2\n4 2\n1 6\n5 6\n\nSample Output 1\n\n2\n\nThe tree is shown below. Removing vertices 5 and 6 will result in a good tree with the diameter of 2.\n\nSample Input 2\n\n6 5\n1 2\n3 2\n4 2\n1 6\n5 6\n\nSample Output 2\n\n0\n\nSince the given tree is already good, you do not need to remove any vertex.", "sample_input": "6 2\n1 2\n3 2\n4 2\n1 6\n5 6\n"}, "reference_outputs": ["2\n"], "source_document_id": "p04049", "source_text": "Score : 600 points\n\nProblem Statement\n\nGiven an undirected tree, let the distance between vertices u and v be the\nnumber of edges on the simple path from u to v.\nThe diameter of a tree is the maximum among the distances between any two vertices.\nWe will call a tree good if and only if its diameter is at most K.\n\nYou are given an undirected tree with N vertices numbered 1 through N.\nFor each i (1≦i≦N-1), there is an edge connecting vertices A_i and B_i.\n\nYou want to remove zero or more vertices from the tree, so that the resulting tree is good.\nWhen a vertex is removed, all incident edges will also be removed.\nThe resulting graph must be connected.\n\nFind the minimum number of vertices that you need to remove in order to produce a good tree.\n\nConstraints\n\n2≦N≦2000\n\n1≦K≦N-1\n\n1≦A_i≦N, 1≦B_i≦N\n\nThe graph defined by A_i and B_i is a tree.\n\nInput\n\nThe input is given from Standard Input in the following format:\n\nN K\nA_1 B_1\nA_2 B_2\n:\nA_{N-1} B_{N-1}\n\nOutput\n\nPrint the minimum number of vertices that you need to remove in order to produce a good tree.\n\nSample Input 1\n\n6 2\n1 2\n3 2\n4 2\n1 6\n5 6\n\nSample Output 1\n\n2\n\nThe tree is shown below. Removing vertices 5 and 6 will result in a good tree with the diameter of 2.\n\nSample Input 2\n\n6 5\n1 2\n3 2\n4 2\n1 6\n5 6\n\nSample Output 2\n\n0\n\nSince the given tree is already good, you do not need to remove any vertex.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported 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": 104, "memory_kb": 3840}, "variant": "low_resource"} {"dataset": "codeNet", "domain": "code_generation", "example_id": "codeNet:OCaml:s702339579", "group_id": "codeNet:p04051", "input_text": "let id x = x\n\nlet s = 1000000007\n\nlet repeat f =\n let rec aux accu = function\n | 0 -> accu\n | n -> aux (f () :: accu) (n - 1) in\n aux []\n\nlet pow k =\n let rec aux accu k = function\n | 0 -> accu\n | n when n mod 2 == 0 -> aux accu (k*k mod s) (n/2)\n | n -> aux (accu*k mod s) (k*k mod s) (n/2) in\n aux 1 k\n\nlet inv k = pow k (s-2)\n\nlet rec bc n = function 0 -> 1 | k -> ((bc (n-1) (k-1))*(n*inv(k) mod s) mod s)\n\nlet () =\n let n = Scanf.scanf \"%d\\n\" id in\n let l = repeat (fun () -> Scanf.scanf \"%d %d\\n\" (fun a b -> (a,b))) n in\n let (maxa, maxb) = List.fold_left (fun (c,d) (a,b) -> (max a c, max d b)) (0, 0) l in\n let sal = List.sort (fun (a,b) (c,d) -> compare c a) l in\n let dp = Array.make (1 + 2 * maxb) 0 in\n let solve =\n let rec auxr sl accu m =\n match sl with\n | [] -> accu\n | (a, b) :: tl when a = m-maxa -> auxr tl ((accu+dp.(b+maxb)) mod s) m\n | _ -> Array.iteri (fun i x -> dp.(i) <- (x + if i > 0 then dp.(i-1) else 0) mod s) dp; auxr sl accu (m+1) in\n let rec auxl sl m =\n if m > maxa then (Array.iteri (fun i x -> dp.(i) <- (x + if i > 0 then dp.(i-1) else 0) mod s) dp; auxr (List.rev sal) 0 m)\n else match sl with\n | (a, b) :: tl when a = maxa-m -> dp.(maxb-b) <- (dp.(maxb-b) +1) mod s; auxl tl m\n | _ -> Array.iteri (fun i x -> dp.(i) <- (x + if i > 0 then dp.(i-1) else 0) mod s) dp; auxl sl (m+1) in\n auxl sal 0 in\n let x = List.fold_left (fun x (a,b) -> (x + bc (2*a+2*b) (2*a)) mod s) 0 l in\n if solve < x then print_int ((s+solve - x)/2) else print_int ((solve-x)/2);", "language": "OCaml", "metadata": {"date": 1468822064, "filename_ext": "ml", "original_language": "OCaml (4.02.3)", "problem_description_relpath": "problem_descriptions/p04051.html", "problem_id": "p04051", "resource_group": "low_resource", "sample_input_relpath": "derived/input_output/data/p04051/input.txt", "sample_output_relpath": "derived/input_output/data/p04051/output.txt", "source_dataset": "Project CodeNet", "source_relpath": "data/p04051/OCaml/s702339579.ml", "split_policy": "Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.", "status": "Wrong Answer", "submission_id": "s702339579", "user_id": "u367021138"}, "prompt_components": {"gold_output": "26\n", "input_to_evaluate": "let id x = x\n\nlet s = 1000000007\n\nlet repeat f =\n let rec aux accu = function\n | 0 -> accu\n | n -> aux (f () :: accu) (n - 1) in\n aux []\n\nlet pow k =\n let rec aux accu k = function\n | 0 -> accu\n | n when n mod 2 == 0 -> aux accu (k*k mod s) (n/2)\n | n -> aux (accu*k mod s) (k*k mod s) (n/2) in\n aux 1 k\n\nlet inv k = pow k (s-2)\n\nlet rec bc n = function 0 -> 1 | k -> ((bc (n-1) (k-1))*(n*inv(k) mod s) mod s)\n\nlet () =\n let n = Scanf.scanf \"%d\\n\" id in\n let l = repeat (fun () -> Scanf.scanf \"%d %d\\n\" (fun a b -> (a,b))) n in\n let (maxa, maxb) = List.fold_left (fun (c,d) (a,b) -> (max a c, max d b)) (0, 0) l in\n let sal = List.sort (fun (a,b) (c,d) -> compare c a) l in\n let dp = Array.make (1 + 2 * maxb) 0 in\n let solve =\n let rec auxr sl accu m =\n match sl with\n | [] -> accu\n | (a, b) :: tl when a = m-maxa -> auxr tl ((accu+dp.(b+maxb)) mod s) m\n | _ -> Array.iteri (fun i x -> dp.(i) <- (x + if i > 0 then dp.(i-1) else 0) mod s) dp; auxr sl accu (m+1) in\n let rec auxl sl m =\n if m > maxa then (Array.iteri (fun i x -> dp.(i) <- (x + if i > 0 then dp.(i-1) else 0) mod s) dp; auxr (List.rev sal) 0 m)\n else match sl with\n | (a, b) :: tl when a = maxa-m -> dp.(maxb-b) <- (dp.(maxb-b) +1) mod s; auxl tl m\n | _ -> Array.iteri (fun i x -> dp.(i) <- (x + if i > 0 then dp.(i-1) else 0) mod s) dp; auxl sl (m+1) in\n auxl sal 0 in\n let x = List.fold_left (fun x (a,b) -> (x + bc (2*a+2*b) (2*a)) mod s) 0 l in\n if solve < x then print_int ((s+solve - x)/2) else print_int ((solve-x)/2);", "problem_context": "Score : 1400 points\n\nProblem Statement\n\nSnuke is having another barbeque party.\n\nThis time, he will make one serving of Skewer Meal.\n\nHe has a stock of N Skewer Meal Packs. The i-th Skewer Meal Pack contains one skewer, A_i pieces of beef and B_i pieces of green pepper.\nAll skewers in these packs are different and distinguishable, while all pieces of beef and all pieces of green pepper are, respectively, indistinguishable.\n\nTo make a Skewer Meal, he chooses two of his Skewer Meal Packs, and takes out all of the contents from the chosen packs, that is, two skewers and some pieces of beef or green pepper.\n(Remaining Skewer Meal Packs will not be used.)\nThen, all those pieces of food are threaded onto both skewers, one by one, in any order.\n\n(See the image in the Sample section for better understanding.)\n\nIn how many different ways can he make a Skewer Meal? Two ways of making a Skewer Meal is different if and only if the sets of the used skewers are different, or the orders of the pieces of food are different.\nSince this number can be extremely large, find it modulo 10^9+7.\n\nConstraints\n\n2≦N≦200,000\n\n1≦A_i≦2000, 1≦B_i≦2000\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 B_N\n\nOutput\n\nPrint the number of the different ways Snuke can make a serving of Skewer Meal, modulo 10^9+7.\n\nSample Input 1\n\n3\n1 1\n1 1\n2 1\n\nSample Output 1\n\n26\n\nThe 26 ways of making a Skewer Meal are shown below.\nGray bars represent skewers, each with a number denoting the Skewer Meal Set that contained the skewer.\nBrown and green rectangles represent pieces of beef and green pepper, respectively.", "sample_input": "3\n1 1\n1 1\n2 1\n"}, "reference_outputs": ["26\n"], "source_document_id": "p04051", "source_text": "Score : 1400 points\n\nProblem Statement\n\nSnuke is having another barbeque party.\n\nThis time, he will make one serving of Skewer Meal.\n\nHe has a stock of N Skewer Meal Packs. The i-th Skewer Meal Pack contains one skewer, A_i pieces of beef and B_i pieces of green pepper.\nAll skewers in these packs are different and distinguishable, while all pieces of beef and all pieces of green pepper are, respectively, indistinguishable.\n\nTo make a Skewer Meal, he chooses two of his Skewer Meal Packs, and takes out all of the contents from the chosen packs, that is, two skewers and some pieces of beef or green pepper.\n(Remaining Skewer Meal Packs will not be used.)\nThen, all those pieces of food are threaded onto both skewers, one by one, in any order.\n\n(See the image in the Sample section for better understanding.)\n\nIn how many different ways can he make a Skewer Meal? Two ways of making a Skewer Meal is different if and only if the sets of the used skewers are different, or the orders of the pieces of food are different.\nSince this number can be extremely large, find it modulo 10^9+7.\n\nConstraints\n\n2≦N≦200,000\n\n1≦A_i≦2000, 1≦B_i≦2000\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 B_N\n\nOutput\n\nPrint the number of the different ways Snuke can make a serving of Skewer Meal, modulo 10^9+7.\n\nSample Input 1\n\n3\n1 1\n1 1\n2 1\n\nSample Output 1\n\n26\n\nThe 26 ways of making a Skewer Meal are shown below.\nGray bars represent skewers, each with a number denoting the Skewer Meal Set that contained the skewer.\nBrown and green rectangles represent pieces of beef and green pepper, respectively.", "split": "train", "target_descriptions": {"code_size_bytes": "Submitted source-code file size, in bytes.", "cpu_time_ms": "Execution CPU time reported by official Project CodeNet metadata, in milliseconds.", "memory_kb": "Peak memory usage reported by official Project CodeNet metadata, in kilobytes."}, "targets": {"code_size_bytes": 1580, "cpu_time_ms": 2110, "memory_kb": 31872}, "variant": "low_resource"}