apple pie's submission of Buy 2 Get 1 Free | CodeChef