Help me in solving AIRM problem

My issue

This was the code that I wrote whilst the competition and I was getting wrong answer. I don’t understand what was wrong in this code. After seeing the hints, I submitted a different code for which I got Correct answer. Although, the approach is different, the logic remained the same.

My code

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

#define lli long long int

int main() {
	// your code goes here
	lli t;
	cin>>t;
	while(t--) {
	    lli n;
	    cin>>n;
	    vector<lli> v;
	    lli runways = 1;
	    for (lli i = 0; i < n*2; i++) {
	        lli temp;
	        cin>>temp;
	        v.push_back(temp);
	    }
	    sort(v.begin(),v.end());
	    
	    lli curr,count;
	    
	    for (lli i = 0; i < n*2; i++) {
	        if (i == 0) {
	            curr = v[i];
	            count = 1;
	        }
	        
	        else if (v[i] == curr) {
	            count++;
	        } else if (v[i] != curr) {
	            if (count > runways) runways = count;
	            count = 1;
	            curr = v[i];
	        }
	    }
	    cout<<runways<<"\n";
	}
	return 0;
}

Problem Link: AIRM Problem - CodeChef

@elsonpais the logic is to find the max frequency of a number .
in the first test case 4 has occured 3 times , so the answer is 3
i have pasted my correct code below

Hope this helps!!
include <bits/stdc++.h>
using namespace std;

int main() {
// your code goes here
int t;
cin>>t;
while(t–)
{ unordered_map<int,int>mp;
int n;
cin>>n;
std::vectorv;
for(int i=0;i<2*n;i++)
{ int a; cin>>a;
mp[a]++;
}
int mx=0;int res=-1;
for(auto x:mp)
{
if(x.second>mx){
res= x.first;
mx=x.second;
}
}
cout<<mx<<endl;
}
return 0;
}