'''simple docstring'''

from __future__ import annotations

import math


class 				_lowercase	:
 '''simple docstring'''


 def __init__(				self					,lowerCamelCase_							)			->			None:



    '''simple docstring'''



    UpperCAmelCase__							:				List[Any]   				=  size
    # approximate the overall size of segment tree with given value
    UpperCAmelCase__							:				Optional[Any]   				=  [0 for i in range(0					,4 * size							)]
    # create array to store lazy update
    UpperCAmelCase__							:				Tuple   				=  [0 for i in range(0					,4 * size							)]
    UpperCAmelCase__							:				Optional[Any]   				=  [0 for i in range(0					,4 * size							)]  # flag for lazy update




 def 		lowerCAmelCase__					(				self					,lowerCamelCase_							)			->			int:



    '''simple docstring'''



    return idx * 2




 def 		lowerCAmelCase__					(				self					,lowerCamelCase_							)			->			int:



    '''simple docstring'''



    return idx * 2 + 1




 def 		lowerCAmelCase__					(				self					,lowerCamelCase_					,lowerCamelCase_					,lowerCamelCase_					,lowerCamelCase_							)			->			None:



    '''simple docstring'''



    if left_element == right_element:
       UpperCAmelCase__							:				Optional[int]   				=  a[left_element - 1]
    else:
       UpperCAmelCase__							:				List[Any]   				=  (left_element + right_element) // 2
       self.build(self.left(lowerCamelCase_							)					,lowerCamelCase_					,lowerCamelCase_					,lowerCamelCase_							)
       self.build(self.right(lowerCamelCase_							)					,mid + 1					,lowerCamelCase_					,lowerCamelCase_							)
       UpperCAmelCase__							:				int   				=  max(
           self.segment_tree[self.left(lowerCamelCase_							)]					,self.segment_tree[self.right(lowerCamelCase_							)]							)




 def 		lowerCAmelCase__					(				self					,lowerCamelCase_					,lowerCamelCase_					,lowerCamelCase_					,lowerCamelCase_					,lowerCamelCase_					,lowerCamelCase_							)			->			bool:



    '''simple docstring'''



    if self.flag[idx] is True:
       UpperCAmelCase__							:				Optional[Any]   				=  self.lazy[idx]
       UpperCAmelCase__							:				Optional[Any]   				=  False
       if left_element != right_element:
          UpperCAmelCase__							:				Optional[Any]   				=  self.lazy[idx]
          UpperCAmelCase__							:				List[Any]   				=  self.lazy[idx]
          UpperCAmelCase__							:				List[Any]   				=  True
          UpperCAmelCase__							:				Tuple   				=  True

    if right_element < a or left_element > b:
       return True
    if left_element >= a and right_element <= b:
       UpperCAmelCase__							:				Union[str, Any]   				=  val
       if left_element != right_element:
          UpperCAmelCase__							:				List[str]   				=  val
          UpperCAmelCase__							:				List[str]   				=  val
          UpperCAmelCase__							:				Optional[int]   				=  True
          UpperCAmelCase__							:				Any   				=  True
       return True
    UpperCAmelCase__							:				str   				=  (left_element + right_element) // 2
    self.update(self.left(lowerCamelCase_							)					,lowerCamelCase_					,lowerCamelCase_					,lowerCamelCase_					,lowerCamelCase_					,lowerCamelCase_							)
    self.update(self.right(lowerCamelCase_							)					,mid + 1					,lowerCamelCase_					,lowerCamelCase_					,lowerCamelCase_					,lowerCamelCase_							)
    UpperCAmelCase__							:				Dict   				=  max(
        self.segment_tree[self.left(lowerCamelCase_							)]					,self.segment_tree[self.right(lowerCamelCase_							)]							)
    return True




 def 		lowerCAmelCase__					(				self					,lowerCamelCase_					,lowerCamelCase_					,lowerCamelCase_					,lowerCamelCase_					,lowerCamelCase_							)			->			int | float:



    '''simple docstring'''



    if self.flag[idx] is True:
       UpperCAmelCase__							:				int   				=  self.lazy[idx]
       UpperCAmelCase__							:				Optional[int]   				=  False
       if left_element != right_element:
          UpperCAmelCase__							:				str   				=  self.lazy[idx]
          UpperCAmelCase__							:				int   				=  self.lazy[idx]
          UpperCAmelCase__							:				Optional[Any]   				=  True
          UpperCAmelCase__							:				Tuple   				=  True
    if right_element < a or left_element > b:
       return -math.inf
    if left_element >= a and right_element <= b:
       return self.segment_tree[idx]
    UpperCAmelCase__							:				int   				=  (left_element + right_element) // 2
    UpperCAmelCase__							:				Optional[int]   				=  self.query(self.left(lowerCamelCase_							)					,lowerCamelCase_					,lowerCamelCase_					,lowerCamelCase_					,lowerCamelCase_							)
    UpperCAmelCase__							:				Any   				=  self.query(self.right(lowerCamelCase_							)					,mid + 1					,lowerCamelCase_					,lowerCamelCase_					,lowerCamelCase_							)
    return max(lowerCamelCase_					,lowerCamelCase_							)




 def __str__(				self							)			->			str:



    '''simple docstring'''



    return str([self.query(1					,1					,self.size					,lowerCamelCase_					,lowerCamelCase_							) for i in range(1					,self.size + 1							)]							)


if __name__ == "__main__":
  UpperCamelCase__     :	int				=			[1, 2, -4, 7, 3, -5, 6, 11, -20, 9, 14, 15, 5, 2, -8]
  UpperCamelCase__     :	Optional[int]				=			15
  UpperCamelCase__     :	Union[str, Any]				=			SegmentTree(size)
  segt.build(1, 1, size, A)
  print(segt.query(1, 1, size, 4, 6))
  print(segt.query(1, 1, size, 7, 11))
  print(segt.query(1, 1, size, 7, 12))
  segt.update(1, 1, size, 1, 3, 111)
  print(segt.query(1, 1, size, 1, 15))
  segt.update(1, 1, size, 7, 8, 235)
  print(segt)





'''simple docstring'''

import math







def __UpperCamelCase(   _A					:				float  ,			_A					:				float    ):
   '''simple docstring'''
   return math.pow(_A  ,			2    ) - a







def __UpperCamelCase(   _A					:				float    ):
   '''simple docstring'''
   return 2 * x







def __UpperCamelCase(   _A					:				float    ):
   '''simple docstring'''
   UpperCAmelCase__							:				int   				=  2.0

   while start <= a:
      UpperCAmelCase__							:				int   				=  math.pow(_A  ,			2    )

   return start







def __UpperCamelCase(   _A					:				float  ,			_A					:				int = 99_99  ,			_A					:				float = 0.0_0_0_0_0_0_0_0_0_0_0_0_0_1    ):
   '''simple docstring'''

   if a < 0:
      raise ValueError('''math domain error'''    )

   UpperCAmelCase__							:				Any   				=  get_initial_point(_A    )

   for _ in range(_A    ):
      UpperCAmelCase__							:				Optional[Any]   				=  value
      UpperCAmelCase__							:				Tuple   				=  value - fx(_A  ,			_A    ) / fx_derivative(_A    )
      if abs(prev_value - value    ) < tolerance:
         return value

   return value


if __name__ == "__main__":
  from doctest import testmod

  testmod()




