"""simple docstring"""


from __future__ import annotations

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

UpperCAmelCase__     :   str  		=						TypeVar("""T""")


class        a				(		Generic[T]   ):


    def __init__(					self	:  str   ,				__lowerCAmelCase	:  list[T]   ,				__lowerCAmelCase	:  Callable[[T, T], T]					):
      _UpperCAmelCase						 =      None

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


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


    def      lowerCAmelCase_  (					self	:  Any   ,				__lowerCAmelCase	:  int   ,				__lowerCAmelCase	:  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      lowerCAmelCase_  (					self	:  int   ,				__lowerCAmelCase	:  int   ,				__lowerCAmelCase	:  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(__lowerCAmelCase   ,				self.st[l]					)
        if r % 2 == 0:
          _UpperCAmelCase						 =      self.st[r] if res is None else self.fn(__lowerCAmelCase   ,				self.st[r]					)
        _UpperCAmelCase ,				_UpperCAmelCase						 =      (l + 1) // 2, (r - 1) // 2
      return res


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

    UpperCAmelCase__     :   List[str]  		=						[1, 1_0, -2, 9, -3, 8, 4, -7, 5, 6, 1_1, -1_2]

    UpperCAmelCase__     :   Optional[Any]  		=						{
        0: 7,
        1: 2,
        2: 6,
        3: -1_4,
        4: 5,
        5: 4,
        6: 7,
        7: -1_0,
        8: 9,
        9: 1_0,
        1_0: 1_2,
        1_1: 1,
    }

    UpperCAmelCase__     :   Tuple  		=						SegmentTree(test_array, min)
    UpperCAmelCase__     :   int  		=						SegmentTree(test_array, max)
    UpperCAmelCase__     :   int  		=						SegmentTree(test_array, lambda a, b: a + b)






    def     __UpperCAmelCase					(			):







      """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():
        UpperCAmelCase__     :   str  		=						value
        min_segment_tree.update(index, value)
        max_segment_tree.update(index, value)
        sum_segment_tree.update(index, value)
        test_all_segments()

"""simple docstring"""


# Lint as: python3
import itertools
import os
import re


UpperCAmelCase__  		=						re.compile(r"""([A-Z]+)([A-Z][a-z])""")
UpperCAmelCase__  		=						re.compile(r"""([a-z\d])([A-Z])""")

UpperCAmelCase__  		=						re.compile(r"""(?<!_)_(?!_)""")
UpperCAmelCase__  		=						re.compile(r"""(_{2,})""")

UpperCAmelCase__  		=						r"""^\w+(\.\w+)*$"""

UpperCAmelCase__  		=						r"""<>:/\|?*"""






def     __UpperCAmelCase					(			lowercase		):







  """simple docstring"""
  _UpperCAmelCase						 =      _uppercase_uppercase_re.sub(R"""\1_\2"""   ,lowercase		)
  _UpperCAmelCase						 =      _lowercase_uppercase_re.sub(R"""\1_\2"""   ,lowercase		)
  return name.lower()






def     __UpperCAmelCase					(			lowercase		):







  """simple docstring"""
  _UpperCAmelCase						 =      _single_underscore_re.split(lowercase		)
  _UpperCAmelCase						 =      [_multiple_underscores_re.split(lowercase		) for n in name]
  return "".join(n.capitalize() for n in itertools.chain.from_iterable(lowercase		) if n != """"""		)






def     __UpperCAmelCase					(			lowercase		):







  """simple docstring"""
  if os.path.basename(lowercase		) != name:
    raise ValueError(f'''Should be a dataset name, not a path: {name}'''		)
  return camelcase_to_snakecase(lowercase		)






def     __UpperCAmelCase					(			lowercase   ,lowercase		):







  """simple docstring"""
  if os.path.basename(lowercase		) != name:
    raise ValueError(f'''Should be a dataset name, not a path: {name}'''		)
  if not re.match(_split_re   ,lowercase		):
    raise ValueError(f'''Split name should match \'{_split_re}\'\' but got \'{split}\'.'''		)
  return f'''{filename_prefix_for_name(lowercase		)}-{split}'''






def     __UpperCAmelCase					(			lowercase   ,lowercase   ,lowercase   ,lowercase=None		):







  """simple docstring"""
  _UpperCAmelCase						 =      filename_prefix_for_split(lowercase   ,lowercase		)
  if filetype_suffix:
    prefix += f'''.{filetype_suffix}'''
  _UpperCAmelCase						 =      os.path.join(lowercase   ,lowercase		)
  return f'''{filepath}*'''






def     __UpperCAmelCase					(			lowercase   ,lowercase   ,lowercase   ,lowercase=None   ,lowercase=None		):







  """simple docstring"""
  _UpperCAmelCase						 =      filename_prefix_for_split(lowercase   ,lowercase		)
  _UpperCAmelCase						 =      os.path.join(lowercase   ,lowercase		)

  if shard_lengths:
    _UpperCAmelCase						 =      len(lowercase		)
    _UpperCAmelCase						 =      [f'''{prefix}-{shard_id:05d}-of-{num_shards:05d}''' for shard_id in range(lowercase		)]
    if filetype_suffix:
      _UpperCAmelCase						 =      [filename + f'''.{filetype_suffix}''' for filename in filenames]
    return filenames
  else:
    _UpperCAmelCase						 =      prefix
    if filetype_suffix:
      filename += f'''.{filetype_suffix}'''
    return [filename]
