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

Here is my submission - CodeChef: Practical coding for everyone
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?