정답 코드
#include <iostream>
#include <algorithm>
#include <map>
using namespace std;
int n;
map<string, int> m;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
cin>>n;
for(int i=0; i<n; i++) {
string in;
cin>>in;
if(m.find(in)!=m.end()) { //map에 이미 존재하는 경우
m[in]++;
}
else {
m.insert({in, 0});
}
}
int ans=-1;
string ansStr="";
for(auto a: m) {
if(a.second > ans) {
ans=a.second;
ansStr=a.first;
}
}
cout<<ansStr<<'\n';
return 0;
}