Why do i get a Run Time Error here? I can use dynamic memory allocation (malloc, free, ..) in C right?

Here is my submission - https://www.codechef.com/viewsolution/19460938
It gives runtime error on codechef but it works on my computer.
Why am I getting this runtime error?
I can use dynamic memory allocation, Right?