#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    string s,e;
    cin>>n;
    vector <pair<string,string>> m(n);
    for(int i=0;i<n;i++)
    {
        cin >> s >> e;
        if (e.find("gmail")!=string::npos)
            m[i]=make_pair(s,e);
    }
    sort(m.begin(),m.end());
    auto it=m.begin();
    while(it!=m.end())
    {
        cout<<it->first<<"\n";
        it++;
    }
}
Output:
julia
julia
riya
samantha
tanya
My output is correct, but one extra line is getting printed at the beginning and hence none of my test cases pass in Hackerrank.