#include using namespace std; using ll = long long; template map compress(vector &A){ map comp; int N = A.size(), i=0; for (int i=0; i struct BIT { private: vector bit; int N; T _sum(int r){ r++; T res = 0; while(r > 0) res += bit[r-1], r -= r & -r; return res; } public: BIT (int n){ N = n; bit.resize(N);} BIT (vector &a) : BIT(a.size()) { for (int i=0; i> n; vector t(n), x(n), y(n), z; for (int i=0; i> t[i] >> x[i] >> y[i]; z.push_back(x[i]); if (t[i] == 1) z.push_back(y[i]); } auto comp = compress(z); for (int i=0; i bit(comp.size()+1); for (int i=0; i