C++ for problem 118 now works on sample input