For the Benefit of All (hard version) | CodeChef