codility-lesson-8 in C&C++