#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; vector tree; long long int sum(int i) { long long int ans = 0; while (i > 0) { ans += tree[i]; i -= (i & -i); } return ans; } void update(int i, long long int diff) { while (i < tree.size()) { tree[i] += diff; i += (i & (-i)); } } int main(void) { cin.tie(0); ios::sync_with_stdio(false); int n, a, b, c; vector >> query; set S; map idx; cin >> n; for (int i = 0; i < n; i++) { cin >> a >> b >> c; query.push_back(make_pair(a, make_pair(b, c))); if (a == 0) { S.insert(b); } else { S.insert(b); S.insert(c); } } int num = 1; for (auto it : S) { idx[it] = num++; } tree.resize(num); long long int res = 0; for (int i = 0; i < n; i++) { if (query[i].first == 0) { int IDX = idx[query[i].second.first]; update(IDX, query[i].second.second); } else { int L = idx[query[i].second.first]; int R = idx[query[i].second.second]; res += (sum(R) - sum(L - 1)); } } cout << res << '\n'; return 0; }