Help me in solving MISSP problem

My issue

Why am I getting wrong answer? I am unable to figure out what’s the problem with my code.

My code

#include<iostream>
#include<map>
#define ll long long int
using namespace std;
int main(){
    int ca;cin>>ca;
    while(ca--){
        ll n;cin>>n;
        map<ll,ll> mp;
        for(ll i=0;i<n;i++){
            ll a;cin>>a;
            mp[a]++;
        }
        for(auto it:mp){
            if(it.second!=2){
                cout<<it.first<<endl;break;
            }
        }
    }
}

Learning course: Arrays, Strings & Sorting
Problem Link: Chef and Dolls Practice Problem in Arrays, Strings & Sorting - CodeChef

Your approach is right but there’s issue with your understanding

Suppose there are 4 ‘1-type’ dolls and 3 ‘2-type’ dolls. So your code will give output as 1 because mp[1] != 2.

But the actual answer is 2 because Chef had 2 pairs of ‘2-type’ dolls (i.e 4 dolls) and 1 of them was stolen.

So you should check ( it.second%2 != 0 )

Like this
for(auto it:mp){
if(it.second%2 != 0){
cout<<it.first<<endl;break;
}
}