



'''simple docstring'''




# Lint as: python3
# pylint: enable=line-too-long
# pylint: disable=g-import-not-at-top,g-bad-import-order,wrong-import-position

a   :			Dict					  =    """2.13.1"""

import platform

import pyarrow
from packaging import version


if version.parse(platform.python_version()) < version.parse("""3.7"""):
							raise ImportWarning(
							    """To use `datasets`, Python>=3.7 is required, and the current version of Python doesn't match this condition."""
							)

if version.parse(pyarrow.__version__).major < 8:
							raise ImportWarning(
							    """To use `datasets`, the module `pyarrow>=8.0.0` is required, and the current version of `pyarrow` doesn't match this condition.\n"""
							    """If you are running this in a Google Colab, you should probably just restart the runtime to use the right version of `pyarrow`."""
							)

del platform
del pyarrow
del version

from .arrow_dataset import Dataset
from .arrow_reader import ReadInstruction
from .builder import ArrowBasedBuilder, BeamBasedBuilder, BuilderConfig, DatasetBuilder, GeneratorBasedBuilder
from .combine import concatenate_datasets, interleave_datasets
from .dataset_dict import DatasetDict, IterableDatasetDict
from .download import *
from .features import *
from .fingerprint import disable_caching, enable_caching, is_caching_enabled, set_caching_enabled
from .info import DatasetInfo, MetricInfo
from .inspect import (
    get_dataset_config_info,
    get_dataset_config_names,
    get_dataset_infos,
    get_dataset_split_names,
    inspect_dataset,
    inspect_metric,
    list_datasets,
    list_metrics,
)
from .iterable_dataset import IterableDataset
from .load import load_dataset, load_dataset_builder, load_from_disk, load_metric
from .metric import Metric
from .splits import (
    NamedSplit,
    NamedSplitAll,
    Split,
    SplitBase,
    SplitDict,
    SplitGenerator,
    SplitInfo,
    SubSplitInfo,
    percent,
)
from .tasks import *
from .utils import *
from .utils import logging


# deprecated modules
from datasets import arrow_dataset as _arrow_dataset  # isort:skip
from datasets import utils as _utils  # isort:skip
from datasets.utils import download_manager as _deprecated_download_manager  # isort:skip

a   :			Dict					  =    concatenate_datasets
a   :			str					  =    DownloadConfig
a   :			Union[str, Any]					  =    DownloadManager
a   :			Tuple					  =    DownloadMode
a   :			List[Any]					  =    DownloadConfig
a   :			Dict					  =    DownloadMode
a   :			Any					  =    DownloadManager

del _arrow_dataset, _utils, _deprecated_download_manager






'''simple docstring'''




from __future__ import annotations

import math

class 			UpperCamelCase_ :





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





	def  _lowercase(  self		,		A    )			->			int:
								return idx * 2





	def  _lowercase(  self		,		A    )			->			int:
								return idx * 2 + 1





	def  _lowercase(  self		,		A		,		A		,		A		,		A    )			->			None:
								if left_element == right_element:
															UpperCAmelCase     :		str							     =		a[left_element - 1]
								else:
															UpperCAmelCase     :		Tuple							     =		(left_element + right_element) // 2
															self.build(self.left(A    )		,		A		,		A		,		A    )
															self.build(self.right(A    )		,		mid + 1		,		A		,		A    )
															UpperCAmelCase     :		str							     =		max(
															    self.segment_tree[self.left(A    )]		,		self.segment_tree[self.right(A    )]    )





	def  _lowercase(  self		,		A		,		A		,		A		,		A		,		A		,		A    )			->			bool:
								if self.flag[idx] is True:
															UpperCAmelCase     :		Optional[Any]							     =		self.lazy[idx]
															UpperCAmelCase     :		int							     =		False
															if left_element != right_element:
																						UpperCAmelCase     :		List[str]							     =		self.lazy[idx]
																						UpperCAmelCase     :		Optional[Any]							     =		self.lazy[idx]
																						UpperCAmelCase     :		List[str]							     =		True
																						UpperCAmelCase     :		int							     =		True

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





	def  _lowercase(  self		,		A		,		A		,		A		,		A		,		A    )			->			int | float:
								if self.flag[idx] is True:
															UpperCAmelCase     :		Any							     =		self.lazy[idx]
															UpperCAmelCase     :		Any							     =		False
															if left_element != right_element:
																						UpperCAmelCase     :		Optional[Any]							     =		self.lazy[idx]
																						UpperCAmelCase     :		Tuple							     =		self.lazy[idx]
																						UpperCAmelCase     :		List[str]							     =		True
																						UpperCAmelCase     :		Tuple							     =		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]
								UpperCAmelCase     :		Dict							     =		(left_element + right_element) // 2
								UpperCAmelCase     :		List[Any]							     =		self.query(self.left(A    )		,		A		,		A		,		A		,		A    )
								UpperCAmelCase     :		str							     =		self.query(self.right(A    )		,		mid + 1		,		A		,		A		,		A    )
								return max(A		,		A    )






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


if __name__ == "__main__":
							a   :			Optional[int]					  =    [1, 2, -4, 7, 3, -5, 6, 1_1, -2_0, 9, 1_4, 1_5, 5, 2, -8]
							a   :			Optional[Any]					  =    1_5
							a   :			Union[str, Any]					  =    SegmentTree(size)
							segt.build(1, 1, size, A)
							print(segt.query(1, 1, size, 4, 6))
							print(segt.query(1, 1, size, 7, 1_1))
							print(segt.query(1, 1, size, 7, 1_2))
							segt.update(1, 1, size, 1, 3, 1_1_1)
							print(segt.query(1, 1, size, 1, 1_5))
							segt.update(1, 1, size, 7, 8, 2_3_5)
							print(segt)

