Getting MLE during submission

Hello sir…
I am doing this question from google kickstart …
https://www.youtube.com/redirect?q=https%3A%2F%2Fcodingcompetitions.withgoogle.com%2Fkickstart%2Fround%2F000000000019ff49%2F000000000043b0c6%23problem&event=video_description&redir_token=QUFFLUhqbENDTWk1dnlXRHU3V3dJYV9VbnhHZW9jWjdqQXxBQ3Jtc0tsbHd1WDgteGlDNHlGMG1rejU1UF8wd2NHVm91OG44elc5S2lpZ0l1azFBYTd1c3NtVWlnVlUzaGZ5NXBHZzJ5THJVSFc3LU9ScF9SYlYyQnBYM19MUko1OURreFJtdko5NWt6WHVDVHhPcnRSWXdtcw%3D%3D&v=2yAEj-0A8bk

This problem is based on concept Digit Dp…
I have watched this video and tried to implement the logic it on my own…This is my code…https://ide.codingblocks.com/s/398449
Please see this …It is showing MLE(memory limit exceeded)…
Thanks

the question link isnt working