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



int main()
{
	vector<string> word;
	string sent;
	int ss = 0;
	getline(cin, sent);
	//input word
	for(int i = 0; i < sent.size(); i++)
	{
		if(sent[i] == ' ' )
		{
			
			word.push_back(sent.substr(ss,i - ss));
			int inc = 1,tmp = i;
			while(1)
			{
				if(!(sent[tmp+1] == ' ') )	break;
				++inc; ++tmp;
			}
			ss = i + inc;
		}
		if(i == sent.size() - 1)
		{
			word.push_back(sent.substr(ss, (i+1) - ss));
		}
	}
	
	int leng = 0, p = 0;
	//length
	for(int i = 0;i < word.size(); i++)
	{
		if(word[i].size() > leng)
		{
			leng = word[i].size();
			p = i;
		}
	}
	//cout << word[p] << endl;
	//frequency
	/*
	int bucket[1024];
	for(int i = 0; i < 1024; i++) bucket[i] = 0;
	
	vector<string> list;

	for(int i = 0; i < word.size(); i++)
	{
		if( list.empty() || !( find(list.begin(), list.end(), word[i]) == list.end() ) )
		{
			list.push_back(word[i]);
		}
		for(int i = 0; i < list.size(); i++)
		{
			cout << list[i] << endl;
		}
	}
	*/
	
	map<string, int> freq;
	for(int i = 0;i < word.size(); i++)
	{
		bool judge = false;

		if(freq.find(word[i]) == freq.end())
		{
			freq.insert(make_pair<string,int>(word[i], 1));
		}
		else
		{
			freq[ word[i] ]++;
		}
	}
	map<string, int>::iterator it, high;
	leng = 0;
	for(it = freq.begin(); it != freq.end(); it++)
	{
		if( leng < (*it).second)
		{
			leng = (*it).second;
			high = it;
		}	
		//cout << (*it).first << (*it).second << endl;
	}
	cout << (*high).first << ' ' << word[p] << endl;
}

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

class MNode {
private:
	const string key;
	int value;
	MNode *left, *right;
public:
	MNode(string k, int v);
	~MNode();
	MNode* find(string k);
	int& Value() { return value; }
};

MNode::MNode(string k, int v) : key(k), value(v) {
	left = nullptr;
	right = nullptr;
}

MNode::~MNode() {
	if (left != nullptr)
		delete left;
	if (right != nullptr)
		delete right;
}

MNode* MNode::find(string k) {
	if (key == k)
		return this;
	else if (k < key) {
		if (left == nullptr) {
			left = new MNode(k, 0);
			return left;
		}
		else
			return left->find(k);
	}
	else {
		if (right== nullptr) {
			right = new MNode(k, 0);
			return right;
		}
		else
			return right->find(k);
	}
}

class StrIntMap {
private:
	MNode *root;
	const string center;
public:
	StrIntMap();
	~StrIntMap();
	int& operator [](string str) {
		return (root->find(str))->Value();
	}
};

StrIntMap::StrIntMap() : center("n") {
	root = new MNode(center, 0);
}

StrIntMap::~StrIntMap() {
	delete root;
}

int main() {
	string str;
	StrIntMap m;
	int maxlen = 0, maxnum = 0;
	string maxlen_str, maxnum_str;
	while (cin >> str) {
		if (++m[str] > maxnum) {
			maxnum = m[str];
			maxnum_str = str;
		}
		if (str.size() > maxlen) {
			maxlen = str.size();
			maxlen_str = str;
		}
	}
	cout << maxnum_str << ' ' << maxlen_str << endl;
}

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

int main() {
	string sp,st,hw,ew;
	map<string,int> sd;
	int s=0,e=0,k=0,h=0,m=0;
    getline(cin,st);
	st=st+"  ";
	while(e!=st.size()) {
	 for(e; st[e]!=' ' ;e++);
	 sp.append(st,s,e-s);
	 if (sp.length()>h) { h=sp.length(); hw=sp; }
	 if (sd.find(sp)==sd.end()) sd.insert(map<string,int>::value_type(sp,1));
	 else {sd[sp]++ ; if (sd[sp]>m) m=sd[sp]; }
	 e++; s=e; sp=""; 
	}
	map<string,int>::iterator it=sd.begin();
	for (h=0;it!=sd.end();it++) if (h<(*it).second) { h=(*it).second; ew=(*it).first;}
	cout << ew << endl << hw << endl;
	return 0;
}

C++: #include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<cstring>
using namespace std;
int main(){
	char ans[40][10000] = {{0}};
	char a[10000] = {0};
	scanf("%[^\n]",a);
	int cnt = 0;
	int mx_len = 0;
	char date[10000] = {0};
	for(int i = 0,j = 0; i <= strlen(a); i++){
        if(a[i] >= 'a' && a[i] <= 'z' || a[i] >= 'A' && a[i] <= 'Z'){
            ans[cnt][j] = a[i];
            j++;
        }
        else{
            if(mx_len < j){
                strncpy(date,a+i-j,j);
                mx_len = max(mx_len,j);
            }
            cnt++;
            j = 0;
        }
	}
	char da[10000] = {0};
	int check[10000] = {0};
	for(int i = 0; i < cnt; i++){
        for(int j = i; j < cnt; j++){
            if(i != j){
                if(strcmp(ans[i],ans[j]) == 0){
                    fill(ans[j],ans[j]+1000,-1);
                    check[i]++;
                }
            }
        }
	}
	mx_len = 0;
	char mx_date[10000] = {0};
	for(int i = 0; i < cnt; i++){
	    if(mx_len < check[i]){
	        strcpy(mx_date,ans[i]);
            mx_len = max(mx_len,check[i]);
	    }
	}
    cout << mx_date << " "<< date << endl;
	return 0;
}

C++: // clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
template<typename V> constexpr typename V::value_type sum(const V &v) { return accumulate(all(v), 0); }
void solve();
main { solve(); return 0; }
// clang-format on

void solve() {
  vs v;
  string s;
  while (cin >> s) transform(all(s), s.begin(), ::tolower), v.pb(s);
  map<string, int> m;
  int freq = 0, len = 0;
  string freqs, lens;
  rep(i, v.size()) {
    if (cmax(freq, ++m[v[i]])) {
      freqs = v[i];
    }
    if (cmax(len, v[i].size())) {
      lens = v[i];
    }
  }
  cout << freqs << ' ' << lens << endl;
}

C++: #include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<cstring>
using namespace std;
int main(){
	char ans[50][10000] = {{0}};
	char a[10000] = {0};
	scanf("%[^\n]",a);
	int cnt = 0;
	int mx_len = 0;
	char date[10000] = {0};
	int j = 0;
	int len = 0;
	for(int i = 0; a[i] != 0; i++) len++;
	for(int i = 0; i <= len; i++){
        if('a' <= a[i] && a[i] <= 'z' || 'A' <= a[i] && a[i] <= 'Z'){
            ans[cnt][j] = a[i];
            j++;
        }
        else{
            cnt++;
            j = 0;
        }
	}
	for(int i = 0; i < cnt; i++){
        cout << ans[i] << endl;
	}
	return 0;
}