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 <bits/stdc++.h>
using namespace std;
string s;
long long base=311,MOD=1e9+7,slen;
long long hashs[1005],lt[1005],Pow[1005];
int res1,res2,max1,max2,dau[1005],cuoi[1005],kc[1005],dem;
void nhap()
{
    getline(cin,s);
    s=' '+s;
    slen=s.length()-1;
}
void taohash()
{
    Pow[0]=1;
    for (long long i=1;i<=slen;i++) Pow[i]=(Pow[i-1]*base)%MOD;
    for (long long i=1;i<=slen;i++){
        hashs[i]=(hashs[i-1]*base+s[i])%MOD;
    }
}
long long get(long long i,long long j)
{
    return ((hashs[j]-hashs[i-1]*Pow[j-i+1])+MOD*MOD)%MOD;
}
bool kt(int x,int y)
{
    if (kc[x]!=kc[y]) return false;
    return get(dau[x],cuoi[x])==get(dau[y],cuoi[y]);
}
void push(int u,int v)
{
    dem++;
    dau[dem]=u;
    cuoi[dem]=v;
    kc[dem]=v-u;
}
void khoitao()
{
    int u=1,v;
    for (int i=1;i<=slen;i++){
        if (s[i]==' '||i==slen){
            v=i-1;
            if (i==slen) v=i;
            push(u,v);
            if (kc[dem]>max2){
                res2=dem;
                max2=kc[dem];
            }
            u=i+1;
        }
    }
}
void xuli()
{
    khoitao();
    taohash();
    for (int i=1;i<=dem;i++){
        int kq=0;
        for (int j=1;j<=dem;j++){
            if (j!=i) if (kt(i,j)) kq++;
        }
        if (kq>max1){
            res1=i;
            max1=kq;
        }
    }
    for (int i=dau[res1];i<=cuoi[res1];i++) printf("%c",s[i]);
    printf(" ");
    for (int i=dau[res2];i<=cuoi[res2];i++) printf("%c",s[i]);
    printf("\n");
}
int main()
{
    nhap();
    xuli();
}

C++: #include<iostream>
#include<string.h>
#include<vector>
#include<list>
#include<stdio.h>
#include<math.h>
#include<iomanip>
#include<map>
#include<stack>
#include<queue>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define debug(x) cout << "debug " << x << endl;
using namespace std;

int main(){
    string s, ans1, ans2;
    int longest = 0, many = 0;
    map<string, int> time;
    while(cin >> s){
        if(longest < s.size()){
            longest = s.size();
            ans2 = s;
        }
        time[s]++;
        if(many < time[s]){
            many = time[s];
            ans1 = s;
        }
    }
    rep(i, ans1.size()){
        cout << ans1[i];
    }
    cout << ' ';
    rep(i, ans2.size()){
        cout << ans2[i];
    }
    cout << endl;
}

C++: #include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef pair<string, int> PAIR;

int main(){
	vector<PAIR> vec;
	vector<PAIR>::iterator ite;
	vector<PAIR>::iterator max;
	string st, siz;
	while(cin >> st){
		if(st == "0") break;
		if(vec.empty()){
			vec.push_back(PAIR(st, 1));
			//max = vec.begin();
			//siz = st;
		}else{
			ite = vec.begin();
			while(1){
				if((*ite).first == st){
					(*ite).second++;
					//if((*max).second < (*ite).second) max = ite;
					break;
				}
				ite++;
				if(ite == vec.end()){
					vec.push_back(PAIR(st, 1));
					//if(siz.size() < st.size()) siz = st;
					break;
				}
			}
		}

		ite = vec.begin();
		max = vec.begin();
		siz = (*ite).first;
		while(ite != vec.end()){
			if((*max).second < (*ite).second) max = ite;
			if(siz.size() < (*ite).first.size()) siz = (*ite).first;
			ite++;
		}


	}
		cout << (*max).first << " " << siz << endl;
	return 0;
}

C++: /*AOJ 0029*/

#include<iostream>
#include<vector>
#include<string>

using namespace std;

int main(){

	vector<string> data;

	char str[35];

	while(cin>>str){
		data.push_back(str);
	}

	int max=0;
	int maxNum = 0;
	int sum=0;

	for(int i=0;i<data.size();i++){
		sum = 0;
		for(int j=i+1;j<data.size();j++){
			if(data.at(i) == data.at(j)){
				sum++;
			}
		}
		if(max<=sum){
			max = sum;
			maxNum = i;
		}
	}

	cout<<data.at(maxNum)<<endl;

	max = 0;
	maxNum = 0;

	for(int i=0;i<data.size();i++){
		if(max <= data.at(i).size()){
			max = data.at(i).size();
			maxNum = i;
		}
	}

	cout<<data.at(maxNum)<<endl;


	return 0;
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cmath>

#define rep(i, n) for(int i = 0; i < n; i ++)
#define ALL(T) T.begin(), T.end()
#define mp make_pair
#define N first
#define L second

using namespace std;

typedef pair<int, int> pii;
typedef pair<string, string> pss;
typedef unsigned long long ull;

int main(void){
    map<string, pii> dic;
    pss res;

    for(string in; cin >> in;){
        dic[in].N ++;
        dic[in].L = in.size();

        if(dic[res.N].N < dic[in].N)
            res.N = in;
        if(dic[res.L].L < dic[in].L)
            res.L = in;
    }
    cout << res.N << " " << res.L << endl;

    return 0;
}

C++: #include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstring>
#include <iterator>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <iomanip>
#include <cassert>
//#include <utility>
//#include <memory>
//#include <functional>
//#include <deque>
//#include <cctype>
//#include <ctime>
//#include <numeric>
//#include <list>
//#include <iomanip>

//#if __cplusplus >= 201103L
//#include <array>
//#include <tuple>
//#include <initializer_list>
//#include <forward_list>
//
//#define cauto const auto&
//#else

//#endif

using namespace std;


typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()
#define DEBUG
#ifdef DEBUG
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#else
#define dump(x) 
#define debug(x) 
#endif

#define MOD 1000000007LL
#define EPS 1e-8
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)

void mainmain(){
	map<string,int> ma;
	string s;
	pair<int,string> m1(0,"");
	pair<int,string> m2(0,"");
	while(cin>>s){
		if(ma.count(s)==0) ma[s]=0;
		ma[s]++;
		maxs(m1,mkp((int)s.size(),s));
	}
	for(auto x:ma){
		maxs(m2,mkp(x.S,x.F));
	}
	cout<<m2.S<<" "<<m1.S<<endl;
}


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(20);
    mainmain();
}