





from copy import deepcopy




class 							UpperCamelCase_							:







 """simple docstring"""

 def __init__(   self  ,				UpperCAmelCase = None  ,				UpperCAmelCase = None							):

       if arr is None and size is not None:
             __lowerCamelCase				   =       size
             __lowerCamelCase				   =       [0] * size
       elif arr is not None:
             self.init(_SCREAMING_SNAKE_CASE							)
       else:
             raise ValueError("""Either arr or size must be specified"""							)


 def 		lowerCamelCase_ (   self  ,				UpperCAmelCase							):
       __lowerCamelCase				   =       len(_SCREAMING_SNAKE_CASE							)
       __lowerCamelCase				   =       deepcopy(_SCREAMING_SNAKE_CASE							)
       for i in range(1  ,				self.size							):
             __lowerCamelCase				   =       self.next_(_SCREAMING_SNAKE_CASE							)
             if j < self.size:
                   self.tree[j] += self.tree[i]


 def 		lowerCamelCase_ (   self							):
       __lowerCamelCase				   =       self.tree[:]
       for i in range(self.size - 1  ,				0  ,				-1							):
             __lowerCamelCase				   =       self.next_(_SCREAMING_SNAKE_CASE							)
             if j < self.size:
                   arr[j] -= arr[i]
       return arr


 @staticmethod
 def 		lowerCamelCase_ (   UpperCAmelCase							):
       return index + (index & (-index))


 @staticmethod
 def 		lowerCamelCase_ (   UpperCAmelCase							):
       return index - (index & (-index))


 def 		lowerCamelCase_ (   self  ,				UpperCAmelCase  ,				UpperCAmelCase							):

       if index == 0:
             self.tree[0] += value
             return
       while index < self.size:
             self.tree[index] += value
             __lowerCamelCase				   =       self.next_(_SCREAMING_SNAKE_CASE							)


 def 		lowerCamelCase_ (   self  ,				UpperCAmelCase  ,				UpperCAmelCase							):
       self.add(_SCREAMING_SNAKE_CASE  ,				value - self.get(_SCREAMING_SNAKE_CASE							)							)


 def 		lowerCamelCase_ (   self  ,				UpperCAmelCase							):

       if right == 0:
             return 0
       __lowerCamelCase				   =       self.tree[0]
       right -= 1  # make right inclusive
       while right > 0:
             result += self.tree[right]
             __lowerCamelCase				   =       self.prev(_SCREAMING_SNAKE_CASE							)
       return result


 def 		lowerCamelCase_ (   self  ,				UpperCAmelCase  ,				UpperCAmelCase							):
       return self.prefix(_SCREAMING_SNAKE_CASE							) - self.prefix(_SCREAMING_SNAKE_CASE							)


 def 		lowerCamelCase_ (   self  ,				UpperCAmelCase							):
       return self.query(_SCREAMING_SNAKE_CASE  ,				index + 1							)



 def 		lowerCamelCase_ (   self  ,				UpperCAmelCase							):
       value -= self.tree[0]
       if value < 0:
             return -1

       __lowerCamelCase				   =       1  # Largest power of 2 <= size
       while j * 2 < self.size:
             j *= 2

       __lowerCamelCase				   =       0

       while j > 0:
             if i + j < self.size and self.tree[i + j] <= value:
                   value -= self.tree[i + j]
                   i += j
             j //= 2
       return i


if __name__ == "__main__":
   import doctest

   doctest.testmod()











"""simple docstring"""






from abc import ABC, abstractmethod
from argparse import ArgumentParser



class      A__  (    __SCREAMING_SNAKE_CASE				):




	'''simple docstring'''





	@staticmethod
	@abstractmethod
	def 				_SCREAMING_SNAKE_CASE  (	_SCREAMING_SNAKE_CASE:						ArgumentParser)							->			Optional[int]:

				"""simple docstring"""

				raise NotImplementedError()







	@abstractmethod
	def 				_SCREAMING_SNAKE_CASE  (	self:						Union[str, Any])							->			Dict:

				"""simple docstring"""

				raise NotImplementedError()