AquaMoon and Strange Sort

CodeForces - 1546C