let () =
  let rec read total qty_total cnt =
    try let unit_price, qty = Scanf.scanf " %f,%f\n" (fun x y -> x,y) in
        let price = unit_price*.qty in
        read (total+.price) (qty_total+.qty) (cnt+.1.)
    with
      End_of_file ->
      let favg = qty_total/.cnt in
      let avg =
        if int_of_float favg |> float |> (-.) favg >= 0.5 then
          (int_of_float favg)+1
        else
          (int_of_float favg)
      in
      Printf.printf "%d\n" (int_of_float total);
      Printf.printf "%d\n" avg
  in read 0. 0. 0.
;;