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>
#include <vector>
using namespace std;
typedef pair<string, int> PAIR;

int main(){
	vector<PAIR> vec;
	vector<PAIR>::iterator ite;
	vector<PAIR>::iterator max;
	string st, siz;
	while(cin >> st){
		if(st == "0") break;
		if(vec.empty()){
			vec.push_back(PAIR(st, 1));
			//max = vec.begin();
			//siz = st;
		}else{
			ite = vec.begin();
			while(1){
				if((*ite).first == st){
					(*ite).second++;
					//if((*max).second < (*ite).second) max = ite;
					break;
				}
				ite++;
				if(ite == vec.end()){
					vec.push_back(PAIR(st, 1));
					//if(siz.size() < st.size()) siz = st;
					break;
				}
			}
		}

		ite = vec.begin();
		max = vec.begin();
		siz = (*ite).first;
		while(ite != vec.end()){
			if((*max).second < (*ite).second) max = ite;
			if(siz.size() < (*ite).first.size()) siz = (*ite).first;
			ite++;
		}

		cout << (*max).first << " " << siz << endl;

	}
	return 0;
}

C++: #include<iostream>
#include<string>
#include<algorithm>	
#include<cmath>
#include<map>
#include<vector>
#define int long long
using namespace std;
int uiop[123456];
string test[123456];
signed main() {
	int n, b = 0, sum = 0, ans = 0; string s, t = "a", u = "a";
	for (int h = 0; h < 8; h++) {
		cin >> s; if (ans < s.size()) { ans = s.size(); t = s; }
		int a = 0;
		for (int i = 0; i < b; i++) {
			if (test[i] == s) {
				uiop[i]++; a++;
			}
		}
		if (a == 0) {
			test[b] = s; uiop[b]++; b++;
		}
	}
	for (int h = 0; h < b; h++) {
		sum = max(sum, uiop[h]);
	}
	for (int h = 0; h < b; h++) {
		if (uiop[h] == sum) {
			u = test[h];
		}
	}
	cout << u << ' ' << t << endl;
}

C++: #include <bits/stdc++.h>

using namespace std;

int main()
{
    map<string, int> mp;
    string w, word, mw;
    while (cin >> word) {
        mp[word]++;
        if (mp[word] > mp[mw]) mw = word;
        if (word.size() > w.size()) w = word;
    }
    cout << mw << " " << w << endl;
    return 0;
}

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

int main()
{
	string s;
	string maxLenS = "";
	map<string, int> m;
	vector<string> v;
	while (cin >> s)
	{
		if (maxLenS.size() < s.size())
		{
			maxLenS = s;
		}
		if (m.find(s) == m.end())
		{
			m[s] = 0;
			v.push_back(s);
		}
		else
		{
			m[s]++;
		}
	}
	int maxIndex = 0;
	for (int i = 0; i < v.size(); i++)
	{
		if (m[v[i]] > m[v[maxIndex]])
		{
			maxIndex = i;
		}
	}
	cout << v[maxIndex] << " " << maxLenS << endl;
	return 0;
}

C++: #include <iostream>
#include <string>
using namespace std;
int main(){
    long saidai=0;
    char f;
    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++){
                if(isupper(str[j])){
                    f=str[j];
                    f=f+32;
                    str[j]=f;
                }
                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]==""))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++: #define _USE_MATH_DEFINES
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<list>
#include<stack>
#include<queue>
#include<cctype>
#include<iomanip>
#include<functional>
#include<numeric>
#include<map>
#include<set>
#define EPS 1e-10
using namespace std;
typedef long long llong;
int main() {
	map<string, int>a;
	int len = 0, freq = 0;
	string s;
	while (cin>>s) {
		a[s]++;
		if (len < s.length())len = s.length();
		if (freq < a[s])freq = a[s];
	}
	for (auto it = a.begin(); it != a.end(); it++) {
		if (freq == it->second)cout << it->first << " ";
	}
	for (map<string, int>::iterator it = a.begin(); it != a.end(); it++) {
		if (len == it->first.length())cout << it->first << endl;
	}
	return 0;
}

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

int main() {
  string s;
  vector<string> s_list;
  map<string, int> s_map;
  while (cin >> s) {
    s_map[s]++;
    s_list.push_back(s);
  }
  int max_s = 0;
  int i;
  for (i = 0; i < s_list.size(); i++) {
    max_s = max(max_s, s_map[s_list[i]]);
  }
  for (i = 0; i < s_list.size(); i++) {
    if (s_map[s_list[i]] == max_s) {
      cout << s_list[i] << ' ';
      break;
    }
  }
  int max_length = 0;
  for (i = 0; i < s_list.size(); i++) {
    max_length = max(max_length, (int)(s_list[i].length()));
  }
  for (i = 0; i < s_list.size(); i++) {
    if (max_length == s_list[i].length()) {
      cout << s_list[i] << endl;
      break;
    }
  }
  return 0;
}

C++: #define _USE_MATH_DEFINES
#include <iostream>
#include <queue>
#include <vector>
#include <math.h>
#include <algorithm>
#include <iomanip>
#include <string>
#include <stack>
#include <cctype>
#include <cstdlib>
#include <string.h>
#include <utility>
#include <cstdio>
#include <set>
#include <map>
#include <boost/multiprecision/cpp_int.hpp>
#include <assert.h>
using namespace std;
namespace mp = boost::multiprecision;

#define INF (1 << 20)
#define EPS (1e-10)
#define EQ(a,b) (fabs((a)-(b)) < EPS)

#define ll long long
#define LL long long

int main() {
	string s;
	map<string, int> n;
	int maxl = 0;
	string maxls;
	while (cin >> s) {
		transform(s.begin(), s.end(), s.begin(), (int (*)(int))tolower);
		if (s.length() > maxl) {
			maxl = s.length();
			maxls = s;
		}
		auto res = n.find(s);
		if (res == n.end()) n.insert(make_pair(s, 1));
		else res->second++;
	}
	int maxn = 0;
	string maxns;
	for_each(n.begin(), n.end(), [&](pair<string, int> p) {
			if (p.second > maxn) {
			maxn = p.second;
			maxns = p.first;
			}
			});
	cout << maxns << ' ' << maxls << endl;
	return 0;
}

C++: #include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
using namespace std;
vector<string> st;
map<string,int> stm;
main(){
  char hoge[1001];
  string str;
  fgets(hoge,sizeof(hoge),stdin);
  str=hoge;
  int stp=0;
  int n=str.size();
  for(int i=0;i<n;i++){
    if(str.at(i)==' '){
      st.push_back(str.substr(stp,i-stp));
      stp=i+1;
      stm[st.back()]++;
    }
  }
  st.push_back(str.substr(stp,n-stp-1));

  int m=st.size();

  string strmax;
  string stres;
  int count=0;
  int tc=0;
  for(int i=0;i<m;i++){
    if(i==0){
      strmax=st[0];
      stres=st[0];

    }else{
      if(strmax.size() < st[i].size()){
	strmax=st[i];
      } 
      if(stm[st[i]] > stm[stres]){
	stres=st[i];
      }
    }
    
  } 
  cout << stres <<" "<<strmax<<endl;
}