def kth(self, k: int) -> int:
pos = 0
for i in range(self._size.bit_length() - 1, -1, -1):
p = (1 << i)
if pos + p - 1 < self._size:
v = self._tree[pos + p - 1]
if v < k:
k -= v
pos += p
return pos
def kth(self, k: int) -> int:
i = 1
while i < self._size:
i += i
t = self._tree[i]
if t < k:
k -= t
i += 1
return i - self._size
def get_nums_between(ost, beg, end):
k = ost.count_less_than(beg)
ret = []
for i in range(k + 1, ost.size() + 1):
nums = ost.kth(i)
if nums >= end:
break
ret.append(nums)
return ret