Language: C++


// Problem : C - Poll
// Contest : AtCoder Beginner Contest 155
// URL : https://atcoder.jp/contests/abc155/tasks/abc155_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/coder3101/cp-editor)

#include<bits/stdc++.h>
#define pb emplace_back
#define int long long
#define vi vector<int>
#define pii pair<int,int>
#define m_p(x,y) make_pair(x,y)
#define vp vector<pair<int,int>>
#define setbits(x) __builtin_popcountll(x)
#define f first
#define se second
#define iniz(n) memset(n,0,sizeof(n))
#define inin(n) memset(n,-1,sizeof(n))
#define inf LLONG_MAX
using namespace std;
template<typename T1,typename T2>istream &operator>>(istream &is, vector<pair<T1,T2>> &v) { for (pair<T1,T2> &t : v) is >> t.f>>t.se; return is; }
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }
double pi=acos(-1.0);
int md=1000000007;
int abst(int a)
{return a<0?-a:a;}
struct HASH{
  size_t operator()(const pii &x)const{
    return (size_t) x.first * 37U + (size_t) x.second;}};

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

int Pow(int n,int x){int ans=1;
 while(x>0)
 {if(x&1)ans=(ans*n)%md;n=(n*n)%md;x=x>>1;}
 return ans;}

 vi fact,inv;
void inverse(int n)
{inv.resize(n+1);inv[0]=1;
for(int i=1;i<=n;i++)inv[i]=Pow(fact[i],md-2);}
void factorial(int n)
{fact.resize(n+1);fact[0]=1;
for(int i=1;i<=n;i++)fact[i]=(fact[i-1]*i)%md;}

int max(int a,int b){return a>b?a:b;}
int min(int a,int b){return a<b?a:b;}
bool cmp(pair<int,string> p1,pair<int,string> p2)
{
	return p1.f>p2.f;
}
void solve()
{
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int n;cin>>n;
map<string,int> mp;
while(n--)
{
	string s;cin>>s;
	mp[s]++;
}
vector<pair<int,string>> v;
for(pair<string,int> p : mp)
v.pb(m_p(p.se,p.f));
sort(v.begin(),v.end(),cmp);
int x=v[0].f;
int i=0;
while(v[i].f==x)
{
	cout<<v[i].se<<"\n";
	i++;
}

}

int32_t main(){
ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
int t=1;
//cin>>t;
while(t--)
{
    solve();
}
}

// Problem : C - Poll
// Contest : AtCoder Beginner Contest 155
// URL : https://atcoder.jp/contests/abc155/tasks/abc155_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/coder3101/cp-editor)

#include<bits/stdc++.h>
#define pb emplace_back
#define int long long
#define vi vector<int>
#define pii pair<int,int>
#define m_p(x,y) make_pair(x,y)
#define vp vector<pair<int,int>>
#define setbits(x) __builtin_popcountll(x)
#define f first
#define se second
#define iniz(n) memset(n,0,sizeof(n))
#define inin(n) memset(n,-1,sizeof(n))
#define inf LLONG_MAX
using namespace std;
template<typename T1,typename T2>istream &operator>>(istream &is, vector<pair<T1,T2>> &v) { for (pair<T1,T2> &t : v) is >> t.f>>t.se; return is; }
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }
double pi=acos(-1.0);
int md=1000000007;
int abst(int a)
{return a<0?-a:a;}
struct HASH{
  size_t operator()(const pii &x)const{
    return (size_t) x.first * 37U + (size_t) x.second;}};

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

int Pow(int n,int x){int ans=1;
 while(x>0)
 {if(x&1)ans=(ans*n)%md;n=(n*n)%md;x=x>>1;}
 return ans;}

 vi fact,inv;
void inverse(int n)
{inv.resize(n+1);inv[0]=1;
for(int i=1;i<=n;i++)inv[i]=Pow(fact[i],md-2);}
void factorial(int n)
{fact.resize(n+1);fact[0]=1;
for(int i=1;i<=n;i++)fact[i]=(fact[i-1]*i)%md;}

int max(int a,int b){return a>b?a:b;}
int min(int a,int b){return a<b?a:b;}
bool cmp(pair<int,string> p1,pair<int,string> p2)
{
	return p1.f>p2.f;
}
void solve()
{
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int n;cin>>n;
map<string,int> mp;
while(n--)
{
	string s;cin>>s;
	mp[s]++;
}
vector<pair<int,string>> v;
for(pair<string,int> p : mp)
v.pb(m_p(p.se,p.f));
sort(v.begin(),v.end(),cmp);
int x=v[0].f;
int i=0;
while(v[i].f==x)
{
	cout<<v[i].se<<"\n";
	i++;
}

}

int32_t main(){
ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
int t=1;
//cin>>t;
while(t--)
{
    solve();
}
}


Compiler output:
a.cc:122:43: error: redefinition of 'template<class T1, class T2> std::istream& operator>>(std::istream&, std::vector<std::pair<_T1, _T2> >&)'
  122 | template<typename T1,typename T2>istream &operator>>(istream &is, vector<pair<T1,T2>> &v) { for (pair<T1,T2> &t : v) is >> t.f>>t.se; return is; }
      |                                           ^~~~~~~~
a.cc:23:43: note: 'template<class T1, class T2> std::istream& operator>>(std::istream&, std::vector<std::pair<_T1, _T2> >&)' previously declared here
   23 | template<typename T1,typename T2>istream &operator>>(istream &is, vector<pair<T1,T2>> &v) { for (pair<T1,T2> &t : v) is >> t.f>>t.se; return is; }
      |                                           ^~~~~~~~
a.cc:123:30: error: redefinition of 'template<class T> std::istream& operator>>(std::istream&, std::vector<_Tp>&)'
  123 | template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
      |                              ^~~~~~~~
a.cc:24:30: note: 'template<class T> std::istream& operator>>(std::istream&, std::vector<_Tp>&)' previously declared here
   24 | template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
      |                              ^~~~~~~~
a.cc:124:30: error: redefinition of 'template<class T> std::ostream& operator<<(std::ostream&, const std::vector<_Tp>&)'
  124 | template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }
      |                              ^~~~~~~~
a.cc:25:30: note: 'template<class T> std::ostream& operator<<(std::ostream&, const std::vector<_Tp>&)' previously declared here
   25 | template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }
      |                              ^~~~~~~~
a.cc:125:8: error: redefinition of 'double pi'
  125 | double pi=acos(-1.0);
      |        ^~
a.cc:26:8: note: 'double pi' previously defined here
   26 | double pi=acos(-1.0);
      |        ^~
a.cc:126:5: error: redefinition of 'long long int md'
  126 | int md=1000000007;
      |     ^~
a.cc:27:5: note: 'long long int md' previously defined here
   27 | int md=1000000007;
      |     ^~
a.cc:127:5: error: redefinition of 'long long int abst(long long int)'
  127 | int abst(int a)
      |     ^~~~
a.cc:28:5: note: 'long long int abst(long long int)' previously defined here
   28 | int abst(int a)
      |     ^~~~
a.cc:129:8: error: redefinition of 'struct HASH'
  129 | struct HASH{
      |        ^~~~
a.cc:30:8: note: previous definition of 'struct HASH'
   30 | struct HASH{
      |        ^~~~
a.cc:133:8: error: redefinition of 'struct custom_hash'
  133 | struct custom_hash {
      |        ^~~~~~~~~~~
a.cc:34:8: note: previous definition of 'struct custom_hash'
   34 | struct custom_hash {
      |        ^~~~~~~~~~~
a.cc:147:5: error: redefinition of 'long long int Pow(long long int, long long int)'
  147 | int Pow(int n,int x){int ans=1;
      |     ^~~
a.cc:48:5: note: 'long long int Pow(long long int, long long int)' previously defined here
   48 | int Pow(int n,int x){int ans=1;
      |     ^~~
a.cc:152:5: error: redefinition of 'std::vector<long long int> fact'
  152 |  vi fact,inv;
      |     ^~~~
a.cc:53:5: note: 'std::vector<long long int> fact' previously declared here
   53 |  vi fact,inv;
      |     ^~~~
a.cc:152:10: error: redefinition of 'std::vector<long long int> inv'
  152 |  vi fact,inv;
      |          ^~~
a.cc:53:10: note: 'std::vector<long long int> inv' previously declared here
   53 |  vi fact,inv;
      |          ^~~
a.cc:153:6: error: redefinition of 'void inverse(long long int)'
  153 | void inverse(int n)
      |      ^~~~~~~
a.cc:54:6: note: 'void inverse(long long int)' previously defined here
   54 | void inverse(int n)
      |      ^~~~~~~
a.cc:156:6: error: redefinition of 'void factorial(long long int)'
  156 | void factorial(int n)
      |      ^~~~~~~~~
a.cc:57:6: note: 'void factorial(long long int)' previously defined here
   57 | void factorial(int n)
      |      ^~~~~~~~~
a.cc:160:5: error: redefinition of 'long long int max(long long int, long long int)'
  160 | int max(int a,int b){return a>b?a:b;}
      |     ^~~
a.cc:61:5: note: 'long long int max(long long int, long long int)' previously defined here
   61 | int max(int a,int b){return a>b?a:b;}
      |     ^~~
a.cc:161:5: error: redefinition of 'long long int min(long long int, long long int)'
  161 | int min(int a,int b){return a<b?a:b;}
      |     ^~~
a.cc:62:5: note: 'long long int min(long long int, long long int)' previously defined here
   62 | int min(int a,int b){return a<b?a:b;}
      |     ^~~
a.cc:162:6: error: redefinition of 'bool cmp(std::pair<long long int, std::__cxx11::basic_string<char> >, std::pair<long long int, std::__cxx11::basic_string<char> >)'
  162 | bool cmp(pair<int,string> p1,pair<int,string> p2)
      |      ^~~
a.cc:63:6: note: 'bool cmp(std::pair<long long int, std::__cxx11::basic_string<char> >, std::pair<long long int, std::__cxx11::basic_string<char> >)' previously defined here
   63 | bool cmp(pair<int,string> p1,pair<int,string> p2)
      |      ^~~
a.cc:166:6: error: redefinition of 'void solve()'
  166 | void solve()
      |      ^~~~~
a.cc:67:6: note: 'void solve()' previously defined here
   67 | void solve()
      |      ^~~~~
a.cc:190:9: error: redefinition of 'int32_t main()'
  190 | int32_t main(){
      |         ^~~~
a.cc:91:9: note: 'int32_t main()' previously defined here
   91 | int32_t main(){
      |         ^~~~