Tilling Problem - II doub1

While submitting the code no response comes out. What’s the error in the code? Please help.

@Rooopak_Sharma hey roopak this problem need a dynamic approach as this question need more computation.