My program is not getting submitted

My issue

Some of the test cases are not satisfied ,could you help me how to correct it.

My code

#include <iostream>
#include <vector>
#include<algorithm>
using namespace std;

int main() 
{
    int t,n;
    cin>>t;
    while(t--)
    {
        cin>>n;
        vector <int> vec;
        for(int i=0;i<n;i++)
        {
            int a;
            cin>>a;
            vec.emplace_back(a);
        }
        int c=0;
        for(auto it:vec)
        {
            if(count(vec.begin(),vec.end(),it)==1)
            c++;
            else
            {
                cout<<(n-count(vec.begin(),vec.end(),it))+1<<endl;
                break;
                
            }
            
        }
        if(c>0)
        cout<<c<<endl;
        
    }
	
	return 0;
}

Problem Link: CodeChef: Practical coding for everyone

@codestar05
your code is missing some conditions .
I have implemented in much simpler way using sorting .
Hope u will get it.

#include <iostream>
#include <vector>
#include<algorithm>
using namespace std;

int main() 
{
    int t,n;
    cin>>t;
    while(t--)
    {
        cin>>n;
        vector <int> v;
        for(int i=0;i<n;i++)
        {
            int a;
            cin>>a;
            v.emplace_back(a);
        }
        int c=1;
        sort(v.begin(),v.end());
        for(int i=1;i<v.size();i++)
        {
           if(v[i]==v[i-1])
           continue;
           else
           c++;
            
        }
        cout<<c<<endl;
        
    }
	
	return 0;
}

Thank you