class BIT:
def __init__(self, n: int):
self.n = n+1
self.c = [0]*(self.n)
def update(self, i: int, di: int) -> None:
diff = di
i += 1
while i<self.n:
self.c[i] += diff
i += i&(-i)
def sumRange(self, i: int, j: int) -> int:
res1 = 0
res2 = 0
i = i-1+1
while i>0:
res1 += self.c[i]
i -= i&(-i)
j += 1
while j>0:
res2 += self.c[j]
j -= j&(-j)
return res2 - res1
05-26
1043