Go: package main

import (
	"bufio"
	"fmt"
	"os"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Scan()
	l := sc.Text()
	words := strings.Split(l, " ")

	frequency := map[string]int{}
	long := map[string]int{}
	var maxFrequency, longest int
	var frequentWord, longestWord string
	for _, w := range words {
		frequency[w]++
		long[w] = len(w)
		if frequency[w] > maxFrequency {
			maxFrequency = frequency[w]
			frequentWord = w
		}
		if len(w) > longest {
			longest = long[w]
			longestWord = w
		}
	}

	fmt.Println(frequentWord + " " + longestWord)
}

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;
  
}

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;
}