# library

This documentation is automatically generated by online-judge-tools/verification-helper

View the Project on GitHub kazunetakahashi/library

## Code

#define PROBLEM "http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DSL_2_E"

/*
get(i): output the value of a_i.
*/

#include <iostream>
#include <vector>
using namespace std;
using ll = long long;

template <typename T = ll>
{ // index starts at 0.
int N;
vector<T> data;

public:
RangeAddQuery(int N) : N{N}, data(N + 1, T{0}) {}

T get(int i)
{
return _sum(i + 1);
}

void add(int a, int b, T x)
{ // [a, b)
}

private:
T _sum(int i)
{ // [1, i]
T s{0};
while (i > 0)
{
s += data[i];
i -= i & -i;
}
return s;
}

{
while (i <= N)
{
data[i] += x;
i += i & -i;
}
}
};

// ----- main -----

int main()
{
int N, Q;
cin >> N >> Q;
for (auto i = 0; i < Q; ++i)
{
int c;
cin >> c;
if (c == 0)
{
int s, t;
ll x;
cin >> s >> t >> x;
--s;
--t;
}
else
{
int i;
cin >> i;
--i;
cout << RAQ.get(i) << endl;
}
}
}



#line 1 "DataStructure/RangeAddQuery.cpp"
#define PROBLEM "http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DSL_2_E"

/*
get(i): output the value of a_i.
*/

#include <iostream>
#include <vector>
using namespace std;
using ll = long long;

template <typename T = ll>
{ // index starts at 0.
int N;
vector<T> data;

public:
RangeAddQuery(int N) : N{N}, data(N + 1, T{0}) {}

T get(int i)
{
return _sum(i + 1);
}

void add(int a, int b, T x)
{ // [a, b)
}

private:
T _sum(int i)
{ // [1, i]
T s{0};
while (i > 0)
{
s += data[i];
i -= i & -i;
}
return s;
}

{
while (i <= N)
{
data[i] += x;
i += i & -i;
}
}
};

// ----- main -----

int main()
{
int N, Q;
cin >> N >> Q;
for (auto i = 0; i < Q; ++i)
{
int c;
cin >> c;
if (c == 0)
{
int s, t;
ll x;
cin >> s >> t >> x;
--s;
--t;
}
else
{
int i;
cin >> i;
--i;
cout << RAQ.get(i) << endl;
}
}
}