Write a function to count, for each element, how many smaller elements appear to its right in an array.
Implement count_smaller(nums), where nums is a list of integers. Return a list where result[i] is the number of elements strictly smaller than nums[i] that occur at an index greater than i. Equal values are not counted. Aim for better than O(n²) time.
def count_smaller(nums):