class BIT{ private: vector<int> tree; int m; public: BIT(int n):m(n), tree(n + 1){} int lowbit(int x){ return x & (-x); } void update(int x){ while(x <= m){ tree[x]++; x += lowbit(x); } } int query(int x){ ...