What are you entering for Input (line 27)? And what are the command-line arguments you are using (argv[])?
I tried to run your program and it crashed upon startup, the reason is that it takes up too much stack space. All those huge arrays are just too much. Move lines 14 and 16 up above main() into global space and the program will run.
line 40: That is a memory leak.
Ignore that comment -- your program is freeing memory correctly.