CF295E Yaroslav and Points
Description
Yaroslav has $ n $ points that lie on the $ Ox $ axis. The coordinate of the first point is $ x_{1} $ , the coordinate of the second point is $ x_{2} $ , ..., the coordinate of the $ n $ -th point is — $ x_{n} $ . Now Yaroslav wants to execute $ m $ queries, each of them is of one of the two following types:
1. Move the $ p_{j} $ -th point from position $ x_{pj} $ to position $ x_{pj}+d_{j} $ . At that, it is guaranteed that after executing such query all coordinates of the points will be distinct.
2. Count the sum of distances between all pairs of points that lie on the segment $ [l_{j},r_{j}] $ $ (l_{j}
Input Format
The first line contains integer $ n $ — the number of points $ (1
Output Format
For each type 2 query print the answer on a single line. Print the answers in the order, in which the queries follow in the input.
Please, do not use the %lld specifier to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams of the %I64d specifier.