Scanf.scanf "%d %d %d %d %d" (fun a b c x y ->
    let lim = 2 * max x y in
    let rec loop i acc =
        if i > lim then acc / 2 else
            let cost = a * max 0 (2 * x - i) + b * max 0 (2 * y - i) + 2 * c * i in
            loop (i + 1) (min cost acc)
    in
    loop 0 max_int |> Printf.printf "%d\n"
)