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 <iostream>
#include <string>
#include <map>
using namespace std;
int main(){
	string str,s,mls,mcs,input[32];
	map <string,int> dic;
	int n,c,a,ml,mc;
	getline(cin,str);
		c = a = mc = ml = 0;
		str += ' ';
		while(str.length()){
			n = str.find(' ');
			s = str[c];
			++c;
			for(;c < n;++c){
				s += str[c];
			}
			str.erase(0,n+1);
			c = 0;
			input[a] = s;
			++a;
			++dic[s];
			if(s.length() > ml) {
				ml = s.length();
				mls = s;
			}
		}
		for(int i = 0;i < a;++i){
			if(mc < dic[input[i]]){
				mc = dic[input[i]];
				mcs = input[i];
			}
		
		cout << mcs << " " << mls << endl;
	}
	return 0;
}

C++: #include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

int main() {
	multimap<int,string> words;
	string str;
	string maxstr="";
	for(;cin>>str;){
		if(maxstr.size()<str.size())maxstr=str;
		multimap<int,string>::iterator it;
		bool nw=true;
		for(it=words.begin();it!=words.end();it++){
			if(it->second==str){
				words.insert(map<int,string>::value_type(it->first-1,str));
				nw=false;
break;
			}
		}
		if(nw)words.insert(map<int,string>::value_type(-1,str));
		/*for(it=words.begin();it!=words.end();it++){
			cout<<it->second<<endl;
			cout<<1<<endl;
		}*/
		//cout<<str<<endl;
	}
	cout<<words.begin()->second<<" "<<maxstr<<endl;
	return 0;
}

C++: import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Scanner;

class Main {

	public static void main(String[] args) {

		Scanner sc = null;
		try {
			sc = new Scanner(System.in);

			// ??\???
			while (sc.hasNextLine()) {
				String[] sentence = sc.nextLine().split(" ");

				// ???????????????1????????????????????¢???
				Main main = new Main();
				String frequencyWord = main.maxFrequency(sentence);

				// ????????????????????????????????¢???
				String longWord = main.maxLong(sentence);

				// ????????????
				System.out.println(frequencyWord + " " + longWord);
			}

		} finally {
			sc.close();
		}
	}

	// value?????????????????§??????key?????????
	public String maxFrequency(String[] s) {
		Map<String, Integer> frequency = new HashMap<String, Integer>();
		for (String word : s) {
			int count = 1;
			if (frequency.containsKey(word)) {
				count += frequency.get(word);
			}
			frequency.put(word, count);
		}

		return valueSort(frequency).get(0).getKey();

	}

	//
	public String maxLong(String[] str) {
		// ??????????????????????????????List?????\??????
		List<String> list = new ArrayList<String>(new HashSet<String>(
				Arrays.asList(str)));

		String max = new String();
		for (String s : list) {
			if (max.length() < s.length()) {
				max = s;
			}
		}
		return max;
	}

	// Map???value??§?????????????????????
	private List<Map.Entry<String, Integer>> valueSort(Map<String, Integer> map) {
		List<Map.Entry<String, Integer>> list = new ArrayList<Map.Entry<String, Integer>>(
				map.entrySet());
		Collections.sort(list, new Comparator<Map.Entry<String, Integer>>() {
			public int compare(Map.Entry<String, Integer> map1,
					Map.Entry<String, Integer> map2) {
				return map2.getValue().compareTo(map1.getValue());
			}
		});
		return list;
	}
}

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

using namespace std;

int main() {
    map<string, int> freq;
    int modecnt = 0;
    string mode;
    string longest;
    string str;
    while(cin >> str) {
        if(modecnt < ++freq[str]) {
            modecnt = freq[str];
            mode = str;
        }
        if(str.size() > longest.size()) longest = str;
    }
    cout << mode << ' ' << longest << endl;
    return 0;
}

C++: #include <iostream>
#include <bitset>
#include <fstream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
#include <unordered_map>
#define Debug 0
//#include <boost/multiprecision/cpp_int.hpp>

const double EPS = (1e-10);


using namespace std;
using Int = long long;
//using namespace boost::multiprecision;

const Int MOD = 1000000007;

Int mod_pow(Int x, Int n) {
    Int res = 1;
    while(n > 0) {
        if(n & 1) res = (res * x) % MOD; //ビット演算(最下位ビットが1のとき)
        x = (x * x) % MOD;
        n >>= 1; //右シフト(n = n >> 1)
    }
    return res;
}

//最大公約数
template<typename T>
T gcd(T a, T b) {
    return b != 0 ? gcd(b, a % b) : a;
}

//最小公倍数
template<typename T>
T lcm(T a, T b) {
    return a * b / gcd(a, b);
}

unordered_map<string, int> m;

int main(){
    string S;
    size_t max_len = 0;
    string ans;
    while (cin >> S) {
        m[S]++;
        if (max_len < S.length()) {
            ans = S;
            max_len = S.length();
        }
    }
    int ma = 0;
    for (auto i: m) {
        ma = max(i.second, ma);
    }
    for (auto i: m) {
        if (ma == i.second) {
            cout << i.first << " ";
            break;
        }
    }
    cout << ans << endl;
}

C++: #include<iostream>
#include<string>
#include<map>
#include<vector>
using namespace std;
int main(void){
	string str;
	vector<string> w;
	map<string,int> word;
	unsigned int max=0,length=0;

	while(cin>>str){
		w.push_back(str);
		if(word.find(str) != word.end()){
			word[str]++;//ツ出ツ個サツ嘉アツ青板づーツカツウツδ督ト
		}else{
			word.insert(make_pair(str,1));
		}
	}
	map<string,int>::iterator it;
	for(it=word.begin();it!=word.end();it++){//ツ催頻ツ出ツづーツ仰づ淞づゥ
		if(max<it->second)
			max=it->second;
	}
	for(it=word.begin();it!=word.end();it++){
		if(max==it->second)
			cout<<it->first<<" ";
	}
	for(unsigned int i=0;i<w.size();i++){
		if(length<w[i].size()){
			length=w[i].size();
		}
	}
	for(unsigned int i=0;i<w.size();i++){
		if(length==w[i].size()){
			cout<<w[i]<<endl;
			break;
		}
	}
	return 0;
}

C++: #include<iostream>
#include<string>
using namespace std;
int main(){
string s,ss,tt[1000];
int i=0,j,l,m=0,n,cc[1000]={0};
while(cin>>s){
l=s.size();
if(m<l){m=l;ss=s;}
tt[i++]=s;
}
n=i;
for(i=0;i<n-1;i++)
for(j=i+1;j<n;j++)if(tt[i]==tt[j])cc[i]++;
for(m=0,i=0;i<n;i++){
if(m<cc[i]){m=cc[i];l=i;}
}
cout<<tt[l]<<" "<<ss<<endl;
return 0;
}