#include #include #include #include template class dynamic_segtree { public: void set(size_t p, S x) { assert(p < n); for (node[p += n] = x; p >>= 1;) node[p] = op(value(p << 1 | 0), value(p << 1 | 1)); } S get(size_t p) { assert(p < n); return value(p + n); } S prod(size_t l, size_t r) { assert(l <= r && r <= n); S resl = e(), resr = e(); for (l += n, r += n; l < r; l >>= 1, r >>= 1) { if (l & 1) resl = op(resl, value(l++)); if (r & 1) resr = op(value(--r), resr); } return op(resl, resr); } private: std::unordered_map node; size_t n; S value(size_t p) { return node.count(p) ? node[p] : e(); } }; using S = int; S op(S a, S b) { return a + b; } S e() { return 0; } int main() { dynamic_segtree seg; size_t q; std::cin >> q; long long ans = 0; while (q--) { int type; std::cin >> type; if (type == 0) { size_t x; int y; std::cin >> x >> y; seg.set(x, seg.get(x) + y); } else { size_t l, r; std::cin >> l >> r; ans += seg.prod(l, r + 1); } } std::cout << ans << '\n'; }