I guess there's not much point in reminding you that Nvodsk winters aren't exactly hot. That increased the popularity of the public transport dramatically. The route of bus 62 has exactly n stops (stop 1 goes first on its way and stop n goes last). The stops are positioned on a straight line and their coordinates are 0 = x1 < x2 < ... < xn. Each day exactly m people use bus 62. For each person we know the number of the stop where he gets on the bus and the number of the stop where he gets off the bus. A ticket from stop a to stop b (a < b) costs xb - xa rubles. However, the conductor can choose no more than one segment NOT TO SELL a ticket for. We mean that conductor should choose C and D (С <= D) and sell a ticket for the segments [A, C] and [D, B], or not sell the ticket at all. The conductor and the passenger divide the saved money between themselves equally. The conductor's "untaxed income" is sometimes interrupted by inspections that take place as the bus drives on some segment of the route located between two consecutive stops. The inspector fines the conductor by c rubles for each passenger who doesn't have the ticket for this route's segment.You know the coordinated of all stops xi; the numbers of stops where the i-th passenger gets on and off, ai and bi (ai < bi); the fine c; and also pi — the probability of inspection on segment between the i-th and the i + 1-th stop. The conductor asked you to help him make a plan of selling tickets that maximizes the mathematical expectation of his profit.

The first line contains three integers n, m and c (2 ≤ n ≤ 150 000, 1 ≤ m ≤ 300 000, 1 ≤ c ≤ 10 000). The next line contains n integers xi (0 ≤ xi ≤ 109, x1 = 0, xi < xi + 1) — the coordinates of the stops on the bus's route. The third line contains n - 1 integer pi (0 ≤ pi ≤ 100) — the probability of inspection in percents on the segment between stop i and stop i + 1. Then follow m lines that describe the bus's passengers. Each line contains exactly two integers ai and bi (1 ≤ ai < bi ≤ n) — the numbers of stops where the i-th passenger gets on and off.

Print the single real number — the maximum expectation of the conductor's profit. Your answer will be considered correct if its absolute or relative error does not exceed 10 - 6.  Namely: let's assume that your answer is a, and the answer of the jury is b. The checker program will consider your answer correct, if .

NoteA comment to the first sample:The first and third passengers get tickets from stop 1 to stop 2. The second passenger doesn't get a ticket. There always is inspection on the segment 1-2 but both passengers have the ticket for it. There never is an inspection on the segment 2-3, that's why the second passenger gets away with the cheating. Our total profit is (0 + 90 / 2 + 90 / 2) = 90.

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

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 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

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

(* 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. -. 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


For the given sequence with n different elements find the number of increasing subsequences with k + 1 elements. It is guaranteed that the answer is not greater than 8·1018.

First line contain two integer values n and k (1 ≤ n ≤ 105, 0 ≤ k ≤ 10) — the length of sequence and the number of elements in increasing subsequences. Next n lines contains one integer ai (1 ≤ ai ≤ n) each — elements of sequence. All values ai are different.

Print one integer — the answer to the problem.

let (+|) = Int64.add
let (-|) = Int64.sub
let ( *| ) = Int64.mul
let ( /| ) = Int64.div

let g2d n = n land (-n)

let fenwick_new n =
  Array.make n 0L

let fenwick_modify ft n x =
  let i = ref (n + 1) in
    while !i <= Array.length ft do
      ft.(!i - 1) <- ft.(!i - 1) +| x;
      i := !i + g2d !i;
    done

let fenwick_count ft n =
  let i = ref (n + 1) in
  let res = ref 0L in
    while !i > 0 do
      res := !res +| ft.(!i - 1);
      i := !i - g2d !i;
    done;
    !res

let fenwick_count2 ft m n =
  fenwick_count ft n -| fenwick_count ft (m - 1)

let _ =
  let sb = Scanf.Scanning.stdib in
  let n = Scanf.bscanf sb "%d " (fun s -> s) in
  let k = Scanf.bscanf sb "%d " (fun s -> s) in
  let k = k + 1 in
  let a = Array.make n 0 in
  let b = Array.make n (0, 0) in
    for i = 0 to n - 1 do
      let x = Scanf.bscanf sb "%d " (fun s -> s) in
	a.(i) <- x;
	b.(i) <- (x, i);
    done;
    Array.sort compare b;
    let ft = Array.init (k + 1) (fun _ -> fenwick_new (n + 1)) in
      fenwick_modify ft.(0) 0 1L;
      for i = 0 to n - 1 do
	for j = k downto 1 do
	  let c = fenwick_count ft.(j - 1) (a.(i) - 1) in
	    fenwick_modify ft.(j) a.(i) c
	done
      done;
      let res = fenwick_count ft.(k) n in
	Printf.printf "%Ld\n" res


There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exact number of wins of each team, instead he thought that absolute difference between number of wins of first and second team will be d1 and that of between second and third team will be d2.You don't want any of team win the tournament, that is each team should have the same number of wins after n games. That's why you want to know: does there exist a valid tournament satisfying the friend's guess such that no team will win this tournament?Note that outcome of a match can not be a draw, it has to be either win or loss.

The first line of the input contains a single integer corresponding to number of test cases t (1 ≤ t ≤ 105). Each of the next t lines will contain four space-separated integers n, k, d1, d2 (1 ≤ n ≤ 1012; 0 ≤ k ≤ n; 0 ≤ d1, d2 ≤ k) — data for the current test case.

For each test case, output a single line containing either "yes" if it is possible to have no winner of tournament, or "no" otherwise (without quotes).

NoteSample 1. There has not been any match up to now (k = 0, d1 = 0, d2 = 0). If there will be three matches (1-2, 2-3, 3-1) and each team wins once, then at the end each team will have 1 win.Sample 2. You missed all the games (k = 3). As d1 = 0 and d2 = 0, and there is a way to play three games with no winner of tournament (described in the previous sample), the answer is "yes".Sample 3. You missed 4 matches, and d1 = 1, d2 = 0. These four matches can be: 1-2 (win 2), 1-3 (win 3), 1-2 (win 1), 1-3 (win 1). Currently the first team has 2 wins, the second team has 1 win, the third team has 1 win. Two remaining matches can be: 1-2 (win 2), 1-3 (win 3). In the end all the teams have equal number of wins (2 wins).

module I = Int64 ;;

let (+/) = I.add
let ( */ ) = I.mul
let ( -/ ) = I.sub
let ( // ) = I.div

let check1 n k d1 d2 =
  let d = d1 +/ d1 +/ d2 in
  let c = d1 +/ 2L */ d2 in
  k >= c && Int64.rem (k -/ c) 3L = 0L &&
  n -/ k >= d &&
  I.rem (n -/ k -/ d) 3L = 0L
;;

let check4 n k d1 d2 =
  let d = d1 +/ d2 +/ d2 in
  let c = d1 +/ d1 +/ d2 in
  k >= c && Int64.rem (k -/ c) 3L = 0L &&
  n -/ k >= d &&
  I.rem (n -/ k -/ d) 3L = 0L
;;

let check2 n k d1 d2 =
  let d1, d2 = max d1 d2, min d1 d2 in
  let d = (d1 -/ d2) +/ d1 in
  let c = d1 +/ d2 in
  k >= c && Int64.rem (k -/ c) 3L = 0L &&
  n -/ k >= d &&
  I.rem (n -/ k -/ d) 3L = 0L
;;

let check3 n k d1 d2 =
  let d1, d2 = max d1 d2, min d1 d2 in
  let d = d1 +/ d2 in
  let c = d1 +/ (d1 -/ d2) in
  k >= c && Int64.rem (k -/ c) 3L = 0L &&
  n -/ k >= d &&
  I.rem (n -/ k -/ d) 3L = 0L
;;

let () =
  Scanf.scanf "%d " (fun n ->
  for i = 0 to n - 1 do
    Scanf.scanf "%Ld %Ld %Ld %Ld " (fun n k d1 d2 ->
      if check1 n k d1 d2 || check2 n k d1 d2 || check3 n k d1 d2 || check4 n k d1 d2 then
        print_endline "yes"
      else
        print_endline "no")
  done)
;;

module I = Int64 ;;

let (+/) = I.add
let ( */ ) = I.mul
let ( -/ ) = I.sub
let ( // ) = I.div

let check1 n k d1 d2 =
  let d = d1 +/ d1 +/ d2 in
  let c = d1 +/ 2L */ d2 in
  k >= c && Int64.rem (k -/ c) 3L = 0L &&
  n -/ k >= d &&
  I.rem (n -/ k -/ d) 3L = 0L
;;

let check2 n k d1 d2 =
  let d1, d2 = max d1 d2, min d1 d2 in
  let d = (d1 -/ d2) +/ d1 in
  let c = d1 +/ d2 in
  k >= c && Int64.rem (k -/ c) 3L = 0L &&
  n -/ k >= d &&
  I.rem (n -/ k -/ d) 3L = 0L
;;

let check3 n k d1 d2 =
  let d1, d2 = max d1 d2, min d1 d2 in
  let d = d1 +/ d2 in
  let c = d1 +/ (d1 -/ d2) in
  k >= c && Int64.rem (k -/ c) 3L = 0L &&
  n -/ k >= d &&
  I.rem (n -/ k -/ d) 3L = 0L
;;

let () =
  Scanf.scanf "%d " (fun n ->
  for i = 0 to n - 1 do
    Scanf.scanf "%Ld %Ld %Ld %Ld " (fun n k d1 d2 ->
      if check1 n k d1 d2 || check2 n k d1 d2 || check3 n k d1 d2  then
        print_endline "yes"
      else
        print_endline "no")
  done)
;;

module I = Int64 ;;

let (+/) = I.add
let ( */ ) = I.mul
let ( -/ ) = I.sub
let ( // ) = I.div

let () =
  Scanf.scanf "%d " (fun n ->
  for i = 0 to n - 1 do
    Scanf.scanf "%Ld %Ld %Ld %Ld " (fun n k d1 d2 ->
      if n -/ k >= 2L */ d1 +/ d2 &&
         I.rem (n -/ k -/ (2L */ d1 +/ d2)) 3L = 0L then
        print_endline "yes"
      else
        print_endline "no")
  done)
;;


Nicholas, a painter is going to paint several new canvases. Nicholas is sure that the canvases will turn out so great that each one will need framing and being hung on the wall. Frames are what Nicholas decided to begin with. Nicholas has n sticks whose lengths equal a1, a2, ... an. Nicholas does not want to break the sticks or glue them together. To make a h × w-sized frame, he needs two sticks whose lengths equal h and two sticks whose lengths equal w. Specifically, to make a square frame (when h = w), he needs four sticks of the same length.Now Nicholas wants to make from the sticks that he has as many frames as possible; to be able to paint as many canvases as possible to fill the frames. Help him in this uneasy task. Note that it is not necessary to use all the sticks Nicholas has.

The first line contains an integer n (1 ≤ n ≤ 100) — the number of sticks. The second line contains n space-separated integers. The i-th integer equals the length of the i-th stick ai (1 ≤ ai ≤ 100).

Print the single number — the maximum number of frames Nicholas can make for his future canvases.

let () =
	let n = read_int() in
	let p = Hashtbl.create (n/2) in (
		for i = 1 to n do
			let l = Scanf.scanf " %d" (fun i->i) in
			let old =
				try Hashtbl.find p l
				with _ -> 0
			in
			Hashtbl.replace p l (old+1)
		done;

		let ns = Hashtbl.fold (fun _ l ns ->
			l/2 + ns
		) p 0 in
		print_int (ns/2)

	)
;;

let rec split_by2 = function
	| x::y::xs -> (x,y)::(split_by2 xs)
	| _ -> []
;;

let () =
	let n = read_int() in
	let p = Hashtbl.create (n/2) in (
		for i = 1 to n do
			let l = Scanf.scanf " %d" (fun i->i) in
			let old =
				try Hashtbl.find p l
				with _ -> 0
			in
			Hashtbl.replace p l (old+1)
		done;

		let ns = Hashtbl.fold (fun _ l ns ->
			l :: ns
		) p [] in
		let s = List.sort compare ns in
		let p = split_by2 s in
		let m = List.map (fun (w,h)-> (max w h)/2) p in
		print_int (List.fold_left (+) 0 m)
	)
;;


As you know, every birthday party has a cake! This time, Babaei is going to prepare the very special birthday party's cake.Simple cake is a cylinder of some radius and height. The volume of the simple cake is equal to the volume of corresponding cylinder. Babaei has n simple cakes and he is going to make a special cake placing some cylinders on each other.However, there are some additional culinary restrictions. The cakes are numbered in such a way that the cake number i can be placed only on the table or on some cake number j where j < i. Moreover, in order to impress friends Babaei will put the cake i on top of the cake j only if the volume of the cake i is strictly greater than the volume of the cake j.Babaei wants to prepare a birthday cake that has a maximum possible total volume. Help him find this value.

The first line of the input contains a single integer n (1 ≤ n ≤ 100 000) — the number of simple cakes Babaei has. Each of the following n lines contains two integers ri and hi (1 ≤ ri, hi ≤ 10 000), giving the radius and height of the i-th cake.

Print the maximum volume of the cake that Babaei can make. Your answer will be considered correct if its absolute or relative error does not exceed 10 - 6. Namely: let's assume that your answer is a, and the answer of the jury is b. The checker program will consider your answer correct, if .

NoteIn first sample, the optimal way is to choose the cake number 1.In second sample, the way to get the maximum volume is to use cakes with indices 1, 2 and 4.

let ( ** ) a b = Int64.mul a b
let ( ++ ) a b = Int64.add a b
let long x = Int64.of_int x

let parent v = v/2
let lc v = 2*v
let rc v = 2*v+1

let superceil n =
  let rec loop i ac = if i=0 then ac else loop (i lsr 1) (ac lor i) in
  1 + (loop (n-1) 0)

open Printf
open Scanf

let sq z = z ** z

let read_int () = bscanf Scanning.stdib " %d " (fun x -> x)
let () =
  let n = read_int () in
  let vol = Array.init n (fun i ->
    let r = long (read_int()) in
    let h = long (read_int()) in
    ((sq r) ** h, i)
  ) in

  Array.sort compare vol;
  let perm = Array.make n 0 in
  for i=0 to n-1 do
    perm.(snd vol.(i)) <- i
  done;

  let nn = superceil n in

  let v = Array.make (2*nn) 0L in (* v in our tree *)
  let t = Array.make (2*nn) 0L in (* t in our tree *)

  let rec insert a i x =
    let rec loop j = if j>0 then (
      a.(j) <- max a.(j) x;
      loop (parent j)
    ) in
    loop (i+nn)
  in

  let max_t_in_range i j =
    let rec f v l r ql qr =
      let m = (l+r)/2 in
      if l=ql && r=qr then t.(v) else
	let t1 = if ql<=m then f (lc v) l m ql (min m qr) else 0L in
	let t2 = if qr>m then f (rc v) (m+1) r (max ql (m+1)) qr else 0L in
	max t1 t2
    in
    f 1 0 (nn-1) i j
  in

  let find_index vol =
    (* find the leftmost one of this volume, which is guaranteed to exist *)
    let rec loop x = if x>=nn then x-nn else
	if v.(lc x) < vol then loop (rc x) else loop (lc x)
    in
    if v.(1) < vol then failwith "should be there";
    loop 1
  in

  let bestvol = ref 0L in

  for i=0 to n-1 do
    let j = perm.(i) in
    let (vj, _) = vol.(j) in
    insert v j vj;
    (* the ith one to insert has volume vj and is to be put in position j *)
    let tj = (
      let k = find_index vj in
      vj ++ (if k = 0 then 0L else max_t_in_range 0 (k-1))
    ) in
    insert t j tj;
    bestvol := max !bestvol tj
  done;

  let pi = (asin 1.0) *. 2.0 in
  let volume = (Int64.to_float !bestvol) *. pi in

  printf "%.9f\n" volume

let ( ** ) a b = Int64.mul a b
let ( ++ ) a b = Int64.add a b
let long x = Int64.of_int x

let parent v = v/2
let lc v = 2*v
let rc v = 2*v+1

let superceil n =
  let rec loop i ac = if i=0 then ac else loop (i lsr 1) (ac lor i) in
  1 + (loop (n-1) 0)

open Printf
open Scanf

let sq z = z ** z

let read_int () = bscanf Scanning.stdib " %d " (fun x -> x)
let () =
  let n = read_int () in
  let vol = Array.init n (fun i ->
    let r = long (read_int()) in
    let h = long (read_int()) in
    ((sq r) ** h, i)
  ) in

  Array.sort compare vol;
  let perm = Array.make n 0 in
  for i=0 to n-1 do
    perm.(snd vol.(i)) <- i
  done;

  let nn = superceil n in

  let v = Array.make (2*nn) 0L in (* v in our tree *)
  let t = Array.make (2*nn) 0L in (* t in our tree *)

  let rec insert a i x =
    let rec loop j = if j>0 then (
      a.(j) <- max a.(j) x;
      loop (parent j)
    ) in
    loop (i+nn)
  in

  let max_t_in_range i j =
    let rec f v l r ql qr =
      let m = (l+r)/2 in
      if l=ql && r=qr then t.(v) else
	let t1 = if ql<=m then f (lc v) l m ql (min m qr) else 0L in
	let t2 = if qr>m then f (rc v) (m+1) r (max ql (m+1)) qr else 0L in
	max t1 t2
    in
    f 1 0 (nn-1) i j
  in

  let find_index vol =
    (* find the rightmost index with v < vol.  -1 if none exists *)
    let rec loop x = if x>=nn then x-nn-1 else
	if v.(lc x) < vol then loop (rc x) else loop (lc x)
    in
    if v.(1) < vol then nn-1 else loop 1
  in

  let bestvol = ref 0L in

  for i=0 to n-1 do
    let (vj, j) = vol.(perm.(i)) in
    (* the ith one to insert has volume vj and is to be put in position j *)
    let tj = if i=0 then vj else (
      let k = find_index vj in
      vj ++ (if k >= 0 then max_t_in_range 0 k else 0L)
    ) in
    insert v j vj;
    insert t j tj;
    bestvol := max !bestvol tj
  done;

  let pi = (asin 1.0) *. 2.0 in
  let volume = (Int64.to_float !bestvol) *. pi in

  printf "%.9f\n" volume

(* needs to be debugged *)

let ( ** ) a b = Int64.mul a b
let ( ++ ) a b = Int64.add a b
let long x = Int64.of_int x

let parent v = v/2
let lc v = 2*v
let rc v = 2*v+1

let superceil n =
  let rec loop i ac = if i=0 then ac else loop (i lsr 1) (ac lor i) in
  1 + (loop (n-1) 0)

open Printf
open Scanf

let sq z = z ** z

let read_int () = bscanf Scanning.stdib " %d " (fun x -> x)
let () =
  let n = read_int () in
  let vol = Array.init n (fun i ->
    let r = long (read_int()) in
    let h = long (read_int()) in
    ((sq r) ** h, i)
  ) in

  Array.sort compare vol;
  let perm = Array.make n 0 in
  for i=0 to n-1 do
    perm.(snd vol.(i)) <- i
  done;

  let nn = superceil n in

  let v = Array.make (2*nn) 0L in (* v in our tree *)
  let t = Array.make (2*nn) 0L in (* t in our tree *)

  let rec insert a i x =
    let rec loop j = if j>0 then (
      a.(j) <- max a.(j) x;
      loop (parent j)
    ) in
    loop (i+nn)
  in

  let max_t_in_range i j =
    let rec f v l r ql qr =
      let m = (l+r)/2 in
      if l=ql && r=qr then t.(v) else
	let t1 = if ql<=m then f (lc v) l m ql (min m qr) else 0L in
	let t2 = if qr>m then f (rc v) (m+1) r (max ql (m+1)) qr else 0L in
	max t1 t2
    in
    f 1 0 (nn-1) i j
  in

  let find_index vol =
    (* find the leftmost one of this volume, which is guaranteed to exist *)
    let rec loop x = if x>=nn then x-nn else
	if v.(lc x) < vol then loop (rc x) else loop (lc x)
    in
    if v.(1) < vol then failwith "should be there";
    loop 1
  in

  let bestvol = ref 0L in

  for i=0 to n-1 do
    let (vj, j) = vol.(perm.(i)) in
    insert v j vj;
    (* the ith one to insert has volume vj and is to be put in position j *)
    let tj = (
      let k = find_index vj in
      vj ++ (if k = 0 then 0L else max_t_in_range 0 (k-1))
    ) in
    insert t j tj;
    bestvol := max !bestvol tj
  done;

  let pi = (asin 1.0) *. 2.0 in
  let volume = (Int64.to_float !bestvol) *. pi in

  printf "%.9f\n" volume


The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all the houses with larger numbers. In other words, a house is luxurious if the number of floors in it is strictly greater than in all the houses, which are located to the right from it. In this task it is assumed that the heights of floors in the houses are the same.The new architect is interested in n questions, i-th of them is about the following: "how many floors should be added to the i-th house to make it luxurious?" (for all i from 1 to n, inclusive). You need to help him cope with this task.Note that all these questions are independent from each other — the answer to the question for house i does not affect other answers (i.e., the floors to the houses are not actually added).

The first line of the input contains a single number n (1 ≤ n ≤ 105) — the number of houses in the capital of Berland. The second line contains n space-separated positive integers hi (1 ≤ hi ≤ 109), where hi equals the number of floors in the i-th house.

Print n integers a1, a2, ..., an, where number ai is the number of floors that need to be added to the house number i to make it luxurious. If the house is already luxurious and nothing needs to be added to it, then ai should be equal to zero. All houses are numbered from left to right, starting from one.

let () = Scanf.scanf "%d\n" (fun n ->
    (* heights of houses *)
    let h = Array.init n (fun _ ->
        Scanf.scanf "%d%_c" (fun x -> x))
    in

    (* maximum of all houses to the right *)
    let maxes = Array.fold_right (fun x ->
        function
        | [] -> [x]
        | (hd :: _) as acc -> (max x hd) :: acc)
    h [0]
    in
    print_endline (String.concat " "
        (List.map2 (fun x h ->
            (* how much to add to x to make it strictly greater than h? *)
                string_of_int (max (x - h + 1) 0))
            (List.tl maxes) (Array.to_list h))))

let () = Scanf.scanf "%d\n" (fun n ->
    (* heights of houses *)
    let h = Array.init n (fun _ ->
        Scanf.scanf "%d%_c" (fun x -> x))
    in

    (* maximum of all houses to the right *)
    let maxes = Array.fold_right (fun x ->
        function
        | [] -> [x]
        | (hd :: _) as acc -> (max x hd) :: acc)
    h []
    in
    print_endline (String.concat " "
        (List.map2 (fun x h ->
                string_of_int (max (x - h) 0 + if x - h > 0 then 1 else 0))
            maxes (Array.to_list h))))