My algorithm competition solution