from __future__ import annotations

import math


class 	lowerCamelCase_     :






    '''simple docstring'''






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







    def 			UpperCamelCase__   (	self , __lowercase)       ->	int:
        return idx * 2







    def 			UpperCamelCase__   (	self , __lowercase)       ->	int:
        return idx * 2 + 1







    def 			UpperCamelCase__   (	self , __lowercase , __lowercase , __lowercase , __lowercase)       ->	None:
        if left_element == right_element:
            __UpperCamelCase     :List[str]			  =		a[left_element - 1]
        else:
            __UpperCamelCase     :Optional[Any]			  =		(left_element + right_element) // 2
            self.build(self.left(A_) , A_ , A_ , A_)
            self.build(self.right(A_) , mid + 1 , A_ , A_)
            __UpperCamelCase     :int			  =		max(
                self.segment_tree[self.left(A_)] , self.segment_tree[self.right(A_)])







    def 			UpperCamelCase__   (	self , __lowercase , __lowercase , __lowercase , __lowercase , __lowercase , __lowercase)       ->	bool:
        if self.flag[idx] is True:
            __UpperCamelCase     :List[str]			  =		self.lazy[idx]
            __UpperCamelCase     :Any			  =		False
            if left_element != right_element:
                __UpperCamelCase     :Any			  =		self.lazy[idx]
                __UpperCamelCase     :List[str]			  =		self.lazy[idx]
                __UpperCamelCase     :str			  =		True
                __UpperCamelCase     :int			  =		True

        if right_element < a or left_element > b:
            return True
        if left_element >= a and right_element <= b:
            __UpperCamelCase     :Tuple			  =		val
            if left_element != right_element:
                __UpperCamelCase     :Union[str, Any]			  =		val
                __UpperCamelCase     :Union[str, Any]			  =		val
                __UpperCamelCase     :int			  =		True
                __UpperCamelCase     :List[Any]			  =		True
            return True
        __UpperCamelCase     :Dict			  =		(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 			UpperCamelCase__   (	self , __lowercase , __lowercase , __lowercase , __lowercase , __lowercase)       ->	int | float:
        if self.flag[idx] is True:
            __UpperCamelCase     :Any			  =		self.lazy[idx]
            __UpperCamelCase     :Union[str, Any]			  =		False
            if left_element != right_element:
                __UpperCamelCase     :Tuple			  =		self.lazy[idx]
                __UpperCamelCase     :int			  =		self.lazy[idx]
                __UpperCamelCase     :Optional[Any]			  =		True
                __UpperCamelCase     :Optional[Any]			  =		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     :int			  =		(left_element + right_element) // 2
        __UpperCamelCase     :str			  =		self.query(self.left(A_) , A_ , A_ , A_ , A_)
        __UpperCamelCase     :List[Any]			  =		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__":
    __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, 111)
    print(segt.query(1, 1, size, 1, 15))
    segt.update(1, 1, size, 7, 8, 235)
    print(segt)









from typing import TYPE_CHECKING

from ...utils import (
    OptionalDependencyNotAvailable,
    _LazyModule,
    is_tf_available,
    is_tokenizers_available,
    is_torch_available,
)


_A		       =						{
    'configuration_convbert': ['CONVBERT_PRETRAINED_CONFIG_ARCHIVE_MAP', 'ConvBertConfig', 'ConvBertOnnxConfig'],
    'tokenization_convbert': ['ConvBertTokenizer'],
}

try:
   if not is_tokenizers_available():
      raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
   pass
else:
   _A		       =						['ConvBertTokenizerFast']

try:
   if not is_torch_available():
      raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
   pass
else:
   _A		       =						[
       'CONVBERT_PRETRAINED_MODEL_ARCHIVE_LIST',
       'ConvBertForMaskedLM',
       'ConvBertForMultipleChoice',
       'ConvBertForQuestionAnswering',
       'ConvBertForSequenceClassification',
       'ConvBertForTokenClassification',
       'ConvBertLayer',
       'ConvBertModel',
       'ConvBertPreTrainedModel',
       'load_tf_weights_in_convbert',
   ]


try:
   if not is_tf_available():
      raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
   pass
else:
   _A		       =						[
       'TF_CONVBERT_PRETRAINED_MODEL_ARCHIVE_LIST',
       'TFConvBertForMaskedLM',
       'TFConvBertForMultipleChoice',
       'TFConvBertForQuestionAnswering',
       'TFConvBertForSequenceClassification',
       'TFConvBertForTokenClassification',
       'TFConvBertLayer',
       'TFConvBertModel',
       'TFConvBertPreTrainedModel',
   ]


if TYPE_CHECKING:
   from .configuration_convbert import CONVBERT_PRETRAINED_CONFIG_ARCHIVE_MAP, ConvBertConfig, ConvBertOnnxConfig
   from .tokenization_convbert import ConvBertTokenizer

   try:
      if not is_tokenizers_available():
         raise OptionalDependencyNotAvailable()
   except OptionalDependencyNotAvailable:
      pass
   else:
      from .tokenization_convbert_fast import ConvBertTokenizerFast

   try:
      if not is_torch_available():
         raise OptionalDependencyNotAvailable()
   except OptionalDependencyNotAvailable:
      pass
   else:
      from .modeling_convbert import (
          CONVBERT_PRETRAINED_MODEL_ARCHIVE_LIST,
          ConvBertForMaskedLM,
          ConvBertForMultipleChoice,
          ConvBertForQuestionAnswering,
          ConvBertForSequenceClassification,
          ConvBertForTokenClassification,
          ConvBertLayer,
          ConvBertModel,
          ConvBertPreTrainedModel,
          load_tf_weights_in_convbert,
      )

   try:
      if not is_tf_available():
         raise OptionalDependencyNotAvailable()
   except OptionalDependencyNotAvailable:
      pass
   else:
      from .modeling_tf_convbert import (
          TF_CONVBERT_PRETRAINED_MODEL_ARCHIVE_LIST,
          TFConvBertForMaskedLM,
          TFConvBertForMultipleChoice,
          TFConvBertForQuestionAnswering,
          TFConvBertForSequenceClassification,
          TFConvBertForTokenClassification,
          TFConvBertLayer,
          TFConvBertModel,
          TFConvBertPreTrainedModel,
      )


else:
   import sys

   _A		       =						_LazyModule(__name__, globals()['__file__'], _import_structure, module_spec=__spec__)





