Hey all ! I've observed that using a ordered map is much better than unordered maps. (There are some cases when using a unordered map we get a TLE ) I'm using python for cp. So what would be alternative for an ordered map in python ? Thanks in advance. Try to solve this problem using ordered and unordered maps and see the difference. https://codeforces.com/contest/1899/problem/D Ps : You can't solve the problem using python dictionaries.