help in recovering from SIGSEGV error on codechef

here is my code
link:Code link

the local machine is not giving any kind of runtime errors but on codechef its giving a runtime error
any help will be greatly appreciated. I use Ubuntu to do the coding (GCC 6.3.0)

You have initialized the arrays with size n and m which you don’t have value for

thank you i cleared that error
Do you think multi threading will help improve time effiency??

//