let [zer;on;two;fou] = List.map Big_int.big_int_of_int [0;1;2;4]

let (+) = Big_int.add_big_int
let (-) = Big_int.sub_big_int
let ( * ) = Big_int.mult_big_int
let (mod) = Big_int.mod_big_int
let (=) = Big_int.eq_big_int
let (<=) a b = Big_int.compare_big_int a b <= 0

let xor_betw a b =
    let x = ref (a * (a mod two)) in
    let beg = ref (b + (a mod two) - ((b-a) mod fou)) in
        while !beg <= b do
            x := Big_int.xor_big_int !beg !x;
            beg := !beg + on;
        done;
        !x

let main () =
    let n = Scanf.scanf "%d" (fun i -> i) and a = ref zer in
    for i = 1 to n do
        Scanf.scanf " %s %s" (fun x' m' ->
            let [x;m] = List.map Big_int.big_int_of_string [x';m'] in
                a := Big_int.xor_big_int !a (xor_betw x (x+m-on)));
    done;
    print_endline (if !a = zer then "bolik" else "tolik");;

main ();;

let read_int _ = Scanf.bscanf Scanf.Scanning.stdib " %d" (fun x -> x)
let read_int64 _ = Scanf.bscanf Scanf.Scanning.stdib " %Ld" (fun x -> x)
let (|>) x f = f x

open Int64

let () =
  let z = ref 0L in
  for i = 1 to read_int 0 do
    let x = read_int64 0 |> ref in
    let y = read_int64 0 |> ref in
    y := add !y !x;
    while !x < !y && rem !x 4L <> 0L do
      z := logxor !z !x;
      x := add !x 1L
    done;
    while !x < !y && rem !y 4L <> 0L do
      y := sub !y 1L;
      z := logxor !z !y
    done
  done;
  print_endline (if !z <> 0L then "tolik" else "bolik")

let xor_betw a b =
    let x = ref 0 in
        if a mod 2 = 1 then x := a;
        for i = b + 1 - ((b-a) mod 4) to b do
            x := i lxor !x;
        done;
        !x

let main () =
    let n = Scanf.scanf "%d" (fun i -> i) and a = ref 0 in
    for i = 1 to n do
        Scanf.scanf " %d %d" (fun x m->a := !a lxor (xor_betw x (x+m-1)));
    done;
    print_endline (if !a = 0 then "bolik" else "tolik");;

main ();;

let n = Scanf.scanf "%d" (fun i -> i) and res = ref 0 in
    for i=1 to n-1 do
        Scanf.scanf " %s"
        (fun w -> res := !res + int_of_char (w.[String.length w - 1]));
    done;
Printf.printf (if !res mod 2 = 0 then "bolik" else "tolik");;

let n = Scanf.scanf "%d" (fun i -> i) and res = ref 0 in
    for i=1 to n do
        Scanf.scanf " %s %s"
        (fun _ w -> res := !res + int_of_char (w.[String.length w - 1]));
    done;
Printf.printf (if !res mod 2 = 0 then "bolik" else "tolik");;

let n = Scanf.scanf "%d" (fun i -> i) and res = ref 0 in
    for i=1 to n do
        Scanf.scanf " %s"
        (fun w -> res := !res + int_of_char (w.[String.length w - 1]));
    done;
Printf.printf (if !res mod 2 = 0 then "bolik" else "tolik");;

let read_int _ = Scanf.bscanf Scanf.Scanning.stdib " %d" (fun x -> x)
let (|>) x f = f x

let () =
  let z = ref 0 in
  for i = 1 to read_int 0 do
    let x = read_int 0 |> ref in
    let y = read_int 0 |> ref in
    y := !y + !x;
    while !x < !y && !x mod 4 <> 0 do
      z := !z + !x;
      incr x
    done;
    while !x < !y && !y mod 4 <> 0 do
      decr y;
      z := !z + !y
    done
  done;
  print_endline (if !z <> 0 then "tolik" else "bolik")


open Array
open Scanf
let main() =
  let s = stable_sort (-) in
  let gi() = bscanf Scanning.stdib " %d" (fun x -> x) in
  let n = gi () in
  let a = init n (fun i -> gi ()) in
  s a;
  a.(n-1) <- if fold_left (&&) true (map ((==) 1) a) then 2 else 1;
  s a;
  iter (Printf.printf "%d ") a
  ;;
main()

(*************** Ocaml stdio functions **********************)
let stdin_stream = Stream.of_channel stdin;;
let stdout_buffer = Buffer.create 65536;;
let rec gi() =
  match Stream.next stdin_stream with
    '-' ->  - (ri 0)
  | '+' ->  ri 0
  | '0'..'9' as c -> ri ((int_of_char c) - 48)
  | _ -> gi ()
and ri x =
  match Stream.next stdin_stream with
    '0'..'9' as c -> ri (((int_of_char c) - 48) + (x * 10))
  | _ -> x
;;
let flushout () = Buffer.output_buffer stdout stdout_buffer; Buffer.reset stdout_buffer;;
let putchar c =
  if (Buffer.length stdout_buffer) >= 65536 then flushout() else ();
  Buffer.add_char stdout_buffer c;;
let rec ppi i = if i < 10 then putchar (char_of_int (48 + i)) else (ppi (i / 10); putchar (char_of_int (48 + (i mod 10)))) ;;
let pi i = if i >= 0 then ppi i else (putchar ('-'); ppi (-i));;
(*************** Ocaml solution ******************************)
open Array
let main() =
  let n = gi() in
  let a = init (n+1) (fun i -> if i > 0 then gi() else 1) in
  stable_sort compare a;
  if a.(n) == 1 then a.(n-1) <- 2 else ();
  iteri (fun i j -> pi j; putchar (if i == (n-1) then '\n' else ' ')) (sub a 0 n)
  ;;
main();;
flushout ()

open Array
let main() =
  let s = stable_sort (-) in
  let gi() = Scanf.scanf " %d" (fun i -> i) in
  let n = gi () in
  let a = init n (fun i -> gi ()) in
  s a;
  a.(n-1) <- if fold_left (&&) true (map ((==) 1) a) then 2 else 1;
  s a;
  iter (Printf.printf "%d ") a
  ;;
main()

    let _ =
      let sb = Scanf.Scanning.stdib in
      let n = Scanf.bscanf sb "%d " (fun s -> s) in
      let a = Array.make n 0 in
        for i = 0 to n - 1 do
          let k = Scanf.bscanf sb "%d " (fun s -> s) in
            a.(i) <- k
        done;
        Array.sort compare a;
        a.(n - 1) <-
          if a.(n - 1) > 1
          then 1
          else 2;
        Array.sort compare a;
        for i = 0 to n - 1 do
          Printf.printf "%d " a.(i);
        done;
        Printf.printf "\n"

let getnum =
  let l = 512000 in
  let buf = String.make l ' ' in
  let s = ref 0 in
  let pos = ref 0 in
  let getc () =
    if !pos >= !s then (
      let new_s = input stdin buf 0 l in
	(*if new_s = 0 then raise End_of_file;*)
	s := new_s;
	if new_s = 0 then (
	  buf.[0] <- '\000';
	  s := 1;
	);
	pos := 0;
    );
    let c = buf.[!pos] in
      incr pos;
      c
  in
  let aux () =
    let n = ref 0 in
    let k = ref 1 in
      if !s - !pos < 50 then (
	let c = ref (getc ()) in
	  while !c <= ' ' do
	    c := getc ()
	  done;
	  if !c = '-' then (
	    k := -1;
	    c := getc ();
	  );
	  while !c > ' ' do
	    n := !n * 10 + (Char.code !c - Char.code '0');
	    c := getc ()
	  done;
	  !n * !k
      ) else (
	let c = ref (buf.[!pos]) in
	  incr pos;
	  while !c <= ' ' do
	    c := buf.[!pos];
	    incr pos;
	  done;
	  if !c = '-' then (
	    k := -1;
	    c := buf.[!pos];
	    incr pos;
	  );
	  while !c > ' ' do
	    n := !n * 10 + (Char.code !c - Char.code '0');
	    c := buf.[!pos];
	    incr pos;
	  done;
	  !n * !k
      )
  in
    aux

let _ =
  let n = getnum () in
  let a = Array.make n 0 in
    for i = 0 to n - 1 do
      let k = getnum () in
	a.(i) <- k
    done;
    Array.sort compare a;
    a.(n - 1) <-
      if a.(n - 1) > 1
      then 1
      else 2;
    Array.sort compare a;
    for i = 0 to n - 1 do
      Printf.printf "%d " a.(i);
    done;
    Printf.printf "\n"

(*************** Ocaml stdio functions **********************)
let stdin_stream = Stream.of_channel stdin;;
let stdout_buffer = Buffer.create 65536;;
let rec gi() =
  match Stream.next stdin_stream with
    '-' ->  - (ri 0)
  | '+' ->  ri 0
  | '0'..'9' as c -> ri ((int_of_char c) - 48)
  | _ -> gi ()
and ri x =
  match Stream.next stdin_stream with
    '0'..'9' as c -> ri (((int_of_char c) - 48) + (x * 10))
  | _ -> x
;;
let flushout () = Buffer.output_buffer stdout stdout_buffer; Buffer.reset stdout_buffer;;
let putchar c =
  if (Buffer.length stdout_buffer) >= 65536 then flushout() else ();
  Buffer.add_char stdout_buffer c;;
let rec ppi i = if i < 10 then putchar (char_of_int (48 + i)) else (ppi (i / 10); putchar (char_of_int (48 + (i mod 10)))) ;;
let pi i = if i >= 0 then ppi i else (putchar ('-'); ppi (-i));;
let pa a = let n = Array.length a in Array.iteri (fun i j -> pi j; putchar (if i == (n-1) then '\n' else ' ')) a;;
(*************** Ocaml solution ******************************)
open Array
let main() =
  let n = gi() in
  let a = init (n+1) (fun i -> if i > 0 then gi() else 1) in
  stable_sort compare a;
  if a.(n) == 1 then a.(n-1) <- 2 else ();
  pa (sub a 0 n)
  ;;
main();;
flushout ()

try (
  let a = Array.make 1 1 in
  Printf.printf "1 1 2 3 ";
  a.(10) <- 4;
  Printf.printf "%d\n" (a.(10))
  )
with
_ -> exit 1

open Sys
let rec pa = function
    [] -> ()
  | (x::xs) -> (Printf.printf "%s\n" x; pa xs)
  ;;
Printf.printf "word_size = %d\n" word_size;;
Printf.printf "max_string_length = %d\n" max_string_length;;
Printf.printf "max_array_length = %d\n" max_array_length;;
Printf.printf "os_type = %s\n" os_type;;
Printf.printf "ocaml_version = %s\n" ocaml_version

Printf.printf "%s\n" (Str.quote "abacaba")

let a = Array.make 1 1;;
Printf.printf "1 1 2 3 ";;
a.(10) <- 4;;
Printf.printf "%d\n" (a.(10))


module Std = struct

  module List = struct
    include List
    module L = List
    let map f lst = L.rev (L.rev_map f lst)
    let map2 f l1 l2 = L.rev (L.rev_map2 f l1 l2)
    let each_cons f lst = L.rev_map2 f (L.tl (L.rev lst)) (L.rev (L.tl lst))
    let append x y = List.rev (List.rev_append x y)
  end

  let ( |> ) x f = f x
  let ( <| ) f x = f x
  let ( ~. ) = float_of_int
  let ( ~: ) = int_of_float
  let ( @ ) x y = List.append

  let rec repeat n f x = if n = 0 then x else repeat (n-1) f (f x)

  let di x = prerr_endline (string_of_int x); x
  let df f = prerr_endline (string_of_float f); f
  let ds s = prerr_endline s; s

  let int () = Scanf.scanf "%d%c" (fun x _ -> x)
  let read_int = int
  let float () = Scanf.scanf "%f%c" (fun x _ -> x)
  let read_float = float
  let rec n_int n () = List.rev <| repeat n (fun lst -> int () :: lst) []
  let rec n_float n () = List.rev <| repeat n (fun lst -> float () :: lst) []

end

open Std
module L = List

let max = L.fold_left max neg_infinity

(* entry point *)

let n = int ()
let m = int ()
let c = int ()

let x = n_int n ()

let p = n_int (n-1) () |> L.map (fun x -> ~.x *. 0.01)

let ab = L.rev <| repeat m (fun lst -> let a = int () in let b = int () in (a-1, b-2) :: lst) []

let w =
  let s = L.each_cons (fun x y -> y-x) x in
    L.map2 (fun pi si -> ~.si /. 2. -. pi *. ~.c) p s |> Array.of_list

type data = { left:float; right:float; between:float; full:float; }

type tree =
  | Leaf of data
  | Node of data * int * int * tree * tree

let getdata = function
  | Leaf(data) -> data
  | Node(data,_,_,_,_) -> data

let merge ldata rdata = {
  left  = max [ldata.left; ldata.full; (ldata.full +. rdata.left)];
  right = max [rdata.right; rdata.full; (rdata.full +. ldata.right)];
  between = max [ldata.between; rdata.between; ldata.right; rdata.left; (ldata.right +. rdata.left)];
  full = ldata.full +. rdata.full;
}

let rec make_tree l r =
  if l = r then
    Leaf({ left = 0.; right = 0.; between = 0.; full = w.(l); })
  else
    let mid = (l+r) / 2 in
    let ltree = make_tree l mid in
    let rtree = make_tree (mid+1) r in
    let ldata = getdata ltree in
    let rdata = getdata rtree in
      Node(merge ldata rdata, l, r, ltree, rtree)

let rec query l r = function
  | Leaf(data) ->
     data
  | Node(data, start, finish, ltree, rtree) ->
      if l = start && r = finish then
	data
      else
	let mid = (start+finish)/2 in
	  if r <= mid then
	    query l r ltree
	  else if l > mid then
	    query l r rtree
	  else
	    let ldata = query l mid ltree in
	    let rdata = query (mid+1) r rtree in
	      merge ldata rdata

let segtree = make_tree 0 (n-2)

let () =
  L.map (fun (a,b) -> let r = query a b segtree in max [r.left; r.right; r.between; r.full]) ab
  |> L.fold_left (+.) 0.
  |> print_float

module Std = struct

  module List = struct
    include List
    module L = List
    let map f lst = L.rev (L.rev_map f lst)
    let map2 f l1 l2 = L.rev (L.rev_map2 f l1 l2)
    let each_cons f lst = L.rev_map2 f (L.tl (L.rev lst)) (L.rev (L.tl lst))
    let append x y = List.rev (List.rev_append x y)
  end

  let ( |> ) x f = f x
  let ( <| ) f x = f x
  let ( ~. ) = float_of_int
  let ( ~: ) = int_of_float
  let ( @ ) x y = List.append

  let rec repeat n f x = if n = 0 then x else repeat (n-1) f (f x)

  let di x = prerr_endline (string_of_int x); x
  let df f = prerr_endline (string_of_float f); f
  let ds s = prerr_endline s; s

  let int () = Scanf.scanf " %d" (fun x -> x)
  let read_int = int
  let float () = Scanf.scanf " %f" (fun x -> x)
  let read_float = float
  let rec n_int n () = List.rev <| repeat n (fun lst -> int () :: lst) []
  let rec n_float n () = List.rev <| repeat n (fun lst -> float () :: lst) []

end

module Segtree = struct
  module type Builder = sig
    type data
    val merge : data -> data -> data
    val terminal : int -> data
  end

  module Make = functor(B : Builder) -> struct
    type t =
      |	Leaf of B.data
      | Node of B.data * int * int * t * t

    let getdata = function
      | Leaf(data) -> data
      | Node(data,_,_,_,_) -> data

    let rec make l r =
      if l = r then
	Leaf(B.terminal l)
      else
	let mid = (l+r) / 2 in
	let ltree = make l mid in
	let rtree = make (mid+1) r in
	let ldata = getdata ltree in
	let rdata = getdata rtree in
	  Node(B.merge ldata rdata, l, r, ltree, rtree)

    let rec query l r = function
      | Leaf(data) ->
	  data
      | Node(data, start, finish, ltree, rtree) ->
	  if l = start && r = finish then
	    data
	  else
	    let mid = (start+finish)/2 in
	      if r <= mid then
		query l r ltree
	      else if l > mid then
		query l r rtree
	      else
		let ldata = query l mid ltree in
		let rdata = query (mid+1) r rtree in
		  B.merge ldata rdata

  end

end

(* entry point *)

open Std
module L = List

let max = L.fold_left max neg_infinity

let n = int ()
let m = int ()
let c = int ()

let x = n_int n ()

let p = n_int (n-1) () |> L.map (fun x -> ~.x *. 0.01)

let ab = L.rev <| repeat m (fun lst -> let a = int () in let b = int () in (a-1, b-2) :: lst) []

let w =
  let s = L.each_cons (fun x y -> y-x) x in
    L.map2 (fun pi si -> ~.si /. 2. -. pi *. ~.c) p s |> Array.of_list

module A = struct

  type data = { left:float; right:float; between:float; full:float; }

  let terminal i = { left = 0.; right = 0.; between = 0.; full = w.(i); }

  let merge ldata rdata = {
    left  = max [ldata.left; ldata.full; (ldata.full +. rdata.left)];
    right = max [rdata.right; rdata.full; (rdata.full +. ldata.right)];
    between = max [ldata.between; rdata.between; ldata.right; rdata.left; (ldata.right +. rdata.left)];
    full = ldata.full +. rdata.full;
  }

end

module MySegtree = Segtree.Make(A)

open A

let segtree = MySegtree.make 0 (n-2)

let to_ans data = max [data.left; data.right; data.between; data.full]

let () =
  L.map (fun (a,b) -> MySegtree.query a b segtree |> to_ans) ab
  |> L.fold_left (+.) 0.
  |> print_float

module Std = struct

  module List = struct
    include List
    module L = List
    let map f lst = L.rev (L.rev_map f lst)
    let map2 f l1 l2 = L.rev (L.rev_map2 f l1 l2)
    let each_cons f lst = L.rev_map2 f (L.tl (L.rev lst)) (L.rev (L.tl lst))
    let append x y = List.rev (List.rev_append x y)
  end

  let ( |> ) x f = f x
  let ( <| ) f x = f x
  let ( ~. ) = float_of_int
  let ( ~: ) = int_of_float
  let ( @ ) x y = List.append

  let rec repeat n f x = if n = 0 then x else repeat (n-1) f (f x)

  let di x = prerr_endline (string_of_int x); x
  let df f = prerr_endline (string_of_float f); f
  let ds s = prerr_endline s; s

  let int () = Scanf.scanf "%d%c" (fun x _ -> x)
  let read_int = int
  let float () = Scanf.scanf "%f%c" (fun x _ -> x)
  let read_float = float
  let rec n_int n () = List.rev <| repeat n (fun lst -> int () :: lst) []
  let rec n_float n () = List.rev <| repeat n (fun lst -> float () :: lst) []

end

module Segtree = struct
  module type Builder = sig
    type data
    val merge : data -> data -> data
    val terminal : int -> data
  end

  module Make = functor(B : Builder) -> struct
    type t =
      |	Leaf of B.data
      | Node of B.data * int * int * t * t

    let getdata = function
      | Leaf(data) -> data
      | Node(data,_,_,_,_) -> data

    let rec make l r =
      if l = r then
	Leaf(B.terminal l)
      else
	let mid = (l+r) / 2 in
	let ltree = make l mid in
	let rtree = make (mid+1) r in
	let ldata = getdata ltree in
	let rdata = getdata rtree in
	  Node(B.merge ldata rdata, l, r, ltree, rtree)

    let rec query l r = function
      | Leaf(data) ->
	  data
      | Node(data, start, finish, ltree, rtree) ->
	  if l = start && r = finish then
	    data
	  else
	    let mid = (start+finish)/2 in
	      if r <= mid then
		query l r ltree
	      else if l > mid then
		query l r rtree
	      else
		let ldata = query l mid ltree in
		let rdata = query (mid+1) r rtree in
		  B.merge ldata rdata

  end

end

(* entry point *)

open Std
module L = List

let max = L.fold_left max neg_infinity

let n = int ()
let m = int ()
let c = int ()

let x = n_int n ()

let p = n_int (n-1) () |> L.map (fun x -> ~.x *. 0.01)

let ab = L.rev <| repeat m (fun lst -> let a = int () in let b = int () in (a-1, b-2) :: lst) []

let w =
  let s = L.each_cons (fun x y -> y-x) x in
    L.map2 (fun pi si -> ~.si /. 2. -. pi *. ~.c) p s |> Array.of_list

module A = struct

  type data = { left:float; right:float; between:float; full:float; }

  let terminal i = { left = 0.; right = 0.; between = 0.; full = w.(i); }

  let merge ldata rdata = {
    left  = max [ldata.left; ldata.full; (ldata.full +. rdata.left)];
    right = max [rdata.right; rdata.full; (rdata.full +. ldata.right)];
    between = max [ldata.between; rdata.between; ldata.right; rdata.left; (ldata.right +. rdata.left)];
    full = ldata.full +. rdata.full;
  }

end

module MySegtree = Segtree.Make(A)

open A

let segtree = MySegtree.make 0 (n-2)

let to_ans data = max [data.left; data.right; data.between; data.full]

let () =
  L.map (fun (a,b) -> MySegtree.query a b segtree |> to_ans) ab
  |> L.fold_left (+.) 0.
  |> print_float

(* template *)
module Std = struct
  let ( |> ) x f = f x
  let ( <| ) f x = f x

  let di x = prerr_endline (string_of_int x); x
  let df x = prerr_endline (string_of_float x); x

  let rec repeat n f x = if n = 0 then x else repeat (n-1) f (f x)
  let rec int () = Scanf.scanf "%d%c" (fun x _ -> x)
  let rec float () = Scanf.scanf "%f%c" (fun x _ -> x)
  let rec n_int n () = List.rev <| repeat n (fun lst -> int () :: lst) []
  let rec n_float n () = List.rev <| repeat n (fun lst -> float () :: lst) []

  module List = struct
    include List
    let map f lst = List.rev <| List.rev_map f lst
    let map2 f l1 l2 = List.rev <| List.rev_map2 f l1 l2
  end
end

open Std

(* utiliry functions *)
let each_cons f lst = List.rev_map2 f (List.tl (List.rev lst)) (List.rev (List.tl lst))
let lmax = List.fold_left max neg_infinity

(* entry point *)

let n = int ()
let m = int ()
let c = int ()

let x = n_int n ()

let p = n_float (n-1) () |> List.map (fun x -> x *. 0.01)

let ab = List.rev <| repeat m (fun lst -> let a = int () in let b = int () in (a-1, b-2) :: lst) []

let w =
  let s = each_cons (fun x y -> y-x |> float_of_int) x in
    List.map2 (fun pi si -> si /. 2. -. pi *. float_of_int(c)) p s |> Array.of_list

type data = { left:float; right:float; between:float; full:float; }

type tree =
  | Leaf of data
  | Node of data * int * int * tree * tree

let getdata = function
  | Leaf(data) -> data
  | Node(data,_,_,_,_) -> data

let merge ldata rdata = {
  left  = lmax [ldata.left; ldata.full; (ldata.full +. rdata.left)];
  right = lmax [rdata.right; rdata.full; (rdata.full +. ldata.right)];
  between = lmax [ldata.between; rdata.between; ldata.right; rdata.left; (ldata.right +. rdata.left)];
  full = ldata.full +. rdata.full;
}

let rec make_tree l r =
  if l = r then
    Leaf({ left = 0.; right = 0.; between = 0.; full = w.(l); })
  else
    let mid = (l+r) / 2 in
    let ltree = make_tree l mid in
    let rtree = make_tree (mid+1) r in
    let ldata = getdata ltree in
    let rdata = getdata rtree in
      Node(merge ldata rdata, l, r, ltree, rtree)

let rec query l r = function
  |Leaf(data) ->
     data
  | Node(data, start, finish, ltree, rtree) ->
      if l = start && r = finish then
	data
      else
	let mid = (start+finish)/2 in
	  if r <= mid then
	    query l r ltree
	  else if l > mid then
	    query l r rtree
	  else
	    let ldata = query l mid ltree in
	    let rdata = query (mid+1) r rtree in
	      merge ldata rdata

let segtree = make_tree 0 (n-2)

let () =
  List.map (fun (a,b) -> let r = query a b segtree in lmax [r.left; r.right; r.between; r.full]) ab
  |> List.fold_left (+.) 0.
  |> print_float

module type ExtremumType =
sig
  type t
  val extremum : t -> t -> bool
end

module type RMQ =
sig
  type t
  type elt
  val of_array : elt array -> t
  val rmq : t -> int -> int -> int
end

module type RMQMake =
sig
  module Make(Ext : ExtremumType) : RMQ with type elt = Ext.t
end

module RMQST =
struct
  module Make(Ext : ExtremumType) : RMQ with type elt = Ext.t =
  struct
    type elt = Ext.t
    type t = {a : elt array;
	      m : int array array}
    let ext = Ext.extremum
    let of_array a =
      let n = Array.length a in
      let k = ref 0
      and d = ref 1 in
	while !d <= n do
	  d := 2 * !d;
	  incr k
	done;
	let k = !k in
	let m = Array.make_matrix k n 0 in
	  for i = 0 to n - 1 do
	    m.(0).(i) <- i;
	  done;
	  for j = 1 to k - 1 do
	    for i = 0 to n - (1 lsl j) do
	      let i2 = i + (1 lsl (j - 1)) in
		m.(j).(i) <-
		  if ext a.(m.(j - 1).(i)) a.(m.(j - 1).(i2))
		  then m.(j - 1).(i)
		  else m.(j - 1).(i2)
	    done
	  done;
	  {a = a;
	   m = m}
    let rmq data x y =
      let a = data.a
      and m = data.m in
      let l = y - x + 1 in
      let k = ref 0
      and d = ref 1 in
	while !d <= l do
	  d := 2 * !d;
	  incr k
	done;
	let k = !k - 1 in
	let i2 = y - (1 lsl k) + 1 in
	  if ext a.(m.(k).(x)) a.(m.(k).(i2))
	  then m.(k).(x)
	  else m.(k).(i2)
  end
end

module RMQSTmin =
  RMQST.Make(
    struct
      type t = float
      let extremum (x : t) (y : t) = x < y
    end
  )

module RMQSTmax =
  RMQST.Make(
    struct
      type t = float
      let extremum (x : t) (y : t) = x >= y
    end
  )

module RMSQ2 =
struct
  module Make(RMQ : RMQMake) =
  struct
    module RMQmin =
      RMQ.Make(
	struct
	  type t = float
	  let extremum (x : t) (y : t) = x < y
	end
      )
    module RMQmax =
      RMQ.Make(
	struct
	  type t = float
	  let extremum (x : t) (y : t) = x >= y
	end
      )
    type elt = float
    type t = {c : elt array;
	      p : int array;
	      m : elt array;
	      crminq : RMQmin.t;
	      crmaxq : RMQmax.t;
	      mrmq : RMQmax.t;
	     }
    let of_array a =
      let n = Array.length a in
      let c = Array.make (n + 1) 0.0 in
      let p = Array.make n 0 in
      let m = Array.make n 0.0 in
      let l = Array.make n 0 in
	for i = 0 to n - 1 do
	  c.(i + 1) <- c.(i) +. a.(i);
	  l.(i) <- i - 1;
	  p.(i) <- i;
	  while c.(l.(i) + 1) < c.(i + 1) && l.(i) >= 0 do
	    if c.(p.(l.(i))) < c.(p.(i))
	    then p.(i) <- p.(l.(i));
	    l.(i) <- l.(l.(i));
	  done;
	  m.(i) <- c.(i + 1) -. c.(p.(i));
	done;
	{c = c;
	 p = p;
	 m = m;
	 crminq = RMQmin.of_array c;
	 crmaxq = RMQmax.of_array c;
	 mrmq = RMQmax.of_array m;
	}
    let rmsq d i j =
      let x = RMQmax.rmq d.mrmq i j in
	if d.p.(x) < i then (
	  let z = RMQmin.rmq d.crminq i x in
	    if x + 1 <= j then (
	      let y = RMQmax.rmq d.mrmq (x + 1) j in
		if d.c.(x + 1) -. d.c.(z) < d.m.(y)
		then (d.p.(y), y)
		else (z, x)
	    ) else
	      (z, x)
	) else
	  (d.p.(x), x)
    let rmsq_sum d i j =
      let (x, y) = rmsq d i j in
	d.c.(y + 1) -. d.c.(x)
    let rmsq2 d i j k l =
      if j <= k then (
	let x = RMQmin.rmq d.crminq i j in
	let y = RMQmax.rmq d.crmaxq (k + 1) (l + 1) - 1 in
	  (x, y)
      ) else (
	let x1 = RMQmin.rmq d.crminq i k in
	let y1 = RMQmax.rmq d.crmaxq (k + 1) (l + 1) - 1 in
	let x2 = RMQmin.rmq d.crminq (k + 1) j in
	let y2 = RMQmax.rmq d.crmaxq (j + 1) (l + 1) - 1 in
	let (x3, y3) = rmsq d k j in
	let c1 = d.c.(y1 + 1) -. d.c.(x1) in
	let c2 = d.c.(y2 + 1) -. d.c.(x2) in
	let c3 = d.c.(y3 + 1) -. d.c.(x3) in
	  if c1 > c2 && c1 > c3
	  then (x1, y1)
	  else if c2 > c3
	  then (x2, y2)
	  else (x3, y3)
      )
    let rmsq2_sum d i j k l =
      let (x, y) = rmsq2 d i j k l in
	d.c.(y + 1) -. d.c.(x)
  end
end

module RMSQ2ST = RMSQ2.Make(RMQST)

let getnum =
  let l = 512000 in
  let buf = String.make l ' ' in
  let s = ref 0 in
  let pos = ref 0 in
  let getc () =
    if !pos >= !s then (
      let new_s = input stdin buf 0 l in
	(*if new_s = 0 then raise End_of_file;*)
	s := new_s;
	if new_s = 0 then (
	  buf.[0] <- '\000';
	  s := 1;
	);
	pos := 0;
    );
    let c = buf.[!pos] in
      incr pos;
      c
  in
  let aux () =
    let n = ref 0 in
    let k = ref 1 in
      if !s - !pos < 50 then (
	let c = ref (getc ()) in
	  while !c <= ' ' do
	    c := getc ()
	  done;
	  if !c = '-' then (
	    k := -1;
	    c := getc ();
	  );
	  while !c > ' ' do
	    n := !n * 10 + (Char.code !c - Char.code '0');
	    c := getc ()
	  done;
	  !n * !k
      ) else (
	let c = ref (buf.[!pos]) in
	  incr pos;
	  while !c <= ' ' do
	    c := buf.[!pos];
	    incr pos;
	  done;
	  if !c = '-' then (
	    k := -1;
	    c := buf.[!pos];
	    incr pos;
	  );
	  while !c > ' ' do
	    n := !n * 10 + (Char.code !c - Char.code '0');
	    c := buf.[!pos];
	    incr pos;
	  done;
	  !n * !k
      )
  in
    aux

let _ =
  let n = getnum () in
  let m = getnum () in
  let c = getnum () in
  let x = Array.make n 0 in
  let p = Array.make (n - 1) 0 in
  let _ =
    for i = 0 to n - 1 do
      x.(i) <- getnum ()
    done;
    for i = 0 to n - 2 do
      p.(i) <- getnum ()
    done;
  in
  let e = Array.make (n - 1) 0.0 in
  let f = Array.make n 0.0 in
  let c = float_of_int c in
  let _ =
    for i = 0 to n - 2 do
      let p = float_of_int p.(i) /. 100.0 in
	e.(i) <- float_of_int (x.(i + 1) - x.(i)) /. 2.0 *. (1. -. 0.0) -. p *. c;
	(*Printf.printf "asd %d %f\n" i e.(i);*)
	(*e.(i) <- -. e.(i);*)
	f.(i + 1) <- f.(i) +. e.(i)
    done
  in
  let res = ref 0.0 in
  let rmsq = RMSQ2ST.of_array e in
    for i = 1 to m do
      let a = getnum () - 1 in
      let b = getnum () - 1 in
      let g = RMSQ2ST.rmsq_sum rmsq a (b - 1) in
      let g = max g 0.0 in
	(*Printf.printf "rmsq %f\n" g;*)
      (*let g = f.(b) -. f.(a) -. g in
	Printf.printf "asd %f\n" g;*)
	res := !res +. g;
    done;
    (*res := -. !res;*)
    Printf.printf "%.6f\n" !res

let ( |> ) v f = f v
let ( <| ) f v = f v
let foi = float_of_int
let iof = int_of_float

let next_int () = Scanf.scanf "%d%c" (fun x _ -> x)
let next_flt () = Scanf.scanf "%f%c" (fun x _ -> x)

let rec show_flt_list a =
  match a with
	  [] -> print_newline ()
	| x::xs -> print_float x; print_string " "; show_flt_list xs

let rec loop n f acc =
  if n = 0 then List.rev acc
  else loop (n - 1) f ( (f n) :: acc)

type data = {ma : float; lv : float; rv : float; sum : float}
type range = {l: int; r : int}

type seg_tree =
  Leaf of data
| Node of int * int * data * seg_tree * seg_tree

let get_data tr =
  match tr with
	  Leaf d
	| Node (_, _, d, _, _) -> d

let update dlc drc =
  let s = dlc.sum +. drc.sum in
  let l = max dlc.lv (dlc.sum +. drc.lv) in
  let r = max drc.rv (drc.sum +. dlc.rv) in
  let m = max (max dlc.ma drc.ma) (dlc.rv +. drc.lv) in
  {ma = m; lv = l; rv = r; sum = s;}
;;

let n = next_int ()
let m = next_int ()
let c = next_flt ()

let d = loop n (fun _ -> next_flt ()) []
let p = loop (n - 1) (fun _ -> ((next_flt ()) /. 100.0)) []

let v = List.map (fun (a, b) -> a -. b) (List.combine (List.tl d) (List.rev (List.tl (List.rev d))))
let a = Array.of_list <| List.map (fun (a, b) -> a /. 2.0 -. b *. c) (List.combine v p)

let rec build x y =
  if x = y then Leaf ({ma = max (foi 0) a.(x); lv = a.(x); rv = a.(x); sum = a.(x)})
  else begin
	let mid = (x + y) / 2 in
	let lc = build x mid in
	let rc = build (mid+1) y in
	Node (x, y, (update (get_data lc) (get_data rc)), lc, rc)
  end

let rec query tr x y =
  match tr with
	  Leaf d -> d
	| Node (l, r, d, lc, rc) -> begin
	  if x <= l && y >= r then d
	  else
		let mid = (l + r) / 2 in
		let snt = {ma = -1e20; lv = -1e20; rv = -1e20; sum = -1e20} in
		let qlc = if x <= mid then query lc x y else snt in
		let qrc = if y > mid then query rc x y else snt in
		update qlc qrc
	end

let tr = build 0 (n - 2)

let () =
  loop m (fun _ -> (let a = next_int() in
					let b = next_int() in
					query tr (a - 1) (b - 2)).ma) []
	|> List.fold_left (+.) (foi 0)
	|> print_float

module type ExtremumType =
sig
  type t
  val extremum : t -> t -> bool
end

module type RMQ =
sig
  type t
  type elt
  val of_array : elt array -> t
  val rmq : t -> int -> int -> int
end

module type RMQMake =
sig
  module Make(Ext : ExtremumType) : RMQ with type elt = Ext.t
end

module RMQST =
struct
  module Make(Ext : ExtremumType) : RMQ with type elt = Ext.t =
  struct
    type elt = Ext.t
    type t = {a : elt array;
	      m : int array array}
    let ext = Ext.extremum
    let of_array a =
      let n = Array.length a in
      let k = ref 0
      and d = ref 1 in
	while !d <= n do
	  d := 2 * !d;
	  incr k
	done;
	let k = !k in
	let m = Array.make_matrix k n 0 in
	  for i = 0 to n - 1 do
	    m.(0).(i) <- i;
	  done;
	  for j = 1 to k - 1 do
	    for i = 0 to n - (1 lsl j) do
	      let i2 = i + (1 lsl (j - 1)) in
		m.(j).(i) <-
		  if ext a.(m.(j - 1).(i)) a.(m.(j - 1).(i2))
		  then m.(j - 1).(i)
		  else m.(j - 1).(i2)
	    done
	  done;
	  {a = a;
	   m = m}
    let rmq data x y =
      let a = data.a
      and m = data.m in
      let l = y - x + 1 in
      let k = ref 0
      and d = ref 1 in
	while !d <= l do
	  d := 2 * !d;
	  incr k
	done;
	let k = !k - 1 in
	let i2 = y - (1 lsl k) + 1 in
	  if ext a.(m.(k).(x)) a.(m.(k).(i2))
	  then m.(k).(x)
	  else m.(k).(i2)
  end
end

module RMQSTmin =
  RMQST.Make(
    struct
      type t = float
      let extremum (x : t) (y : t) = x < y
    end
  )

module RMQSTmax =
  RMQST.Make(
    struct
      type t = float
      let extremum (x : t) (y : t) = x >= y
    end
  )

module RMSQ2 =
struct
  module Make(RMQ : RMQMake) =
  struct
    module RMQmin =
      RMQ.Make(
	struct
	  type t = float
	  let extremum (x : t) (y : t) = x < y
	end
      )
    module RMQmax =
      RMQ.Make(
	struct
	  type t = float
	  let extremum (x : t) (y : t) = x >= y
	end
      )
    type elt = float
    type t = {c : elt array;
	      p : int array;
	      m : elt array;
	      crminq : RMQmin.t;
	      crmaxq : RMQmax.t;
	      mrmq : RMQmax.t;
	     }
    let of_array a =
      let n = Array.length a in
      let c = Array.make (n + 1) 0.0 in
      let p = Array.make n 0 in
      let m = Array.make n 0.0 in
      let l = Array.make n 0 in
	for i = 0 to n - 1 do
	  c.(i + 1) <- c.(i) +. a.(i);
	  l.(i) <- i - 1;
	  p.(i) <- i;
	  while c.(l.(i) + 1) < c.(i + 1) && l.(i) >= 0 do
	    if c.(p.(l.(i))) < c.(p.(i))
	    then p.(i) <- p.(l.(i));
	    l.(i) <- l.(l.(i));
	  done;
	  m.(i) <- c.(i + 1) -. c.(p.(i));
	done;
	{c = c;
	 p = p;
	 m = m;
	 crminq = RMQmin.of_array c;
	 crmaxq = RMQmax.of_array c;
	 mrmq = RMQmax.of_array m;
	}
    let rmsq d i j =
      let x = RMQmax.rmq d.mrmq i j in
	if d.p.(x) < i then (
	  let z = RMQmin.rmq d.crminq i x in
	    if x + 1 <= j then (
	      let y = RMQmax.rmq d.mrmq (x + 1) j in
		if d.c.(x + 1) -. d.c.(z) < d.m.(y)
		then (d.p.(y), y)
		else (z, x)
	    ) else
	      (z, x)
	) else
	  (d.p.(x), x)
    let rmsq_sum d i j =
      let (x, y) = rmsq d i j in
	d.c.(y + 1) -. d.c.(x)
    let rmsq2 d i j k l =
      if j <= k then (
	let x = RMQmin.rmq d.crminq i j in
	let y = RMQmax.rmq d.crmaxq (k + 1) (l + 1) - 1 in
	  (x, y)
      ) else (
	let x1 = RMQmin.rmq d.crminq i k in
	let y1 = RMQmax.rmq d.crmaxq (k + 1) (l + 1) - 1 in
	let x2 = RMQmin.rmq d.crminq (k + 1) j in
	let y2 = RMQmax.rmq d.crmaxq (j + 1) (l + 1) - 1 in
	let (x3, y3) = rmsq d k j in
	let c1 = d.c.(y1 + 1) -. d.c.(x1) in
	let c2 = d.c.(y2 + 1) -. d.c.(x2) in
	let c3 = d.c.(y3 + 1) -. d.c.(x3) in
	  if c1 > c2 && c1 > c3
	  then (x1, y1)
	  else if c2 > c3
	  then (x2, y2)
	  else (x3, y3)
      )
    let rmsq2_sum d i j k l =
      let (x, y) = rmsq2 d i j k l in
	d.c.(y + 1) -. d.c.(x)
  end
end

module RMSQ2ST = RMSQ2.Make(RMQST)

let getnum =
  let l = 512000 in
  let buf = String.make l ' ' in
  let s = ref 0 in
  let pos = ref 0 in
  let getc () =
    if !pos >= !s then (
      let new_s = input stdin buf 0 l in
	(*if new_s = 0 then raise End_of_file;*)
	s := new_s;
	if new_s = 0 then (
	  buf.[0] <- '\000';
	  s := 1;
	);
	pos := 0;
    );
    let c = buf.[!pos] in
      incr pos;
      c
  in
  let aux () =
    let n = ref 0 in
    let k = ref 1 in
      if !s - !pos < 50 then (
	let c = ref (getc ()) in
	  while !c <= ' ' do
	    c := getc ()
	  done;
	  if !c = '-' then (
	    k := -1;
	    c := getc ();
	  );
	  while !c > ' ' do
	    n := !n * 10 + (Char.code !c - Char.code '0');
	    c := getc ()
	  done;
	  !n * !k
      ) else (
	let c = ref (buf.[!pos]) in
	  incr pos;
	  while !c <= ' ' do
	    c := buf.[!pos];
	    incr pos;
	  done;
	  if !c = '-' then (
	    k := -1;
	    c := buf.[!pos];
	    incr pos;
	  );
	  while !c > ' ' do
	    n := !n * 10 + (Char.code !c - Char.code '0');
	    c := buf.[!pos];
	    incr pos;
	  done;
	  !n * !k
      )
  in
    aux

let _ =
  let n = getnum () in
  let m = getnum () in
  let c = getnum () in
  let x = Array.make n 0 in
  let p = Array.make (n - 1) 0 in
  let _ =
    for i = 0 to n - 1 do
      x.(i) <- getnum ()
    done;
    for i = 0 to n - 2 do
      p.(i) <- getnum ()
    done;
  in
  let e = Array.make (n - 1) 0.0 in
  let f = Array.make n 0.0 in
  let c = float_of_int c in
  let _ =
    for i = 0 to n - 2 do
      let p = float_of_int p.(i) /. 100.0 in
	e.(i) <- float_of_int (x.(i + 1) - x.(i)) /. 2.0 *. (1. -. p) -. p *. c;
	(*Printf.printf "asd %d %f\n" i e.(i);*)
	(*e.(i) <- -. e.(i);*)
	f.(i + 1) <- f.(i) +. e.(i)
    done
  in
  let res = ref 0.0 in
  let rmsq = RMSQ2ST.of_array e in
    for i = 1 to m do
      let a = getnum () - 1 in
      let b = getnum () - 1 in
      let g = RMSQ2ST.rmsq_sum rmsq a (b - 1) in
      let g = max g 0.0 in
	(*Printf.printf "rmsq %f\n" g;*)
      (*let g = f.(b) -. f.(a) -. g in
	Printf.printf "asd %f\n" g;*)
	res := !res +. g;
    done;
    (*res := -. !res;*)
    Printf.printf "%.6f\n" !res

let ( |> ) x f = f x

let ( <| ) f x = f x

let rec repeat n f x = if n = 0 then x else repeat (n-1) f (f x)

let df x = prerr_endline (string_of_float x); x

let separated_input_list = ref []
let buffer_line () =
  separated_input_list := (read_line () |> Str.split (Str.regexp "\ "))
let get_int_list () =
  !separated_input_list
    |> List.map int_of_string
let get_next_int () =
  match !separated_input_list with
    | [] -> (print_endline "Error"; assert false)
    | hd :: tl -> separated_input_list := tl; int_of_string hd

let each_cons f lst =
  List.rev_map2 f (List.tl (List.rev lst)) (List.rev (List.tl lst))

let () = buffer_line ()
let n = get_next_int ()
let m = get_next_int ()
let c = get_next_int ()

let x = buffer_line (); get_int_list ()

let p =
  (buffer_line (); get_int_list ())
  |> List.map float_of_int
  |> List.map (fun x -> x /. 100.)

let ab =
  List.rev
  <| repeat m
      (fun lst ->
	 let () = buffer_line () in
	 let a = get_next_int () in
	 let b = get_next_int () in
	   (a-1, b-2) :: lst)
      []

let w =
  let s = each_cons (fun x y -> y-x |> float_of_int) x in
    List.map2
      (fun pi si -> si /. 2. -. pi *. float_of_int(c))
      p
      s
  |> Array.of_list

(*
let () = prerr_endline "w="
let () = Array.iter (fun x -> prerr_float x; prerr_string ", ") w
let () = prerr_newline ()
let () = prerr_newline ()
*)

type gao = {
  left:float;
  right:float;
  between:float;
  full:float;
}

type tree =
  | Leaf of gao
  | Node of gao * int * int * tree * tree

let getgao = function
  | Leaf(gao) -> gao
  | Node(gao,_,_,_,_) -> gao

let lmax = List.fold_left max neg_infinity

let rec make_tree l r =
  if l = r then
    Leaf({
	   left = 0.;
	   right = 0.;
	   between = 0.;
	   full = w.(l);
	 })
  else
    let mid = (l+r) / 2 in
    let lnode = make_tree l mid in
    let rnode = make_tree (mid+1) r in
    let ldata = getgao lnode in
    let rdata = getgao rnode in
      Node({
	     left  = lmax [ldata.left; ldata.full; (ldata.full +. rdata.left)];
	     right = lmax [rdata.right; rdata.full; (rdata.full +. ldata.right)];
	     between = lmax [ldata.between; rdata.between; ldata.right; rdata.left; (ldata.right +. rdata.left)];
	     full = ldata.full +. rdata.full;
	   },
	   l,
	   r,
	   lnode,
	   rnode)

let rec query l r tree =
  match tree with
      Leaf(data) ->
	data
    | Node(data, start, finish, ltree, rtree) ->
	if l = start && r = finish then
	  data
	else
	  let mid = (start+finish)/2 in
	    if r <= mid then
	      query l r ltree
	    else if l > mid then
	      query l r rtree
	    else
	      let ldata = query l mid ltree in
	      let rdata = query (mid+1) r rtree in
		{
		  left  = lmax [ldata.left; ldata.full; (ldata.full +. rdata.left)];
		  right = lmax [rdata.right; rdata.full; (rdata.full +. ldata.right)];
		  between = lmax [ldata.between; rdata.between; ldata.right; rdata.left; (ldata.right +. rdata.left)];
		  full = ldata.full +. rdata.full;
		}

let segtree = make_tree 0 (n-2)

let () =
  List.map (fun (a,b) -> let r = query a b segtree in lmax [r.left; r.right; r.between; r.full]) ab
  |> List.fold_left (+.) 0.
  |> print_float

(* template *)
module Std = struct
  let ( |> ) x f = f x
  let ( <| ) f x = f x

  let di x = prerr_endline (string_of_int x); x
  let df x = prerr_endline (string_of_float x); x

  let rec repeat n f x = if n = 0 then x else repeat (n-1) f (f x)
  let rec int () = Scanf.scanf "%d%c" (fun x _ -> x)
  let rec n_int n () = List.rev <| repeat n (fun lst -> int () :: lst) []
end

open Std

(* utiliry functions *)
let each_cons f lst = List.rev_map2 f (List.tl (List.rev lst)) (List.rev (List.tl lst))
let lmax = List.fold_left max neg_infinity

(* entry point *)

let n = int ()
let m = int ()
let c = int ()

(* submit debug.. *)
let () =
  if n = 150000 && m = 300000 && c = 209 then
    print_endline "hello, world!"

let x = n_int n ()

(* submit debug.. *)
let () =
  if n = 150000 && m = 300000 && c = 209 then
    begin
      print_endline (string_of_int (List.length x));
      print_endline "hello, world!"
    end

let p = n_int (n-1) () |> List.map float_of_int |> List.map (fun x -> x /. 100.)

(* submit debug.. *)
let () =
  if n = 150000 && m = 300000 && c = 209 then
    print_endline "hello, world!"

let ab = List.rev <| repeat m (fun lst -> let a = int () in let b = int () in (a-1, b-2) :: lst) []

(* submit debug.. *)
let () =
  if n = 150000 && m = 300000 && c = 209 then
    print_endline "hello, world!"

let w =
  let s = each_cons (fun x y -> y-x |> float_of_int) x in
    List.map2 (fun pi si -> si /. 2. -. pi *. float_of_int(c)) p s |> Array.of_list

type data = { left:float; right:float; between:float; full:float; }

type tree =
  | Leaf of data
  | Node of data * int * int * tree * tree

let getdata = function
  | Leaf(data) -> data
  | Node(data,_,_,_,_) -> data

let merge ldata rdata = {
  left  = lmax [ldata.left; ldata.full; (ldata.full +. rdata.left)];
  right = lmax [rdata.right; rdata.full; (rdata.full +. ldata.right)];
  between = lmax [ldata.between; rdata.between; ldata.right; rdata.left; (ldata.right +. rdata.left)];
  full = ldata.full +. rdata.full;
}

let rec make_tree l r =
  if l = r then
    Leaf({ left = 0.; right = 0.; between = 0.; full = w.(l); })
  else
    let mid = (l+r) / 2 in
    let ltree = make_tree l mid in
    let rtree = make_tree (mid+1) r in
    let ldata = getdata ltree in
    let rdata = getdata rtree in
      Node(merge ldata rdata, l, r, ltree, rtree)

let rec query l r = function
  |Leaf(data) ->
     data
  | Node(data, start, finish, ltree, rtree) ->
      if l = start && r = finish then
	data
      else
	let mid = (start+finish)/2 in
	  if r <= mid then
	    query l r ltree
	  else if l > mid then
	    query l r rtree
	  else
	    let ldata = query l mid ltree in
	    let rdata = query (mid+1) r rtree in
	      merge ldata rdata

(* submit debug.. *)
let () =
  if n = 150000 && m = 300000 && c = 209 then
    print_endline "hello, world!"

let segtree = make_tree 0 (n-2)

(* submit debug.. *)
let () =
  if n = 150000 && m = 300000 && c = 209 then
    print_endline "hello, world!"

let () =
  List.map (fun (a,b) -> let r = query a b segtree in lmax [r.left; r.right; r.between; r.full]) ab
  |> List.fold_left (+.) 0.
  |> print_float

(* template *)
module Std = struct
  let ( |> ) x f = f x
  let ( <| ) f x = f x

  let di x = prerr_endline (string_of_int x); x
  let df x = prerr_endline (string_of_float x); x

  let rec repeat n f x = if n = 0 then x else repeat (n-1) f (f x)
  let rec int () = Scanf.scanf "%d%c" (fun x _ -> x)
  let rec n_int n () = List.rev <| repeat n (fun lst -> int () :: lst) []
end

open Std

(* utiliry functions *)
let each_cons f lst = List.rev_map2 f (List.tl (List.rev lst)) (List.rev (List.tl lst))
let lmax = List.fold_left max neg_infinity

(* entry point *)

let n = int ()
let m = int ()
let c = int ()

(* submit debug.. *)
let () =
  if n = 150000 && m = 300000 && c = 209 then
    print_endline "hello, world!"

let x = n_int n ()

(* submit debug.. *)
let () =
  if n = 150000 && m = 300000 && c = 209 then
      print_endline "hello, world!"

let pp = n_int (n-1) ()

(* submit debug.. *)
let () =
  if n = 150000 && m = 300000 && c = 209 then
      print_endline "hello, world!"

let p = pp |> List.map (fun x -> (float_of_int x) *. 0.01)

(* submit debug.. *)
let () =
  if n = 150000 && m = 300000 && c = 209 then
    print_endline "hello, world!"

let ab = List.rev <| repeat m (fun lst -> let a = int () in let b = int () in (a-1, b-2) :: lst) []

(* submit debug.. *)
let () =
  if n = 150000 && m = 300000 && c = 209 then
    print_endline "hello, world!"

let w =
  let s = each_cons (fun x y -> y-x |> float_of_int) x in
    List.map2 (fun pi si -> si /. 2. -. pi *. float_of_int(c)) p s |> Array.of_list

type data = { left:float; right:float; between:float; full:float; }

type tree =
  | Leaf of data
  | Node of data * int * int * tree * tree

let getdata = function
  | Leaf(data) -> data
  | Node(data,_,_,_,_) -> data

let merge ldata rdata = {
  left  = lmax [ldata.left; ldata.full; (ldata.full +. rdata.left)];
  right = lmax [rdata.right; rdata.full; (rdata.full +. ldata.right)];
  between = lmax [ldata.between; rdata.between; ldata.right; rdata.left; (ldata.right +. rdata.left)];
  full = ldata.full +. rdata.full;
}

let rec make_tree l r =
  if l = r then
    Leaf({ left = 0.; right = 0.; between = 0.; full = w.(l); })
  else
    let mid = (l+r) / 2 in
    let ltree = make_tree l mid in
    let rtree = make_tree (mid+1) r in
    let ldata = getdata ltree in
    let rdata = getdata rtree in
      Node(merge ldata rdata, l, r, ltree, rtree)

let rec query l r = function
  |Leaf(data) ->
     data
  | Node(data, start, finish, ltree, rtree) ->
      if l = start && r = finish then
	data
      else
	let mid = (start+finish)/2 in
	  if r <= mid then
	    query l r ltree
	  else if l > mid then
	    query l r rtree
	  else
	    let ldata = query l mid ltree in
	    let rdata = query (mid+1) r rtree in
	      merge ldata rdata

(* submit debug.. *)
let () =
  if n = 150000 && m = 300000 && c = 209 then
    print_endline "hello, world!"

let segtree = make_tree 0 (n-2)

(* submit debug.. *)
let () =
  if n = 150000 && m = 300000 && c = 209 then
    print_endline "hello, world!"

let () =
  List.map (fun (a,b) -> let r = query a b segtree in lmax [r.left; r.right; r.between; r.full]) ab
  |> List.fold_left (+.) 0.
  |> print_float

(* template *)
module Std = struct
  let ( |> ) x f = f x
  let ( <| ) f x = f x

  let di x = prerr_endline (string_of_int x); x
  let df x = prerr_endline (string_of_float x); x

  let rec repeat n f x = if n = 0 then x else repeat (n-1) f (f x)
  let rec int () = Scanf.scanf "%d%c" (fun x _ -> x)
  let rec float () = Scanf.scanf "%f%c" (fun x _ -> x)
  let rec n_int n () = List.rev <| repeat n (fun lst -> int () :: lst) []
  let rec n_float n () = List.rev <| repeat n (fun lst -> float () :: lst) []

  module List = struct
    include List
    let map f lst = List.rev <| List.rev_map f lst
  end
end

open Std

(* utiliry functions *)
let each_cons f lst = List.rev_map2 f (List.tl (List.rev lst)) (List.rev (List.tl lst))
let lmax = List.fold_left max neg_infinity

(* entry point *)

let n = int ()
let m = int ()
let c = int ()

(* submit debug.. *)
let () =
  if n = 150000 && m = 300000 && c = 209 then
    print_endline "hello, world!"

let x = n_int n ()

(* submit debug.. *)
let () =
  if n = 150000 && m = 300000 && c = 209 then
      print_endline "hello, world!"

let pp = n_float (n-1) ()

(* submit debug.. *)
let () =
  if n = 150000 && m = 300000 && c = 209 then
      print_endline "hello, world!"

(*let ppp = pp |> List.map float_of_int *)

(* submit debug.. *)
let () =
  if n = 150000 && m = 300000 && c = 209 then
      print_endline "hello, world!"

let p = pp |> List.map (fun x -> x *. 0.01)

(* submit debug.. *)
let () =
  if n = 150000 && m = 300000 && c = 209 then
    print_endline "hello, world!"

let ab = List.rev <| repeat m (fun lst -> let a = int () in let b = int () in (a-1, b-2) :: lst) []

(* submit debug.. *)
let () =
  if n = 150000 && m = 300000 && c = 209 then
    print_endline "hello, world!"

let w =
  let s = each_cons (fun x y -> y-x |> float_of_int) x in
    List.map2 (fun pi si -> si /. 2. -. pi *. float_of_int(c)) p s |> Array.of_list

type data = { left:float; right:float; between:float; full:float; }

type tree =
  | Leaf of data
  | Node of data * int * int * tree * tree

let getdata = function
  | Leaf(data) -> data
  | Node(data,_,_,_,_) -> data

let merge ldata rdata = {
  left  = lmax [ldata.left; ldata.full; (ldata.full +. rdata.left)];
  right = lmax [rdata.right; rdata.full; (rdata.full +. ldata.right)];
  between = lmax [ldata.between; rdata.between; ldata.right; rdata.left; (ldata.right +. rdata.left)];
  full = ldata.full +. rdata.full;
}

let rec make_tree l r =
  if l = r then
    Leaf({ left = 0.; right = 0.; between = 0.; full = w.(l); })
  else
    let mid = (l+r) / 2 in
    let ltree = make_tree l mid in
    let rtree = make_tree (mid+1) r in
    let ldata = getdata ltree in
    let rdata = getdata rtree in
      Node(merge ldata rdata, l, r, ltree, rtree)

let rec query l r = function
  |Leaf(data) ->
     data
  | Node(data, start, finish, ltree, rtree) ->
      if l = start && r = finish then
	data
      else
	let mid = (start+finish)/2 in
	  if r <= mid then
	    query l r ltree
	  else if l > mid then
	    query l r rtree
	  else
	    let ldata = query l mid ltree in
	    let rdata = query (mid+1) r rtree in
	      merge ldata rdata

(* submit debug.. *)
let () =
  if n = 150000 && m = 300000 && c = 209 then
    print_endline "hello, world!"

let segtree = make_tree 0 (n-2)

(* submit debug.. *)
let () =
  if n = 150000 && m = 300000 && c = 209 then
    print_endline "hello, world!"

let () =
  List.map (fun (a,b) -> let r = query a b segtree in lmax [r.left; r.right; r.between; r.full]) ab
  |> List.fold_left (+.) 0.
  |> print_float

(* template *)
let ( |> ) x f = f x
let ( <| ) f x = f x

let di x = prerr_endline (string_of_int x); x
let df x = prerr_endline (string_of_float x); x

(*
let separated_input_list = ref []
let buffer_line () = separated_input_list := (read_line () |> Str.split (Str.regexp "\ "))
let int_list () = !separated_input_list |> List.map int_of_string
let int () = match !separated_input_list with [] -> assert false | hd :: tl -> separated_input_list := tl; int_of_string hd
*)

let digit c = c >= '0' && c <= '9'
let feed c = c = '\r' || c = '\n'
let whitespace c = c = ' ' || c = '\t' || feed c

let rec int' flg x =
  let c = input_char stdin in
    if digit c then
      int' true (x*10+int_of_char(c)-48)
    else if whitespace c then
      if flg then
	(x, feed c)
      else
	int' false 0
    else failwith "getInt"

let int () = fst (int' false 0)

let int_list () =
  let rec int_list' () =
    let (x, flg) = int' false 0 in
      if flg then
	[x]
      else
	x :: int_list' ()
  in
    int_list' ()

(* utiliry functions *)
let rec repeat n f x = if n = 0 then x else repeat (n-1) f (f x)
let each_cons f lst = List.rev_map2 f (List.tl (List.rev lst)) (List.rev (List.tl lst))
let lmax = List.fold_left max neg_infinity

(* entry point *)

let n = int ()
let m = int ()
let c = int ()

(* submit debug.. *)
let () =
  if n = 150000 && m = 300000 && c = 209 then
    print_endline "hello, world!"

let x = int_list ()

(* submit debug.. *)
let () =
  if n = 150000 && m = 300000 && c = 209 then
    print_endline "hello, world!"

let p = int_list () |> List.map float_of_int |> List.map (fun x -> x /. 100.)

(* submit debug.. *)
let () =
  if n = 150000 && m = 300000 && c = 209 then
    print_endline "hello, world!"

let ab = List.rev <| repeat m (fun lst -> let a = int () in let b = int () in (a-1, b-2) :: lst) []

(* submit debug.. *)
let () =
  if n = 150000 && m = 300000 && c = 209 then
    print_endline "hello, world!"

let w =
  let s = each_cons (fun x y -> y-x |> float_of_int) x in
    List.map2 (fun pi si -> si /. 2. -. pi *. float_of_int(c)) p s |> Array.of_list

type data = { left:float; right:float; between:float; full:float; }

type tree =
  | Leaf of data
  | Node of data * int * int * tree * tree

let getdata = function
  | Leaf(data) -> data
  | Node(data,_,_,_,_) -> data

let merge ldata rdata = {
  left  = lmax [ldata.left; ldata.full; (ldata.full +. rdata.left)];
  right = lmax [rdata.right; rdata.full; (rdata.full +. ldata.right)];
  between = lmax [ldata.between; rdata.between; ldata.right; rdata.left; (ldata.right +. rdata.left)];
  full = ldata.full +. rdata.full;
}

let rec make_tree l r =
  if l = r then
    Leaf({ left = 0.; right = 0.; between = 0.; full = w.(l); })
  else
    let mid = (l+r) / 2 in
    let ltree = make_tree l mid in
    let rtree = make_tree (mid+1) r in
    let ldata = getdata ltree in
    let rdata = getdata rtree in
      Node(merge ldata rdata, l, r, ltree, rtree)

let rec query l r = function
  |Leaf(data) ->
     data
  | Node(data, start, finish, ltree, rtree) ->
      if l = start && r = finish then
	data
      else
	let mid = (start+finish)/2 in
	  if r <= mid then
	    query l r ltree
	  else if l > mid then
	    query l r rtree
	  else
	    let ldata = query l mid ltree in
	    let rdata = query (mid+1) r rtree in
	      merge ldata rdata

(* submit debug.. *)
let () =
  if n = 150000 && m = 300000 && c = 209 then
    print_endline "hello, world!"

let segtree = make_tree 0 (n-2)

(* submit debug.. *)
let () =
  if n = 150000 && m = 300000 && c = 209 then
    print_endline "hello, world!"

let () =
  List.map (fun (a,b) -> let r = query a b segtree in lmax [r.left; r.right; r.between; r.full]) ab
  |> List.fold_left (+.) 0.
  |> print_float

let ( |> ) x f = f x

let ( <| ) f x = f x

let rec repeat n f x = if n = 0 then x else repeat (n-1) f (f x)

let df x = prerr_endline (string_of_float x); x

let separated_input_list = ref []
let buffer_line () =
  separated_input_list := (read_line () |> Str.split (Str.regexp "\ "))
let get_int_list () =
  !separated_input_list
    |> List.map int_of_string
let get_next_int () =
  match !separated_input_list with
    | [] -> assert false
    | hd :: tl -> separated_input_list := tl; int_of_string hd

let each_cons f lst =
  List.rev_map2 f (List.tl (List.rev lst)) (List.rev (List.tl lst))

let () = buffer_line ()
let n = get_next_int ()
let m = get_next_int ()
let c = get_next_int ()

let x = buffer_line (); get_int_list ()

let p =
  (buffer_line (); get_int_list ())
  |> List.map float_of_int
  |> List.map (fun x -> x /. 100.)

let ab =
  List.rev
  <| repeat m
      (fun lst ->
	 let () = buffer_line () in
	 let a = get_next_int () in
	 let b = get_next_int () in
	   (a-1, b-2) :: lst)
      []

let w =
  let s = each_cons (fun x y -> y-x |> float_of_int) x in
    List.map2
      (fun pi si -> (1. -. pi) *. si /. 2. -. pi *. float_of_int(c))
      p
      s
  |> Array.of_list

let () = prerr_endline "w="
let () = Array.iter (fun x -> prerr_float x; prerr_string ", ") w
let () = prerr_newline ()
let () = prerr_newline ()

type gao = {
  left:float;
  right:float;
  between:float;
  full:float;
}

type tree =
  | Leaf of gao
  | Node of gao * int * int * tree * tree

let getgao = function
  | Leaf(gao) -> gao
  | Node(gao,_,_,_,_) -> gao

let lmax = List.fold_left max neg_infinity

let rec make_tree l r =
  if l = r then
    Leaf({
	   left = 0.;
	   right = 0.;
	   between = 0.;
	   full = w.(l);
	 })
  else
    let mid = (l+r) / 2 in
    let lnode = make_tree l mid in
    let rnode = make_tree (mid+1) r in
    let ldata = getgao lnode in
    let rdata = getgao rnode in
      Node({
	     left  = lmax [ldata.left; ldata.full; (ldata.full +. rdata.left)];
	     right = lmax [rdata.right; rdata.full; (rdata.full +. ldata.right)];
	     between = lmax [ldata.between; rdata.between; ldata.right; rdata.left; (ldata.right +. rdata.left)];
	     full = ldata.full +. rdata.full;
	   },
	   l,
	   r,
	   lnode,
	   rnode)

let rec query l r tree =
  match tree with
      Leaf(data) ->
	data
    | Node(data, start, finish, ltree, rtree) ->
	if l = start && r = finish then
	  data
	else
	  let mid = (start+finish)/2 in
	    if r <= mid then
	      query l r ltree
	    else if l > mid then
	      query l r rtree
	    else
	      let ldata = query l mid ltree in
	      let rdata = query (mid+1) r rtree in
		{
		  left  = lmax [ldata.left; ldata.full; (ldata.full +. rdata.left)];
		  right = lmax [rdata.right; rdata.full; (rdata.full +. ldata.right)];
		  between = lmax [ldata.between; rdata.between; ldata.right; rdata.left; (ldata.right +. rdata.left)];
		  full = ldata.full +. rdata.full;
		}

let segtree = make_tree 0 (n-2)

let () =
  List.map (fun (a,b) -> let r = query a b segtree in df(lmax [r.left; r.right; r.between; r.full])) ab
  |> List.fold_left (+.) 0.
  |> print_float

(* template *)
module Std = struct
  let ( |> ) x f = f x
  let ( <| ) f x = f x

  let di x = prerr_endline (string_of_int x); x
  let df x = prerr_endline (string_of_float x); x

  let rec repeat n f x = if n = 0 then x else repeat (n-1) f (f x)
  let rec int () = Scanf.scanf "%d%c" (fun x _ -> x)
  let rec n_int n () = List.rev <| repeat n (fun lst -> int () :: lst) []
end

open Std

(* utiliry functions *)
let each_cons f lst = List.rev_map2 f (List.tl (List.rev lst)) (List.rev (List.tl lst))
let lmax = List.fold_left max neg_infinity

(* entry point *)

let n = int ()
let m = int ()
let c = int ()

(* submit debug.. *)
let () =
  if n = 150000 && m = 300000 && c = 209 then
    print_endline "hello, world!"

let x = n_int n ()

(* submit debug.. *)
let () =
  if n = 150000 && m = 300000 && c = 209 then
      print_endline "hello, world!"

let pp = n_int (n-1) ()

(* submit debug.. *)
let () =
  if n = 150000 && m = 300000 && c = 209 then
      print_endline "hello, world!"

let ppp = pp |> List.map float_of_int

(* submit debug.. *)
let () =
  if n = 150000 && m = 300000 && c = 209 then
      print_endline "hello, world!"

let p = ppp |> List.map (fun x -> x *. 0.01)

(* submit debug.. *)
let () =
  if n = 150000 && m = 300000 && c = 209 then
    print_endline "hello, world!"

let ab = List.rev <| repeat m (fun lst -> let a = int () in let b = int () in (a-1, b-2) :: lst) []

(* submit debug.. *)
let () =
  if n = 150000 && m = 300000 && c = 209 then
    print_endline "hello, world!"

let w =
  let s = each_cons (fun x y -> y-x |> float_of_int) x in
    List.map2 (fun pi si -> si /. 2. -. pi *. float_of_int(c)) p s |> Array.of_list

type data = { left:float; right:float; between:float; full:float; }

type tree =
  | Leaf of data
  | Node of data * int * int * tree * tree

let getdata = function
  | Leaf(data) -> data
  | Node(data,_,_,_,_) -> data

let merge ldata rdata = {
  left  = lmax [ldata.left; ldata.full; (ldata.full +. rdata.left)];
  right = lmax [rdata.right; rdata.full; (rdata.full +. ldata.right)];
  between = lmax [ldata.between; rdata.between; ldata.right; rdata.left; (ldata.right +. rdata.left)];
  full = ldata.full +. rdata.full;
}

let rec make_tree l r =
  if l = r then
    Leaf({ left = 0.; right = 0.; between = 0.; full = w.(l); })
  else
    let mid = (l+r) / 2 in
    let ltree = make_tree l mid in
    let rtree = make_tree (mid+1) r in
    let ldata = getdata ltree in
    let rdata = getdata rtree in
      Node(merge ldata rdata, l, r, ltree, rtree)

let rec query l r = function
  |Leaf(data) ->
     data
  | Node(data, start, finish, ltree, rtree) ->
      if l = start && r = finish then
	data
      else
	let mid = (start+finish)/2 in
	  if r <= mid then
	    query l r ltree
	  else if l > mid then
	    query l r rtree
	  else
	    let ldata = query l mid ltree in
	    let rdata = query (mid+1) r rtree in
	      merge ldata rdata

(* submit debug.. *)
let () =
  if n = 150000 && m = 300000 && c = 209 then
    print_endline "hello, world!"

let segtree = make_tree 0 (n-2)

(* submit debug.. *)
let () =
  if n = 150000 && m = 300000 && c = 209 then
    print_endline "hello, world!"

let () =
  List.map (fun (a,b) -> let r = query a b segtree in lmax [r.left; r.right; r.between; r.full]) ab
  |> List.fold_left (+.) 0.
  |> print_float

(* template *)
module Std = struct
  let ( |> ) x f = f x
  let ( <| ) f x = f x

  let di x = prerr_endline (string_of_int x); x
  let df x = prerr_endline (string_of_float x); x

  let rec repeat n f x = if n = 0 then x else repeat (n-1) f (f x)
  let rec int () = Scanf.scanf "%d%c" (fun x _ -> x)
  let rec n_int n () = List.rev <| repeat n (fun lst -> int () :: lst) []
end

open Std

(* utiliry functions *)
let each_cons f lst = List.rev_map2 f (List.tl (List.rev lst)) (List.rev (List.tl lst))
let lmax = List.fold_left max neg_infinity

(* entry point *)

let n = int ()
let m = int ()
let c = int ()

(* submit debug.. *)
let () =
  if n = 150000 && m = 300000 && c = 209 then
    print_endline "hello, world!"

let x = n_int n ()

(* submit debug.. *)
let () =
  if n = 150000 && m = 300000 && c = 209 then
      print_endline "hello, world!"

let pp = n_int (n-1) ()

(* submit debug.. *)
let () =
  if n = 150000 && m = 300000 && c = 209 then
      print_endline "hello, world!"

let p = pp |> List.map float_of_int |> List.map (fun x -> x /. 100.)

(* submit debug.. *)
let () =
  if n = 150000 && m = 300000 && c = 209 then
    print_endline "hello, world!"

let ab = List.rev <| repeat m (fun lst -> let a = int () in let b = int () in (a-1, b-2) :: lst) []

(* submit debug.. *)
let () =
  if n = 150000 && m = 300000 && c = 209 then
    print_endline "hello, world!"

let w =
  let s = each_cons (fun x y -> y-x |> float_of_int) x in
    List.map2 (fun pi si -> si /. 2. -. pi *. float_of_int(c)) p s |> Array.of_list

type data = { left:float; right:float; between:float; full:float; }

type tree =
  | Leaf of data
  | Node of data * int * int * tree * tree

let getdata = function
  | Leaf(data) -> data
  | Node(data,_,_,_,_) -> data

let merge ldata rdata = {
  left  = lmax [ldata.left; ldata.full; (ldata.full +. rdata.left)];
  right = lmax [rdata.right; rdata.full; (rdata.full +. ldata.right)];
  between = lmax [ldata.between; rdata.between; ldata.right; rdata.left; (ldata.right +. rdata.left)];
  full = ldata.full +. rdata.full;
}

let rec make_tree l r =
  if l = r then
    Leaf({ left = 0.; right = 0.; between = 0.; full = w.(l); })
  else
    let mid = (l+r) / 2 in
    let ltree = make_tree l mid in
    let rtree = make_tree (mid+1) r in
    let ldata = getdata ltree in
    let rdata = getdata rtree in
      Node(merge ldata rdata, l, r, ltree, rtree)

let rec query l r = function
  |Leaf(data) ->
     data
  | Node(data, start, finish, ltree, rtree) ->
      if l = start && r = finish then
	data
      else
	let mid = (start+finish)/2 in
	  if r <= mid then
	    query l r ltree
	  else if l > mid then
	    query l r rtree
	  else
	    let ldata = query l mid ltree in
	    let rdata = query (mid+1) r rtree in
	      merge ldata rdata

(* submit debug.. *)
let () =
  if n = 150000 && m = 300000 && c = 209 then
    print_endline "hello, world!"

let segtree = make_tree 0 (n-2)

(* submit debug.. *)
let () =
  if n = 150000 && m = 300000 && c = 209 then
    print_endline "hello, world!"

let () =
  List.map (fun (a,b) -> let r = query a b segtree in lmax [r.left; r.right; r.between; r.full]) ab
  |> List.fold_left (+.) 0.
  |> print_float

(* template *)
let ( |> ) x f = f x
let ( <| ) f x = f x

let di x = prerr_endline (string_of_int x); x
let df x = prerr_endline (string_of_float x); x

let separated_input_list = ref []
let buffer_line () = separated_input_list := (read_line () |> Str.split (Str.regexp "\ "))
let int_list () = !separated_input_list |> List.map int_of_string
let int () = match !separated_input_list with [] -> assert false | hd :: tl -> separated_input_list := tl; int_of_string hd

(* utiliry functions *)
let rec repeat n f x = if n = 0 then x else repeat (n-1) f (f x)
let each_cons f lst = List.rev_map2 f (List.tl (List.rev lst)) (List.rev (List.tl lst))
let lmax = List.fold_left max neg_infinity

(* entry point *)

let () = buffer_line ()
let n = int ()
let m = int ()
let c = int ()

(* submit debug.. *)
let () =
  if n = 150000 && m = 300000 && c = 209 then
    print_endline "hello, world!"

let x = buffer_line (); int_list ()

let p = buffer_line (); int_list () |> List.map float_of_int |> List.map (fun x -> x /. 100.)

let ab = List.rev <| repeat m (fun lst -> buffer_line (); let a = int () in let b = int () in (a-1, b-2) :: lst) []

let w =
  let s = each_cons (fun x y -> y-x |> float_of_int) x in
    List.map2 (fun pi si -> si /. 2. -. pi *. float_of_int(c)) p s |> Array.of_list

type data = { left:float; right:float; between:float; full:float; }

type tree =
  | Leaf of data
  | Node of data * int * int * tree * tree

let getdata = function
  | Leaf(data) -> data
  | Node(data,_,_,_,_) -> data

let merge ldata rdata = {
  left  = lmax [ldata.left; ldata.full; (ldata.full +. rdata.left)];
  right = lmax [rdata.right; rdata.full; (rdata.full +. ldata.right)];
  between = lmax [ldata.between; rdata.between; ldata.right; rdata.left; (ldata.right +. rdata.left)];
  full = ldata.full +. rdata.full;
}

let rec make_tree l r =
  if l = r then
    Leaf({ left = 0.; right = 0.; between = 0.; full = w.(l); })
  else
    let mid = (l+r) / 2 in
    let ltree = make_tree l mid in
    let rtree = make_tree (mid+1) r in
    let ldata = getdata ltree in
    let rdata = getdata rtree in
      Node(merge ldata rdata, l, r, ltree, rtree)

let rec query l r = function
  |Leaf(data) ->
     data
  | Node(data, start, finish, ltree, rtree) ->
      if l = start && r = finish then
	data
      else
	let mid = (start+finish)/2 in
	  if r <= mid then
	    query l r ltree
	  else if l > mid then
	    query l r rtree
	  else
	    let ldata = query l mid ltree in
	    let rdata = query (mid+1) r rtree in
	      merge ldata rdata

(* submit debug.. *)
let () =
  if n = 150000 && m = 300000 && c = 209 then
    print_endline "hello, world!"

let segtree = make_tree 0 (n-2)

(* submit debug.. *)
let () =
  if n = 150000 && m = 300000 && c = 209 then
    print_endline "hello, world!"

let () =
  List.map (fun (a,b) -> let r = query a b segtree in lmax [r.left; r.right; r.between; r.full]) ab
  |> List.fold_left (+.) 0.
  |> print_float

let ( |> ) x f = f x

let ( <| ) f x = f x

let rec repeat n f x = if n = 0 then x else repeat (n-1) f (f x)

let df x = prerr_endline (string_of_float x); x

let separated_input_list = ref []
let buffer_line () =
  separated_input_list := (read_line () |> Str.split (Str.regexp "\ "))
let get_int_list () =
  !separated_input_list
    |> List.map int_of_string
let get_next_int () =
  match !separated_input_list with
    | [] -> assert false
    | hd :: tl -> separated_input_list := tl; int_of_string hd

let each_cons f lst =
  List.rev_map2 f (List.tl (List.rev lst)) (List.rev (List.tl lst))

let () = buffer_line ()
let n = get_next_int ()
let m = get_next_int ()
let c = get_next_int ()

let x = buffer_line (); get_int_list ()

let p =
  (buffer_line (); get_int_list ())
  |> List.map float_of_int
  |> List.map (fun x -> x /. 100.)

let ab =
  List.rev
  <| repeat m
      (fun lst ->
	 let () = buffer_line () in
	 let a = get_next_int () in
	 let b = get_next_int () in
	   (a-1, b-2) :: lst)
      []

let w =
  let s = each_cons (fun x y -> y-x |> float_of_int) x in
    List.map2
      (fun pi si -> si /. 2. -. pi *. float_of_int(c))
      p
      s
  |> Array.of_list

let () = prerr_endline "w="
let () = Array.iter (fun x -> prerr_float x; prerr_string ", ") w
let () = prerr_newline ()
let () = prerr_newline ()

type gao = {
  left:float;
  right:float;
  between:float;
  full:float;
}

type tree =
  | Leaf of gao
  | Node of gao * int * int * tree * tree

let getgao = function
  | Leaf(gao) -> gao
  | Node(gao,_,_,_,_) -> gao

let lmax = List.fold_left max neg_infinity

let rec make_tree l r =
  if l = r then
    Leaf({
	   left = 0.;
	   right = 0.;
	   between = 0.;
	   full = w.(l);
	 })
  else
    let mid = (l+r) / 2 in
    let lnode = make_tree l mid in
    let rnode = make_tree (mid+1) r in
    let ldata = getgao lnode in
    let rdata = getgao rnode in
      Node({
	     left  = lmax [ldata.left; ldata.full; (ldata.full +. rdata.left)];
	     right = lmax [rdata.right; rdata.full; (rdata.full +. ldata.right)];
	     between = lmax [ldata.between; rdata.between; ldata.right; rdata.left; (ldata.right +. rdata.left)];
	     full = ldata.full +. rdata.full;
	   },
	   l,
	   r,
	   lnode,
	   rnode)

let rec query l r tree =
  match tree with
      Leaf(data) ->
	data
    | Node(data, start, finish, ltree, rtree) ->
	if l = start && r = finish then
	  data
	else
	  let mid = (start+finish)/2 in
	    if r <= mid then
	      query l r ltree
	    else if l > mid then
	      query l r rtree
	    else
	      let ldata = query l mid ltree in
	      let rdata = query (mid+1) r rtree in
		{
		  left  = lmax [ldata.left; ldata.full; (ldata.full +. rdata.left)];
		  right = lmax [rdata.right; rdata.full; (rdata.full +. ldata.right)];
		  between = lmax [ldata.between; rdata.between; ldata.right; rdata.left; (ldata.right +. rdata.left)];
		  full = ldata.full +. rdata.full;
		}

let segtree = make_tree 0 (n-2)

let () =
  List.map (fun (a,b) -> let r = query a b segtree in df(lmax [r.left; r.right; r.between; r.full])) ab
  |> List.fold_left (+.) 0.
  |> print_float

(* template *)
module Std = struct
  let ( |> ) x f = f x
  let ( <| ) f x = f x

  let di x = prerr_endline (string_of_int x); x
  let df x = prerr_endline (string_of_float x); x

  let rec repeat n f x = if n = 0 then x else repeat (n-1) f (f x)
  let rec int () = Scanf.scanf "%d%c" (fun x _ -> x)
  let rec float () = Scanf.scanf "%f%c" (fun x _ -> x)
  let rec n_int n () = List.rev <| repeat n (fun lst -> int () :: lst) []
  let rec n_float n () = List.rev <| repeat n (fun lst -> float () :: lst) []

  module List = struct
    include List
    let map f lst = List.rev <| List.rev_map f lst
    let map2 f l1 l2 = List.rev <| List.rev_map2 f l1 l2
  end
end

open Std

(* utiliry functions *)
let each_cons f lst = List.rev_map2 f (List.tl (List.rev lst)) (List.rev (List.tl lst))
let lmax = List.fold_left max neg_infinity

(* entry point *)

let n = int ()
let m = int ()
let c = int ()

(* submit debug.. *)
let () =
  if n = 150000 && m = 300000 && c = 209 then
    print_endline "hello, world!"

let x = n_int n ()

(* submit debug.. *)
let () =
  if n = 150000 && m = 300000 && c = 209 then
      print_endline "hello, world!"

let pp = n_float (n-1) ()

(* submit debug.. *)
let () =
  if n = 150000 && m = 300000 && c = 209 then
      print_endline "hello, world!"

(*let ppp = pp |> List.map float_of_int *)

(* submit debug.. *)
let () =
  if n = 150000 && m = 300000 && c = 209 then
      print_endline "hello, world!"

let p = pp |> List.map (fun x -> x *. 0.01)

(* submit debug.. *)
let () =
  if n = 150000 && m = 300000 && c = 209 then
    print_endline "hello, world!"

let ab = List.rev <| repeat m (fun lst -> let a = int () in let b = int () in (a-1, b-2) :: lst) []

(* submit debug.. *)
let () =
  if n = 150000 && m = 300000 && c = 209 then
    print_endline "hello, world!"

let w =
  let s = each_cons (fun x y -> y-x |> float_of_int) x in
    List.map2 (fun pi si -> si /. 2. -. pi *. float_of_int(c)) p s |> Array.of_list

type data = { left:float; right:float; between:float; full:float; }

type tree =
  | Leaf of data
  | Node of data * int * int * tree * tree

let getdata = function
  | Leaf(data) -> data
  | Node(data,_,_,_,_) -> data

let merge ldata rdata = {
  left  = lmax [ldata.left; ldata.full; (ldata.full +. rdata.left)];
  right = lmax [rdata.right; rdata.full; (rdata.full +. ldata.right)];
  between = lmax [ldata.between; rdata.between; ldata.right; rdata.left; (ldata.right +. rdata.left)];
  full = ldata.full +. rdata.full;
}

let rec make_tree l r =
  if l = r then
    Leaf({ left = 0.; right = 0.; between = 0.; full = w.(l); })
  else
    let mid = (l+r) / 2 in
    let ltree = make_tree l mid in
    let rtree = make_tree (mid+1) r in
    let ldata = getdata ltree in
    let rdata = getdata rtree in
      Node(merge ldata rdata, l, r, ltree, rtree)

let rec query l r = function
  |Leaf(data) ->
     data
  | Node(data, start, finish, ltree, rtree) ->
      if l = start && r = finish then
	data
      else
	let mid = (start+finish)/2 in
	  if r <= mid then
	    query l r ltree
	  else if l > mid then
	    query l r rtree
	  else
	    let ldata = query l mid ltree in
	    let rdata = query (mid+1) r rtree in
	      merge ldata rdata

(* submit debug.. *)
let () =
  if n = 150000 && m = 300000 && c = 209 then
    print_endline "hello, world!"

let segtree = make_tree 0 (n-2)

(* submit debug.. *)
let () =
  if n = 150000 && m = 300000 && c = 209 then
    print_endline "hello, world!"

let () =
  List.map (fun (a,b) -> let r = query a b segtree in lmax [r.left; r.right; r.between; r.full]) ab
  |> List.fold_left (+.) 0.
  |> print_float

(* template *)
let ( |> ) x f = f x
let ( <| ) f x = f x

let di x = prerr_endline (string_of_int x); x
let df x = prerr_endline (string_of_float x); x

let separated_input_list = ref []
let buffer_line () = separated_input_list := (read_line () |> Str.split (Str.regexp "\ "))
let int_list () = !separated_input_list |> List.map int_of_string
let int () = match !separated_input_list with [] -> assert false | hd :: tl -> separated_input_list := tl; int_of_string hd

(* utiliry functions *)
let rec repeat n f x = if n = 0 then x else repeat (n-1) f (f x)
let each_cons f lst = List.rev_map2 f (List.tl (List.rev lst)) (List.rev (List.tl lst))
let lmax = List.fold_left max neg_infinity

(* entry point *)

let () = buffer_line ()
let n = int ()
let m = int ()
let c = int ()

(* submit debug.. *)
let () =
  if n = 150000 && m = 300000 && c = 209 then
    print_endline "hello, world!"

let x = buffer_line (); int_list ()

let p = buffer_line (); int_list () |> List.map float_of_int |> List.map (fun x -> x /. 100.)

let ab = List.rev <| repeat m (fun lst -> buffer_line (); let a = int () in let b = int () in (a-1, b-2) :: lst) []

let w =
  let s = each_cons (fun x y -> y-x |> float_of_int) x in
    List.map2 (fun pi si -> si /. 2. -. pi *. float_of_int(c)) p s |> Array.of_list

type data = { left:float; right:float; between:float; full:float; }

type tree =
  | Leaf of data
  | Node of data * int * int * tree * tree

let getdata = function
  | Leaf(data) -> data
  | Node(data,_,_,_,_) -> data

let merge ldata rdata = {
  left  = lmax [ldata.left; ldata.full; (ldata.full +. rdata.left)];
  right = lmax [rdata.right; rdata.full; (rdata.full +. ldata.right)];
  between = lmax [ldata.between; rdata.between; ldata.right; rdata.left; (ldata.right +. rdata.left)];
  full = ldata.full +. rdata.full;
}

let rec make_tree l r =
  if l = r then
    Leaf({ left = 0.; right = 0.; between = 0.; full = w.(l); })
  else
    let mid = (l+r) / 2 in
    let ltree = make_tree l mid in
    let rtree = make_tree (mid+1) r in
    let ldata = getdata ltree in
    let rdata = getdata rtree in
      Node(merge ldata rdata, l, r, ltree, rtree)

let rec query l r = function
  |Leaf(data) ->
     data
  | Node(data, start, finish, ltree, rtree) ->
      if l = start && r = finish then
	data
      else
	let mid = (start+finish)/2 in
	  if r <= mid then
	    query l r ltree
	  else if l > mid then
	    query l r rtree
	  else
	    let ldata = query l mid ltree in
	    let rdata = query (mid+1) r rtree in
	      merge ldata rdata

(* submit debug.. *)
let () =
(*  if n = 150000 && m = 300000 && c = 209 then *)
    print_endline "hello, world!"

let segtree = make_tree 0 (n-2)

(* submit debug.. *)
let () =
  if n = 150000 && m = 300000 && c = 209 then
    print_endline "hello, world!"

let () =
  List.map (fun (a,b) -> let r = query a b segtree in lmax [r.left; r.right; r.between; r.full]) ab
  |> List.fold_left (+.) 0.
  |> print_float

(* template *)
let ( |> ) x f = f x
let ( <| ) f x = f x

let di x = prerr_endline (string_of_int x); x
let df x = prerr_endline (string_of_float x); x

(*
let separated_input_list = ref []
let buffer_line () = separated_input_list := (read_line () |> Str.split (Str.regexp "\ "))
let int_list () = !separated_input_list |> List.map int_of_string
let int () = match !separated_input_list with [] -> assert false | hd :: tl -> separated_input_list := tl; int_of_string hd
*)

let digit c = c >= '0' && c <= '9'
let feed c = c = '\r' || c = '\n'
let whitespace c = c = ' ' || c = '\t' || feed c

let rec int' flg x =
  let c = input_char stdin in
    if digit c then
      int' true (x*10+int_of_char(c)-48)
    else if whitespace c then
      if flg then
	(x, feed c)
      else
	int' false 0
    else failwith "getInt"

let int () = fst (int' false 0)

let int_list () =
  let rec int_list' () =
    let (x, flg) = int' false 0 in
      if flg then
	[x]
      else
	x :: int_list' ()
  in
    int_list' ()

(* utiliry functions *)
let rec repeat n f x = if n = 0 then x else repeat (n-1) f (f x)
let each_cons f lst = List.rev_map2 f (List.tl (List.rev lst)) (List.rev (List.tl lst))
let lmax = List.fold_left max neg_infinity

(* entry point *)

let n = int ()
let m = int ()
let c = int ()

(* submit debug.. *)
let () =
  if n = 150000 && m = 300000 && c = 209 then
    print_endline "hello, world!"

let x = int_list ()

(* submit debug.. *)
let () =
  if n = 150000 && m = 300000 && c = 209 then
    begin
      print_endline (string_of_int (List.length x));
      print_endline "hello, world!"
    end

let p = int_list () |> List.map float_of_int |> List.map (fun x -> x /. 100.)

(* submit debug.. *)
let () =
  if n = 150000 && m = 300000 && c = 209 then
    print_endline "hello, world!"

let ab = List.rev <| repeat m (fun lst -> let a = int () in let b = int () in (a-1, b-2) :: lst) []

(* submit debug.. *)
let () =
  if n = 150000 && m = 300000 && c = 209 then
    print_endline "hello, world!"

let w =
  let s = each_cons (fun x y -> y-x |> float_of_int) x in
    List.map2 (fun pi si -> si /. 2. -. pi *. float_of_int(c)) p s |> Array.of_list

type data = { left:float; right:float; between:float; full:float; }

type tree =
  | Leaf of data
  | Node of data * int * int * tree * tree

let getdata = function
  | Leaf(data) -> data
  | Node(data,_,_,_,_) -> data

let merge ldata rdata = {
  left  = lmax [ldata.left; ldata.full; (ldata.full +. rdata.left)];
  right = lmax [rdata.right; rdata.full; (rdata.full +. ldata.right)];
  between = lmax [ldata.between; rdata.between; ldata.right; rdata.left; (ldata.right +. rdata.left)];
  full = ldata.full +. rdata.full;
}

let rec make_tree l r =
  if l = r then
    Leaf({ left = 0.; right = 0.; between = 0.; full = w.(l); })
  else
    let mid = (l+r) / 2 in
    let ltree = make_tree l mid in
    let rtree = make_tree (mid+1) r in
    let ldata = getdata ltree in
    let rdata = getdata rtree in
      Node(merge ldata rdata, l, r, ltree, rtree)

let rec query l r = function
  |Leaf(data) ->
     data
  | Node(data, start, finish, ltree, rtree) ->
      if l = start && r = finish then
	data
      else
	let mid = (start+finish)/2 in
	  if r <= mid then
	    query l r ltree
	  else if l > mid then
	    query l r rtree
	  else
	    let ldata = query l mid ltree in
	    let rdata = query (mid+1) r rtree in
	      merge ldata rdata

(* submit debug.. *)
let () =
  if n = 150000 && m = 300000 && c = 209 then
    print_endline "hello, world!"

let segtree = make_tree 0 (n-2)

(* submit debug.. *)
let () =
  if n = 150000 && m = 300000 && c = 209 then
    print_endline "hello, world!"

let () =
  List.map (fun (a,b) -> let r = query a b segtree in lmax [r.left; r.right; r.between; r.full]) ab
  |> List.fold_left (+.) 0.
  |> print_float

(* template *)
module Std = struct
  let ( |> ) x f = f x
  let ( <| ) f x = f x

  let di x = prerr_endline (string_of_int x); x
  let df x = prerr_endline (string_of_float x); x

  let rec repeat n f x = if n = 0 then x else repeat (n-1) f (f x)
  let rec int () = Scanf.scanf "%d%c" (fun x _ -> x)
  let rec float () = Scanf.scanf "%f%c" (fun x _ -> x)
  let rec n_int n () = List.rev <| repeat n (fun lst -> int () :: lst) []
  let rec n_float n () = List.rev <| repeat n (fun lst -> float () :: lst) []
end

open Std

(* utiliry functions *)
let each_cons f lst = List.rev_map2 f (List.tl (List.rev lst)) (List.rev (List.tl lst))
let lmax = List.fold_left max neg_infinity

(* entry point *)

let n = int ()
let m = int ()
let c = int ()

(* submit debug.. *)
let () =
  if n = 150000 && m = 300000 && c = 209 then
    print_endline "hello, world!"

let x = n_int n ()

(* submit debug.. *)
let () =
  if n = 150000 && m = 300000 && c = 209 then
      print_endline "hello, world!"

let pp = n_float (n-1) ()

(* submit debug.. *)
let () =
  if n = 150000 && m = 300000 && c = 209 then
      print_endline "hello, world!"

(*let ppp = pp |> List.map float_of_int *)

(* submit debug.. *)
let () =
  if n = 150000 && m = 300000 && c = 209 then
      print_endline "hello, world!"

let p = pp |> List.map (fun x -> x *. 0.01)

(* submit debug.. *)
let () =
  if n = 150000 && m = 300000 && c = 209 then
    print_endline "hello, world!"

let ab = List.rev <| repeat m (fun lst -> let a = int () in let b = int () in (a-1, b-2) :: lst) []

(* submit debug.. *)
let () =
  if n = 150000 && m = 300000 && c = 209 then
    print_endline "hello, world!"

let w =
  let s = each_cons (fun x y -> y-x |> float_of_int) x in
    List.map2 (fun pi si -> si /. 2. -. pi *. float_of_int(c)) p s |> Array.of_list

type data = { left:float; right:float; between:float; full:float; }

type tree =
  | Leaf of data
  | Node of data * int * int * tree * tree

let getdata = function
  | Leaf(data) -> data
  | Node(data,_,_,_,_) -> data

let merge ldata rdata = {
  left  = lmax [ldata.left; ldata.full; (ldata.full +. rdata.left)];
  right = lmax [rdata.right; rdata.full; (rdata.full +. ldata.right)];
  between = lmax [ldata.between; rdata.between; ldata.right; rdata.left; (ldata.right +. rdata.left)];
  full = ldata.full +. rdata.full;
}

let rec make_tree l r =
  if l = r then
    Leaf({ left = 0.; right = 0.; between = 0.; full = w.(l); })
  else
    let mid = (l+r) / 2 in
    let ltree = make_tree l mid in
    let rtree = make_tree (mid+1) r in
    let ldata = getdata ltree in
    let rdata = getdata rtree in
      Node(merge ldata rdata, l, r, ltree, rtree)

let rec query l r = function
  |Leaf(data) ->
     data
  | Node(data, start, finish, ltree, rtree) ->
      if l = start && r = finish then
	data
      else
	let mid = (start+finish)/2 in
	  if r <= mid then
	    query l r ltree
	  else if l > mid then
	    query l r rtree
	  else
	    let ldata = query l mid ltree in
	    let rdata = query (mid+1) r rtree in
	      merge ldata rdata

(* submit debug.. *)
let () =
  if n = 150000 && m = 300000 && c = 209 then
    print_endline "hello, world!"

let segtree = make_tree 0 (n-2)

(* submit debug.. *)
let () =
  if n = 150000 && m = 300000 && c = 209 then
    print_endline "hello, world!"

let () =
  List.map (fun (a,b) -> let r = query a b segtree in lmax [r.left; r.right; r.between; r.full]) ab
  |> List.fold_left (+.) 0.
  |> print_float

(* template *)
let ( |> ) x f = f x
let ( <| ) f x = f x

let di x = prerr_endline (string_of_int x); x
let df x = prerr_endline (string_of_float x); x

let separated_input_list = ref []
let buffer_line () = separated_input_list := (read_line () |> Str.split (Str.regexp "\ "))
let int_list () = !separated_input_list |> List.map int_of_string
let int () = match !separated_input_list with [] -> assert false | hd :: tl -> separated_input_list := tl; int_of_string hd

(* utiliry functions *)
let rec repeat n f x = if n = 0 then x else repeat (n-1) f (f x)
let each_cons f lst = List.rev_map2 f (List.tl (List.rev lst)) (List.rev (List.tl lst))
let lmax = List.fold_left max neg_infinity

(* entry point *)

let () = buffer_line ()
let n = int ()
let m = int ()
let c = int ()

(* submit debug.. *)
let () =
  if n = 150000 && m = 300000 && c = 209 then
    print_endline "hello, world!"

let x = buffer_line (); int_list ()

(* submit debug.. *)
let () =
  if n = 150000 && m = 300000 && c = 209 then
    print_endline "hello, world!"

let p = buffer_line (); int_list () |> List.map float_of_int |> List.map (fun x -> x /. 100.)

(* submit debug.. *)
let () =
  if n = 150000 && m = 300000 && c = 209 then
    print_endline "hello, world!"

let ab = List.rev <| repeat m (fun lst -> buffer_line (); let a = int () in let b = int () in (a-1, b-2) :: lst) []

(* submit debug.. *)
let () =
  if n = 150000 && m = 300000 && c = 209 then
    print_endline "hello, world!"

let w =
  let s = each_cons (fun x y -> y-x |> float_of_int) x in
    List.map2 (fun pi si -> si /. 2. -. pi *. float_of_int(c)) p s |> Array.of_list

type data = { left:float; right:float; between:float; full:float; }

type tree =
  | Leaf of data
  | Node of data * int * int * tree * tree

let getdata = function
  | Leaf(data) -> data
  | Node(data,_,_,_,_) -> data

let merge ldata rdata = {
  left  = lmax [ldata.left; ldata.full; (ldata.full +. rdata.left)];
  right = lmax [rdata.right; rdata.full; (rdata.full +. ldata.right)];
  between = lmax [ldata.between; rdata.between; ldata.right; rdata.left; (ldata.right +. rdata.left)];
  full = ldata.full +. rdata.full;
}

let rec make_tree l r =
  if l = r then
    Leaf({ left = 0.; right = 0.; between = 0.; full = w.(l); })
  else
    let mid = (l+r) / 2 in
    let ltree = make_tree l mid in
    let rtree = make_tree (mid+1) r in
    let ldata = getdata ltree in
    let rdata = getdata rtree in
      Node(merge ldata rdata, l, r, ltree, rtree)

let rec query l r = function
  |Leaf(data) ->
     data
  | Node(data, start, finish, ltree, rtree) ->
      if l = start && r = finish then
	data
      else
	let mid = (start+finish)/2 in
	  if r <= mid then
	    query l r ltree
	  else if l > mid then
	    query l r rtree
	  else
	    let ldata = query l mid ltree in
	    let rdata = query (mid+1) r rtree in
	      merge ldata rdata

(* submit debug.. *)
let () =
  if n = 150000 && m = 300000 && c = 209 then
    print_endline "hello, world!"

let segtree = make_tree 0 (n-2)

(* submit debug.. *)
let () =
  if n = 150000 && m = 300000 && c = 209 then
    print_endline "hello, world!"

let () =
  List.map (fun (a,b) -> let r = query a b segtree in lmax [r.left; r.right; r.between; r.full]) ab
  |> List.fold_left (+.) 0.
  |> print_float

(* template *)
let ( |> ) x f = f x
let ( <| ) f x = f x

let di x = prerr_endline (string_of_int x); x
let df x = prerr_endline (string_of_float x); x

let separated_input_list = ref []
let buffer_line () = separated_input_list := (read_line () |> Str.split (Str.regexp "\ "))
let int_list () = !separated_input_list |> List.map int_of_string
let int () = match !separated_input_list with [] -> assert false | hd :: tl -> separated_input_list := tl; int_of_string hd

(* utiliry functions *)
let rec repeat n f x = if n = 0 then x else repeat (n-1) f (f x)
let each_cons f lst = List.rev_map2 f (List.tl (List.rev lst)) (List.rev (List.tl lst))
let lmax = List.fold_left max neg_infinity

(* entry point *)

let () = buffer_line ()
let n = int ()
let m = int ()
let c = int ()

let x = buffer_line (); int_list ()

let p = buffer_line (); int_list () |> List.map float_of_int |> List.map (fun x -> x /. 100.)

let ab = List.rev <| repeat m (fun lst -> buffer_line (); let a = int () in let b = int () in (a-1, b-2) :: lst) []

let w =
  let s = each_cons (fun x y -> y-x |> float_of_int) x in
    List.map2 (fun pi si -> si /. 2. -. pi *. float_of_int(c)) p s |> Array.of_list

type data = { left:float; right:float; between:float; full:float; }

type tree =
  | Leaf of data
  | Node of data * int * int * tree * tree

let getdata = function
  | Leaf(data) -> data
  | Node(data,_,_,_,_) -> data

let merge ldata rdata = {
  left  = lmax [ldata.left; ldata.full; (ldata.full +. rdata.left)];
  right = lmax [rdata.right; rdata.full; (rdata.full +. ldata.right)];
  between = lmax [ldata.between; rdata.between; ldata.right; rdata.left; (ldata.right +. rdata.left)];
  full = ldata.full +. rdata.full;
}

let rec make_tree l r =
  if l = r then
    Leaf({ left = 0.; right = 0.; between = 0.; full = w.(l); })
  else
    let mid = (l+r) / 2 in
    let ltree = make_tree l mid in
    let rtree = make_tree (mid+1) r in
    let ldata = getdata ltree in
    let rdata = getdata rtree in
      Node(merge ldata rdata, l, r, ltree, rtree)

let rec query l r tree =
  match tree with
      Leaf(data) ->
	data
    | Node(data, start, finish, ltree, rtree) ->
	if l = start && r = finish then
	  data
	else
	  let mid = (start+finish)/2 in
	    if r <= mid then
	      query l r ltree
	    else if l > mid then
	      query l r rtree
	    else
	      let ldata = query l mid ltree in
	      let rdata = query (mid+1) r rtree in
		merge ldata rdata

let segtree = make_tree 0 (n-2)

let () =
  List.map (fun (a,b) -> let r = query a b segtree in lmax [r.left; r.right; r.between; r.full]) ab
  |> List.fold_left (+.) 0.
  |> print_float


open Array;;

let (|>) x f = f x

let calc t1 t2 k  = fun (a, b, i) ->
        let a = float a in
        let b = float b in
        let f a b = a *. t1 *. (1.0 -. k) +. b *. t2 in
                ( max (f a b) (f b a) , i)
(* (res, i) *)

let cmp' x =
        if x > 0.0
        then -1
        else if x < 0.0 then 1
        else 0

let cmp = fun (a, c) -> fun (b, d) ->
        if a = b
        then c - d
        else cmp' (a -. b)
let print a =
        Printf.printf "%d " (snd a + 1);
        (fst a)|> Printf.printf "%.2f\n"

let main _ =
        let f i = Scanf.scanf "%d %d\n" (fun a -> fun b -> a, b, i) in
        let n, t1, t2, k = Scanf.scanf "%d %d %d %d\n"
         (fun m -> fun p->fun k->fun l
         -> m,p,k,l) in
          let a =  init n f  |> map (calc (float t1) (float t2) ((float k)/. 100.0) ) in
                fast_sort cmp a;
                iter print a;;

main ();;

let ni () = Scanf.scanf " %d" (fun x -> x) in
let nf () = float_of_int (ni ()) in
let n = ni () in
let t1 = nf () in
let t2 = nf () in
let k = 1.0 -. nf () /. 100.0 in
let f a b = a *. t1 *. k +. b *. t2 in
let a = Array.init n (fun i ->
  let a, b = nf (), nf () in
  (-1. *. max (f a b) (f b a), i + 1)
) in
Array.sort compare a;
Array.iter (fun (e, i) ->
  Printf.printf "%d %.2f\n" i ~-.e
) a;;

open Array;;

 let (|>) x f = f x

let calc t1 t2 k  = fun (a, b, i) ->
        let a = float a in
        let b = float b in
        let f a b = a *. t1 *. (1.0 -. k) +. b *. t2 in
                ( max (f a b) (f b a) , i)
(* (res, i) *)

let cmp' x =
        if x > 0.0
        then -1
        else if x < 0.0 then 1
        else 0

let cmp = fun (a, c) -> fun (b, d) ->
        if a = b
        then d - c
        else cmp' (a -. b)
let print a =
        Printf.printf "%d " (snd a + 1);
        (fst a)|> Printf.printf "%.2f\n"

let main _ =
        let f i = Scanf.scanf "%d %d\n" (fun a -> fun b -> a, b, i) in
        let n, t1, t2, k = Scanf.scanf "%d %d %d %d\n"
         (fun m -> fun p->fun k->fun l
         -> m,p,k,l) in
          let a =  init n f  |> map (calc (float t1) (float t2) ((float k)/. 100.0) ) in
                fast_sort cmp a;
                iter print a;;

main ();;


open Printf
open Scanf

let read_int _ = bscanf Scanning.stdib " %d " (fun x -> x)
let () =
  let n = read_int () in
  let a = Array.init n read_int in

  Array.sort compare a;

  let rec run_length prev count best i = if i=n then best else (
    if a.(i) = prev then (
      let count = count + 1 in
      let best = max best count in
      run_length prev count best (i+1)
    ) else (
      run_length a.(i) 1 best (i+1)
    )
  ) in

  printf "%d\n" (run_length a.(0) 1 1 1)

let input () =
  let getNumber () = Scanf.bscanf Scanf.Scanning.stdin " %d" (fun x -> x)
  in let n = getNumber ()
  in let a = Array.make n (max_int, false)
  in begin
    for i = 0 to n - 1 do
      a.(i) <- (getNumber (), false)
    done;
    a
  end

let bSearch i a =
  let n = Array.length a
  in let l = ref (i + 1)
  in let r = ref (n - 1)
  in let m = ref 0
  in let found = ref false
  in begin
    while l <= r do
      m := (!l + !r) / 2;
      if fst a.(!m) > fst a.(i) && snd a.(!m) = false then
        if fst a.(!m - 1) = fst a.(i) || snd a.(!m - 1) = true then
          (r := !l - 1;
           found := true)
        else
          r := !m - 1
      else
        l := !m + 1
    done;
    if !found then Some !m
    else None
  end

let eat a =
  let n = Array.length a
  in let count = ref n
  in begin
    for i = 0 to n - 1 do
      match bSearch i a with
      | Some x -> begin
          count := !count - 1;
          a.(x) <- (fst a.(x), true)
        end
      | None -> ()
    done;
    !count
  end

let main () =
  let a = input ()
  in let cmp (x, _) (y, _) = compare x y
  in begin
    Array.sort cmp a;
    Printf.printf "%d" (eat a)
  end
;;

main ();;

let input () =
  let getNumber () = Scanf.bscanf Scanf.Scanning.stdin " %d" (fun x -> x)
  in let n = getNumber ()
  in let a = Array.make n (max_int, false)
  in begin
    for i = 0 to n - 1 do
      a.(i) <- (getNumber (), false)
    done;
    a
  end

let bSearch i a =
  let n = Array.length a
  in let l = ref (i + 1)
  in let r = ref (n - 1)
  in let m = ref 0
  in let found = ref false
  in begin
    while l <= r do
      m := (!l + !r) / 2;
      if fst a.(!m) > fst a.(i) && snd a.(!m) = false then
        if fst a.(!m - 1) = fst a.(i) || snd a.(!m - 1) = true then
          (r := !l - 1;
           found := true)
        else
          r := !m - 1
      else
        l := !m + 1
    done;
    if !found then Some !m
    else None
  end

let eat a =
  let n = Array.length a
  in let count = ref n
  in begin
    for i = 0 to n - 1 do
      match bSearch i a with
      | Some x -> begin
          count := !count - 1;
          a.(x) <- (fst a.(x), true)
        end
      | None -> ()
    done;
    !count
  end

let main () =
  let a = input ()
  in let cmp (x, _) (y, _) = compare x y
  in begin
    Array.sort cmp a;
    eat a
  end
;;

main ();;


open Printf
open String
open Int64

let n = Scanf.scanf "%d " (fun x -> x);;

let e = Array.make n Int64.zero (*energy for reverse string*)
let s = Array.make n "" (*stores all the strings to be sorted*)
let rs = Array.make n ""

let d1 = Array.make n (Int64.max_int) (*flip*)

let d2 = Array.make n (Int64.max_int)

for i = 0 to n-1 do
  let jj = Scanf.bscanf Scanf.Scanning.stdin "%Ld " (fun x -> x) in
  e.(i) <- jj
done

let rev s =
  let len = String.length s in
  let rec rev_helper i s2 =
    if i >= len then s2
    else
      rev_helper (i+1) s2^(Char.escaped s.[i])
  in
  rev_helper 0 ""

for i = 0 to n - 1 do
  let jj = Scanf.bscanf Scanf.Scanning.stdin "%s " (fun x -> x) in
  s.(i) <- jj; rs.(i) <- (rev jj)
done

let () = d1.(0) <- of_int 0;;
let () = d2.(0) <- e.(0);;

(*printf "%Ld" max_int;;
*)

(*DEBUG*)
(*
 let () = print_endline (rev "abc")

for i = 0 to n - 1 do
  print_endline s.(i);
  print_endline rs.(i)
done
*)

let g s1 s2 =
  let x = String.compare s1 s2 in
  if (x<=0) then of_int 0
  else max_int

let f s1 s2 n =
  let x = String.compare s1 s2 in
  if (x<=0) then e.(n)
  else max_int

let my_add a b =
  if ( (compare a max_int == 0 ) || (compare b max_int == 0 ) ) then max_int
  else add a b

let () =
  for i = 1 to n - 1 do
    let x1 = my_add d1.(i-1)  (g s.(i-1) s.(i) ) in
    let x2 = my_add d2.(i-1) (g rs.(i-1) s.(i) ) in
    d1.(i) <- min x1 x2;
   let y1 = my_add d1.(i-1) (f s.(i-1) rs.(i) i ) in
   let y2 = my_add d2.(i-1)  (f rs.(i-1) rs.(i) i ) in
   d2.(i) <- min y1 y2
done

let () =
  let x = min d1.(n-1) d2.(n-1) in
  if (x==max_int) then printf "%d\n" (-1)
  else print_endline (to_string x)

open Printf
open Scanf

let reverse s =
  let n = String.length s in
  String.init n (fun i -> s.[n-i-1])

let ( ** ) a b = Int64.mul a b
let ( ++ ) a b = Int64.add a b
let ( -- ) a b = Int64.sub a b
let ( // ) a b = Int64.div a b
let ( %% ) a b = Int64.rem a b

let long x = Int64.of_int x
let short x = Int64.to_int x

let read_int () = bscanf Scanning.stdib " %d " (fun x -> x)
let read_string () = bscanf Scanning.stdib " %s " (fun x -> x)
let () =
  let n = read_int () in
  let c = Array.init n (fun _ -> long (read_int())) in
  let s = Array.init n (fun _ -> read_string ()) in
  let sr = Array.init n (fun i -> reverse s.(i)) in

  let nr_cost = Array.make n 0L in
  let r_cost = Array.make n 0L in

  nr_cost.(n-1) <- 0L;
  r_cost.(n-1) <- c.(n-1);

  let inf = (Int64.max_int) // 4L in

  for i=n-2 downto 0 do
    let test a b = if a > b then inf else 0L in
    nr_cost.(i) <- min
      (nr_cost.(i+1) ++ (test s.(i) s.(i+1)))
      (r_cost.(i+1) ++ (test s.(i) sr.(i+1)));
    r_cost.(i) <- c.(i) ++ min
      (nr_cost.(i+1) ++ (test sr.(i) s.(i+1)))
      (r_cost.(i+1) ++ (test sr.(i) sr.(i+1)));
    nr_cost.(i) <- min nr_cost.(i) inf;
    r_cost.(i) <- min r_cost.(i) inf;
  done;

  let total = min nr_cost.(0) r_cost.(0) in

  if total = inf then printf "-1\n" else printf "%Ld\n" total

open Printf
open String

let n = Scanf.scanf "%d " (fun x -> x);;

let e = Array.make n (-1) (*energy for reverse string*)
let s = Array.make n "" (*stores all the strings to be sorted*)
let rs = Array.make n ""

let d1 = Array.make n (max_int) (*flip*)

let d2 = Array.make n (max_int)

for i = 0 to n-1 do
  let jj = Scanf.bscanf Scanf.Scanning.stdin "%d " (fun x -> x) in
  e.(i) <- jj
done

let rev s =
  let len = String.length s in
  let rec rev_helper i s2 =
    if i >= len then s2
    else
      rev_helper (i+1) s2^(Char.escaped s.[i])
  in
  rev_helper 0 ""

for i = 0 to n - 1 do
  let jj = Scanf.bscanf Scanf.Scanning.stdin "%s " (fun x -> x) in
  s.(i) <- jj; rs.(i) <- (rev jj)
done

let () = d1.(0) <- 0;;
let () = d2.(0) <- e.(0);;

(*DEBUG*)
(*
 let () = print_endline (rev "abc")

for i = 0 to n - 1 do
  print_endline s.(i);
  print_endline rs.(i)
done
*)

let g s1 s2 =
  let x = String.compare s1 s2 in
  if (x<=0) then 0
  else max_int

let f s1 s2 n =
  let x = String.compare s1 s2 in
  if (x<=0) then e.(n)
  else max_int

let my_add a b =
  if (a==max_int || b==max_int) then max_int
  else a + b

let () =
  for i = 1 to n - 1 do
    let x1 = my_add d1.(i-1)  (g s.(i-1) s.(i) ) in
    let x2 = my_add d2.(i-1) (g rs.(i-1) s.(i) ) in
    d1.(i) <- min x1 x2;
   let y1 = my_add d1.(i-1) (f s.(i-1) rs.(i) i ) in
   let y2 = my_add d2.(i-1)  (f rs.(i-1) rs.(i) i ) in
   d2.(i) <- min y1 y2
done

let () =
  let x = min d1.(n-1) d2.(n-1) in
  if (x==max_int) then
    begin
      print_int (-1); print_endline ""
    end
  else
    begin
      print_int x; print_endline ""
    end


open Str;;
open Array;;
let n = read_int () and ans = ref 0 and price = ref 101;;
for i = 1 to n do
    let ins = map (int_of_string) (of_list (split (regexp " ") (read_line ()))) in
    let a = ins.(0) and b = ins.(1) in
    begin
        price := min !price b;
        ans := !ans + !price * a;
    end;
done;;
print_int !ans;;

let read () = Scanf.scanf "%d " (fun n -> n)

let input () =
    let n = read () in
    let rec loop i list =
        if i < n
        then
            let mass = read () in
            let price = read () in
            loop (i + 1) ((mass, price) :: list)
        else
            List.rev list
    in loop 0 []

let get_min price min =
    if price >= min
    then
        min
    else
        price

let get_sum sum min mass =
    sum + min * mass

let update_sum_min (mass, price) (sum, min) =
    let min_upd = get_min price min in
    let sum_upd = get_sum sum mass min_upd in
    (sum_upd, min_upd)

let solve list =
    let rec loop (sum, min) list =
        match list with
        | (head :: tail) -> loop (update_sum_min head (sum, min)) tail
        | [] -> sum
    in loop (0, 101) list

let print result = Printf.printf "%d\n" result
let () = print (solve (input ()))

let () = Scanf.scanf "%d\n" (fun n ->
			     let a = Array.init n (fun _ ->
						   Scanf.scanf "%d %d\n"
							       (fun a w -> (a, w))) in
			     (* buy as much as we need to hit the next cheapest day *)
			     let rec calc cur acc =
			       if cur >= n then acc
			       else begin
				   let rec loop i s =
				     if i >= n || snd a.(i) < snd a.(cur)
				     then i, s
				     else loop (i + 1) (s + fst a.(i) * snd a.(cur)) in
				   let next, add = loop cur 0 in
				   calc next (acc + add)
				 end
			     in
			     Printf.printf "%d\n" (calc 0 0))

let () = Scanf.scanf "%d\n" (fun n ->
    let a = Array.init n (fun _ -> Scanf.scanf "%d%_c%d%_c" (fun x y -> (x, y))) in

	let sum = ref 0 in

	let min = ref 2000000 in

	let rec loop i =
		if i < n then
		begin
			let (x, y) = a.(i) in
			if !min > y then begin min := y end;
			sum := !sum + x * !min;
			loop (i+1)
		end
	in
	loop 0;
	Printf.printf "%d\n" !sum);;

let () = Scanf.scanf "%d\n" (fun n ->
    let a = Array.init n (fun _ -> Scanf.scanf "%d%_c%d%_c" (fun x y -> (x, y))) in

	let sum = ref 0 in

	let min = ref 2000000 in

	let rec loop i =
		if i < n then
		begin
			let (x, y) = a.(i) in
			if !min > x then begin min := x end;
			sum := !sum + y * !min;
			loop (i+1)
		end
	in
	loop 0;
	Printf.printf "%d\n" !sum);;