



from __future__ import annotations

import math
class 				__A					:





			def __init__(self							,    __magic_name__				):
						lowerCamelCase__ :      Optional[Any]								=		size
						# approximate the overall size of segment tree with given value
						lowerCamelCase__ :      Tuple								=		[0 for i in range(0							,    4 * size				)]
						# create array to store lazy update
						lowerCamelCase__ :      List[Any]								=		[0 for i in range(0							,    4 * size				)]
						lowerCamelCase__ :      Any								=		[0 for i in range(0							,    4 * size				)]  # flag for lazy update





			def        _snake_case    (self							,    __magic_name__				):
						return idx * 2





			def        _snake_case    (self							,    __magic_name__				):
						return idx * 2 + 1





			def        _snake_case    (self							,    __magic_name__							,    __magic_name__							,    __magic_name__							,    __magic_name__				):
						if left_element == right_element:
									lowerCamelCase__ :      Dict								=		a[left_element - 1]
						else:
									lowerCamelCase__ :      Optional[int]								=		(left_element + right_element) // 2
									self.build(self.left(__magic_name__				)							,    __magic_name__							,    __magic_name__							,    __magic_name__				)
									self.build(self.right(__magic_name__				)							,    mid + 1							,    __magic_name__							,    __magic_name__				)
									lowerCamelCase__ :      Dict								=		max(
									    self.segment_tree[self.left(__magic_name__				)]							,    self.segment_tree[self.right(__magic_name__				)]				)





			def        _snake_case    (self							,    __magic_name__							,    __magic_name__							,    __magic_name__							,    __magic_name__							,    __magic_name__							,    __magic_name__				):
						if self.flag[idx] is True:
									lowerCamelCase__ :      Tuple								=		self.lazy[idx]
									lowerCamelCase__ :      str								=		False
									if left_element != right_element:
												lowerCamelCase__ :      Dict								=		self.lazy[idx]
												lowerCamelCase__ :      Optional[Any]								=		self.lazy[idx]
												lowerCamelCase__ :      int								=		True
												lowerCamelCase__ :      int								=		True

						if right_element < a or left_element > b:
									return True
						if left_element >= a and right_element <= b:
									lowerCamelCase__ :      Tuple								=		val
									if left_element != right_element:
												lowerCamelCase__ :      List[Any]								=		val
												lowerCamelCase__ :      Dict								=		val
												lowerCamelCase__ :      List[str]								=		True
												lowerCamelCase__ :      List[Any]								=		True
									return True
						lowerCamelCase__ :      Optional[Any]								=		(left_element + right_element) // 2
						self.update(self.left(__magic_name__				)							,    __magic_name__							,    __magic_name__							,    __magic_name__							,    __magic_name__							,    __magic_name__				)
						self.update(self.right(__magic_name__				)							,    mid + 1							,    __magic_name__							,    __magic_name__							,    __magic_name__							,    __magic_name__				)
						lowerCamelCase__ :      List[Any]								=		max(
						    self.segment_tree[self.left(__magic_name__				)]							,    self.segment_tree[self.right(__magic_name__				)]				)
						return True





			def        _snake_case    (self							,    __magic_name__							,    __magic_name__							,    __magic_name__							,    __magic_name__							,    __magic_name__				):
						if self.flag[idx] is True:
									lowerCamelCase__ :      Any								=		self.lazy[idx]
									lowerCamelCase__ :      Dict								=		False
									if left_element != right_element:
												lowerCamelCase__ :      str								=		self.lazy[idx]
												lowerCamelCase__ :      str								=		self.lazy[idx]
												lowerCamelCase__ :      List[Any]								=		True
												lowerCamelCase__ :      List[str]								=		True
						if right_element < a or left_element > b:
									return -math.inf
						if left_element >= a and right_element <= b:
									return self.segment_tree[idx]
						lowerCamelCase__ :      Optional[Any]								=		(left_element + right_element) // 2
						lowerCamelCase__ :      str								=		self.query(self.left(__magic_name__				)							,    __magic_name__							,    __magic_name__							,    __magic_name__							,    __magic_name__				)
						lowerCamelCase__ :      Optional[int]								=		self.query(self.right(__magic_name__				)							,    mid + 1							,    __magic_name__							,    __magic_name__							,    __magic_name__				)
						return max(__magic_name__							,    __magic_name__				)





			def __str__(self				):
						return str([self.query(1							,    1							,    self.size							,    __magic_name__							,    __magic_name__				) for i in range(1							,    self.size + 1				)]				)


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








from math import factorial, pi






def      _A				(UpperCamelCase		:      float      ,			UpperCamelCase		:      int = 30 )  ->float:



			'''simple docstring'''







			if not isinstance(UpperCamelCase      ,			(int, float) ):
						raise ValueError("""maclaurin_sin() requires either an int or float for theta""" )

			if not isinstance(UpperCamelCase      ,			UpperCamelCase ) or accuracy <= 0:
						raise ValueError("""maclaurin_sin() requires a positive int for accuracy""" )

			lowerCamelCase__ :      Dict								=		float(UpperCamelCase )
			lowerCamelCase__ :      int								=		theta // (2 * pi)
			theta -= 2 * div * pi
			return sum(
			    (-1) ** r * theta ** (2 * r + 1) / factorial(2 * r + 1 ) for r in range(UpperCamelCase ) )






def      _A				(UpperCamelCase		:      float      ,			UpperCamelCase		:      int = 30 )  ->float:



			'''simple docstring'''







			if not isinstance(UpperCamelCase      ,			(int, float) ):
						raise ValueError("""maclaurin_cos() requires either an int or float for theta""" )

			if not isinstance(UpperCamelCase      ,			UpperCamelCase ) or accuracy <= 0:
						raise ValueError("""maclaurin_cos() requires a positive int for accuracy""" )

			lowerCamelCase__ :      int								=		float(UpperCamelCase )
			lowerCamelCase__ :      Optional[int]								=		theta // (2 * pi)
			theta -= 2 * div * pi
			return sum((-1) ** r * theta ** (2 * r) / factorial(2 * r ) for r in range(UpperCamelCase ) )


if __name__ == "__main__":
				import doctest

				doctest.testmod()

				print(maclaurin_sin(10))
				print(maclaurin_sin(-10))
				print(maclaurin_sin(10, 15))
				print(maclaurin_sin(-10, 15))

				print(maclaurin_cos(5))
				print(maclaurin_cos(-5))
				print(maclaurin_cos(10, 15))
				print(maclaurin_cos(-10, 15))



