{"source_code": "\nmodule Prelude = struct\n let scanf = Scanf.scanf\n let printf = Printf.printf\n\n module Int = struct\n type t = int\n let compare = compare\n end\nend\n\nopen Prelude\n\nmodule IntSet = Set.Make(Int)\n\nlet gen_prime_t = Array.create 100000 0\nlet gen_prime (upto: int): int array =\n let rec f (n: int) (s: int): int =\n if n > upto\n then s\n else\n let rec is_prime i =\n if i >= s then true\n else\n let t = Array.get gen_prime_t i in\n if t > n / 2 then true\n else if n mod t = 0 then false\n else is_prime (i + 1)\n in f (n + 2) (if is_prime 0 then (Array.set gen_prime_t s n; s + 1) else s)\n in\n Array.set gen_prime_t 0 2;\n let l = f 3 1 in Array.sub gen_prime_t 0 l\n\nmodule PrimeFactors = struct\n type item = { factor: int; count: int; }\n type t = item list\n\n let to_string (src: t) =\n src |>\n List.map (fun { factor; count } -> Printf.sprintf \"(%d * %d)\" count factor) |>\n String.concat \" \"\n\n let get_all_factors (src: t): int list =\n let rec outer (n: int) (src: item list) (ret: int list): int list =\n match src with\n | [] -> n :: ret\n | item :: items ->\n let rec inner (i: int) (n: int) (ret: int list): int list =\n if i > item.count\n then ret\n else\n let ret = outer n items ret in\n inner (i + 1) (n * item.factor) ret\n in inner 0 n ret\n in outer 1 src []\n\nend\n\nlet factorize (primes: int array) (src: int64): PrimeFactors.t =\n let rec f (cur: int64) (i: int) (ret: PrimeFactors.t) =\n if i >= Array.length primes then ret else\n let rec g (cur: int64) (n: int): int64 * int = Int64.(\n let t = Array.get primes i in\n if (rem cur (of_int t)) = zero\n then g (div cur (of_int t)) (n + 1)\n else (cur, n)\n ) in\n let cur, t = g cur 0 in\n let ret = if t = 0 then ret else { factor = Array.get primes i; count = t } :: ret in\n f cur (i + 1) ret\n in f src 0 []\n\n (* NOTE: we don't need the second extra check, the rem will do it ... *)\n (* if lhs > rhs then gcd rhs Int64.(rem lhs rhs) *)\nlet rec gcd (lhs: int64) (rhs: int64): int64 =\n Int64.(if rhs = zero then lhs else gcd rhs (rem lhs rhs))\n\nlet _ =\n (* let primes = gen_prime 100000 in *)\n (* printf \"gen complete\\n\";\n * let factors = factorize primes (Int64.of_int 720720) in\n * PrimeFactors.get_all_factors factors |> List.iter (printf \"%d\\n\")\n * printf \"%s\\n\" (factorize primes (Int64.of_int 8400) |> PrimeFactors.to_string) *)\n let n, k, a, b = scanf \"%d %d %d %d\" (fun a b c d -> a, b, c, d) in Int64.(\n let n, k, a, b = of_int n, of_int k, of_int a, of_int b in\n let total = (mul n k) in\n let do_try (posb: int64) (maxv, minv): int64 * int64 =\n let time = (div total (gcd total (sub posb a))) in (* let l = (sub posb a) in let actual_l = gcd total l in *)\n ((if time > maxv then time else maxv), (if time < minv then time else minv))\n in\n let rec test_cycle (posb: int64) (maxv, minv): int64 * int64 =\n if posb > (add total a)\n then (maxv, minv)\n else test_cycle (add posb k) (do_try posb (maxv, minv))\n in\n let tu = (Int64.min_int, Int64.max_int) in\n let tu = tu |> test_cycle (add k b) |> test_cycle (sub k b) in\n let (maxv, minv) = tu in\n printf \"%Ld %Ld\\n\" minv maxv)\n (* let factors = PrimeFactors.get_all_factors (factorize primes total) in\n * let rec f (factors: int list) (maxv: int64) (minv: int64): int64 * int64 =\n * match factors with\n * | [] -> maxv, minv\n * | l :: factors ->\n * let dist2 = (rem (add (of_int a) (of_int l)) (of_int k)) in\n * if (dist2 = (of_int b)) || (dist2 = (of_int (k - b)))\n * then\n * let time = (div total (of_int l)) in\n * let maxv = if Int64.compare time maxv > 0 then time else maxv in\n * let minv = if Int64.compare time minv < 0 then time else minv in\n * f factors maxv minv\n * else f factors maxv minv\n * in\n * let maxv, minv = f factors min_int max_int in *)\n", "positive_code": [{"source_code": "\nmodule Prelude = struct\n let scanf = Scanf.scanf\n let printf = Printf.printf\n\n module Int = struct\n type t = int\n let compare = compare\n end\nend\n\nopen Prelude\n\nmodule IntSet = Set.Make(Int)\n\nlet gen_prime_t = Array.create 100000 0\nlet gen_prime (upto: int): int array =\n let rec f (n: int) (s: int): int =\n if n > upto\n then s\n else\n let rec is_prime i =\n if i >= s then true\n else\n let t = Array.get gen_prime_t i in\n if t > n / 2 then true\n else if n mod t = 0 then false\n else is_prime (i + 1)\n in f (n + 2) (if is_prime 0 then (Array.set gen_prime_t s n; s + 1) else s)\n in\n Array.set gen_prime_t 0 2;\n let l = f 3 1 in Array.sub gen_prime_t 0 l\n\nmodule PrimeFactors = struct\n type item = { factor: int; count: int; }\n type t = item list\n\n let to_string (src: t) =\n src |>\n List.map (fun { factor; count } -> Printf.sprintf \"(%d * %d)\" count factor) |>\n String.concat \" \"\n\n let get_all_factors (src: t): int list =\n let rec outer (n: int) (src: item list) (ret: int list): int list =\n match src with\n | [] -> n :: ret\n | item :: items ->\n let rec inner (i: int) (n: int) (ret: int list): int list =\n if i > item.count\n then ret\n else\n let ret = outer n items ret in\n inner (i + 1) (n * item.factor) ret\n in inner 0 n ret\n in outer 1 src []\n\nend\n\nlet factorize (primes: int array) (src: int64): PrimeFactors.t =\n let rec f (cur: int64) (i: int) (ret: PrimeFactors.t) =\n if i >= Array.length primes then ret else\n let rec g (cur: int64) (n: int): int64 * int = Int64.(\n let t = Array.get primes i in\n if (rem cur (of_int t)) = zero\n then g (div cur (of_int t)) (n + 1)\n else (cur, n)\n ) in\n let cur, t = g cur 0 in\n let ret = if t = 0 then ret else { factor = Array.get primes i; count = t } :: ret in\n f cur (i + 1) ret\n in f src 0 []\n\nlet rec gcd (lhs: int64) (rhs: int64): int64 =\n if rhs = Int64.zero\n then lhs\n (* NOTE: we don't need the second extra check, the rem will do it ... *)\n (* if lhs > rhs then gcd rhs Int64.(rem lhs rhs) *)\n else gcd rhs Int64.(rem lhs rhs)\n\nlet _ =\n (* let primes = gen_prime 100000 in *)\n (* printf \"gen complete\\n\";\n * let factors = factorize primes (Int64.of_int 720720) in\n * PrimeFactors.get_all_factors factors |> List.iter (printf \"%d\\n\")\n * printf \"%s\\n\" (factorize primes (Int64.of_int 8400) |> PrimeFactors.to_string) *)\n let n, k, a, b = scanf \"%d %d %d %d\" (fun a b c d -> a, b, c, d) in Int64.(\n let total = (mul (of_int n) (of_int k)) in\n let do_try (posb: int64) (maxv, minv): int64 * int64 =\n let time =\n let l = (sub posb (of_int a)) in\n let actual_l = gcd total l in\n (div total actual_l)\n in\n let maxv = if Int64.compare time maxv > 0 then time else maxv in\n let minv = if Int64.compare time minv < 0 then time else minv in\n (maxv, minv)\n in\n let rec test_cycle (posb: int64) (maxv, minv): int64 * int64 =\n if posb > (add total (of_int a))\n then (maxv, minv)\n else let tu = do_try posb (maxv, minv) in test_cycle (add posb (of_int k)) tu\n in\n let tu = (Int64.min_int, Int64.max_int) in\n let tu = test_cycle (sub (of_int k) (of_int b)) tu in\n let tu = test_cycle (add (of_int k) (of_int b)) tu in\n let (maxv, minv) = tu in\n printf \"%Ld %Ld\\n\" minv maxv)\n (* let factors = PrimeFactors.get_all_factors (factorize primes total) in\n * let rec f (factors: int list) (maxv: int64) (minv: int64): int64 * int64 =\n * match factors with\n * | [] -> maxv, minv\n * | l :: factors ->\n * let dist2 = (rem (add (of_int a) (of_int l)) (of_int k)) in\n * if (dist2 = (of_int b)) || (dist2 = (of_int (k - b)))\n * then\n * let time = (div total (of_int l)) in\n * let maxv = if Int64.compare time maxv > 0 then time else maxv in\n * let minv = if Int64.compare time minv < 0 then time else minv in\n * f factors maxv minv\n * else f factors maxv minv\n * in\n * let maxv, minv = f factors min_int max_int in *)\n"}, {"source_code": "\nmodule Prelude = struct\n let scanf = Scanf.scanf\n let printf = Printf.printf\n\n module Int = struct\n type t = int\n let compare = compare\n end\nend\n\nopen Prelude\n\nmodule IntSet = Set.Make(Int)\n\nlet gen_prime_t = Array.create 100000 0\nlet gen_prime (upto: int): int array =\n let rec f (n: int) (s: int): int =\n if n > upto\n then s\n else\n let rec is_prime i =\n if i >= s then true\n else\n let t = Array.get gen_prime_t i in\n if t > n / 2 then true\n else if n mod t = 0 then false\n else is_prime (i + 1)\n in f (n + 2) (if is_prime 0 then (Array.set gen_prime_t s n; s + 1) else s)\n in\n Array.set gen_prime_t 0 2;\n let l = f 3 1 in Array.sub gen_prime_t 0 l\n\nmodule PrimeFactors = struct\n type item = { factor: int; count: int; }\n type t = item list\n\n let to_string (src: t) =\n src |>\n List.map (fun { factor; count } -> Printf.sprintf \"(%d * %d)\" count factor) |>\n String.concat \" \"\n\n let get_all_factors (src: t): int list =\n let rec outer (n: int) (src: item list) (ret: int list): int list =\n match src with\n | [] -> n :: ret\n | item :: items ->\n let rec inner (i: int) (n: int) (ret: int list): int list =\n if i > item.count\n then ret\n else\n let ret = outer n items ret in\n inner (i + 1) (n * item.factor) ret\n in inner 0 n ret\n in outer 1 src []\n\nend\n\nlet factorize (primes: int array) (src: int64): PrimeFactors.t =\n let rec f (cur: int64) (i: int) (ret: PrimeFactors.t) =\n if i >= Array.length primes then ret else\n let rec g (cur: int64) (n: int): int64 * int = Int64.(\n let t = Array.get primes i in\n if (rem cur (of_int t)) = zero\n then g (div cur (of_int t)) (n + 1)\n else (cur, n)\n ) in\n let cur, t = g cur 0 in\n let ret = if t = 0 then ret else { factor = Array.get primes i; count = t } :: ret in\n f cur (i + 1) ret\n in f src 0 []\n\nlet rec gcd (lhs: int64) (rhs: int64): int64 =\n if rhs = Int64.zero\n then lhs\n (* NOTE: we don't need the second extra check, the rem will do it ... *)\n (* if lhs > rhs then gcd rhs Int64.(rem lhs rhs) *)\n else gcd rhs Int64.(rem lhs rhs)\n\nlet _ =\n (* let primes = gen_prime 100000 in *)\n (* printf \"gen complete\\n\";\n * let factors = factorize primes (Int64.of_int 720720) in\n * PrimeFactors.get_all_factors factors |> List.iter (printf \"%d\\n\")\n * printf \"%s\\n\" (factorize primes (Int64.of_int 8400) |> PrimeFactors.to_string) *)\n let n, k, a, b = scanf \"%d %d %d %d\" (fun a b c d -> a, b, c, d) in Int64.(\n let total = (mul (of_int n) (of_int k)) in\n let do_try (posb: int64) (maxv, minv): int64 * int64 =\n let time =\n let l = (sub posb (of_int a)) in\n let actual_l = gcd total l in\n (div total actual_l)\n in\n let maxv = if Int64.compare time maxv > 0 then time else maxv in\n let minv = if Int64.compare time minv < 0 then time else minv in\n (maxv, minv)\n in\n let rec test_cycle (posb: int64) (maxv, minv): int64 * int64 =\n if posb > (add total (of_int a))\n then (maxv, minv)\n else let tu = do_try posb (maxv, minv) in test_cycle (add posb (of_int k)) tu\n in\n let tu = (Int64.min_int, Int64.max_int) in\n let tu = test_cycle (sub (of_int k) (of_int b)) tu in\n let tu = test_cycle (add (of_int k) (of_int b)) tu in\n let (maxv, minv) = tu in\n (* let factors = PrimeFactors.get_all_factors (factorize primes total) in\n * let rec f (factors: int list) (maxv: int64) (minv: int64): int64 * int64 =\n * match factors with\n * | [] -> maxv, minv\n * | l :: factors ->\n * let dist2 = (rem (add (of_int a) (of_int l)) (of_int k)) in\n * if (dist2 = (of_int b)) || (dist2 = (of_int (k - b)))\n * then\n * let time = (div total (of_int l)) in\n * let maxv = if Int64.compare time maxv > 0 then time else maxv in\n * let minv = if Int64.compare time minv < 0 then time else minv in\n * f factors maxv minv\n * else f factors maxv minv\n * in\n * let maxv, minv = f factors min_int max_int in *)\n printf \"%Ld %Ld\\n\" minv maxv)\n"}, {"source_code": "\nmodule Prelude = struct\n let scanf = Scanf.scanf\n let printf = Printf.printf\n\n module Int = struct\n type t = int\n let compare = compare\n end\nend\n\nopen Prelude\n\nmodule IntSet = Set.Make(Int)\n\nlet gen_prime_t = Array.create 100000 0\nlet gen_prime (upto: int): int array =\n let rec f (n: int) (s: int): int =\n if n > upto\n then s\n else\n let rec is_prime i =\n if i >= s then true\n else\n let t = Array.get gen_prime_t i in\n if t > n / 2 then true\n else if n mod t = 0 then false\n else is_prime (i + 1)\n in f (n + 2) (if is_prime 0 then (Array.set gen_prime_t s n; s + 1) else s)\n in\n Array.set gen_prime_t 0 2;\n let l = f 3 1 in Array.sub gen_prime_t 0 l\n\nmodule PrimeFactors = struct\n type item = { factor: int; count: int; }\n type t = item list\n\n let to_string (src: t) =\n src |>\n List.map (fun { factor; count } -> Printf.sprintf \"(%d * %d)\" count factor) |>\n String.concat \" \"\n\n let get_all_factors (src: t): int list =\n let rec outer (n: int) (src: item list) (ret: int list): int list =\n match src with\n | [] -> n :: ret\n | item :: items ->\n let rec inner (i: int) (n: int) (ret: int list): int list =\n if i > item.count\n then ret\n else\n let ret = outer n items ret in\n inner (i + 1) (n * item.factor) ret\n in inner 0 n ret\n in outer 1 src []\n\nend\n\nlet factorize (primes: int array) (src: int64): PrimeFactors.t =\n let rec f (cur: int64) (i: int) (ret: PrimeFactors.t) =\n if i >= Array.length primes then ret else\n let rec g (cur: int64) (n: int): int64 * int = Int64.(\n let t = Array.get primes i in\n if (rem cur (of_int t)) = zero\n then g (div cur (of_int t)) (n + 1)\n else (cur, n)\n ) in\n let cur, t = g cur 0 in\n let ret = if t = 0 then ret else { factor = Array.get primes i; count = t } :: ret in\n f cur (i + 1) ret\n in f src 0 []\n\nlet rec gcd (lhs: int64) (rhs: int64): int64 =\n if rhs = Int64.zero\n then lhs\n (* NOTE: we don't need the second extra check, the rem will do it ... *)\n (* if lhs > rhs then gcd rhs Int64.(rem lhs rhs) *)\n else gcd rhs Int64.(rem lhs rhs)\n\nlet _ =\n (* let primes = gen_prime 100000 in *)\n (* printf \"gen complete\\n\";\n * let factors = factorize primes (Int64.of_int 720720) in\n * PrimeFactors.get_all_factors factors |> List.iter (printf \"%d\\n\")\n * printf \"%s\\n\" (factorize primes (Int64.of_int 8400) |> PrimeFactors.to_string) *)\n let n, k, a, b = scanf \"%d %d %d %d\" (fun a b c d -> a, b, c, d) in Int64.(\n let n, k, a, b = of_int n, of_int k, of_int a, of_int b in\n let total = (mul n k) in\n let do_try (posb: int64) (maxv, minv): int64 * int64 =\n let time =\n let l = (sub posb a) in\n let actual_l = gcd total l in\n (div total actual_l)\n in\n let maxv = if Int64.compare time maxv > 0 then time else maxv in\n let minv = if Int64.compare time minv < 0 then time else minv in\n (maxv, minv)\n in\n let rec test_cycle (posb: int64) (maxv, minv): int64 * int64 =\n if posb > (add total a)\n then (maxv, minv)\n else let tu = do_try posb (maxv, minv) in test_cycle (add posb k) tu\n in\n let tu = (Int64.min_int, Int64.max_int) in\n let tu = tu |> test_cycle (add k b) |> test_cycle (sub k b) in\n let (maxv, minv) = tu in\n printf \"%Ld %Ld\\n\" minv maxv)\n (* let factors = PrimeFactors.get_all_factors (factorize primes total) in\n * let rec f (factors: int list) (maxv: int64) (minv: int64): int64 * int64 =\n * match factors with\n * | [] -> maxv, minv\n * | l :: factors ->\n * let dist2 = (rem (add (of_int a) (of_int l)) (of_int k)) in\n * if (dist2 = (of_int b)) || (dist2 = (of_int (k - b)))\n * then\n * let time = (div total (of_int l)) in\n * let maxv = if Int64.compare time maxv > 0 then time else maxv in\n * let minv = if Int64.compare time minv < 0 then time else minv in\n * f factors maxv minv\n * else f factors maxv minv\n * in\n * let maxv, minv = f factors min_int max_int in *)\n"}], "negative_code": [{"source_code": "\nmodule Prelude = struct\n let scanf = Scanf.scanf\n let printf = Printf.printf\n\n module Int = struct\n type t = int\n let compare = compare\n end\nend\n\nopen Prelude\n\nmodule IntSet = Set.Make(Int)\n\nlet gen_prime_t = Array.create 100000 0\nlet gen_prime (upto: int): int array =\n let rec f (n: int) (s: int): int =\n if n > upto\n then s\n else\n let rec is_prime i =\n if i >= s then true\n else\n let t = Array.get gen_prime_t i in\n if t > n / 2 then true\n else if n mod t = 0 then false\n else is_prime (i + 1)\n in f (n + 2) (if is_prime 0 then (Array.set gen_prime_t s n; s + 1) else s)\n in\n Array.set gen_prime_t 0 2;\n let l = f 3 1 in Array.sub gen_prime_t 0 l\n\nmodule PrimeFactors = struct\n type item = { factor: int; count: int; }\n type t = item list\n\n let to_string (src: t) =\n src |>\n List.map (fun { factor; count } -> Printf.sprintf \"(%d * %d)\" count factor) |>\n String.concat \" \"\n\n let get_all_factors (src: t): int list =\n let rec outer (n: int) (src: item list) (ret: int list): int list =\n match src with\n | [] -> n :: ret\n | item :: items ->\n let rec inner (i: int) (n: int) (ret: int list): int list =\n if i > item.count\n then ret\n else\n let ret = outer n items ret in\n inner (i + 1) (n * item.factor) ret\n in inner 0 n ret\n in outer 1 src []\n\nend\n\nlet factorize (primes: int array) (src: int64): PrimeFactors.t =\n let rec f (cur: int64) (i: int) (ret: PrimeFactors.t) =\n if i >= Array.length primes then ret else\n let rec g (cur: int64) (n: int): int64 * int = Int64.(\n let t = Array.get primes i in\n if (rem cur (of_int t)) = zero\n then g (div cur (of_int t)) (n + 1)\n else (cur, n)\n ) in\n let cur, t = g cur 0 in\n let ret = if t = 0 then ret else { factor = Array.get primes i; count = t } :: ret in\n f cur (i + 1) ret\n in f src 0 []\n\nlet _ =\n let primes = gen_prime 100000 in\n (* printf \"gen complete\\n\";\n * let factors = factorize primes (Int64.of_int 720720) in\n * PrimeFactors.get_all_factors factors |> List.iter (printf \"%d\\n\")\n * printf \"%s\\n\" (factorize primes (Int64.of_int 8400) |> PrimeFactors.to_string) *)\n let n, k, a, b = scanf \"%d %d %d %d\" (fun a b c d -> a, b, c, d) in Int64.(\n let total = (mul (of_int n) (of_int k)) in\n let factors = PrimeFactors.get_all_factors (factorize primes total) in\n let rec f (factors: int list) (maxv: int64) (minv: int64): int64 * int64 =\n match factors with\n | [] -> maxv, minv\n | l :: factors ->\n let dist2 = (rem (add (of_int a) (of_int l)) (of_int k)) in\n if (dist2 = (of_int b)) || (dist2 = (of_int (k - b)))\n then\n let time = (div total (of_int l)) in\n let maxv = if Int64.compare time maxv > 0 then time else maxv in\n let minv = if Int64.compare time minv < 0 then time else minv in\n f factors maxv minv\n else f factors maxv minv\n in\n let maxv, minv = f factors min_int max_int in\n printf \"%Ld %Ld\\n\" minv maxv)\n"}], "src_uid": "5bb4adff1b332f43144047955eefba0c"} {"source_code": "let () = Scanf.scanf \"%d\\n\" (fun n ->\n let arr = Array.make_matrix n n 1 in\n for i = 1 to n - 1 do\n for j = 1 to n - 1 do\n arr.(i).(j) <- arr.(i-1).(j) + arr.(i).(j-1)\n done\n done;\n Printf.printf \"%d\\n\" arr.(n-1).(n-1))\n", "positive_code": [{"source_code": "let solve () = \n let n = Scanf.scanf \"%d\" (fun n -> n) in\n let rec f i = \n if i = 0\n then\n 1\n else\n (f (i - 1) * (i * 2) * ((i * 2) - 1)/ i )/ i in\n f (n - 1)\n\nlet print result = Printf.printf \"%d\\n\" result\nlet () = print (solve ())"}, {"source_code": "let solve () = \n let n = Scanf.scanf \"%d\" (fun n -> n) in\n let rec loop i prev =\n if i < n \n then\n let rec looper j current = \n if j < n\n then\n (let element = (Array.get prev j) + (Array.get current (j - 1)) in\n Array.set current j element;\n looper (j + 1) current)\n else\n loop (i + 1) current\n in looper 1 (Array.make n 1)\n else\n Array.get prev (n - 1)\n in loop 1 (Array.make n 1)\n\nlet print result = Printf.printf \"%d\\n\" result\nlet () = print (solve ())"}, {"source_code": "open Printf\nopen Scanf\n\nlet ( ++ ) a b = Int64.add a b\n\n(*------------create binomial--------------*)\nlet init_binomial n m = \n (* compute an array b so that b.(p).(q) = (p choose q), \n where 0 <= p <= n and 0 <= q <= m. *)\n let b = Array.make_matrix (n+1) (m+1) 0L in\n for i=0 to n do for j=0 to min i m do \n b.(i).(j) <- if j=0 then 1L else b.(i-1).(j-1) ++ b.(i-1).(j)\n done done;\n b\n\nlet read_int () = bscanf Scanning.stdib \" %d \" (fun x -> x)\nlet () = \n let n = read_int () in\n\n let b = init_binomial (2*(n-1)) (2*(n-1)) in\n\n printf \"%Ld\\n\" (b.(2*(n-1)).(n-1))\n"}, {"source_code": "\nlet rec a = function\n (_, 1) -> 1\n |(1, _) -> 1\n |(n, m) -> a (n - 1, m) + a (n, m - 1);;\n\nlet () =\n Printf.printf \"%d\\n\"\n (Scanf.scanf \"%d \"\n (fun n -> a (n, n)));;"}], "negative_code": [], "src_uid": "2f650aae9dfeb02533149ced402b60dc"} {"source_code": "let dist = function\n | [[x1; y1] ; [x2; y2]] ->\n begin\n let open Int64 in\n max\n (abs (sub x1 x2))\n (abs (sub y1 y2))\n end\n | _ -> Int64.zero\n\nlet () =\n let line1 = read_line () in\n let line2 = read_line () in\n [ line1; line2 ]\n |> List.map (fun x -> List.map Int64.of_string @@ Str.split (Str.regexp \" \") x)\n |> dist |> Int64.to_string\n |> print_string\n |> print_newline\n", "positive_code": [{"source_code": "let xint() = Scanf.scanf \" %ld\" (fun x -> x)\n\nlet () = \n let x1 = xint() and y1 = xint() in\n let x2 = xint() and y2 = xint() in\n let abs x = \n if Int32.compare x 0l < 0 then Int32.sub 0l x\n else x\n in\n let x = abs (Int32.sub x2 x1) in\n let y = abs (Int32.sub y2 y1) in\n Printf.printf \"%ld\\n\" (\n if Int32.compare x y > 0 then x\n else y\n )\n"}, {"source_code": "let (+|) = Int64.add\nlet (-|) = Int64.sub\nlet ( *| ) = Int64.mul\nlet ( /| ) = Int64.div\n\nlet _ =\n let sb = Scanf.Scanning.stdib in\n let x1 = Scanf.bscanf sb \"%Ld \" (fun s -> s) in\n let y1 = Scanf.bscanf sb \"%Ld \" (fun s -> s) in\n let x2 = Scanf.bscanf sb \"%Ld \" (fun s -> s) in\n let y2 = Scanf.bscanf sb \"%Ld \" (fun s -> s) in\n let res = max (Int64.abs (x1 -| x2)) (Int64.abs (y1 -| y2)) in\n Printf.printf \"%Ld\\n\" res\n"}, {"source_code": "open Printf\nopen Scanf\n\nlet ( ** ) a b = Int64.mul a b\nlet ( ++ ) a b = Int64.add a b\nlet ( -- ) a b = Int64.sub a b\nlet abs = Int64.abs\n \nlet read_pair () = bscanf Scanning.stdib \" %Ld %Ld \" (fun x y -> (x,y))\nlet () = \n let (x1,y1) = read_pair () in\n let (x2,y2) = read_pair () in \n\n printf \"%Ld\\n\" (max (abs (x1--x2)) (abs (y1--y2)))\n"}], "negative_code": [{"source_code": "let dist = function\n | [[x1; y1] ; [x2; y2]] -> begin\n max\n (abs (x1 - x2))\n (abs (y1 - y2))\n end\n | _ -> -1\n\nlet () =\n let line1 = read_line () in\n let line2 = read_line () in\n [ line1; line2 ]\n |> List.map (fun x -> List.map int_of_string @@ Str.split (Str.regexp \" \") x)\n |> dist\n |> print_int\n |> print_newline\n"}, {"source_code": "let xint() = Scanf.scanf \" %d\" (fun x -> x)\n\nlet () = \n let x1 = xint() and y1 = xint() in\n let x2 = xint() and y2 = xint() in\n let abs x = \n if x < 0 then -x\n else x\n in\n let x = abs (x2 - x1) in\n let y = abs (y2 - y1) in\n Printf.printf \"%d\\n\" (\n if x > y then x\n else y\n )\n"}], "src_uid": "a6e9405bc3d4847fe962446bc1c457b4"} {"source_code": "let read_int () = Scanf.bscanf Scanf.Scanning.stdib \" %d \" (fun x -> x)\n\nlet () = \n let n = read_int() in\n let a = Array.init n (fun i -> read_int()) in\n let c = Array.make 3 0 in\n for i=0 to n-1 do\n let e = i mod 3 in\n\tc.(e) <- c.(e) + a.(i);\n done;\n\n let m = max (max c.(0) c.(1)) c.(2) in\n let s = if c.(0) = m then \"chest\"\n else if c.(1) = m then \"biceps\"\n else \"back\" in\n \n Printf.printf \"%s\\n\" s\n\n", "positive_code": [{"source_code": "let read_int () = Scanf.bscanf Scanf.Scanning.stdib \" %d \" (fun x -> x) ;;\n\nlet n = read_int () ;;\n\nlet a =\n let rec loop i n f =\n if i = n then f []\n else let ai = read_int () in loop (i + 1) n (fun l -> f (ai :: l))\n in loop 0 n (fun x -> x) ;;\n\nlet count l = \n let rec loop i (chest, biceps, back) = function\n | [] -> (chest, biceps, back)\n | h :: t -> \n if i mod 3 = 0 then loop (i + 1) (chest + h, biceps, back) t\n else if i mod 3 = 1 then loop (i + 1) (chest, biceps + h, back) t\n else loop (i + 1) (chest, biceps, back + h) t\n in loop 0 (0, 0, 0) l ;;\n\nlet strongest_muscle (chest, biceps, back) =\n if chest > biceps && chest > back then \"chest\"\n else if biceps > chest && biceps > back then \"biceps\"\n else \"back\" ;;\n \nPrintf.printf \"%s\\n\" (strongest_muscle (count a)) ;;"}], "negative_code": [], "src_uid": "579021de624c072f5e0393aae762117e"} {"source_code": "let (|>) x f = f x\n\nlet main = \n let (n, d) = Scanf.scanf \"%d %d\\n\" (fun n d -> (n,d)) in\n let rec aux n acc =\n match n with\n 0 -> acc\n | n -> aux (n-1) (acc + (Scanf.scanf \"%d \" (fun n -> n)))\n in\n let sum = aux n 0 in\n if (n-1)*10 + sum > d then Printf.printf \"-1\\n\"\n else Printf.printf \"%d\\n\" ((d-sum)/5)\n", "positive_code": [{"source_code": "let read () = Scanf.scanf \"%d \" (fun n -> n)\n\nlet get_sum songs = \n let rec loop i acc = \n if i < songs \n then\n let song = read () in\n loop (i + 1) (acc + song)\n else\n acc\n in loop 0 0 \n\nlet input () = \n let songs = read () in\n let time_limit = read () in\n let time_songs = get_sum songs in\n (songs, time_limit, time_songs)\n\nlet solve (songs, time_limit, time_songs) =\n let time_pauses = 10 * (songs - 1) in\n let time_needed = time_pauses + time_songs in\n if time_needed <= time_limit\n then\n (time_limit - time_songs) / 5\n else\n -1 \n\nlet print result = Printf.printf \"%d\\n\" result\nlet () = print (solve (input ()))"}, {"source_code": "let read_int()=Scanf.scanf \"%d \" (fun x->x);;\nlet n=read_int();;\nlet d=read_int();;\nlet nb=ref 0;;\nlet j=ref 0;;\nfor i=1 to n-1 do\n let x=read_int() in\n nb:= !nb+10+x;\n j:= !j+2;\ndone;;\nlet x=Scanf.scanf \"%d\" (fun x->x);;\nnb:= !nb+x;;\nlet a=d- !nb;;\nif a<0 then print_int (-1) else print_int(!j+(a/5));;"}], "negative_code": [], "src_uid": "b16f5f5c4eeed2a3700506003e8ea8ea"} {"source_code": "let good year = \n let n1,n2,n3,n4=(year mod 10000)/1000,(year mod 1000)/100,(year mod 100)/10,(year mod 10) in\n if (n1<>n2) && (n1<>n3) && (n1<>n4) && (n2<>n3) && (n2<>n4) && (n3<>n4) then true\n else false;;\t\nlet rec solve year = \n\tif (good year) then year\n else solve (year+1);;\t\nlet year = read_int ();;\nprint_int (solve (year+1));;", "positive_code": [{"source_code": "let str_to_list s =\n let rec loop i l =\n if i < 0 \n then l \n else loop (i - 1) ((Pervasives.int_of_char s.[i] - Pervasives.int_of_char '0') :: l) in\n loop (String.length s - 1) []\n\nlet input () = Scanf.scanf \"%s\" (fun s -> (List.rev (str_to_list s)))\n\nlet find_allowed year =\n let rec loop year allowed = \n match year with\n |(int :: tail) -> loop tail (List.filter((<>) int) allowed)\n |[] -> allowed\n in loop year [0;1;2;3;4;5;6;7;8;9]\n\nlet is_good year = \n List.length (find_allowed year) = 10 - List.length year \n\nlet rec increase year = \n let allowed = find_allowed year in\n match year with\n |(ones :: tail) -> (match (List.filter(fun a -> a > ones) allowed) with\n |(min :: _) when is_good tail -> (min :: tail)\n |_ -> let temp = increase tail in\n (List.hd(find_allowed temp) :: temp))\n |[] -> [1]\n\nlet solve input = List.rev (increase input)\n\nlet () = List.iter(Printf.printf \"%d\") (solve (input())) "}, {"source_code": "let rec dig n ak =\n\tif n = 0 then ak\n\telse dig (n / 10) ((n mod 10)::ak)\n;;\nlet good n =\n\tlet li = List.sort compare (dig n [])\n\tand krok (last, ans) e = \n\t\tif e = last then (e, false)\n\t\telse (e, ans)\n\tin snd (List.fold_left krok (10, true) li)\n;; \n\nlet rec solve n =\n\tif good n then n\n\telse solve (n + 1)\n;;\nlet year n = solve (n + 1);;\nlet x = read_int ();;\nprint_int (year x);;\n"}, {"source_code": "open Printf\n\nexception Found\n\nlet n = Scanf.scanf \"%d \" ( fun x -> x)\n\nlet y = ref (n+1)\n\nlet not_distinct year =\n let flag = ref false in\n try\n let s = string_of_int year in\n let l = String.length s in\n for i = 0 to l-1 do\n for j =i+1 to l -1 do\n let x = String.get s i in\n let y1 = String.get s j in\n if(x==y1) then begin flag := true; raise Found end\n done;\n done; \n !flag;\n with Found -> !flag\n;;\n\nlet () =\n while( (not_distinct !y) ) do\n incr y\n done\n;;\n\nprintf \"%d\\n\" !y\n"}], "negative_code": [{"source_code": "let str_to_list s =\n let rec loop i l =\n if i < 0 \n then l \n else loop (i - 1) ((Pervasives.int_of_char s.[i] - Pervasives.int_of_char '0') :: l) in\n loop (String.length s - 1) []\n\nlet input () = Scanf.scanf \"%s\" (fun s -> (List.rev (str_to_list s)))\n\nlet find_allowed year =\n let rec loop year allowed = \n match year with\n |(int :: tail) -> loop tail (List.filter((<>) int) allowed)\n |[] -> allowed\n in loop year [0; 1; 2; 3; 4; 5; 6; 7; 8; 9]\n\nlet rec increase year = \n let allowed = find_allowed year in\n match year with\n |(ones :: tail) -> (match (List.filter(fun a -> a > ones) allowed) with\n |(min :: _) -> (min :: tail)\n |[] -> let temp = increase tail in\n (List.hd(find_allowed temp) :: temp))\n |[] -> [1]\n\nlet solve input = List.rev (increase input)\n\nlet () = List.iter(Printf.printf \"%d\") (solve (input())) "}], "src_uid": "d62dabfbec52675b7ed7b582ad133acd"} {"source_code": "let data = [|\n \"111111101010101111100101001111111\";\n \"100000100000000001010110001000001\";\n \"101110100110110000011010001011101\";\n \"101110101011001001111101001011101\";\n \"101110101100011000111100101011101\";\n \"100000101010101011010000101000001\";\n \"111111101010101010101010101111111\";\n \"000000001111101111100111100000000\";\n \"100010111100100001011110111111001\";\n \"110111001111111100100001000101100\";\n \"011100111010000101000111010001010\";\n \"011110000110001111110101100000011\";\n \"111111111111111000111001001011000\";\n \"111000010111010011010011010100100\";\n \"101010100010110010110101010000010\";\n \"101100000101010001111101000000000\";\n \"000010100011001101000111101011010\";\n \"101001001111101111000101010001110\";\n \"101101111111000100100001110001000\";\n \"000010011000100110000011010000010\";\n \"001101101001101110010010011011000\";\n \"011101011010001000111101010100110\";\n \"111010100110011101001101000001110\";\n \"110001010010101111000101111111000\";\n \"001000111011100001010110111110000\";\n \"000000001110010110100010100010110\";\n \"111111101000101111000110101011010\";\n \"100000100111010101111100100011011\";\n \"101110101001010000101000111111000\";\n \"101110100011010010010111111011010\";\n \"101110100100011011110110101110000\";\n \"100000100110011001111100111100000\";\n \"111111101101000101001101110010001\"; |]\n\nlet _ =\n let sb = Scanf.Scanning.stdib in\n let n = Scanf.bscanf sb \"%d \" (fun s -> s) in\n let m = Scanf.bscanf sb \"%d \" (fun s -> s) in\n Printf.printf \"%c\\n\" data.(n).[m]\n", "positive_code": [{"source_code": "let read_int () = Scanf.bscanf Scanf.Scanning.stdib \" %d \" (fun x -> x)\nlet read_string () = Scanf.bscanf Scanf.Scanning.stdib \" %s \" (fun x -> x)\n\nlet s = String.lowercase (read_string())\nlet k = read_int();;\nfor i=0 to (String.length s)-1 do \n\ts.[i] <- if int_of_char s.[i] < k + 97 then Char.uppercase s.[i] else Char.lowercase s.[i]\ndone;\nPrintf.printf \"%s\\n\" s"}, {"source_code": "let _ =\n let sb = Scanf.Scanning.stdib in\n let s = Scanf.bscanf sb \"%s \" (fun s -> s) in\n let n = Scanf.bscanf sb \"%d \" (fun s -> s) in\n let s = String.lowercase s in\n let res = String.make (String.length s) '\\000' in\n let n = ref n in\n let pos = ref 0 in\n for i = 0 to String.length s - 1 do\n let c = s.[i] in\n\tif Char.code c < !n + 97\n\tthen res.[!pos] <- Char.uppercase c\n\telse res.[!pos] <- c;\n\tincr pos\n done;\n Printf.printf \"%s\\n\" res\n"}, {"source_code": "let _ =\n let sb = Scanf.Scanning.stdib in\n let x = Scanf.bscanf sb \"%f \" (fun s -> s) in\n for a' = 1 to 10 do\n for h' = 1 to 10 do\n\tlet a = float_of_int a'\n\tand h = float_of_int h' in\n\tlet r = a *. h /. sqrt (a *. a +. 4.0 *. h *. h) in\n\t if abs_float (r -. x) < 1e-6 then (\n\t Printf.printf \"%d %d\\n\" a' h';\n\t exit 0\n\t )\n done\n done\n"}, {"source_code": "let read_int () = Scanf.bscanf Scanf.Scanning.stdib \" %d \" (fun x -> x)\nlet read_string () = Scanf.bscanf Scanf.Scanning.stdib \" %s \" (fun x -> x)\n\n\nlet s = String.lowercase (read_string())\n\nlet k = read_int()\n;;\n\nfor i=0 to (String.length s)-1 do\n let c = s.[i] in\n let c = if int_of_char c < k + 97 then \n Char.uppercase c else Char.lowercase c in\n s.[i] <- c\ndone;\n\nPrintf.printf \"%s\\n\" s\n"}, {"source_code": "let _ =\n let main () =\n let f a =\n Printf.printf \"%.f\\n\" (6. *. a *. (a -. 1.) +. 1.)\n in\n Scanf.sscanf (read_line ()) \"%f\" f\n in\n main ()\n"}, {"source_code": "open Int64\n\nlet rec solve n accm =\n if n < one\n then accm\n else solve (sub n one) (add accm (mul (of_int 12) (pred n)))\n\nlet solve n = solve (of_int n) one\n\nlet _ =\n Printf.printf \"%s\\n\" (to_string (Scanf.scanf \" %d\" solve))\n"}, {"source_code": "let _ =\n let sb = Scanf.Scanning.stdib in\n let a = Scanf.bscanf sb \"%ld \" (fun s -> s) in\n let res = Int32.add (Int32.mul 6l (Int32.mul a (Int32.sub a 1l))) 1l in\n Printf.printf \"%ld\\n\" res;\n"}, {"source_code": "let l = [\n(0,1,1,0),0;(0,0,0,0),0;(1,0,0,0),1;(0,1,0,0),0;(1,1,0,0),1;\n(0,0,1,0),0;(1,0,1,0),0;(1,1,1,0),1;(0,0,0,1),1;(1,0,0,1),1;\n(0,1,0,1),0;(1,1,0,1),0;(0,0,1,1),1;(1,0,1,1),1;(0,1,1,1),0;\n(1,1,1,1),1\n]\n\nlet rec ok x = function\n | (a,b)::l when a = x -> b\n | _::l -> ok x l\n | _ -> -1;;\n\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 = ok (a,b,c,d) l in\n if ans = -1\n then if b = 0 then print_int (1/0) else print_int 2\n else print_int ans"}, {"source_code": "let qr =\n [ \"111111101010101111100101001111111\"\n ; \"100000100000000001010110001000001\"\n ; \"101110100110110000011010001011101\"\n ; \"101110101011001001111101001011101\"\n ; \"101110101100011000111100101011101\"\n ; \"100000101010101011010000101000001\"\n ; \"111111101010101010101010101111111\"\n ; \"000000001111101111100111100000000\"\n ; \"100010111100100001011110111111001\"\n ; \"110111001111111100100001000101100\"\n ; \"011100111010000101000111010001010\"\n ; \"011110000110001111110101100000011\"\n ; \"111111111111111000111001001011000\"\n ; \"111000010111010011010011010100100\"\n ; \"101010100010110010110101010000010\"\n ; \"101100000101010001111101000000000\"\n ; \"000010100011001101000111101011010\"\n ; \"101001001111101111000101010001110\"\n ; \"101101111111000100100001110001000\"\n ; \"000010011000100110000011010000010\"\n ; \"001101101001101110010010011011000\"\n ; \"011101011010001000111101010100110\"\n ; \"111010100110011101001101000001110\"\n ; \"110001010010101111000101111111000\"\n ; \"001000111011100001010110111110000\"\n ; \"000000001110010110100010100010110\"\n ; \"111111101000101111000110101011010\"\n ; \"100000100111010101111100100011011\"\n ; \"101110101001010000101000111111000\"\n ; \"101110100011010010010111111011010\"\n ; \"101110100100011011110110101110000\"\n ; \"100000100110011001111100111100000\"\n ; \"111111101101000101001101110010001\"];;\n\nScanf.scanf \"%d %d\" (fun r c -> (print_char (String.get (List.nth qr r) c);\nprint_endline \"\"));;\n"}], "negative_code": [{"source_code": "let l = [\n(0,1,1,0),0;(0,0,0,0),0;(1,0,0,0),1;(0,1,0,0),0;(1,1,0,0),1;\n(0,0,1,0),0;(1,0,1,0),0;(1,1,1,0),1;(0,0,0,1),1;(1,0,0,1),1;\n(0,1,0,1),0;(1,1,0,1),0;(0,0,1,1),1;(1,0,1,1),1;(0,1,1,1),0;\n(1,1,1,1),0\n]\n\nlet rec ok x = function\n | (a,b)::l when a = x -> b\n | _::l -> ok x l\n | _ -> -1;;\n\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 = ok (a,b,c,d) l in\n if ans = -1\n then if b = 0 then print_int (1/0) else print_int 2\n else print_int ans"}, {"source_code": "let l = [\n(0,1,1,0),0;(0,0,0,0),0;(1,0,0,0),1;(0,1,0,0),0;(1,1,0,0),1;\n(0,0,1,0),0;(1,0,1,0),0;(1,1,1,0),1;(0,0,0,1),1;(1,0,0,1),1;\n(0,1,0,1),0;(1,1,0,1),1;(0,0,1,1),0\n]\n\nlet rec ok x = function\n | (a,b)::l when a = x -> b\n | _::l -> ok x l\n | _ -> -1;;\n\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 = ok (a,b,c,d) l in\n if ans = -1\n then if b = 0 then print_int (1/0) else print_int 2\n else print_int ans"}, {"source_code": "let l = [\n(0,1,1,0),0;(0,0,0,0),0;(1,0,0,0),1;(0,1,0,0),0;(1,1,0,0),1;\n(0,0,1,0),0;(1,0,1,0),0;(1,1,1,0),1;(0,0,0,1),1;(1,0,0,1),1;\n(0,1,0,1),0;(1,1,0,1),0;(0,0,1,1),1;(1,0,1,1),1;(0,1,1,1),0;\n]\n\nlet rec ok x = function\n | (a,b)::l when a = x -> b\n | _::l -> ok x l\n | _ -> -1;;\n\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 = ok (a,b,c,d) l in\n if ans = -1\n then if b = 0 then print_int (1/0) else print_int 2\n else print_int ans"}, {"source_code": "let which f =\n let plop = ref [] in\n for a = 0 to 1 do\n for b = 0 to 1 do\n for c = 0 to 1 do\n for d = 0 to 1 do\n plop := (f (a=1) (b=1) (c=1) (d=1))::!plop\n done;\n done;\n done;\n done;\n !plop\n \nlet l =\n let olol = ref [] in\n for a = 0 to 1 do\n let b = 1 - a in\n for d = 0 to 1 do\n olol := (fun i j ->\n match i,j with\n | true,true -> a=0\n | true,false -> b=0\n | false,true -> b=0\n | false,false -> d=0\n )::!olol;\n done;\n done;\n !olol\n\nlet prod_cart a b =\n List.(flatten (map (fun i -> map (fun j -> i,j) b) a))\n\nlet beuleu = prod_cart l (prod_cart l l)\n \nlet hamza = List.map (fun (i,(j,k)) -> i,j,k) beuleu\n\nlet f (triang,triang_sub,sqr) a b c d =\n let x = triang a b in\n let y = triang_sub c d in\n let z = sqr b c in\n let zz = triang a d in\n let dx = sqr x y in\n let dy = triang_sub z zz in\n let final = triang dx dy in\n final;;\n\nlet all_f = List.map f hamza;;\n\nlet finally = List.filter (fun i -> false = i false true true false) all_f;;\n\n\nlet rec no_doub = function\n | (a,b)::(c,_)::l when a = c -> no_doub ((a,b)::l)\n | x::l -> x::(no_doub l)\n | l -> l;;\n\nlet compare (a,_) (c,_) = compare a c;;\n\nlet with_sig = no_doub (List.sort compare (List.map (fun h -> which h, h) finally));;\n\nlet finnnnal = List.map snd with_sig;;\n\nlet _ =\n let kikou = Scanf.scanf \"%d %d %d %d\" (fun a b c d -> (List.hd finnnnal) (a=1) (b=1) (c=1) (d=1)) in\n if kikou then print_int 1 else print_int 0"}, {"source_code": "let l = [\n(0,1,1,0),0;(0,0,0,0),0;(1,0,0,0),1;(0,1,0,0),0;(1,1,0,0),1;\n(0,0,1,0),0;(1,0,1,0),0;(1,1,1,0),1;(0,0,0,1),0;\n]\n\nlet rec ok x = function\n | (a,b)::l when a = x -> b\n | _::l -> ok x l\n | _ -> -1;;\n\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 = ok (a,b,c,d) l in\n if ans = -1\n then if b = 0 then print_int (1/0) else print_int 2\n else print_int ans"}, {"source_code": "let l = [(0,1,1,0),0;(0,0,0,0),0]\n\nlet rec ok x = function\n | (a,b)::l when a = x -> b\n | _::l -> ok x l\n | _ -> -1;;\n\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 = ok (a,b,c,d) l in\n if ans = -1\n then if a = 0 then print_int (1/0) else print_int 2\n else print_int ans"}, {"source_code": "let l = [\n(0,1,1,0),0;(0,0,0,0),0;(1,0,0,0),1;(0,1,0,0),0;(1,1,0,0),1;\n(0,0,1,0),0;(1,0,1,0),0\n]\n\nlet rec ok x = function\n | (a,b)::l when a = x -> b\n | _::l -> ok x l\n | _ -> -1;;\n\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 = ok (a,b,c,d) l in\n if ans = -1\n then if b = 0 then print_int (1/0) else print_int 2\n else print_int ans"}, {"source_code": "let rec pow x n =\n if n = 0 then 1 else x * pow x (n-1)\n\nlet olol n =\n if n = 3 then 27 else 2\n\nlet _ =\n let n = Scanf.scanf \"%d\" (fun n -> n) in\n print_int (olol n)"}, {"source_code": "let l = [(0,1,1,0),0;(0,0,0,0),0;(1,0,0,0),1;(0,1,0,0),0;(1,1,0,0),0]\n\nlet rec ok x = function\n | (a,b)::l when a = x -> b\n | _::l -> ok x l\n | _ -> -1;;\n\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 = ok (a,b,c,d) l in\n if ans = -1\n then if b = 0 then print_int (1/0) else print_int 2\n else print_int ans"}, {"source_code": "let which f =\n let plop = ref [] in\n for a = 0 to 1 do\n for b = 0 to 1 do\n for c = 0 to 1 do\n for d = 0 to 1 do\n plop := (f (a=1) (b=1) (c=1) (d=1))::!plop\n done;\n done;\n done;\n done;\n !plop\n \nlet l =\n let olol = ref [] in\n for a = 0 to 1 do\n let b = 1 - a in\n for d = 0 to 1 do\n olol := (fun i j ->\n match i,j with\n | true,true -> a=0\n | true,false -> b=0\n | false,true -> b=0\n | false,false -> d=0\n )::!olol;\n done;\n done;\n !olol\n\nlet prod_cart a b =\n List.(flatten (map (fun i -> map (fun j -> i,j) b) a))\n\nlet beuleu = prod_cart l (prod_cart l l)\n \nlet hamza = List.map (fun (i,(j,k)) -> i,j,k) beuleu\n\nlet f (triang,triang_sub,sqr) a b c d =\n let x = triang a b in\n let y = triang_sub c d in\n let z = sqr b c in\n let zz = triang a d in\n let dx = sqr x y in\n let dy = triang_sub z zz in\n let final = triang dx dy in\n final;;\n\nlet all_f = List.map f hamza;;\n\nlet finally = List.filter (fun i -> false = i false true true false) all_f;;\n\n\nlet rec no_doub = function\n | (a,b)::(c,_)::l when a = c -> no_doub ((a,b)::l)\n | x::l -> x::(no_doub l)\n | l -> l;;\n\nlet compare (a,_) (c,_) = compare a c;;\n\nlet with_sig = no_doub (List.sort compare (List.map (fun h -> which h, h) finally));;\n\nlet finnnnal = List.map snd with_sig;;\n\nlet _ =\n let kikou = Scanf.scanf \"%d %d %d %d\" (fun a b c d -> (List.nth finnnnal 2) (a=1) (b=1) (c=1) (d=1)) in\n if kikou then print_int 1 else print_int 0"}, {"source_code": "let l = [\n(0,1,1,0),0;(0,0,0,0),0;(1,0,0,0),1;(0,1,0,0),0;(1,1,0,0),1;\n(0,0,1,0),0;(1,0,1,0),0;(1,1,1,0),1;(0,0,0,1),1;(1,0,0,1),1;\n(0,1,0,1),1\n]\n\nlet rec ok x = function\n | (a,b)::l when a = x -> b\n | _::l -> ok x l\n | _ -> -1;;\n\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 = ok (a,b,c,d) l in\n if ans = -1\n then if b = 0 then print_int (1/0) else print_int 2\n else print_int ans"}, {"source_code": "let l = [(0,1,1,0),0;(0,0,0,0),0;(1,0,0,0),0]\n\nlet rec ok x = function\n | (a,b)::l when a = x -> b\n | _::l -> ok x l\n | _ -> -1;;\n\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 = ok (a,b,c,d) l in\n if ans = -1\n then if a = 0 then print_int (1/0) else print_int 2\n else print_int ans"}, {"source_code": "let l = [\n(0,1,1,0),0;(0,0,0,0),0;(1,0,0,0),1;(0,1,0,0),0;(1,1,0,0),1;\n(0,0,1,0),0;(1,0,1,0),0;(1,1,1,0),0;\n]\n\nlet rec ok x = function\n | (a,b)::l when a = x -> b\n | _::l -> ok x l\n | _ -> -1;;\n\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 = ok (a,b,c,d) l in\n if ans = -1\n then if b = 0 then print_int (1/0) else print_int 2\n else print_int ans"}, {"source_code": "let l = [\n(0,1,1,0),0;(0,0,0,0),0;(1,0,0,0),1;(0,1,0,0),0;(1,1,0,0),1;\n(0,0,1,0),0;(1,0,1,0),0;(1,1,1,0),1;(0,0,0,1),1;(1,0,0,1),1;\n(0,1,0,1),0;(1,1,0,1),0;(0,0,1,1),1;(1,0,1,1),0;\n]\n\nlet rec ok x = function\n | (a,b)::l when a = x -> b\n | _::l -> ok x l\n | _ -> -1;;\n\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 = ok (a,b,c,d) l in\n if ans = -1\n then if b = 0 then print_int (1/0) else print_int 2\n else print_int ans"}, {"source_code": "let l = [\n(0,1,1,0),0;(0,0,0,0),0;(1,0,0,0),1;(0,1,0,0),0;(1,1,0,0),1;\n(0,0,1,0),0;(1,0,1,0),0;(1,1,1,0),1;(0,0,0,1),1;(1,0,0,1),0;\n]\n\nlet rec ok x = function\n | (a,b)::l when a = x -> b\n | _::l -> ok x l\n | _ -> -1;;\n\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 = ok (a,b,c,d) l in\n if ans = -1\n then if b = 0 then print_int (1/0) else print_int 2\n else print_int ans"}, {"source_code": "let l = [\n(0,1,1,0),0;(0,0,0,0),0;(1,0,0,0),1;(0,1,0,0),0;(1,1,0,0),1;\n(0,0,1,0),0;(1,0,1,0),0;(1,1,1,0),1;(0,0,0,1),1;(1,0,0,1),1;\n(0,1,0,1),0\n]\n\nlet rec ok x = function\n | (a,b)::l when a = x -> b\n | _::l -> ok x l\n | _ -> -1;;\n\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 = ok (a,b,c,d) l in\n if ans = -1\n then if b = 0 then print_int (1/0) else print_int 2\n else print_int ans"}, {"source_code": "let l = [(0,1,1,0),0;(0,0,0,0),0;(1,0,0,0),1;(0,1,0,0),0]\n\nlet rec ok x = function\n | (a,b)::l when a = x -> b\n | _::l -> ok x l\n | _ -> -1;;\n\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 = ok (a,b,c,d) l in\n if ans = -1\n then if b = 0 then print_int (1/0) else print_int 2\n else print_int ans"}, {"source_code": "let l =\n let olol = ref [] in\n for a = 0 to 1 do\n let b = 1 - a in\n for d = 0 to 1 do\n olol := (fun i j ->\n match i,j with\n | true,true -> a=0\n | true,false -> b=0\n | false,true -> b=0\n | false,false -> d=0\n )::!olol;\n done;\n done;\n !olol\n\nlet prod_cart a b =\n List.(flatten (map (fun i -> map (fun j -> i,j) b) a))\n\nlet beuleu = prod_cart l (prod_cart l l)\n \nlet hamza = List.map (fun (i,(j,k)) -> i,j,k) beuleu\n\nlet f (triang,triang_sub,sqr) a b c d =\n let x = triang a b in\n let y = triang_sub c d in\n let z = sqr b c in\n let zz = triang a d in\n let dx = sqr x y in\n let dy = triang_sub z zz in\n let final = triang dx dy in\n final\n \nlet all_f = List.map f hamza\n\nlet finally = List.filter (fun i -> false = i false true true false) all_f\n\n\nlet _ =\n let kikou = Scanf.scanf \"%d %d %d %d\" (fun a b c d -> (List.hd finally) (a=1) (b=1) (c=1) (d=1)) in\n if kikou then print_int 1 else print_int 0"}, {"source_code": "let rec solve n accm =\n if n < 1 then accm else solve (n - 1) (accm + 12*(n-1))\n\nlet solve n = solve n 1\n\nlet _ =\n Printf.printf \"%d\\n\" (Scanf.scanf \" %d\" solve)\n"}, {"source_code": "let l = [\n(0,1,1,0),0;(0,0,0,0),0;(1,0,0,0),1;(0,1,0,0),0;(1,1,0,0),1;\n(0,0,1,0),0;(1,0,1,0),0;(1,1,1,0),1;(0,0,0,1),1;(1,0,0,1),1;\n(0,1,0,1),0;(1,1,0,1),0;(0,0,1,1),0\n]\n\nlet rec ok x = function\n | (a,b)::l when a = x -> b\n | _::l -> ok x l\n | _ -> -1;;\n\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 = ok (a,b,c,d) l in\n if ans = -1\n then if b = 0 then print_int (1/0) else print_int 2\n else print_int ans"}, {"source_code": "let l = [\n(0,1,1,0),0;(0,0,0,0),0;(1,0,0,0),1;(0,1,0,0),0;(1,1,0,0),1;\n(0,0,1,0),0;(1,0,1,0),0;(1,1,1,0),1;(0,0,0,1),1;(1,0,0,1),1;\n]\n\nlet rec ok x = function\n | (a,b)::l when a = x -> b\n | _::l -> ok x l\n | _ -> -1;;\n\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 = ok (a,b,c,d) l in\n if ans = -1\n then if b = 0 then print_int (1/0) else print_int 2\n else print_int ans"}, {"source_code": "let l = [\n(0,1,1,0),0;(0,0,0,0),0;(1,0,0,0),1;(0,1,0,0),0;(1,1,0,0),1;\n(0,0,1,0),0;(1,0,1,0),1;(1,1,1,0),0;\n]\n\nlet rec ok x = function\n | (a,b)::l when a = x -> b\n | _::l -> ok x l\n | _ -> -1;;\n\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 = ok (a,b,c,d) l in\n if ans = -1\n then if b = 0 then print_int (1/0) else print_int 2\n else print_int ans"}, {"source_code": "let l = [(0,1,1,0),0;(0,0,0,0),0;(1,0,0,0),1]\n\nlet rec ok x = function\n | (a,b)::l when a = x -> b\n | _::l -> ok x l\n | _ -> -1;;\n\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 = ok (a,b,c,d) l in\n if ans = -1\n then if b = 0 then print_int (1/0) else print_int 2\n else print_int ans"}, {"source_code": "let which f =\n let plop = ref [] in\n for a = 0 to 1 do\n for b = 0 to 1 do\n for c = 0 to 1 do\n for d = 0 to 1 do\n plop := (f (a=1) (b=1) (c=1) (d=1))::!plop\n done;\n done;\n done;\n done;\n !plop\n \nlet l =\n let olol = ref [] in\n for a = 0 to 1 do\n let b = 1 - a in\n for d = 0 to 1 do\n olol := (fun i j ->\n match i,j with\n | true,true -> a=0\n | true,false -> b=0\n | false,true -> b=0\n | false,false -> d=0\n )::!olol;\n done;\n done;\n !olol\n\nlet prod_cart a b =\n List.(flatten (map (fun i -> map (fun j -> i,j) b) a))\n\nlet beuleu = prod_cart l (prod_cart l l)\n \nlet hamza = List.map (fun (i,(j,k)) -> i,j,k) beuleu\n\nlet f (triang,triang_sub,sqr) a b c d =\n let x = triang a b in\n let y = triang_sub c d in\n let z = sqr b c in\n let zz = triang a d in\n let dx = sqr x y in\n let dy = triang_sub z zz in\n let final = triang dx dy in\n final;;\n\nlet all_f = List.map f hamza;;\n\nlet finally = List.filter (fun i -> false = i false true true false) all_f;;\n\n\nlet rec no_doub = function\n | (a,b)::(c,_)::l when a = c -> no_doub ((a,b)::l)\n | x::l -> x::(no_doub l)\n | l -> l;;\n\nlet compare (a,_) (c,_) = compare a c;;\n\nlet with_sig = no_doub (List.sort compare (List.map (fun h -> which h, h) finally));;\n\nlet finnnnal = List.map snd with_sig;;\n\nlet _ =\n let kikou = Scanf.scanf \"%d %d %d %d\" (fun a b c d -> (List.nth finnnnal 1) (a=1) (b=1) (c=1) (d=1)) in\n if kikou then print_int 1 else print_int 0"}, {"source_code": "let l = [\n(0,1,1,0),0;(0,0,0,0),0;(1,0,0,0),1;(0,1,0,0),0;(1,1,0,0),1;\n(0,0,1,0),0;(1,0,1,0),1;\n]\n\nlet rec ok x = function\n | (a,b)::l when a = x -> b\n | _::l -> ok x l\n | _ -> -1;;\n\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 = ok (a,b,c,d) l in\n if ans = -1\n then if b = 0 then print_int (1/0) else print_int 2\n else print_int ans"}, {"source_code": "let l = [\n(0,1,1,0),0;(0,0,0,0),0;(1,0,0,0),1;(0,1,0,0),0;(1,1,0,0),1;\n(0,0,1,0),0;(1,0,1,0),0;(1,1,1,0),1;(0,0,0,1),1;(1,0,0,1),1;\n(0,1,0,1),0;(1,1,0,1),0;(0,0,1,1),1;(1,0,1,1),1\n]\n\nlet rec ok x = function\n | (a,b)::l when a = x -> b\n | _::l -> ok x l\n | _ -> -1;;\n\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 = ok (a,b,c,d) l in\n if ans = -1\n then if b = 0 then print_int (1/0) else print_int 2\n else print_int ans"}, {"source_code": "let rec pow x n =\n if n = 0 then 1 else x * pow x (n-1)\n\nlet olol n =\n 2\n\nlet _ =\n let n = Scanf.scanf \"%d\" (fun n -> n) in\n print_int (olol n)"}], "src_uid": "879ac20ae5d3e7f1002afe907d9887df"} {"source_code": "let read_int () = Scanf.bscanf Scanf.Scanning.stdib \" %d \" (fun x -> x) \nlet read_string () = Scanf.bscanf Scanf.Scanning.stdib \" %s \" (fun x -> x) \n\nlet () =\n let r1 = read_int() in\n let r2 = read_int() in\n let c1 = read_int() in\n let c2 = read_int() in\n let d1 = read_int() in\n let d2 = read_int() in\n\n\n for i1 = 1 to 9 do\n for i2 = 1 to 9 do\n\tfor i3 = 1 to 9 do\n\t for i4 = 1 to 9 do\n\t if r1=i1+i2 && r2=i3+i4 && c1=i1+i3 && c2=i2+i4 && d1=i1+i4 && d2=i2+i3 \n\t && i1<>i2 && i1<>i3 && i1<>i4 && i2<>i3 && i2<>i4 && i3<>i4\n\t then (\n\t Printf.printf \"%d %d\\n%d %d\\n\" i1 i2 i3 i4;\n\t exit 1\n\t )\n\t done\n\tdone\n done\n done;\n \n Printf.printf \"-1\\n\"\n", "positive_code": [{"source_code": "let r1, r2 = Scanf.scanf \"%d %d\\n\" (fun x y -> (x,y));;\nlet c1, c2 = Scanf.scanf \"%d %d\\n\" (fun x y -> (x,y));;\nlet d1, d2 = Scanf.scanf \"%d %d\\n\" (fun x y -> (x,y));;\n\nfor p00 = 1 to 9 do begin\n\tlet p01 = r1 - p00\n\tand p10 = c1 - p00\n\tand p11 = d1 - p00 in\n\tif (p00 <= 9) && (p00 >= 1) && (p01 <= 9) && (p01 >= 1) &&\n(p10 <= 9) && (p10 >= 1) &&\n(p11 <= 9) && (p11 >= 1) &&\n\n\t\t(p00 <> p01) && (p00 <> p10) && (p00 <> p11) &&\n\t\t(p01 <> p10) && (p01 <> p11) && (p10 <> p11) \n\t\t&& (p10 + p11 = r2) && (p01 + p11 = c2) && (p10 + p01 = d2) then begin\n\t\tprint_int p00; print_char ' '; print_int p01; print_string \"\\n\";\n\t\tprint_int p10; print_char ' '; print_int p11;\n\t\texit 0;\n\tend\nend done;;\n\nprint_int (0-1);;\n"}], "negative_code": [{"source_code": "let r1, r2 = Scanf.scanf \"%d %d\\n\" (fun x y -> (x,y));;\nlet c1, c2 = Scanf.scanf \"%d %d\\n\" (fun x y -> (x,y));;\nlet d1, d2 = Scanf.scanf \"%d %d\\n\" (fun x y -> (x,y));;\n\nfor p00 = 1 to 9 do begin\n\tlet p01 = r1 - p00\n\tand p10 = c1 - p00\n\tand p11 = d1 - p00 in\n\tif (p00 <> p01) && (p00 <> p10) && (p00 <> p11) &&\n\t\t(p01 <> p10) && (p01 <> p11) && (p10 <> p11) \n\t\t&& (p10 + p11 = r2) && (p01 + p11 = c2) && (p10 + p01 = d2) then begin\n\t\tprint_int p00; print_char ' '; print_int p01; print_string \"\\n\";\n\t\tprint_int p10; print_char ' '; print_int p11;\n\t\texit 0;\n\tend\nend done;;\n\nprint_int (0-1);;\n"}, {"source_code": "let read_int () = Scanf.bscanf Scanf.Scanning.stdib \" %d \" (fun x -> x) \nlet read_string () = Scanf.bscanf Scanf.Scanning.stdib \" %s \" (fun x -> x) \n\nlet () =\n let r1 = read_int() in\n let r2 = read_int() in\n let c1 = read_int() in\n let c2 = read_int() in\n let d1 = read_int() in\n let d2 = read_int() in\n\n\n for i1 = 0 to 9 do\n for i2 = 0 to 9 do\n\tfor i3 = 0 to 9 do\n\t for i4 = 0 to 9 do\n\t if r1=i1+i2 && r2=i3+i4 && c1=i1+i3 && c2=i2+i4 && d1=i1+i4 && d2=i2+i3 \n\t && i1<>i2 && i1<>i3 && i1<>i4 && i2<>i3 && i2<>i4 && i3<>i4\n\t then (\n\t Printf.printf \"%d %d\\n%d %d\\n\" i1 i2 i3 i4;\n\t exit 1\n\t )\n\t done\n\tdone\n done\n done;\n \n Printf.printf \"-1\\n\"\n"}, {"source_code": "let read_int () = Scanf.bscanf Scanf.Scanning.stdib \" %d \" (fun x -> x) \nlet read_string () = Scanf.bscanf Scanf.Scanning.stdib \" %s \" (fun x -> x) \n\nlet () =\n let r1 = read_int() in\n let r2 = read_int() in\n let c1 = read_int() in\n let c2 = read_int() in\n let d1 = read_int() in\n let d2 = read_int() in\n\n\n for i1 = 0 to 9 do\n for i2 = 0 to 9 do\n\tfor i3 = 0 to 9 do\n\t for i4 = 0 to 9 do\n\t if r1=i1+i2 && r2=i3+i4 && c1=i1+i3 && c2=i2+i4 && d1=i1+i4 && d2=i2+i3 then (\n\t Printf.printf \"%d %d\\n%d %d\\n\" i1 i2 i3 i4;\n\t exit 1\n\t )\n\t done\n\tdone\n done\n done;\n \n Printf.printf \"-1\\n\"\n"}], "src_uid": "6821f502f5b6ec95c505e5dd8f3cd5d3"} {"source_code": "(*#load \"str.cma\"*)\nopen Printf;;\nlet [a; b] = List.map (ref) (List.map (int_of_string) (Str.split (Str.regexp \" \") (read_line ())));;\nlet ans = ref 0;;\nwhile (!a <= !b) do\n\ta := !a * 3;\n\tb := !b * 2;\n\tans := !ans + 1;\ndone;;\nprintf \"%d\\n\" !ans;;\n", "positive_code": [{"source_code": " let x, y = Scanf.scanf \"%d %d\" (fun x y -> float_of_int x, float_of_int y)\n \n let _ = \n print_int (int_of_float (ceil (log(y /. x) /. log(1.5) +. 0.00001)))"}, {"source_code": "let input () = Scanf.scanf \"%d %d\" (fun a b -> (a, b))\n\nlet solve (a, b) = \n let rec loop i a_mass b_mass = \n if a_mass > b_mass\n then\n i\n else\n loop (i + 1) (a_mass * 3) (b_mass * 2)\n in loop 0 a b\n\nlet print result = Printf.printf \"%d\\n\" result\nlet () = print (solve (input ()))"}, {"source_code": "let main () =\n let gr () = Scanf.scanf \" %d\" (fun i -> i) in \n let a = gr () in\n let b = gr() in \n let rec f x y ans = \n let newx = 3 * x in \n let newy = 2 * y in \n if newx > newy then (ans + 1) else f newx newy (ans + 1) \n in\n Printf.printf \"%d\\n\" (f a b 0)\n ;;\nlet _ = main();;\n"}, {"source_code": "let get_int () =\n Scanf.scanf \" %d\" (fun x -> x)\n;;\nlet () =\n let x = get_int () in\n let y = get_int () in\n let rec f x y t =\n if x > y then t\n else f (3 * x) (2 * y) (t + 1) in\n Printf.printf \"%d\\n\" (f x y 0)\n;;\n"}, {"source_code": "let wczytaj () =\n Scanf.scanf \" %d\" (fun x -> x)\n;;\n\nlet rec kiedy a b cnt =\n let roznica = (a > b) in\n match roznica with\n | true -> cnt\n | false -> (kiedy (a*3) (b*2) (cnt+1))\n;;\n\nlet main () =\n let a = (wczytaj ()) in\n let b = (wczytaj ()) in\n (kiedy a b 0)\n;;\n\nlet _ = Printf.printf \"%d\" (main ())\n"}, {"source_code": "let min_time a b =\n let rec helper a b acc =\n if a > b then \n acc\n else helper (3 * a) (2 * b) (acc + 1)\n in helper a b 0\nin\n\nlet a = Scanf.scanf \" %d\" (fun x -> x) in\nlet b = Scanf.scanf \" %d\" (fun x -> x) in\nPrintf.printf \"%d\\n\" (min_time a b);\n"}, {"source_code": "open Printf\nopen Scanf\n\nlet read_pair _ = bscanf Scanning.stdib \" %d %d \" (fun x y -> (x,y))\nlet () = \n let (a,b) = read_pair () in\n\n let rec loop a b count = if a > b then count else loop (3*a) (2*b) (count+1) in\n\n printf \"%d\\n\" (loop a b 0)\n"}], "negative_code": [{"source_code": "let x, y = Scanf.scanf \"%d %d\" (fun x y -> float_of_int x, float_of_int y)\n \nlet _ = \n print_int (int_of_float (ceil (log(y /. x) /. log(1.5))))"}], "src_uid": "a1583b07a9d093e887f73cc5c29e444a"} {"source_code": "let read_string () = Scanf.bscanf Scanf.Scanning.stdib \" %s \" (fun x -> x)\n\nlet is_vowel c =\n List.mem c ['A'; 'E'; 'I'; 'O'; 'U'; 'Y']\n\nlet () =\n let s = read_string () in\n let len = String.length s in\n let rec loop i count max_sum =\n if i >= len then max (count + 1) max_sum\n else if is_vowel s.[i] then\n loop (i + 1) 0 (max (count + 1) max_sum)\n else loop (i + 1) (count + 1) max_sum\n in\n loop 0 0 0\n |> Printf.printf \"%d\"\n", "positive_code": [{"source_code": "let is_vowel c =\n List.mem c ['A'; 'E'; 'I'; 'O'; 'U'; 'Y']\n\nlet () =\n let s = read_line () in\n let rec loop ability jump i =\n if i = String.length s then\n max jump ability\n else if is_vowel s.[i] then\n loop (max jump ability) 1 (i + 1)\n else\n loop ability (jump + 1) (i + 1) in\n loop 1 1 0 |> string_of_int |> print_endline\n"}, {"source_code": "let min_jump s =\n let len = String.length s in\n let rec jump i jumped m =\n if i = len then\n max m jumped\n else\n match s.[i] with\n 'A' | 'E' | 'I' | 'O' | 'U' | 'Y' ->\n jump (i+1) 1 (max m jumped)\n | _ ->\n jump (i+1) (jumped+1) m\n in jump 0 1 0 ;;\n\nlet s = read_line ()\nin Printf.printf \"%d\\n\" (min_jump s) ;;\n"}, {"source_code": "let input () = Scanf.scanf \"%s\\n\" (fun s -> s)\nlet print result = Printf.printf \"%d\\n\" result\n\nlet is_vovel char = \n match char with\n | 'A' | 'E' | 'I' | 'O' | 'U' | 'Y' -> true\n | _ -> false\n\nlet solve str = \n let l = String.length str in\n let rec loop i prev max = \n if i < l \n then\n let char = str.[i] in\n if is_vovel char\n then\n let hop = Pervasives.max (i - prev) max in\n loop (i + 1) i hop\n else\n loop (i + 1) prev max\n else\n Pervasives.max (l - prev) max\n in loop 0 (-1) 0\n\nlet () = print (solve (input ()))"}, {"source_code": "\n\nlet solve s =\n let n = String.length s in\n let rec solve last_pos i acc =\n if i <= n then\n if s.[i-1] = 'A' || s.[i-1] = 'E' || s.[i-1] = 'I' ||\n s.[i-1] = 'O' || s.[i-1] = 'U' || s.[i-1] = 'Y' then\n solve i (i+1) (max acc (i - last_pos))\n else\n solve last_pos (i+1) acc\n else\n max acc (i - last_pos)\n in\n solve 0 1 0\n;;\n\n\nlet main () =\n let s = read_line () in\n let () = print_int (solve s) in\n print_string \"\\n\"\n;;\n\n\nmain ()\n"}], "negative_code": [{"source_code": "let read_string () = Scanf.bscanf Scanf.Scanning.stdib \" %s \" (fun x -> x)\n\nlet is_vowel c =\n List.mem c ['A'; 'E'; 'I'; 'O'; 'U'; 'Y']\n\nlet () =\n let s = read_string () in\n let len = String.length s in\n let rec loop i count max_sum =\n if i >= len then max count max_sum\n else if is_vowel s.[i] then\n loop (i + 1) 0 (max (count + 1) max_sum)\n else loop (i + 1) (count + 1) max_sum\n in\n loop 0 0 0\n |> Printf.printf \"%d\"\n"}, {"source_code": "let read_string () = Scanf.bscanf Scanf.Scanning.stdib \" %s \" (fun x -> x)\n\nlet is_vowel c =\n List.mem c ['A'; 'E'; 'I'; 'O'; 'U'; 'Y']\n\nlet () =\n let s = read_string () in\n let len = String.length s in\n let rec loop i count max_sum =\n if i >= len then max_sum\n else if is_vowel s.[i] then\n loop (i + 1) 0 (max (count + 1) max_sum)\n else loop (i + 1) (count + 1) max_sum\n in\n loop 0 0 0\n |> Printf.printf \"%d\"\n"}, {"source_code": "let is_vowel c =\n List.mem c ['A'; 'E'; 'I'; 'O'; 'U'; 'Y']\n\nlet () =\n let s = read_line () in\n let rec loop ability jump i =\n if i = String.length s then\n ability\n else if is_vowel s.[i] then\n loop (max jump ability) 1 (i + 1)\n else\n loop ability (jump + 1) (i + 1) in\n loop 1 1 0 |> string_of_int |> print_endline\n"}, {"source_code": "let min_jump s =\n let len = String.length s in\n let rec jump i jumped m =\n if i = len then\n max m jumped\n else\n match s.[i] with\n 'A' | 'E' | 'I' | 'O' | 'U' | 'Y' ->\n jump (i+1) 1 (max m jumped)\n | _ ->\n jump (i+1) (jumped+1) m\n in jump 0 0 0 ;;\n\nlet s = read_line ()\nin Printf.printf \"%d\\n\" (min_jump s) ;;\n"}], "src_uid": "1fc7e939cdeb015fe31f3cf1c0982fee"} {"source_code": "let lcm a b =\n let rec gcd a b = if b = Int32.zero then a else gcd b (Int32.rem a b)\n in (Int32.div (Int32.mul a b) (gcd a b)) in\nlet (x, y, a, b) = Scanf.scanf \"%ld %ld %ld %ld\\n\" (fun x y a b -> (x, y, a, b)) in\nlet m = lcm x y in\n(* determine number of m in interval [a,b] *)\nlet start = Int32.add a (Int32.rem (Int32.sub m (Int32.rem a m)) m)\nand last = Int32.sub b (Int32.rem b m) in\nPrintf.printf \"%ld\\n\" (max (Int32.succ (Int32.div (Int32.sub last start) m))\nInt32.zero) ;;\n", "positive_code": [{"source_code": "open Printf\nopen Scanf\nopen String\nopen List\nopen Int64\n\nlet rec gcd a b =\n\tif b = zero then a\n\telse gcd b (rem a b);;\n\nlet solve x y a b =\n\tlet l = (div (mul x y) (gcd x y))\n\tin printf \"%Ld\" (sub (div b l) (div (pred a) l))\nin scanf \"%Ld %Ld %Ld %Ld\" solve;;\n"}], "negative_code": [{"source_code": "let rec gcd a = function 0 -> a | b -> gcd b (a mod b) in\nlet lcm a b = (a * b) / (gcd a b) in\nlet (x, y, a, b) = Scanf.scanf \"%d %d %d %d\\n\" (fun x y a b -> (x, y, a, b)) in\nlet m = lcm x y in\n(* determine number of m in interval [a,b] *)\nlet start = a + (a mod m)\nand last = b - (b mod m) in\nPrintf.printf \"%d\\n\" (max ((last - start) / m + 1) 0) ;;\n"}], "src_uid": "c7aa8a95d5f8832015853cffa1374c48"} {"source_code": "let input () = Scanf.scanf \"%s\" (fun s -> s)\n\nlet solve input =\n if String.contains input 'H' || String.contains input 'Q' || String.contains input '9'\n then\n \"YES\"\n else\n \"NO\"\n\nlet print result = Printf.printf \"%s\\n\" result\n\nlet () = print (solve (input ()))", "positive_code": [{"source_code": "let rec p str n = if (n=String.length str) then \"NO\"\n else match str.[n] with 'H' | 'Q' | '9' -> \"YES\" | _ -> p str (n+1)\n\nlet main () = ((print_string (p (read_line ()) 0)); print_newline ();\n);;\n\nif !Sys.interactive then () else main ();;"}, {"source_code": "let flag = ref \"NO\";;\n\nexception Found;;\n\nlet vote = function\n | 'H' -> raise Found\n | 'Q' -> raise Found\n | '9' -> raise Found\n | _ -> ()\n;;\n\nlet s = Scanf.scanf \"%s \" (fun x -> x)\n\ntry\n for i=0 to String.length s - 1 do\n vote (String.get s i)\n done\nwith Found -> flag := \"YES\";;\n\nprint_endline !flag;;\n"}, {"source_code": "let solve p =\n if String.contains p 'H' || String.contains p 'Q' || String.contains p '9'\n then \"YES\"\n else \"NO\"\n\nlet _ =\n Printf.printf \"%s\\n\" (Scanf.scanf \"%s\" solve)\n\n"}, {"source_code": "\nlet solve s len =\n let rec solve' i = match s.[i], i with\n | 'H', _ | 'Q', _ | '9', _ -> \"YES\"\n | _, n when n = len -> \"NO\"\n | _, n -> solve' (i + 1)\n in solve' 0\n\nlet () =\n let s = read_line () in\n Printf.printf \"%s\\n\" (solve (s ^ \" \") (String.length s))\n"}, {"source_code": "let pf = Printf.printf;;\nlet sf = Scanf.scanf;;\nlet ssf = Scanf.sscanf;;\n\nlet (|>) x f = f x;;\nlet (@@) f x = f x;;\n\nexception Error of string\n\nlet inf = 1000000000;;\nlet eps = 1e-11;;\n\nlet charlist_of_string s =\n let rec inner rv = function\n 0 -> rv\n | m -> inner (s.[m-1]::rv) (m-1) in\n inner [] (String.length s)\n;;\n\nlet l = ['H'; 'Q'; '9'];;\n\nlet _ =\n let s = read_line() in\n let func c = List.memq c @@ charlist_of_string s in\n print_endline (if List.exists func l then \"YES\" else \"NO\")\n;;\n"}], "negative_code": [], "src_uid": "1baf894c1c7d5aeea01129c7900d3c12"} {"source_code": "let readInt64 () = Scanf.scanf \" %Ld\" (fun x -> x)\n\nlet tri k = Int64.(div (mul k (add k 1L)) 2L)\n\nlet isTri n =\n let rec lim k =\n if tri k <= n then lim (Int64.mul 2L k)\n else k\n in\n let rec go l r = Int64.(\n if sub r l <= 1L then tri l = n\n else\n let m = add l (div (sub r l) 2L) in\n if tri m <= n then go m r\n else go l m\n )\n in go 0L (lim 3L)\n\nlet isDoubleTri n =\n let rec go i sum = Int64.(\n if sum >= n then false\n else if isTri (sub n sum) then true\n else let ii = add i 1L in go ii (add sum ii)\n )\n in go 1L 1L\n\nlet () =\n let n = readInt64 () in\n Printf.printf (if isDoubleTri n then \"YES\\n\" else \"NO\\n\")\n", "positive_code": [{"source_code": "let rec gao n a b = match a, b with\n | [], _ | _, [] -> \"NO\"\n | (x::xs), (y::ys) ->\n if x + y = n then \"YES\"\n else if x + y > n then gao n a ys\n else gao n xs b\n;;\n\nlet triangular n =\n if n mod 2 = 0\n then n / 2 * (n + 1)\n else (n + 1) / 2 * n\n;;\n\nlet a = Array.init 45000 triangular in\nlet l = List.tl (Array.to_list a) in\nlet n = Scanf.scanf \"%d\" (fun x -> x) in\nprint_endline (gao n l (List.rev l));;\n\n"}, {"source_code": "let readInt () = Scanf.scanf \" %d\" (fun x -> x)\n\nlet tri k = k * (k + 1) / 2\n\nlet isTri n =\n let rec go l r =\n if r - l <= 1 then tri l == n\n else\n let m = l + (r - l) / 2 in\n if tri m <= n then go m r\n else go l m\n in go 0 (int_of_float (sqrt (float_of_int (2 * n)) +. 1.))\n\nlet isDoubleTri n =\n let rec go i sum =\n if sum >= n then false\n else if isTri (n - sum) then true\n else go (i + 1) (sum + i + 1)\n in go 1 1\n\nlet () =\n let n = readInt () in\n Printf.printf (if isDoubleTri n then \"YES\\n\" else \"NO\\n\")\n"}, {"source_code": "let readInt32 () = Scanf.scanf \" %ld\" (fun x -> x)\n\nlet tri k = Int32.(div (mul k (add k 1l)) 2l)\n\nlet isTri n =\n let rec lim k =\n if tri k <= n then lim Int32.(div (mul 14l k) 10l)\n else k\n in\n let rec go l r = Int32.(\n if sub r l <= 1l then tri l = n\n else\n let m = add l (div (sub r l) 2l) in\n if tri m <= n then go m r\n else go l m\n )\n in go 0l (lim 3l)\n\nlet isDoubleTri n =\n let rec go i sum = Int32.(\n if sum >= n then false\n else if isTri (sub n sum) then true\n else let ii = add i 1l in go ii (add sum ii)\n )\n in go 1l 1l\n\nlet () =\n let n = readInt32 () in\n Printf.printf (if isDoubleTri n then \"YES\\n\" else \"NO\\n\")\n"}], "negative_code": [{"source_code": "let readInt () = Scanf.scanf \" %d\" (fun x -> x)\n\nlet tri k = k * (k + 1) / 2\n\nlet isTri n =\n let rec go l r =\n if r - l <= 1 then tri l == n\n else\n let m = l + (r - l) / 2 in\n if tri m <= n then go m r\n else go l m\n in go 0 n\n\nlet isDoubleTri n =\n let rec go i sum =\n if sum >= n then false\n else if isTri (n - sum) then true\n else go (i + 1) (sum + i + 1)\n in go 1 1\n\nlet () =\n let n = readInt () in\n Printf.printf (if isDoubleTri n then \"YES\\n\" else \"NO\\n\")\n"}], "src_uid": "245ec0831cd817714a4e5c531bffd099"} {"source_code": "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 factor n =\n let m,r = ref n,ref [] in\n rep 2L (n/2L) (fun i ->\n if !m mod i = 0L then (\n let k = ref 0L in\n while !m mod i = 0L do\n k += 1L; m /= i;\n done;\n r := (i,!k) :: !r));\n if !m>1L then (!m,1L)::!r else !r\n\nlet binary_search_opt ng ok f =\n let d = if ng < ok then 1L else -1L in\n let i = binary_search ng ok f in\n if i=ng-d || i=ok+d then None else Some i\n\nlet pow n k =\n let rec f a n = function\n | 0L -> a\n | 1L -> n*a\n | k when k mod 2L = 0L -> f a (n*n) (k/2L)\n | k -> f (a*n) n (k-1L)\n in f 1L n k\n\nlet () =\n let n = get_i64 0 in\n let ls = factor n in\n let ans,k_max = List.fold_left (fun (u,w) (v,x) -> (u*v,max w x)) (1L,0L) ls in\n let nibekies =\n let i = ref 1L in\n let r = ref [] in\n while !i <= 1000008L do\n r := !i :: !r;\n i *= 2L;\n done; !r |> List.rev |> of_list in\n let k_to = lower_bound nibekies k_max in\n if pow ans (pow 2L k_to) = n then printf \"%Ld %Ld\\n\" ans k_to\n else printf \"%Ld %Ld\\n\" ans (k_to + 1L)\n\n\n\n\n\n\n\n\n\n\n", "positive_code": [{"source_code": "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\nlet sieve n = (* includes 0, O(nloglogn) *)\n let prime = Array.make (n+$1) true in\n prime.(0) <- false;\n prime.(1) <- false;\n for i=2 to n do\n if prime.(i) then let j = ref @@ i*$2 in\n while !j <= n do prime.(!j) <- false; j := !j +$ i; done\n done; prime\n(* let pow n k = fix (fun f n k a ->\n if k=0L then a\n else if k=1L then n*a\n else if k mod 2L = 0L then f (n*n) (k/2L) a\n else f n (k-1L) (a*n)) n k 1L *)\nlet pow n k =\n let rec f a n = function\n | 0L -> a\n | 1L -> n*a\n | k when k mod 2L = 0L -> f a (n*n) (k/2L)\n | k -> f (a*n) n (k-1L)\n in f 1L n k\nlet () =\n let n = get_i64 0 in\n let pr = sieve (i32 n) in\n let i = ref 1L in\n let tp =\n let i = ref 1L in\n let r = ref [] in\n while !i <= 1000000L do\n r := !i :: !r;\n i *= 2L;\n done; !r |> List.rev |> of_list in\n (* print_array ist tp; *)\n let r = ref [] in\n while !i <= n do\n if n mod !i = 0L && pr.(i32 !i) then (\n r := !i :: !r;\n );\n i += 1L;\n done;\n (* print_list ist !r; *)\n let mx = ref 0L in\n let alltp = ref true in\n List.iter (fun p ->\n let m = ref n in\n let k = ref 0L in\n while !m>=1L && !m mod p = 0L do\n k += 1L;\n m := !m / p;\n done;\n let t = lower_bound tp !k |> i32 in\n if t<=0 || i64 t>alen tp || tp.(t) <> !k then alltp := false;\n (* printf \"%Ld %Ld : %d ::: %b\\n\" p !k t !alltp; *)\n mx := max !mx !k\n ) !r;\n (* printf \"%Ld\\n\" !mx; *)\n (* let mxv = tp.(i32 @@ upper_bound tp !mx) in *)\n let mxv = lower_bound tp !mx in\n let mxv = if mxv<=0L then (\n 1L\n ) else mxv in\n (* printf \"%Ld : %Ld\\n\" !mx mxv; *)\n let res = List.fold_left ( * ) 1L !r in\n if res = n then printf \"%Ld 0\" res\n else\n printf \"%Ld %Ld\\n\" res\n (* (mxv + if !alltp then 0L else 1L) *)\n (mxv + if pow res @@ pow 2L mxv = n then 0L else 1L)\n\n\n\n\n\n\n\n\n\n\n\n\n"}, {"source_code": "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 factor n =\n let m,r = ref n,ref [] in\n rep 2L (n/2L) (fun i ->\n if !m mod i = 0L then (\n let k = ref 0L in\n while !m mod i = 0L do\n k += 1L; m /= i;\n done;\n r := (i,!k) :: !r));\n if !m>1L then (!m,1L)::!r else !r\n\nlet binary_search_opt ng ok f =\n let d = if ng < ok then 1L else -1L in\n let i = binary_search ng ok f in\n if i=ng-d || i=ok+d then None else Some i\n\nlet pow n k =\n let rec f a n = function\n | 0L -> a\n | 1L -> n*a\n | k when k mod 2L = 0L -> f a (n*n) (k/2L)\n | k -> f (a*n) n (k-1L)\n in f 1L n k\n\nlet () =\n let n = get_i64 0 in\n let ls = factor n in\n let ans,k_max = List.fold_left (fun (u,w) (v,x) -> (u*v,max w x)) (1L,0L) ls in\n let nibekies =\n let i = ref 1L in\n let r = ref [] in\n while !i <= 1000008L do\n r := !i :: !r;\n i *= 2L;\n done; !r |> List.rev |> of_list in\n let k_to = lower_bound nibekies k_max in\n if pow ans (nibekies.(i32 k_to)) = n then printf \"%Ld %Ld\\n\" ans k_to\n else printf \"%Ld %Ld\\n\" ans (k_to + 1L)\n\n\n\n\n\n\n\n\n\n\n"}], "negative_code": [{"source_code": "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\nlet sieve n = (* includes 0, O(nloglogn) *)\n let prime = Array.make (n+$1) true in\n prime.(0) <- false;\n prime.(1) <- false;\n for i=2 to n do\n if prime.(i) then let j = ref @@ i*$2 in\n while !j <= n do prime.(!j) <- false; j := !j +$ i; done\n done; prime\nlet () =\n let n = get_i64 0 in\n let pr = sieve (i32 n) in\n let i = ref 1L in\n let tp =\n let i = ref 1L in\n let r = ref [] in\n while !i <= 1000000L do\n r := !i :: !r;\n i *= 2L;\n done; !r |> List.rev |> of_list in\n (* print_array ist tp; *)\n let r = ref [] in\n while !i <= n / 2L do\n if n mod !i = 0L && pr.(i32 !i) then (\n r := !i :: !r;\n );\n i += 1L;\n done;\n (* print_list ist !r; *)\n let mx = ref 0L in\n let alltp = ref true in\n List.iter (fun p ->\n let m = ref n in\n let k = ref 0L in\n while !m>=1L && !m mod p = 0L do\n k += 1L;\n m := !m / p;\n done;\n let t = lower_bound tp !k |> i32 in\n if t<=0 || i64 t>alen tp || tp.(t) <> !k then alltp := false;\n (* printf \"%Ld %Ld : %d\\n\" p !k t; *)\n mx := max !mx !k\n ) !r;\n (* printf \"%Ld\\n\" !mx; *)\n (* let mxv = tp.(i32 @@ upper_bound tp !mx) in *)\n let mxv = lower_bound tp !mx in\n (* printf \"%Ld : %Ld\\n\" !mx mxv; *)\n printf \"%Ld %Ld\\n\" (List.fold_left ( * ) 1L !r)\n (mxv + if !alltp then 0L else 1L)\n\n\n\n\n\n\n\n\n\n\n\n\n"}, {"source_code": "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\nlet sieve n = (* includes 0, O(nloglogn) *)\n let prime = Array.make (n+$1) true in\n prime.(0) <- false;\n prime.(1) <- false;\n for i=2 to n do\n if prime.(i) then let j = ref @@ i*$2 in\n while !j <= n do prime.(!j) <- false; j := !j +$ i; done\n done; prime\nlet () =\n let n = get_i64 0 in\n let pr = sieve (i32 n) in\n let i = ref 1L in\n let tp =\n let i = ref 1L in\n let r = ref [] in\n while !i <= 1000000L do\n r := !i :: !r;\n i *= 2L;\n done; !r |> List.rev |> of_list in\n (* print_array ist tp; *)\n let r = ref [] in\n while !i <= n do\n if n mod !i = 0L && pr.(i32 !i) then (\n r := !i :: !r;\n );\n i += 1L;\n done;\n (* print_list ist !r; *)\n let mx = ref 0L in\n let alltp = ref true in\n List.iter (fun p ->\n let m = ref n in\n let k = ref 0L in\n while !m>=1L && !m mod p = 0L do\n k += 1L;\n m := !m / p;\n done;\n let t = lower_bound tp !k |> i32 in\n if t<=0 || i64 t>alen tp || tp.(t) <> !k then alltp := false;\n (* printf \"%Ld %Ld : %d\\n\" p !k t; *)\n mx := max !mx !k\n ) !r;\n (* printf \"%Ld\\n\" !mx; *)\n (* let mxv = tp.(i32 @@ upper_bound tp !mx) in *)\n let mxv = lower_bound tp !mx in\n let mxv = if mxv<=0L then (\n 1L\n ) else mxv in\n (* printf \"%Ld : %Ld\\n\" !mx mxv; *)\n let res = List.fold_left ( * ) 1L !r in\n if res = n then printf \"%Ld 0\" res\n else\n printf \"%Ld %Ld\\n\" res\n (mxv + if !alltp then 0L else 1L)\n\n\n\n\n\n\n\n\n\n\n\n\n"}, {"source_code": "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\nlet sieve n = (* includes 0, O(nloglogn) *)\n let prime = Array.make (n+$1) true in\n prime.(0) <- false;\n prime.(1) <- false;\n for i=2 to n do\n if prime.(i) then let j = ref @@ i*$2 in\n while !j <= n do prime.(!j) <- false; j := !j +$ i; done\n done; prime\n(* let pow n k = fix (fun f n k a ->\n if k=0L then a\n else if k=1L then n*a\n else if k mod 2L = 0L then f (n*n) (k/2L) a\n else f n (k-1L) (a*n)) n k 1L *)\nlet pow n k =\n let rec f a n = function\n | 0L -> a\n | 1L -> n*a\n | k when k mod 2L = 0L -> f a (n*n) (k/2L)\n | k -> f (a*n) n (k-1L)\n in f 1L n k\nlet () =\n let n = get_i64 0 in\n let pr = sieve (i32 n) in\n let i = ref 1L in\n let tp =\n let i = ref 1L in\n let r = ref [] in\n while !i <= 1000000L do\n r := !i :: !r;\n i *= 2L;\n done; !r |> List.rev |> of_list in\n (* print_array ist tp; *)\n let r = ref [] in\n while !i <= n do\n if n mod !i = 0L && pr.(i32 !i) then (\n r := !i :: !r;\n );\n i += 1L;\n done;\n (* print_list ist !r; *)\n let mx = ref 0L in\n let alltp = ref true in\n List.iter (fun p ->\n let m = ref n in\n let k = ref 0L in\n while !m>=1L && !m mod p = 0L do\n k += 1L;\n m := !m / p;\n done;\n let t = lower_bound tp !k |> i32 in\n if t<=0 || i64 t>alen tp || tp.(t) <> !k then alltp := false;\n (* printf \"%Ld %Ld : %d ::: %b\\n\" p !k t !alltp; *)\n mx := max !mx !k\n ) !r;\n (* printf \"%Ld\\n\" !mx; *)\n (* let mxv = tp.(i32 @@ upper_bound tp !mx) in *)\n let mxv = lower_bound tp !mx in\n let mxv = if mxv<=0L then (\n 1L\n ) else mxv in\n (* printf \"%Ld : %Ld\\n\" !mx mxv; *)\n let res = List.fold_left ( * ) 1L !r in\n if res = n then printf \"%Ld 0\" res\n else\n printf \"%Ld %Ld\\n\" res\n (* (mxv + if !alltp then 0L else 1L) *)\n (mxv + if pow res mxv = n then 0L else 1L)\n\n\n\n\n\n\n\n\n\n\n\n\n"}], "src_uid": "212cda3d9d611cd45332bb10b80f0b56"} {"source_code": "let is_prime n =\n if n = 2 then true\n else if n < 2 || n mod 2 = 0 then false\n else\n let rec loop k =\n if k * k > n then true\n else if n mod k = 0 then false\n else loop (k+2)\n in loop 3\n;;\n\nprint_string (Scanf.scanf \"%d %d\" (fun n k ->\n\tlet m = ref 0 in\n\tlet i = ref 3 in\n\tlet last = ref 2 in\n\tlet _ = while (!i) <= n-(!last)-1 do\n\t\tif is_prime(!i) then begin\n\t\t\tif !i+ !last+ 1 <= n && is_prime(!i+ !last+ 1)\n\t\t\tthen (incr m);\n\t\t\tlast := (!i)\n\t\tend;\n\t\ti := (!i) + 2;\n\tdone in\n\tif (!m) < k then \"NO\" else \"YES\"\n));;\n", "positive_code": [{"source_code": "let read_int _ = Scanf.bscanf Scanf.Scanning.stdib \" %d\" (fun x -> x)\n\nlet () =\n let b = Array.make 1000 true in\n for i = 2 to 1000-1 do\n if b.(i) then\n let rec go j =\n if j < 1000 then (\n b.(j) <- false;\n go (j+i)\n )\n in\n go (i*i)\n done;\n let n = read_int 0 in\n let k = read_int 0 in\n let rec go acc last i =\n if i >= 504 then\n acc\n else if not b.(i) then\n go acc last (i+1)\n else if last > 0 && last+i+1 <= n && b.(last+i+1) then\n go (acc+1) i (i+1)\n else\n go acc i (i+1)\n in\n print_endline (if go 0 0 2 >= k then \"YES\" else \"NO\")\n"}], "negative_code": [{"source_code": "let is_prime n =\n if n = 2 then true\n else if n < 2 || n mod 2 = 0 then false\n else\n let rec loop k =\n if k * k > n then true\n else if n mod k = 0 then false\n else loop (k+2)\n in loop 3\n;;\n\nprint_string (Scanf.scanf \"%d %d\" (fun n k ->\n\tlet m = ref 0 in\n\tlet i = ref 3 in\n\tlet last = ref 2 in\n\tlet _ = while (!i) <= n/2+2 do\n\t\tif is_prime(!i) then begin\n\t\t\tif !i+ !last+ 1 <= n && is_prime(!i+ !last+ 1)\n\t\t\tthen (incr m);\n\t\t\tlast := (!i)\n\t\tend;\n\t\ti := (!i) + 2;\n\tdone in\n\tif (!m) < k then \"NO\" else \"YES\"\n));;\n"}, {"source_code": "let is_prime n =\n if n = 2 then true\n else if n < 2 || n mod 2 = 0 then false\n else\n let rec loop k =\n if k * k > n then true\n else if n mod k = 0 then false\n else loop (k+2)\n in loop 3\n;;\n\nprint_string (Scanf.scanf \"%d %d\" (fun n k ->\n\tlet m = ref 0 in\n\tlet i = ref 3 in\n\tlet last = ref 2 in\n\tlet _ = while (!i) <= n/2 do\n\t\tif is_prime(!i) then begin\n\t\t\tif (!i)+(!last)+1 < n && is_prime((!i)+(!last)+1)\n\t\t\tthen incr m;\n\t\t\tlast := (!i)\n\t\tend;\n\t\ti := (!i) + 2;\n\tdone in\n\tif (!m) < k then \"NO\" else \"YES\"\n));;\n"}, {"source_code": "let is_prime n =\n if n = 2 then true\n else if n < 2 || n mod 2 = 0 then false\n else\n let rec loop k =\n if k * k > n then true\n else if n mod k = 0 then false\n else loop (k+2)\n in loop 3\n;;\n\nprint_string (Scanf.scanf \"%d %d\" (fun n k ->\n\tlet m = ref 0 in\n\tlet i = ref 3 in\n\tlet last = ref 2 in\n\tlet _ = while (!i) < n/2 do\n\t\tif is_prime(!i) then begin\n\t\t\tif (!i)+(!last)+1 < n && is_prime((!i)+(!last)+1)\n\t\t\tthen incr m;\n\t\t\tlast := (!i)\n\t\tend;\n\t\ti := (!i) + 2;\n\tdone in\n\tif (!m) < k then \"NO\" else \"YES\"\n));;\n"}, {"source_code": "let is_prime n =\n if n = 2 then true\n else if n < 2 || n mod 2 = 0 then false\n else\n let rec loop k =\n if k * k > n then true\n else if n mod k = 0 then false\n else loop (k+2)\n in loop 3\n;;\n\nprint_string (Scanf.scanf \"%d %d\" (fun n k ->\n\tlet m = ref 0 in\n\tlet i = ref 3 in\n\tlet last = ref 2 in\n\tlet _ = while (!i) <= n/2+1 do\n\t\tif is_prime(!i) then begin\n\t\t\tif !i+ !last+ 1 <= n && is_prime(!i+ !last+ 1)\n\t\t\tthen (incr m);\n\t\t\tlast := (!i)\n\t\tend;\n\t\ti := (!i) + 2;\n\tdone in\n\tif (!m) < k then \"NO\" else \"YES\"\n));;\n"}], "src_uid": "afd2b818ed3e2a931da9d682f6ad660d"} {"source_code": "let nombre = ref (read_int ()) and nb_avant = ref 0 and puissance = ref 1;;\nwhile !nombre > 0 do\n\tif !nombre mod 10 = 7 then nb_avant := !nb_avant + !puissance;\n\tpuissance := !puissance * 2;\n\tnombre := !nombre / 10\ndone;;\nprint_int (!nb_avant + !puissance - 1);;\nprint_newline ();;\n", "positive_code": [{"source_code": "let rec puiss = function\n\t|0\t-> 1\n\t|n\t-> let demi = puiss (n/2) in\n\t\t\t(1 + n mod 2) * demi * demi\n\nlet f = function '4' -> 1 | '7' -> 2\n\nlet rec place mot long n =\n\tif n = long\n\t\tthen 0\n\t\telse (f (mot.[n]))*(puiss (long-n-1)) + place mot long (n+1)\n\nlet final n =\n\tlet mot = string_of_int n in\n\tplace mot (String.length mot) 0\n\nlet () =\n\tlet n = Scanf.scanf \"%d\" (fun i -> i) in\n\t\tPrintf.printf \"%d\" (final n)\n"}], "negative_code": [], "src_uid": "6a10bfe8b3da9c11167e136b3c6fb2a3"} {"source_code": "let solve () = \n let a = Pervasives.read_line () in\n let b = Pervasives.read_line () in\n let l = String.length a in\n let rec loop i result = \n if i < l\n then\n if a.[i] = b.[i]\n then\n loop (i + 1) (0 :: result)\n else\n loop (i + 1) (1 :: result)\n else\n List.rev result\n in loop 0 []\n\nlet () = List.iter(Printf.printf \"%d\") (solve ())", "positive_code": [{"source_code": "let a = read_line () in\nString.iter (fun c ->\n\tprint_char (if c <> (input_char stdin) then '1' else '0')\n) a;;\n"}, {"source_code": "(fun x y -> for i = 0 to String.length x - 1 do ( print_string(if String.get x i == String.get y i then \"0\" else \"1\") ) done ) (read_line()) (read_line())\n"}], "negative_code": [], "src_uid": "3714b7596a6b48ca5b7a346f60d90549"} {"source_code": "let read () = Pervasives.read_line ()\n\nlet get_strings () = \n let host = read () in\n let guest = read () in\n let letters = read () in\n let names = host ^ guest in\n (letters, names)\n\nlet str_to_list s =\n let rec loop i l =\n if i < 0 \n then \n l \n else \n loop (i - 1) (s.[i] :: l)\n in loop (String.length s - 1) []\n\nlet solve (letters, names) = \n let letters_sorted = List.sort Pervasives.compare (str_to_list letters) in\n let names_sorted = List.sort Pervasives.compare (str_to_list names) in\n if (Pervasives.compare letters_sorted names_sorted) = 0\n then\n \"YES\"\n else\n \"NO\"\n\nlet print result = Printf.printf \"%s\\n\" result\nlet () = print (solve (get_strings ()))", "positive_code": [{"source_code": "\nlet charlist_of_string str =\n let n = String.length str in\n let rec iter i cl =\n if i < 0 then\n cl\n else\n let sc = str.[i] in\n iter (i-1) (sc :: cl)\n in iter (n-1) []\n\nlet s1 = charlist_of_string (read_line ());;\nlet s2 = charlist_of_string (read_line ());;\nlet s3 = charlist_of_string (read_line ());;\n\n\nlet _ =\n let s4 = List.append s1 s2 in\n let s5 = List.sort Char.compare s4 in\n let s6 = List.sort Char.compare s3 in\n let rec compare x =\n match x with\n | ([], []) -> true\n | (r1 :: res1, r2 :: res2) ->\n if r1 = r2 then compare (res1, res2)\n else false\n | _ -> false\n in\n if compare (s5, s6) then\n print_endline \"YES\"\n else\n print_endline \"NO\";;\n\n"}, {"source_code": "let a = Scanf.scanf \"%s\\n\" (fun x->x);;\nlet b = Scanf.scanf \"%s\\n\" (fun x->x);;\nlet l = Scanf.scanf \"%s\\n\" (fun x->x);;\n\nlet letters = Hashtbl.create 0;;\n\nString.iter (fun c ->\n\tif Hashtbl.mem letters c then\n\t\tHashtbl.replace letters c (Hashtbl.find letters c + 1)\n\telse\n\t\tHashtbl.add letters c 1\n) l;;\n\nlet it c =\n\ttry\n\t\tHashtbl.replace letters c (Hashtbl.find letters c - 1)\n\twith _ -> (print_string \"NO\";exit 0)\n;;\n\nString.iter it a;;\nString.iter it b;;\n\nHashtbl.iter (fun _ x ->\n\tif x <> 0 then begin print_string \"NO\"; exit 0 end\n) letters;;\n\nprint_string \"YES\";;\n"}, {"source_code": "let list_of_string str =\n let rec loop i lst =\n match i with\n | -1 -> lst\n | i -> loop (i-1) ((String.get str i) :: lst)\n in\n loop ((String.length str)-1) []\n\nlet sort lst = List.sort compare lst\n\nlet equal lst1 lst2 =\n let rec loop lst1 lst2 =\n match lst1 with\n\t| [] -> lst2 = []\n\t| h :: t ->\n\t if h = List.hd lst2 then loop t (List.tl lst2)\n\t else false\n in\n if List.length lst1 < List.length lst2\n then loop lst1 lst2\n else loop lst2 lst1\n \nlet solve guest_name host_name shuffled_name =\n let guest_name = list_of_string guest_name in\n let host_name = list_of_string host_name in\n let shuffled_name = list_of_string shuffled_name in\n if equal (sort (guest_name @ host_name)) (sort shuffled_name)\n then \"YES\"\n else \"NO\"\n\nlet _ =\n let guest_name = Scanf.scanf \"%s\\n\" (fun s -> s) in\n let host_name = Scanf.scanf \"%s\\n\" (fun s -> s) in\n let shuffled_name = Scanf.scanf \"%s\\n\" (fun s -> s) in\n begin\n Printf.printf \"%s\\n\" (solve guest_name host_name shuffled_name)\n end\n"}, {"source_code": "\n(* Codeforces 141A *)\n\nlet string_to_char_list s =\n let len = String.length s in\n let rec inner l = function\n | 0 -> s.[0] :: l\n | i -> inner (s.[i] :: l) (i-1)\n in\n inner [] (len-1)\n\nlet _ =\n let guest = read_line() in\n let host = read_line() in\n let shuffled_letters = read_line() in\n let buf1 =\n List.sort compare ((string_to_char_list guest) @\n\t (string_to_char_list host)) in\n let buf2 = List.sort compare (string_to_char_list (shuffled_letters)) in\n let answer = \n if (buf1 = buf2)\n then \"YES\"\n else \"NO\"\n in\n print_endline answer\n \n"}, {"source_code": "\n(* Codeforces 141A *)\n\nlet string_to_char_list s =\n let len = String.length s in\n let rec inner l = function\n | 0 -> s.[0] :: l\n | i -> inner (s.[i] :: l) (i-1)\n in\n inner [] (len-1)\n\nlet _ =\n let guest = read_line() in\n let host = read_line() in\n let shuffled_letters = read_line() in\n let buf1 = List.sort Char.compare (string_to_char_list (guest^host)) in\n let buf2 = List.sort Char.compare (string_to_char_list (shuffled_letters)) in\n let answer = \n if (buf1 = buf2)\n then \"YES\"\n else \"NO\"\n in\n Printf.printf \"%s\\n\" answer\n \n"}], "negative_code": [{"source_code": "let a = Scanf.scanf \"%s\\n\" (fun x->x);;\nlet b = Scanf.scanf \"%s\\n\" (fun x->x);;\nlet l = Scanf.scanf \"%s\\n\" (fun x->x);;\n\nlet letters = Hashtbl.create 0;;\n\nString.iter (fun c ->\n\tif Hashtbl.mem letters c then\n\t\tHashtbl.replace letters c (Hashtbl.find letters c + 1)\n\telse\n\t\tHashtbl.add letters c 1\n) l;;\n\nlet it c =\n\ttry\n\t\tHashtbl.replace letters c (Hashtbl.find letters c - 1)\n\twith _ -> (print_string \"NO\";exit 0)\n;;\n\nString.iter it a;;\nString.iter it b;;\n\nHashtbl.iter (fun _ x ->\n\tif x < 0 then begin print_string \"NO\"; exit 0 end\n) letters;;\n\nprint_string \"YES\";;\n"}, {"source_code": "let x, y = Scanf.scanf \"%f %f %f\\n\" (fun a x y -> ( x /. a , y /. a -. 1.));;\n\nif (x < 0.5) && (x > -0.5) && (y < 0.0) && (y > -1.0) then begin\n\tprint_string \"1\";\n\texit 0;\nend;;\n\nif (y -. (floor y)) = 0. then begin\n\tprint_string \"-1\";\n\texit 0;\nend;;\n\nif (int_of_float (floor y)) mod 2 = 0 then begin\n\tif (x < 0.5) && (x > -0.5) then begin\n\t\tprint_int ((int_of_float (floor y)) / 2 * 3 + 2);\n\tend else begin\n\t\tprint_string \"-1\";\n\t\texit 0;\n\tend\nend else begin\n\tif ((x > 0.) && (x < 1.)) then begin\n\t\tprint_int ((int_of_float (floor y)) / 2 * 3 + 4);\n\tend else if ((x > -1.) && (x < 0.)) then begin\n\t\tprint_int ((int_of_float (floor y)) / 2 * 3 + 3);\n\tend else begin\n\t\tprint_string \"-1\";\n\t\texit 0;\n\tend\nend;;\n"}], "src_uid": "b6456a39d38fabcd25267793ed94d90c"} {"source_code": "open Printf\nopen String\nopen Bigarray\nopen Num\n \nlet (n1,k,d) = Scanf.scanf \"%d %d %d \" (fun x y z -> (x,y,z));;\n\nlet dp = Array.init (n1+2) (fun _ -> Array.make 3 (num_of_int (-10)) )\n\nlet modn = num_of_int 1000000007\n \nlet rec ways n flag =\n if n= 0 then\n if flag=1 then num_of_int 1\n else num_of_int 0\n else if n< 0 then\n num_of_int 0\n else\n begin\n let x = dp.(n).(flag) in\n if x >=/ num_of_int 0 then\n x\n else\n begin\n let cnt = ref (num_of_int 0) in\n for i = 1 to d-1 do\n cnt := !cnt +/ (ways (n-i) flag)\n done;\n for i = d to k do\n cnt := !cnt +/ (ways (n-i) 1)\n done; cnt:=mod_num !cnt modn; dp.(n).(flag)<- !cnt; !cnt\n end\n end\n \nlet rslt = ways n1 0\n \nlet _ = printf \"%s\\n\" (string_of_num rslt)\n", "positive_code": [{"source_code": "(* compiled on 64-bit system with ocamlopt -pp camlp4o $file *)\n\nopen Printf\nopen Scanf\nopen Array\n\nmodule S = String\nmodule Q = Queue\nmodule T = Stack\nmodule H = Hashtbl\nmodule L = List\n\n(* misc *)\nlet neg_compare x y = - compare x y\nlet min3 a b c = min a (min b c)\nlet mid3 a b c = if a < b then max a (min b c) else max b (min a c) \nlet max3 a b c = max a (max b c)\nlet min4 a b c d = min (min a b) (min c d)\nlet max4 a b c d = max (max a b) (max c d)\nlet itb a = a <> 0\nlet bti b = if b then 1 else 0\nlet rec bsearch_min a b test =\n if b - a = 1 then b else \n let mid = (a-b)/2 + b in \n if test mid then bsearch_min a mid test else \n bsearch_min mid b test\nlet rec bsearch_max a b test = \n if b - a = 1 then a else \n let mid = (a-b)/2 + b in \n if test mid then bsearch_max mid b test else \n bsearch_max a mid test\n(* int *)\nlet sqrt_floor n = bsearch_max 0 (1 lsl 31) (fun i -> i*i <= n)\nlet sqrt_ceil n = bsearch_min (-1) (1 lsl 31) (fun i -> n <= i*i) \n(* float *)\nlet round f = truncate (f +. 0.5)\nlet inv_float f = 1. /. f\n(* functional *)\nlet id x = x\nlet const x _ = x\nlet (|>) x f = f x\nlet (^>) x f = f x\nlet (@@) a b = a b \nlet on g f a b = g (f a) (f b)\nlet rec fix f = f (fun x -> fix f x)\nlet ift cond a = if cond then a\nlet ifte cond a b = if cond then a else b\nlet rec for_ i len c f = if i = len then c else for_ (i+1) len (f i c) f\n(* predicate *)\nlet is_odd x = x land 1 = 1\nlet is_even x = x land 1 = 0\n(* option *)\nlet is_none = function | Some _ -> false | None -> true\nlet is_some = function | Some _ -> true | None -> false\nlet default x = function Some y -> y | None -> x\n(* ref *)\nlet (+=) a b = a := !a + b\nlet (-=) a b = a := !a - b \nlet ( *= ) a b = a := !a * b\nlet assign_min x y = x := min !x y \nlet assign_max x y = x := max !x y\n(* array *) \nlet set_min x i v = x.(i) <- min x.(i) v \nlet set_max x i v = x.(i) <- max x.(i) v \nlet swap arr i j = let t = arr.(i) in arr.(i) <- arr.(j); arr.(j) <- t \n(* int, int *)\nlet (++) (a,b) (c,d) = (a+c,b+d)\nlet (--) (a,b) (c,d) = (a-c,b-d)\n(* Arithmetic *)\nlet negate x = -x\nlet rec factorial n = if n = 0 then 1 else n * factorial (n-1)\nlet rec gcd a b = if b = 0 then a else gcd b (a mod b)\nlet rec extgcd a b = \n if b = 0 then 1,0,a else\n let x,y,g = extgcd b (a mod b) in \n y,x-(a/b)*y,g\nlet rec pow x n = if n = 0 then 1 else\n let n' = n/2 in\n let p = pow x n' in\n if is_odd n then x*p*p else p*p\nlet rec modpow m x n = \n if n = 0 then 1 else \n let n' = n/2 in\n let p = modpow m x n' in \n if is_even n then (p*p mod m) else\n (x*(p*p mod m) mod m) \nlet modinv m i = let _,x,_ = extgcd m i in x\n(* IO *)\nlet is_digit c =\n let i = int_of_char c in\n 48 <= i && i < 58\nlet is_space c = c = ' ' || c = '\\n' || c = '\\t' || c = '\\r' \nlet read_char () = try input_char stdin with End_of_file -> '\\000'\nlet rec read_letter () = \n let c = read_char() in \n if is_space c then read_letter() else c \nlet read_int () = \n let digit c = int_of_char c - 48 in\n let rec read n = \n let c = read_char() in \n if is_digit c then read (10*n + (digit c)) else \n n \n in\n let rec run c = \n if is_digit c then read (digit c) else \n if c = '-' then begin \n let c = read_char() in \n if is_digit c then -read (digit c) else run c \n end else \n if c = '\\000' then 0 else \n run (read_char())\n in \n run (read_char())\nlet read_float () = \n let digit c = float (int_of_char c - 48) in\n let rec read_decimial m f = \n let c = read_char () in \n if is_digit c then read_decimial (m /. 10.) (f +. m *. digit c) else f\n in \n let rec read_integral n = \n let c = read_char () in \n if is_digit c then read_integral (10. *. n +. digit c) else \n if c = '.' then n +. read_decimial 0.1 0.0 else \n n \n in \n let rec run c = begin \n if is_digit c then read_integral (digit c) else \n if c = '-' then begin \n let c = read_char() in \n if is_digit c then -. read_integral (digit c) else \n run c \n end else \n if c = '.' then read_decimial 0.1 0.0 else \n if c = '\\000' then 0.0 else \n run (read_char())\n end in \n run (read_char())\nlet read_word () = \n let open Buffer in \n let buf = create 128 in \n let rec read c = \n if is_space c || c = '\\000' then contents buf else begin \n add_char buf c; \n read (read_char())\n end \n in\n let rec run c = \n if is_space c then run (read_char()) else \n if c = '\\000' then \"\" else \n read c \n in \n run (read_char())\nlet read_line () = \n let open Buffer in \n let buf = create (4*1024) in \n let rec run c = \n if c = '\\n' || c = '\\000' then contents buf else begin \n add_char buf c;\n run (read_char())\n end \n in\n run (read_char()) \nlet newline () = print_newline()\nlet print_int n = printf \"%d\\n\" n\nlet print_tuple s (x,y) = printf s x y \nlet print_array s arr = Array.iter (printf s) arr; print_newline()\nlet print_matrix s mat = Array.iter (print_array s) mat\nlet print_list s lis = List.iter (printf s) lis; print_newline()\n;;\n\nlet read_int64 () = \n let digit c = Int64.of_int( int_of_char c - 48 )in\n let rec read n = \n let c = read_char() in \n if is_digit c then read (Int64.add (Int64.mul 10L n) (digit c)) else \n n \n in\n let rec run c = \n if is_digit c then read (digit c) else \n if c = '-' then begin \n let c = read_char() in \n if is_digit c then Int64.neg (read (digit c)) else run c \n end else \n if c = '\\000' then 0L else \n run (read_char())\n in \n run (read_char())\n\nmodule LL = struct \n include Int64\n let (+) a b = add a b \n let (-) a b = sub a b \n let ( * ) a b = mul a b \n let (/) a b = div a b \n let (mod) a b = rem a b \n let (land) a b = logand a b \n let (lor) a b = logor a b \n let (lxor) a b = logxor a b \n let (lnot) a = lognot a \nend \n\nlet modulo = 1_000_000_007L\n\nlet isum n up = \n let arr = make (LL.to_int n + 1) (-1L) in\n let read n = arr.(LL.to_int n) in \n let save n v = arr.(LL.to_int n) <- v; v in \n\n let rec run (n: int64) = LL.(\n if read n <> -1L then read n else \n let ans = \n if n <= 1L then 1L else \n let t = 2L * run (n-1L) mod modulo in \n if n <= up then t else \n (t - run (n-1L-up)) mod modulo \n in \n save n ans \n ) in \n if up = 0L then 0L else LL.((run n + modulo) mod modulo)\n\nlet _ = \n let n = read_int64() in \n let k = read_int64() in \n let d = read_int64() in \n let ans = LL.( (isum n k - isum n (d-1L) + modulo) mod modulo) in \n printf \"%s\\n\" (LL.to_string ans) \n\n(* let _ = \n for i = 0 to 10 do \n let i = LL.of_int i in \n printf \"%s\\n\" (LL.to_string (isum i i))\n done *)"}, {"source_code": "open Printf\nopen Scanf\n\nlet read_int () = bscanf Scanning.stdib \" %d \" (fun x -> x)\n\nlet mm = 1000000007L\n\nlet ( ++ ) a b = \n let a = Int64.of_int a in\n let b = Int64.of_int b in\n let ans = Int64.rem (Int64.add a b) mm in\n Int64.to_int ans\n\nlet () = \n let n = read_int () in\n let k = read_int () in\n let d = read_int () in\n\n let a = Array.make_matrix (n+1) (n+k+1) 0 in\n let b = Array.make_matrix (n+1) (n+k+1) 0 in\n\n a.(0).(0) <- 1;\n\n let count = ref 0 in\n\n let rec pass i = \n (* job is to fill in the i+1 st position and continue *)\n if i+1 > n then () else (\n for s=0 to n do\n\tfor v = 1 to k do\n\t if v < d then a.(i+1).(s+v) <- a.(i+1).(s+v) ++ a.(i).(s);\n\t b.(i+1).(s+v) <- b.(i+1).(s+v) ++ b.(i).(s);\n\t if v >= d then b.(i+1).(s+v) <- b.(i+1).(s+v) ++ a.(i).(s);\n\tdone\n done;\n count := !count ++ b.(i+1).(n);\n pass (i+1)\n )\n in\n\n pass 0;\n\n printf \"%d\\n\" !count\n"}], "negative_code": [{"source_code": "open Printf\nopen Scanf\n\nlet read_int () = bscanf Scanning.stdib \" %d \" (fun x -> x)\n\nlet mm = 1000000007L\n\nlet ( ++ ) a b = \n let a = Int64.of_int a in\n let b = Int64.of_int b in\n let ans = Int64.rem (Int64.add a b) mm in\n Int64.to_int ans\n\nlet () = \n let n = read_int () in\n let k = read_int () in\n let d = read_int () in\n\n let a = Array.make_matrix (n+1) (n+k+1) 0 in\n let b = Array.make_matrix (n+1) (n+k+1) 0 in\n\n a.(0).(0) <- 1;\n\n let count = ref 0 in\n\n let rec pass i = \n (* job is to fill in the i+1 st position and continue *)\n if i+1 > n then () else (\n for s=0 to n do\n\tfor v = 1 to k do\n\t if v < d then a.(i+1).(s+v) <- a.(i+1).(s+v) + a.(i).(s);\n\t b.(i+1).(s+v) <- b.(i+1).(s+v) + b.(i).(s);\n\t if v >= d then b.(i+1).(s+v) <- b.(i+1).(s+v) + a.(i).(s);\n\tdone\n done;\n count := !count ++ b.(i+1).(n);\n pass (i+1)\n )\n in\n\n pass 0;\n\n printf \"%d\\n\" !count\n"}, {"source_code": "open Printf\nopen String\nopen Bigarray\n\nlet (n1,k,d) = Scanf.scanf \"%d %d %d \" (fun x y z -> (x,y,z));;\n\nlet dp = Array.init (n1+2) (fun _ -> Array.make 3 (-10) )\n \n \nlet rec ways n flag =\n if n= 0 then\n if flag=1 then 1\n else 0\n else if n<0 then\n 0\n else\n begin\n let x = dp.(n).(flag) in\n if x >=0 then\n x\n else\n begin\n let cnt = ref 0 in\n for i = 1 to d-1 do\n cnt := !cnt + (ways (n-i) flag)\n done;\n for i = d to k do\n cnt := !cnt + (ways (n-i) 1)\n done; dp.(n).(flag)<- !cnt; !cnt\n end\n end\n \nlet rslt = ways n1 0\n \nlet _ = printf \"%d\\n\" rslt\n"}, {"source_code": "(* compiled on 64-bit system with ocamlopt -pp camlp4o $file *)\n\nopen Printf\nopen Scanf\nopen Array\n\nmodule S = String\nmodule Q = Queue\nmodule T = Stack\nmodule H = Hashtbl\nmodule L = List\n\n(* misc *)\nlet neg_compare x y = - compare x y\nlet min3 a b c = min a (min b c)\nlet mid3 a b c = if a < b then max a (min b c) else max b (min a c) \nlet max3 a b c = max a (max b c)\nlet min4 a b c d = min (min a b) (min c d)\nlet max4 a b c d = max (max a b) (max c d)\nlet itb a = a <> 0\nlet bti b = if b then 1 else 0\nlet rec bsearch_min a b test =\n if b - a = 1 then b else \n let mid = (a-b)/2 + b in \n if test mid then bsearch_min a mid test else \n bsearch_min mid b test\nlet rec bsearch_max a b test = \n if b - a = 1 then a else \n let mid = (a-b)/2 + b in \n if test mid then bsearch_max mid b test else \n bsearch_max a mid test\n(* int *)\nlet sqrt_floor n = bsearch_max 0 (1 lsl 31) (fun i -> i*i <= n)\nlet sqrt_ceil n = bsearch_min (-1) (1 lsl 31) (fun i -> n <= i*i) \n(* float *)\nlet round f = truncate (f +. 0.5)\nlet inv_float f = 1. /. f\n(* functional *)\nlet id x = x\nlet const x _ = x\nlet (|>) x f = f x\nlet (^>) x f = f x\nlet (@@) a b = a b \nlet on g f a b = g (f a) (f b)\nlet rec fix f = f (fun x -> fix f x)\nlet ift cond a = if cond then a\nlet ifte cond a b = if cond then a else b\nlet rec for_ i len c f = if i = len then c else for_ (i+1) len (f i c) f\n(* predicate *)\nlet is_odd x = x land 1 = 1\nlet is_even x = x land 1 = 0\n(* option *)\nlet is_none = function | Some _ -> false | None -> true\nlet is_some = function | Some _ -> true | None -> false\nlet default x = function Some y -> y | None -> x\n(* ref *)\nlet (+=) a b = a := !a + b\nlet (-=) a b = a := !a - b \nlet ( *= ) a b = a := !a * b\nlet assign_min x y = x := min !x y \nlet assign_max x y = x := max !x y\n(* array *) \nlet set_min x i v = x.(i) <- min x.(i) v \nlet set_max x i v = x.(i) <- max x.(i) v \nlet swap arr i j = let t = arr.(i) in arr.(i) <- arr.(j); arr.(j) <- t \n(* int, int *)\nlet (++) (a,b) (c,d) = (a+c,b+d)\nlet (--) (a,b) (c,d) = (a-c,b-d)\n(* Arithmetic *)\nlet negate x = -x\nlet rec factorial n = if n = 0 then 1 else n * factorial (n-1)\nlet rec gcd a b = if b = 0 then a else gcd b (a mod b)\nlet rec extgcd a b = \n if b = 0 then 1,0,a else\n let x,y,g = extgcd b (a mod b) in \n y,x-(a/b)*y,g\nlet rec pow x n = if n = 0 then 1 else\n let n' = n/2 in\n let p = pow x n' in\n if is_odd n then x*p*p else p*p\nlet rec modpow m x n = \n if n = 0 then 1 else \n let n' = n/2 in\n let p = modpow m x n' in \n if is_even n then (p*p mod m) else\n (x*(p*p mod m) mod m) \nlet modinv m i = let _,x,_ = extgcd m i in x\n(* IO *)\nlet is_digit c =\n let i = int_of_char c in\n 48 <= i && i < 58\nlet is_space c = c = ' ' || c = '\\n' || c = '\\t' || c = '\\r' \nlet read_char () = try input_char stdin with End_of_file -> '\\000'\nlet rec read_letter () = \n let c = read_char() in \n if is_space c then read_letter() else c \nlet read_int () = \n let digit c = int_of_char c - 48 in\n let rec read n = \n let c = read_char() in \n if is_digit c then read (10*n + (digit c)) else \n n \n in\n let rec run c = \n if is_digit c then read (digit c) else \n if c = '-' then begin \n let c = read_char() in \n if is_digit c then -read (digit c) else run c \n end else \n if c = '\\000' then 0 else \n run (read_char())\n in \n run (read_char())\nlet read_float () = \n let digit c = float (int_of_char c - 48) in\n let rec read_decimial m f = \n let c = read_char () in \n if is_digit c then read_decimial (m /. 10.) (f +. m *. digit c) else f\n in \n let rec read_integral n = \n let c = read_char () in \n if is_digit c then read_integral (10. *. n +. digit c) else \n if c = '.' then n +. read_decimial 0.1 0.0 else \n n \n in \n let rec run c = begin \n if is_digit c then read_integral (digit c) else \n if c = '-' then begin \n let c = read_char() in \n if is_digit c then -. read_integral (digit c) else \n run c \n end else \n if c = '.' then read_decimial 0.1 0.0 else \n if c = '\\000' then 0.0 else \n run (read_char())\n end in \n run (read_char())\nlet read_word () = \n let open Buffer in \n let buf = create 128 in \n let rec read c = \n if is_space c || c = '\\000' then contents buf else begin \n add_char buf c; \n read (read_char())\n end \n in\n let rec run c = \n if is_space c then run (read_char()) else \n if c = '\\000' then \"\" else \n read c \n in \n run (read_char())\nlet read_line () = \n let open Buffer in \n let buf = create (4*1024) in \n let rec run c = \n if c = '\\n' || c = '\\000' then contents buf else begin \n add_char buf c;\n run (read_char())\n end \n in\n run (read_char()) \nlet newline () = print_newline()\nlet print_int n = printf \"%d\\n\" n\nlet print_tuple s (x,y) = printf s x y \nlet print_array s arr = Array.iter (printf s) arr; print_newline()\nlet print_matrix s mat = Array.iter (print_array s) mat\nlet print_list s lis = List.iter (printf s) lis; print_newline()\n;;\n\nlet read_int64 () = \n let digit c = Int64.of_int( int_of_char c - 48 )in\n let rec read n = \n let c = read_char() in \n if is_digit c then read (Int64.add (Int64.mul 10L n) (digit c)) else \n n \n in\n let rec run c = \n if is_digit c then read (digit c) else \n if c = '-' then begin \n let c = read_char() in \n if is_digit c then Int64.neg (read (digit c)) else run c \n end else \n if c = '\\000' then 0L else \n run (read_char())\n in \n run (read_char())\n\nmodule LL = struct \n include Int64\n let (+) a b = add a b \n let (-) a b = sub a b \n let ( * ) a b = mul a b \n let (/) a b = div a b \n let (mod) a b = rem a b \n let (land) a b = logand a b \n let (lor) a b = logor a b \n let (lxor) a b = logxor a b \n let (lnot) a = lognot a \nend \n\nlet modulo = 1_000_000_007L\n\nlet isum n up = \n let arr = make (LL.to_int n + 1) (-1L) in\n let read n = arr.(LL.to_int n) in \n let save n v = arr.(LL.to_int n) <- v; v in \n\n let rec run (n: int64) = LL.(\n if read n <> -1L then read n else \n let ans = \n if n <= 1L then 1L else \n let t = 2L * run (n-1L) mod modulo in \n if n <= up then t else \n (t - run (n-1L-up)) mod modulo \n in \n save n ans \n ) in \n if up = 0L then 0L else run n\n\nlet _ = \n let n = read_int64() in \n let k = read_int64() in \n let d = read_int64() in \n let ans = LL.( (isum n k - isum n (d-1L) ) mod modulo) in \n printf \"%s\\n\" (LL.to_string ans) \n\n(* let _ = \n for i = 0 to 10 do \n let i = LL.of_int i in \n printf \"%s\\n\" (LL.to_string (isum i i))\n done *)"}, {"source_code": "(* compiled on 64-bit system with ocamlopt -pp camlp4o $file *)\n\nopen Printf\nopen Scanf\nopen Array\n\nmodule S = String\nmodule Q = Queue\nmodule T = Stack\nmodule H = Hashtbl\nmodule L = List\n\n(* misc *)\nlet neg_compare x y = - compare x y\nlet min3 a b c = min a (min b c)\nlet mid3 a b c = if a < b then max a (min b c) else max b (min a c) \nlet max3 a b c = max a (max b c)\nlet min4 a b c d = min (min a b) (min c d)\nlet max4 a b c d = max (max a b) (max c d)\nlet itb a = a <> 0\nlet bti b = if b then 1 else 0\nlet rec bsearch_min a b test =\n if b - a = 1 then b else \n let mid = (a-b)/2 + b in \n if test mid then bsearch_min a mid test else \n bsearch_min mid b test\nlet rec bsearch_max a b test = \n if b - a = 1 then a else \n let mid = (a-b)/2 + b in \n if test mid then bsearch_max mid b test else \n bsearch_max a mid test\n(* int *)\nlet sqrt_floor n = bsearch_max 0 (1 lsl 31) (fun i -> i*i <= n)\nlet sqrt_ceil n = bsearch_min (-1) (1 lsl 31) (fun i -> n <= i*i) \n(* float *)\nlet round f = truncate (f +. 0.5)\nlet inv_float f = 1. /. f\n(* functional *)\nlet id x = x\nlet const x _ = x\nlet (|>) x f = f x\nlet (^>) x f = f x\nlet (@@) a b = a b \nlet on g f a b = g (f a) (f b)\nlet rec fix f = f (fun x -> fix f x)\nlet ift cond a = if cond then a\nlet ifte cond a b = if cond then a else b\nlet rec for_ i len c f = if i = len then c else for_ (i+1) len (f i c) f\n(* predicate *)\nlet is_odd x = x land 1 = 1\nlet is_even x = x land 1 = 0\n(* option *)\nlet is_none = function | Some _ -> false | None -> true\nlet is_some = function | Some _ -> true | None -> false\nlet default x = function Some y -> y | None -> x\n(* ref *)\nlet (+=) a b = a := !a + b\nlet (-=) a b = a := !a - b \nlet ( *= ) a b = a := !a * b\nlet assign_min x y = x := min !x y \nlet assign_max x y = x := max !x y\n(* array *) \nlet set_min x i v = x.(i) <- min x.(i) v \nlet set_max x i v = x.(i) <- max x.(i) v \nlet swap arr i j = let t = arr.(i) in arr.(i) <- arr.(j); arr.(j) <- t \n(* int, int *)\nlet (++) (a,b) (c,d) = (a+c,b+d)\nlet (--) (a,b) (c,d) = (a-c,b-d)\n(* Arithmetic *)\nlet negate x = -x\nlet rec factorial n = if n = 0 then 1 else n * factorial (n-1)\nlet rec gcd a b = if b = 0 then a else gcd b (a mod b)\nlet rec extgcd a b = \n if b = 0 then 1,0,a else\n let x,y,g = extgcd b (a mod b) in \n y,x-(a/b)*y,g\nlet rec pow x n = if n = 0 then 1 else\n let n' = n/2 in\n let p = pow x n' in\n if is_odd n then x*p*p else p*p\nlet rec modpow m x n = \n if n = 0 then 1 else \n let n' = n/2 in\n let p = modpow m x n' in \n if is_even n then (p*p mod m) else\n (x*(p*p mod m) mod m) \nlet modinv m i = let _,x,_ = extgcd m i in x\n(* IO *)\nlet is_digit c =\n let i = int_of_char c in\n 48 <= i && i < 58\nlet is_space c = c = ' ' || c = '\\n' || c = '\\t' || c = '\\r' \nlet read_char () = try input_char stdin with End_of_file -> '\\000'\nlet rec read_letter () = \n let c = read_char() in \n if is_space c then read_letter() else c \nlet read_int () = \n let digit c = int_of_char c - 48 in\n let rec read n = \n let c = read_char() in \n if is_digit c then read (10*n + (digit c)) else \n n \n in\n let rec run c = \n if is_digit c then read (digit c) else \n if c = '-' then begin \n let c = read_char() in \n if is_digit c then -read (digit c) else run c \n end else \n if c = '\\000' then 0 else \n run (read_char())\n in \n run (read_char())\nlet read_float () = \n let digit c = float (int_of_char c - 48) in\n let rec read_decimial m f = \n let c = read_char () in \n if is_digit c then read_decimial (m /. 10.) (f +. m *. digit c) else f\n in \n let rec read_integral n = \n let c = read_char () in \n if is_digit c then read_integral (10. *. n +. digit c) else \n if c = '.' then n +. read_decimial 0.1 0.0 else \n n \n in \n let rec run c = begin \n if is_digit c then read_integral (digit c) else \n if c = '-' then begin \n let c = read_char() in \n if is_digit c then -. read_integral (digit c) else \n run c \n end else \n if c = '.' then read_decimial 0.1 0.0 else \n if c = '\\000' then 0.0 else \n run (read_char())\n end in \n run (read_char())\nlet read_word () = \n let open Buffer in \n let buf = create 128 in \n let rec read c = \n if is_space c || c = '\\000' then contents buf else begin \n add_char buf c; \n read (read_char())\n end \n in\n let rec run c = \n if is_space c then run (read_char()) else \n if c = '\\000' then \"\" else \n read c \n in \n run (read_char())\nlet read_line () = \n let open Buffer in \n let buf = create (4*1024) in \n let rec run c = \n if c = '\\n' || c = '\\000' then contents buf else begin \n add_char buf c;\n run (read_char())\n end \n in\n run (read_char()) \nlet newline () = print_newline()\nlet print_int n = printf \"%d\\n\" n\nlet print_tuple s (x,y) = printf s x y \nlet print_array s arr = Array.iter (printf s) arr; print_newline()\nlet print_matrix s mat = Array.iter (print_array s) mat\nlet print_list s lis = List.iter (printf s) lis; print_newline()\n;;\n\nlet read_int64 () = \n let digit c = Int64.of_int( int_of_char c - 48 )in\n let rec read n = \n let c = read_char() in \n if is_digit c then read (Int64.add (Int64.mul 10L n) (digit c)) else \n n \n in\n let rec run c = \n if is_digit c then read (digit c) else \n if c = '-' then begin \n let c = read_char() in \n if is_digit c then Int64.neg (read (digit c)) else run c \n end else \n if c = '\\000' then 0L else \n run (read_char())\n in \n run (read_char())\n\nmodule LL = struct \n include Int64\n let (+) a b = add a b \n let (-) a b = sub a b \n let ( * ) a b = mul a b \n let (/) a b = div a b \n let (mod) a b = rem a b \n let (land) a b = logand a b \n let (lor) a b = logor a b \n let (lxor) a b = logxor a b \n let (lnot) a = lognot a \nend \n\nlet modulo = 1_000_000_007L\n\nlet isum n up = \n let arr = make (LL.to_int n + 1) (-1L) in\n let read n = arr.(LL.to_int n) in \n let save n v = arr.(LL.to_int n) <- v; v in \n\n let rec run (n: int64) = LL.(\n if read n <> -1L then read n else \n let ans = \n if n <= 1L then 1L else \n if up < 1L then 0L else \n if n <= up then 2L * run (n-1L) mod modulo else \n (2L * run (n-1L) - run (n-1L-up)) mod modulo \n in \n save n ans \n ) in \n run n\n\nlet _ = \n let n = read_int64() in \n let k = read_int64() in \n let d = read_int64() in \n let ans = LL.( (isum n k - isum n (d-1L) ) mod modulo) in \n printf \"%s\\n\" (LL.to_string ans) \n"}, {"source_code": "(* compiled on 64-bit system with ocamlopt -pp camlp4o $file *)\n\nopen Printf\nopen Scanf\nopen Array\n\nmodule S = String\nmodule Q = Queue\nmodule T = Stack\nmodule H = Hashtbl\nmodule L = List\n\n(* misc *)\nlet neg_compare x y = - compare x y\nlet min3 a b c = min a (min b c)\nlet mid3 a b c = if a < b then max a (min b c) else max b (min a c) \nlet max3 a b c = max a (max b c)\nlet min4 a b c d = min (min a b) (min c d)\nlet max4 a b c d = max (max a b) (max c d)\nlet itb a = a <> 0\nlet bti b = if b then 1 else 0\nlet rec bsearch_min a b test =\n if b - a = 1 then b else \n let mid = (a-b)/2 + b in \n if test mid then bsearch_min a mid test else \n bsearch_min mid b test\nlet rec bsearch_max a b test = \n if b - a = 1 then a else \n let mid = (a-b)/2 + b in \n if test mid then bsearch_max mid b test else \n bsearch_max a mid test\n(* int *)\nlet sqrt_floor n = bsearch_max 0 (1 lsl 31) (fun i -> i*i <= n)\nlet sqrt_ceil n = bsearch_min (-1) (1 lsl 31) (fun i -> n <= i*i) \n(* float *)\nlet round f = truncate (f +. 0.5)\nlet inv_float f = 1. /. f\n(* functional *)\nlet id x = x\nlet const x _ = x\nlet (|>) x f = f x\nlet (^>) x f = f x\nlet (@@) a b = a b \nlet on g f a b = g (f a) (f b)\nlet rec fix f = f (fun x -> fix f x)\nlet ift cond a = if cond then a\nlet ifte cond a b = if cond then a else b\nlet rec for_ i len c f = if i = len then c else for_ (i+1) len (f i c) f\n(* predicate *)\nlet is_odd x = x land 1 = 1\nlet is_even x = x land 1 = 0\n(* option *)\nlet is_none = function | Some _ -> false | None -> true\nlet is_some = function | Some _ -> true | None -> false\nlet default x = function Some y -> y | None -> x\n(* ref *)\nlet (+=) a b = a := !a + b\nlet (-=) a b = a := !a - b \nlet ( *= ) a b = a := !a * b\nlet assign_min x y = x := min !x y \nlet assign_max x y = x := max !x y\n(* array *) \nlet set_min x i v = x.(i) <- min x.(i) v \nlet set_max x i v = x.(i) <- max x.(i) v \nlet swap arr i j = let t = arr.(i) in arr.(i) <- arr.(j); arr.(j) <- t \n(* int, int *)\nlet (++) (a,b) (c,d) = (a+c,b+d)\nlet (--) (a,b) (c,d) = (a-c,b-d)\n(* Arithmetic *)\nlet negate x = -x\nlet rec factorial n = if n = 0 then 1 else n * factorial (n-1)\nlet rec gcd a b = if b = 0 then a else gcd b (a mod b)\nlet rec extgcd a b = \n if b = 0 then 1,0,a else\n let x,y,g = extgcd b (a mod b) in \n y,x-(a/b)*y,g\nlet rec pow x n = if n = 0 then 1 else\n let n' = n/2 in\n let p = pow x n' in\n if is_odd n then x*p*p else p*p\nlet rec modpow m x n = \n if n = 0 then 1 else \n let n' = n/2 in\n let p = modpow m x n' in \n if is_even n then (p*p mod m) else\n (x*(p*p mod m) mod m) \nlet modinv m i = let _,x,_ = extgcd m i in x\n(* IO *)\nlet is_digit c =\n let i = int_of_char c in\n 48 <= i && i < 58\nlet is_space c = c = ' ' || c = '\\n' || c = '\\t' || c = '\\r' \nlet read_char () = try input_char stdin with End_of_file -> '\\000'\nlet rec read_letter () = \n let c = read_char() in \n if is_space c then read_letter() else c \nlet read_int () = \n let digit c = int_of_char c - 48 in\n let rec read n = \n let c = read_char() in \n if is_digit c then read (10*n + (digit c)) else \n n \n in\n let rec run c = \n if is_digit c then read (digit c) else \n if c = '-' then begin \n let c = read_char() in \n if is_digit c then -read (digit c) else run c \n end else \n if c = '\\000' then 0 else \n run (read_char())\n in \n run (read_char())\nlet read_float () = \n let digit c = float (int_of_char c - 48) in\n let rec read_decimial m f = \n let c = read_char () in \n if is_digit c then read_decimial (m /. 10.) (f +. m *. digit c) else f\n in \n let rec read_integral n = \n let c = read_char () in \n if is_digit c then read_integral (10. *. n +. digit c) else \n if c = '.' then n +. read_decimial 0.1 0.0 else \n n \n in \n let rec run c = begin \n if is_digit c then read_integral (digit c) else \n if c = '-' then begin \n let c = read_char() in \n if is_digit c then -. read_integral (digit c) else \n run c \n end else \n if c = '.' then read_decimial 0.1 0.0 else \n if c = '\\000' then 0.0 else \n run (read_char())\n end in \n run (read_char())\nlet read_word () = \n let open Buffer in \n let buf = create 128 in \n let rec read c = \n if is_space c || c = '\\000' then contents buf else begin \n add_char buf c; \n read (read_char())\n end \n in\n let rec run c = \n if is_space c then run (read_char()) else \n if c = '\\000' then \"\" else \n read c \n in \n run (read_char())\nlet read_line () = \n let open Buffer in \n let buf = create (4*1024) in \n let rec run c = \n if c = '\\n' || c = '\\000' then contents buf else begin \n add_char buf c;\n run (read_char())\n end \n in\n run (read_char()) \nlet newline () = print_newline()\nlet print_int n = printf \"%d\\n\" n\nlet print_tuple s (x,y) = printf s x y \nlet print_array s arr = Array.iter (printf s) arr; print_newline()\nlet print_matrix s mat = Array.iter (print_array s) mat\nlet print_list s lis = List.iter (printf s) lis; print_newline()\n;;\n\nlet read_int64 () = \n let digit c = Int64.of_int( int_of_char c - 48 )in\n let rec read n = \n let c = read_char() in \n if is_digit c then read (Int64.add (Int64.mul 10L n) (digit c)) else \n n \n in\n let rec run c = \n if is_digit c then read (digit c) else \n if c = '-' then begin \n let c = read_char() in \n if is_digit c then Int64.neg (read (digit c)) else run c \n end else \n if c = '\\000' then 0L else \n run (read_char())\n in \n run (read_char())\n\nmodule LL = struct \n include Int64\n let (+) a b = add a b \n let (-) a b = sub a b \n let ( * ) a b = mul a b \n let (/) a b = div a b \n let (mod) a b = rem a b \n let (land) a b = logand a b \n let (lor) a b = logor a b \n let (lxor) a b = logxor a b \n let (lnot) a = lognot a \nend \n\nlet modulo = 1_000_000_007L\n\nlet isum n up = \n let arr = make (LL.to_int n + 1) (-1L) in\n let read n = arr.(LL.to_int n) in \n let save n v = arr.(LL.to_int n) <- v; v in \n\n let rec run (n: int64) = LL.(\n if read n <> -1L then read n else \n let ans = \n if n <= 1L then 1L else \n if n <= up then 2L * run (n-1L) mod modulo else \n (2L * run (n-1L) - run (n-1L-up)) mod modulo \n in \n save n ans \n ) in \n if up = 0L then 0L else run n\n\nlet _ = \n let n = read_int64() in \n let k = read_int64() in \n let d = read_int64() in \n let ans = LL.( (isum n k - isum n (d-1L) ) mod modulo) in \n printf \"%s\\n\" (LL.to_string ans) \n\n(* let _ = \n for i = 0 to 10 do \n let i = LL.of_int i in \n printf \"%s\\n\" (LL.to_string (isum i i))\n done *)"}, {"source_code": "(* compiled on 64-bit system with ocamlopt -pp camlp4o $file *)\n\nopen Printf\nopen Scanf\nopen Array\n\nmodule S = String\nmodule Q = Queue\nmodule T = Stack\nmodule H = Hashtbl\nmodule L = List\n\n(* misc *)\nlet neg_compare x y = - compare x y\nlet min3 a b c = min a (min b c)\nlet mid3 a b c = if a < b then max a (min b c) else max b (min a c) \nlet max3 a b c = max a (max b c)\nlet min4 a b c d = min (min a b) (min c d)\nlet max4 a b c d = max (max a b) (max c d)\nlet itb a = a <> 0\nlet bti b = if b then 1 else 0\nlet rec bsearch_min a b test =\n if b - a = 1 then b else \n let mid = (a-b)/2 + b in \n if test mid then bsearch_min a mid test else \n bsearch_min mid b test\nlet rec bsearch_max a b test = \n if b - a = 1 then a else \n let mid = (a-b)/2 + b in \n if test mid then bsearch_max mid b test else \n bsearch_max a mid test\n(* int *)\nlet sqrt_floor n = bsearch_max 0 (1 lsl 31) (fun i -> i*i <= n)\nlet sqrt_ceil n = bsearch_min (-1) (1 lsl 31) (fun i -> n <= i*i) \n(* float *)\nlet round f = truncate (f +. 0.5)\nlet inv_float f = 1. /. f\n(* functional *)\nlet id x = x\nlet const x _ = x\nlet (|>) x f = f x\nlet (^>) x f = f x\nlet (@@) a b = a b \nlet on g f a b = g (f a) (f b)\nlet rec fix f = f (fun x -> fix f x)\nlet ift cond a = if cond then a\nlet ifte cond a b = if cond then a else b\nlet rec for_ i len c f = if i = len then c else for_ (i+1) len (f i c) f\n(* predicate *)\nlet is_odd x = x land 1 = 1\nlet is_even x = x land 1 = 0\n(* option *)\nlet is_none = function | Some _ -> false | None -> true\nlet is_some = function | Some _ -> true | None -> false\nlet default x = function Some y -> y | None -> x\n(* ref *)\nlet (+=) a b = a := !a + b\nlet (-=) a b = a := !a - b \nlet ( *= ) a b = a := !a * b\nlet assign_min x y = x := min !x y \nlet assign_max x y = x := max !x y\n(* array *) \nlet set_min x i v = x.(i) <- min x.(i) v \nlet set_max x i v = x.(i) <- max x.(i) v \nlet swap arr i j = let t = arr.(i) in arr.(i) <- arr.(j); arr.(j) <- t \n(* int, int *)\nlet (++) (a,b) (c,d) = (a+c,b+d)\nlet (--) (a,b) (c,d) = (a-c,b-d)\n(* Arithmetic *)\nlet negate x = -x\nlet rec factorial n = if n = 0 then 1 else n * factorial (n-1)\nlet rec gcd a b = if b = 0 then a else gcd b (a mod b)\nlet rec extgcd a b = \n if b = 0 then 1,0,a else\n let x,y,g = extgcd b (a mod b) in \n y,x-(a/b)*y,g\nlet rec pow x n = if n = 0 then 1 else\n let n' = n/2 in\n let p = pow x n' in\n if is_odd n then x*p*p else p*p\nlet rec modpow m x n = \n if n = 0 then 1 else \n let n' = n/2 in\n let p = modpow m x n' in \n if is_even n then (p*p mod m) else\n (x*(p*p mod m) mod m) \nlet modinv m i = let _,x,_ = extgcd m i in x\n(* IO *)\nlet is_digit c =\n let i = int_of_char c in\n 48 <= i && i < 58\nlet is_space c = c = ' ' || c = '\\n' || c = '\\t' || c = '\\r' \nlet read_char () = try input_char stdin with End_of_file -> '\\000'\nlet rec read_letter () = \n let c = read_char() in \n if is_space c then read_letter() else c \nlet read_int () = \n let digit c = int_of_char c - 48 in\n let rec read n = \n let c = read_char() in \n if is_digit c then read (10*n + (digit c)) else \n n \n in\n let rec run c = \n if is_digit c then read (digit c) else \n if c = '-' then begin \n let c = read_char() in \n if is_digit c then -read (digit c) else run c \n end else \n if c = '\\000' then 0 else \n run (read_char())\n in \n run (read_char())\nlet read_float () = \n let digit c = float (int_of_char c - 48) in\n let rec read_decimial m f = \n let c = read_char () in \n if is_digit c then read_decimial (m /. 10.) (f +. m *. digit c) else f\n in \n let rec read_integral n = \n let c = read_char () in \n if is_digit c then read_integral (10. *. n +. digit c) else \n if c = '.' then n +. read_decimial 0.1 0.0 else \n n \n in \n let rec run c = begin \n if is_digit c then read_integral (digit c) else \n if c = '-' then begin \n let c = read_char() in \n if is_digit c then -. read_integral (digit c) else \n run c \n end else \n if c = '.' then read_decimial 0.1 0.0 else \n if c = '\\000' then 0.0 else \n run (read_char())\n end in \n run (read_char())\nlet read_word () = \n let open Buffer in \n let buf = create 128 in \n let rec read c = \n if is_space c || c = '\\000' then contents buf else begin \n add_char buf c; \n read (read_char())\n end \n in\n let rec run c = \n if is_space c then run (read_char()) else \n if c = '\\000' then \"\" else \n read c \n in \n run (read_char())\nlet read_line () = \n let open Buffer in \n let buf = create (4*1024) in \n let rec run c = \n if c = '\\n' || c = '\\000' then contents buf else begin \n add_char buf c;\n run (read_char())\n end \n in\n run (read_char()) \nlet newline () = print_newline()\nlet print_int n = printf \"%d\\n\" n\nlet print_tuple s (x,y) = printf s x y \nlet print_array s arr = Array.iter (printf s) arr; print_newline()\nlet print_matrix s mat = Array.iter (print_array s) mat\nlet print_list s lis = List.iter (printf s) lis; print_newline()\n;;\n\nlet isum n up =\n let rec run n = \n if n <= 1 then 1 else \n if n <= up then 2 * run (n-1) else \n 2 * run (n-1) - run (n-1-up) \n in \n run n \n\nlet _ = \n let n = read_int() in \n let k = read_int() in \n let d = read_int() in \n let ans = isum n k - isum n (d-1) in \n printf \"%d\\n\" ans "}], "src_uid": "894a58c9bba5eba11b843c5c5ca0025d"} {"source_code": "open Printf\nopen Scanf\n\nlet read_int _ = bscanf Scanning.stdib \" %d \" (fun x -> x)\nlet () = \n let n = read_int () in\n let w = Array.init n read_int in\n\n let rec loop (x,y) i = if i=n then true else (\n let z = 6 - x - y in\n if w.(i) = x then loop (x,z) (i+1)\n else if w.(i) = y then loop (y,z) (i+1)\n else false\n ) in\n\n\n if loop (1,2) 0 then printf \"YES\\n\" else printf \"NO\\n\"\n", "positive_code": [{"source_code": "let scan_int () = Scanf.scanf \" %d\" (fun x -> x);;\nlet n = scan_int() and gra = ref 1 and pom = ref 0 and gra2 = ref 2 and siedzi = ref 3 and czy = ref 1 in\nbegin\nfor i = 1 to n do\n\tlet x= scan_int() in \n if x = !siedzi then czy := 0\n else if !gra = x then begin pom:= !siedzi; siedzi := !gra2; gra2 := !pom end\n else begin pom := !siedzi; siedzi := !gra; gra := !pom end\ndone;\nif !czy = 1 then print_string(\"YES\")\nelse print_string(\"NO\")\nend \n"}, {"source_code": "let scan_int () = Scanf.scanf \" %d\" (fun x -> x);;\nlet scan_string () = Scanf.scanf \" %s\" (fun x -> x);;\nlet psp () = print_string \" \";;\nlet b2i x = if x == true then 1 else 0;;\n\nlet n = scan_int();;\nlet stan = ref 3;;\nlet wyn = ref 1;;\n\nfor i = 0 to (n - 1) do\n let x = scan_int() in\n if((1 lsl (x - 1)) land (!stan) == 0) then wyn := 0;\n stan := (!stan - (1 lsl (x - 1))) lxor 7;\ndone;\n\nif !wyn = 1 then print_string(\"YES\") else print_string(\"NO\");;\n\n"}], "negative_code": [], "src_uid": "6c7ab07abdf157c24be92f49fd1d8d87"} {"source_code": "open Printf\n\nlet read_int () = Scanf.scanf \"%d \" (fun x -> x);;\nlet read_int3 () = Scanf.scanf \" %d %d %d \" (fun x y z -> (x,y,z) );;\n\nlet n = read_int ()\n\ntype action = Rest | Test | Sport | None;;\ntype day = A | B | C | D;; (* 0, 1, 2, 3*)\n\nlet itoa = function\n | 0 -> A\n | 1 -> B\n | 2 -> C\n | 3 -> D\n\nlet a = Array.init n (fun i -> (read_int () |> itoa))\n\nlet act_poss d act =\n match (d, act) with\n | (A, Sport) -> false\n | (A, Test) -> false\n | (B, Sport) -> false\n | (C, Test) -> false\n | (_, _) -> true\n\ntype rmin = { mutable rest : int; mutable sport : int; mutable test : int};;\n\n (*Note: should not use Array.make here*)\nlet r = Array.init (n+1) (fun i ->\n {rest = max_int; sport = max_int; test = max_int });;\n\nlet () = r.(0) <- {rest = 0; sport = 0; test = 0};;\n\nlet () =\n for i = 1 to n\n do\n let x = r.(i-1).sport in\n let y = r.(i-1).test in\n let z = r.(i-1).rest in\n begin\n if (act_poss a.(i-1) Rest) then\n let w = min x (min y z) in\n if(w x);;\nlet read_int3 () = Scanf.scanf \" %d %d %d \" (fun x y z -> (x,y,z) );;\n\nlet n = read_int ()\n\ntype action = Rest | Test | Sport | None;;\ntype day = A | B | C | D;; (* 0, 1, 2, 3*)\n\nlet itoa = function\n | 0 -> A\n | 1 -> B\n | 2 -> C\n | 3 -> D\n\nlet a = Array.init n (fun i -> (read_int () |> itoa))\n\nlet act_poss d act =\n match (d, act) with\n | (A, Sport) -> false\n | (A, Test) -> false\n | (B, Sport) -> false\n | (C, Test) -> false\n | (_, _) -> true\n\ntype rmin = { mutable rest : int; mutable sport : int; mutable test : int};;\n\n (*Note: should not use Array.make here*)\nlet r = Array.init (n+1) (fun i ->\n {rest = max_int; sport = max_int; test = max_int });;\n\nlet () = r.(0) <- {rest = 0; sport = 0; test = 0};;\n\nlet () =\n for i = 1 to n\n do\n let x = r.(i-1).sport in\n let y = r.(i-1).test in\n let z = r.(i-1).rest in\n begin\n if (act_poss a.(i-1) Rest) then\n let w = min x (min y z) in\n if(w x);;\nlet read_int3 () = Scanf.scanf \" %d %d %d \" (fun x y z -> (x,y,z) );;\n\nlet n = read_int ()\n\ntype action = Rest | Test | Sport | None;;\ntype day = A | B | C | D;; (* 0, 1, 2, 3*)\n\nlet itoa = function\n | 0 -> A\n | 1 -> B\n | 2 -> C\n | 3 -> D\n\nlet a = Array.init n (fun i -> (read_int () |> itoa))\n\nlet act_poss d act =\n match (d, act) with\n | (A, Sport) -> false\n | (A, Test) -> false\n | (B, Sport) -> false\n | (C, Test) -> false\n | (_, _) -> true\n\ntype rmin = { mutable rest : int; mutable sport : int; mutable test : int};;\n\n (*Note: should not use Array.make here*)\nlet r = Array.init (n+1) (fun i ->\n {rest = max_int; sport = max_int; test = max_int });;\n\nlet () = r.(0) <- {rest = 0; sport = 0; test = 0};;\n\nlet () =\n for i = 1 to n\n do\n let x = r.(i-1).sport in\n let y = r.(i-1).test in\n let z = r.(i-1).rest in\n begin\n if (act_poss a.(i-1) Rest) then\n let w = min x (min y z) in\n if(w x)\n\nlet () =\n let n = read_int () in\n let a = Array.init (n + 1) (fun i -> if i = 0 then 0 else read_int ())\n and dp = Array.make_matrix (n + 1) 4 1000000000 in\n dp.(0).(0) <- 0;\n for i = 1 to n do\n dp.(i).(0) <- 1 + (min dp.(i - 1).(0) (min dp.(i - 1).(1) dp.(i - 1).(2)));\n if a.(i) = 1 || a.(i) = 3 then\n dp.(i).(1) <- min dp.(i - 1).(0) dp.(i - 1).(2);\n if a.(i) = 2 || a.(i) = 3 then\n dp.(i).(2) <- min dp.(i - 1).(0) dp.(i - 1).(1)\n done;\n printf \"%d\\n\" (min dp.(n).(0) (min dp.(n).(1) dp.(n).(2)))"}], "negative_code": [{"source_code": "open Printf\n\nlet read_int () = Scanf.scanf \"%d \" (fun x -> x);;\nlet read_int3 () = Scanf.scanf \" %d %d %d \" (fun x y z -> (x,y,z) );;\n\nlet n = read_int ()\n\ntype action = Rest | Test | Sport | None;;\ntype day = A | B | C | D;; (* 0, 1, 2, 3*)\n\nlet itoa = function\n | 0 -> A\n | 1 -> B\n | 2 -> C\n | 3 -> D\n\nlet a = Array.init n (fun i -> (read_int () |> itoa))\n\nlet act_poss d act p_act =\n match (d, act, p_act) with\n | (A, Sport, _) -> false\n | (A, Test, _) -> false\n | (B, Sport, _) -> false\n | (B, Test, Test) -> false\n | (C, Test, _) -> false\n | (C, Sport, Sport) -> false\n | (D, Sport, Sport) -> false\n | (D, Test, Test) -> false\n | (_, _, _) -> true\n\nlet r = Array.make (n+1) max_int;;\n\nlet () = r.(0) <- 0 in\nlet act = Array.make (n+1) None in\nlet () = act.(0) <- Rest in\nlet () =\n for i = 1 to n \n do\n if (act_poss a.(i-1) Rest act.(i-1) ) then\n begin\n if ( r.(i) > r.(i-1)+1 ) then\n begin\n act.(i) <- Rest;\n r.(i) <- r.(i-1) + 1\n end\n end;\n if (act_poss a.(i-1) Test act.(i-1) ) then\n begin\n if ( r.(i) > r.(i-1) ) then\n begin\n act.(i) <- Test;\n r.(i) <- r.(i-1)\n end\n end;\n if (act_poss a.(i-1) Sport act.(i-1) ) then\n begin\n if ( r.(i) > r.(i-1) ) then\n begin\n act.(i) <- Sport;\n r.(i) <- r.(i-1) \n end\n end;\n done in ()\n;;\n\nlet () = printf \"%d\\n\" r.(n);;\n"}], "src_uid": "08f1ba79ced688958695a7cfcfdda035"} {"source_code": "let (no_of_ppl, no_of_puzzles) = Scanf.scanf \"%d %d \" (fun n m -> n, m)\n \nlet read m =\n let rec loop list m = \n if m > 0\n then\n let var = Scanf.scanf \"%d \" (fun v -> v) in\n loop (var :: list) (m - 1)\n else\n list\n in loop [] no_of_puzzles\n\nlet sort list = List.sort(Pervasives.compare) (List.rev list)\n\nlet find_min list n m = \n let rec traverse i min =\n if i + n - 1< m\n then\n let dif = List.nth list (i + n - 1) - List.nth list i in\n if dif < min\n then\n traverse (i + 1) dif\n else\n traverse (i + 1) min\n else\n min \n in traverse 0 1000\n\nlet solve (no_of_ppl, no_of_puzzles) = find_min (sort (read no_of_puzzles)) no_of_ppl no_of_puzzles\n\nlet print result = Printf.printf \"%d\\n\" result\n\nlet () = print (solve (no_of_ppl, no_of_puzzles))", "positive_code": [{"source_code": "let (n, m) = Scanf.scanf \"%d %d\\n\" (fun n m -> n, m) in\n\nlet a = Array.make m 0 in\nfor i = 0 to m - 1 do\n Scanf.scanf \"%d%[ ]\" (fun x _ -> a.(i) <- x)\ndone ;\n\nArray.sort compare a ;\n\nlet ans = ref max_int in\nfor i = 0 to m - n do\n ans := min !ans (a.(i + n - 1) - a.(i))\ndone ;\n\nPrintf.printf \"%d\\n\" !ans ;;\n"}, {"source_code": "let read_int () = Scanf.scanf \" %d\" (fun x -> x)\n\nlet parse_list (n : int) : (int list) =\n let rec parse_list_helper acc = function\n | 0 -> acc\n | n -> parse_list_helper (acc @ [read_int ()]) (n - 1)\n in\n parse_list_helper [] n\n\nlet () =\n let ans = ref 1001 in\n let n = read_int () in\n let m = read_int () in\n let lst = List.sort compare (parse_list m) in\n for k = 0 to m-n do\n let diff = (List.nth lst (k + n - 1)) - (List.nth lst k) in\n ans := min !ans diff\n done;\n print_int !ans\n"}, {"source_code": "let read_int () = Scanf.scanf \" %d\" (fun x -> x)\n\nlet parse_list (n : int) : (int list) =\n let rec parse_list_helper acc = function\n | 0 -> acc\n | n -> parse_list_helper (acc @ [read_int ()]) (n - 1)\n in\n parse_list_helper [] n\n\nlet () =\n let b = ref 1001 in\n let n = read_int () in\n let m = read_int () in\n let lst = parse_list m in\n let sorted_lst = List.sort compare lst in\n for k = 0 to m-n do\n let diff = (List.nth sorted_lst (k + n - 1)) - (List.nth sorted_lst k) in\n b := min !b diff\n done;\n print_int !b\n"}, {"source_code": "let (n, m) = Scanf.scanf \"%d %d\\n\" (fun n m -> n, m) in\nlet p = Array.make m 0 in\nfor i = 0 to m - 1 do\n Scanf.scanf \"%d%[ ]\" (fun x _ -> p.(i) <- x)\ndone ;\nArray.sort compare p ;\nlet b = ref max_int in\nfor i = 0 to m - n do\n b := min !b (p.(i + n - 1) - p.(i))\ndone ;\nPrintf.printf \"%d\\n\" !b ;;\n"}, {"source_code": "open Scanf;;\nopen String;;\n\n\nlet n = bscanf Scanning.stdin \"%d \" (fun x -> x);;\nlet m = bscanf Scanning.stdin \"%d \" (fun x -> x);;\n\nlet p = Array.init m (fun x -> 0);;\n\nfor i=0 to m-1 do\n let f = bscanf Scanning.stdin \"%d \" (fun x -> x) in\n p.(i) <- f\ndone;;\n\n(*Sort the array ascendingly*)\nArray.sort (fun x y -> x-y ) p;;\n\n(*Test the sorting result\nArray.iter (fun x -> Printf.printf \"%d \" x) p;;\n*)\n\nlet i = ref 0 in\nlet maxdiff = ref max_int in\nlet () = \n while (!i + n-1) <= (m-1) do\n let diff = p.(!i+n-1) -p.(!i) in\n if ( diff < !maxdiff) then maxdiff := diff ;\n i := !i + 1\n done in\nprint_int !maxdiff; print_endline \"\"\n;;\n"}, {"source_code": "open Scanf;;\nopen String;;\n\n\nlet n = Scanf.bscanf Scanf.Scanning.stdin \"%d \" (fun x -> x);;\nlet m = Scanf.bscanf Scanf.Scanning.stdin \"%d \" (fun x -> x);;\n\nlet p = Array.init m (fun x -> 0);;\n\nfor i=0 to m-1 do\n let f = Scanf.bscanf Scanf.Scanning.stdin \"%d \" (fun x -> x) in\n p.(i) <- f\ndone;;\n\n(*Sort the array ascendingly*)\nArray.sort (fun x y -> x-y ) p;;\n\n(*Test the sorting result\nArray.iter (fun x -> Printf.printf \"%d \" x) p;;\n*)\n\nlet i = ref 0 in\nlet maxdiff = ref max_int in\nlet () = \n while (!i + n-1) <= (m-1) do\n let diff = p.(!i+n-1) -p.(!i) in\n if ( diff < !maxdiff) then maxdiff := diff ;\n i := !i + 1\n done in\nprint_int !maxdiff; print_endline \"\"\n;;\n"}], "negative_code": [{"source_code": "let read_int () = Scanf.scanf \" %d\" (fun x -> x)\n\nlet parse_list (n : int) : (int list) =\n let rec parse_list_helper acc = function\n | 0 -> acc\n | n -> parse_list_helper (acc @ [read_int ()]) (n - 1)\n in\n parse_list_helper [] n\n\nlet () =\n let ans = ref 1001 in\n let n = read_int () in\n let m = read_int () in\n let lst = List.sort compare (parse_list m) in\n for k = 1 to m-n do\n let diff = (List.nth lst (k + n - 1)) - (List.nth lst k) in\n ans := min !ans diff\n done;\n print_int !ans\n"}, {"source_code": "open Scanf;;\nopen String;;\n\n\nlet n = Scanf.bscanf Scanf.Scanning.stdin \"%d \" (fun x -> x);;\nlet m = Scanf.bscanf Scanf.Scanning.stdin \"%d \" (fun x -> x);;\n\nlet p = Array.init m (fun x -> 0);;\n\nfor i=0 to m-1 do\n let f = Scanf.bscanf Scanf.Scanning.stdin \"%d \" (fun x -> x) in\n p.(i) <- f\ndone;;\n\n(*Sort the array ascendingly*)\nArray.sort (fun x y -> x-y ) p;;\n\n(*Test the sorting result\nArray.iter (fun x -> Printf.printf \"%d \" x) p;;\n*)\n\nlet i = ref 0 in\nlet maxdiff = ref max_int in\nlet () = \n while (!i + 3) <= (m-1) do\n let diff = p.(!i+3) -p.(!i) in\n if ( diff < !maxdiff) then maxdiff := diff ;\n i := !i + 1\n done in\nprint_int !maxdiff; print_endline \"\"\n;;\n"}], "src_uid": "7830aabb0663e645d54004063746e47f"} {"source_code": "\nlet consonants s =\n let regex_vowel = Str.regexp \"[aeiouy]\" in\n let vowel_deleted = Str.split regex_vowel (String.lowercase s)\n in\n String.concat \"\" vowel_deleted\n;;\n\nlet () =\n Scanf.scanf \"%s\" (fun s -> String.iter (fun c -> Printf.printf \".%c\" c)\n (consonants s));\n print_newline ()\n;;\n \n \n", "positive_code": [{"source_code": "let str_to_list s =\n let rec loop i l =\n if i < 0 \n then l \n else loop (i - 1) (s.[i] :: l) in\n loop (String.length s - 1) []\n\nlet word = Scanf.scanf \"%s\" (fun word -> str_to_list (String.lowercase(word)))\n\nlet is_consonant c = match c with\n |'a' | 'o' | 'y' | 'e' | 'u' | 'i' -> false\n | _ -> true\n\nlet remove_vowels l = List.filter(fun char -> is_consonant char) l\n\nlet add_dot = (fun l -> List.concat(List.map(fun char -> ['.'; char]) l))\n\nlet () = List.iter(Printf.printf \"%c\") (add_dot(remove_vowels word))\n"}, {"source_code": "String.iter (fun c ->\n\tif not (c = 'a' || c = 'o' || c = 'y' || c = 'e' || c = 'u' || c = 'i') then\n\t\t(print_char '.'; print_char c)\n) (String.lowercase (read_line()));;\n"}, {"source_code": "let stringToList str =\n let rec loop idx str =\n let len = String.length(str) in\n if idx >= len then\n []\n else\n str.[idx] :: loop (idx+1) str in\n loop 0 str;;\n\nlet isConsonant ch =\n match ch \n with 'a'|'o'|'y'|'e'|'u'|'i' -> false\n | _ -> true;;\n\nlet printWithDot ch =\n Printf.printf \".%c\" ch;;\n\nlet _ =\n let line = read_line() in\n let l = stringToList (String.lowercase line) in\n List.map printWithDot (List.filter isConsonant l) in\n print_newline()\n"}, {"source_code": "let s=read_line();;\nlet rec op t=\nif t=\"\" then [] else t.[0]::(op (String.sub t 1 (String.length(t)-1)));;\nlet l=op s;;\nlet letter char= match char with\n| 'a' | 'e' | 'i' | 'o' | 'u' | 'y' \n | 'A' | 'E' | 'I' | 'O' | 'U' | 'Y' ->()\n|'a'..'z'->print_string \".\";print_char char\n|'A'..'Z'->print_string \".\";print_char (Char.chr(int_of_char(char)+32))\n|_->();;\nlet rec doo=function\n|[]->()\n|h::t->letter h;doo t;;\ndoo l;;"}, {"source_code": "let do_it c =\n\tmatch c with\n\t'a'|'o'|'y'|'e'|'u'|'i'|'A'|'O'|'Y'|'E'|'U'|'I' -> c\n\t|_ -> print_string (\".\" ^ String.make 1 c); c\n;;\n\nString.map do_it (String.lowercase (read_line()))"}, {"source_code": "let str=String.lowercase(read_line());;\nlet ans= ref \"\" ;;\nfor i=1 to String.length(str) do\n let va= str.[i-1] in\n if (va!='a' && va!='e' && va!='i' && va!='o' && va!='u' && va!='y') then ans:=(!ans)^(String.make 1 '.')^(String.make 1 va)\ndone;;\nprint_endline(!ans)\n"}, {"source_code": "let atr=read_line();;\nlet str=String.lowercase(atr);;\nlet ans= ref \"\" ;;\nfor i=1 to String.length(str) do\n let va= str.[i-1] in\n if (va!='a' && va!='e' && va!='i' && va!='o' && va!='u' && va!='y') then ans:=(!ans)^(String.make 1 '.')^(String.make 1 va)\ndone;;\nprint_endline(!ans)\n"}, {"source_code": "open Scanf\nopen Num\nopen Printf\nopen String\n\nlet s = Scanf.bscanf Scanf.Scanning.stdin \"%s \" ( fun x -> x) |> String.lowercase\n\nlet explode s =\n let r = ref [] in\n for i = 0 to (length s - 1) do\n let c = String.get s i in\n r := !r@[c]\n done; !r\n;;\n\nlet is_vowel = function\n | 'a' -> true\n | 'o' -> true\n | 'y' -> true\n | 'e' -> true\n | 'u' -> true\n | 'i' -> true\n | _ -> false\n\nlet l = ( explode s \n |> List.filter (fun x -> (not (is_vowel x)) )\n );;\n\nList.iter (fun x -> print_string (\".\"^(String.make 1 x)) ) l; print_endline \"\";;\n"}, {"source_code": "let solve =\n let s = read_line () in\n let terminated_s = s ^ \".\" in\n let rec parse_string i = match terminated_s.[i] with\n | '.' -> print_string \"\\n\"\n | 'a' | 'o' | 'y' | 'e' | 'u' | 'i'\n | 'A' | 'O' | 'Y' | 'E' | 'U' | 'I' -> parse_string (i+1)\n | c when c >= 'A' && c <= 'Z' ->\n print_char '.'; print_char (Char.lowercase c); parse_string (i+1)\n | c -> print_char '.'; print_char c; parse_string (i+1)\n in parse_string 0; ()\n\nlet () = solve\n"}, {"source_code": "let vowels = 'a'::'i'::'u'::'e'::'o'::'y'::[]\n\nlet petya c = \n let lower = Char.lowercase c in\n if List.exists (fun x -> x = lower) vowels then ()\n else Printf.printf \".%c\" lower\n\nlet main () =\n let gr () = Scanf.scanf \"%s\\n\" (fun i -> i) in\n let str = gr () in\n let () = String.iter petya str in\n Printf.printf(\"\\n\")\n;;\n\nlet _ = main();;\n\n"}, {"source_code": "\nopen String;;\nopen Printf;;\nopen Scanf;;\nopen Char;;\n \n\nlet convert ch =\n match ch with\n |'a'|'e'|'u'|'i'|'o'|'y'\n |'A'|'E'|'U'|'I'|'O'|'Y' -> None\n |_ -> Some (\".\" ^ String.make 1 (Char.lowercase ch))\n \n\nlet rec process inp =\n let res = ref \"\" in\n for i = 0 to length inp - 1 do\n let ch = convert inp.[i] in\n match ch with\n | Some x -> res := (!res ^ x)\n | None -> ()\n done;\n !res\n\nlet () =\n let inp = read_line () in\n printf \"%s\\n\" (process inp)\n ;;\n\n\n\n"}, {"source_code": "let pf = Printf.printf;;\nlet sf = Scanf.scanf;;\n\nlet (|>) x f = f x;;\nlet (@@) f x = f x;;\n\nexception Error of string\n\nlet inf = 1000000000;;\nlet eps = 1e-11;;\n\nlet f s =\n let t = Char.lowercase s in\n if List.memq t ['a'; 'i'; 'u'; 'e'; 'o'; 'y']\n then \"\"\n else \".\" ^ Char.escaped t\n;;\n\nlet _ =\n let str = read_line() in\n let res = ref \"\" in\n for i = 0 to String.length str - 1 do\n res := !res ^ f str.[i]\n done;\n print_endline !res\n;;\n"}, {"source_code": "let _ =\n let main () =\n let conv k =\n let s = String.lowercase k in\n\n let rec loop i acc =\n if i < 0 then acc else\n let k = try String.index \"aoyeui\" s.[i] with _ -> -1 in\n loop (i - 1) (if k >= 0 then acc else s.[i] :: acc)\n in\n loop (String.length s - 1) []\n in\n let s = read_line () in\n let result = conv s in\n List.iter (Printf.printf \".%c\") result;\n print_newline ()\n in\n main ()\n"}], "negative_code": [{"source_code": "let atr=read_line();;\nlet str=String.lowercase(atr);;\nlet ans= ref \"\" ;;\nfor i=1 to String.length(str) do\n let va= str.[i-1] in\n if (va!='a' && va!='e' && va!='i' && va!='o' && va!='u') then ans:=(!ans)^(String.make 1 '.')^(String.make 1 va)\ndone;;\nprint_endline(!ans)\n"}, {"source_code": "let vowels = 'a'::'i'::'u'::'e'::'o'::[]\n\nlet petya c = \n let lower = Char.lowercase c in\n if List.exists (fun x -> x = lower) vowels then ()\n else Printf.printf \".%c\" lower\n\nlet main () =\n let gr () = Scanf.scanf \"%s\\n\" (fun i -> i) in\n let str = gr () in\n let () = String.iter petya str in\n Printf.printf(\"\\n\")\n;;\n\nlet _ = main();;\n\n"}], "src_uid": "db9520e85b3e9186dd3a09ff8d1e8c1b"} {"source_code": "open Printf\n\nlet main =\n let s = read_line() in\n let h = s.[0] in\n let t = String.sub s 1 ((String.length s) - 1) in\n \n printf \"%c%s\\n\" (Char.uppercase h) t;\n", "positive_code": [{"source_code": "print_string (String.capitalize (read_line()))\n"}, {"source_code": "let input () = Scanf.scanf \"%s\" (fun s -> s)\n\nlet solve input = String.capitalize input\n\nlet print result = Printf.printf \"%s\\n\" result\n\nlet () = print (solve (input ()))"}, {"source_code": "\nlet () =\n let s = read_line () in\n let len = String.length s in\n let head = String.sub s 0 1 in\n let tail = String.sub s 1 (len - 1)\n in\n print_endline (String.uppercase head ^ tail);;\n"}, {"source_code": "let read_int () = Scanf.scanf \"%s \" (fun x -> x);;\n\nlet () = read_int () |> String.capitalize\n|> print_endline ;;\n\n"}, {"source_code": "\n(* Codeforces 281A *)\n\nlet _ =\n Printf.printf \"%s\\n\" (Scanf.scanf \"%s\" (fun s -> String.capitalize s))\n"}, {"source_code": "\n\nlet () = \n let s = read_line() in\n let isupper c = int_of_char c <= int_of_char 'Z' && int_of_char c >= int_of_char 'A' in\n if not (isupper s.[0]) then\n s.[0] <- char_of_int ((int_of_char s.[0]) + (int_of_char 'A') - (int_of_char 'a'));\n\n Printf.printf \"%s\\n\" s\n"}], "negative_code": [], "src_uid": "29e0fc0c5c0e136ac8e58011c91397e4"} {"source_code": "let read_int () = Scanf.scanf \" %d \" (fun x -> x)\nlet read_string () = Scanf.scanf \" %s \" (fun x -> x)\n\nlet ( $ ) f x = f x\n\n\n\nlet main () = \n let n = ref (read_int ()) in\n let cur = ref 0 in\n let fail = ref false in\n let t = ref 0 in\n let str = ref \"\" in\n for i = 1 to !n do\n fail := !fail || not(0 <= !cur && !cur <= 20000);\n t := read_int ();\n str := read_string ();\n if !str = \"North\" then\n cur := !cur - !t\n else if !str = \"South\" then\n cur := !cur + !t\n else if (!str = \"East\" || !str = \"West\") && (!cur = 0 || !cur = 20000) then\n fail := true\n \n done;\n Printf.printf (if not !fail && !cur = 0 then \"YES\" else \"NO\")\n\n\n\n\nlet () = main ()", "positive_code": [{"source_code": "open Printf\nopen Scanf\n\nlet read_int () = bscanf Scanning.stdib \" %d \" (fun x -> x)\nlet read_string () = bscanf Scanning.stdib \" %s \" (fun x -> x)\n\nlet () = \n let n = read_int () in\n\n let rec loop i x = if i=n then x=0 else\n let t = read_int() in\n match (read_string()) with\n\t| \"South\" ->\n\t let x = x + t in\n\t if x > 20_000 then false\n\t else loop (i+1) x\n\t| \"North\" ->\n\t let x = x - t in\n\t if x < 0 then false\n\t else loop (i+1) x\n\t| _ ->\n\t if x = 0 || x = 20_000 then false\n\t else loop (i+1) x\n in\n\n if loop 0 0 then printf \"Yes\\n\" else printf \"No\\n\"\n"}], "negative_code": [], "src_uid": "11ac96a9daa97ae1900f123be921e517"} {"source_code": "let n = int_of_string (input_line stdin);;\nlet s = input_line stdin;;\nlet a = Array.make 26 false;;\n\nfor i = 0 to n - 1 do\n a.(Char.code (Char.lowercase s.[i]) - Char.code 'a') <- true;\ndone;;\n\nif List.mem false (Array.to_list a) then print_string \"NO\"\nelse print_string \"YES\";;\nprint_newline ();;\n", "positive_code": [{"source_code": "let input () = \n let total = Scanf.scanf \"%d \" (fun n -> n) in\n let rec read i list =\n if i < total\n then\n let char = Char.lowercase (Scanf.scanf \"%c\" (fun c -> c)) in\n read (i + 1) (char :: list)\n else\n list\n in read 0 []\n\nlet rec get_uniques = function\n | head :: (middle :: _ as tail) -> \n if head = middle \n then \n get_uniques tail \n else \n (head :: get_uniques tail)\n | smaller -> smaller\n\nlet solve list =\n let uniques = List.length (get_uniques (List.sort(Pervasives.compare) list)) in\n if uniques = 26\n then\n \"YES\"\n else\n \"NO\"\n\nlet print result = Printf.printf \"%s\\n\" result\nlet () = print (solve (input ()))"}, {"source_code": "let answer s n = \n let a = Array.make 26 false in \n for i = 0 to n-1 do\n let c = Char.code s.[i] in\n if c >= 97 then a.(c-97) <- true\n else a.(c-65) <- true\n done;\n let b = ref true in\n for i = 0 to 25 do\n b := !b && a.(i)\n done;\n if !b then print_endline \"YES\" else print_endline \"NO\"\n\nlet () = \n let n = int_of_string (read_line ()) in\n let s = read_line () in\n answer s n\n\n"}], "negative_code": [], "src_uid": "f13eba0a0fb86e20495d218fc4ad532d"} {"source_code": "open Printf\nopen Scanf\n\nlet read_int () = bscanf Scanning.stdib \" %d \" (fun x -> x)\nlet () = \n let n = read_int () in\n let answer = if n=0 then 1 else [|6;8;4;2|].(n mod 4) in\n printf \"%d\\n\" answer\n", "positive_code": [{"source_code": "let input () = Scanf.scanf \"%d \" (fun n -> n)\n\nlet solve n = \n if n = 0\n then\n 1\n else\n match (n mod 4) with\n | 1 -> 8\n | 2 -> 4\n | 3 -> 2\n | 4 | 0 -> 6 \n\nlet print result = Printf.printf \"%d\\n\" result\n\nlet () = print (solve (input ()))"}], "negative_code": [], "src_uid": "4b51b99d1dea367bf37dc5ead08ca48f"} {"source_code": "let input = Scanf.scanf \"%d %d %d\" (fun a b c -> (a, b, c))\n\nlet get_max (a, b, c)= \n List.fold_left (Pervasives.max) 0 \n [a * (b + c);\n (a + b) * c;\n a * b * c;\n a * b + c;\n a + b * c;\n a + b + c]\n \nlet print result = Printf.printf \"%d\\n\" result\n\nlet () = print (get_max (input))", "positive_code": [{"source_code": "let () =\nlet a,b,c = Scanf.scanf \"%d %d %d \" (fun a b c -> a,b,c) in\nPrintf.printf \"%d\\n\" @@\nList.fold_left max 0 \n[\na+b+c;\na * b * c;\n(a+b) * c;\na+(b * c);\n(a * b)+c;\na * (b+c);\n]"}], "negative_code": [], "src_uid": "1cad9e4797ca2d80a12276b5a790ef27"} {"source_code": "let pf = Printf.printf ;;\nlet epf = Printf.eprintf ;;\nlet sf = Scanf.scanf ;;\n\nlet (|>) x f = f x ;;\n\nmodule Array = struct\n include ArrayLabels\n let fold_lefti ~f ~init arr =\n let acc = ref init in\n for i = 0 to Array.length arr - 1 do\n acc := f i !acc arr.(i)\n done;\n !acc\n ;;\nend\nmodule String = StringLabels ;;\nmodule List = struct\n include ListLabels ;;\n let rec repeat n a = if n = 0 then [] else a :: repeat (n - 1) a ;;\n let rec drop n a =\n if n = 0 then a\n else match a with\n | [] -> failwith \"cannot take\"\n | x :: xs -> drop (n - 1) xs ;;\n\n let init ~f n =\n let res = ref [] in\n for i = 0 to n - 1 do\n res := f i :: !res\n done;\n List.rev !res\n ;;\nend ;;\nmodule H = Hashtbl ;;\n\nmodule SI = Set.Make (struct\n type t = int \n let compare = compare\nend)\n\nlet () =\n let n, m = sf \"%d %d \" (fun n m -> n, m) in\n let sock = ref n in\n let i = ref 1 in\n while !sock > 0 do\n epf \"i, sock = %d, %d\\n\" !i !sock;\n decr sock;\n if !i > 1 && !i mod m = 0 then incr sock;\n if !sock > 0 then incr i;\n done;\n pf \"%d\\n\" !i\n;;\n", "positive_code": [{"source_code": "let input () = Scanf.scanf \"%d %d\" (fun n m -> (n, m))\n\nlet add socks days m = \n if days mod m = 0\n then\n socks + 1\n else\n socks\n\nlet solve (n, m) =\n let rec loop socks days =\n if socks > 0\n then\n loop ((add socks days m) - 1) (days + 1) \n else\n days - 1\n in loop n 1\n\nlet print result = Printf.printf \"%d\\n\" result\nlet () = print (solve (input ()))"}], "negative_code": [], "src_uid": "42b25b7335ec01794fbb1d4086aa9dd0"} {"source_code": "(* Codeforces 103A - UnilShtan *)\n\nopen Filename;;\n\n(* you can use either gr or rdln but not both *)\nlet use_input_txt = false;;\nlet fn = (Filename.dirname Filename.current_dir_name);;\nlet filename = Filename.concat \".\" \"input.txt\";;\nlet cin = if use_input_txt then Scanf.Scanning.open_in filename\n\telse Scanf.Scanning.stdin;;\n\nlet cout = open_out \"output.txt\";;\nlet gr () = Scanf.bscanf cin \" %d\" (fun i -> i);;\nlet grf () = Scanf.scanf \" %f\" (fun i -> i);;\nlet grl () = Scanf.scanf \" %Ld\" (fun i -> i);;\nlet rdln() = input_line Pervasives.stdin;;\n(* let spli s = Str.split (Str.regexp \" \") s;; *)\nlet printlisti li = List.iter (fun i -> (print_int i; print_string \" \")) li;;\nlet printlisti64 li = List.iter (fun i -> (print_string (Int64.to_string i); print_string \" \")) li;;\nlet printarri ai = Array.iter (fun i -> (print_int i; print_string \" \")) ai;;\nlet debug = false;;\n\nlet rec readlist n acc = match n with\n\t| 0 -> List.rev acc\n\t| _ -> readlist (n -1) (gr() :: acc);;\n\nlet aa = Array.make 4 \"\";;\n\nlet rec readaa i n =\n\tif i == n then ()\n\telse (\n\t\taa.(i) <- rdln();\n\t\treadaa (i +1) n\n\t);;\n\nlet cntaa ii jj c =\n\tlet cnt = ref 0 in (\n\t\tfor i = ii to ii +1 do\n\t\t\tfor j = jj to jj +1 do\n\t\t\t\tif aa.(i).[j] == c then\n\t\t\t\t\tcnt := !cnt + 1\n\t\t\tdone\n\t\tdone;\n\t\t!cnt\n\t);;\n\nlet rec ifiq () =\n\tlet iqok = ref false in\n\tbegin\n\t\tfor ii = 0 to 2 do\n\t\t\tfor jj = 0 to 2 do\n\t\t\t\tbegin\n\t\t\t\t\tif (cntaa ii jj '#') >= 3 then iqok := true;\n\t\t\t\t\tif (cntaa ii jj '.') >= 3 then iqok := true\n\t\t\t\tend\n\t\t\tdone\n\t\tdone;\n\t\t!iqok\n\tend;;\n\nlet main() =\n\tbegin\n\t\treadaa 0 4;\n\t\tprint_string (if ifiq() then \"YES\" else \"NO\") \n\tend;;\n\nmain();;\n", "positive_code": [{"source_code": "\nlet data = Array.init 4 (fun i -> read_line () ) ;;\n\nlet solve i j = let cnt = ref 0 in \n for ii = 0 to 1 do for jj = 0 to 1 do \n if (data.(i+ii)).[j+jj] = '#' then cnt := !cnt + 1\n done\n done;\n !cnt <= 1;;\n\nlet solve2 i j = let cnt = ref 0 in \n for ii = 0 to 1 do for jj = 0 to 1 do \n if (data.(i+ii)).[j+jj] = '.' then cnt := !cnt + 1\n done\n done;\n !cnt <= 1;;\n\n(*for i = 0 to 3 do print_endline data.(i) done;;*)\n\nlet flag = ref false;;\n\nfor i = 0 to 2 do\n for j = 0 to 2 do\n flag := !flag || solve i j || solve2 i j\n done\ndone;;\n\nif !flag = false then print_string \"NO\\n\"\nelse print_string \"YES\\n\";;\n"}], "negative_code": [], "src_uid": "01b145e798bbdf0ca2ecc383676d79f3"} {"source_code": "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_lim,min_i64_lim = Int64.(max_int,min_int)\n let max_i64,min_i64 = 2000000000000000000L,-2000000000000000000L\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 slen s = String.length s\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 s = scanf \" %s\" @@ id in\n let n = gi 0 in\n let hat,rep = ref [],ref [] in\n let a = fix (fun f i x ->\n if i>=String.length s then x\n else\n let c = s.[i] in\n if c='?' || c='*' then (\n if c='?' then hat := i::!hat;\n if c='*' then rep := i::!rep;\n f (i+$1) (List.tl x)\n ) else f (i+$1) (c::x)\n ) 0 [] |> List.rev in\n let l = List.length a in\n (* printf \"%d\\n\" l;\n print_list string_of_int !hat;\n print_list string_of_int !rep; *)\n (* print_list (String.make 1) a; *)\n rep := List.sort compare !rep;\n hat := List.sort compare !hat;\n if llen a > n then (\n print_endline \"Impossible\"; exit 0\n ) else if llen a = n then (\n print_endline @@ string_of_list ~separator:\"\" (String.make 1) a; exit 0\n );\n if List.length !rep = 0 then (\n if llen a + llen !hat < n then (\n print_endline \"Impossible\"; exit 0\n ) else (\n let cnt = ref @@ n - llen a in\n String.iteri (fun i c ->\n (* printf \"%d :: %d <> %d :: %Ld\\n\" (List.length !hat) (i+$1) (List.hd !hat) !cnt; *)\n if List.length !hat > 0 && i+$1=List.hd !hat && !cnt > 0L then (\n hat := List.tl !hat;\n print_char c;\n cnt -= 1L;\n ) else if c='?' || (i <= String.length s-$2 && (s.[i+$1]='?' || s.[i+$1]='*'))\n then (\n\n ) else (\n print_char c;\n )\n ) s\n )\n ) else (\n let rest = i32 @@ n - llen a in\n let j = List.hd !rep in\n String.iteri (fun i c ->\n if i+$1=j then (\n repi 1 rest (fun _ -> printf \"%c\" c)\n )\n else\n if c='?' || c='*' || (i <= String.length s-$2 && (s.[i+$1]='?' || s.[i+$1]='*')) then ()\n else (\n print_char c\n )\n ) s\n )\n\n\n\n\n\n\n\n\n", "positive_code": [{"source_code": "let rec fix f x = f (fix f) x;;\nArray.(Scanf.scanf \" %s %d\" @@ fun s n ->\n let a = init (String.length s) (fun i -> s.[i]) in\n let undef = -7 in\n let p,q,r,_ = fold_left (fun (p,q,r,i) -> function\n | '*' -> (List.tl p, q,i,i+1)\n | '?' -> (List.tl p,i::q,r,i+1)\n | _ -> ( i::p, q,r,i+1)\n ) ([],[],undef,0) a in\n let p,q = List.(rev p, rev q) in\n if List.length p = n then\n (List.iter (fun i -> print_char a.(i)) p; exit 0)\n else if List.length p > n then\n (print_string \"Impossible\"; exit 0);\n let need = n - List.length p in\n let u = ref p in\n if r<>undef then (\n iteri (fun i c ->\n if List.length !u > 0 && List.hd !u = i then (\n print_char a.(i); u := List.tl !u\n ) else if i+1=r then\n for k=1 to need do print_char a.(i) done\n ) a\n ) else (\n if need > List.length q then\n (print_string \"Impossible\"; exit 0);\n let w = ref q in\n let rest = ref need in\n iteri (fun i c ->\n if List.length !u > 0 && List.hd !u = i then (\n print_char a.(i); u := List.tl !u\n ) else if List.length !w > 0 && List.hd !w = i+1 && !rest > 0 then (\n print_char a.(i); w := List.tl !w;\n rest := !rest - 1\n ) else if i+1=r then\n for k=1 to need do print_char a.(i) done\n ) a\n )\n)"}], "negative_code": [{"source_code": "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_lim,min_i64_lim = Int64.(max_int,min_int)\n let max_i64,min_i64 = 2000000000000000000L,-2000000000000000000L\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 slen s = String.length s\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 s = scanf \" %s\" @@ id in\n let n = gi 0 in\n let hat,rep = ref [],ref [] in\n let a = fix (fun f i x ->\n if i>=String.length s then x\n else\n let c = s.[i] in\n if c='?' || c='*' then (\n if c='?' then hat := i::!hat;\n if c='*' then rep := i::!rep;\n f (i+$1) (List.tl x)\n ) else f (i+$1) (c::x)\n ) 0 [] |> List.rev in\n let l = List.length a in\n (* printf \"%d\\n\" l;\n print_list string_of_int !hat;\n print_list string_of_int !rep; *)\n (* print_list (String.make 1) a; *)\n if llen a > n then (\n print_endline \"Impossible\"; exit 0\n ) else if llen a = n then (\n print_endline @@ string_of_list ~separator:\"\" (String.make 1) a; exit 0\n );\n if List.length !rep = 0 then (\n if llen a + llen !hat > n then (\n print_endline \"Impossible\"; exit 0\n ) else (\n let cnt = ref @@ List.length !hat in\n String.iteri (fun i c ->\n if c='?' then ()\n else (\n if List.length !rep > 0 && i+$1=List.hd !rep && !cnt > 0 then (\n rep := List.tl !rep;\n cnt := !cnt -$ 1;\n );\n print_char c;\n )\n ) s\n )\n ) else (\n let rest = i32 @@ n - llen a in\n let j = List.hd !rep in\n String.iteri (fun i c ->\n if i+$1=j then (\n repi 1 rest (fun _ -> printf \"%c\" c)\n )\n else\n if c='?' || c='*' || (i <= String.length s-$2 && (s.[i+$1]='?' || s.[i+$1]='*')) then ()\n else (\n print_char c\n )\n ) s\n )\n\n\n\n\n\n\n\n\n"}, {"source_code": "let rec fix f x = f (fix f) x;;\nArray.(Scanf.scanf \" %s %d\" @@ fun s n ->\n let p,q,r,_ = init (String.length s) (fun i -> s.[i])\n |> fold_left (fun (p,q,r,i) c ->\n if c = '?' then (List.tl p,i::q,r,i+1)\n else if c='*' then (List.tl p,q,i::r,i+1)\n else ((c,i)::p,q,r,i+1)\n ) ([],[],[],0) in\n let p,q,r = List.(rev p,rev q,rev r) in\n if List.length p = n then\n List.map fst p |> List.iter print_char\n else if List.length p > n then\n print_endline \"Impossible\"\n else (\n let need = n - List.length p in\n if List.length r <> 0 then (\n let j = List.hd r in\n List.iter (fun (c,i) ->\n print_char c;\n if i=j-2 then for k=0 to need do\n print_char s.[i+1]\n done\n ) p\n ) else (\n if List.length p + List.length q < n then\n print_endline \"Impossible\"\n else (\n List.fold_left (fun (rest,q) (c,i) ->\n print_char c;\n match q with\n | [] -> (rest,q)\n | h::t as q ->\n if i=h-2 then (\n print_char s.[h-1]; (rest-1,t)\n ) else (rest,q)\n ) (need,q) p |> ignore\n )\n )\n ))"}, {"source_code": "let rec fix f x = f (fix f) x;;\nArray.(Scanf.scanf \" %s %d\" @@ fun s n ->\n let p,q,r,_ = init (String.length s) (fun i -> s.[i])\n |> fold_left (fun (p,q,r,i) c ->\n if c = '?' then (List.tl p,i::q,r,i+1)\n else if c='*' then (List.tl p,q,i::r,i+1)\n else ((c,i)::p,q,r,i+1)\n ) ([],[],[],0) in\n let p,q,r = List.(rev p,rev q,rev r) in\n if List.length p = n then\n List.map fst p |> List.iter print_char\n else if List.length p > n then\n print_endline \"Impossible\"\n else (\n let need = n - List.length p in\n if List.length r <> 0 then (\n let j = List.hd r in\n List.iter (fun (c,i) ->\n print_char c;\n if i=j-2 then for k=1 to need do\n print_char s.[i+1]\n done\n ) p\n ) else (\n if List.length p + List.length q < n then\n print_endline \"Impossible\"\n else (\n List.fold_left (fun (rest,q) (c,i) ->\n print_char c;\n match q with\n | [] -> (rest,q)\n | h::t as q ->\n if i=h-2 then (\n print_char s.[h-1]; (rest-1,t)\n ) else (rest,q)\n ) (need,q) p |> ignore\n )\n )\n ))"}], "src_uid": "90ad5e6bb5839f9b99a125ccb118a276"} {"source_code": "open Printf\nopen Scanf\n\nlet rec fold i j f init = if i>j then init else fold (i+1) j f (f i init)\nlet sum i j f = fold i j (fun i a -> (f i) + a) 0\n\nlet isupper c = c <= 'Z' && c >= 'A'\nlet toupper = Char.uppercase\n\nlet read_string () = bscanf Scanning.stdib \" %s \" (fun x -> x)\nlet () = \n let board = Array.init 8 (fun _ -> read_string()) in\n\n let score p =\n let s = match toupper p with\n | 'K' -> 0\n | 'Q' -> 9\n | 'R' -> 5\n | 'B' -> 3\n | 'N' -> 3\n | 'P' -> 1\n | '.' -> 0\n | _ -> failwith \"bad input\"\n in\n \n if isupper p then s else -s\n in\n\n let answer = sum 0 7 (fun i -> sum 0 7 (fun j -> score board.(i).[j])) in\n\n if answer = 0 then printf \"Draw\\n\"\n else if answer > 0 then printf \"White\\n\"\n else printf \"Black\\n\"\n", "positive_code": [{"source_code": "let evalue = function\n\t|'Q'\t-> (9,0)\n\t|'R'\t-> (5,0)\n\t|'B'\t-> (3,0)\n\t|'N'\t-> (3,0)\n\t|'P'\t-> (1,0)\n\t|'q'\t-> (0,9)\n\t|'r'\t-> (0,5)\n\t|'b'\t-> (0,3)\n\t|'n'\t-> (0,3)\n\t|'p'\t-> (0,1)\n\t|_\t-> (0,0);;\n\nlet main () =\n\tlet a = ref 0 and b = ref 0 and l= ref [] in\n\tfor i=0 to 7 do\n\t\tl := (Scanf.scanf \"%s\\n\" (fun j -> j))::!l;\n\tdone;\n\tList.iter (fun x ->\n\t\t\tfor i=0 to String.length x - 1 do\n\t\t\t\tlet (c,d) = evalue (x.[i]) in\n\t\t\t\t\ta:= !a + c;\n\t\t\t\t\tb:= !b + d;\n\t\t\tdone) !l;\n\tif !a < !b\n\t\tthen Printf.printf \"Black\"\n\t\telse if !a = !b\n\t\t\tthen Printf.printf \"Draw\"\n\t\t\telse Printf.printf \"White\";;\n\nmain ();;\n"}, {"source_code": "let score x = \n let check_upp = function \n | 'a' .. 'z' -> false\n | 'A' .. 'Z' -> true\n | _ -> false in\n let upper x = (if (check_upp x) then x else Char.uppercase x) in\n ((if (check_upp x) then 0 else 1) , match (upper x) with\n | 'Q' -> 9\n | 'R' -> 5\n | 'B' -> 3\n | 'N' -> 3\n | 'P' -> 1\n | _ -> 0);; \n\n(*Running Code*)\nlet ans = [|ref 0; ref 0|];;\nfor i = 1 to 8 do\n let a = ref (read_line ()) in\n for j = 0 to ((String.length !a) - 1) do \n let p = (score !a.[j]) in\n (ans.(fst p)) := !(ans.(fst p)) + (snd p);\n done;\ndone;;\nprint_string (if (!(ans.(0)) > !(ans.(1))) then \"White\" else (if (!(ans.(0)) = !(ans.(1))) then \"Draw\" else \"Black\"));;\nprint_string \"\\n\"\n"}, {"source_code": "let read () = Scanf.scanf \"%c \" (fun c -> c)\n\nlet colour char = \n if char != '.' && char != '\\n'\n then\n if Char.lowercase char = char\n then\n `Black\n else\n `White\n else\n `Pass\n\nlet count char score =\n match Char.lowercase char with\n | 'q' -> score + 9\n | 'r' -> score + 5\n | 'b' | 'n' -> score + 3\n | 'p' -> score + 1\n | 'k' -> score\n\nlet get_winner black white = \n if black > white\n then\n \"Black\"\n else\n if white > black\n then\n \"White\"\n else\n \"Draw\"\n\nlet solve () = \n let rec loop i score_black score_white =\n if i < 64\n then \n let char = read () in\n match (colour char) with\n | `Black -> loop (i + 1) (count char score_black) score_white\n | `White -> loop (i + 1) score_black (count char score_white)\n | `Pass -> loop (i + 1) score_black score_white\n else\n get_winner score_black score_white\n in loop 0 0 0\n \nlet print winner = Printf.printf \"%s\\n\" winner\nlet () = print (solve ())"}], "negative_code": [{"source_code": "let evalue = function\n\t|'Q'\t-> (9,0)\n\t|'R'\t-> (5,0)\n\t|'B'\t-> (3,0)\n\t|'N'\t-> (3,0)\n\t|'P'\t-> (1,0)\n\t|'q'\t-> (0,9)\n\t|'r'\t-> (0,5)\n\t|'b'\t-> (0,3)\n\t|'n'\t-> (0,3)\n\t|'p'\t-> (0,1)\n\t|_\t-> (0,0);;\n\nlet main () =\n\tlet a = ref 0 and b = ref 0 and l= ref [] in\n\tfor i=0 to 7 do\n\t\tl := (Scanf.scanf \"%s\" (fun j -> j))::!l;\n\tdone;\n\tList.iter (fun x ->\n\t\t\tfor i=0 to String.length x - 1 do\n\t\t\t\tlet (c,d) = evalue (x.[i]) in\n\t\t\t\t\ta:= !a + c;\n\t\t\t\t\tb:= !b + d;\n\t\t\tdone) !l;\n\tif !a < !b\n\t\tthen Printf.printf \"White\"\n\t\telse if !a = !b\n\t\t\tthen Printf.printf \"Draw\"\n\t\t\telse Printf.printf \"Black\";;\n\nmain ();;\n"}, {"source_code": "open Printf\nopen Scanf\n\nlet rec fold i j f init = if i>j then init else fold (i+1) j f (f i init)\nlet sum i j f = fold i j (fun i a -> (f i) + a) 0\n\nlet isupper c = c <= 'Z' && c >= 'A'\nlet toupper = Char.uppercase\n\nlet read_string () = bscanf Scanning.stdib \" %s \" (fun x -> x)\nlet () = \n let board = Array.init 8 (fun _ -> read_string()) in\n\n let score p =\n let s = match toupper p with\n | 'K' -> 0\n | 'Q' -> 8\n | 'R' -> 5\n | 'B' -> 3\n | 'N' -> 3\n | 'P' -> 1\n | '.' -> 0\n | _ -> failwith \"bad input\"\n in\n \n if isupper p then s else -s\n in\n\n let answer = sum 0 7 (fun i -> sum 0 7 (fun j -> score board.(i).[j])) in\n\n if answer = 0 then printf \"Draw\\n\"\n else if answer > 0 then printf \"White\\n\"\n else printf \"Black\\n\"\n"}], "src_uid": "44bed0ca7a8fb42fb72c1584d39a4442"} {"source_code": "let read_int () = Scanf.scanf \" %d \" (fun x -> x)\nlet solve n = if n > 2 then n - 2 else n + 2\n \nlet main () =\n let n = read_int () in\n let answer = if n > 2 then n - 2 else n + 2 in \n print_int answer;;\n\nmain ()\n\n", "positive_code": [{"source_code": "let _ =\n let sb = Scanf.Scanning.stdib in\n let n = Scanf.bscanf sb \"%d \" (fun s -> s) in\n let m =\n if n + 2 <= 1000\n then n + 2\n else n - 2\n in\n Printf.printf \"%d\\n\" m\n"}], "negative_code": [{"source_code": "let _ =\n let sb = Scanf.Scanning.stdib in\n let n = Scanf.bscanf sb \"%d \" (fun s -> s) in\n let m = n + 2 in\n Printf.printf \"%d\\n\" m\n"}], "src_uid": "5c68e20ac6ecb7c289601ce8351f4e97"} {"source_code": "let input () = Scanf.scanf \"%s\" (fun s -> (s, String.length s))\n\nlet traverse (remix, l) = \n let rec loop i original =\n if i + 3 <= l\n then\n if remix.[i] = 'W'\n then\n if remix.[i + 1] = 'U'\n then\n if remix.[i + 2] = 'B'\n then\n loop (i + 3) (' ' :: original)\n else\n loop (i + 2) (remix.[i + 1] :: remix.[i] :: original)\n else\n loop (i + 1) (remix.[i] :: original)\n else\n loop (i + 1) (remix.[i] :: original)\n else\n if i + 2 <= l\n then\n (' ' :: remix.[i + 1] :: remix.[i] :: original)\n else\n if i + 1 <= l\n then\n (' ' :: remix.[i] :: original)\n else\n (' ' :: original)\n in loop 0 [' ']\n\nlet solve input = List.rev (traverse input)\n\nlet build result =\n let rec loop last list temp =\n (match (temp, last) with\n |(' ' :: tail), ' ' -> loop ' ' list tail\n |(x :: tail), _ -> \n loop x (x :: list) tail\n |[], _ -> List.rev list)\n in loop ' ' [] result\n\nlet rec print list = \n (match list with\n |[' '] -> ()\n |(x :: tail) -> \n Printf.printf \"%c\" x;\n print tail\n |[] -> ())\n\nlet () = print (build (solve (input())))", "positive_code": [{"source_code": "let str_to_list s =\n let rec loop i l =\n if i < 0 \n then l \n else loop (i - 1) (s.[i] :: l) in\n loop (String.length s - 1) []\n\nlet input () = Scanf.scanf \"%s\" (fun s -> str_to_list s)\n\nlet traverse input =\n let rec loop remix original = \n match remix with \n |('W' :: 'U' :: 'B' :: tail) -> loop tail (' ' :: original)\n |[] -> List.rev original\n |(x :: tail) -> loop tail (x :: original)\n in loop input [' ']\n\nlet build result =\n let rec loop last list temp =\n (match (temp, last) with\n |(' ' :: tail), ' ' -> loop ' ' list tail\n |(x :: tail), _ -> \n loop x (x :: list) tail\n |[], _ -> List.rev list)\n in loop ' ' [] result\n\nlet rec print list = \n (match list with\n |[' '] -> ()\n |(x :: tail) -> \n Printf.printf \"%c\" x;\n print tail\n |[] -> ())\n\nlet () = print (build (traverse (input())))"}, {"source_code": "let split_WUB s =\n Str.split (Str.regexp \"WUB\") s\n\nlet add_space words =\n let f word =\n if word = \"\" then word\n else \" \" ^ word\n in\n (List.hd words) :: (List.map f (List.tl words))\n\nlet solve s =\n List.iter (Printf.printf \"%s\") (add_space (split_WUB s))\n\nlet _ =\n Scanf.scanf \" %s\" solve\n \n"}], "negative_code": [], "src_uid": "edede580da1395fe459a480f6a0a548d"} {"source_code": "let ints = read_line () |> Str.split (Str.regexp \" +\") |> List.map int_of_string in\nlet d1 = List.nth ints 0 and\n d2 = List.nth ints 1 and\n d3 = List.nth ints 2 and\n max_int = Int32.shift_right (Int32.max_int) 1 |> Int32.to_int in \nList.fold_right min [d1+d3+d2; d1+d1+d2+d2; d2+d3+d3+d2 ;d1+d3+d3+d1] max_int |> print_int \n", "positive_code": [{"source_code": "\nopen Printf\nopen Scanf\n\nlet ( ** ) a b = Int64.mul a b\nlet ( ++ ) a b = Int64.add a b\nlet ( -- ) a b = Int64.sub a b\nlet long x = Int64.of_int x\n\nlet read_int () = bscanf Scanning.stdib \" %Ld \" (fun x -> x)\n\nlet () = \n let d1 = read_int () in\n let d2 = read_int () in\n let d3 = read_int () in \n\n let answer = min (min ((d1++d2)**2L) (d1++d2++d3)) (min ((d1++d3)**2L) ((d2++d3)**2L)) in\n\n printf \"%Ld\\n\" answer\n"}, {"source_code": "let input () = Scanf.scanf \"%d %d %d\" (fun d1 d2 d3 -> d1, d2, d3)\nlet solve (d1, d2, d3) =\n let p1 = d1 + d2 + d3 in\n let p2 = 2 * d1 + 2 * d2 in\n let p3 = 2 * d1 + 2 * d3 in\n let p4 = 2 * d2 + 2 * d3 in\n let paths = (p1 :: p2 :: p3 :: p4 :: []) in\n let min = List.hd (List.sort (Pervasives.compare) paths) in\n min\nlet print result = Printf.printf \"%d\\n\" result\nlet () = print (solve (input ()))"}], "negative_code": [{"source_code": "let ints = read_line () |> Str.split (Str.regexp \" +\") |> List.map int_of_string in\nlet d1 = List.nth ints 0 and\n d2 = List.nth ints 1 and\n d3 = List.nth ints 2 and\n max_int = Int32.shift_right (Int32.max_int) 1 |> Int32.to_int in \nList.fold_right min [d1+d3+d2; d1+d1+d2+d2; d2+d3+d1] max_int |> print_int "}, {"source_code": "let ints = read_line () |> Str.split (Str.regexp \" +\") |> List.map int_of_string in\nlet d1 = List.nth ints 0 and\n d2 = List.nth ints 1 and\n d3 = List.nth ints 2 and\n max_int = Int32.shift_right (Int32.max_int) 1 |> Int32.to_int in\nList.fold_right min [d1+d3+d2; d1+d1+d2+d2; d2+d3+d1; d2+d3+d3+d2] max_int |> print_int\n"}, {"source_code": "let ints = read_line () |> Str.split (Str.regexp \" +\") |> List.map int_of_string in\nlet d1 = List.nth ints 0 and\n d2 = List.nth ints 1 and\n d3 = List.nth ints 2 and\n max_int = Int32.shift_right (Int32.max_int) 1 |> Int32.to_int in \nList.fold_right min [d1+d3+d2; d1+d1+d2+d2; d2+d3+d1; d2+d3+d3+d2] max_int |> print_int \n"}, {"source_code": "\nopen Printf\nopen Scanf\n\nlet ( ** ) a b = Int64.mul a b\nlet ( ++ ) a b = Int64.add a b\nlet ( -- ) a b = Int64.sub a b\nlet long x = Int64.of_int x\n\nlet read_int () = bscanf Scanning.stdib \" %Ld \" (fun x -> x)\n\nlet () = \n let d1 = read_int () in\n let d2 = read_int () in\n let d3 = read_int () in \n\n let answer = min ((d1++d2)**2L) (d1++d2++d3) in\n\n printf \"%Ld\\n\" answer\n"}, {"source_code": "\nopen Printf\nopen Scanf\n\nlet read_int () = bscanf Scanning.stdib \" %d \" (fun x -> x)\n\nlet () = \n let d1 = read_int () in\n let d2 = read_int () in\n let d3 = read_int () in \n\n let answer = min ((d1+d2)*2) (d1+d2+d3) in\n\n printf \"%d\\n\" answer\n"}], "src_uid": "26cd7954a21866dbb2824d725473673e"} {"source_code": "open Printf\nopen Scanf\n\nlet rec fold i j f init = if i>j then init else fold (i+1) j f (f i init)\nlet sum i j f = fold i j (fun i a -> (f i) + a) 0\n\nlet read_int _ = bscanf Scanning.stdib \" %d \" (fun x -> x)\nlet () = \n let n = read_int () in\n let k = read_int () in\n let a = Array.init n read_int in\n\n let s = sum 0 (n-1) (fun i -> a.(i)) in\n\n printf \"%d\\n\" (max 0 (2*n*k - n - 2 * s))\n", "positive_code": [{"source_code": "let read () = Scanf.scanf \" %d\" (fun x -> x) and\n foi = float_of_int in\nlet (k,n) = (read(), read()) in\nlet s = ref 0 in\nfor i = 0 to n-1 do s := !s + (read()) done;\nlet (fn , fs, fk ) = (foi n, foi !s, foi k) in\nprint_int @@ if fs /. fn > fk -. 0.5 then 0 else int_of_float @@ ((fn *. (fk -. 0.5)) -. fs) /. 0.5"}], "negative_code": [{"source_code": "let read () = Scanf.scanf \" %d\" (fun x -> x) and\n foi = float_of_int in\nlet (k,n) = (read(), read()) in\nlet s = ref 0 in\nfor i = 0 to n-1 do s := !s + (read()) done;\nlet (fn , fs, fk ) = (foi n, foi !s, foi k) in\nprint_int @@ int_of_float @@ ((fn *. (fk -. 0.5)) -. fs) /. 0.5"}], "src_uid": "f22267bf3fad0bf342ecf4c27ad3a900"} {"source_code": "let ps = [\"vaporeon\"; \"jolteon\"; \"flareon\"; \"espeon\"; \"umbreon\"; \"leafeon\"; \"glaceon\"; \"sylveon\"]\n\nlet () =\n Scanf.scanf \"%d %s \" (fun n s ->\n let pat = Str.regexp (\"^\" ^ s ^ \"$\") in\n print_endline (List.find (fun p -> Str.string_match pat p 0) ps))\n;;", "positive_code": [{"source_code": "let ps = [\"vaporeon\"; \"jolteon\"; \"flareon\"; \"espeon\"; \"umbreon\"; \"leafeon\"; \"glaceon\"; \"sylveon\"]\n\nlet () =\n Scanf.scanf \"%d %s \" (fun n s ->\n let pat = Str.regexp s in\n print_endline (List.find (fun p -> String.length s = String.length p && Str.string_match pat p 0) ps))\n;;"}], "negative_code": [{"source_code": "let ps = [\"vaporeon\"; \"jolteon\"; \"flareon\"; \"espeon\"; \"umbreon\"; \"leafeon\"; \"glaceon\"; \"sylveon\"]\n\nlet () =\n Scanf.scanf \"%d %s \" (fun n s ->\n let pat = Str.regexp s in\n print_endline (List.find (fun p -> Str.string_match pat p 0) ps))\n;;\n"}], "src_uid": "ec3d15ff198d1e4ab9fd04dd3b12e6c0"} {"source_code": "let _ =\n let sb = Scanf.Scanning.stdib in\n let a = Scanf.bscanf sb \"%d \" (fun s -> s) in\n let b = Scanf.bscanf sb \"%d \" (fun s -> s) in\n let a = a - 1 in\n let d = [| 6; 2; 5; 5; 4; 5; 6; 3; 7; 6 |] in\n let t = 49 in\n let rec calc n =\n if n = 0\n then 0\n else (\n let r = ref 0 in\n let c = n mod 10 in\n\tif c = 0\n\tthen (\n\t let m = ref n in\n\t while !m > 0 do\n\t r := !r + d.(!m mod 10);\n\t m := !m / 10;\n\t done;\n\t (*Printf.printf \"qwe1 %d %d\\n\" n (!r - d.(0) + t * (n / 10));*)\n\t !r - d.(0) + t * (n / 10) + 10 * calc ((n - 1) / 10);\n\t) else (\n\t let m = ref n in\n\t while !m > 0 do\n\t r := !r + d.(!m mod 10);\n\t m := !m / 10;\n\t done;\n\t r := (!r - d.(c)) * c;\n\t for i = 1 to c do\n\t r := !r + d.(i);\n\t done;\n\t (*!r + t * (n / 10) + 10 * calc (n / 10)*)\n\t (*Printf.printf \"qwe2 %d %d\\n\" n !r;*)\n\t !r + calc (n - c)\n\t)\n )\n in\n let res = calc b - calc a in\n Printf.printf \"%d\\n\" res\n", "positive_code": [{"source_code": "open Printf\nopen Scanf\n\nlet rec fold i j f init = if i>j then init else fold (i+1) j f (f i init)\nlet sum i j f = fold i j (fun i a -> (f i) + a) 0\n \nlet read_pair () = bscanf Scanning.stdib \" %d %d \" (fun x y -> (x,y))\nlet () = \n let (a,b) = read_pair () in\n\n let tab = [|6;2;5;5;4;5;6;3;7;6|] in\n (* 0 1 2 3 4 5 6 7 8 9 *)\n\n let score x = if x=0 then tab.(0) else\n let rec loop x = if x=0 then 0 else tab.(x mod 10) + loop (x/10) in\n loop x\n in\n \n printf \"%d\\n\" (sum a b score)\n"}, {"source_code": "let num_segs = function\n | 0 -> 6\n | 1 -> 2\n | 2 -> 5\n | 3 -> 5\n | 4 -> 4\n | 5 -> 5\n | 6 -> 6\n | 7 -> 3\n | 8 -> 7\n | 9 -> 6\n\nlet rec total_segs = function\n | 0 -> 0\n | n -> num_segs (n mod 10) + total_segs (n / 10)\n\nlet () =\n let [lo; hi] = read_line ()\n |> Str.split (Str.regexp \" \")\n |> List.map int_of_string in\n let sum = ref 0 in\n for i = lo to hi do\n sum := !sum + total_segs i\n done;\n print_int !sum;\n print_newline ()\n"}, {"source_code": "let xint() = Scanf.scanf \" %d\" (fun x -> x)\n\nlet () = \n let a = xint() and b = xint() in\n let s = Array.make 1000001 0 in\n s.(0) <- 6;\n s.(1) <- 2;\n s.(2) <- 5;\n s.(3) <- 5;\n s.(4) <- 4;\n s.(5) <- 5;\n s.(6) <- 6;\n s.(7) <- 3;\n s.(8) <- 7;\n s.(9) <- 6;\n for i = 10 to 1000000 do\n s.(i) <- s.(i / 10) + s.(i mod 10);\n done;\n let sum = ref 0 in\n for i = a to b do\n sum := !sum + s.(i);\n done;\n Printf.printf \"%d\\n\" !sum;\n"}], "negative_code": [{"source_code": "let _ =\n let sb = Scanf.Scanning.stdib in\n let n = Scanf.bscanf sb \"%d \" (fun s -> s) in\n let a = Array.make n 0 in\n let _ =\n for i = 0 to n - 1 do\n a.(i) <- Scanf.bscanf sb \"%d \" (fun s -> s)\n done;\n in\n let ks = ref [] in\n let ht = Hashtbl.create 10 in\n let prev = ref (-1) in\n for i = 0 to n - 1 do\n if Hashtbl.mem ht a.(i) then (\n\tks := (!prev + 1, i) :: !ks;\n\tprev := i;\n\tHashtbl.clear ht;\n ) else (\n\tHashtbl.replace ht a.(i) ()\n )\n done;\n let ks =\n if !prev = n - 1\n then !ks\n else (\n\tmatch !ks with\n\t | [] ->\n\t Printf.printf \"-1\\n\";\n\t exit 0\n\t | (l, r) :: ks ->\n\t (l, n - 1) :: ks\n )\n in\n let ks = List.rev ks in\n Printf.printf \"%d\\n\" (List.length ks);\n List.iter\n\t(fun (l, r) ->\n\t Printf.printf \"%d %d\\n\" (l + 1) (r + 1)\n\t) ks\n"}], "src_uid": "1193de6f80a9feee8522a404d16425b9"} {"source_code": "(* Codeforces *)\n\n(* you can use either gr or rdln but not both *)\nlet gr () = Scanf.scanf \" %d\" (fun i -> i);;\nlet grf () = Scanf.scanf \" %f\" (fun i -> i);;\nlet grl () = Scanf.scanf \" %Ld\" (fun i -> i);;\nlet rdln() = input_line stdin;;\n(* let spli s = Str.split (Str.regexp \" \") s;; *)\nlet printlisti li = List.iter (fun i -> (print_int i; print_string \" \")) li;;\nlet printarri ai = Array.iter (fun i -> (print_int i; print_string \" \")) ai;;\nlet debug = false;;\n\nlet rec readlist n acc = match n with\n| 0 -> acc\n| _ -> readlist (n -1) (gr() :: acc);;\nlet printlisti li = List.iter (fun i -> (print_int i; print_string \" \")) li;;\nlet printlists ls = List.iter (fun s -> (print_string s; print_string \" \")) ls;;\n\nlet rec head_cnt k cnt l = match l with\n| [] -> (cnt, [])\n| h :: tl ->\n\tif h > k then (cnt, l)\n\telse head_cnt k (cnt+1) tl;;\n\nlet main() =\n\tlet n = gr () in\n\tlet k = gr () in\n\tlet a = readlist n [] in\n\tlet ha, tl = head_cnt k 0 a in\n\tlet rev_tl = List.rev tl in\n\tlet ta, _ = head_cnt k 0 rev_tl in\t\n\tbegin\n\t\t(* print_string \"a = \"; printlisti a;\n\t\tprint_string \" ha = \";\n\t\tprint_int ha; print_string \" ta = \";\n\t\tprint_int ta; print_string \" \\n\"; *)\t\t\n\t\tprint_int (ha + ta);\n\t\tprint_string \"\\n\"\n end;;\n\nmain();;", "positive_code": [{"source_code": "let ( */ ) = Big_int.mult_big_int;;\nlet ( +/ ) = Big_int.add_big_int;;\nlet ( -/ ) = Big_int.sub_big_int;;\nlet to_int = Big_int.int_of_big_int;;\nlet of_int = Big_int.big_int_of_int;;\nlet min = Big_int.min_big_int;;\nlet (modi) = Big_int.mod_big_int;;\nlet to_string = Big_int.string_of_big_int;;\nlet of_string = Big_int.big_int_of_string;;\nlet ( n,k) in\nlet problem = read_line () |> split_on_char ' ' |> List.map int_of_string |> Array.of_list in\nlet count = ref 0 in\nwhile !count < n && problem.(!count) <= k do\n incr count;\ndone;\nlet tmp = !count in\nbegin try\n for i = n - 1 downto tmp + 1 do\n if problem.(i) > k then raise End;\n incr count;\n done\n with End -> ();\nend;\nPrintf.printf \"%i\" !count;\nprint_newline ();\n"}], "negative_code": [], "src_uid": "ecf0ead308d8a581dd233160a7e38173"} {"source_code": "(* http://codeforces.com/contest/104/problem/A *)\n\nlet f n = \n if 0 <= n && n <= 10 then 0\n else if 11 <= n && n <= 19 then 4\n else if n = 20 then 15\n else if n = 21 then 4\n else 0;;\nPrintf.printf \"%d\\n\" (Scanf.scanf \"%d\" f);;\n\n\n", "positive_code": [{"source_code": "let n = read_int () - 10 in\nprint_int (if n = 10 then 15\nelse if n >= 1 && n <= 11 then 4\nelse 0)\n"}], "negative_code": [{"source_code": "(* http://codeforces.com/contest/104/problem/A *)\n\nlet f n = \n if 0 <= n && n <= 10 then 0\n else if 11 <= n && n <= 19 then 4\n else if n = 20 then 15\n else if n = 21 then 1\n else 0;;\nPrintf.printf \"%d\\n\" (Scanf.scanf \"%d\" f);;\n"}], "src_uid": "5802f52caff6015f21b80872274ab16c"} {"source_code": "open Int64;;\nlet scan_int () = Scanf.scanf \" %d\" (fun x -> x)\nlet scan_ll () = Scanf.scanf \" %Ld\" (fun x -> x)\nlet pom = function (4 | 7) -> 1 | _ -> 0;;\n\nlet rec fart n =\n\tlet rec lucky x acc = match x with\n\t\t|0L -> acc \n\t\t|_ -> lucky (div x 10L) (acc + (pom(to_int(rem x 10L))))\n\tin\nlucky n 0;;\n\nlet n = scan_ll ()\nlet kek = fart n;;\n(*print_int kek;;*)\n\nlet s = match kek with\n\t|(4 | 7) -> \"YES\"\n\t|_ ->\"NO\"\n;;\n\nprint_string s;;\n\n", "positive_code": [{"source_code": "let n = read_line() in\nlet m = ref 0 in\nlet _ = String.iter (function\n\t| ('4'|'7') -> incr m\n\t| _ -> ()\n) n in\nprint_string (if !m = 4 || !m = 7 then \"YES\" else \"NO\");\n"}, {"source_code": "open Int64;;\nlet scan_int () = Scanf.scanf \" %d\" (fun x -> x)\nlet scan_ll () = Scanf.scanf \" %Ld\" (fun x -> x)\nlet ten = of_int(10);;\nlet zero = of_int(0);;\nlet pom = function (4 | 7) -> 1 | _ -> 0;;\n\nlet rec fart n =\n\tlet rec lucky x acc =\n\t\tif x = zero then acc \n\t\telse lucky (div x ten) (acc + (pom(to_int(rem x ten))))\n\tin\nlucky n 0;;\n\nlet n = scan_ll ()\nlet kek = fart n;;\n(*print_int kek;;*)\n\nlet s = match kek with\n\t|(4 | 7) -> \"YES\"\n\t|_ ->\"NO\"\n;;\n\nprint_string s;;\n\n"}, {"source_code": "let str_to_list s =\n let rec loop i l =\n if i < 0 \n then l \n else loop (i - 1) (s.[i] :: l) in\n loop (String.length s - 1) []\n\nlet input () = Scanf.scanf \"%s\" (fun s -> (str_to_list s))\n\nlet is_lucky_numbers = function \n |'4' | '7'-> true\n |_ -> false\n\nlet count input = List.length(List.filter(is_lucky_numbers) input)\n\nlet solve input = \n if is_lucky_numbers(String.get (Pervasives.string_of_int(count input)) 0)\n then\n \"YES\"\n else\n \"NO\"\n\nlet print result = Printf.printf \"%s\\n\" result\n\nlet () = print (solve (input ())) \n\n"}], "negative_code": [{"source_code": "let n = String.length (read_line()) in\nprint_string (if n = 4 || n = 7 then \"YES\" else \"NO\")\n"}], "src_uid": "33b73fd9e7f19894ea08e98b790d07f1"} {"source_code": "let solve a b r =\n let diameter = 2 * r in\n if diameter <= a && diameter <= b then \"First\"\n else \"Second\"\n\n\nlet _ =\n Printf.printf \"%s\\n\" (Scanf.scanf \"%d %d %d\\n\" solve)\n \n\n", "positive_code": [{"source_code": "module Std = struct\n\n module List = struct\n include List\n module L = List\n let map f lst = L.rev (L.rev_map f lst)\n let map2 f l1 l2 = L.rev (L.rev_map2 f l1 l2)\n let each_cons f lst = L.rev_map2 f (L.tl (L.rev lst)) (L.rev (L.tl lst))\n let append x y = L.rev (L.rev_append x y)\n let fold = L.fold_left\n let permute_with lst p = L.map (Array.get (Array.of_list lst)) p\n end\n\n let ( |> ) x f = f x\n let ( <| ) f x = f x\n let ( ~. ) = float_of_int\n let ( @ ) = List.append\n\n let rec repeat n f x = if n = 0 then x else repeat (n-1) f (f x)\n\n let di x = prerr_endline (string_of_int x); x\n let df f = prerr_endline (string_of_float f); f\n let ds s = prerr_endline s; s\n \n let int () = Scanf.scanf \" %d\" (fun x -> x)\n let read_int = int\n let float () = Scanf.scanf \" %f\" (fun x -> x)\n let read_float = float\n let rec n_int n () = List.rev <| repeat n (fun lst -> int () :: lst) []\n let rec n_float n () = List.rev <| repeat n (fun lst -> float () :: lst) []\n\nend\n\nopen Std\nmodule L = List\n\n(* entry point *)\n\nlet a = int ()\nlet b = int ()\nlet r = int ()\n\nlet () =\n Printf.printf \"%s\\n\"\n (if r*2 <= a && r*2 <= b then \"First\"\n else \"Second\")\n\n\n\n\n\n\n\n\n\n\n\n"}, {"source_code": "let ni = fun _ -> Scanf.scanf \" %d\" (fun x -> x) in\nlet a = ni () in\nlet b = ni () in\nlet d = 2 * ni () in\nprint_string (if a >= d && b >= d then \"First\" else \"Second\");;\n"}], "negative_code": [{"source_code": "let solve a b r =\n let diam = 2 * r in\n let plate_in_a_row len r =\n len/(2*diam-1) + (len-(len/(2*diam-1))*(2*diam-1))/diam\n in\n if ((plate_in_a_row a r) * (plate_in_a_row b r)) mod 2 == 0 then \"Second\"\n else \"First\"\n\nlet _ =\n Printf.printf \"%s\\n\" (Scanf.scanf \"%d %d %d\\n\" solve)\n \n\n"}, {"source_code": "let solve a b r =\n let diam = 2 * r in\n let vdiam = 4*r - 1 in\n let max_in_a_row n r =\n ((n/vdiam) + (n-(a/vdiam))/diam)\n in\n if ( (max_in_a_row a r) * (max_in_a_row b r) ) mod 2 == 0 then \"Second\"\n else \"First\"\n\nlet _ =\n Printf.printf \"%s\\n\" (Scanf.scanf \"%d %d %d\\n\" solve)\n \n\n"}, {"source_code": "let solve a b r =\n let diam = 2 * r in\n let plate_in_a_row len r =\n len/(2*diam-1) + (len-(len/(2*diam-1)))/diam\n in\n if ((plate_in_a_row a r) * (plate_in_a_row b r)) mod 2 == 0 then \"Second\"\n else \"First\"\n\nlet _ =\n Printf.printf \"%s\\n\" (Scanf.scanf \"%d %d %d\\n\" solve)\n \n\n"}, {"source_code": "let solve a b r =\n let diameter = 2 * r in\n if ((a/diameter) * (b/diameter)) mod 2 == 0 then \"Second\"\n else \"First\"\n\nlet _ =\n Printf.printf \"%s\\n\" (Scanf.scanf \"%d %d %d\\n\" solve)\n \n\n"}], "src_uid": "90b9ef939a13cf29715bc5bce26c9896"} {"source_code": "let (|>) x f = f x ;;\nlet (@@) f x = f x ;;\n\nlet ident x = x ;;\nlet ident2 x y = (x, y) ;;\nlet ident3 x y z = (x, y, z) ;;\nlet ident4 x y z w = (x, y, z, w) ;;\nlet ident5 x y z w v = (x, y, z, w, v) ;;\n\nlet char_to_int x = int_of_char x - int_of_char '0' ;;\nlet int_to_char x = char_of_int (x + int_of_char '0') ;;\n\nmodule List = struct\n include ListLabels ;;\n\n let rec iteri i f = function\n | [] -> ()\n | a::l -> f i a; iteri (i + 1) f l\n\n let iteri ~f l = iteri 0 f l\nend\n;;\n\nmodule Array = struct\n include ArrayLabels ;;\n\n let reduce ~f xs =\n let acc = ref xs.(0) in\n for i = 1 to length xs - 1 do\n acc := f !acc xs.(i)\n done;\n !acc\n ;;\nend\n;;\n\nmodule String = struct\n include StringLabels ;;\n\n let map_to_list ~f ss =\n let res = ref [] in\n iter ss ~f:(fun c -> res := f c :: !res);\n List.rev !res\n ;;\n\n let of_char_list ss =\n let res = String.create @@ List.length ss in\n List.iteri ss ~f:(fun i c -> res.[i] <- c);\n res\n ;;\n\n let iteri ~f a =\n for i = 0 to length a - 1 do f i (unsafe_get a i) done\n ;;\nend\n;;\n\nmodule Float = struct\n let (+) = (+.)\n let (-) = (-.)\n let ( * ) = ( *. )\n let (/) = (/.)\nend\n;;\n\nmodule Int64 = struct\n include Int64\n let (+) = add\n let (-) = sub\n let ( * ) = mul\n let (/) = div\nend\n;;\n\nlet fold_for ?(skip=1) min max ~init ~f =\n let acc = ref init in\n let cur = ref min in\n while !cur < max do\n acc := f !acc !cur;\n cur := !cur + skip;\n done;\n !acc\n;;\n\nlet iter_for ?(skip=1) min max ~f =\n let cur = ref min in\n while !cur < max do\n f !cur;\n cur := !cur + skip;\n done\n;;\n\nlet () =\n let n = Scanf.scanf \"%d \" ident in\n let xs = fold_for 0 n ~init:[] ~f:(fun acc x ->\n Scanf.scanf \"%d \" ident :: acc) |> List.rev in\n let rec iter ps prev = function\n | [] -> print_endline \"no\"\n | cur :: xs ->\n let x, y = (min cur prev, max cur prev) in\n List.iter ps ~f:(fun (x, y) -> Printf.eprintf \"%d, %d\\n\" x y);\n prerr_endline \"ok\";\n if List.exists ps ~f:(fun (x', y') ->\n x < x' && x' < y && y < y' ||\n x' < x && x < y' && y' < y) then\n print_endline \"yes\"\n else iter ((x, y) :: ps) cur xs in\n match xs with\n | [] -> assert false\n | x :: xs -> iter [] x xs\n;;\n", "positive_code": [{"source_code": "let (|>) x f = f x\nlet (<|) f x = f x\n\nlet rec loop n f acc = \n if n = 0 then List.rev acc else loop (n-1) f ((f n) :: acc)\n\nlet next_int () = Scanf.scanf \"%d%c\" (fun x _ -> x)\n\nlet rec make_pair l acc = \n match l with\n\t[] -> acc\n | [x] -> acc\n | x :: ((y :: ys) as xs) -> make_pair xs ((if x <= y then (x, y) else (y, x) ):: acc)\n\n\nlet n = next_int()\n\nlet a = loop n (fun _ -> next_int ()) []\nlet b = make_pair a []\n;;\n\n\nlet valid p = \n let intersect q = \n\tlet x1 = fst p in\n\tlet y1 = snd p in\n\tlet x2 = fst q in\n\tlet y2 = snd q in\n\tif x1 <= x2 then x2 > x1 && x2 < y1 && y2 > y1 \n\telse y2 > x1 && y2 < y1 in\n List.exists intersect b\n;;\n\nlet () = \n(* List.iter (fun (x, y) -> print_int x; print_string \" \"; print_int y;\n print_string \"\\n\") b; *)\nif List.exists valid b then print_string \"yes\" else print_string \"no\"\n"}], "negative_code": [{"source_code": "let (|>) x f = f x\nlet (<|) f x = f x\n\nlet rec loop n f acc = \n if n = 0 then List.rev acc else loop (n-1) f ((f n) :: acc)\n\nlet next_int () = Scanf.scanf \"%d%c\" (fun x _ -> x)\n\nlet rec make_pair l acc = \n match l with\n\t[] -> acc\n | [x] -> acc\n | x :: ((y :: ys) as xs) -> make_pair xs ((x, y) :: acc)\n\n\nlet n = next_int()\n\nlet a = loop n (fun _ -> next_int ()) []\nlet b = make_pair a []\n\nlet valid p = \n let intersect q = \n\tlet x1 = fst p in\n\tlet y1 = snd p in\n\tlet x2 = fst q in\n\tlet y2 = snd q in\n\tif x1 <= x2 then x2 < y1 && y2 > y1 \n\telse y2 > x1 && y2 < y1 in\n List.exists intersect b\n\nlet () = if List.exists valid b then print_string \"yes\" else print_string \"no\"\n"}, {"source_code": "let (|>) x f = f x\nlet (<|) f x = f x\n\nlet rec loop n f acc = \n if n = 0 then List.rev acc else loop (n-1) f ((f n) :: acc)\n\nlet next_int () = Scanf.scanf \"%d%c\" (fun x _ -> x)\n\nlet rec make_pair l acc = \n match l with\n\t[] -> acc\n | [x] -> acc\n | x :: ((y :: ys) as xs) -> make_pair xs ((if x <= y then (x, y) else (y, x) ):: acc)\n\n\nlet n = next_int()\n\nlet a = loop n (fun _ -> next_int ()) []\nlet b = make_pair a []\n;;\n\n\nlet valid p = \n let intersect q = \n\tlet x1 = fst p in\n\tlet y1 = snd p in\n\tlet x2 = fst q in\n\tlet y2 = snd q in\n\tif x1 <= x2 then x2 < y1 && y2 > y1 \n\telse y2 > x1 && y2 < y1 in\n List.exists intersect b\n;;\n\nlet () = if List.exists valid b then print_string \"yes\" else print_string \"no\"\n"}], "src_uid": "f1b6b81ebd49f31428fe57913dfc604d"} {"source_code": "\nlet in_channel = stdin;;\n\nlet n = int_of_string (input_line in_channel);;\n\n\nlet s = input_line in_channel;;\n\nlet rec count a = match (String.length a) with\n| 0 -> 0\n| 1 -> 1\n| _ -> (\n\tif ((String.sub a 0 2) = \"RU\" || (String.sub a 0 2) = \"UR\") then\n\t\t1 + count (String.sub a 2 ((String.length a) - 2))\n\telse \n\t\t1 + count (String.sub a 1 ((String.length a) - 1))\n);;\n\nPrintf.printf \"%d\\n\" (count s);;\n\n\n", "positive_code": [{"source_code": "\n\nlet read_int () = Scanf.scanf \" %d\" (fun x -> x);;\nlet read_string () = Scanf.scanf \" %s\" (fun x -> x);;\n\nlet n = read_int();;\n\nlet s = read_string();;\n\nlet rec cut s = match (String.length s) with\n | 0 -> 0\n | 1 -> 1\n | _ ->\n if (String.get s 0 = String.get s 1) then 1 + cut(String.sub s 1 ((String.length s) - 1))\n else 1 + cut(String.sub s 2 ((String.length s) - 2));;\n\n\n\nPrintf.printf \"%d\\n\" (cut s);\n"}], "negative_code": [{"source_code": "\n\nlet read_int () = Scanf.scanf \" %d\" (fun x -> x);;\nlet read_string () = Scanf.scanf \" %s\" (fun x -> x);;\n\nlet s = read_string();;\n\nlet rec cut s = match (String.length s) with\n | 0 -> 0\n | 1 -> 1\n | _ ->\n if (String.get s 0 = String.get s 1) then 1 + cut(String.sub s 1 ((String.length s) - 1))\n else 1 + cut(String.sub s 2 ((String.length s) - 2));;\n\n\n\nPrintf.printf \"%d\\n\" (cut s);\n"}], "src_uid": "986ae418ce82435badadb0bd5588f45b"} {"source_code": "let read_int () = Scanf.bscanf Scanf.Scanning.stdib \" %d \" (fun x -> x)\n\nlet rec fold i j f init = if i>j then init else fold (i+1) j f (f i init)\nlet sum i j f = fold i j (fun i a -> (f i) + a) 0\n\nlet () = \n let a = Array.make_matrix 3 3 0 in\n for i=0 to 2 do\n for j=0 to 2 do\n\ta.(i).(j) <- read_int()\n done\n done;\n\n let ismagic () =\n let s = sum 0 2 (fun i -> a.(i).(i)) in\n\tsum 0 2 (fun i -> a.(i).(2-i)) = s &&\n(*\tsum 0 2 (fun i -> a.(0).(i)) = s && \n\tsum 0 2 (fun i -> a.(1).(i)) = s &&\n\tsum 0 2 (fun i -> a.(2).(i)) = s && *)\n\tsum 0 2 (fun i -> a.(i).(0)) = s &&\n\tsum 0 2 (fun i -> a.(i).(1)) = s &&\n\tsum 0 2 (fun i -> a.(i).(2)) = s\n in\n\n let rec loop t = if t>100_000 then false else (\n a.(0).(0) <- t;\n let s = t + a.(0).(1) + a.(0).(2) in\n\ta.(1).(1) <- s - a.(1).(0) - a.(1).(2);\n\ta.(2).(2) <- s - a.(2).(0) - a.(2).(1);\n\tif ismagic () then true else loop (t+1)\n )\n in\n\n if loop 0 then (\n\tfor i=0 to 2 do\n\t for j=0 to 2 do\n\t Printf.printf \"%d \" a.(i).(j)\n\t done;\n\t print_newline()\n\tdone\n ) else (\n\tPrintf.printf \"impossible\\n\"\n )\n", "positive_code": [{"source_code": "(* Codeforces 257B SlonMagSquare *)\n\nopen Filename;;\nopen String;;\n\n(* you can use either gr or rdln but not both *)\nlet use_input_txt = false;;\nlet fn = (Filename.dirname Filename.current_dir_name);;\nlet filename = Filename.concat \".\" \"input.txt\";;\nlet cin = if use_input_txt then Scanf.Scanning.open_in filename\n\telse Scanf.Scanning.stdin;;\n\nlet cout = open_out \"output.txt\";;\nlet gr () = Scanf.bscanf cin \" %d\" (fun i -> i);;\nlet grf () = Scanf.scanf \" %f\" (fun i -> i);;\nlet grl () = Scanf.scanf \" %Ld\" (fun i -> i);;\nlet rdln() = input_line Pervasives.stdin;;\n(* let spli s = Str.split (Str.regexp \" \") s;; *)\nlet printlisti li = List.iter (fun i -> (print_int i; print_string \" \")) li;;\nlet printarri ai = Array.iter (fun i -> (print_int i; print_string \" \")) ai;;\nlet debug = false;;\n\nlet mg = Array.make_matrix 3 3 0;;\n\nlet readmat () =\n\tbegin\n\t\tfor i = 0 to 2 do\n\t\t\tfor j = 0 to 2 do\n\t\t\t\tmg.(i).(j) <- gr()\n\t\t\tdone\n\t\tdone\n\tend;;\n\nlet solve() =\n\tlet cma = (mg.(0).(1) + mg.(0).(2) - mg.(2).(0) - mg.(2).(1)) in\n\tlet bma = mg.(0).(1) + mg.(0).(2) - mg.(1).(0) - mg.(1).(2) in\n\tlet cpa = mg.(2).(0) + mg.(0).(2) in\n\tlet c = (cpa + cma) / 2 in\n\tlet a = (cpa - cma) / 2 in\n\tlet b = a + bma in\n\tbegin\n\t\tmg.(0).(0) <- a;\n\t\tmg.(1).(1) <- b;\n\t\tmg.(2).(2) <- c;\n\tend;;\n\nlet printmat () =\n\tfor i = 0 to 2 do\n\t\tbegin\n\t\t\tfor j = 0 to 2 do\n\t\t\t\tbegin\n\t\t\t\t\tprint_int mg.(i).(j);\n\t\t\t\t\tprint_string \" \"\n\t\t\t\tend\n\t\t\tdone;\n\t\t\tprint_newline ()\n\t\tend\n\tdone;;\n\nlet main () =\n\tbegin\n\t\treadmat ();\n\t\tsolve();\n\t\tprintmat()\t\t\n\tend;;\n\nmain();;\n"}], "negative_code": [], "src_uid": "0c42eafb73d1e30f168958a06a0f9bca"} {"source_code": "let s = Scanf.scanf \"%s \" ( fun x -> x) |> String.lowercase\n\nlet h = \"hello\";;\nlet j = ref 0;;\nlet c = ref (String.get h !j);;\nlet flag = ref \"NO\";;\n\nexception Success;;\n try\nfor i = 0 to String.length s - 1 do\n let si = String.get s i in\n if(si == !c) then\n begin\n incr j;\n if (!j > 4) then raise Success;\n c := String.get h !j;\n end\ndone\n with Success -> flag := \"YES\";;\n\n print_endline !flag;;\n", "positive_code": [{"source_code": "let input () = Scanf.scanf \"%s\" (fun s -> s)\n\nlet rec traverse input target i n =\n if i < String.length target\n then \n if n < String.length input\n then\n let char = String.get input n in\n if char = String.get target i\n then\n traverse input target (i + 1) (n + 1)\n else\n traverse input target i (n + 1)\n else\n \"NO\"\n else\n \"YES\"\n\n\nlet solve input = traverse input \"hello\" 0 0\n\nlet print result = Printf.printf \"%s\\n\" result\n\nlet () = print (solve (input ()))"}, {"source_code": "let input () = Scanf.scanf \"%s\" (fun s -> s)\n\nlet rec traverse input target i n =\n if n < String.length input\n then\n if i < String.length target\n then\n let char = String.get input n in\n if char = String.get target i\n then\n if i + 1 = String.length target\n then\n \"YES\"\n else\n traverse input target (i + 1) (n + 1)\n else\n traverse input target i (n + 1)\n else\n \"NO\"\n else\n \"NO\"\n\nlet solve input = traverse input \"hello\" 0 0\n\nlet print result = Printf.printf \"%s\\n\" result\n\nlet () = print (solve (input ()))"}, {"source_code": "open List;;\n\nlet chat = fun s -> \n let hello = ['h';'e';'l';'l';'o'] in\n\n let rec pom l i len =\n if i > len || (i = len && l != [] ) then \n print_string \"NO\"\n else\n match l with \n |[] -> print_string \"YES\"\n | hl::tl -> if s.[i] = hl then pom tl (i + 1) len\n else pom l (i + 1) len\n in pom hello 0 (String.length s)\n;;\n\nScanf.scanf \"%s\" chat;;\n\n"}, {"source_code": "let s = read_line () in\nlet a = try\n\tlet i = ref 0 in\n\tlet _ = String.iter (fun c ->\n\t\ti := String.index_from s (!i) c + 1\n\t) \"hello\" in \n\t\"YES\"\nwith _ -> \"NO\" in\nprint_string a;;\n"}], "negative_code": [{"source_code": "let input () = Scanf.scanf \"%s\" (fun s -> s)\n\nlet rec traverse input target i n =\n if n < String.length input\n then\n if i + 1 < String.length target\n then\n let char = String.get input n in\n if char = String.get target i\n then\n traverse input target (i + 1) (n + 1)\n else\n traverse input target i (n + 1)\n else\n \"YES\"\n else\n \"NO\"\n\nlet solve input = traverse input \"hello\" 0 0\n\nlet print result = Printf.printf \"%s\\n\" result\n\nlet () = print (solve (input ()))"}, {"source_code": "let input () = Scanf.scanf \"%s\" (fun s -> s)\n\nlet rec traverse input target i n =\n if n < String.length input\n then\n if i < String.length target\n then\n let char = String.get input n in\n if char = String.get target i\n then\n traverse input target (i + 1) (n + 1)\n else\n traverse input target i (n + 1)\n else\n \"YES\"\n else\n \"NO\"\n\nlet solve input = traverse input \"hello\" 0 0\n\nlet print result = Printf.printf \"%s\\n\" result\n\nlet () = print (solve (input ()))"}, {"source_code": "let input () = Scanf.scanf \"%s\" (fun s -> s)\n\nlet rec traverse input target i n =\n if n < String.length input\n then\n if i < String.length target\n then\n let char = String.get input n in\n if char = String.get target i\n then\n if i = String.length target\n then\n \"YES\"\n else\n traverse input target (i + 1) (n + 1)\n else\n traverse input target i (n + 1)\n else\n \"NO\"\n else\n \"NO\"\n\nlet solve input = traverse input \"hello\" 0 0\n\nlet print result = Printf.printf \"%s\\n\" result\n\nlet () = print (solve (input ()))"}, {"source_code": "let input () = Scanf.scanf \"%s\" (fun s -> s)\n\nlet rec traverse input target i n =\n if n < String.length input\n then\n if i = String.length target\n then\n \"YES\"\n else\n let char = String.get input n in\n if char = String.get target i\n then\n traverse input target (i + 1) (n + 1)\n else\n traverse input target i (n + 1)\n else\n \"NO\"\n\nlet solve input = traverse input \"hello\" 0 0\n\nlet print result = Printf.printf \"%s\\n\" result\n\nlet () = print (solve (input ()))"}, {"source_code": "let s = Scanf.scanf \"%s \" ( fun x -> x) |> String.lowercase\n\nlet h = \"hello\";;\nlet j = ref 0;;\nlet c = ref (String.get h !j);;\nlet flag = ref \"NO\";;\n\nexception Success;;\n try\nfor i = 0 to String.length s - 1 do\n let si = String.get s i in\n if(si == !c) then\n begin\n incr j;\n c := String.get h !j;\n if (!j>=4) then raise Success\n end\ndone\n with Success -> flag := \"YES\";;\n\n print_endline !flag;;\n"}], "src_uid": "c5d19dc8f2478ee8d9cba8cc2e4cd838"} {"source_code": "open Big_int\n\nlet (+|) = add_big_int\nlet (-|) = sub_big_int\nlet ( *| ) = mult_big_int\nlet (/|) = div_big_int\nlet bmod = mod_big_int\nlet (=|) = eq_big_int\nlet (/=|) a b = not (a =| b)\nlet (>|) = gt_big_int\nlet (<|) = lt_big_int\nlet (>=|) = ge_big_int\nlet (<=|) = le_big_int\n\nlet n0 = zero_big_int\nlet n1 = unit_big_int\nlet n2 = big_int_of_int 2\nlet n9 = big_int_of_int 9\nlet n10 = big_int_of_int 10\n\nlet _ =\n let sb = Scanf.Scanning.stdib in\n let s = Scanf.bscanf sb \"%s \" (fun s -> s) in\n let n = String.length s in\n let a = Array.make 10 false in\n let b = Array.make 11 0 in\n let cnt = ref 10 in\n let res = ref n1 in\n for i = 0 to n - 1 do\n let c = s.[i] in\n\tmatch c with\n\t | '0'..'9' -> ()\n\t | '?' ->\n\t if i = 0\n\t then b.(9) <- b.(9) + 1\n\t else b.(10) <- b.(10) + 1\n\t | 'A'..'J' ->\n\t let k = Char.code c - Char.code 'A' in\n\t\tif not a.(k) then (\n\t\t a.(k) <- true;\n\t\t if i = 0\n\t\t then b.(9) <- b.(9) + 1\n\t\t else b.(!cnt) <- b.(!cnt) + 1;\n\t\t decr cnt\n\t\t)\n\t | _ -> assert false\n done;\n for i = 1 to 10 do\n res := !res *| power_int_positive_int i b.(i)\n done;\n Printf.printf \"%s\\n\" (string_of_big_int !res)\n\n", "positive_code": [{"source_code": "open Big_int\n\nlet (+|) = add_big_int\nlet (-|) = sub_big_int\nlet ( *| ) = mult_big_int\nlet (/|) = div_big_int\nlet bmod = mod_big_int\nlet (=|) = eq_big_int\nlet (/=|) a b = not (a =| b)\nlet (>|) = gt_big_int\nlet (<|) = lt_big_int\nlet (>=|) = ge_big_int\nlet (<=|) = le_big_int\n\nlet n0 = zero_big_int\nlet n1 = unit_big_int\nlet n2 = big_int_of_int 2\nlet n9 = big_int_of_int 9\nlet n10 = big_int_of_int 10\n\nlet _ =\n let sb = Scanf.Scanning.stdib in\n let s = Scanf.bscanf sb \"%s \" (fun s -> s) in\n let n = String.length s in\n let a = Array.make 10 false in\n let cnt = ref 10 in\n let res = ref n1 in\n for i = 0 to n - 1 do\n let c = s.[i] in\n\tmatch c with\n\t | '0'..'9' -> ()\n\t | '?' ->\n\t if i = 0\n\t then res := !res *| n9\n\t else res := !res *| n10\n\t | 'A'..'J' ->\n\t let k = Char.code c - Char.code 'A' in\n\t\tif not a.(k) then (\n\t\t a.(k) <- true;\n\t\t if i = 0\n\t\t then res := !res *| n9\n\t\t else res := !res *| (big_int_of_int !cnt);\n\t\t decr cnt\n\t\t)\n\t | _ -> assert false\n done;\n Printf.printf \"%s\\n\" (string_of_big_int !res)\n\n"}], "negative_code": [], "src_uid": "d3c10d1b1a17ad018359e2dab80d2b82"} {"source_code": "open Scanf\nopen Printf\nopen Char\n\nlet max a b = if a > b then a else b;;\n\nlet foo d = let a = lowercase d in if(a >= 'a' && a <= 'z') then 0 else 1;; \n\nlet () = \nlet n = scanf \" %d \" (fun x-> x) in\nlet s = scanf \" %s \" (fun x-> x) in\nlet rec calc i l typ len cnt = \nif i < n then match(s.[i]) with\n'(' -> calc (i + 1) 0 true (max len l) cnt\n| ')' -> calc (i + 1) 0 false len cnt\n| '_' -> calc (i + 1) 0 typ (if typ then len else (max len l)) cnt\n| _ -> calc (i + 1) (l + 1) typ len (if typ then cnt + foo s.[i - 1] else cnt) \nelse printf \"%d %d\\n\" (max len l) cnt in calc 0 0 false 0 0;;\n", "positive_code": [{"source_code": "let read_int () = Scanf.bscanf Scanf.Scanning.stdib \" %d \" (fun x -> x)\nlet read_string () = Scanf.bscanf Scanf.Scanning.stdib \" %s \" (fun x -> x)\n\nlet parse_sentence sentence length =\n let w_outside = ref [] in\n let w_inside = ref [] in\n let buffer = Buffer.create length in\n let in_flag = ref false in\n for i = 0 to length - 1 do\n let c = sentence.[i] in\n if c = '(' then\n begin\n in_flag := true;\n if Buffer.length buffer != 0 then\n begin\n w_outside := (Buffer.contents buffer)::!w_outside;\n Buffer.clear buffer;\n end\n end\n\n else if c = ')' then\n begin\n in_flag := false;\n if Buffer.length buffer != 0 then\n begin\n w_inside := (Buffer.contents buffer)::!w_inside;\n Buffer.clear buffer;\n end\n end\n\n else if c = '_' && Buffer.length buffer != 0 then\n begin\n if !in_flag = false then\n begin\n w_outside := (Buffer.contents buffer)::!w_outside;\n Buffer.clear buffer;\n end\n else\n begin\n w_inside := (Buffer.contents buffer)::!w_inside;\n Buffer.clear buffer;\n end\n end\n else if c = '_' then ()\n else if i = length - 1 then\n begin\n Buffer.add_char buffer c;\n w_outside := (Buffer.contents buffer)::!w_outside\n end\n else Buffer.add_char buffer c\n done;\n (!w_outside, !w_inside)\n\nlet () =\n let length = read_int () in\n let sentence = read_string () in\n let (w_outside, w_inside) = parse_sentence sentence length in\n let out_max_length = List.fold_left (fun acc ele ->\n max acc (String.length ele)) 0 w_outside in\n Printf.printf \"%d %d\" out_max_length (List.length w_inside)\n"}], "negative_code": [{"source_code": "let read_int () = Scanf.bscanf Scanf.Scanning.stdib \" %d \" (fun x -> x)\nlet read_string () = Scanf.bscanf Scanf.Scanning.stdib \" %s \" (fun x -> x)\n\nlet parse_sentence sentence length =\n let w_outside = ref [] in\n let w_inside = ref [] in\n let buffer = Buffer.create length in\n let in_flag = ref false in\n let has_parentheses = ref false in\n for i = 0 to length - 1 do\n let c = sentence.[i] in\n if c = '(' then\n begin\n in_flag := true;\n has_parentheses := true;\n if Buffer.length buffer != 0 then\n begin\n w_outside := (Buffer.contents buffer)::!w_outside;\n Buffer.clear buffer;\n end\n end\n\n else if c = ')' then\n begin\n in_flag := false;\n if Buffer.length buffer != 0 then\n begin\n w_inside := (Buffer.contents buffer)::!w_inside;\n Buffer.clear buffer;\n end\n end\n\n else if c = '_' && Buffer.length buffer != 0 then\n begin\n if !in_flag = false then\n begin\n w_outside := (Buffer.contents buffer)::!w_outside;\n Buffer.clear buffer;\n end\n else\n begin\n w_inside := (Buffer.contents buffer)::!w_inside;\n Buffer.clear buffer;\n end\n end\n else if c = '_' then ()\n else if i = length - 1 && Buffer.length buffer != 0 then\n begin\n Buffer.add_char buffer c;\n w_outside := (Buffer.contents buffer)::!w_outside\n end\n else Buffer.add_char buffer c\n done;\n if !has_parentheses then (!w_outside, !w_inside) else ([], [])\n\nlet () =\n let length = read_int () in\n let sentence = read_string () in\n let (w_outside, w_inside) = parse_sentence sentence length in\n let out_max_length = List.fold_left (fun acc ele ->\n max acc (String.length ele)) 0 w_outside in\n Printf.printf \"%d %d\" out_max_length (List.length w_inside)\n"}, {"source_code": "let read_int () = Scanf.bscanf Scanf.Scanning.stdib \" %d \" (fun x -> x)\nlet read_string () = Scanf.bscanf Scanf.Scanning.stdib \" %s \" (fun x -> x)\n\nlet parse_sentence sentence length =\n let w_outside = ref [] in\n let w_inside = ref [] in\n let buffer = Buffer.create length in\n let in_flag = ref false in\n for i = 0 to length - 1 do\n let c = sentence.[i] in\n if c = '(' then\n begin\n in_flag := true;\n if Buffer.length buffer != 0 then begin\n w_outside := (Buffer.contents buffer)::!w_outside;Buffer.clear buffer;\n end\n end\n else if c = ')' then\n begin\n in_flag := false;\n if Buffer.length buffer != 0 then begin\n w_inside := (Buffer.contents buffer)::!w_inside; Buffer.clear buffer;\n end\n end\n else if c = '_' && Buffer.length buffer != 0 then\n begin\n if !in_flag = false then begin\n w_outside := (Buffer.contents buffer)::!w_outside;Buffer.clear buffer;\n end\n else begin\n w_inside := (Buffer.contents buffer)::!w_inside;\n Buffer.clear buffer;\n end\n end\n else if c = '_' then ()\n else Buffer.add_char buffer c\n done;\n (!w_outside, !w_inside)\n\nlet () =\n let length = read_int () in\n let sentence = read_string () in\n let (w_outside, w_inside) = parse_sentence sentence length in\n let out_max_length = List.fold_left (fun acc ele ->\n max acc (String.length ele)) 0 w_outside in\n Printf.printf \"%d %d\" out_max_length (List.length w_inside)\n"}, {"source_code": "let read_int () = Scanf.bscanf Scanf.Scanning.stdib \" %d \" (fun x -> x)\nlet read_string () = Scanf.bscanf Scanf.Scanning.stdib \" %s \" (fun x -> x)\n\nlet parse_sentence sentence length =\n let w_outside = ref [] in\n let w_inside = ref [] in\n let buffer = Buffer.create length in\n let in_flag = ref false in\n for i = 0 to length - 1 do\n let c = sentence.[i] in\n if c = '(' then\n begin\n in_flag := true;\n if Buffer.length buffer != 0 then\n begin\n w_outside := (Buffer.contents buffer)::!w_outside;\n Buffer.clear buffer;\n end\n end\n\n else if c = ')' then\n begin\n in_flag := false;\n if Buffer.length buffer != 0 then\n begin\n w_inside := (Buffer.contents buffer)::!w_inside;\n Buffer.clear buffer;\n end\n end\n\n else if c = '_' && Buffer.length buffer != 0 then\n begin\n if !in_flag = false then\n begin\n w_outside := (Buffer.contents buffer)::!w_outside;\n Buffer.clear buffer;\n end\n else\n begin\n w_inside := (Buffer.contents buffer)::!w_inside;\n Buffer.clear buffer;\n end\n end\n else if c = '_' then ()\n else if i = length - 1 && Buffer.length buffer != 0 then\n begin\n Buffer.add_char buffer c;\n w_outside := (Buffer.contents buffer)::!w_outside\n end\n else Buffer.add_char buffer c\n done;\n (!w_outside, !w_inside)\n\nlet () =\n let length = read_int () in\n let sentence = read_string () in\n let (w_outside, w_inside) = parse_sentence sentence length in\n let out_max_length = List.fold_left (fun acc ele ->\n max acc (String.length ele)) 0 w_outside in\n Printf.printf \"%d %d\" out_max_length (List.length w_inside)\n"}, {"source_code": "open Scanf\nopen Printf\nopen Char\n\nlet max a b = if a > b then a else b;;\n\nlet foo d = let a = lowercase d in if(a >= 'a' && a <= 'z') then 0 else 1;; \n\nlet () = \nlet n = scanf \" %d \" (fun x-> x) in\nlet s = scanf \" %s \" (fun x-> x) in\nlet rec calc i l typ len cnt = \nif i < n then match(s.[i]) with\n'(' -> calc (i + 1) 0 true (max len l) cnt\n| ')' -> calc (i + 1) 0 false len cnt\n| '_' -> calc (i + 1) 0 typ (if typ then len else (max len l)) cnt\n| _ -> calc (i + 1) (l + 1) typ len (if typ then cnt + foo s.[i - 1] else cnt) \nelse printf \"%d %d\\n\" len cnt in calc 0 0 false 0 0;;\n"}], "src_uid": "fc86df4931e787fa3a1a40e2aecf0b92"} {"source_code": "let main () =\n let getNumber () = Scanf.bscanf Scanf.Scanning.stdin \" %d\" (fun x -> x)\n in let c = getNumber ()\n in let o = getNumber ()\n in if o = 0 then\n Printf.printf \"No\"\n else if o = 1\n then if c = 0 then\n Printf.printf \"Yes\"\n else\n Printf.printf \"No\"\n else if c - o >= -1 && (c - o + 1) mod 2 = 0 then\n Printf.printf \"Yes\"\n else\n Printf.printf \"No\"\n;;\n\nmain ();;", "positive_code": [{"source_code": "\nlet judge x y =\n let times_for_original = y - 1 in\n let copy_produced_by_copy = x - times_for_original in\n (times_for_original >= 0) &&\n (copy_produced_by_copy >= 0) &&\n (copy_produced_by_copy mod 2 == 0) &&\n (copy_produced_by_copy == 0 || times_for_original > 0)\n\nlet output_yn v =\n (match v with\n | true -> print_string \"Yes\"\n | false -> print_string \"No\");\n print_char '\\n'\n\nlet () =\n Scanf.scanf \"%u %u\" judge |> output_yn\n\n(* TODO: do test *)\n(* 1 0 *)\n(* 2 1 *)"}, {"source_code": "(* Codeforces 914 B Conan and Agasa play a Card Game - not done*)\n\n(* you can use either gr or rdln but not both *)\nlet gr () = Scanf.scanf \" %d\" (fun i -> i);;\nlet grf () = Scanf.scanf \" %f\" (fun i -> i);;\nlet grl () = Scanf.scanf \" %Ld\" (fun i -> i);;\nlet grc () = Scanf.scanf \" %c\" (fun i -> i);;\nlet rdln() = input_line stdin;;\n(* let spli s = Str.split (Str.regexp \" \") s;; *)\nlet printlisti li = List.iter (fun i -> (print_int i; print_string \" \")) li;;\nlet printarri ai = Array.iter (fun i -> (print_int i; print_string \" \")) ai;;\nlet debug = false;;\n\nlet rec readlist n acc = match n with\n\t| 0 -> acc\n\t| _ -> readlist (n -1) (gr() :: acc);;\n\nlet printlisti li = List.iter (fun i -> (print_int i; print_string \" \")) li;;\n\nlet possible x y = \n\tif y <= 0 then false\n\telse if x > 0 && y==1 then false\n\telse if x < (y - 1) then false\n\telse if (x mod 2) == (y mod 2) then false\n\telse true;;\n\nlet main() =\n\tlet x = gr() in\n\tlet y = gr() in\n\tlet pos = possible x y in\n\tbegin\n\t\tprint_string (if pos then \"Yes\" else \"No\");\n\t\tprint_string \"\\n\"\n\tend;;\n\nmain();;"}], "negative_code": [{"source_code": "\nlet judge x y =\n let times_for_original = y - 1 in\n let copy_produced_by_copy = x - times_for_original in\n (times_for_original >= 0) &&\n (copy_produced_by_copy >= 0) &&\n (copy_produced_by_copy mod 2 == 0)\n\nlet output_yn v =\n (match v with\n | true -> print_string \"Yes\"\n | false -> print_string \"No\");\n print_char '\\n'\n\nlet () =\n Scanf.scanf \"%u %u\" judge |> output_yn\n\n(* TODO: do test *)\n(* 1 0 *)"}, {"source_code": "\nlet judge x y =\n let times_for_original = y - 1 in\n let copy_produced_by_copy = x - times_for_original in\n (copy_produced_by_copy >= 0) && (copy_produced_by_copy mod 2 == 0)\n\nlet output_yn v =\n (match v with\n | true -> print_string \"Yes\"\n | false -> print_string \"No\");\n print_char '\\n'\n\nlet () =\n Scanf.scanf \"%u %u\" judge |> output_yn\n"}, {"source_code": "let main () =\n let getNumber () = Scanf.bscanf Scanf.Scanning.stdin \" %d\" (fun x -> x)\n in let c = getNumber ()\n in let o = getNumber ()\n in let c1 = o - 1\n in let c2 = c - c1\n in let c2m = c2 mod 2\n in if c < 0 || o <= 0 || c - o < -1 || c2m = 1 then\n Printf.printf \"No\"\n else\n Printf.printf \"Yes\"\n;;\n\nmain ();;\n"}, {"source_code": "let main () =\n let getNumber () = Scanf.bscanf Scanf.Scanning.stdin \" %d\" (fun x -> x)\n in let c = getNumber ()\n in let o = getNumber ()\n in if o = 0 then\n Printf.printf \"No\"\n else if o = 1\n then if c = 0 then\n Printf.printf \"Yes\"\n else\n Printf.printf \"No\"\n else if c - o >= -1 && c - o + 1 mod 2 = 0 then\n Printf.printf \"Yes\"\n else\n Printf.printf \"No\"\n;;\n\nmain ();;"}, {"source_code": "let main () =\n let getNumber () = Scanf.bscanf Scanf.Scanning.stdin \" %d\" (fun x -> x)\n in let c = getNumber ()\n in let o = getNumber ()\n in let c1 = o - 1\n in let c2 = c - c1\n in let c2m = c2 mod 2\n in if c2m = 1 then\n Printf.printf \"No\"\n else\n Printf.printf \"Yes\"\n;;\n\nmain ();;\n"}, {"source_code": "let main () =\n let getNumber () = Scanf.bscanf Scanf.Scanning.stdin \" %d\" (fun x -> x)\n in let c = getNumber ()\n in let o = getNumber ()\n in let c1 = o - 1\n in let c2 = c - c1\n in let c2m = c2 mod 2\n in if c < 0 || o <= 0 || c - o < -1 || c2m = 1 then\n Printf.printf \"No\"\n else\n Printf.printf \"Yes\"\n;;\n\nmain ();;\n"}, {"source_code": "let main () =\n let getNumber () = Scanf.bscanf Scanf.Scanning.stdin \" %d\" (fun x -> x)\n in let c = getNumber ()\n in let o = getNumber ()\n in let c1 = o - 1\n in let c2 = c - c1\n in let c2m = c2 mod 2\n in if c2 < 0 || o <= 0 || c - o < -1 || (c - o + 1) mod 2 = 1 then\n Printf.printf \"No\"\n else\n Printf.printf \"Yes\"\n;;\n\nmain ();;\n"}, {"source_code": "(* Codeforces 914 B Conan and Agasa play a Card Game - not done*)\n\n(* you can use either gr or rdln but not both *)\nlet gr () = Scanf.scanf \" %d\" (fun i -> i);;\nlet grf () = Scanf.scanf \" %f\" (fun i -> i);;\nlet grl () = Scanf.scanf \" %Ld\" (fun i -> i);;\nlet grc () = Scanf.scanf \" %c\" (fun i -> i);;\nlet rdln() = input_line stdin;;\n(* let spli s = Str.split (Str.regexp \" \") s;; *)\nlet printlisti li = List.iter (fun i -> (print_int i; print_string \" \")) li;;\nlet printarri ai = Array.iter (fun i -> (print_int i; print_string \" \")) ai;;\nlet debug = false;;\n\nlet rec readlist n acc = match n with\n\t| 0 -> acc\n\t| _ -> readlist (n -1) (gr() :: acc);;\n\nlet printlisti li = List.iter (fun i -> (print_int i; print_string \" \")) li;;\n\nlet possible x y = \n\tif x < (y - 1) then false\n\telse if (x mod 2) == (y mod 2) then false\n\telse true;;\n\nlet main() =\n\tlet x = gr() in\n\tlet y = gr() in\n\tlet pos = possible x y in\n\tbegin\n\t\tprint_string (if pos then \"Yes\" else \"No\");\n\t\tprint_string \"\\n\"\n\tend;;\n\nmain();;"}, {"source_code": "(* Codeforces 914 B Conan and Agasa play a Card Game - not done*)\n\n(* you can use either gr or rdln but not both *)\nlet gr () = Scanf.scanf \" %d\" (fun i -> i);;\nlet grf () = Scanf.scanf \" %f\" (fun i -> i);;\nlet grl () = Scanf.scanf \" %Ld\" (fun i -> i);;\nlet grc () = Scanf.scanf \" %c\" (fun i -> i);;\nlet rdln() = input_line stdin;;\n(* let spli s = Str.split (Str.regexp \" \") s;; *)\nlet printlisti li = List.iter (fun i -> (print_int i; print_string \" \")) li;;\nlet printarri ai = Array.iter (fun i -> (print_int i; print_string \" \")) ai;;\nlet debug = false;;\n\nlet rec readlist n acc = match n with\n\t| 0 -> acc\n\t| _ -> readlist (n -1) (gr() :: acc);;\n\nlet printlisti li = List.iter (fun i -> (print_int i; print_string \" \")) li;;\n\nlet possible x y = \n\tif y <= 0 then false\n\telse if x==2 && y==1 then false\n\telse if x < (y - 1) then false\n\telse if (x mod 2) == (y mod 2) then false\n\telse true;;\n\nlet main() =\n\tlet x = gr() in\n\tlet y = gr() in\n\tlet pos = possible x y in\n\tbegin\n\t\tprint_string (if pos then \"Yes\" else \"No\");\n\t\tprint_string \"\\n\"\n\tend;;\n\nmain();;"}, {"source_code": "(* Codeforces 914 B Conan and Agasa play a Card Game - not done*)\n\n(* you can use either gr or rdln but not both *)\nlet gr () = Scanf.scanf \" %d\" (fun i -> i);;\nlet grf () = Scanf.scanf \" %f\" (fun i -> i);;\nlet grl () = Scanf.scanf \" %Ld\" (fun i -> i);;\nlet grc () = Scanf.scanf \" %c\" (fun i -> i);;\nlet rdln() = input_line stdin;;\n(* let spli s = Str.split (Str.regexp \" \") s;; *)\nlet printlisti li = List.iter (fun i -> (print_int i; print_string \" \")) li;;\nlet printarri ai = Array.iter (fun i -> (print_int i; print_string \" \")) ai;;\nlet debug = false;;\n\nlet rec readlist n acc = match n with\n\t| 0 -> acc\n\t| _ -> readlist (n -1) (gr() :: acc);;\n\nlet printlisti li = List.iter (fun i -> (print_int i; print_string \" \")) li;;\n\nlet possible x y = \n\tif y <= 0 then false\n\telse if x < (y - 1) then false\n\telse if (x mod 2) == (y mod 2) then false\n\telse true;;\n\nlet main() =\n\tlet x = gr() in\n\tlet y = gr() in\n\tlet pos = possible x y in\n\tbegin\n\t\tprint_string (if pos then \"Yes\" else \"No\");\n\t\tprint_string \"\\n\"\n\tend;;\n\nmain();;"}], "src_uid": "1527171297a0b9c5adf356a549f313b9"} {"source_code": "let input () = Scanf.scanf \"%Ld\" (fun n -> n)\n\nlet solve number = \n let rec loop i count correct = \n if i > Int64.one\n then\n let repress = Int64.mul (Int64.sub i (Int64.of_int 2)) correct in \n let temp_count = Int64.add i repress in \n loop (Int64.pred i) (Int64.add count temp_count) (Int64.succ correct)\n else\n Int64.succ count\n in loop number Int64.zero Int64.one\n\nlet print result = Printf.printf \"%Ld\\n\" result\nlet () = print (solve (input ())) ", "positive_code": [{"source_code": "let ( +: ) = Int64.add in\nlet ( -: ) = Int64.sub in\nlet ( *: ) = Int64.mul in\nlet n = read_line () |> int_of_string |> Int64.of_int in\nlet rec count n i a = \n match n with\n | 1L -> 1L\n | 2L -> 3L\n | e -> if n-:i =2L then a+:n+:1L else count n (i+:1L) (a+:(i+:1L)*:(n-:i)-:i) in\ncount n 1L n |> Int64.to_string |> print_string\n"}, {"source_code": "let ( * ) = Int64.mul\nlet ( + ) = Int64.add\nlet ( - ) = Int64.sub\nlet zero = Int64.zero\nlet one = Int64.one\nlet two = Int64.of_int 2\n\nlet input () = Scanf.scanf \"%Ld\" (fun n -> n)\n\nlet solve number = \n let rec loop i count correct = \n if i > one\n then\n let repress = (i - two) * correct in \n let temp_count = i + repress in \n loop (i - one) (count + temp_count) (correct + one)\n else\n count + one\n in loop number zero one\n\nlet print result = Printf.printf \"%Ld\\n\" result\nlet () = print (solve (input ())) "}], "negative_code": [{"source_code": "let input () = Scanf.scanf \"%d\" (fun n -> n)\n\nlet solve number = \n let rec loop i count correct = \n if i > 1\n then\n let repress = (i - 2) * correct in \n loop (i - 1) (count + i + repress) (correct + 1)\n else\n count + 1\n in loop number 0 1\n\nlet print result = Printf.printf \"%d\\n\" result\nlet () = print (solve (input ())) "}, {"source_code": "let n = read_line () |> int_of_string in\nlet rec count n a = if n <= 1 then a else count (n-2) (a+n*(n-1)) in\ncount n (if n==2 || n mod 2 ==1 then 1 else 0) |> print_int\n"}, {"source_code": "let n = read_line () |> int_of_string in\nlet rec count n a = if n <= 1 then a else count (n-2) (a+n*(n-1)) in\nprint_int (if n==2 then 3 else count n 0)\n"}, {"source_code": "let n = read_line () |> int_of_string in\nlet rec count n i a = \n match n with\n | 1 -> 1\n | 2 -> 3\n | e -> if n-i=2 then a+n+1 else count n (i+1) (a+(i+1)*(n-i)-i) in\ncount n 1 n |> print_int\n"}, {"source_code": "let n = read_line () |> int_of_string in\nlet count = ref 0 in\nbegin\nfor i = 1 to n do\n count := !count + (i+1)*(n-i)\ndone;\nprint_int (if n == 2 then 3 else !count)\nend\n"}], "src_uid": "6df251ac8bf27427a24bc23d64cb9884"} {"source_code": "\nlet ( |> ) v f = f v\nlet ( @@ ) f x = f x\nlet input_to_list ic =\n let buf = Buffer.create 0 in\n let rec aux acc =\n match input_char ic with\n | ' ' -> let v = int_of_string (Buffer.contents buf) in\n Buffer.clear buf; aux (v::acc)\n | '\\n' -> let v = int_of_string (Buffer.contents buf) in\n Buffer.clear buf; List.rev (v::acc)\n | c -> Buffer.add_char buf c; aux acc\n in aux []\n\nlet read_input () =\n let cups = input_to_list stdin |> List.fold_left (fun sum x -> sum + x) 0 in\n let medals = input_to_list stdin |> List.fold_left (fun sum x -> sum + x) 0 in\n let shelves = int_of_string (input_line stdin) in\n (cups, medals, shelves)\n\nlet check_ok (cups, medals, shelves) =\n let shelves_for_cups = cups / 5 + (if cups mod 5 > 0 then 1 else 0)\n in let shelves_for_medals = medals / 10 + (if medals mod 10 > 0 then 1 else 0)\n in shelves_for_cups + shelves_for_medals <= shelves\n\nlet () =\n print_endline (if (check_ok (read_input ())) then \"YES\" else \"NO\")\n", "positive_code": [{"source_code": "let read () = Scanf.scanf \"%d \" (fun n -> n)\nlet sum () = Scanf.scanf \"%d %d %d \" (fun n m l -> n + m + l)\nlet print result = Printf.printf \"%s\\n\" result\n\nlet div_rounding_up = (fun x y ->\n x / y + (match x mod y with\n | 0 -> 0\n | _ -> 1))\n\nlet input () = \n let goblets = sum () in\n let medals = sum () in\n let shelves = read () in\n (goblets, medals, shelves)\n\nlet solve (goblets, medals, shelves) = \n let goblet_shelves = div_rounding_up goblets 5 in\n let medal_shelves = div_rounding_up medals 10 in\n let shelves_needed = goblet_shelves + medal_shelves in\n if shelves_needed <= shelves\n then\n \"YES\"\n else\n \"NO\"\n\nlet () = print (solve (input ()))"}], "negative_code": [{"source_code": "\nlet input_to_list ic =\n let buf = Buffer.create 0 in\n let rec aux acc =\n match input_char ic with\n | ' ' -> let v = int_of_string (Buffer.contents buf) in\n Buffer.clear buf; aux (v::acc)\n | '\\n' -> let v = int_of_string (Buffer.contents buf) in\n Buffer.clear buf; List.rev (v::acc)\n | c -> Buffer.add_char buf c; aux acc\n in aux []\n\nlet read_input () =\n let cups = input_to_list stdin in\n let medals = input_to_list stdin in\n let shelves = int_of_string (input_line stdin) in\n (cups, medals, shelves)\n\nlet check_ok (cups, medals, shelves) =\n let shelves_for_cups =\n (List.length cups) / 5 + (if List.length cups mod 5 > 0 then 1 else 0)\n in let shelves_for_medals =\n (List.length medals) / 10 + (if List.length medals mod 10 > 0 then 1 else 0)\n in shelves_for_cups + shelves_for_medals <= shelves\n\nlet () =\n print_endline (if (check_ok (read_input ())) then \"YES\" else \"NO\")\n"}], "src_uid": "fe6301816dea7d9cea1c3a06a7d1ea7e"}