Counting inversions
inversions += ( mid - i + 1 ) ; temp [ k ++ ] = v [ j ++ ] ; } } while ( i <= mid ) temp [ k ++ ] = v [ i ++ ] ; while ( j <= right ) temp [ k ++ ] = v [ j ++ ] ; k = 0 ; for ( int a = left ; a <= right ; a ++ ) { v [ a ] = temp [ k ++ ] ; } }