#include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i ) #define rep(i,n) REP(i,0,n) typedef long long ll; typedef pair pint; typedef pair pli; const int inf=1e9+7; const ll longinf=1LL<<60 ; const ll mod=1e9+7 ; template struct SegmentTree{ struct Node{ T val; Node *lch,*rch; Node(T val):val(val),lch(nullptr),rch(nullptr){} }; Node *root; ll sz; T id; T f(T x,T y){ //return max(x,y); //return min(x,y); return x+y; //return {x.first*y.first, y.first*x.second + y.second}; } T g(T x,T y){ //return x; return x+y; } T val(Node* t){return t ? t->val : id;} SegmentTree(ll sz_,T id_=0):root(nullptr),id(id_){ sz=1; while(szval=g(x,t->val); return t; } if(k<(l+r)/2)t->lch=update(t->lch,k, l, (l+r)>>1, x); else t->rch=update(t->rch,k, (l+r)>>1, r, x); t->val=f(val(t->lch), val(t->rch)); return t; } T get(Node* t, ll a,ll b,ll l, ll r){ if(!t)return id; if(b<=l||r<=a)return id; if(a<=l&&r<=b)return t->val; T lx=get(t->lch, a, b, l, (l+r)>>1); T rx=get(t->rch, a, b, (l+r)>>1, r); return f(lx,rx); } void update(ll k,T x){ root = update(root, k, 0, sz, x); } T get(ll a, ll b){ return get(root, a, b, 0, sz); } }; typedef pair P; int main(){ int n; cin>>n; SegmentTree sg(inf); ll ans=0; rep(i,n){ int a,b,c; cin>>a>>b>>c; if(a){ ans+=sg.get(b,c+1); } else { sg.update(b,c); } } cout<