My solutions to CodinGame with Haxe
Compile into JS, and replace "{INPUT}" and 9999 by readline() and console.log by print It's did automatically with sed in build.hxml. Remove the -cmd line if you haven't got 'sed' command.
(Look at JS folder for JS generated and used to validate)