Topcoder C++ and C# solutions