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 <iostream>

#include <map>

using namespace std;

const int M = 33;
const int N = 333001;

char text[N];
char word[N][M];
char tmp[N], ansm[N], ansl[N]; 

int cmp(const void *a, const void *b) {
	return strcmp((char *)a, (char *)b);
}

void solve(int k) {
/*	int len = strlen(text);
	for (int i=0; i<len; ++i) {
		if (text[i] >= 'A' && text[i] <= 'Z') text[i] = text[i] - 'A' + 'a';
	}
	int j = 0, k = 0;
	for (int i=0; i<len; ++i) {//分解文章 
		if (text[i] != ' ') word[k][j++] = text[i];
		else {
			if (j == 0) continue;
			word[k++][j] = '\0', j = 0;
		}
	}
	if (j) word[k++][j] = '\0';*/
	qsort(word, k, sizeof(word[0]), cmp);
	int maxs = -1;
	int cnt = 1;
	strcpy(tmp, word[0]);
	strcpy(ansl, word[0]);
	int maxl = strlen(word[0]);
	for (int i=1; i<k; ++i) {
		if (maxl < strlen(word[i])) maxl = strlen(word[i]), strcpy(ansl, word[i]);
		if (!strcmp(tmp, word[i])) ++cnt;
		else {
			if (maxs < cnt) {
				maxs = cnt;
				strcpy(ansm, tmp);
			}
			strcpy(tmp, word[i]);
		}
	}
	if (maxs < cnt) strcpy(ansm, tmp);
}

int main() {
//	cin.getline(text, N, '\n');
//	while (cin.getline(text, N, '\n')) {
//		solve(text);
//		cout<<ansm<<" "<<ansl<<endl;
//	}
	int i = 0;
	while (scanf("%s", word[i++]) != EOF);
//	solve(word)
	solve(i);
	cout<<ansm<<" "<<ansl<<endl;
/*	map<string,int> data;
	string ans1,ans2,str;
	while(cin >> str){
		data[str]++;
		if(data[ans1] < data[str]) ans1 = str;
		if(ans2.size() < str.size() ) ans2 = str;
	}
	cout << ans1 << " " << ans2 << endl;*/
	return 0;
}






/*
#include <map>
using namespace std;

int main(){
	map<string,int> data;
	string ans1,ans2,str;
	while(cin >> str){
		data[str]++;
		if(data[ans1] < data[str]) ans1 = str;
		if(ans2.size() < str.size() ) ans2 = str;
	}
	cout << ans1 << " " << ans2 << endl;
}
*/

C++: #include<iostream>
#include<vector>
#include<algorithm>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define all(in) in.begin(),in.end()
#define pb(in,a) in.push_back(a)
using namespace std;
int main(){
  vector<string>a;
  vector<int>b,c;
  string s;
  while(cin>>s){
    bool n=false;
    rep(i,a.size())if(a[i]==s){b[i]++;n=true;}
    if(!n){
      pb(a,s);
      pb(b,1);
      pb(c,s.size());
    }
  }
  int max=0;
  int maxi=0;
  rep(i,a.size())if(max<b[i]){max=b[i];maxi=i;}
  cout<<a[maxi];

  max=maxi=0;
  rep(i,a.size())if(max<c[i]){max=c[i];maxi=i;}
  cout<<" "<<a[maxi]<<endl;
}

C++: #include <stdio.h>
#include <ctype.h>
#include <string.h>

int main(void){
	char word[33];
	int len = 0;
	int mlen = 0;
	char mword[33];
	char dict[1000][33];
	int mode[1000];
	int st = 0;
	bool find = false;
	int i = 0;

	while(scanf("%s", word) != EOF){
		len = strlen(word);
		for(i=0; i<len; ++i){
			word[i] = tolower(word[i]);
		}

		if(mlen < len){
			mlen = len;
			strcpy(mword, word);
		}

		find = false;
		for(i=0; i<st; ++i){
			if(strcmp(dict[i], word) == 0){
				find = true;
				break;
			}
		}
		if(find){
			mode[i]++; 
		}else{
			strcpy(dict[st], word);
			mode[st] = 1;
			st++;
		}
	}

	int max = 0;
	int maxi = 0;
	for(i = 0; i<st; ++i){
		if(max < mode[i]){
			max = mode[i];
			maxi = i;
		}
	}
	printf("%s %s\n", dict[maxi], mword);

	getchar();
	return 0;
}

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

struct WordRanking
{
	WordRanking(){}

	WordRanking(std::string word, int count):m_word(word),m_count(count)
	{
	}

	std::string m_word;

	int m_count;
};

int MaxNum(std::vector<WordRanking> rank)
{
	if(rank.empty())
	{
		return 0;
	}

	int max = rank[0].m_count;

	int maxNum=0;

	for(size_t i=1; i<rank.size(); ++i)
	{
		if(rank[i].m_count>max)
		{
			max = rank[i].m_count;

			maxNum = i;
		}
	}

	return maxNum;
}


int main()
{
	std::string str;

	//while(1){
		getline(std::cin,str);

		if(std::cin.eof())
		{
			exit(1);
		}

		std::stringstream ss;

		std::vector<std::string> word;

		ss << str;

		std::string hoge;

		for(; !(ss.eof());)
		{
			ss >> hoge;

			word.push_back(hoge);
		}

		std::sort(word.begin(),word.end());

		std::string temp = "";

		std::vector<WordRanking> rankFriq;

		for(size_t i=0; i<word.size(); ++i)
		{
			if(temp != word[i])
			{
				rankFriq.push_back(WordRanking(word[i],1));
			}
			else
			{
				++rankFriq[rankFriq.size()-1].m_count;
			}

			temp = word[i]; 
		}

		std::vector<WordRanking> rankLength;

		for(size_t i=0; i<word.size(); ++i)
		{
			rankLength.push_back(WordRanking(word[i],word[i].length()));
		}

		std::cout << rankFriq[MaxNum(rankFriq)].m_word << ' ' << rankLength[MaxNum(rankLength)].m_word << '\n';
		
	//}
}

C++: #include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <sstream>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <numeric>
#include <cmath>
#include <climits>
#include <limits>
#include <cfloat>
#include <fstream>
using namespace std;

int main()
{
//	cut here before submit 
//	freopen("testcase.es", "r", stdin);
	string str = "";

	while ( getline (cin, str ) ){

		map <string, int> freq, leng;
		if (str.find('.') != string::npos){
			str = str.erase (str.find('.'), 1);
		} // end if
		stringstream ss(str);
		string s = "";

		while (ss >> s){
			++freq[s];
			leng[s] = s.length();
		} // end while

		if (freq.size() == 2){
			cout << "The two words separated by a space." << endl;
			continue;
		} // end if		
		if (!freq.empty() && !leng.empty() ){ 
			multimap <int, string, greater<int> > rank;
			map <string, int>::iterator itf = freq.begin();
			for (; itf != freq.end(); ++itf){
				rank.insert (make_pair ((*itf).second, (*itf).first ) );
			} // end for
			multimap<int, string, greater<int> > mlen;
			map<string, int>::iterator itl = leng.begin();
			for (; itl != leng.end(); ++itl){
				mlen.insert (make_pair ((*itl).second, (*itl).first ) );
			} // end for
			multimap<int, string, greater<int> >::iterator itr = rank.begin();
			multimap<int, string, greater<int> >::iterator itm = mlen.begin();
			cout << (*itr).second << ' ' << (*itm).second << endl;
		} // end if
	} // end while
		
	return 0;
}