//#include #include // cout, endl, cin #include // string, to_string, stoi #include // vector #include // min, max, swap, sort, reverse, lower_bound, upper_bound #include // pair, make_pair #include // tuple, make_tuple #include // int64_t, int*_t #include // printf #include // map #include // queue, priority_queue #include // set #include // stack #include // deque #include // unordered_map #include // unordered_set #include // bitset #include // isupper, islower, isdigit, toupper, tolower #include #include using namespace std; //using namespace atcoder; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define repi(i, a, b) for (int i = (int)(a); i < (int)(b); i++) typedef long long ll; typedef unsigned long long ull; const ll inf=1e18; using graph = vector > ; using P= pair; using vi=vector; using vvi=vector; using vll=vector; using vvll=vector; using vp=vector

; using vpp=vector; //string T="ABCDEFGHIJKLMNOPQRSTUVWXYZ"; //string S="abcdefghijklmnopqrstuvwxyz"; //g++ main.cpp -std=c++14 -I . //cout <d; void comp(vector&a){ sets(a.begin(),a.end()); int cnt=0; for(auto y:s)d[y]=cnt++; for(auto&y:a)y=d[y]; } using np=pair; const ll seg_size=(1ll<<20); ll seg_take(int l,int r,vector &seg){ l+=seg.size()/2; r+=seg.size()/2; ll res=0; while(l &seg){ ind+=seg.size()/2; seg[ind]+=v; while(ind>0){ ind/=2; seg[ind]=seg[2*ind]+seg[ind*2+1]; } } int main(){ int q; cin >> q; int n=2*q; int n2=1; while(n2<=n)n2*=2; vector Q; vi a; rep(i,q){ int t; cin >> t; if(t==0){ int x,y; cin >> x >> y; Q.push_back(np(0,P(x,y))); a.push_back(x); } else { int l,r; cin >> l >> r; Q.push_back(np(1,P(l,r))); a.push_back(l); a.push_back(r); } } comp(a); rep(i,q){ int t=Q[i].first; if(t==0){ Q[i].second.first=d[Q[i].second.first]; } else { Q[i].second.first=d[Q[i].second.first]; Q[i].second.second=d[Q[i].second.second]; } } vi seg(n2*2); ll ans=0; rep(i,q){ int t=Q[i].first; if(t==0){ int x=Q[i].second.first,y=Q[i].second.second; seg_set(x,y,seg); } else { int l=Q[i].second.first,r=Q[i].second.second; ll v=seg_take(l,r+1,seg); ans+=v; } } cout << ans << endl; }