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++11 (judge verdict: Time Limit Exceeded)

#include<cstdio>
#include<vector>
#include<algorithm>
#include<utility>
#include<numeric>
#include<iostream>
#include<array>
#include<string>
#include<sstream>
#include<stack>
#include<queue>
#include<list>
#include<functional>
#define _USE_MATH_DEFINES

#include<math.h>
#include<map>

#define SENTINEL 1000000001

#define min(a,b) ((a)>(b)?(b):(a))
#define max(a,b) ((a)>(b)?(a):(b))

using namespace std;

typedef pair<int, int> pii;

class OwnNode
{
public:
	int num;
	int l, r;
	int left, right;

	OwnNode(int l,int r):l(l),r(r),num(0),left(-1),right(-1){}
};

vector<OwnNode> nodes;

int Build(int l, int r)
{
	int id = nodes.size();
	nodes.push_back(OwnNode(l, r));
	int m = (l + r) / 2;
	if (l + 1 != r)
	{
		nodes[id].left = Build(l, m);
		nodes[id].right = Build(m, r);
	}
	return id;
}

void Update(int id, int s, int t, int v)
{
	if (t <= nodes[id].l || nodes[id].r <= s)
	{
		return;
	}
	
	nodes[id].num += v*(min(t, nodes[id].r) - max(s, nodes[id].l));
	
	int m = (nodes[id].l + nodes[id].r) / 2;
	if (nodes[id].right != -1)
	{
		if (m < t)
		{
			Update(nodes[id].right, s, t, v);
		}
	}
	if (nodes[id].left != -1)
	{
		if (s < m)
		{
			Update(nodes[id].left, s, t, v);
		}
	}
}

int Find(int id,int s, int t)
{
	if (t <= nodes[id].l || nodes[id].r <= s)
	{
		return 0;
	}
	if (s<=nodes[id].l&&nodes[id].r<=t)
	{
		return nodes[id].num;
	}
	int num = 0;
	int m = (nodes[id].l + nodes[id].r) / 2;
	if (nodes[id].right != -1)
	{
		if (m < t)
		{
			num += Find(nodes[id].right,s, t);
		}
	}
	if (nodes[id].left != -1)
	{
		if (s < m)
		{
			num += Find(nodes[id].left, s, t);
		}
	}
	return num;
}

int main()
{
	nodes.reserve(200000);
	int n, q;
	vector<int> ans;
	scanf("%d %d", &n, &q);

	Build(0, n);

	for (int i = 0; i < q; i++)
	{
		int c, s, t, v;
		scanf("%d", &c);

		switch (c)
		{
		case 0:
			scanf("%d %d %d", &s, &t, &v);
			Update(0, s - 1, t, v);
			break;
		case 1:
			scanf("%d", &s);
			ans.push_back(Find(0, s - 1, s));
			break;
		}
	}

	for (auto& n : ans)
	{
		cout << n << endl;
	}

	return 0;
}