Getting wrong answer in buy1-get1(BUY1GET1) problem

Here is the link to my solution for BUY1GET1 problem: CodeChef: Practical coding for everyone

I’ve used map datastructure and I don’t know which test case it is failing. What is wrong with this solution ?