#include #include #define llint long long using namespace std; struct SegNode{ llint val; int left, right, parent; SegNode(llint p, llint x = 0){ //initial value left = right = -1; parent = p; val = x; } }; struct SegTree{ llint size; vector seg; SegTree(llint size){ this->size = size; init(); } void init() { seg.clear(); seg.push_back(SegNode(-1)); } void check(llint p){ if(seg[p].left == -1){ seg.push_back(SegNode(p)); seg[p].left = (llint)seg.size()-1; } if(seg[p].right == -1){ seg.push_back(SegNode(p)); seg[p].right = (llint)seg.size()-1; } } void update(llint i, llint val) { llint p = 0, l = 0, r = (1<> n; llint t, a, b, ans = 0; for(llint i = 0; i < n; i++){ cin >> t >> a >> b; if(t == 0){ seg.update(a, seg.query(a, a)+b); } if(t == 1){ ans += seg.query(a, b); } } cout << ans << endl; return 0; }