Twice-As-Big Pairs — Solution & Editorial
Merge-sort counting, like inversions, but the crossing condition ai > 2aj needs its own two-pointer pass before merging (a BIT over compressed 2·values works too).
Complexity: O(N log N)
Watch out: Negative values: 2·aj with aj negative flips intuition — the comparison must be exact, not index tricks.