Code for problem "Candy".