{.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)= if i>=self.n*2: return 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 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 t in (1..q).mapIt(stdin.readLine.split).reversed: let x=t[1].parseInt y=t[2].parseInt if t[0]=="A": b[x-1]+=y*c.query x-1 else: c.update(x-1,y,1) for x,y in a: b[x]+=y*c.query x echo b.mapIt($it).join" "