What could be going wrong if it only works for small values (ZCO20002)

I’ve done everything, practically declare all values as long long int and used ans%p at all steps. I’ve even declared extra space on each array. Also checked the value of each variable before using it as an index.

It seems memset has some memory constraints