Runtime error in CF02,Edit distance

The link to question is https://www.codechef.com/problems/CF02
The link to my solution is http://ideone.com/dkKV9D

It’s giving correct answers for all test cases i could check but after submitting I am getting runtime error.
Please help me out to find my error.Thanks in advance.

//