from bisect import bisect_left def count_inversion(sequence): return sum(sum(m