TopCoder SRM 589 Div2