





import math





class 						_A:


				"""simple docstring"""


				def __init__(      self					, _A					):
									__A     :						Optional[Any]          =    len(_A					)
									__A     :						Tuple          =    [0] * (
									    4 * self.N
									)  # approximate the overall size of segment tree with array N
									self.build(1					, 0					, self.N - 1					)



				def  UpperCAmelCase_		(      self					, _A					):
									return idx * 2



				def  UpperCAmelCase_		(      self					, _A					):
									return idx * 2 + 1



				def  UpperCAmelCase_		(      self					, _A					, _A					, _A					):  # noqa: E741
									if l == r:
														__A     :						Optional[int]          =    A[l]
									else:
														__A     :						int          =    (l + r) // 2
														self.build(self.left(_A					)					, _A					, _A					)
														self.build(self.right(_A					)					, mid + 1					, _A					)
														__A     :						Any          =    max(self.st[self.left(_A					)]					, self.st[self.right(_A					)]					)



				def  UpperCAmelCase_		(      self					, _A					, _A					, _A					):
									return self.update_recursive(1					, 0					, self.N - 1					, a - 1					, b - 1					, _A					)



				def  UpperCAmelCase_		(      self					, _A					, _A					, _A					, _A					, _A					, _A					):  # noqa: E741
									if r < a or l > b:
														return True
									if l == r:
														__A     :						Optional[int]          =    val
														return True
									__A     :						Union[str, Any]          =    (l + r) // 2
									self.update_recursive(self.left(_A					)					, _A					, _A					, _A					, _A					, _A					)
									self.update_recursive(self.right(_A					)					, mid + 1					, _A					, _A					, _A					, _A					)
									__A     :						List[str]          =    max(self.st[self.left(_A					)]					, self.st[self.right(_A					)]					)
									return True



				def  UpperCAmelCase_		(      self					, _A					, _A					):
									return self.query_recursive(1					, 0					, self.N - 1					, a - 1					, b - 1					)



				def  UpperCAmelCase_		(      self					, _A					, _A					, _A					, _A					, _A					):  # noqa: E741
									if r < a or l > b:
														return -math.inf
									if l >= a and r <= b:
														return self.st[idx]
									__A     :						Optional[Any]          =    (l + r) // 2
									__A     :						Union[str, Any]          =    self.query_recursive(self.left(_A					)					, _A					, _A					, _A					, _A					)
									__A     :						Tuple          =    self.query_recursive(self.right(_A					)					, mid + 1					, _A					, _A					, _A					)
									return max(_A					, _A					)





				def  UpperCAmelCase_		(      self					):
									__A     :						int          =    []
									for i in range(1					, N + 1					):
														show_list += [self.query(_A					, _A					)]
									print(_A					)


if __name__ == "__main__":
				UpperCAmelCase						:       Dict        =					[1, 2, -4, 7, 3, -5, 6, 11, -20, 9, 14, 15, 5, 2, -8]
				UpperCAmelCase						:       Any        =					15
				UpperCAmelCase						:       Tuple        =					SegmentTree(A)
				print(segt.query(4, 6))
				print(segt.query(7, 11))
				print(segt.query(7, 12))
				segt.update(1, 3, 1_11)
				print(segt.query(1, 15))
				segt.update(7, 8, 2_35)
				segt.show_data()











from .hash_table import HashTable





class 						_A( snake_case__       ):


				"""simple docstring"""


				def __init__(      self					, *_A					, **_A					):
									super().__init__(*_A					, **_A					)





				def  UpperCAmelCase_		(      self					, _A					, _A=None					):
									__A     :						Optional[int]          =    1
									__A     :						Union[str, Any]          =    self.hash_function(key + i * i					)

									while self.values[new_key] is not None and self.values[new_key] != key:
														i += 1
														__A     :						Tuple          =    (
														    self.hash_function(key + i * i					)
														    if not self.balanced_factor() >= self.lim_charge
														    else None
														)

														if new_key is None:
																			break

									return new_key




