Recursion Dictionary order smaller 2 out of 4 test cases fail

ques link : https://hack.codingblocks.com/contests/c/670/362
code link : https://ide.codingblocks.com/s/85145

@Jaa18Crx0002 could u plzz help me with the question?