#include using namespace std; #define ALL(x) (x).begin(),(x).end() #define IO ios::sync_with_stdio(false),cin.tie(nullptr); #define LB(v, x) (ll)(lower_bound(ALL(v),x)-(v).begin()) #define UQ(v) sort(ALL(v)),(v).erase(unique(ALL(v)),v.end()) #define REP(i, n) for(ll i=0; i<(ll)(n); i++) #define FOR(i, a, b) for(ll i=(ll)(a); (a)<(b) ? i<(b) : i>(b); i+=((a)<(b) ? 1 : -1)) #define chmax(a, b) ((a)<(b) ? ((a)=(b), 1) : 0) #define chmin(a, b) ((a)>(b) ? ((a)=(b), 1) : 0) template using rpriority_queue=priority_queue,greater>; using ll=long long; const int INF=1e9+10; const ll INFL=4e18; using ld=long double; using ull=uint64_t; using LL=__int128_t; using VI=vector; using VVI=vector; using VL=vector; using VVL=vector; using PL=pair; using VP=vector; using WG=vector>>; template struct SegTreeDyanamic { using Type=typename Monoid::Type; struct Node { Type value; array to; ll left,right; Node(ll l, ll r) { to.fill(-1); left=l; right=r; } }; vector node; ll mx=1e9; vector route; SegTreeDyanamic(ll mx=1e9, int q=5e5) { this->mx=mx; node.reserve(q); node.push_back(Node(0,mx)); route.reserve(100); } void set(ll i, Type v) { ll left=0,right=mx,cur=0; route.clear(); while(left Type { if(rightr) return Monoid::id(); if(l<=left&&right<=r) return node[idx].value; ll mid=(left+right)/2; int leftc=node[idx].to[0],rightc=node[idx].to[1]; Type leftv,rightv; if(leftc==-1) leftv=Monoid::id(); else leftv=dfs(dfs,leftc,left,mid); if(rightc==-1) rightv=Monoid::id(); else rightv=dfs(dfs,rightc,mid,right); return Monoid::op(leftv,rightv); }; return dfs(dfs,0,0,mx); } }; /// @brief モノイド namespace Monoid { /// @brief Minモノイド /// @tparam max_value 単位元 template struct Min { using Type=T; static Type id() { return max_value; } static Type op(const Type& a, const Type& b) { return min(a,b); } }; /// @brief Maxモノイド /// @tparam min_value 単位元 template struct Max { using Type=T; static Type id() { return min_value; } static Type op(const Type& a, const Type& b) { return max(a,b); } }; /// @brief 和 template struct Sum { using Type=T; static Type id() { return 0; } static Type op(const Type& a, const Type& b) { return a+b; } }; /// @brief (和,区間の長さ) template struct SumPair { using Type=pair; static Type id() { return make_pair(T(0),0); } static Type op(const Type& a, const Type& b) { return {a.first+b.first,a.second+b.second}; } }; } //---------------------------------------------------------- int main() { IO; int Q; cin>>Q; const int N=1e9+10; SegTreeDyanamic> seg(N); ll ans=0; while(Q--) { int t; cin>>t; if(t==0) { int x,y; cin>>x>>y; seg.set(x,seg.fold(x,x+1)+y); } else { int l,r; cin>>l>>r; r++; ans+=seg.fold(l,r); } } cout<