Racing horses--sigsegv error

Please format your code or link your submission when you ask for help in CC Discuss. It helps to improve the readability of your code.

Note that you have declared s[50] where N can be as large as 5000.