Solve problem 34 using C++.
Improve performance of Python's problem 34.