Topcoder SRM 596 Div. 2 problems.