





'''simple docstring'''

from __future__ import annotations

from collections.abc import Callable
from typing import Any, Generic, TypeVar

UpperCAmelCase					:		List[str]		=							TypeVar('T')





class lowerCamelCase						(Generic[T]					):







  def __init__(		self     ,     lowercase__     ,     lowercase__		)		->						None:






        """simple docstring"""





        _snake_case		:	Any | T					     =     None

        _snake_case		:	int					     =     len(lowercase__		)
        _snake_case		:	list[T]					     =     [any_type for _ in range(self.N		)] + arr
        _snake_case		:	Optional[Any]					     =     fnc
        self.build()







  def 				UpperCAmelCase_				(		self		)		->						None:






        """simple docstring"""





        for p in range(self.N - 1     ,     0     ,     -1		):
              _snake_case		:	Optional[int]					     =     self.fn(self.st[p * 2]     ,     self.st[p * 2 + 1]		)







  def 				UpperCAmelCase_				(		self     ,     lowercase__     ,     lowercase__		)		->						None:






        """simple docstring"""





        p += self.N
        _snake_case		:	int					     =     v
        while p > 1:
              _snake_case		:	str					     =     p // 2
              _snake_case		:	str					     =     self.fn(self.st[p * 2]     ,     self.st[p * 2 + 1]		)







  def 				UpperCAmelCase_				(		self     ,     lowercase__     ,     lowercase__		)		->						T | None:  # noqa: E741






        """simple docstring"""





        _snake_case     ,							_snake_case		:	Optional[Any]					     =     l + self.N, r + self.N

        _snake_case		:	T | None					     =     None
        while l <= r:
              if l % 2 == 1:
                    _snake_case		:	Any					     =     self.st[l] if res is None else self.fn(lowercase__     ,     self.st[l]		)
              if r % 2 == 0:
                    _snake_case		:	List[str]					     =     self.st[r] if res is None else self.fn(lowercase__     ,     self.st[r]		)
              _snake_case     ,							_snake_case		:	Any					     =     (l + 1) // 2, (r - 1) // 2
        return res


if __name__ == "__main__":
   from functools import reduce

   UpperCAmelCase					:		Any		=							[1, 1_0, -2, 9, -3, 8, 4, -7, 5, 6, 1_1, -1_2]

   UpperCAmelCase					:		Union[str, Any]		=							{
       0: 7,
       1: 2,
       2: 6,
       3: -1_4,
       4: 5,
       5: 4,
       6: 7,
       7: -1_0,
       8: 9,
       9: 1_0,
       1_0: 1_2,
       1_1: 1,
   }

   UpperCAmelCase					:		Optional[int]		=							SegmentTree(test_array, min)
   UpperCAmelCase					:		Dict		=							SegmentTree(test_array, max)
   UpperCAmelCase					:		Tuple		=							SegmentTree(test_array, lambda a, b: a + b)




   def    _a    (							):





         """simple docstring"""



         for i in range(len(lowerCAmelCase_	)	):
               for j in range(lowerCAmelCase_			,      len(lowerCAmelCase_	)	):
                     _snake_case		:	List[str]					     =     reduce(lowerCAmelCase_			,      test_array[i : j + 1]	)
                     _snake_case		:	Optional[int]					     =     reduce(lowerCAmelCase_			,      test_array[i : j + 1]	)
                     _snake_case		:	Dict					     =     reduce(lambda lowerCAmelCase_			,      lowerCAmelCase_	: a + b			,      test_array[i : j + 1]	)
                     assert min_range == min_segment_tree.query(lowerCAmelCase_			,      lowerCAmelCase_	)
                     assert max_range == max_segment_tree.query(lowerCAmelCase_			,      lowerCAmelCase_	)
                     assert sum_range == sum_segment_tree.query(lowerCAmelCase_			,      lowerCAmelCase_	)

   test_all_segments()

   for index, value in test_updates.items():
      UpperCAmelCase					:		Tuple		=							value
      min_segment_tree.update(index, value)
      max_segment_tree.update(index, value)
      sum_segment_tree.update(index, value)
      test_all_segments()









'''simple docstring'''

import math

from numpy import inf
from scipy.integrate import quad




def    _a    (							lowerCAmelCase_	):





      """simple docstring"""



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

      return quad(lowerCAmelCase_			,      0			,      lowerCAmelCase_			,      args=(lowerCAmelCase_)	)[0]




def    _a    (							lowerCAmelCase_			,      lowerCAmelCase_	):





      """simple docstring"""



      return math.pow(lowerCAmelCase_			,      z - 1	) * math.exp(-x	)


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

   testmod()


