Substring and five rules | CodeChef