import sys sys.setrecursionlimit(10 ** 6) int1 = lambda x: int(x) - 1 p2D = lambda x: print(*x, sep="\n") def II(): return int(sys.stdin.readline()) def MI(): return map(int, sys.stdin.readline().split()) def LI(): return list(map(int, sys.stdin.readline().split())) def LLI(rows_number): return [LI() for _ in range(rows_number)] def SI(): return sys.stdin.readline()[:-1] class LazySeg: def __init__(self, aa): inf = 10 ** 16 n = 1 << (len(aa) - 1).bit_length() tree = [-inf] * (2 * n) lazy = [0] * (2 * n) tree[n:n + len(aa)] = aa for u in range(n - 1, 0, -1): tree[u] = max(tree[u * 2], tree[u * 2 + 1]) self.tree = tree self.lazy = lazy self.n = n self.inf = inf def add(self, l, r, a, u=1, tl=0, tr=-1): if tr == -1: tr = self.n self._eval(u) if r <= tl or tr <= l: return if l <= tl and tr <= r: self.lazy[u] += a self._eval(u) return tm = (tl + tr) // 2 self.add(l, r, a, u * 2, tl, tm) self.add(l, r, a, u * 2 + 1, tm, tr) self.tree[u]=max(self.tree[u*2],self.tree[u*2+1]) def max(self, l, r, u=1, tl=0, tr=-1): if tr == -1: tr = self.n if r <= tl or tr <= l: return -self.inf self._eval(u) if l <= tl and tr <= r:return self.tree[u] tm = (tl + tr) // 2 res=max(self.max(l, r, u * 2, tl, tm),self.max(l, r, u * 2 + 1, tm, tr)) return res def _eval(self, u): self.tree[u]+=self.lazy[u] if u