This documentation is automatically generated by online-judge-tools/verification-helper
#define PROBLEM "https://judge.yosupo.jp/problem/point_add_range_sum"
#include "../../../src/template/template.hpp"
#include "../../../src/data_structure/fenwick_tree.hpp"
int main(void) {
int n, q;
cin >> n >> q;
FenwickTree<ll> fw(n);
rep(i, 0, n) {
ll a;
cin >> a;
fw.add(i, a);
}
while(q--) {
int t;
cin >> t;
if(t == 0) {
int p, x;
cin >> p >> x;
fw.add(p, x);
} else {
int l, r;
cin >> l >> r;
cout << fw.sum(l, r) << '\n';
}
}
}
#line 1 "verify/library_checker/data_structure/point_add_range_sum.test.cpp"
#define PROBLEM "https://judge.yosupo.jp/problem/point_add_range_sum"
#line 2 "src/template/template.hpp"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<long long, long long>;
#define rep(i, a, b) for(long long i = (a); i < (b); ++i)
#define rrep(i, a, b) for(long long i = (a); i >= (b); --i)
constexpr long long inf = 4e18;
struct SetupIO {
SetupIO() {
ios::sync_with_stdio(0);
cin.tie(0);
cout << fixed << setprecision(30);
}
} setup_io;
#line 3 "src/data_structure/fenwick_tree.hpp"
template <typename T>
struct FenwickTree {
FenwickTree(const int N)
: n(N), data(N) {}
void add(int p, const T& x) {
assert(0 <= p and p < n);
++p;
while(p <= n) {
data[p - 1] += x;
p += p & -p;
}
}
T sum(const int l, const int r) const {
assert(0 <= l and l <= r and r <= n);
return sum(r) - sum(l);
}
T get(const int x) const {
assert(0 <= x and x < n);
return sum(x + 1) - sum(x);
}
private:
int n;
vector<T> data;
inline T sum(int r) const {
T s = 0;
while(r > 0) {
s += data[r - 1];
r -= r & -r;
}
return s;
}
};
#line 4 "verify/library_checker/data_structure/point_add_range_sum.test.cpp"
int main(void) {
int n, q;
cin >> n >> q;
FenwickTree<ll> fw(n);
rep(i, 0, n) {
ll a;
cin >> a;
fw.add(i, a);
}
while(q--) {
int t;
cin >> t;
if(t == 0) {
int p, x;
cin >> p >> x;
fw.add(p, x);
} else {
int l, r;
cin >> l >> r;
cout << fw.sum(l, r) << '\n';
}
}
}