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

C++: #include <iostream>
#include <sstream>
#include <map>
#include <algorithm>
using namespace std;
int main(){
	string line;
	getline(cin, line);
	stringstream ss;
	ss << line;
	string s;
	map<string, int> cnt;
	string maxLengthString = "";
	pair<int, string> maxEncount(0,"");
	while(ss >> s){
		cnt[s]++;
		if( maxLengthString.size() < s.size()) maxLengthString = s;
		if(maxEncount.first < cnt[s]){
			maxEncount = make_pair<int,string>(cnt[s],s);
		}
	}
	cout << maxEncount.second << " " << maxLengthString << endl;
	return 0;
}

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

using namespace std;

void solve()
{
	string str;
	getline(cin, str);
	string word[1000];

	int pos = 0;
	int n = str.size();
	for(int i = 0; i < n; ++i)
	{
		if(str[i] == ' ')
		{
			word[pos] += '\0';
			pos++;
		}
		else
		{
			word[pos] += str[i];
		}
	}
	word[pos] += '\0';
	pos++;
	map<string, int> Map;
	for(int i = 0; i < pos; ++i)
	{
		Map[word[i]]++;
	}
	int frequency = 0;
	for(map<string, int>::iterator Ite = Map.begin(); Ite != Map.end(); ++Ite)
	{
		if(frequency < (*Ite).second)
		{
			frequency = (*Ite).second;
		}
	}
	int max_length = 0;
	for(int i = 0; i < pos; ++i)
	{
		if(max_length < word[i].size())
		{
			max_length = word[i].size();
		}
	}
	for(map<string, int>::iterator Ite = Map.begin(); Ite != Map.end(); ++Ite)
	{
		if(frequency == (*Ite).second)
		{
			cout << (*Ite).first << " ";
			break;
		}
	}
	for(int i = 0; i < pos; ++i)
	{
		if(max_length == word[i].size())
		{
			cout << word[i] << endl;
			break;
		}
	}
}

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;
    size_t N = 0;
    while (cin >> word)
    {
        table[word]++;
        if (N < table[word])
        {
            N = table[word];
            frequent = word;
        }
        if (word.size>longest.size)
            longest = word;
    }
    cout << frequent << " " << longest << endl;
    return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
	string str[1000],mx("a");
	int i=0,cnt[1000]={0},ms;
	while(cin >> str[i]){
		if(mx.size()<str[i].size())mx=str[i];	
	
		for(int j=0;j<i;j++){
			if(str[i]==str[j]){
				cnt[j]++;
			}
		}
		i++;
	}
	for(int j=0;j<i;j++){
		for(int k=0;k<i;k++){
			if(cnt[j]<cnt[k])ms=k;
		}
	}
	cout << str[ms] << " " <<mx << endl;
return 0;
}