Place the Tiles

Sir, getting Runtime error for last two testcase. I made sure to use map for given contraints too. Please suggest where am I going wrong, as first 4 cases are passing.

Because of such large constraints, top-down DP doesn’t works due to stack overflow!
use bottom up DP

Okay, I implemented the code using Bottom up approach, currently getting TLE on those two cases(n being 10^8).

See my code, I submitted it on hackerblocks and it got accepted, try submitting at hackerblocks!

Could you please share the link, do not know under which section it belongs.