Given an array, count the number of inversions: pairs where but . Example: has 3 inversions: .
Naive approach: check all pairs in . BIT approach: process right to left. For each element, query how many smaller elements you've seen so far (to the right).
This counts inversions. Constraints: up to elements.