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
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int main() {
  int fn = 0, ln = 0;
  map<string, int> m ;
  string str, f, l;
  bool b;

  while(cin >> str) {
    b = true;
    map<string, int>::iterator it = m.begin();
    while(it != m.end()) {
      if(it->first == str) {
	it->second += 1;
	b = false;
      }
      it++;
    }
    if(b) m.insert(pair<string, int>(str, 1));
  }
  map<string, int>::iterator it = m.begin();
  while(it != m.end()) {
    if(it->second > fn) {
      fn = it->second;
      f = it->first;
    }
    if((it->first).length() > ln) {
      ln = (it->first).length();
      l = it->first;
    }
    it++;
  }
  cout << f << ' ' << l << endl;
}

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

int main(){
	// word[s] Å ¶ñsÌo»ñªÔÁÄ­é
	map<string, int> word;
	vector<string> v;
	string s;

	while( cin >> s ){
		v.push_back(s);
		
		//üÍµ½Pêª·ÅÉ é©T·
		if( word.count(s) ){
			word[s]++;
		}else{
			word[s] = 1;
		}
	}
	// ÅpoÌPêð²×é
	int mode=0;
	for(int i=0 ; i < v.size() ; i++ ){
		mode = max( mode , word[ v[i] ] );
	}
	for(int i=0 ; i < v.size() ; i++ ){
		if( mode == word[ v[i] ] ){
			cout << v[i];
		}
	}
	// Å·ÌPêðßé
	int length = 0;
	for(int i=0 ; i < v.size() ; i++ ){
		length = max( length , v[i].size() );
	}
	for(int i=0 ; i < v.size() ; i++ ){
		if( length == v[i].size() ){
			cout << " " << v[i] << endl;
		}
	}
}

C++: #include<iostream>
#include<string>
#include<map>
using namespace std;int main(){string s,m,l;for(map<string,int>d;cin>>s;l=s.size()>l.size()?s:l)m=++d[s]>d[m]?s:m;cout<<m+" "+l+"\n";}

C++: #include <iostream>
#include <queue>
#include <string>
#include <stdio.h>

using namespace std;

int main()
{
  char cmd[2]; // command
  int digit; // digit to insert
  priority_queue<int> Q;
  while (true) {
    scanf("%s", cmd);
    if (cmd[0] == 'e' && cmd[1] == 'n') break;
    if (cmd[0] == 'i') {
      scanf("%d", &digit);
      Q.push(digit);
    } else {
      cout << Q.top() << endl;
      Q.pop();
    }
  }
}

C++: #include<iostream>
#include<cstdio>
#include<queue>
#include<cmath>
#include<string>
#include<cstring>
#include<cctype>
using namespace std;

int main(){
	string ss;
	getline(cin,ss);
	int num=0;
	queue<string> spot;
	string str="";
	for(int i=0;i<=ss.size();i++){
		if(!isalpha(ss[i]) || ss[i]=='\0'){
			if(i>0){
				spot.push(str);
				str="";
			}
		}else{
			str+=ss[i];
		}
	}
	int often[spot.size()];
	int ll=spot.size();
	string ansoften="",anslen="";
	int flg=0;
	int mark[ll];
	for(int i=0;i<ll;i++){mark[i]=0;}
	for(int a=0;a<ll;a++){
		if(mark[a]==1){
			often[a]=0;
		}else{
			string now=spot.front();
			spot.pop();
			for(int j=0;j<ll;j++){
				string rig=spot.front();
				spot.pop();
				if(now==rig){
					often[a]++;
					mark[j]=1;
				}
				if(flg==0 && rig.size()>anslen.size())anslen=rig;
				spot.push(rig);
			}
			flg++;
			spot.push(now);
		}
	}
	int aa=0;
	for(int b=0;b<ll;b++){
		if(aa<often[b])ansoften=spot.front();
		spot.pop();
	}
	cout<<ansoften<<" "<<anslen<<endl;
	return 0;
}

C++: #include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <set>
using namespace std;
#define rep2(x,from,to) for(int x=(from); x<(to); (x)++)
#define rep(x,to) rep2(x,0,to)
int main() {
	string s;
	vector<string> str1;
	set<string> str2;
	while(cin >> s) {
		str1.push_back(s);
		str2.insert(s);
	}
	int w = 0;
	string ret;
	rep(i,str1.size()) {
		if(w < str1[i].length()) {
			w = str1[i].length();
			ret = str1[i];
		}
	}

	int cnt[1000];
	rep(i,1000) {
		cnt[i] = 0;
	}
	int c = 0;
	for(auto it=str2.begin(); it != str2.end(); ++it) {
		rep(j,str1.size()) {
			if(*it == str1[j]) cnt[c]++;
		}
		c++;
	}
	int max = 0, r = 0;
	string ret2;
	for(auto it=str2.begin(); it != str2.end(); ++it) {
		if(max < cnt[r]) {
			max = cnt[r];
			ret2 = *it;
		}
		r++;
	}
	cout << ret << " " << ret2 << endl;
	return 0;
}

C++: #include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<cstring>
using namespace std;
int main(){
	char ans[50][10000] = {{0}};
	char a[10000] = {0};
	scanf("%[^\n]",a);
	int cnt = 0;
	int mx_len = 0;
	char date[10000] = {0};/*
	for(int i = 0,j = 0; i <= strlen(a); i++){
        if(a[i] >= 'a' && a[i] <= 'z' || a[i] >= 'A' && a[i] <= 'Z'){
            ans[cnt][j] = a[i];
            j++;
        }
        else{
            cnt++;
            j = 0;
        }
	}
	for(int i = 0; i < cnt; i++){
        cout << ans[i] << endl;
	}*/
	return 0;
}

C++: #include<stdio.h>
#include<string.h>
#include<ctype.h>
int main()
{
	int l=0,i=0,ls[64],max=0;
	char bun[64][64],mo[64];
	while(scanf("%s",bun[i])!=EOF){
		for(int j=0;j<strlen(bun[i]);j++){
			if(isupper(bun[i][j])){
				bun[i][j]=tolower(bun[i][j]);
			}
		}
		if(strlen(bun[i])>l){
			l=strlen(bun[i]);
			strcpy(mo,bun[i]);
		}
		i++;
	}
	for(int j=0;j<i-1;j++){
		for(int k=0;k<i-1;k++){
			if(k!=j){
				if(strcmp(bun[k],bun[j])==0){
					ls[j]++;
				}
			}
		}
	}
	for(int j=0;j<i;j++){
		if(ls[max]<=ls[j]){
			max=j;
		}
	}
	printf("%s %s\n",bun[max+1],mo);
	return 0;
}

C++: #include<iostream>
#include<cstdio>
#include<string>
#include<map>
using namespace std;
int main(){
  map<string,int> t;
  string s, mxc, mxl;
  int freq, len;
  while(cin >> s){
    if(t.find(s) == t.end()){
      t[s] = 1;
    }
    else{
      t[s]++;
    }

    if(t[s] > freq){
      freq = t[s];
      mxc = s;
    }
    if(s.size() > len){
      len = s.size();
      mxl = s;
    }
  }
  cout << mxc << " " << mxl << endl;
}