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 <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>

using namespace std;

const int M = 33;
const int N = 1001;

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

void solve(char text[]) {
	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);
			}
			cnt = 1;
			strcpy(tmp, word[i]);
		}
	}
	if (maxs < cnt) strcpy(ansm, tmp);
}

int main() {
	int i = 0;
	while (scanf("%s", word[i++]) != EOF);
	solve(i);
	cout<<ansm<<" "<<ansl<<endl;
	return 0;
}

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

int main(){
    // word[s] で 文字列sの出現回数が返ってくる
    map<string, int> word;
    vector<string> v;
    string s;
    
    while( cin >> s ){
        v.push_back(s);
        
        //入力した単語がすでにあるか探す
        // countはすでに文字列sがキーとして存在すれば1が、そうでなければ0が返ってくる
        if( word.count(s) ){ 
            word[s]++;
        }else{
            word[s] = 1;
        }
    }
    // 最頻出の単語を調べる
    int mode = 0;
    for(int i=0 ; i < v.size() ; i++ ){
        mode = max( mode , word[ v[i] ] );
    }
    for(int i=0 ; i < v.size() ; i++ ){
        if( mode == word[ v[i] ] ){
            cout << v[i];
            break;
        }
    }
    // 最長の単語を求める
    int length = 0;
    for(int i=0 ; i < v.size() ; i++ ){
        // v[i].size()で返ってくる数値はint型でなくsize_t型なので注意！
        length = max( length , (int)v[i].size() );
    }
    for(int i=0 ; i < v.size() ; i++ ){
        if( length == v[i].size() ){
            cout << " " << v[i] << endl;
        }
    }
}

C++: #include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <string>
#include <algorithm>
#include <climits>
#include <utility>

#define PRINT(STR) cout << STR << endl;
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); (i)++)
#define REG(i, a, b) for (int (i) = ((int)(a)); (i) < ((int)(b)); i++)
#define ALL(V) (V).begin(), (V).end()
#define SPACE " "

typedef long long ll;

using namespace std;

int nextInt() { int n = -1; cin >> n; return n; }
double nextDouble() { double d = -1; cin >> d; return d; }
ll nextll() { ll n = -1; cin >> n; return n; }
string nextString() { string str; cin >> str; return str; }

int INF = 1LL << 25;
double EPS = 1e-9;

// BEGIN //////////////////////////////////////////////////////////////
int main() {
	map<string, int> d;
	string str;
	while (cin >> str) {
		d[str]++;
	}
	int d_max = -1;
	string ans = "";
	for (auto it = d.begin(); it != d.end(); it++) {
		d_max = max(d_max, it->second);
		if (ans.size() < it->first.size()) {
			ans.assign(it->first);
		}
	}
	for (auto it = d.begin(); it != d.end(); it++) {
		if (it->second == d_max) {
			cout << it->first << SPACE;
			break;
		}
	}
	PRINT(ans);

	return 0;
}
// END   //////////////////////////////////////////////////////////////

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

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <utility>
#include <vector>
#include <numeric>

using namespace std;

struct Data
{
	string word;
	int count;

	Data()
	{
		
	}

	Data(string word)
	{
		this->word = word;
		this->count = 1;
	}
};

int main()
{
	vector<Data> d;

	string str;
	getline(cin, str);

	stringstream ss;
	ss << str;

	string s;
	for (; ss >> s;)
	{
		int i;
		bool b = false;
		for (i = 0; i < d.size(); i++)
		{
			if (d.at(i).word == s)
			{
				b = true;
				break;
			}
		}

		if (b)
		{
			d.at(i).count++;
		}
		else
		{
			d.push_back(Data(s));
		}
	}

	int maxw = 0;
	int maxl = 0;

	string w, l;
	for (int i = 0; i < d.size(); i++)
	{
		if (d.at(i).count > maxw)
		{
			w = d.at(i).word;
			maxw = d.at(i).count;
		}

		if (d.at(i).word.size() > maxl)
		{
			l = d.at(i).word;
			maxl = d.at(i).word.size();
		}
	}

	cout << w << " " << l << endl;
}

C++: #include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	map<string,int> M;
	string S,MS("");
	while(cin>>S){
		M[S]++;
		if(S.size()>MS.size()){
			MS = S;
		}
	}
	
	int num=0;
	for(auto& x:M){
		if(x.second>num){
			S = x.first;
			num = x.second;
		}
	}
	out(S,MS);
	return 0;
}

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

int main() {
	string s;
	vector<string>sa;
	vector<int>h;
	int z;
	string b,m;
	cin >> b;
	sa.push_back(b);
	h.push_back(1);
	z = b.size();
	m = b;
	while (cin >> s) {
		if (s.size() > z) {
			z = s.size();
			m = s;
		}
		int flg = 0;
		for (int i = 0;i < sa.size();i++) {
			if (sa[i] == s) {
				h[i]++;
				flg = 1;
				break;
			}
		}
		if (flg == 0) {
			sa.push_back(s);
			h.push_back(1);
		}

	}
	int va = 0;
	string xs;
	for (int i = 0;i < sa.size();i++) {
		if (va < h[i]) {
			va = h[i];
			xs = sa[i];
		}
	}
	cout << xs << ' ' << m << endl;
	return 0;
}

C++: #include<iostream>
#include<map>
#include<string>
using namespace std;
int main()
{
  map<string,int>m;
  string a[1000];
  char c;
  while(true){
    int i=0;
    while(true){
      cin>>a[i];
      i++;
      if((c=getchar())=='\n')
	break;   
    }
    m.clear();
    for(int j=0;j<i;++j)
      m[a[j]]++;
    int max=0,temp;
    for(int j=0;j<i;++j)
      if(max<m[a[j]]){
	max=m[a[j]];
	temp=j;
      }
    cout<<a[temp]<<' ';
    max=0;
    for(int j=0;j<i;++j)
      if(max<a[j].size()){
	max=a[j].size();
	temp=j;
      }
    cout<<a[temp]<<endl;
  }
  return 0;
}