int lowbit(int x) { return x & (-x); } void add(int x, int k) { while (x <= N)c[x] += k, x += lowbit(x); } int sum(int x) { int res = 0; while (x)res += c[x], x -= lowbit(x); return res; }