MLE exception on actual testcases

Sample test case is passing but the actual test cases are giving MLE exception. Please help

You can check your inbox and paired code