Count smaller elements on right side(array)

i am not able to code the logic that i have made for this ques
i want to use stl i.e using unordered map and pair,we store index and element and sort it using stl comparator and than generate answer
help me implement this logic only.not other methods