Sherlock and Inversions

CodeChef - IITI15