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++: #include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <set>
#include <queue>
#include <cstring>
#include <climits>
#include <cmath>
#include <cfloat>

using namespace std;

multiset<string> se;
string mast = "";
string manumst = "";
int manum = 0;

int main()
{
	string str;
	
	while( cin >> str, !cin.eof())
	{
		if( mast.size() < str.size() )
			mast = str;
		
		se.insert(str);
		if( se.count(str) > manum )
			manumst == str;
	}
	
	cout << manumst << " " << mast << 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;
}
*/

C++: #include <iostream>
#include <map>
#include <string>
using namespace std;
int main() {
  map<string, int> m;
  string s, t, u;
  int n, k = 0, l = 0;
  while (cin >> s) {
    if (s.size() > l) {
      l = s.size();
      u = s;
    }
    m[s]++;
    if (m[s] > k) {
      k = m[s];
      t = s;
    }
  }
  cout << t << ' ' << u << endl;
  return 0;
}

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

using namespace std;

string s[1001];
int count[1001];

int main(void){
	char temp[1002];
	
	while(fgets(temp,1001,stdin) != 0){
		int temp_n = strlen(temp);
		int c = 0;
		int max_h = 0;
		int max_H = 0;
		int max_l = 0;
		int max_L = 0;
		
		for(int i = 0; i < 1001; i++){
			s[i] = "";
			count[i] = 0;
		}
		
		for(int i = 0; i < temp_n; i++){
			for(int j = i; ; j++){
				if(temp[j] == ' '){
					i=j;
					c++;
					break;
				}else if(temp[j] == '\n'){
					i=j;
					c++;
					break;
				}
				s[c] += temp[j];
			}
		}
		/*
		for(int i = 0; i < c; i++){
			printf("%d s == %s[%d]\n",i,s[i].c_str(),s[i].size());
		}
		*/
		for(int i = 0; i < c; i++){
			for(int j = 0; j < c; j++){
				if(i == j)continue;
				if(s[i] == s[j])count[i]++;
			}
		}
		
		for(int i = 0 ; i < c; i++){
			if(s[i].size() > s[max_l].size() )max_l = i;
			if(count[i] > count[max_h])max_h = i;
		}
		
		printf("%s %s\n", s[max_h].c_str(), s[max_l].c_str() );
	}
	return 0;
}

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

int main(){
	string s[1000];
	int c = 0;
	while(cin >> s[c]){c++;}
	int th,tm;
	int h = 0;
	int m = 0;
	for(int i=0;i<c;i++){
		if(s[i].size()>m){ m = s[i].size(); tm = i; }
		int a = 0;
		for(int j=0;j<c;j++) if(s[i]==s[j]) a++;
		if(a>h){ h = a; th = i; }
	}
	cout << s[th] << " " << s[tm] << endl;
}

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

int main()
{
  map<string, int> Map;
  string str;
  string max, freq;

  while (cin >> str){
    Map[str]++;
    if (Map[max] < Map[str]){
      max = str;
    }
    if (freq.size() < str.size()){
      freq = str;
    }
  }

  cout << max << " " << freq << '\n';

  return (0);
}

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

int main()
{
    int i=0,max=0,maxNumber=-1,maxN=0,maxNNumber=0;
    string str[1000];
    while(cin>>str[i]){
        i++;
    }
    int wordCount[i+1];
    for(int j=0;j<i+1;j++){
        wordCount[j]=0;
    }
    bool kaburi[i+1];
    for(int j=0;j<i+1;j++){
        if(kaburi[j]) continue;
        if(max<str[j].length()){
            max=str[j].length();
            maxNumber=j;
        }
        for(int k=0;k<i+1;k++){
            if(str[j]==str[k]){
                wordCount[j]++;
                kaburi[k]=true;
            }
        }
    }
    for(int j=0;j<i+1;j++){
        if(maxN<wordCount[j]){
            maxN=wordCount[j];
            maxNNumber=j;
        }
    }
    cout<<str[maxNNumber]<<' '<<str[maxNumber]<<endl;
    return 0;
}

C++: #include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <sstream>
#include <utility>
#include <cstdlib>
#include <cctype>
#include <climits>
#include <fstream>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<double> vd;
typedef vector<pair<int, int> > vpii;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define foreach(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); itr++)
#define dbg(x) cout << #x"="<< (x) << endl
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back(a) 
#define in(x) cin >> x;
#define all(x) (x).begin(), (x).end()
#define INF 2147483600
#define fi first
#define se second
using namespace std;

map <string,int> ans;
int l=0;
int k=0;

int main(){
    string str;
    string a,b;
    while(cin>>str){
        if(str.size()>=l){
            b = str;
            l=str.size();
        }
        ans[str]++;
        if(ans[str]>=k){
            k=ans[str];
            a=str;
        }
    }
    cout<<a<<" "<<b<<endl;
}

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

typedef map<string, int> M;
typedef M::value_type MV;
int main()
{
    M word_counts;
    string max_letters = "";

    for (string s; cin >> s;) {
        if (s.size() > max_letters.size())
            max_letters = s;
        word_counts[s]++;
    }
    cout << (*max_element(word_counts.begin(), word_counts.end(),
                          [](MV &a, MV &b){return a.second < b.second;})).first
        << " " << max_letters << endl;

    return 0;
}