TopCoder SRM 597