Speed up the solution for problem C2