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++: #define _CRT_SECURE_NO_DEPRECATE  
#define _CRT_NONSTDC_NO_DEPRECATE

#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <ctime>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <functional>
#include <cctype>
#include <numeric>
#include <cstring>
#include <bitset>
#include <complex>
#include <complex>

using namespace std;

template<typename T> ostream& operator<<(ostream& os, const vector<T>& v){
    //os << "{ ";
    for (typename vector<T>::const_iterator it = v.begin(); it != v.end(); ++it)
        os << "" << *it << "" << (it + 1 == v.end() ? "" : " ");
    //os << " }";
    return os;
}
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<string> vs;
typedef long long ll;
typedef unsigned uint;
typedef unsigned long ul;
typedef unsigned long long ull;

#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define loop(i,a,b) for(ull i=(a); i<(ull)(b); i++)
#define rep(i,b) loop(i,0,b)
#define iter(i,c) for(auto it=c.begin(); it!=c.end(); ++it)
#define pb push_back
#define mp make_pair
string const resstr[] = { "Impossible", "Possible", "No", "Yes" };

int main(){
    int msize = 0;
    string s;
    set<string> dic;
    map<string, int> ss;
    while (1){
        string in; 
        if (!(cin >> in)) break;
        dic.insert(in);
        ss[in]++;
        if (msize < in.size()){
            s = in;
            msize = s.size();
        }
    }
    string a = s;
    int f = 0;
    iter(it,dic){
        if (f < ss[*it]){
            f = ss[*it];
            s = *it;
        }
    }
    cout << s << " " << a << endl;
}

C++: #include <iostream>
#include <string>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <climits>
#include <cfloat>
#include <map>

using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)

const int INF = INT_MAX;

typedef long long LL;
typedef pair<int,int> P;

int main(){
    vector<string> str;
    map<string,int> m;
    string s;
    while(cin>>s){
        str.push_back(s);
        m[s]++;
    }
    int ans1=0;
    string ans1str,ans2str;
    int ans2=0;
    int n=str.size();
    rep(i,n){
        if(str[i].length()>ans2){
            ans2=str[i].length();
            ans2str=str[i];
        }
    }
    rep(i,n){
        if(m[str[i]]>ans1){
            ans1=m[str[i]];
            ans1str=str[i];
        }
    }
    cout << ans1str << " " << ans2str << endl;
    return 0;
}

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

map<string,int> M;
int main(){
	int N=0,L=0;
	string word,fre,lon;
	while(cin>>word){
		M[word]+=1;
		if(M[word]>N){
			N=M[word];
			fre=word;
		}
		if(word.size()>L){
			L=word.size();
			lon=word;
		}
	}
	cout<<fre<<" "<<lon<<endl;
}

C++: #include <cstdio>
#include <cstring>
#include <string>
#include <algorithm>
using namespace std;
int main()
{
	int m=0,i,j,t=0,p=0,count,len,max_len=0;
	int dc[1001];
	for(i=0;i<1001;i++)
	{
		dc[i] = 0;
	}
	char str[1001],max_word[33],word[33],d[1001][33];
	fgets(str,sizeof(str),stdin);
	memset(d,'\0',sizeof(d));
	memset(word,'\0',sizeof(word));
	len = strlen(str);
	for(i=0;i<len;i++)
	{
		if(str[i] == ' '||i==len-1)
		{
			strcpy(d[p],word);
			p++;
			if(max_len < strlen(word))
			{
				max_len = strlen(word);
				memset(max_word,'\0',sizeof(max_word));
				strcpy(max_word,word);
				memset(word,'\0',sizeof(word));
				t=0;
			}
			else
			{
				memset(word,'\0',sizeof(word));
				t=0;
			}
		}
		else
		{
			word[t]=str[i];
			t++;
		}
	}
	for(i=0;i<p;i++)
	{
		for(j=i+1;j<p;j++)
		{
			if(strcmp(d[i],d[j]) == 0)
			{
				dc[i]++;
			}
		}
	}
	for(i=0;i<p;i++)
	{
		if(dc[i] > m)
		{
			m=i;
		}
	}
	printf("%s %s\n",d[m],max_word);
	return 0;

}

C++: #define _USE_MATH_DEFINES
 
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>

using namespace std;

int main(){
	vector<string> str;
	int count[1000]={0};
	//int length[1000]={0};
	string max_length="";

	string s;
	while(cin >> s){
		int i;
		bool find_flag = 1;
		for(i=0;i<str.size();i++){
			if(str[i]==s){
				count[i]++;
				find_flag = 0;
				break;
			}
		}
		if( find_flag ){
			str.push_back(s);
			if(s.size()>max_length.size()){
				max_length = s;
			}
		}
	}
	
	int max = 0;
	for(int i=0;i<str.size();i++){
		if(count[i]>count[max]){
			max=i;
		}
	}
	cout << str[max] << " " << max_length << endl;
	
	return 0;
}

C++: #include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<time.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
const int inf=1e8;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
vector<vector<char> >tmp;
vector<vector<int> >scr;
int main(){
	string s;
	string nagai;
	int naga=0;
	map<string,int>m;
	while(cin>>s){
		if(naga<s.size()){naga=s.size();nagai=s;}
		//cout<<naga<<" "<<s.size()<<endl;
		m[s]++;
	}
	int ma=-1;
	string mas;
	map<string,int>::iterator it=m.begin();
	
	for(;it !=m.end();it++){
		string t=it->first;
		if(ma<m[t]){ma=m[t];mas=t;}
	}
	cout<<mas<<" "<<nagai<<endl;
}

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

int main() {
    map<string,int> freq;
    int amx = 0, bmx = 0;
    string s, a, b;
    while (cin >> s) {
        freq[s] ++;
        if (amx < freq[s]) {
            amx = freq[s];
            a = s;
        }
        if (bmx < s.size()) {
            bmx = s.size();
            b = s;
        }
    }
    cout << a << " " << b << endl;
    return 0;
}

C++: #include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <set>
using namespace std;
#define rep2(x,from,to) for(int x=(from); x<(to); (x)++)
#define rep(x,to) rep2(x,0,to)
int main() {
	string s;
	vector<string> str1;
	set<string> str2;
	while(cin >> s && s != "0") {
		str1.push_back(s);
		str2.insert(s);
	}
	int w = 0;
	string ret;
	rep(i,str1.size()) {
		if(w < str1[i].length()) {
			w = str1[i].length();
			ret = str1[i];
		}
	}

	int cnt[1000];
	rep(i,1000) {
		cnt[i] = 0;
	}
	int c = 0;
	for(auto it=str2.begin(); it != str2.end(); ++it) {
		rep(j,str1.size()) {
			if(*it == str1[j]) cnt[c]++;
		}
		c++;
	}
	int max = 0, r = 0;
	string ret2;
	for(auto it=str2.begin(); it != str2.end(); ++it) {
		if(max < cnt[r]) {
			max = cnt[r];
			ret2 = *it;
		}
		r++;
	}
	cout << ret << " " << ret2 << endl;
	return 0;
}