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++14 (judge verdict: Accepted)

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

using Value = long long int;
const Value INI = 0;


namespace perseg {

	struct lazy_segtree {
		Value val;
		Value lazy;
		int l, r;
		vector < shared_ptr<lazy_segtree>>chs;
		lazy_segtree(const int size_) :val(INI), lazy(INI), l(0), r(size_), chs(2, nullptr) {

		}
		lazy_segtree(const int l_,const int r_):val(INI),lazy(INI),l(l_),r(r_),chs(2,nullptr) {

		}
		Value add_val(const Value&l, const Value&r) {
			return l + r;
		}
		Value add_lazy(const Value&l, const Value&r) {
			return l + r;
		}
		Value ltov(const Value&la) {
			return la*(r - l);
		}
		shared_ptr<lazy_segtree>getch(const int num) {
			if (chs[num] == nullptr) {
				const int m = (l + r) / 2;
				if (!num) {
					chs[0] = make_shared<lazy_segtree>(l, m);
				}
				else {
					chs[1] = make_shared<lazy_segtree>(m,r);
				}
			}
			return chs[num];
		}
		void push() {
			if (lazy!=INI) {
				val += ltov(lazy);
				if (l + 1 != r) {
					const int m = (l + r);
					for (int i = 0; i < 2; ++i) {
						auto ch = getch(i);
						ch->lazy = add_lazy(ch->lazy, lazy);
					}
				}
				lazy = INI;
			}
		}
		Value query(int a, int b) {
			if (r <= a or b <= l)return 0;
			else if (a<=l&&r<=b) {
				return val + ltov(lazy);
			}
			else {
				push();
				const int m = (l + r) / 2;
				const Value lval=getch(0)->query(a, b);
				const Value rval=getch(1)->query(a, b);
				return val=add_val(lval, rval);
			}
		}
		void update(int a,int b,int k) {
			if (r <= a or b <= l)return;
			else if (a<=l && r<=b)lazy += k;
			else {
				push();
				const int m = (l + r) / 2;
				getch(0)->update(a, b, k);
				getch(1)->update(a, b, k);
				val = chs[0]->val + chs[0]->ltov(chs[0]->lazy) + chs[1]->val + chs[1]->ltov(chs[1]->lazy);
			}
		}
	};
}

struct query {
	int l;
	int r;
	int v;
};
using namespace perseg;

int main() {
	int N, Q; cin >> N >> Q;
	lazy_segtree seg(1<<17);
	while (Q--) {
		int a; cin >> a;
		if (a) {
			int i; cin >> i;
			i--;
			Value ans = seg.query(i, i + 1);
			cout << ans << endl;
		}
		else {
			int s, t, x; cin >> s >> t >> x;
			s--;
			seg.update(s, t, x);
		}
	}

	return 0;
}