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<cstdio>
#include<string>
#include<map>
using namespace std;
int main(){
  map<string,int> t;
  string s, mxc, mxl;
  int freq, len;
  while(cin >> s){
    if(t.find(s) == t.end()){
      t[s] = 1;
    }
    else{
      t[s]++;
    }

    if(t[s] > freq){
      freq = t[s];
      mxc = s;
    }
    if(s.size() > len){
      len = s.size();
      mxl = s;
    }
  }
  cout << mxc << " " << mxl << endl;
}

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

int main(){
    std::string inp;
    std::map<std::string, int> occ;
    std::string maxLen, maxOcc;
    while(std::cin >> inp){
        (occ[inp])++;
        if(occ[maxOcc] < occ[inp])
            maxOcc = inp;
        if(maxLen.size() < inp.size())
            maxLen = inp;
    }
    std::cout << maxOcc << ' ' << maxLen << std::endl;    
}

C++: #include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>

using namespace std;

const int M = 33;
const int N = 3333001;

char text[N];
char word[N][M];
char tmp[N], ansm[N], ansl[N]; 

int cmp(const void *a, const void *b) {
	return strcmp((char *)a, (char *)b);
}

void solve(char text[]) {
	int len = strlen(text);
//	for (int i=0; i<len; ++i) {
//		if (text[i] >= 'A' && text[i] <= 'Z') text[i] = text[i] - 'A' + 'a';
//	}
	int j = 0, k = 0;
	for (int i=0; i<len; ++i) {//分解文章 
		if (text[i] != ' ') word[k][j++] = text[i];
		else {
			if (j == 0) continue;
			word[k++][j] = '\0', j = 0;
		}
	}
	if (j) word[k++][j] = '\0';
	qsort(word, k, sizeof(word[0]), cmp);
	int maxs = -1;
	int cnt = 1;
	strcpy(tmp, word[0]);
	strcpy(ansl, word[0]);
	int maxl = strlen(word[0]);
	for (int i=1; i<k; ++i) {
		if (maxl < strlen(word[i])) maxl = strlen(word[i]), strcpy(ansl, word[i]);
		if (!strcmp(tmp, word[i])) ++cnt;
		else {
			if (maxs < cnt) {
				maxs = cnt;
				strcpy(ansm, tmp);
			}
			strcpy(tmp, word[i]);
		}
	}
	if (maxs < cnt) strcpy(ansm, tmp);
}

int main() {
	cin.getline(text, N, '\n');
//	while (cin.getline(text, N, '\n')) {
		solve(text);
		cout<<ansm<<" "<<ansl<<endl;
//	}
	return 0;
}

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

int main()
{
	string t;
	multiset<string> d;
	while (cin >> t)
	{
		d.insert(t);
	}

	t = *(d.begin());
	multiset<string>::iterator it;
	for (it=++d.begin(); it!=d.end(); it++)
	{
		if (d.count(t) < d.count(*it)) t = *it;
	}
	cout << t << ' ';

	t = *(d.begin());
	for (it=++d.begin(); it!=d.end(); it++)
	{
		if (t.size() < it->size()) t = *it;
	}
	cout << t << endl;

	return 0;
}

C++: #include <map>
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
int main(){
	std::string s;
	std::map<std::string,int> M;
	int maxlen=0;
	while(std::cin>>s){
		maxlen = std::max(maxlen, (int)s.size());
		M[s]++;
	}
	int maxapp=0;
	for(std::map<std::string,int>::iterator it = M.begin(); it != M.end(); ++it){
		maxapp = std::max(maxapp, it->second);
	}	
	for(std::map<std::string,int>::iterator it = M.begin(); it != M.end(); ++it){
		if(maxapp == it->second)std::cout<<it->first<<" ";
	}
	for(std::map<std::string,int>::iterator it = M.begin(); it != M.end(); ++it){
		if(maxlen == (it->first).size())std::cout<<it->first<<std::endl;
	}
	return 0;
}

C++: #include <iostream>
#include <string>
#include <map>
using namespace std;
int main(){
  int c=0;
  string s,large="",max;
  map<string,int>wordbox;
  while(cin>>s){
    wordbox[s]++;
    if(s.length()>large.length())large=s;
  }
  map<string,int>::iterator it=wordbox.begin();
  while(it!=wordbox.end()){
    if((*it).second>c)max=(*it).first,c=(*it).second;
    it++;
  }
  cout<<max<<" "<<large<<endl;
  return 0;
}

C++: #include<iostream>
#include<vector>
#include<sstream>
#include<string>
using namespace std;
int main(){
  string str;getline(cin,str);stringstream ss(str);
  vector<string> v;vector<int> n;
  while(ss >> str){
    bool f=0;
    for(int i=0;i<v.size();i++){
      if(str==v[i]) {
	n[i]++;f=1;
      }
    }
    if(!f){
      v.push_back(str);
      n.push_back(1);
    }
  }
  str="";int c=0;
  for(int i=0;i<v.size();i++){
    if(c<n[i]) c=n[i];
  }
  for(int i=0;i<v.size();i++){
    if(n[i]==c) cout << v[i];
    if(str.size()<v[i].size()) str=v[i];
  }cout << " " << str << endl;
}

C++: #include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define pb         push_back
#define mp         make_pair
#define ll         long long
#define PI         acos(-1.0)
#define ALL(A)     ((A).begin(), (A).end())
#define vsort(v)   sort(v.begin(),v.end())
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)


int main(){
    int i, j, lmax=0, lind=0, nmax=0, nind=0, cnt=0, vsize;
    string s,vv;
    vector<string> v;
    while(cin>>s){
        v.pb(s);
    }
    cout << v.size() << endl;
    for(i=0;i<v.size();i++){
        cnt=0;
        for(j=0;j<v.size();j++){
            if(v[i]==v[j]){
                cnt++;
            }
        }
        if(nmax<cnt){
            nmax=max(cnt,nmax);
            nind=i;
        }
        if(lmax<v[i].size()){
            vv=v[i];
            lmax=max(lmax,vv.size());
            lind=i;
        }
    }
    cout << v[lind] << v[nind] << endl;
}

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

using namespace std;

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

C++: #include <iostream>
#include <string>
#include <map>
using namespace std;
int main()
{
	int maxtime = 0, maxlen = 0;
	string str, maxTimeWord, maxLenWord;
	map<string, int> word;
	while (cin >> str)
	{
		if ((signed)str.length() > maxlen)
			maxlen = str.length(), maxLenWord = str;
		if ((word[str]++) >= maxtime)
			maxtime = word[str], maxTimeWord = str;
		if (cin.get() == '\n') break;
	}
	cout << maxTimeWord << " " << maxLenWord << endl;

	return 0;
}

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

using namespace std;

int main()
{
	string s;
	string max_length_string = "";
	map<string, int> m;

	while (cin >> s) {
		m[s]++;
		if (s.size() > max_length_string.size() ) {
			max_length_string = s;
		}
	}

	// 最頻値を求める
	int max = 0;
	string mode = "";
#if 0
	for ( auto x : m ) {
		if (x.second > max) {
			mode = x.first;
			max = x.second;
		}
	}
#else
	for (map<string,int>::iterator it = m.begin(); it != m.end(); it++) {
		if (it->second > max) {
			mode = it->first;
			max = it->second;
		}
	}
#endif
	cout << mode << " " << max_length_string << endl;

	return 0;
}