Go: package main

import (
	"bufio"
	"fmt"
	"os"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Scan()
	l := sc.Text()
	words := strings.Split(l, " ")

	frequency := map[string]int{}
	long := map[string]int{}
	var maxFrequency, longest int
	var frequentWord, longestWord string
	for _, w := range words {
		frequency[w]++
		long[w] = len(w)
		if frequency[w] > maxFrequency {
			maxFrequency = frequency[w]
			frequentWord = w
		}
		if len(w) > longest {
			longest = long[w]
			longestWord = w
		}
	}

	fmt.Println(frequentWord + " " + longestWord)
}

C++: #include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<deque>
using namespace std;

int main() {

    vector<string> words;
    string word; 
    string longest = "";

    while(cin >> word) {
        words.push_back(word);
        if(word.length() > longest.length()) {
                longest = word;
        }
    }

    string freq;
    int frequency = 0;
    for(int i = 0; i < words.size(); i++) {
        int tmp = count(words.begin(), words.end(), words[i]);
        if (tmp > frequency) {
            frequency = tmp;
            freq = words[i];
        }
    }

    cout << freq << " " << longest << endl;

    return 0;
}

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

map <string, int> dic;

string lowerword(string word){
    for (int i=0; i<(int)word.size(); i++)
        word[i] = tolower(word[i]);
    return word;
}

int main(void){

	while (true){
		string s;
		cin>>s;
		if (cin.eof()) break;
		dic[lowerword(s)]++;
	}

	int l=0, m=0, tmp;
	string w1, w2;
	map <string, int> ::iterator it=dic.begin();
	while (it!=dic.end()){
		tmp = (*it).second;
		if (tmp>m){
			m = tmp;
			w1 = (*it).first;
		}
		tmp = (*it).first.size();
		if (tmp>l){
			l = tmp;
			w2 = (*it).first;
		}
		it++;
	}
	cout<<w1<<" "<<w2<<endl;
	return 0;
}

C++: #include <map>
#include <string>
#include <iostream>
using namespace std;
map<string,int> table;
int main()
{
    string word, frequent, longest;
    size_t N=0;
    while (cin >> word)
    {
        table[word]++;
        if(table[word]>N)
        {
            N=table[word];
            frequent=word;
}
            if(word.size()>longest.size())
                longest=word;
    }
        cout<<frequent<<" "<<longest<<endl;
    }

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

using namespace std;

int main(){
    int max = 0;
    string s,longests,frequents;
    map<string,int> dict;
    while(cin >>s){
        dict[s] +=1;
        if(s.size() >= max){
            longests = s;
            max = s.size();
        }
        if(dict[s] >= dict[frequents]){
            frequents = s;
        }
    }
    cout << frequents << " " << longests << endl;
}

C++: #include <iostream>
#include <cstdio>
#include <cstring>

using namespace std;

class Word {
public:
	char w[33];
	int length;
	int freq;
public:	
	Word() {
		strcpy(w, "");
		length = 0;
		freq = 0;
	}
};

int main()
{
	char str[1001];
	char buf[32];
	char *p, *q;
	fgets(str, 1001, stdin);
	
	Word wl[32];
	
	for ( p = str; (q = strstr(p, " ")) != NULL; ) {
		*q = '\0'; strcpy(buf, p); 
		for (int i=0; i<32; i++) {
			if ( strcmp(wl[i].w, "") == 0 ) {
				strcpy(wl[i].w, buf);
				wl[i].length = strlen(buf);
				wl[i].freq = 1;
				break;
			}
			else if ( strcmp(wl[i].w, buf) == 0 ) {
				wl[i].freq++;
				break;
			}
		}
		p = q + 1;
	}
	
	strcpy(buf, p); 
	for (int i=0; i<32; i++) {
		if ( strcmp(wl[i].w, "") == 0 ) {
			strcpy(wl[i].w, buf);
			wl[i].length = strlen(buf);
			wl[i].freq = 1;
			break;
		}
		else if ( strcmp(wl[i].w, buf) == 0 ) {
			wl[i].freq++;
			break;
		}
	}

	
	int max_freq = 0;
	int max_length = 0;
	char max_freq_w[32];
	char max_length_w[32];
	
	for (int i=0; i<32; i++) {
		if (max_freq < wl[i].freq) {
			max_freq = wl[i].freq;
			strcpy(max_freq_w, wl[i].w);
		}
		if (max_length < wl[i].length) {
			max_length = wl[i].length;
			strcpy(max_length_w, wl[i].w);
		}
	}
	
	cout << max_freq_w << " " << max_length_w << endl;
	
	return 0;
}

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

int main(){
  map<string,int> table;
  string word;
  int k1 = 0;
  int k2 = 0;
  string answer1;
  string answer2;
  while(cin >> word){
    table[word]+=1;
    if(table[word] > k1){
      k1 = table[word];
      answer1 = word;
    }
    int len = sizeof(word);
    if (len > k2){
      k2 = len;
      answer2 = word;
    }
  }
  cout << answer1 << " " << answer2 << endl;
}

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

int main()
{
	std::map<std::string,int> word_frequency;
	std::string word;
	while (std::cin >> word) {
		word_frequency[word]++;
	}

	std::string most_frequent_word;
	std::string longest_word;
	int max_frequency = 0;
	for (std::map<std::string,int>::iterator i = word_frequency.begin(); i != word_frequency.end(); ++i) {
		if (i->second > max_frequency) {
			most_frequent_word = i->first;
		}
		if (i->first.size() > longest_word.size()) {
			longest_word = i->first;
		}
	}

	std::cout << most_frequent_word << ' ' << longest_word << std::endl;

	return 0;
}

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

int main()
{
	std::string str;
	std::map<std::string,int> frequency;
	std::string longest,frequent;
	int freq=0;
	int len=0;
	
	std::getline(std::cin,str);
	
	str+=' ';
	
	int begin=0;
	bool inword=false;
	for(int i=0;i<str.size();i++)
	{
		std::string word;
		if(!inword&&isalpha(str[i]))
		{
			inword=true;
			begin=i;
		}
		else if(!isalpha(str[i]))
		{
			inword=false;
			word=str.substr(begin,i-begin);
			if(word.size()>len)
			{
				len=word.size();
				longest=word;
			}
			if(frequency.find(word)==frequency.end())
			{
				frequency.insert(std::pair<std::string,int>(word,0));
			}
			if(++frequency[word]>freq)
			{
				freq=frequency[word];
				frequent=word;
			}
		}
	}
	std::cout<<frequent<<' '<<longest<<std::endl;
	return 0;
}

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);
//	for (int i=0; i<k; ++i) printf ("%s\n", word[i]);
	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);
			}
			cnt = 1;
			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;
//	printf ("%d\n", strcmp("AAAA", "aaaa"));
	while (scanf("%s", word[i++]) != EOF);
//	solve(word)
	solve(i);
	cout<<ansm<<" "<<ansl<<endl;
//	system("PAUSE");
/*	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;
}
*/