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<functional>
#include<algorithm>
using namespace std;

int main(){
	string sentence[1000];
	int sentenceNum[1000];
	int array[1000];
	string input;
	int count = 0;
	bool flag;
	int maxLength = 0;

	for(int i=0; i < 1000; i++) sentenceNum[i] = 0;

	while(cin >> input){
		flag = false;
		if(!count){
			sentence[0] = input;
			sentenceNum[0]++;
			count++;
			int inputSize = input.size();
			maxLength = max(maxLength, inputSize);
		}

		else {
			for(int i=0; i < count; i++){
				if(sentence[i] == input){
					sentenceNum[i]++;
					flag = true;
					break;
				}
			}
			if(!flag){
				sentence[count] = input;
				sentenceNum[count]++;
				count++;
				int inputSize = input.size();
				maxLength = max(maxLength, inputSize);
			}
		}
	}

	for(int i=0; i < 1000; i++) array[i] = sentenceNum[i];

	sort(array, array+1000, greater<int>());

	for(int i=0; i< count; i++){
		if(array[0] == sentenceNum[i]){
			cout << sentence[i];
		}
	}
	for(int i=0; i< count; i++){
		int sentenceSize = sentence[i].size();
		if(maxLength == sentenceSize){
			cout << " " << sentence[i] << endl;
		}
	}
}

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

using namespace std;

int main(){
  string str;
  int max_len = 0;
  int max_fac = 0;
  string max_str1;
  string max_str2;
  map<string, int> map_str;
  while(cin >> str) {
    transform(str.begin(), str.end(), str.begin(), ::tolower);
    map_str[str]++;
  }

  map<string, int>::iterator it;
  for(it = map_str.begin(); it != map_str.end(); it++) {
    if(max_len < (it->first).size()) {
      max_len = (it->first).size();
      max_str1 = it->first;
    }
    if(max_fac < it->second) {
      max_fac = it->second;
      max_str2 = (it->first);
    }
  }

  cout << max_str2 << " " << max_str1 << endl;

  return 0;
}

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

using namespace std;

int main()
{
	string str[10000],mstr,lstr;
	int size=0,max=0,i,j;
	
	for(i=0;cin >> str[i];i++)
	{
		if(size<str[i].size())
			lstr=str[i];
	}
	for(j=0;j<i;j++)
	{
		int count=0;
		for(int k=j;k<i;k++)
			if(str[j]==str[k])
				count++;
		if(max<=count)
		{
			max=count;
			mstr=str[j];
		}
	}
	cout << mstr << " " << lstr << endl;
}

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

int main (void){

	string str,maxByLength("");
	//map<int,string> X; //¶Ì·³
	map<string,int> Y; //¶Ì
	//int mm;

	while (cin>>str){
		if (str.size()>maxByLength.size())	maxByLength=str;
		Y[str]++;
	}

	string maxByCount("");
	int cnt = 0;
	for(map<string, int>::iterator it = Y.begin(); it != Y.end(); ++it) {
		if(it->second > cnt) {
			maxByCount = it->first;
			cnt = it->second;
		}
	}

	cout << maxByCount << " " << maxByLength << endl;

	// cout << (*Y.rbegin()).first << " " << maxByLength << endl;
	return 0;

}

C++: #include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <math.h>
#include <functional>
#include <algorithm>
#include <utility>

typedef long long Int;
#define REP(i,n) for(int i = 0 ; i < n ; ++i)
using namespace std;


map<string, int> aa;
set<string> dic;

int main(){
	string a;

	while (cin >> a){
		dic.insert(a);
		++aa[a];
	}

	int m = 0;
	string ms;

	int m2 = 0;
	string ms2;


	for (auto x : dic){
		if (m < x.length()){
			m = x.length();
			ms = x;
		}
	}

	for (auto x : aa){
		if (m2 < x.second){
			ms2 = x.first;
			m2 = x.second;
		}
	}

	cout << ms2 << " " << ms << endl;

	return 0;
}

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

int main() {
	map<string, int> ms;
	string s, ans, ans2;
	int max = 0, max2 = 0;
	
	while (cin >> s) {
		ms[s]++;
		if (max2 < ms[s]) {
			max2 = ms[s];
			ans2 = s;
		}
		if (max < s.size()) {
			max = s.size();
			ans = s;
		}
		
	}
	cout << ans2 << " " << ans << endl;
}

C++: //#define _GRIBCXX_DEBUG
#include <algorithm>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <iomanip>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;


// ?????¬???????????¬??????
#pragma region MACRO
#define P(x) cout << (x) << endl
#define p(x) cout << (x)
#define PED cout << "\n"
#define rep(i,n) for(int i=0; i<(int)n; ++i)
#define REP(i,x,n) for(int i=x; i<(int)n; ++i)
#define repi(i,n) for(int i=0; i<=(int)n; ++i)
#define REPI(i,x,n) for(int i=x; i<=(int)n; ++i)
#define ILP while(true)
#define FOR(i,c) for(__typeof((c).begin())!=(c).begin(); i!=(c).end(); ++i)
#define ALL(c) (c).begin(), (c).end()
#define mp make_pair
#pragma endregion

// ???
#pragma region TYPE_DEF
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<string, string> pss;
typedef pair<string, int> psi;
typedef pair<int, string> pis;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long> vl;
typedef vector<long long> vll;
typedef vector<string> vs;
#pragma endregion

// Effective std
#pragma region ESTD
template<typename C, typename T>
constexpr int count(C& c, T t) { return count(ALL(c), t); }
template<typename C, typename F>
constexpr int count_if(C& c, F f) { return count_if(ALL(c), f); }
template<typename C, typename T>
void erase(C& c, T t) { remove(ALL(c), t), c.end(); }
template<typename C>
void remove(vector<C>& c, unsigned int index) { c.erase(c.begin()+index); }
template<typename C, typename T, typename U>
constexpr void replace(C& c, T t, U u) { replace(ALL(c), t, u); }
template<typename C, typename F, typename U>
constexpr void replace_if(C& c, F f, U u) { (ALL(c), f, u); }
template<typename C>
constexpr void reverse(C& c) { reverse(ALL(c)); }
template<typename C>
constexpr void sort(C& c) { sort(ALL(c)); }
template<typename C, typename Pred>
constexpr void sort(C& c, Pred p) { sort(ALL(c), p); }
#pragma endregion

// ?????°
#pragma region CONST_VAL
#define PI (2*acos(0.0))
#define EPS (1e-9)
#define MOD (int)(1e9+7)
#pragma endregion


int main()
{
    map<string, int> d;
    string s;
    while(cin>>s) d[s]++;
    string ans1 = "";
    int mx_count1 = 0;
    string ans2 = "";
    int mx_count2 = 0;
    for (auto el : d) {
        if(el.second>=mx_count1) {
            ans1 = el.first;
            mx_count1 = el.second;
        }
        if(el.first.size()>=mx_count2) {
            ans2 = el.first;
            mx_count2 = el.first.size();
        }
    }
    cout << ans1 << " " << ans2 << endl;
    return 0;
}

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

int main() {
	string str[1000],tmp;
	int a[1000] = {}, flag = 0, max = 1, i, length = 0, num = 0;

	while (cin >> tmp) {
		if (flag == 0) {
			flag++;
			tmp[0] = tmp[0] + 'a' - 'A';
		}
		for (i = 0; i < max;i++) {
			if (tmp == str[i]) {
				a[i]++;
				break;
			}
		}

		if (i == max) {
			str[i] = tmp;
			max++;
		}

		if ((int)tmp.size() > length) {
			num = i;
			length = (int)tmp.size();
		}
	}

	cout << str[max] << " " << str[length] << endl;
	return 0;
}