Candy Batching problem