Go: package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	words := strings.Split(scanner.Text(), " ")
	wordMap := make(map[string]int)
	for _, v := range words {
		wordMap[v]++
	}
	key := ""
	value := -1
	l := -1
	word := ""
	for k, v := range wordMap {
		// fmt.Println(k, v)
		if value < v {
			key = k
			value = v
		}
		if l < len(k) {
			l = len(k)
			word = k
		}
	}

	fmt.Println(key, word)
	// fmt.Println(wordMap)
}

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

using namespace std;

void solve()
{
	map<string, int> Map;
	string str;
	getline(cin, str);
	str += ' ';
	int n = str.size();
	string temp;
	string LongestWord;
	for(int i = 0; i < n; ++i)
	{
		if(str[i] == ' ')
		{
			++Map[temp];
			if(LongestWord.size() < temp.size())
			{
				LongestWord = temp;
			}
			temp.clear();
		}
		else
		{
			temp += str[i];
		}
	}
	int Max = 0;
	string FrequentWord;
	for(map<string, int>::iterator Ite = Map.begin(); Ite != Map.end(); ++Ite)
	{
		if(Max < Ite->second)
		{
			Max = Ite->second;
			FrequentWord = Ite->first;
		}
	}
	cout << FrequentWord << " " << LongestWord << endl;
}

int main()
{
	solve();
	return(0);
}

C++: #include <iostream>
#include <string>
#include <map>
using namespace std;
map<string, int> table;
int main() {
  string word, frequent, longest; // input, max frequency, and longest
  size_t N=0; // frequency of the string "frequent"
  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++: #include<bits/stdc++.h>
#define rep(i,n)for(ll i=0;i<n;i++)
using namespace std;
typedef long long ll;

map<string, int>mp;
int main() {
	string s; getline(cin, s);
	istringstream iss(s);
	int Max = 0; string Max_st;
	while (getline(iss, s, ' ')) {
		mp[s]++;
		if (s.size() > Max) { Max = s.size(); Max_st = s; }
	}
	int MAX = 0; string MAX_st;
	for (auto i : mp) {
		if (i.second > MAX) { MAX = i.second; MAX_st = i.first; }
	}
	cout << MAX_st << ' ' << Max_st << endl;
	return 0;
}

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

int main() {
  string word,freq,longest;
  size_t N=0;
  while (cin >> word) {
    table[word] += 1;
    if (table[word]>N) {
      N = table[word];
      freq = word;
    }
    if (word.size()>longest.size())
      longest = word;
  }
  cout << freq << " " << longest << endl;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef complex<double> P;
typedef pair<int,int> pii;
#define REP(i,n) for(ll i=0;i<n;++i)
#define REPR(i,n) for(ll i=1;i<n;++i)
#define FOR(i,a,b) for(ll i=a;i<b;++i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define MOD (ll)(1e9+7)
#define ADD(a,b) a=((a)+(b))%MOD
#define FIX(a) ((a)%MOD+MOD)%MOD

int main(){
  string s;
  map<string,int> yey;
  string mxlen;
  string mostlen;
  int cnt = 0;
  while(cin){
    cin>>s;
    yey[s]++;
    if(mxlen.size() < s.size())mxlen = s;
    if(yey[s]>cnt){
      mostlen = s;
      cnt = yey[s];
    }
  }
  cout<<mostlen<<" "<<mxlen<<endl;
  return 0;
}

C++: // clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define forever for (;;)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
typedef std::pair<int, int> pii;
typedef std::vector<int> vi;
typedef std::vector<double> vd;
typedef std::vector<std::string> vs;
typedef std::vector<pii> vpii;
typedef std::vector<vi> vvi;
typedef std::vector<vpii> vvpii;
const int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
const int MOD = 1000000007;
const 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; }
template<typename T> std::istream &operator>>(std::istream &is, std::vector<T> &v) { rep(i,v.size()) is >> v[i]; return is; }
template<typename A, typename B> std::istream &operator>>(std::istream &is, std::pair<A, B> &p) { is >> p.first; is >> p.second; return is; }
using namespace std;
// clang-format on

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

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

int main(){
  multiset<string> words;
  string wmuch,wlong,w;
  int msize = 0,mcount=0;
  while(cin>>w){
    words.insert(w);
    if (mcount<words.count(w)){
      mcount = words.count(w);
      wmuch = w;
    }
    if (msize<w.size()){
      msize = w.size();
      wlong = w;
    }
  }
  cout << wmuch << " " << wlong << endl;
  return 0;
}

C++: #include<iostream>
#include<algorithm>
#include<string>
#include<map>
using namespace std;
int main(){
  
  string s,str1,str2;
  map<string,int> mp;

  while(cin >> s){

    if(mp.find(s) == mp.end()) mp[s] = 1;
    else mp[s]++;

    if(mp[s] > mp[str1]) str1 = s;
    if(s.size() > str2.size()) str2 = s;

  }
  
  cout << str1 << ' ' << str2 << endl;
  return (0);
}

C++: #include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cmath>
#include <stack>
#include <map>
#include <sstream>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
using namespace std;

int main(){
    map<string, int> dic;
    string str, sfmax, slmax, tmp;
    int fmax = 0, lmax = 0;
    getline(cin, tmp);
    stringstream stream(tmp);
    while (getline(stream, str, ' ')){
    	dic[str]++;
    	if (fmax < dic[str]){
    		fmax = dic[str];
    		sfmax = str;
    	}
    	if (lmax < str.length()){
    		lmax = str.length();
    		slmax = str;
    	}
    }
    cout << sfmax << ' ' << slmax << endl;
}