For first task, we can just simulate the records (since only one customer’s order changes and only one customer orders during a record).
In second subtask, we can keep the orders in a segment tree. For each customer we track how many orders he has performed. Then, when his order amount changes, we use the previous order amount and the kept order count to calculate total deliveries and reset the order count to 0 so that the previous order count do not affect new order amount.
For subtask 3, we will also use segment tree, but this segment tree will keep weight and value for each index. And a query on a range will return the sum of all weight value in that range. Initially, we will read all records then compute the answers for each customer. To do this, we will keep a size segment tree. If i-th record increases customers’ amount by , then, before computing l-th customer’s answer, we’ll increase value of index by , and before computing -th customer’s answer we will decrease value of index by . And if j-th record is l-r customers ordering times then, before computing -th customer’s answer we will increase weight of indices to by and before computing -th customer’s answer we will decrease weight of indices to by . Then to compute answer for a customer we only need to get sum of weight value of all indices.