Problem:
Range Add Query (RAQ)

Write a program which manipulates a sequence A = {a1, a2, . . . , an} with the following operations:

add(s, t, x): add x to as, as+1, ..., at.

get(i): output the value of ai.

Note that the initial values of ai (i = 1, 2, . . . , n) are 0.

Input

n q
query1
query2
:
queryq

In the first line, n (the number of elements in A) and q (the number of queries) are given. Then, ith query queryi is given in the following format:

0 s t x

or

1 t

The first digit represents the type of the query. '0' denotes add(s, t, x) and '1' denotes get(i).

Output

For each get operation, print the value.

Constraints

1 ≤ n ≤ 100000

1 ≤ q ≤ 100000

1 ≤ s ≤ t ≤ n

1 ≤ i ≤ n

0 ≤ x ≤ 1000

Sample Input 1

3 5
0 1 2 1
0 2 3 2
0 3 3 3
1 2
1 3

Sample Output 1

3
5

Sample Input 2

4 3
1 2
0 1 4 1
1 2

Sample Output 2

0
1

Solution in C++ (judge verdict: Accepted)

#include "bits/stdc++.h"
using namespace std;

class SegmentTree {
private:
	long long Size;
	long long Unit;
	vector<long long> Node;
public:
	SegmentTree(long long N, long long X) : Unit(X) {
		Size = 1;
		while (Size < N) Size *= 2;
		Node.assign(Size * 2, Unit);
	}
	void update(long long L, long long R, long long X) {
		long long NOWS = Size;
		while (L < R) {
			if (L & 1) {
				Node[L + NOWS] += X;
				L++;
			}
			if (R & 1) {
				Node[R + NOWS - 1] += X;
				R--;
			}
			L >>= 1, R >>= 1, NOWS >>= 1;
		}
	}
	long long query(long long X) {
		long long ANS = 0;
		long long NOWS = Size;
		while (NOWS > 0) {
			ANS += Node[X + NOWS];
			if (X & 1) X--;
			X >>= 1, NOWS >>= 1;
		}
		return ANS;
	}
};

int main() {
	long long N, Q;
	cin >> N >> Q;
	SegmentTree Seg(N, 0);
	for (int i = 0; i < Q; i++) {
		long long COM;
		cin >> COM;
		if (COM == 0) {
			long long S, T, X;
			cin >> S >> T >> X;
			Seg.update(S - 1, T, X);
		}
		else {
			long long X;
			cin >> X;
			cout << Seg.query(X - 1) << endl;
		}
	}
}