





import math

class 		__a							:



       def __init__(     self	:   str					,			UpperCAmelCase	:   Any			):
           lowerCAmelCase_					:	str						=   len(UpperCAmelCase			)
           lowerCAmelCase_					:	Any						=   [0] * (
               4 * self.N
           )  # approximate the overall size of segment tree with array N
           self.build(1					,			0					,			self.N - 1			)



       def  A							(     self	:   Optional[Any]					,			UpperCAmelCase	:   str			):
           return idx * 2



       def  A							(     self	:   Dict					,			UpperCAmelCase	:   Optional[int]			):
           return idx * 2 + 1



       def  A							(     self	:   int					,			UpperCAmelCase	:   str					,			UpperCAmelCase	:   Any					,			UpperCAmelCase	:   Tuple			):  # noqa: E741







           if l == r:
               lowerCAmelCase_					:	Optional[int]						=   A[l]
           else:
               lowerCAmelCase_					:	str						=   (l + r) // 2
               self.build(self.left(UpperCAmelCase			)					,			UpperCAmelCase					,			UpperCAmelCase			)
               self.build(self.right(UpperCAmelCase			)					,			mid + 1					,			UpperCAmelCase			)
               lowerCAmelCase_					:	List[str]						=   max(self.st[self.left(UpperCAmelCase			)]					,			self.st[self.right(UpperCAmelCase			)]			)



       def  A							(     self	:   List[Any]					,			UpperCAmelCase	:   Tuple					,			UpperCAmelCase	:   Any					,			UpperCAmelCase	:   List[Any]			):
           return self.update_recursive(1					,			0					,			self.N - 1					,			a - 1					,			b - 1					,			UpperCAmelCase			)



       def  A							(     self	:   Tuple					,			UpperCAmelCase	:   Dict					,			UpperCAmelCase	:   Optional[Any]					,			UpperCAmelCase	:   str					,			UpperCAmelCase	:   str					,			UpperCAmelCase	:   str					,			UpperCAmelCase	:   Optional[Any]			):  # noqa: E741







           if r < a or l > b:
               return True
           if l == r:
               lowerCAmelCase_					:	Optional[Any]						=   val
               return True
           lowerCAmelCase_					:	Dict						=   (l + r) // 2
           self.update_recursive(self.left(UpperCAmelCase			)					,			UpperCAmelCase					,			UpperCAmelCase					,			UpperCAmelCase					,			UpperCAmelCase					,			UpperCAmelCase			)
           self.update_recursive(self.right(UpperCAmelCase			)					,			mid + 1					,			UpperCAmelCase					,			UpperCAmelCase					,			UpperCAmelCase					,			UpperCAmelCase			)
           lowerCAmelCase_					:	Optional[Any]						=   max(self.st[self.left(UpperCAmelCase			)]					,			self.st[self.right(UpperCAmelCase			)]			)
           return True



       def  A							(     self	:   Optional[int]					,			UpperCAmelCase	:   List[Any]					,			UpperCAmelCase	:   str			):
           return self.query_recursive(1					,			0					,			self.N - 1					,			a - 1					,			b - 1			)



       def  A							(     self	:   Any					,			UpperCAmelCase	:   List[Any]					,			UpperCAmelCase	:   Union[str, Any]					,			UpperCAmelCase	:   Union[str, Any]					,			UpperCAmelCase	:   Tuple					,			UpperCAmelCase	:   Any			):  # noqa: E741







           if r < a or l > b:
               return -math.inf
           if l >= a and r <= b:
               return self.st[idx]
           lowerCAmelCase_					:	Dict						=   (l + r) // 2
           lowerCAmelCase_					:	Optional[int]						=   self.query_recursive(self.left(UpperCAmelCase			)					,			UpperCAmelCase					,			UpperCAmelCase					,			UpperCAmelCase					,			UpperCAmelCase			)
           lowerCAmelCase_					:	Tuple						=   self.query_recursive(self.right(UpperCAmelCase			)					,			mid + 1					,			UpperCAmelCase					,			UpperCAmelCase					,			UpperCAmelCase			)
           return max(UpperCAmelCase					,			UpperCAmelCase			)



       def  A							(     self	:   Any			):
           lowerCAmelCase_					:	List[str]						=   []
           for i in range(1					,			N + 1			):
               show_list += [self.query(UpperCAmelCase					,			UpperCAmelCase			)]
           print(UpperCAmelCase			)


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









from ..utils import deprecate
from .attention_processor import (  # noqa: F401
    Attention,
    AttentionProcessor,
    AttnAddedKVProcessor,
    AttnProcessor2_0,
    LoRAAttnProcessor,
    LoRALinearLayer,
    LoRAXFormersAttnProcessor,
    SlicedAttnAddedKVProcessor,
    SlicedAttnProcessor,
    XFormersAttnProcessor,
)
from .attention_processor import AttnProcessor as AttnProcessorRename  # noqa: F401


deprecate(
    'cross_attention',
    '0.20.0',
    'Importing from cross_attention is deprecated. Please import from diffusers.models.attention_processor instead.',
    standard_warn=False,
)


__UpperCAmelCase						=      AttentionProcessor

class 		__a							(	__UpperCamelCase      ):



       def __init__(     self	:   List[Any]					,			*UpperCAmelCase	:   List[Any]					,			**UpperCAmelCase	:   Any			):
           lowerCAmelCase_					:	str						=   F'{self.__class__.__name__} is deprecated and will be removed in `0.20.0`. Please use `from diffusers.models.attention_processor import {"".join(self.__class__.__name__.split("Cross"			)			)} instead.'
           deprecate("""cross_attention"""					,			"""0.20.0"""					,			UpperCAmelCase					,			standard_warn=UpperCAmelCase			)
           super().__init__(*UpperCAmelCase					,			**UpperCAmelCase			)






class 		__a							(	__UpperCamelCase      ):



       def __init__(     self	:   Optional[Any]					,			*UpperCAmelCase	:   List[Any]					,			**UpperCAmelCase	:   List[str]			):
           lowerCAmelCase_					:	List[Any]						=   F'{self.__class__.__name__} is deprecated and will be removed in `0.20.0`. Please use `from diffusers.models.attention_processor import {"".join(self.__class__.__name__.split("Cross"			)			)} instead.'
           deprecate("""cross_attention"""					,			"""0.20.0"""					,			UpperCAmelCase					,			standard_warn=UpperCAmelCase			)
           super().__init__(*UpperCAmelCase					,			**UpperCAmelCase			)






class 		__a							(	__UpperCamelCase      ):



       def __init__(     self	:   List[str]					,			*UpperCAmelCase	:   str					,			**UpperCAmelCase	:   Union[str, Any]			):
           lowerCAmelCase_					:	Tuple						=   F'{self.__class__.__name__} is deprecated and will be removed in `0.20.0`. Please use `from diffusers.models.attention_processor import {"".join(self.__class__.__name__.split("Cross"			)			)} instead.'
           deprecate("""cross_attention"""					,			"""0.20.0"""					,			UpperCAmelCase					,			standard_warn=UpperCAmelCase			)
           super().__init__(*UpperCAmelCase					,			**UpperCAmelCase			)






class 		__a							(	__UpperCamelCase      ):



       def __init__(     self	:   Optional[int]					,			*UpperCAmelCase	:   Union[str, Any]					,			**UpperCAmelCase	:   Any			):
           lowerCAmelCase_					:	Tuple						=   F'{self.__class__.__name__} is deprecated and will be removed in `0.20.0`. Please use `from diffusers.models.attention_processor import {"".join(self.__class__.__name__.split("Cross"			)			)} instead.'
           deprecate("""cross_attention"""					,			"""0.20.0"""					,			UpperCAmelCase					,			standard_warn=UpperCAmelCase			)
           super().__init__(*UpperCAmelCase					,			**UpperCAmelCase			)






class 		__a							(	__UpperCamelCase      ):



       def __init__(     self	:   str					,			*UpperCAmelCase	:   Any					,			**UpperCAmelCase	:   List[Any]			):
           lowerCAmelCase_					:	Union[str, Any]						=   F'{self.__class__.__name__} is deprecated and will be removed in `0.20.0`. Please use `from diffusers.models.attention_processor import {"".join(self.__class__.__name__.split("Cross"			)			)} instead.'
           deprecate("""cross_attention"""					,			"""0.20.0"""					,			UpperCAmelCase					,			standard_warn=UpperCAmelCase			)
           super().__init__(*UpperCAmelCase					,			**UpperCAmelCase			)






class 		__a							(	__UpperCamelCase      ):



       def __init__(     self	:   List[str]					,			*UpperCAmelCase	:   Union[str, Any]					,			**UpperCAmelCase	:   Tuple			):
           lowerCAmelCase_					:	Tuple						=   F'{self.__class__.__name__} is deprecated and will be removed in `0.20.0`. Please use `from diffusers.models.attention_processor import {"".join(self.__class__.__name__.split("Cross"			)			)} instead.'
           deprecate("""cross_attention"""					,			"""0.20.0"""					,			UpperCAmelCase					,			standard_warn=UpperCAmelCase			)
           super().__init__(*UpperCAmelCase					,			**UpperCAmelCase			)






class 		__a							(	__UpperCamelCase      ):



       def __init__(     self	:   Dict					,			*UpperCAmelCase	:   int					,			**UpperCAmelCase	:   int			):
           lowerCAmelCase_					:	List[str]						=   F'{self.__class__.__name__} is deprecated and will be removed in `0.20.0`. Please use `from diffusers.models.attention_processor import {"".join(self.__class__.__name__.split("Cross"			)			)} instead.'
           deprecate("""cross_attention"""					,			"""0.20.0"""					,			UpperCAmelCase					,			standard_warn=UpperCAmelCase			)
           super().__init__(*UpperCAmelCase					,			**UpperCAmelCase			)






class 		__a							(	__UpperCamelCase      ):



       def __init__(     self	:   Optional[Any]					,			*UpperCAmelCase	:   Any					,			**UpperCAmelCase	:   int			):
           lowerCAmelCase_					:	Union[str, Any]						=   F'{self.__class__.__name__} is deprecated and will be removed in `0.20.0`. Please use `from diffusers.models.attention_processor import {"".join(self.__class__.__name__.split("Cross"			)			)} instead.'
           deprecate("""cross_attention"""					,			"""0.20.0"""					,			UpperCAmelCase					,			standard_warn=UpperCAmelCase			)
           super().__init__(*UpperCAmelCase					,			**UpperCAmelCase			)


