Finish SRM 144 DIV 1 Problem 1 and the core part of Problem 2