Getting Wrong Answer, Please help

Getting Wrong Answer, Please help

#include <bits/stdc++.h>
using namespace std;

class FenwickTree{
    vector<int> arr;
    public:
    FenwickTree(int n){
        arr.resize(n + 1, 0);
    }
    int query(int index){
        int res = 0;
        while(index > 0){
            res += arr[index];
            index -= (index & (-index));
        }
        return res;
    }

    void update(int index, int val){
        while(index < arr.size()){
            arr[index] += val;
            index += (index & (-index));
        }
    }
};

bool comp(const pair<int,string> &p1, const pair<int,string> &p2){
    return (p1.first < p2.first);
}

int main(){
    int n;
    cin>>n;
    vector<pair<int,string> > arr(n);
    for(int i = 0; i < n; i++){
        cin>>arr[i].second>>arr[i].first;
    }
    sort(arr.begin(), arr.end(), comp);
    int id = 0;
    unordered_map<string,int> prodMp;
    map<int,int> pricesMp;
   
    for(int i = 0; i < n; i++){
        prodMp[arr[i].second] = i;
        if(i-1 >= 0 && arr[i].first == arr[i-1].first);
        else{
            id++;
            pricesMp[arr[i].first] = id;
        }
    }

    FenwickTree tree(id);
    int q;
    cin>>q;
    while(q--){
        char qType;
        cin>>qType;
        if(qType == '+'){
            string product;
            cin>>product;
            tree.update(pricesMp[arr[prodMp[product]].first], 1);
        }
        else if(qType == '-'){
            string product;
            cin>>product;
            tree.update(pricesMp[arr[prodMp[product]].first], -1);
        }
        else{
            int prices;
            cin>>prices;

            auto itr = pricesMp.lower_bound(prices);
            if(itr == pricesMp.end()) cout<<0<<endl;
            else{
                int total_prod = tree.query(id);
                if(itr-> first == prices){
                    int count_prod = tree.query(itr->second);
                    cout<<total_prod - count_prod <<endl;
                }
                else if(itr == pricesMp.begin()){
                    cout<<total_prod<<endl;
                }
                else{
                    itr--;
                    int count_prod = tree.query(itr->second);
                    cout<<total_prod - count_prod <<endl;
                }
            }
        }
    }
    return 0;
}