Function to merge two partitions such that the merged array is sorted
void merge ( vector < int > & v , int left , int mid , int right , int & inversions ) { vector < int > temp ( right - left + 1 ) ; int i = left ; int j = mid + 1 ; int k = 0 ; int cnt = 0 ; while ( i <= mid && j <= right ) { if ( v [ i ] <= v [ j ] ) { temp [ k ++ ] = v [ i ++ ] ; } else {