SPOJ problem (GIVEAWAY)

PROBLEM : You are given an array of len <= 5e5. You have to answer q <= 1e5 queries. Each query may ask you to update the value of the array at a particular index, or, find the number of elements greater than or equal to a particular value in a specified range.
problem link
MY IMPLEMENTATION : I used sqrt decompositon + pbds(ordered _set). Each block of sqrt decomposition as an ordered_set.
my solution
My code gives TLE whereas this code does not.
Any help is appreciated.
Thank you for your efforts.

i dont much but study frenwick tree/binary indexed tree for ranged and updation query.