team split-SIGSEGV

for question team-split(TMSLT Problem - CodeChef), i am getting sigsegv error. can anyone help me in solving this problem.
my solution can be viewed here