Displaying Run error

sir my code is running perfectly on terminal but here it is showing run error. Can u pls help me.

since n is 10^6, making an array of 4 * 10^6 is causing run time error, i would suggest you to solve this using only 1d dp array of size n.
Code for reference purpose

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.