I used unordered_map<long long int, long long int> the key may take values of upto 1e9, this lead to my answer being Time Limit Exceeded.
when I used map<long long int, long long int> it was succesful.
I came to know from other answers that unordered_map is bad when hash function is bad , is there a way to change the hash function of this unordered_map?