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 <bits/stdc++.h>
using namespace std;

int main() {
    string s;
    map<string, int> m;
    while(cin >> s) {
        m[s]++;
    }
    string r1, r2;
    for(auto& p : m) {
        if(m[r1] < p.second) {
            r1 = p.first;
        }
        if(r2.size() < p.first.size()) {
            r2 = p.first;
        }
    }
    cout << r1 << ' ' << r2 << endl;
}

C++: #define _CRT_SECURE_NO_WARNINGS
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#define int ll
//#define endl "\n"
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
#define all(c) (c).begin(), (c).end()
#define loop(i,a,b) for(ll i=a; i<ll(b); i++)
#define rep(i,b) loop(i,0,b)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
template<class T> ostream & operator<<(ostream & os, vector<T> const &);
template<int n, class...T> typename enable_if<(n>=sizeof...(T))>::type _ot(ostream &, tuple<T...> const &){}
template<int n, class...T> typename enable_if<(n< sizeof...(T))>::type _ot(ostream & os, tuple<T...> const & t){ os << (n==0?"":" ") << get<n>(t); _ot<n+1>(os, t); }
template<class...T> ostream & operator<<(ostream & os, tuple<T...> const & t){ _ot<0>(os, t); return os; }
template<class T, class U> ostream & operator<<(ostream & os, pair<T,U> const & p){ return os << "(" << p.first << ", " << p.second << ") "; }
template<class T> ostream & operator<<(ostream & os, vector<T> const & v){ rep(i,v.size()) os << v[i] << (i+1==(int)v.size()?"":" "); return os; }
template<class T> inline bool chmax(T & x, T const & y){ return x<y ? x=y,true : false; }
template<class T> inline bool chmin(T & x, T const & y){ return x>y ? x=y,true : false; }
#ifdef DEBUG
#define dump(...) (cerr<<#__VA_ARGS__<<" = "<<mt(__VA_ARGS__)<<" ["<<__LINE__<<"]"<<endl)
#else
#define dump(...)
#endif
// ll const mod = 1000000007;
// ll const inf = 1LL<<60;

/*
  ch は小さいほうが良い
 */

struct Trie {
    int ctoi(char c){
        return isupper(c) ? c-'A' : c-'a'+26;
    }
    struct Node {
        int val;
        Node * ch[26*2];
        Node() : val(0) {
            for(auto & p : ch) p = nullptr;
        }
        ~Node(){
            for(auto & p : ch) if(p != nullptr) delete p;
        }
    };
    Node *r;

    Node* insert(string const &s){
        auto p = s.begin();
        auto cur = r;
        while(1){
            if(p == s.end()){
                return cur;
            } else {
                auto &nxt = cur->ch[ctoi(*p)];
                if(nxt == nullptr) nxt = new Node();
                cur = nxt;
                ++p;
            }
        }
    }
    bool erase(string const &s){
        auto p = s.begin();
        auto cur = r;
        while(1){
            if(p == s.end()) return cur->val > 0 ? (cur->val--, true) : false;
            auto &nxt = cur->ch[ctoi(*p)];
            if(nxt == nullptr) return false;
            cur = nxt;
            ++p;
        }
    }
    Node* find(string const &s){
        auto p = s.begin();
        auto cur = r;
        while(1){
            if(p == s.end()) return cur;
            auto &nxt = cur->ch[ctoi(*p)];
            if(nxt == nullptr) return nullptr;
            cur = nxt;
            ++p;
        }
    }
    Node* fetch_or_insert(string const &s){
        Node *res = find(s);
        return res ? res : insert(s);
    }
    Trie() : r(new Node()) {}
    ~Trie() { delete r; }
};

int main(){
    Trie t;
    string s;
    string freq;
    string aaa;
    int freq_c = 0;
    while(cin >> s){
        Trie::Node *p = t.fetch_or_insert(s);
        p->val++;
        if(freq_c < p->val){
            freq = s;
            freq_c = p->val;
        }
        if(aaa.size() < s.size()){
            aaa = s;
        }
    }
    cout << freq << " " << aaa << endl;
}

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

int main()
{
	map<string, int> words;
	string str;
	while (cin >> str)
	{
		if (words.count(str))
		{
			words[str]++;
		}
		else
		{
			words[str] = 1;
		}
	}

	int Max = 0;
	string mode;
	string longest;
	for (auto i : words)
	{
		if (Max < i.second)
		{
			Max = i.second;
			mode = i.first;
		}
		if (longest.size() < i.first.size())
		{
			longest = i.first;
		}
	}
	cout << mode << ' ' << longest << endl;

	return 0;
}

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

using namespace std;

int main(){
	string sent;
	string word[500];
	int a[500]={};
	int i,j,k,l;
	int n,m,len;
	i=0;
	while(cin>>sent){
		if(i==0){	//????????????????????????
			word[0]=sent;
			a[0]++;
			i++;
			len=sent.size();
			n=0;
		}
		else {
			if(len<sent.size()){	//?????????????????????????????°??´??°
				len=sent.size();
				n=i;
			}
			for(j=0; j<i; j++){
				if(sent==word[j]){	//?????§????????????????????????
					a[j]++;
					break;
				}
				if(j==i-1){			//??°?????????????????????
					word[i]=sent;
					a[i]++;
					i++;
					break;
				}
			}
		}
	}
	m=0;
	for(j=0; j<i; j++){		//????????????????????????????????????
		if(m<a[j])m=j;
	}
	cout<<word[m]<<" "<<word[n]<<endl;
	// for(j=0; j<i; j++){
	// 	cout<<word[j]<<":"<<a[j]<<endl;
	// }
	//cout<<"len:"<<len<<" "<<word[n]<<endl;
	return 0;
}

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

using namespace std;

int main(void) {
  map<string, int> mp;
  string s, max_len = "";
  while (cin >> s) {
    mp[s]++;
    if (s.size() > max_len.size()) {
      max_len = s;
    }
  }

  string max_cnt = "";
  for (auto i : mp) {
    if (i.second > mp[max_cnt]) {
      max_cnt = i.first;
    }
  }

  cout << max_cnt << " " << max_len << endl;

  return 0;
}

C++: #include <algorithm>
#include <iostream>
#include <string>
#include <cstring>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <stack>
#include <vector>

#define FOR(i,k,n) for(int (i) = (k); (i) < (n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define all(v) begin(v), end(v)
#define debug(x) cerr << #x << ": " << x << endl
#define debug2(x,y) cerr << #x << ": " << x << ", " << #y << ": " << y << endl

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<i_i, int> p_i;
typedef vector<int> vi;
typedef vector< vector<int> > vvi;
template<class T> using vv=vector< vector<T> >;
typedef deque<int> di;
typedef deque< deque<int> > ddi;


int main() {
    map<string,int> M;
    string tmp,rst,rst2;
    int max,maxl;
    while(cin >> tmp) {
        M[tmp] += 1;
        if(max < M[tmp]) {
            max = M[tmp];
            rst = tmp;
        }
        if(tmp.length() > maxl) {
            rst2 = tmp;
            maxl = tmp.length();
        }
    }
    cout << rst << " " << rst2 << endl;
	return 0;
}