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 <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <fstream>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#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++)
template<class T> T RoundOff(T a){ return int(a+.5-(a<0)); }
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }


vector<string> split(string str, string delim)
{
    vector<string> result;
    int cutAt;
    while( (cutAt = str.find_first_of(delim)) != str.npos )
    {
        if(cutAt > 0)
        {
            result.push_back(str.substr(0, cutAt));
        }
        str = str.substr(cutAt + 1);
    }
    if(str.length() > 0)
    {
        result.push_back(str);
    }
	return result;
}


int main()
{
	string str;
	getline(cin, str);

	vector<string> ss = split(str, " ");

	sort(ALL(ss));

	int res = 1, buf = 1;
	string sres = ss[ss.size()-1];

	rep(i, ss.size()-1)
	{
		if(ss[i] == ss[i+1])
		{
			buf++;
		}
		else
		{
			if(res < buf)
			{
				res = buf;
				sres = ss[i];
			}
			buf = 1;
		}

		if(i == ss.size() - 2 && res < buf)
			sres = ss[i];

	}
	cout << sres << " ";

	res = 0;
	rep(i, ss.size())
	{
		if(res < ss[i].size())
		{
			sres = ss[i];
			res = ss[i].size();
		}
	}
	cout << sres << endl;
}

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

using namespace std;
typedef pair<string, int> f_pair;

bool pairCompare(const f_pair& a1, const f_pair& a2)
{
	return a1.second > a2.second;
}

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);

	vector<f_pair> a;
	string s, lMax;
	while (cin >> s)
	{
		int n;
		bool exist = false;

		if (s.size() > lMax.size()) lMax = s;
		for (int i = 0; i < a.size(); ++i)
			if (s == a[i].first)
			{
				exist = true, n = i;
				break;
			}

		if (exist)
			a[n].second++;
		else
			a.push_back(f_pair(s, 1));
	}

	sort(a.begin(), a.end(), pairCompare);
	cout << a[0].first << " " << lMax << endl;

	return 0;
}

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

int main()
{	
	string s, t;
	map<string, int> p;

	while (cin >> s) {
		transform(s.begin(), s.end(), s.begin(), ::tolower);
		if (p.find(s) != p.end())
			p[s]++;
		else
			p[s] = 1;

		if (s.size() > t.size())
			t = s;
	}

	int m = 0;

	for (map<string, int>::iterator itr = p.begin(); itr != p.end(); itr++)
		m = max(m, itr->second);

	for (map<string, int>::iterator itr = p.begin(); itr != p.end(); itr++)
		if (itr->second == m)
			cout << itr->first << endl;

	cout << t << endl;

	return 0;
}

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

int main(){
	multiset<string> se;
	string str,str2;
	while(cin>>str){
		se.insert(str);
	}

	int cnt=0,cnt2=0;
	for(auto it=se.begin();it!=se.end();it++){
		int tmp=se.count(*it);
		if(tmp>cnt){
			cnt=tmp;
			str=(*it);
		}
		int tmp2=(int)(*it).length();
		if(tmp2>cnt2){
			cnt2=tmp2;
			str2=(*it);
		}
	}
	cout<<str<<" "<<str2<<endl;
	return 0;
}

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

int main(void) {
    string a;
    map<string, int> data;

    while (cin >> a)
        ++data[a];

    int max_count = 0;
    string max_str = "";
    int max_len = 0;
    string max_len_str = "";

    for (auto itr = data.begin(); itr != data.end(); ++itr) {
        const pair<string, int>& hoge = *itr;
        if (hoge.second > max_count) {
            max_count = hoge.second;
            max_str = hoge.first;
        }
        if (hoge.first.length() > max_len) {
            max_len = hoge.first.length();
            max_len_str = hoge.first;
        }
    }

    cout << max_str << " " << max_len_str << endl;

    return 0;
}

C++: #include <algorithm>
#include <iostream>
#include <string>
#include <utility>
#include <map>
#define itr(it,a) for(auto it=(a).begin();it!=(a).end();++it)

typedef std::pair<int, std::string> P;

std::map<std::string, int> m;
P maF( 0, "" ), maL( 0, "" );

int main()
{
    std::string s;
    while( std::cin >> s )
    {
        ++m[s];
    
        maL = std::max( maL, P( s.size(), s ) );
    }

    itr( it, m )
        maF = std::max( maF, P( it->second, it->first ) );

    std::cout << maF.second << ' ' << maL.second << std::endl;

    return 0;
}

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

int main()
{
    string field;
    map<string, int> mp;
    string frequently_word;
    string max_num_word;
    int freq_count = 0;
    int max_letter_num = 0;

    while (cin >> field)
    {
        /* store the word which has the maximum number */
        if(field.size() > max_letter_num)
        {
            max_letter_num = field.size();
            max_num_word = field;
        }
        /* search the word from map */
        if(mp.count(field)) 
        {
            mp[field]++; 
        }
        else
        {
            mp[field] = 1;
        }
 
    }
    /* get the most frequently word */
    for(auto itr = mp.begin(); itr != mp.end(); ++itr)
    {
        if(itr->second > freq_count)
        {
            freq_count = itr->second;
            frequently_word = itr->first;
        }
    }
    cout << frequently_word << " " << max_num_word << endl;

    return 0;
}

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

int main(){
    map<string,int> sent;
    string freq,lngest="";
    size_t N=0;

    string word;
    while(cin>>word){
        ++sent[word];
        if(sent[word]>N){
            N=sent[word];
            freq=word;
        }
        lngest=(word.size()>lngest.size()?word:lngest);
    }
    cout<<freq<<" "<<lngest<<"\n";
}

C++: #include "bits/stdc++.h"
using namespace std;
typedef long long ll;

int main(){

    string s1 = "1", s2 = "2";
    map<string, int>cnt;
    for(string s;cin >> s;){
        cnt[s]++;
        if(cnt[s] > cnt[s1])s1 = s;
        if(s.size() > s2.size())s2 = s;
    }    
    cout << s1 << " " << s2 << endl;

    return 0;
}

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

int main(){
    map<string, int> word;
    string s;
    string outen;
    string outlen;
    int maxen;
    int maxlen;
    maxen = 0;
    maxlen = 0;
    while(cin >> s){
        if(word.find(s) != word.end()){
            word[s]++;
            if(word[s] > maxen){
                outen = s;
            }
        }else{
            word.insert(map<string, int>::value_type(s, 1));
            if(s.size() > maxlen){
                outlen = s;
            }
        }
    }
    cout << outen << endl << outlen << endl;
    return 0;
}