





'''simple docstring'''




from __future__ import annotations

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

__SCREAMING_SNAKE_CASE     :Optional[int]       =				TypeVar('''T''')







class   A_	(  Generic[T]			):




 def __init__(					self       :    List[Any]	,			snake_case_       :    list[T]	,			snake_case_       :    Callable[[T, T], T]    ):
      _UpperCAmelCase     							=   None

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




 def      lowercase	(					self       :    List[Any]    ):
      for p in range(self.N - 1	,			0	,			-1    ):
           _UpperCAmelCase     							=   self.fn(self.st[p * 2]	,			self.st[p * 2 + 1]    )




 def      lowercase	(					self       :    Optional[Any]	,			snake_case_       :    int	,			snake_case_       :    T    ):
      p += self.N
      _UpperCAmelCase     							=   v
      while p > 1:
           _UpperCAmelCase     							=   p // 2
           _UpperCAmelCase     							=   self.fn(self.st[p * 2]	,			self.st[p * 2 + 1]    )




 def      lowercase	(					self       :    Any	,			snake_case_       :    int	,			snake_case_       :    int    ):  # noqa: E741
      _UpperCAmelCase							,  _UpperCAmelCase     							=   l + self.N, r + self.N

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


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

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

  __SCREAMING_SNAKE_CASE     :List[str]       =				{
      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     :Any       =				SegmentTree(test_array, min)
  __SCREAMING_SNAKE_CASE     :Any       =				SegmentTree(test_array, max)
  __SCREAMING_SNAKE_CASE     :Any       =				SegmentTree(test_array, lambda a, b: a + b)
  def 	UpperCAmelCase_							(					)		->       None:


       '''simple docstring'''



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

  test_all_segments()

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






from collections.abc import Sequence






def        a_		(       __lowercase   :	Sequence[float]       ,					__lowercase   :	float ) ->  float:
			return sum(c * (x**i) for i, c in enumerate(__lowercase ) )






def        a_		(       __lowercase   :	Sequence[float]       ,					__lowercase   :	float ) ->  float:
			_snake_case		=			0.0
			for coeff in reversed(__lowercase ):
						_snake_case		=			result * x + coeff
			return result


if __name__ == "__main__":
			_lowerCamelCase       :				Optional[Any]       =			(0.0, 0.0, 5.0, 9.3, 7.0)
			_lowerCamelCase       :				Optional[int]       =			1_0.0
			print(evaluate_poly(poly, x))
			print(horner(poly, x))