


from __future__ import annotations

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

_snake_case	:						Union[str, Any]         =							TypeVar("T")

class 							a						(Generic[T] ):




							"""simple docstring"""


							def __init__(				self			:    Tuple       ,      lowerCamelCase			:    list[T]       ,      lowerCamelCase			:    Callable[[T, T], T]							)      ->       None:
														__snake_case						:     Any | T									=  None

														__snake_case						:     int									=  len(lowerCamelCase							)
														__snake_case						:     list[T]									=  [any_type for _ in range(self.N							)] + arr
														__snake_case						:     Tuple									=  fnc
														self.build()

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

							def        __snake_case   (				self			:    Optional[Any]       ,      lowerCamelCase			:    int       ,      lowerCamelCase			:    T							)      ->       None:
														p += self.N
														__snake_case						:     str									=  v
														while p > 1:
																					__snake_case						:     Dict									=  p // 2
																					__snake_case						:     Optional[Any]									=  self.fn(self.st[p * 2]       ,      self.st[p * 2 + 1]							)






							def        __snake_case   (				self			:    List[str]       ,      lowerCamelCase			:    int       ,      lowerCamelCase			:    int							)      ->       T | None:  # noqa: E741
														__snake_case					,     __snake_case						:     Optional[int]									=  l + self.N, r + self.N

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


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

			_snake_case	:						Union[str, Any]         =							[1, 10, -2, 9, -3, 8, 4, -7, 5, 6, 11, -12]

			_snake_case	:						Dict         =							{
			    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[Any]         =							SegmentTree(test_array, min)
			_snake_case	:						Optional[Any]         =							SegmentTree(test_array, max)
			_snake_case	:						Optional[Any]         =							SegmentTree(test_array, lambda a, b: a + b)







			def 							lowerCAmelCase_	(   ):
										for i in range(len(__lowerCamelCase      )      ):
																	for j in range(__lowerCamelCase				,      len(__lowerCamelCase      )      ):
																								__snake_case						:     Optional[int]									=  reduce(__lowerCamelCase				,      test_array[i : j + 1]      )
																								__snake_case						:     List[Any]									=  reduce(__lowerCamelCase				,      test_array[i : j + 1]      )
																								__snake_case						:     Union[str, Any]									=  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():
						_snake_case	:						List[Any]         =							value
						min_segment_tree.update(index, value)
						max_segment_tree.update(index, value)
						sum_segment_tree.update(index, value)
						test_all_segments()








def 		lowerCAmelCase  (	UpperCamelCase__   :   int       ,			UpperCamelCase__   :   float       ,			UpperCamelCase__   :   float					)      ->    float:

						"""simple docstring"""





						return round(float(moles / volume					) * nfactor					)






def 		lowerCAmelCase  (	UpperCamelCase__   :   float       ,			UpperCamelCase__   :   float       ,			UpperCamelCase__   :   float					)      ->    float:

						"""simple docstring"""





						return round(float((moles * 0.08_21 * temperature) / (volume)					)					)






def 		lowerCAmelCase  (	UpperCamelCase__   :   float       ,			UpperCamelCase__   :   float       ,			UpperCamelCase__   :   float					)      ->    float:

						"""simple docstring"""





						return round(float((moles * 0.08_21 * temperature) / (pressure)					)					)






def 		lowerCAmelCase  (	UpperCamelCase__   :   float       ,			UpperCamelCase__   :   float       ,			UpperCamelCase__   :   float					)      ->    float:

						"""simple docstring"""





						return round(float((pressure * volume) / (0.08_21 * moles)					)					)


if __name__ == "__main__":
							import doctest

							doctest.testmod()



