{.checks:off.} import sequtils,strutils,algorithm,future type DualSegTree[T]=object n:int data:seq[T] unit:T f:(T,T)->T proc initDualSegTree[T](n:int,unit:T,f:(T,T)->T):DualSegTree[T]= result.n=n result.data=newSeq[T] n*2 result.data.fill unit result.unit=unit result.f=f proc propagate[T](self:var DualSegTree[T],i:int)= var j=i c=0 while j>0: j=j div 2 c+=1 for j in countdown(c-1,1): let k=i shr j if k>=self.n: break self.data[k*2]=self.f(self.data[k*2],self.data[k]) self.data[k*2+1]=self.f(self.data[k*2+1],self.data[k]) self.data[k]=self.unit proc update[T](self:var DualSegTree[T],left,right:int,x:T)= var l=left+self.n r=right+self.n self.propagate l self.propagate r while la+b) for _ in 1..q: let t=stdin.readLine.split x=parseInt(t[1])-1 y=parseInt t[2] case t[0] of "A": b[x]+=a[x]*c.query x c.update(x,x+1,-c.query x) a[x]+=y of "B": c.update(x,y,1) for x,y in a: b[x]+=y*c.query x echo b.mapIt($it).join" "