TopCoder SRM 597 Div1