For every element of A [ ] apply binary search to find number of pairs where A wins
while ( start <= end ) : NEW_LINE INDENT mid = ( start + end ) // 2 NEW_LINE if ( B [ mid ] <= val ) : NEW_LINE INDENT index = mid NEW_LINE start = mid + 1 NEW_LINE DEDENT else : NEW_LINE INDENT end = mid - 1 NEW_LINE DEDENT DEDENT winA += ( index + 1 ) NEW_LINE