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++: #define _USE_MATH_DEFINES
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>

typedef long long ll;
using namespace std;

typedef pair<int,int> P;

map<string,int> freq;

int main()
{
	char buf[64];
	while(~scanf("%s",buf)){
		string tmp = buf;
		freq[tmp]++;
	}

	int msize=0;
	string msize_str;
	int mfreq=0;
	string mfreq_str;
	for(map<string,int>::iterator it = freq.begin(); it != freq.end(); it++){
		if(msize < it->first.size()){
			msize_str = it->first;
			msize = it->first.size();
		}

		if(mfreq < it->second){
			mfreq_str = it->first;
			mfreq = it->second;
		}	
	}

	cout << mfreq_str << " " << msize_str << endl;
}

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