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)

/**
 *    author:  math2do
 *    created: 28.02.2020 20:21:13
**/

#include <bits/stdc++.h>

using namespace std;

template <typename A, typename B>
string to_string(pair<A, B> p);
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);
 
string to_string(const string& s) {
  return '"' + s + '"';
}
 
string to_string(const char* s) {
  return to_string((string) s);
}
 
string to_string(bool b) {
  return (b ? "1" : "0");
}
string to_string(const char &ch) {
  return string(1, ch);
}
 
string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}
 
template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  reverse(res.begin(), res.end());
  return res;
}

template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
 
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

class segtree {
 public:
  struct node {
    // don't forget to set default value (used for leaves)
    // not necessarily neutral element!
    int add = 0;
    int val = 0;
    bool mark = false;

    void apply(int l, int h, int v) {
      add += v;
      val += v;
      mark = true;
    }
  };
 
  node unite(const node &a, const node &b) const {
    node res;
    return res;
  }
 
  inline void push(int i, int l, int h) {
    int m = (l + h) >> 1;
    // push from i into lc and rc
    if (tree[i].mark) {
      tree[i << 1].apply(l, m, tree[i].add);
      tree[(i << 1) + 1].apply(m + 1, h, tree[i].add);
      tree[i].add = 0;
      tree[i].mark = false;
    }
  }
 
  inline void pull(int i) {
    tree[i] = unite(tree[i << 1], tree[(i << 1) + 1]);
  }
 
  int n;
  vector<node> tree;
 
  void build(int i, int l, int h) {
    if (l == h) {
      return;
    }
    int m = (l + h) >> 1;
    build(i << 1, l, m);
    build((i << 1) + 1, m + 1, h);
    pull(i);
  }
 
  template <typename M>
  void build(int i, int l, int h, const vector<M> &v) {
    if (l == h) {
      tree[i].apply(l, h, v[l]);
      return;
    }
    int m = (l + h) >> 1;
    build(i << 1, l, m, v);
    build((i << 1) + 1, m + 1, h, v);
    pull(i);
  }
 
  node get(int i, int l, int h, int ql, int qh) {
    if (ql <= l && h <= qh) {
      return tree[i];
    }
    int m = (l + h) >> 1;
    push(i, l, h);
    node res{};
    if (qh <= m) {
      res = get(i << 1, l, m, ql, qh);
    } else {
      if (ql > m) {
        res = get((i << 1) + 1, m + 1, h, ql, qh);
      } else {
        res = unite(get(i << 1, l, m, ql, qh), get((i << 1) + 1, m + 1, h, ql, qh));
      }
    }
    pull(i);
    return res;
  }
 
  template <typename... M>
  void modify(int i, int l, int h, int ql, int qh, const M&... v) {
    if (ql <= l && h <= qh) {
      tree[i].apply(l, h, v...);
      return;
    }
    int m = (l + h) >> 1;
    push(i, l, h);
    if (ql <= m) {
      modify(i << 1, l, m, ql, qh, v...);
    }
    if (qh > m) {
      modify((i << 1) + 1, m + 1, h, ql, qh, v...);
    }
    pull(i);
  }
 
  int find_first_knowingly(int i, int l, int h, const function<bool(const node&)> &f) {
    if (l == h) {
      return l;
    }
    push(i, l, h);
    int m = (l + h) >> 1;
    int res;
    if (f(tree[i << 1])) {
      res = find_first_knowingly(i << 1, l, m, f);
    } else {
      res = find_first_knowingly((i << 1) + 1, m + 1, h, f);
    }
    pull(i);
    return res;
  }
 
  int find_first(int i, int l, int h, int ql, int qh, const function<bool(const node&)> &f) {
    if (ql <= l && h <= qh) {
      if (!f(tree[i])) {
        return -1;
      }
      return find_first_knowingly(i, l, h, f);
    }
    push(i, l, h);
    int m = (l + h) >> 1;
    int res = -1;
    if (ql <= m) {
      res = find_first(i << 1, l, m, ql, qh, f);
    }
    if (qh > m && res == -1) {
      res = find_first((i << 1) + 1, m + 1, h, ql, qh, f);
    }
    pull(i);
    return res;
  }
 
  int find_last_knowingly(int i, int l, int h, const function<bool(const node&)> &f) {
    if (l == h) {
      return l;
    }
    push(i, l, h);
    int m = (l + h) >> 1;
    int res;
    if (f(tree[(i << 1) + 1])) {
      res = find_last_knowingly((i << 1) + 1, m + 1, h, f);
    } else {
      res = find_last_knowingly(i << 1, l, m, f);
    }
    pull(i);
    return res;
  }
 
  int find_last(int i, int l, int h, int ql, int qh, const function<bool(const node&)> &f) {
    if (ql <= l && h <= qh) {
      if (!f(tree[i])) {
        return -1;
      }
      return find_last_knowingly(i, l, h, f);
    }
    push(i, l, h);
    int m = (l + h) >> 1;
    int res = -1;
    if (qh > m) {
      res = find_last((i << 1) + 1, m + 1, h, ql, qh, f);
    }
    if (ql <= m && res == -1) {
      res = find_last(i << 1, l, m, ql, qh, f);
    }
    pull(i);
    return res;
  }
 
  segtree(int _n) : n(_n) {
    assert(n > 0);
    tree.resize(4 * n);
    build(1, 0, n - 1);
  }
 
  template <typename M>
  segtree(const vector<M> &v) {
    n = v.size();
    assert(n > 0);
    tree.resize(4 * n);
    build(1, 0, n - 1, v);
  }
 
  node get(int ql, int qh) {
    assert(0 <= ql && ql <= qh && qh <= n - 1);
    return get(1, 0, n - 1, ql, qh);
  }
 
  node get(int p) {
    assert(0 <= p && p <= n - 1);
    return get(1, 0, n - 1, p, p);
  }
 
  template <typename... M>
  void modify(int ql, int qh, const M&... v) {
    assert(0 <= ql && ql <= qh && qh <= n - 1);
    modify(1, 0, n - 1, ql, qh, v...);
  }
 
  // find_first and find_last call all FALSE elements
  // to the left (right) of the sought position exactly once
 
  int find_first(int ql, int qh, const function<bool(const node&)> &f) {
    assert(0 <= ql && ql <= qh && qh <= n - 1);
    return find_first(1, 0, n - 1, ql, qh, f);
  }
 
  int find_last(int ql, int qh, const function<bool(const node&)> &f) {
    assert(0 <= ql && ql <= qh && qh <= n - 1);
    return find_last(1, 0, n - 1, ql, qh, f);
  }
};

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n, q;
  cin >> n >> q;
  segtree st(n);
  while (q--) {
    int t;
    cin >> t;
    if (t == 0) {
      int x, y, v;
      cin >> x >> y >> v;
      x--; y--;
      debug(x, y, n);
      st.modify(x, y, v);
    } else {
      int x;
      cin >> x;
      x--;
      debug(x, n);
      auto ans = st.get(x, x);
      cout << ans.val << '\n';
    } 
  } 
  return 0;
}