open Printf open Scanf
open Array

let i32,i64,i64st = Int64.(to_int,of_int,to_string)
let labs = Int64.abs
let (++),(--),( ** ),(//),(%%) = Int64.(add,sub,mul,div,rem)
let rec gcd_i64 m n = match m,n with | m,0L -> m | m,n -> gcd_i64 n (m %% n)
let lcm_i64 m n = (m // gcd_i64 m n) ** n
let pow_i64 n k =
  let rec f a n = function
  | 0 -> a | 1 -> n**a | k when k mod 2 = 0 -> f a (n**n) (k/2) | k -> f (a**n) (n**n) (k/2)
  in f 1L n k
let rep l r f =
  let rec f0 i =
    if i>r then ()
    else (f i; f0 (i++1L))
  in f0 l
let factors n = (* O(sqrt n) *)
  let m,r = ref n,ref [] in
  rep 2L (2L ++ Int64.of_float (sqrt @@ Int64.to_float n)) (fun i ->
    if !m %% i = 0L then (
      let k = ref 0L in
      while !m %% i = 0L do
        k := !k ++ 1L; m := !m // i;
      done;
      r := (i,!k) :: !r));
  if !m>1L then (!m,1L)::!r else !r

module ModCalc_lightweight = struct
  let md = 1000000007L
  (* let md = 998244353L *)
  let pow_mod n k =
    let rec f a n = function
    | 0L -> a %% md
    | 1L -> (a ** n) %% md
    | k when k %% 2L = 0L -> f a ((n ** n) %% md) (k//2L)
    | k -> f ((a ** n) %% md) n (k--1L)
    in f 1L n k
  let posmod v =
    if v<0L then
      (v ++ (-1L ** v // md ++ 1L) ** md) %% md
    else v
  let rec extgcd a b =
    if b = 0L then 1L,0L,a
    else
      let y,x,d = extgcd b (a %% b) in
      x,(y -- (a//b) ** x),d
  (* let inv v = pow_mod v (md--2L) *)
  let inv v =
    let x,_,_ = extgcd v md in
    let x = posmod x in
    (md ++ (x %% md)) %% md
  let (/%) p q = (p ** (inv q)) %% md
end open ModCalc_lightweight

let () = scanf " %Ld %d" @@ fun n k ->
  let arr = factors n |> of_list in
  let res = ref 1L in
  iter (fun (p,q) ->
    let q = i32 q in
    let dp = make (q+1) 0L in
    dp.(q) <- 1L;
    for _=1 to k do
      let acc = ref 0L in
      for j=q downto 0 do
        acc := (!acc ++ dp.(j) /% (i64 @@ j+1)) %% md;
        dp.(j) <- !acc;
      done;
    done;
    let r = ref 0L in
    let pw = ref 1L in
    for j=0 to q do
      r := !r ++ (dp.(j) ** !pw) %% md;
      pw := (!pw ** p) %% md;
    done;
    res := !res ** (!r %% md);
    res := !res %% md;
  ) arr;
  printf "%Ld" !res


(*
    Author: sighduck
    URL: https://codeforces.com/problemset/problem/4/A
*)

let solve (w: int) : string =
    if w mod 2 == 0 && w > 2 then "YES\n"
    else "NO\n" ;;

let main =
    read_int () |> solve |> print_string ;;


let scan_int () = Scanf.scanf " %d" (fun x -> x);;
let scan_string () = Scanf.scanf " %s" (fun x -> x);;
let psp () = print_string " ";;
let b2i x = if x == true then 1 else 0;;

open Int64;;
let n = Int64.of_int(scan_int()) and m = Int64.of_string(scan_string());;
print_int(Int64.to_int(max zero (sub n (mul (Int64.of_int 2) m)))); psp();

for i = 0 to Int64.to_int(n) do
  let j = Int64.of_int(i) in
  if div (mul j (pred j)) (Int64.of_int 2) >= m then begin
    print_int(Int64.to_int(n) - i); exit 0;
  end;
done;;


open Printf
open Scanf

let l2n c = (int_of_char c) - (int_of_char 'a')
let n2l n = char_of_int ((int_of_char 'a') + n)
let rec forall i j f = (i>j) || ((f i) && forall (i+1) j f)

let read_string () = bscanf Scanning.stdib " %s " (fun x -> x)

let () =
  let s = read_string () in
  let t = read_string () in

  let n = String.length s in

  let ns = Array.init n (fun i -> l2n s.[i]) in

  let c = ref 1 in
  for i=n-1 downto 0 do
    ns.(i) <- ns.(i) + !c;
    if ns.(i) = 26 then (
      ns.(i) <- 0;
      c := 1;
    ) else (
      c := 0;
    )
  done;

  if forall 0 (n-1) (fun i -> n2l ns.(i) = t.[i]) then (
    printf "No such string\n"
  ) else (
    for i=0 to n-1 do
      printf "%c" (n2l ns.(i))
    done;
    print_newline()
  )


open Printf
open Scanf

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

let read_long () = bscanf Scanning.stdib " %Ld " (fun x -> x)

let () =
  let x = read_long() in

  let rec digits x = if x=0L then [] else (Int64.to_int (x %% 10L))::(digits (x//10L)) in

  List.iteri (fun i d ->
    let d = if i=0 && d=9 then d else min (9-d) d in
    printf "%d" d;
  ) (List.rev (digits x));

  print_newline()


module SS = Set.Make(String);;

let read_int () = Scanf.scanf " %d" (fun x -> x)
let read_line () = Scanf.scanf " %s" (fun x -> x)

let (--) i j =
    let rec aux n acc =
        if n < i then acc else aux (n-1) (n :: acc)
    in aux j []

let break str i =
    let n = String.length str in
    let a = String.sub str 0 i in
    let b = String.sub str i (n - i) in
    (a,b)

let print_set s = SS.iter print_endline s

let () =
    let set = SS.empty in
    let str = read_line () in
    let n = String.length str in
    let alphabet = List.map Char.chr (Char.code('a') -- Char.code('z')) in
    let set = List.fold_right (fun i set ->
        List.fold_right (fun j set ->
            let (a,b) = break str j in
            SS.add (a ^ (Char.escaped i) ^ b) set
        ) (0 -- n) set
    ) alphabet set in
    Printf.printf "%d\n" (SS.cardinal set);


let rec r a b n =
    if a = Int64.zero then n
    else
        if a >= b then
            r (Int64.sub a (Int64.mul (Int64.div a b) b)) b (Int64.add n (Int64.div a b))
        else
            r b a n ;;

Printf.printf "%Ld\n" (Scanf.scanf "%Ld %Ld" (fun a b -> r a b Int64.zero)) ;;


let permute n visit =
  let a = Array.init n (fun i -> i + 0)
  and b = Array.init n (fun i -> i)
  and c = Array.make (n + 1) 0 in
  let k = ref 1 in
  let j = ref 1 in
    try
      while true do
	visit a;
	k := 1;
	while c.(!k) = !k do
	  c.(!k) <- 0;
	  incr k
	done;
	if !k = n then
	  raise Not_found;
	c.(!k) <- c.(!k) + 1;
	let t = a.(0) in
	  a.(0) <- a.(b.(!k));
	  a.(b.(!k)) <- t;
	  j := 1;
	  k := !k - 1;
	  while !j < !k do
	    let t = b.(!j) in
	      b.(!j) <- b.(!k);
	      b.(!k) <- t;
	      incr j;
	      k := !k - 1;
	  done
      done
    with
      | Not_found -> ()

exception Found

let _ =
  let sb = Scanf.Scanning.stdib in
  let n = Scanf.bscanf sb "%d " (fun s -> s) in
  let a = Array.make (n * n) 0 in
  let () =
    for i = 0 to n * n - 1 do
      let k = Scanf.bscanf sb "%d " (fun s -> s) in
	a.(i) <- k
    done
  in
  let s =
    let s = ref 0 in
      for i = 0 to n * n - 1 do
	s := !s + a.(i)
      done;
      !s / n
  in
  let b = Array.make_matrix n n 0 in
  let visit p =
    for i = 0 to n - 1 do
      for j = 0 to n - 1 do
	b.(i).(j) <- a.(p.(i * n + j))
      done
    done;
    try
      for i = 0 to n - 1 do
	let r = ref 0 in
	  for j = 0 to n - 1 do
	    r := !r + b.(i).(j)
	  done;
	  if !r <> s
	  then raise Not_found
      done;
      for i = 0 to n - 1 do
	let r = ref 0 in
	  for j = 0 to n - 1 do
	    r := !r + b.(j).(i)
	  done;
	  if !r <> s
	  then raise Not_found
      done;
      (let r = ref 0 in
	 for j = 0 to n - 1 do
	   r := !r + b.(j).(j)
	 done;
	 if !r <> s
	 then raise Not_found
      );
      (let r = ref 0 in
	 for j = 0 to n - 1 do
	   r := !r + b.(j).(n - 1 - j)
	 done;
	 if !r <> s
	 then raise Not_found
      );
      raise Found
    with
      | Not_found -> ()
  in
    try
      if n <= 3 then (
	permute (n * n) visit;
	assert false
      ) else (
	(*for i = 15 downto 1 do
	  let j = Random.int (i + 1) in
	  let t = a.(i) in
	    a.(i) <- a.(j);
	    a.(j) <- t;
	done;*)
	Array.sort compare a;
	let u = Array.make 16 false in
	  for i = 0 to 15 do
	    if not (Array.unsafe_get u i) && not (i > 0 && not u.(i - 1) && a.(i - 1) = a.(i)) then (
	      let i11 = i in
	      Array.unsafe_set u i true;
	      let a11 = Array.unsafe_get a i in
		for i = 0 to 15 do
		  if not (Array.unsafe_get u i) && not (i > 0 && not u.(i - 1) && a.(i - 1) = a.(i)) then (
		    Array.unsafe_set u i true;
		    let a22 = Array.unsafe_get a i in
		      for i = 0 to 15 do
			if not (Array.unsafe_get u i) && not (i > 0 && not u.(i - 1) && a.(i - 1) = a.(i)) then (
			  Array.unsafe_set u i true;
			  let a33 = Array.unsafe_get a i in
			    for i = i11 + 1 to 15 do
			      if not (Array.unsafe_get u i) && not (i > 0 && not u.(i - 1) && a.(i - 1) = a.(i)) then (
				Array.unsafe_set u i true;
				let a44 = Array.unsafe_get a i in
				  if a11 + a22 + a33 + a44 = s then (
		for i = i11 + 1 to 15 do
		  let i41 = i in
		  if not (Array.unsafe_get u i) then (
 let f () =
		    Array.unsafe_set u i true;
		    let a41 = Array.unsafe_get a i in
		      for i = 0 to 15 do
			if not (Array.unsafe_get u i) then (
			  Array.unsafe_set u i true;
			  let a32 = Array.unsafe_get a i in
			    for i = 0 to 15 do
			      if not (Array.unsafe_get u i) then (
				Array.unsafe_set u i true;
				let a23 = Array.unsafe_get a i in
				  for i = i11 + 1 to 15 do
				    if not (Array.unsafe_get u i) then (
				      Array.unsafe_set u i true;
				      let a14 = Array.unsafe_get a i in
					if i < i41 && a41 + a32 + a23 + a14 = s then (
		  for i = 0 to 15 do
		    if not (Array.unsafe_get u i) then (
		      Array.unsafe_set u i true;
		      let a34 = Array.unsafe_get a i in
			for i = 0 to 15 do
			  if not (Array.unsafe_get u i) then (
			    Array.unsafe_set u i true;
			    let a31 = Array.unsafe_get a i in
			      if a31 + a32 + a33 + a34 = s then (
		  for i = 0 to 15 do
		    if not (Array.unsafe_get u i) then (
		      Array.unsafe_set u i true;
		      let a21 = Array.unsafe_get a i in
			if a11 + a21 + a31 + a41 = s then (
		  for i = 0 to 15 do
		    if not (Array.unsafe_get u i) then (
		      Array.unsafe_set u i true;
		      let a24 = Array.unsafe_get a i in
			if a21 + a22 + a23 + a24 = s &&
			  a14 + a24 + a34 + a44 = s
			then (
		  for i = 0 to 15 do
		    if not (Array.unsafe_get u i) then (
		      Array.unsafe_set u i true;
		      let a12 = Array.unsafe_get a i in
			for i = 0 to 15 do
			  if not (Array.unsafe_get u i) then (
			    Array.unsafe_set u i true;
			    let a42 = Array.unsafe_get a i in
			      if a12 + a22 + a32 + a42 = s then (
		  for i = 0 to 15 do
		    if not (Array.unsafe_get u i) then (
		      Array.unsafe_set u i true;
		      let a43 = Array.unsafe_get a i in
			if a41 + a42 + a43 + a44 = s then (
		  for i = 0 to 15 do
		    if not (Array.unsafe_get u i) then (
		      Array.unsafe_set u i true;
		      let a13 = Array.unsafe_get a i in
			if a13 + a23 + a33 + a43 = s &&
			  a11 + a12 + a13 + a14 = s
			then (
			  let bb =
			    [| [| a11; a12; a13; a14 |];
			       [| a21; a22; a23; a24 |];
			       [| a31; a32; a33; a34 |];
			       [| a41; a42; a43; a44 |]; |]
			  in
			    for i = 0 to 3 do
			      for j = 0 to 3 do
				b.(i).(j) <- bb.(i).(j)
			      done
			    done;
			    raise Found;
			);
			Array.unsafe_set u i false;
		    )
		  done;
			);
			Array.unsafe_set u i false;
		    )
		  done;
			);
			Array.unsafe_set u i false;
		    )
		  done;
			Array.unsafe_set u i false;
		    )
		  done;
			);
			Array.unsafe_set u i false;
		    )
		  done;
			);
			Array.unsafe_set u i false;
		    )
		  done;
			);
			Array.unsafe_set u i false;
		    )
		  done;
			Array.unsafe_set u i false;
		    )
		  done;
					);
					Array.unsafe_set u i false;
				    )
				  done;
				  Array.unsafe_set u i false;
			      )
			    done;
			    Array.unsafe_set u i false;
			)
		      done;
		      Array.unsafe_set u i false;
 in f ()
		  )
		done;
				  );
				  Array.unsafe_set u i false;
			      )
			    done;
			    Array.unsafe_set u i false;
			)
		      done;
		      Array.unsafe_set u i false;
		  )
		done;
		Array.unsafe_set u i false;
	    )
	  done
      )
    with
      | Found ->
	  Printf.printf "%d\n" s;
	  for i = 0 to n - 1 do
	    for j = 0 to n - 1 do
	      Printf.printf "%d " b.(i).(j)
	    done;
	    Printf.printf "\n";
	  done;


let readInput n =
  let rec aux i acc =
    match i with
      | 0 -> List.rev acc
      | i -> let v = Scanf.scanf "%d " (fun x -> x) in
          aux (i-1) (v :: acc)
  in
    aux n []

let main =
  let (n, s) = Scanf.scanf "%d %d\n" (fun n s -> (n,s)) in
  let volumes = readInput n in
  let (total,maxV) =
    List.fold_left (fun (sum,maxV) v -> (sum + v, max v maxV))
      (0,0) volumes
  in
    if ((total - maxV) <= s) then Printf.printf "YES\n"
    else Printf.printf "NO\n"


let input = read_line() |> Str.split (Str.regexp " +") |> List.map int_of_string in
let n = List.nth input 0 and
m = List.nth input 1 in
let count = ref (if m <= n then 1 else 0)  in
begin
for i = 2 to min m n do
     if m mod i = 0 && m / i <= n then count := !count+1 else ()
done;
!count |> print_int
end


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

let () =
  let n = read_int () in
  let array = Array.init n (fun _ ->
      read_int ()
    )
  in
  let e = (Array.length array) - 1 in
  if array.(e) = 0 then print_endline "UP"
  else if array.(e) = 15 then print_endline "DOWN"
  else if n = 1 then print_endline "-1"
  else if array.(e) - array.(e - 1) > 0 then print_endline "UP"
  else if array.(e) - array.(e - 1) < 0 then print_endline "DOWN"


(* compiled on 64-bit system with ocamlopt -pp camlp4o $file *)

open Printf
open Scanf
open Array

module S = String
module Q = Queue
module T = Stack
module L = List

(* misc *)
let neg_compare x y = - compare x y
let min3 a b c = min a (min b c)
let mid3 a b c = if a < b then max a (min b c) else max b (min a c)
let max3 a b c = max a (max b c)
let min4 a b c d = min (min a b) (min c d)
let max4 a b c d = max (max a b) (max c d)
let itb a = a <> 0
let bti b = if b then 1 else 0
(* int *)
let intsqrt n =
  if n < 0 then raise (Invalid_argument "sqrt of negative int") else
  let rec bs a b = begin
    if b - a = 1 then a else
    let mid = (a+b)/2 in
    if mid*mid <= n then bs mid b else bs a mid
  end in
  bs 0 (1 lsl 31)
(* float *)
let round f = truncate (f +. 0.5)
let inv_float f = 1. /. f
(* functional *)
let id x = x
let const x _ = x
let (|>) x f = f x
let (^>) x f = f x
let (@@) a b = a b
let on g f a b = g (f a) (f b)
let rec fix f = f (fun x -> fix f x)
let ift cond a = if cond then a
let ifte cond a b = if cond then a else b
let rec for_ i len c f = if i = len then c else for_ (i+1) len (f i c) f
(* predicate *)
let is_odd x = x land 1 = 1
let is_even x = x land 1 = 0
(* option *)
let is_none = function | Some _ -> false | None -> true
let is_some = function | Some _ -> true | None -> false
let default x = function Some y -> y | None -> x
(* ref *)
let (+=) a b = a := !a + b
let (-=) a b = a := !a - b
let ( *= ) a b = a := !a * b
let assign_min x y = x := min !x y
let assign_max x y = x := max !x y
(* array *)
let set_min x i v = x.(i) <- min x.(i) v
let set_max x i v = x.(i) <- max x.(i) v
let swap arr i j = let t = arr.(i) in arr.(i) <- arr.(j); arr.(j) <- t
(* tuple *)
let (+:) (a,b) (c,d) = (a+c,b+d)
let (-:) (a,b) (c,d) = (a-c,b-d)
(* Arithmetic *)
let negate x = -x
let rec factorial n = if n = 0 then 1 else n * factorial (n-1)
let rec gcd a b = if b = 0 then a else gcd b (a mod b)
let rec extgcd a b =
  if b = 0 then 1,0,a else
  let x,y,g = extgcd b (a mod b) in
  y,x-(a/b)*y,g
let rec pow x n = if n = 0 then 1 else
  let n' = n/2 in
  let p = pow x n' in
  if is_odd n then x*p*p else p*p
let rec modpow m x n =
  if n = 0 then 1 else
  let n' = n/2 in
  let p = modpow m x n' in
  if is_even n then (p*p mod m) else
  (x*(p*p mod m) mod m)
let modinv m i = let _,x,_ = extgcd m i in x
(* IO *)
let is_digit c =
  let i = int_of_char c in
  48 <= i && i < 58
let is_space c = c = ' ' || c = '\n' || c = '\t' || c = '\r'
let read_char () = try input_char stdin with End_of_file -> '\000'
let rec read_letter () =
  let c = read_char() in
  if is_space c then read_letter() else c
let read_int () =
  let digit c = int_of_char c - 48 in
  let rec read n =
    let c = read_char() in
    if is_digit c then read (10*n + (digit c)) else
    n
  in
  let rec run c =
    if is_digit c then read (digit c) else
    if c = '-' then begin
      let c = read_char() in
      if is_digit c then -read (digit c) else run c
    end else
    if c = '\000' then 0 else
    run (read_char())
  in
  run (read_char())
let read_float () =
  let digit c = float (int_of_char c - 48) in
  let rec read_decimial m f =
    let c = read_char () in
    if is_digit c then read_decimial (m /. 10.) (f +. m *. digit c) else f
  in
  let rec read_integral n =
    let c = read_char () in
    if is_digit c then read_integral (10. *. n +. digit c) else
    if c = '.' then n +. read_decimial 0.1 0.0 else
    n
  in
  let rec run c = begin
    if is_digit c then read_integral (digit c) else
    if c = '-' then begin
      let c = read_char() in
      if is_digit c then -. read_integral (digit c) else
      run c
    end else
    if c = '.' then read_decimial 0.1 0.0 else
    if c = '\000' then 0.0 else
    run (read_char())
  end in
  run (read_char())
let read_word () =
  let open Buffer in
  let buf = create 1_000_000 in
  let rec read c =
    if is_space c || c = '\000' then contents buf else begin
      add_char buf c;
      read (read_char())
    end
  in
  let rec run c =
    if is_space c then run (read_char()) else
    if c = '\000' then "" else
    read c
  in
  run (read_char())
let read_line () =
  let open Buffer in
  let buf = create 1_000_000 in
  let rec run c =
    if c = '\n' || c = '\000' then contents buf else begin
      add_char buf c;
      run (read_char())
    end
  in
  run (read_char())
let newline () = print_newline()
let print_tuple s (x,y) = printf s x y
let print_array s arr = Array.iter (printf s) arr; print_newline()
let print_matrix s mat = Array.iter (print_array s) mat
let print_list s lis = List.iter (printf s) lis; print_newline()
;;

let _ =
  let len = read_int() in
  let _ = read_int() in
  let arr = init len (fun i -> i,read_int()) in
  sort (on compare snd) arr;
  let ans = make len 0 in
  for i = 0 to len -1 do ans.(fst arr.(i)) <- i land 1 done;
  for i = 0 to len -1 do printf "%d " ans.(i) done


let _ =
  let sb = Scanf.Scanning.stdib in
  let a = Scanf.bscanf sb "%d " (fun s -> s) in
  let c = Scanf.bscanf sb "%d " (fun s -> s) in
  let p = ref 387420489 in
  let b = ref 0l in
    while !p > 0 do
      let da = (a / !p) mod 3 in
      let dc = (c / !p) mod 3 in
      let db = (dc - da + 3) mod 3 in
	b := Int32.add !b (Int32.mul (Int32.of_int db) (Int32.of_int !p));
	p := !p / 3;
    done;
    Printf.printf "%ld\n" !b


let check_stairs a b =
	match (max a b) - (min a b) with
		|0 when a = 0 -> print_endline "NO";
		|0 |1 -> print_endline "YES";
		|_ -> print_endline "NO"
;;

Scanf.bscanf Scanf.Scanning.stdin " %i %i " check_stairs


let dodaj_do_listy a x =
    x :: a
;;

let wczytaj () =
    Scanf.scanf " %d" (fun i -> i)
;;

let wczytaj_i_wypisz () =
    Printf.printf "%d" (wczytaj ())
;;

let wczytaj_liste () =
    let n = wczytaj () in
        let rec dodaj licznik =
             match licznik with
             | 0 -> []
             | licznik ->
                let x = wczytaj () in
                    dodaj_do_listy (dodaj (licznik-1)) x
        in dodaj n
;;

let main () =
    let moja_lista = wczytaj_liste () in
        let sumka = List.fold_left ( + ) 0 moja_lista in
            match sumka with
            | 0 -> false
            | sumka -> true
;;

let sprawdz czy_nie_zero =
    match czy_nie_zero with
    | false -> "EASY"
    | czy_nie_zero -> "HARD"
;;

let _ = Printf.printf "%s" (sprawdz (main ()))


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

let solve input =
    let rec loop i rest last =
        if rest > 0
        then
            let layer = i + last in
                if layer <= rest
                then
                    loop (i + 1) (rest - layer) layer
                else
                    (i - 1)
        else
            (i - 1)
    in loop 1 input 0

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


print_int (Scanf.scanf "%d %d %d" (fun n a b ->
	let i = ref 0 in
	let _ = (for p = 1 to n do
		if p > a && (n-p-1) < b then incr i
	done) in !i
));;


let read_int () = Scanf.bscanf Scanf.Scanning.stdib " %d " (fun x -> x);;
let read_string () = Scanf.bscanf Scanf.Scanning.stdib " %s " (fun x -> x);;

let pages = read_int();;

let r = Array.make 7 0;;

let () =
  for i=0 to 6 do
    r.(i) <- read_int()
  done;;

let rec day left current =
  if left <= r.(current) then current else day (left-r.(current)) ((current+1) mod 7)

;;
Printf.printf "%d\n" ((day pages 0) + 1)


let bs = Scanf.Scanning.stdin
let xint() = Scanf.bscanf bs " %d" (fun x -> x)
let xint32() = Scanf.bscanf bs " %ld" (fun x -> x)
let xint64() = Scanf.bscanf bs " %Ld" (fun x -> x)
let xstr() = Scanf.bscanf bs " %s" (fun x -> x)
let xreal() = Scanf.bscanf bs " %f" (fun x -> x)
let printf = Printf.printf

let () =
  let n = xint() in
  let mx = ref 0 and mi = ref n in
  let check n = n mod 7 <= 1 in
  for s = 0 to 6 do
    let cnt = ref 0 in
    for i = 0 to n - 1 do
      cnt := !cnt + (if check (s + i) then 1 else 0)
    done;
    if !cnt > !mx then mx := !cnt;
    if !cnt < !mi then mi := !cnt;
  done;
  printf "%d %d\n" !mi !mx;


open Printf
open Scanf

let read_int () = bscanf Scanning.stdib " %d " (fun x -> x)
let () =
  let n = read_int () in
  let m = read_int () in

  let rec form_team i j ac =
    if i+j < 3 || i=0 || j=0 then ac else (
      let (i,j) = (max i j, min i j) in
      form_team (i-2) (j-1) (ac+1)
    )
  in

  printf "%d\n" (form_team n m 0)


let main () =
    let (a,b,c,x,y,z) = Scanf.scanf "%d %d %d %d %d %d" (fun i j k l m n -> (i,j,k,l,m,n)) in
    let a' = a - x and b' = b - y and c' = c - z in
    let too_much = List.fold_left (+) 0 (List.map (fun i -> if i > 0 then i / 2 else i) [a';b';c']) in
        print_endline
        (if too_much >= 0 then "Yes" else "No");;

main ();;


open Printf
open Scanf

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

  let rec find i x = if a.(i) = x then i else find (i+1) x in

  let one = find 0 1 in
  let last = find 0 n in

  let opt1 = max ((n-1) - last) last in
  let opt2 = max ((n-1) - one) one in

  printf "%d\n" (max opt1 opt2)


let read_nums () =
    let s = read_line () in
    let nums = List.map int_of_string (Str.split (Str.regexp " ") s) in
    nums

;;

let main () =
    let lst = read_nums () in
    let lst = List.sort compare lst in
    let () = match lst with
    | [a;b;c] -> print_int (c-a)
    | _ -> ()
    in
    print_string "\n"
;;

main ()


let _ =
  let sb = Scanf.Scanning.stdib in
  let s = Scanf.bscanf sb "%s " (fun s -> s) in
  let lc = ref false in
  let uc = ref false in
  let d = ref false in
  let n = String.length s in
    for i = 0 to n - 1 do
      match s.[i] with
	| 'A'..'Z' -> uc := true
	| 'a'..'z' -> lc := true
	| '0'..'9' -> d := true
	| _ -> ()
    done;
    if n >= 5 && !uc && !lc && !d
    then Printf.printf "Correct\n"
    else Printf.printf "Too weak\n"


let scan_int () = Scanf.scanf " %d" (fun x -> x);;
let n = scan_int() and  a = Array.make 100 1 and licz = ref 1 and dwa = ref 2 and wyn = ref 1 in begin
while !wyn < n do
  wyn := (!dwa * 2 - 1) * !dwa;
  dwa := !dwa * 2;
  a.(!licz) <- !wyn;
  licz := !licz +1
done;
licz := !licz -1;
while n mod a.(!licz) <> 0 do
  licz := !licz - 1
done;
print_int a.(!licz)
end


let input () = Scanf.scanf "%d %d" (fun n m -> (n, m))

let add candles hours m =
    if hours mod m = 0
    then
        candles + 1
    else
        candles

let solve (n, m) =
    let rec loop candles hours =
        if candles > 0
        then
            loop ((add candles hours m) - 1) (hours + 1)
        else
            hours - 1
    in loop n 1

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


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

let () =
  let n = read_int() in
    if n<=2 then Printf.printf "-1\n" else (
      for i=n downto 1 do
	Printf.printf "%d "i
      done
    )


let n = read_int();;
let a = Array.append [|0; 0|] (Array.of_list (List.map
	(int_of_string) (Str.split (Str.regexp " ") (read_line()))));;
let fl = ref false and ans = ref 0  and kol = ref 0;;
for i = 0 to Array.length a - 1 do
	if a.(i) = 1 then ans := !ans + 1;
	if (a.(i) = 0) && (!fl = false) then
	begin
		fl := true;
		kol := 1;
	end else if (a.(i) = 0) then kol := !kol + 1;
	if (a.(i) = 1) && (!fl = true) then
	begin
		if (!kol = 1) then ans := !ans + 1;
		fl := false;
	end;
done;;
print_int !ans;


let read1 () = Scanf.scanf "%d\n" ( fun x -> x );;
let read2 () = Scanf.scanf "%d %d\n" ( fun x y -> x, y );;
let read3 () = Scanf.scanf "%d %d %d\n" ( fun x y z -> x, y, z);;
let read4 () = Scanf.scanf "%d %d %d %d\n" ( fun x y z a-> x, y, z, a);;
let read5 () = Scanf.scanf "%d %d %d %d %d\n" ( fun x y z a b-> x, y, z, a, b);;
let read6 () = Scanf.scanf "%d %d %d %d %d %d\n" ( fun x y z a b c-> x, y, z, a, b, c);;
let read x = (if x = 0 then Scanf.scanf "%d\n" else Scanf.scanf "%d ") ( fun x -> x );;

let (+$) x y =
  if x > max_int - y then max_int
  else x + y;;

let rec ( *$ ) x y =
  if y = 0 then 0 else
  if y mod 2 = 1 then x *$ (y-1) +$ x
  else let a = x *$ (y/2) in a +$ a;;

let check o p dod min =
  if o > p then dod
  else if o < 0 then min
  else 0

let _ =
  let (x, y, z) = read3() in
  let (x1, y1, z1) = read3() in
  let (a1, a2, a3, a4, a5, a6) = read6 () in
  let suma = ( check y y1 a2 a1 ) + ( check z z1 a4 a3 ) + ( check x x1 a6 a5 ) in
  Printf.printf "%d\n" suma;;


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

open Int64

let rec gcd x y =
  if y = 0L then
    x
  else
    gcd y (rem x y)

let () =
  let a = read_int64 0 in
  let b = read_int64 0 in
  let x = read_int64 0 in
  let y = read_int64 0 in
  let d = gcd x y in
  let xx = div x d in
  let yy = div y d in
  let t = min (div a xx) (div b yy) in
  Printf.printf "%Ld %Ld\n" (mul xx t) (mul yy t)


let (d, l, v1, v2) = Scanf.scanf "%f %f %f %f" (fun x y z w -> x, y, z, w)
    in Printf.printf "%.8f\n" ((l -. d) /. (v1 +. v2));;


(* work on Fib http://www.codeforces.ru/problemset/problem/199/A *)
open Scanf;;
open Printf;;
open Str;;

let rec fib0 a b f =
  if (a + b + b) == f then (a,b)
  else fib0 b (a+b) f;;

let rec fib2 f = match f with
  | 0 -> (0,0)
  | 1 -> (0,1)
  | fi ->
    let a = 1 in
    let b = 1 in
    fib0 a b fi;;

let fib3 fi = match fi with
  | 0 -> (0,0,0)
  | 1 -> (0,0,1)
  | 2 -> (0,1,1)
  | 3 -> (1,1,1)
  | 5 -> (1,2,2)
  | fii ->
    let (a,b) = fib2 fii in
    (a, b, b);;

let main () =
  let fn = "codeforce.in" in
  let inchan = stdin in
  let gr () = fscanf inchan "%d" (fun i -> i) in
  let fi = gr () in
  let a,b,c = fib3 fi in
  Printf.printf "%n %n %n" a b c
  ;;
let _ = main();;


let n=read_int() and s=read_line();;
let tab=Array.make (n+1) (Int64.zero);;
tab.(1)<-(Int64.one);;
let sum=ref (Int64.one);;
for i=2 to n do
   tab.(i)<- Int64.succ( !sum);
   sum:= Int64.add ( !sum) (tab.(i))
done;;
let sol=ref (Int64.zero);;
for i=1 to n do
   if s.[i-1]='B' then sol:= Int64.add ( !sol) (tab.(i))
done;;
print_string (Int64.to_string( !sol));;


let reverse s =
	let len = String.length s - 1 in
	let r = String.create (len+1) in
	for i = 0 to len do
		r.[i] <- s.[len-i];
	done;
	r
;;

print_string (if (read_line()) = (reverse (read_line())) then "YES" else "NO")


let tau = atan 1.0 *. 8.0

let (|>) x f = f x

type point = float * float

let read_points () =
  let read_point () : point =
    Scanf.scanf "%f %f\n" (fun x y -> (x,y)) in
  let a = read_point () in
  let b = read_point () in
  let c = read_point () in
  (a,b,c)

let diff (ax,ay) (bx,by)        = (bx -. ax, by -. ay)
let dot (ax,ay) (bx,by)         = ax *. bx +. ay *. by
let length a                    = dot a a |> sqrt
let dist a b                    = diff a b |> length
let ortho (x,y)                 = (y, -.x)
let midpoint (ax,ay) (bx,by)    = (0.5 *. (ax +. bx), 0.5 *. (ay +. by))
let det (ax,ay) (bx,by)         = ax *. by -. ay *. bx
let angle a b                   = (dot a b /. (length a) /. (length b)) |> acos
let part a                      = a /. tau
let move (ax,ay) s (bx,by)      = (ax +. s *. bx, ay +. s *. by)

let rec gcd a b =
  if a < b
  then gcd b a
  else if b < 0.0001
  then a
  else gcd b (mod_float a b)

let get_circumcenter a b c : point =
  let p1 = midpoint a c
  and d1 = diff a c |> ortho
  and p2 = midpoint b c
  and d2 = diff b c |> ortho in
  let rhs = diff p1 p2 in
  let det0 = det d1 d2
  and det1 = det rhs d2 in
  move p1 (det1 /. det0) d1

let get_corners m a b c =
  let alpha = angle (diff m a) (diff m b) |> part
  and beta = angle (diff m b) (diff m c) |> part in
  let gamma = 1.0 -. alpha -. beta in
  let (r,n) = 1.0 /. (gcd (gcd alpha beta) gamma) |> modf in
  if r >= 0.5 then n +. 1.0 else n

let get_area n r =
  let alpha = tau /. n in
  let a_tri = r *. r /. 2.0 *. (sin alpha) in
  n *. a_tri

let _ =
  let (a,b,c) = read_points () in
  let center = get_circumcenter a b c in
  let corners = get_corners center a b c in
  Printf.eprintf "  n=%f\n" corners;
  get_area corners (dist center a) |> Printf.printf "%f\n"


open Scanf
open Num
open Printf
open String

let (w,h) = Scanf.bscanf Scanf.Scanning.stdin "%d %d " ( fun x y -> x,y) ;;

let area = w * h;;
let ntotal = ref 0;;

let () =
  if (area < 2) then
    ntotal := 0
  else
    begin
      if (w >= 2) then
        let nw = w / 2 in
        ntotal := !ntotal + (nw* h);
        ntotal := !ntotal + ((w mod 2)*(h/2))
      else
        ntotal := !ntotal + (h/2)
    end
;;

let () = print_int !ntotal; print_endline "";;


let _ =
   let l = Scanf.scanf "%d %d %d %d %d" (fun a b c d e -> [a;b;c;d;e]) in
   let tab = Array.of_list (List.sort compare l) in
   let maxi = ref 0 in
      for i = 0 to 3 do
         if tab.(i) = tab.(i+1)
         then maxi := max !maxi (2 * tab.(i));
      done;
      for i = 0 to 2 do
         if tab.(i) = tab.(i+1) && tab.(i+1) = tab.(i+2)
         then maxi := max !maxi (3 * tab.(i));
      done;
      Printf.printf "%d" (List.fold_left (+) (- !maxi) l)


let input () = Scanf.scanf "%d %d %d %d %d" (fun a b c d e -> a + b + c + d + e)
let solve sum =
    if sum mod 5 <> 0 || sum = 0
    then
        Printf.printf "-1\n"
    else
        Printf.printf "%d\n" (sum / 5)

let () = solve(input())


open Printf;;

let split_on_whitespace s =
  Str.split (Str.regexp "[ \t]+") s
;;

let s = read_line() in
let three_numbers = split_on_whitespace s in
let int_list = List.map int_of_string three_numbers in
let k = List.nth int_list 0 in
let w = List.nth int_list 1 in
let n = List.nth int_list 2 in
let cost = k*(n*(n+1)/2) in
printf "%d\n" (max 0 (cost - w))


let read_int()=Scanf.scanf "%d " (fun x->x);;
let n=read_int();;
let k=read_int();;
let x=read_int();;
let l=ref [];;
for i=1 to n-1 do
   l:=(read_int(),1)::(!l)
done;;
l:=(Scanf.scanf "%d" (fun x->x),1)::(!l);;

let rec avance=function
|[]->[]
|(h,a)::[]->(h,a)::[]
|(h,a)::(g,b)::t->if h<>g then (h,a)::(avance ((g,b)::t))
                  else if a+b>2 then avance t
                  else (h,a+b)::(avance t);;

let rec est_fige=function
|[]->true
|(h,a)::[]->true
|(h,a)::(g,b)::t->if h<>g then est_fige ((g,b)::t)
                  else false;;

let rec taille=function
|[]->0
|(_,_)::t->1+taille t;;

let rec taille2=function
|[]->0
|(_,a)::t->a+taille2 t;;

let init=taille !l;;

let rec ajout i=function
|[]->([],false)
|(h,a)::t->if i>1 then let (m,b)=ajout (i-1) t in ((h,a)::m,b)
           else if x=h then (if a=2 then (t,true) else ((h,a+1)::t,true))
           else ([],false);;

let rec faire liste=
   if est_fige liste then liste else faire (avance liste);;

let maxi=ref 0;;

for i=1 to init do
   let (m,b)=ajout i !l in
   if b then maxi:=max !maxi (init-taille2 (faire m))
done;;

print_int !maxi;;


open Printf open Scanf
module Lib = struct
  let i32,i64,ist = Int64.(to_int,of_int,to_string)
  let (+$) = (+) let (-$) = (-) let (/$) = (/) let ( *$) = ( * ) let (%$) = (mod)
  let labs = Int64.abs
  let (+),(-),( * ),(/),(mod),(%) = Int64.(add,sub,mul,div,rem,rem)
  let (+=) r v = r := !r + v
  let (-=) r v = r := !r - v
  let ( *= ) r v = r := !r * v
  let (/=) r v = r := !r / v
  let (%=) r v = r := !r % v
  let max_i64_lim,min_i64_lim = Int64.(max_int,min_int)
  let max_i64,min_i64 = 2000000000000000000L,-2000000000000000000L
  (* math *)
  let ceildiv p q = (p+q-1L) / q
  let rec gcd m n = match m,n with | m,0L -> m | m,n -> gcd n (m mod n)
  let lcm m n = m / gcd m n * n
  module Int64_infix = struct
    let (land),(lor),(lxor),lnot,(lsl),(lsr),(asr) =
      let open Int64 in
      (logand),(logor),(logxor),lognot,
      (fun u v -> shift_left u (i32 v)),
      (fun u v -> shift_right u (i32 v)),
      (fun u v -> shift_right_logical u (i32 v))
  end
  let pow n k =
    let rec f a n = function
    | 0L -> a | 1L -> n*a | k when k mod 2L = 0L -> f a (n*n) (k/2L) | k -> f (a*n) (n*n) (k/2L)
    in f 1L n k
  (* input *)
  let input_i64_array n = Array.init (i32 n) (fun _ -> Scanf.scanf " %Ld" (fun v -> v)) let iia = input_i64_array
  let get_i64 _ = Scanf.scanf " %Ld" (fun v -> v) let gi = get_i64
  let get_2_i64 _ = Scanf.scanf " %Ld %Ld" (fun u v -> u,v) let g2 = get_2_i64
  let get_3_i64 _ = Scanf.scanf " %Ld %Ld %Ld" (fun u v w -> u,v,w) let g3 = get_3_i64
  let get_4_i64 _ = Scanf.scanf " %Ld %Ld %Ld %Ld" (fun u v w x -> u,v,w,x) let g4 = get_4_i64
  let get_5_i64 _ = Scanf.scanf " %Ld %Ld %Ld %Ld %Ld" (fun u v w x y -> u,v,w,x,y) let g5 = get_5_i64
  let i32_get_int _ = Scanf.scanf " %d" (fun v -> v) let i32_get_2_ints _ = Scanf.scanf " %d %d" (fun u v -> u,v) let i32_get_3_ints _ = Scanf.scanf " %d %d %d" (fun u v w -> u,v,w) let i32_get_4_ints _ = Scanf.scanf " %d %d %d %d" (fun u v w x -> u,v,w,x) let i32_get_5_ints _ = Scanf.scanf " %d %d %d %d %d" (fun u v w x y -> u,v,w,x,y)
  (* utils *)
  external id : 'a -> 'a = "%identity"
  let ( *< ) f g x = f (g x)
  let ( *> ) f g x = g (f x)
  let rv f p q = f q p (* ex. 24 |> rv (/) 6 *)
  let alen a = i64 @@ Array.length a
  let llen l = i64 @@  List.length l
  let slen s = String.length s
  let string_of_list ?(separator=" ") f ls = ls |> List.map f |> String.concat separator
  let string_of_array ?(separator=" ") f a = a |> Array.to_list |> string_of_list ~separator f
  let char_list_of_string str = let rec f0 i a = if i<0 then a else f0 (i-$1) (str.[i]::a) in f0 (String.length str -$ 1) []
  let string_of_char_list ls = List.fold_left (fun u v -> u ^ (String.make 1 v)) "" ls
  let fail _ = failwith "fail"
  let dx,dy = [|1;0;-1;0|],[|0;1;0;-1|]
  let range l r = let ls = ref [] in for i=i32 l to i32 r do ls := i :: !ls done;!ls |> List.rev
  let cartesian_product u v = u |> List.map (fun p -> List.map (fun q -> p,q) v) |> List.flatten
  let shuffle a = Array.sort (fun _ _ -> (Random.int 3) -$ 1) a
  let binary_search ng ok f = let d = if ng < ok then 1L else -1L in
    let rec f0 ng ok =
      if labs (ok - ng) <= 1L then ok
      else let mid = ng + (ok - ng) / 2L in if f mid then f0 ng mid else f0 mid ok
    in f0 (ng-1L*d) (ok+1L*d)
  let lower_bound a v = binary_search 0L (alen a - 1L) (fun i -> a.(i32 i) >= v)
  let upper_bound a v = binary_search 0L (alen a - 1L) (fun i -> a.(i32 i) >  v)
  let equal_range a v = lower_bound a v, upper_bound a v (* #=snd-fst *)
  let rec fix f x = f (fix f) x
  let fix_memo ?(size=10000) f x =
    let tb = Hashtbl.create ~random:true size in
    let rec f0 x =
      try Hashtbl.find tb x with
      | Not_found -> (let v = f f0 x in Hashtbl.add tb x v; v)
    in f0 x
  (* imperative *)
  let rep f t ?(stride=1L) fbod = let i = ref f in while !i <= t do fbod !i; i := !i + stride done
  let repb f t ?(stride=1L) fbod = let i,c = ref f,ref true in while !i <= t && !c do
    match fbod !i with | `Break -> c := false | `Ok -> i := !i + stride done
  let repm f t ?(stride=1L) m0 fbod =
    let i,c,m = ref f,ref true,ref m0 in
    while !i<=t && !c do match fbod !m !i with
    | `Break -> c := false | `Break_m m' -> (c := false; m := m') | `Ok m' -> m := m'; i := !i + stride done; !m
  let repi f t ?(stride=1) fbod = let i = ref f in while !i <= t do fbod !i; i := !i +$ stride done
  let repib f t ?(stride=1) fbod = let i,c = ref f,ref true in while !i <= t && !c do
    match fbod !i with | `Break -> c := false | `Ok -> i := !i +$ stride done
  let repim f t ?(stride=1) m0 fbod =
    let i,c,m = ref f,ref true,ref m0 in
    while !i<=t && !c do match fbod !m !i with
    | `Break -> c := false | `Break_m m' -> (c := false; m := m') | `Ok m' -> m := m'; i := !i +$ stride done; !m
  let rep_rev f t ?(stride=1L) fbod = rep t f ~stride @@ fun v -> fbod @@ f + t - v
  let repb_rev f t ?(stride=1L) fbod = repb t f ~stride @@ fun v -> fbod @@ f + t - v
  let repm_rev f t ?(stride=1L) m0 fbod = repm f t ~stride m0 @@ fun u v -> fbod u @@ f + t - v
  let repi_rev f t ?(stride=1) fbod = repi t f ~stride @@ fun v -> fbod @@ f +$ t -$ v
  let repib_rev f t ?(stride=1) fbod = repib t f ~stride @@ fun v -> fbod @@ f +$ t -$ v
  let repim_rev f t ?(stride=1) m0 fbod = repim f t ~stride m0 @@ fun u v -> fbod u @@ f +$ t -$ v
  (* output *)
  let print_list_mle f ls = string_of_list f ls |> print_endline
  let print_array_mle f a = string_of_array f a |> print_endline
  let print_list f ls = ls |> List.iter (fun v -> printf "%s " @@ f v); print_newline ()
  let print_array f a = a |> Array.iter (fun v -> printf "%s " @@ f v); print_newline ()
  (* debug *)
  let dump_2darr f a = a |> Array.iter (fun b -> print_array f b)
  let dump_i64_list ls = print_list ist ls
  let dump_i64_array a = print_array ist a
end open Lib open Array

let () =
  let n = gi 0 in
  let a = fix (fun f i x ->
    if i*i > 2000000000L then x
    else f (i+1L) ((i*i)::x)
  ) 1L [] |> List.sort compare |> of_list in
  let k = lower_bound a n in
  let p = Int64.(a.(i32 k) |> to_float |> sqrt |> of_float) in
  let q = ceildiv n p in
  (* printf "%Ld :: %Ld :: %Ld :: %Ld\n" n k p q; *)
  printf "%Ld" @@ p+q

  (* let m = n |> Int64.to_float |> sqrt in
  let p,q = m |> floor |> Int64.of_float,
    m |> ceil |> Int64.of_float in
  (* rep m (m+100L) (fun m ->
    if m*m >
  ) *)
  printf "%Ld %Ld %Ld\n" n p q *)