Working on 2008 round1b problem B. Using C++ now because Python is too
slow