



from __future__ import annotations

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

__snake_case		:int   	=  TypeVar('''T''')

class 					_A (			Generic[T]					):



       def __init__(	self							:  Tuple  ,	__SCREAMING_SNAKE_CASE							:  list[T]  ,	__SCREAMING_SNAKE_CASE							:  Callable[[T, T], T]):


           '''simple docstring'''

           __a		 =       None

           __a		 =       len(__SCREAMING_SNAKE_CASE)
           __a		 =       [any_type for _ in range(self.N)] + arr
           __a		 =       fnc
           self.build()



       def 	_lowerCamelCase    (	self							:  Optional[int]):


           '''simple docstring'''

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



       def 	_lowerCamelCase    (	self							:  List[Any]  ,	__SCREAMING_SNAKE_CASE							:  int  ,	__SCREAMING_SNAKE_CASE							:  T):


           '''simple docstring'''

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





       def 	_lowerCamelCase    (	self							:  List[Any]  ,	__SCREAMING_SNAKE_CASE							:  int  ,	__SCREAMING_SNAKE_CASE							:  int):  # noqa: E741


           '''simple docstring'''

           __a ,     __a		 =       l + self.N, r + self.N

           __a		 =       None
           while l <= r:
               if l % 2 == 1:
                   __a		 =       self.st[l] if res is None else self.fn(__SCREAMING_SNAKE_CASE  ,	self.st[l])
               if r % 2 == 0:
                   __a		 =       self.st[r] if res is None else self.fn(__SCREAMING_SNAKE_CASE  ,	self.st[r])
               __a ,     __a		 =       (l + 1) // 2, (r - 1) // 2
           return res


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

 __snake_case		:int   	=  [1, 10, -2, 9, -3, 8, 4, -7, 5, 6, 11, -12]

 __snake_case		:Tuple   	=  {
     0: 7,
     1: 2,
     2: 6,
     3: -14,
     4: 5,
     5: 4,
     6: 7,
     7: -10,
     8: 9,
     9: 10,
     10: 12,
     11: 1,
 }

 __snake_case		:Optional[int]   	=  SegmentTree(test_array, min)
 __snake_case		:Union[str, Any]   	=  SegmentTree(test_array, max)
 __snake_case		:str   	=  SegmentTree(test_array, lambda a, b: a + b)





 def   __snake_case			(    )     ->   List[Any]:
     for i in range(len(_UpperCAmelCase       )       ):
         for j in range(_UpperCAmelCase     ,				len(_UpperCAmelCase       )       ):
             __a		 =       reduce(_UpperCAmelCase     ,				test_array[i : j + 1]       )
             __a		 =       reduce(_UpperCAmelCase     ,				test_array[i : j + 1]       )
             __a		 =       reduce(lambda _UpperCAmelCase     ,				_UpperCAmelCase       : a + b     ,				test_array[i : j + 1]       )
             assert min_range == min_segment_tree.query(_UpperCAmelCase     ,				_UpperCAmelCase       )
             assert max_range == max_segment_tree.query(_UpperCAmelCase     ,				_UpperCAmelCase       )
             assert sum_range == sum_segment_tree.query(_UpperCAmelCase     ,				_UpperCAmelCase       )

 test_all_segments()

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










def   __snake_case			(    _UpperCAmelCase     ,				_UpperCAmelCase = False       ):

    if not isinstance(_UpperCAmelCase     ,				_UpperCAmelCase       ):
        __a		 =       f'Expected string as input, found {type(_UpperCAmelCase       )}'
        raise ValueError(_UpperCAmelCase       )
    if not isinstance(_UpperCAmelCase     ,				_UpperCAmelCase       ):
        __a		 =       f'Expected boolean as use_pascal parameter, found {type(_UpperCAmelCase       )}'
        raise ValueError(_UpperCAmelCase       )

    __a		 =       input_str.split('''_'''       )

    __a		 =       0 if use_pascal else 1

    __a		 =       words[start_index:]

    __a		 =       [word[0].upper() + word[1:] for word in words_to_capitalize]

    __a		 =       '''''' if use_pascal else words[0]

    return "".join([initial_word, *capitalized_words]       )


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

 testmod()





