HackerEarth Match makers problem solution - TheCScience