Go: package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
)

var scanner = bufio.NewScanner(os.Stdin)

func nextString() string {
	scanner.Scan()
	return scanner.Text()
}

type Pair struct {
	key   string
	value int
}

func main() {
	scanner.Split(bufio.ScanWords)
	counts := map[string]int{}
	maxLen := 0
	maxLenWord := ""
	for {
		word := nextString()
		if word == "" {
			break
		}

		counts[word]++

		if len(word) > maxLen {
			maxLen = len(word)
			maxLenWord = word
		}
	}

	mapPairs := []Pair{}
	for k, v := range counts {
		mapPairs = append(mapPairs, Pair{k, v})
	}
	sort.Slice(mapPairs, func(i, j int) bool { return mapPairs[i].value > mapPairs[j].value })

	fmt.Println(mapPairs[0].key, maxLenWord)
}

C++: #include <iostream>
#include <string>
using namespace std;
int main(){
    long saidai=0;
    int a=0,cnt=0,num=0,max=0;
    string str,tango[1000],answer,ans;
    getline(cin,str);
    for(int i=0;i<str.size();i++){
        if(str[i]==' '){
            for(int j=a;j<i;j++){
                tango[cnt]+=str[j];
            }
            cnt=cnt+1;
            a=i+1;
        }
    }
    for(int p=a;p<str.size();p++){
        tango[cnt]+=str[p];
    }
    
    for(int k=0;k<1000;k++){
        if((tango[k]=="0"))break;
        if(saidai<tango[k].size()){
            saidai=tango[k].size();
            ans=tango[k];
        }
    }
    
    for(int s=0;s<=cnt;s++){
        for(int t=s+1;t<=cnt;t++){
            if(tango[s]==tango[t]){
                num=num+1;
            }
        }
        if(max<num){
            max=num;
            answer=tango[s];
        }
    }
    cout<<answer<<" "<<ans<<endl;
    return 0;
}

C++: #include<iostream>
#include <map>

using namespace std;

int main()
{
	string a;
	string max;
	map<string, int> n;
//	map<int, string>::iterator i;

	max = "";
	while (cin>>a) {
		n[a] ++;
		if ( a.size() > max.size() ) max = a;
	}

	map<string, int>::iterator i = --n.end();
	cout<<(*i).first<<" "<<max<<endl;

	return 0;
}

C++: #include<iostream>
#include<cstring>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdio>
#include<cmath>
#define pb(in,tmp) in.push_back(tmp)
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) loop(i,0,b)
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
using namespace std;
int main(){
string s;
vector<string>a;
vector<int>b,c;
while(cin>>s){
int no=-1;
rep(j,a.size())if(a[j]==s)no=j;
if(no+1)b[no]++;
else{
pb(a,s);
pb(b,0);
pb(c,s.size());
}
}
int m=0,mi=0;
rep(i,b.size())if(m<b[i]){m=b[i];mi=i;}
cout<<a[mi]<<" ";
m=mi=0;
rep(i,c.size())if(m<c[i]){m=c[i];mi=i;}
cout<<a[mi]<<endl;
}

C++: #include <iostream>
#include <string>
#include <map>
#include <algorithm>
using namespace std;

int main()
{	
	string s, t;
	map<string, int> p;

	while (cin >> s) {
		transform(s.begin(), s.end(), s.begin(), tolower);
		if (p.find(s) != p.end())
			p[s]++;
		else
			p[s] = 1;

		if (s.size() > t.size())
			t = s;
	}

	int m = 0;

	for (map<string, int>::iterator itr = p.begin(); itr != p.end(); itr++)
		m = max(m, itr->second);

	for (map<string, int>::iterator itr = p.begin(); itr != p.end(); itr++)
		if (itr->second == m)
			cout << itr->first << endl;

	cout << t << endl;

	return 0;
}

C++: #include <iostream>
#include <string>
#include <map>
using namespace std;
map<string,int> table;
int main () {
  string word, frequent, longest;
  size_t N=0; //??????????????????
  while (cin >> word) {
    table[word] += 1;
    if (table[word] > N) {
      N = table[word];
      frequent = word;
    }
    if (word.size() > longest.size()) longest = word;
  }
  cout << frequent << " " << longest << endl;
}

C++: #include<set>
#include<cmath>
#include<stack>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<cstdlib>
#include<numeric>
#include<vector>
#include<ctime>
#include<queue>
#include<list>
#include<map>
#define pi acos(-1)
#define INF 0x7fffffff
#define clr(x)  memset(x,0,sizeof(x));
#define clrto(x,siz,y)  for(int xx=0;xx<=siz;xx++)  x[xx]=y;
#define clrset(x,siz)  for(int xx=0;xx<=siz;xx++)  x[xx]=xx;
#define clrvec(x,siz) for(int xx=0;x<=siz;xx++)  x[xx].clear();
#define fop   freopen("in.txt","r",stdin);freopen("out.txt","w",stdout);
#define myprogram By_135678942570
#define clrcpy(x,siz,y)  for(int xx=0;xx<siz;xx++)  x[xx]=y[xx];
using namespace std;
map<string,int>mp;
main()
{
     string tt;
     string maxstr=" ";
     string maxstr2=" ";
     int maxn=0;
     while(cin>>tt)
     {
         mp[tt]++;
         if(mp[tt]>mp[maxstr])
            maxstr=tt;
         if(tt.size()>maxn)
            maxn=tt.size(),maxstr2=tt;
     }
     cout<<maxstr<<" "<<maxstr2<<endl;
     return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
int main(){
      string s,nmax,gmax;
      map<string,int> m;
      int nm = -1, gm = -1;
      while(cin >> s){
            if(nm < (int)s.length()){
                  nm = (int)s.length();
                  nmax = s;
            }
            if(m.count(s))m[s]++;
            else m[s] = 0;
      }
      for(auto it = m.begin(); it != m.end(); it++){
            if(gm < it->second){
                  gm = it->second;
                  gmax = it->first;
            }
      }
      cout <<gmax<<' '<<nmax<<endl;
}

C++: #include <iostream>
#include <map>
#include <string>
#include <sstream>

using namespace std;

int main(int argc, char *argv[]) {
  map<string, int> words;
  string tmp, line;

  getline(cin, line);
  stringstream ss(line);
  while (ss >> tmp)
    if (words.count(tmp) == 0)
      words.insert(pair<string, int>(tmp, 1));
    else
      words[tmp]++;

  map<string, int>::iterator itr = words.begin();
  string longest = (*itr).first;
  map<string, int>::iterator freq = itr;
  while (itr != words.end()) {
    if (longest.size() < (*itr).first.size())
      longest = (*itr).first;
    if ((*freq).second < (*itr).second)
      freq = itr;
    itr++;
  }

  cout << (*freq).first << ' ' << longest << endl;
  return 0;
}

C++: #include <iostream>
#include <string>

using namespace std;

int main(){
	string s;
	string word[500];
	int a[500]={};
	int i,j,k,l;
	int n,m,len;
	i=0;
	while(cin>>s){
		if(i==0){	//????????????????????????
			word[0]=s;
			a[0]++;
			i++;
			len=s.size();
			n=0;
		}
		else {
			if(len<s.size()){	//?????????????????????????????°??´??°
				len=s.size();
				n=i;
			}
			for(j=0; j<i; j++){
				if(s==word[j]){	//?????§????????????????????????
					a[j]++;
					break;
				}
				if(j==i-1){			//??°?????????????????????
					word[i]=s;
					a[i]++;
					i++;
					break;
				}
			}
		}
	}
	m=0;
	for(j=0; j<i; j++){		//????????????????????????????????????
		if(m<a[j])m=j;
	}
	cout<<word[m]<<" "<<word[n]<<endl;
	// for(j=0; j<i; j++){
	// 	cout<<word[j]<<":"<<a[j]<<endl;
	// }
	//cout<<"len:"<<len<<" "<<word[n]<<endl;
	return 0;
}