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<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double ESP=1e-10;
using namespace std;
int main(){
  string s;
  vector<string> line;
  vector<int> cnt;
  getline(cin,s);
  string word = "";
  string longest = "";
  
  rep(i,s.size()){
    if(s[i] == ' '){
      if(longest.size() < word.size()){
	longest = word;
      }
      bool find = false;
      
      rep(j,line.size()){
	if(line[j] == word){
	  cnt[j] ++;
	  find = true;
	  word = "";
	}
      }
      
      if(find)continue;
      line.pb(word);
      word = "";
    }else{
      word += s[i];
      cnt.pb(1);
    }
  }
  
  int ma = 0;
  string res = "";
  
  rep(i,line.size()){
    if(ma < cnt[i]){
      ma = cnt[i];
      res = line[i];
    }
  }
  
  cout<<res<<" "<<longest<<endl;

}

C++: #include <bits/stdc++.h>

#define reps(v, f, l) for (int v = (f), v##_ = (l); v < v##_; ++v)
#define rep(v, n) reps(v, 0, n)
#define lep(v, n) reps(v, 1, n + 1)
#define rreps(v, f, l) for (int v = (l), v##_ = (f); v >= v##_; --v)
#define rrep(v, n) rreps(v, 0, n - 1)
#define rlep(v, n) rreps(v, 1, n)
#define show_a(a, size) rep(a##_it, size) std::cout << a[a##_it] << " \n"[a##_it == a##_it_ - 1];
#define show_v(v) show_a(v, v.size())
#define debug(x) std::cerr << #x << " = " << (x) << "\n";

using namespace std;

typedef long long int lint;

static inline int in(){ int x; scanf("%d", &x); return x; }
static inline lint inl(){ lint x; scanf("%lld", &x); return x; }

int main()
{
  map<string, int> dict;
  string word;
  while (cin >> word){
    if (dict.find(word) != dict.end()){
      dict[word] += 1;
    }
    else {
      dict.insert(make_pair(word, 1));
    }
  }
  int most_freq = 0;
  string most_string = "";
  string max_string = "";
  for (map<string, int>::iterator it = dict.begin(); it != dict.end(); it++){
    if (max_string.size() < (*it).first.size()){
      max_string = (*it).first;
    }
    if (most_freq < (*it).second){
      most_string = (*it).first;
      most_freq = (*it).second;
    }
  }
  cout << most_string << " " << max_string << endl;
  return 0;
}

C++: #include <iostream>
#include <map>
#include <string>
using namespace std;
int main()
{
	typedef map<string , int> IM;
	IM CounterMap;
	string s;
	string maxLengthSt;
	string maxCountSt;
	int c = 0;
	while(cin >> s){
		IM::iterator it = CounterMap.find(s);
		if(it == CounterMap.end())	CounterMap[s] = 1;
		else{
			++it->second;
			if(it->second > c){
				maxCountSt = s;
				c = it->second;
			}
		}
		if(maxLengthSt.size() < s.size() )
			maxLengthSt= s;
	}
	cout << maxCountSt << " " << maxLengthSt << "\n";
	return 0;
}

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

int main() {
    map<string, int> cnt;
    string x;
    while (cin >> x) cnt[x]++;
    int m = 0;
    for (map<string, int>::iterator it = cnt.begin(); it != cnt.end(); ++it) {
        if (m < it->second) m = it->second;
    }
    string a, b;
    for (map<string, int>::iterator it = cnt.begin(); it != cnt.end(); ++it) {
        if (a.size() < it->first.size()) a = it->first;
        if (m == it->second) b = it->first;
    }
    cout << b << ' ' << a << endl;
    return 0;
}

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

using namespace std;

int main(){
	string sent;
	string word[500];
	int a[500]={};
	int i,j,k,l;
	int n,m,len;
	i=0;
	while(cin>>sent){
		if(i==0){
			word[0]=sent;
			a[0]++;
			i++;
			len=sent.size();
			n=0;
		}
		else {
			if(len<sent.size()){
				len=sent.size();
				n=i;
			}
			for(j=0; j<i; j++){
				if(sent==word[j]){
					a[j]++;
					break;
				}
				if(j==i-1){
					word[i]=sent;
					a[i]++;
					i++;
				}
			}
		}
	}
	m=0;
	for(j=0; j<=i; j++){
		if(m<a[j])m=j;
	}
	cout<<word[m]<<" "<<word[n]<<endl;
	return 0;
}

C++: #include<iostream>
#include<string>
#include<map>
using namespace std;
int main(){
	string s, key="", max="";
	map<string, int> count;
	int ans_int=0;
	while(cin >> s){
		if(s.size() > max.size()) max = s;
		++count[s];
	}
	for(map<string,int>::iterator it = count.begin(); it != count.end(); it++){
		if(ans_int < it->second){
		ans_int = it->second;
		key = it -> first;
		}
	}
			cout << key << " " << max << endl;
}

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

int main(){
  string s,t;
  map<string,int>m;
  for(;cin>>s;)m[s]++;
  s=t=(*m.begin()).first;
  int M=(*m.begin()).second,l=s.length();
  for(map<string,int>::iterator it=m.begin();it!=m.end();it++){
    if(M<(*it).second)M=(*it).second,s=(*it).first;
    if(l<(*it).first.length())l=(*it).first.length(),t=(*it).first;
  }
  cout<<s<<' '<<t<<endl;
}

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