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++: #define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl;
typedef long long ll;
typedef unsigned long long ull;

int main()
{
    string s, ans1 = "", ans2 = "";
    map<string, int> mp;
    int n1 = 0, n2 = 0;
    while (cin >> s)
    {
        if (ans2.size() <= s.size())
            ans2 = s;
        mp[s]++;
        if (mp[s] >= mp[ans1])
            ans1 = s;
    }
    cout << ans1 << " " << ans2 << endl;

    return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <algorithm>

using namespace std;

map<string, int> wordCount;

int main() {
	string input = "";
	
	cin >> input;
	
	string maxWord = "";
	
	while (input.size() > 0) {
		
		if (wordCount.find(input) == wordCount.end()) {
			wordCount[input] = 1;
		} else {
			wordCount[input] = wordCount[input] + 1;
		}
		
		if (input.size() > maxWord.size()) {
			maxWord = input;
		}
		
		input = "";
		cin >> input;
	}
	
	int freqCount = 0;
	string freqWord;
	
	for (map<string, int>::iterator it = wordCount.begin(); it != wordCount.end(); it++) {
		if ((*it).second > freqCount) {
			freqCount = (*it).second;
			freqWord = (*it).first;
		}
	}
	
	cout << freqWord << " " << maxWord << endl;
	
	return 0;
}

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

typedef pair<int,string> P;

int main(void)
{

	char c;
	string str,maxstr;
	P d[1001] = {};	

	while(scanf("%c", &c), c != '\n'){
		if(c != ' '){
			str += c;
		}
		else {
			if(strlen(str.c_str()) > strlen(maxstr.c_str())){
				maxstr.clear();
				maxstr = str;
			}
			int i;
			for(i = 0; d[i].first != 0; i++){
				if(d[i].second == str){
					d[i].first++;
					break;
				}
			}
			if(d[i].first == 0){
				d[i] = P(1,str);
			}
			str.clear();
		}
	}
	if(strlen(str.c_str()) > strlen(maxstr.c_str())){
		maxstr.clear();
		maxstr = str;
	}
	int i;
	for(i = 0; d[i].first != 0; i++){
		if(d[i].second == str){
			d[i].first++;
			break;
		}
	}
	if(d[i].first == 0){
		d[i] = P(1,str);
	}
	str.clear();

	sort(d,d+1001);
	cout << d[1000].second << ' ' << maxstr << endl;

	return 0;
}

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

using namespace std;

int main()
{
	string s,max("");
	map<string,int> w;
	map<int,string> x;
	
	while(cin>>s){
		if(s.size()>max.size()) max=s;
		w[s]++;
	}
	
	for(map<string,int>::iterator it=w.begin();it!=w.end();it++)
		x[(*it).second] = (*it).first;
	
	cout<<(*x.rbegin()).second<<" "<<max<<endl;
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef long double real;
typedef pair<int, int> duo;

#define TT template<typename T>
TT T    sq(T x){ return x*x; }
TT int  ubnd(vector<T>& v,T x){ return upper_bound(v.begin(), v.end(), x) - v.begin(); }
TT int  lbnd(vector<T>& v,T x){ return lower_bound(v.begin(), v.end(), x) - v.begin(); }
TT void sort(T& v){ sort(v.begin(), v.end()); }
TT void revs(T& v){ reverse(v.begin(), v.end()); }
TT void uniq(T& v){ sort(v); v.erase(unique(v.begin(), v.end()), v.end()); }
TT void show(T& v,char d=' ',char e='\n'){for(int i=0;i<v.size();++i)cout<<v[i]<<((i==v.size()-1)?e:d);}
TT void inpt(vector<T>& v,int n){ v.reserve(n);for(int i=0;i<n;++i){T x; cin>>x; v.push_back(x);} }
TT T In(){ T x; cin >> x; return x; }

static inline void fast_io(){ ios::sync_with_stdio(0); cin.tie(0); }
static inline int in(){ int x; scanf("%d", &x); return x; }
static inline string instr(){ string x; cin >> x; return x; }
static inline ll pow_mod(ll a, ll k, ll m){ll r=1;for(;k>0;a=a*a%m,k>>=1)if(k&1)r=r*a%m;return r;}
static inline ll mod_inv(ll a, ll p){ return pow_mod(a,p-2,p); }
static const int dx[] = {0, 0, 1, -1, 1, 1, -1, -1};
static const int dy[] = {1, -1, 0, 0, 1, -1, 1, -1};
static const int Mod = 1000000000;

int main()
{
  map<string, int> cnt;
  string word;
  while (cin >> word){
    cnt[word]++;
  }
  int freq, length;
  string freq_s, length_s;
  length = freq = -1;
  for (const auto& v : cnt){
    if (freq < v.second){
      freq = v.second;
      freq_s = v.first;
    }
    if (length < v.first.size()){
      length = v.first.size();
      length_s = v.first;
    }
  }
  cout << freq_s << " " << length_s << endl;
  return (0);
}

// priority_queue queue deque first second front top push pop map set stringstream max_element min_element insert count find

C++: #include <iostream>
#include <string>
using namespace std;
int main(){
	string w[500], s;
	int wn[500] = {0}, n = -1;
	while(cin >> s){
		bool f = true;
		for(int i = 0; i < n; i++)
			if(s == w[i]){
				wn[i]++;
				f = false;
			}
		if(f){
			w[++n] = s;
			wn[n] = 1;
		}
	}
	int m = 0, mi, ml = 0, mli;
	for(int i = 0; i <= n; i++){
		if(wn[i] > m){
			m = wn[i];
			mi = i;
		}
		if((int)w[i].length() > ml){
			ml = (int)w[i].length();
			mli = i;
		}
	}
	cout << w[mi] << " " << w[mli] << endl;
	return 0;
}

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

typedef ostringstream OSS;
typedef istringstream ISS;

typedef vector<int> VI;
typedef vector< VI > VVI;

typedef long long LL;

typedef pair<int, int> PII;
typedef vector<PII> VPII;

#define X first
#define Y second

// 1テヲツ鳴?・ツュツ耀plit ティツヲツ《stream
vector<string> split(const string &str, char delim) {
	istringstream iss(str); string tmp; vector<string> res;
	while(getline(iss, tmp, delim)) res.push_back(tmp);
	return res;
}

int main(void) {
	string s;
	getline(cin, s);

	vector<string> ws = split(s, ' ');
	string max_len;
	
	map<string, int> ws_cnt;

	for (auto w : ws) {
		ws_cnt[w] = 0;
	}

	for (auto w : ws) {
		ws_cnt[w]++;
		if (max_len.size() < w.size()) {
			max_len = w;
		}
	}

	string max_cnt_str;
	int max_cnt = 0;
	for (auto m : ws_cnt) {
		if (max_cnt < m.second) {
			max_cnt = m.second;
			max_cnt_str = m.first;
		}
	}

	cout << max_cnt_str << " " << max_len << endl;
	
	return 0;
}

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

using namespace std;

int main(void){
  vector<string> res;
  vector<int> rei;
  string maxstr;
  string inp;
  while(cin>>inp){
    if(maxstr.size() < inp.size()){
      maxstr = inp;
    }
    bool used = true;
    for(int i = 0 ; i < res.size() ; i ++){
      if(res[i] == inp){
	rei[i]++;
	used = false;
      }
    }
    if(used){
      res.push_back(inp);
      rei.push_back(1);
    }
  }
  string sizee = "";
  int maxw = 0;
  for(int i = 0 ; i < res.size() ; i ++){
    if(maxw < rei[i]){
      sizee = res[i];
      maxw = rei[i];
    }
  }
  cout<<sizee<<" "<<maxstr<<endl;
  
}