SIGSEGV error

can anyone tell me why the program at this link:CodeChef: Practical coding for everyone
is showing SIGSEGV error.

DON’T use malloc. You are using C++, so why not just use std::vector? No memory management troubles.

Moreover all your members (of class) are public, so instead use a struct.