





'''simple docstring'''


from __future__ import annotations

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

_SCREAMING_SNAKE_CASE	 =							TypeVar("T")

class    lowerCAmelCase_		(		Generic[T]		):




 def __init__(	self			,     _lowerCAmelCase			,     _lowerCAmelCase		)    ->							None:
     _lowerCAmelCase				=      None

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




 def 							_snake_case   (	self		)    ->							None:
     for p in range(self.N - 1			,     0			,     -1		):
         _lowerCAmelCase				=      self.fn(self.st[p * 2]			,     self.st[p * 2 + 1]		)




 def 							_snake_case   (	self			,     _lowerCAmelCase			,     _lowerCAmelCase		)    ->							None:
     p += self.N
     _lowerCAmelCase				=      v
     while p > 1:
         _lowerCAmelCase				=      p // 2
         _lowerCAmelCase				=      self.fn(self.st[p * 2]			,     self.st[p * 2 + 1]		)





 def 							_snake_case   (	self			,     _lowerCAmelCase			,     _lowerCAmelCase		)    ->							T | None:  # noqa: E741
     _lowerCAmelCase			,			_lowerCAmelCase				=      l + self.N, r + self.N

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


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

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

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

       _SCREAMING_SNAKE_CASE	 =							SegmentTree(test_array, min)
       _SCREAMING_SNAKE_CASE	 =							SegmentTree(test_array, max)
       _SCREAMING_SNAKE_CASE	 =							SegmentTree(test_array, lambda a, b: a + b)


       def 	__a():



           '''simple docstring'''





           for i in range(len(SCREAMING_SNAKE_CASE_    )    ):
               for j in range(SCREAMING_SNAKE_CASE_		,       len(SCREAMING_SNAKE_CASE_    )    ):
                   _lowerCAmelCase				=      reduce(SCREAMING_SNAKE_CASE_		,       test_array[i : j + 1]    )
                   _lowerCAmelCase				=      reduce(SCREAMING_SNAKE_CASE_		,       test_array[i : j + 1]    )
                   _lowerCAmelCase				=      reduce(lambda SCREAMING_SNAKE_CASE_		,       SCREAMING_SNAKE_CASE_    : a + b		,       test_array[i : j + 1]    )
                   assert min_range == min_segment_tree.query(SCREAMING_SNAKE_CASE_		,       SCREAMING_SNAKE_CASE_    )
                   assert max_range == max_segment_tree.query(SCREAMING_SNAKE_CASE_		,       SCREAMING_SNAKE_CASE_    )
                   assert sum_range == sum_segment_tree.query(SCREAMING_SNAKE_CASE_		,       SCREAMING_SNAKE_CASE_    )

       test_all_segments()

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









'''simple docstring'''


def 	__a(SCREAMING_SNAKE_CASE_  :					str		,       SCREAMING_SNAKE_CASE_  :					bool = False    ):



    '''simple docstring'''





    if not isinstance(SCREAMING_SNAKE_CASE_		,       SCREAMING_SNAKE_CASE_    ):
        _lowerCAmelCase				=      F'''Expected string as input, found {type(SCREAMING_SNAKE_CASE_    )}'''
        raise ValueError(SCREAMING_SNAKE_CASE_    )
    if not isinstance(SCREAMING_SNAKE_CASE_		,       SCREAMING_SNAKE_CASE_    ):
        _lowerCAmelCase				=      F'''Expected boolean as use_pascal parameter, found {type(SCREAMING_SNAKE_CASE_    )}'''
        raise ValueError(SCREAMING_SNAKE_CASE_    )

    _lowerCAmelCase				=      input_str.split("_"    )

    _lowerCAmelCase				=      0 if use_pascal else 1

    _lowerCAmelCase				=      words[start_index:]

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

    _lowerCAmelCase				=      "" if use_pascal else words[0]

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


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

       testmod()


