Fully working solution in C++ for PA05_POT.