Why my code is not working?

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

bool sortByVal(const pair<string, int> &a,
const pair<string, int> &b)
{
return (a.second > b.second);
}

int main() {
multimap<string,int> m;
int x;
cin>>x;
int n;
cin>>n;
for(int i = 0; i<n; i++)
{
string name;
int sal;
cin>>name>>sal;
m.insert(make_pair(name,sal));
}

vector<pair<string, int>> vec;

multimap<string, int> :: iterator it2;
for (it2=m.begin(); it2!=m.end(); it2++)
{
vec.push_back(make_pair(it2->first, it2->second));
}

sort(vec.begin(), vec.end(), sortByVal);

for (int i = 0; i < vec.size(); i++)
{
	if(vec[i].second >= x)
	cout << vec[i].first << " "<< vec[i].second << endl;
}

return 0;

}

Custom compare for this problem must be something like this:
bool mycompare(pair<string,int> p1,pair<string,int> p2)
{
if(p1.second==p2.second)
{
return p1.first<p2.first;
}
return p1.second>p2.second;
}

Dry run and recheck your logic.
Also please don’t paste your code directly. Save your code on ide.codingblocks.com and then share its link.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.