My code for passing the codeeval problems. (C++ version)