Run time error in 1 tc

I am getting Run Time Error only in one test case (last test case). Rest every other test case is giving right answer… Help Required…

the link of my code:

Please note that storing string in dp makes it a O(n^6) space complexity approach. Better use int dp.

I have tried to implement this question using int dp 3d array…
I am getting some garbage value as the output…
Here is the link of the code :

add this after declaring the array

memset(dp, 0, sizeof dp);

The header file for this is #include<cstring>