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<map>
using namespace std;

int main() {
	map<string, int> ms;
	string s, ans, ans2;
	int max = 0, max2 = 0;
	
	while (cin >> s) {
		ms[s]++;
		if (max2 < ms[s]) {
			max2 = ms[s];
			ans2 = s;
		}
		if (max < s.size()) {
			max = s.size();
			ans = s;
		}
		
	}
	cout << ans2 << " " << ans << endl;
}

C++: //#define _GRIBCXX_DEBUG
#include <algorithm>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <iomanip>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;


// ?????¬???????????¬??????
#pragma region MACRO
#define P(x) cout << (x) << endl
#define p(x) cout << (x)
#define PED cout << "\n"
#define rep(i,n) for(int i=0; i<(int)n; ++i)
#define REP(i,x,n) for(int i=x; i<(int)n; ++i)
#define repi(i,n) for(int i=0; i<=(int)n; ++i)
#define REPI(i,x,n) for(int i=x; i<=(int)n; ++i)
#define ILP while(true)
#define FOR(i,c) for(__typeof((c).begin())!=(c).begin(); i!=(c).end(); ++i)
#define ALL(c) (c).begin(), (c).end()
#define mp make_pair
#pragma endregion

// ???
#pragma region TYPE_DEF
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<string, string> pss;
typedef pair<string, int> psi;
typedef pair<int, string> pis;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long> vl;
typedef vector<long long> vll;
typedef vector<string> vs;
#pragma endregion

// Effective std
#pragma region ESTD
template<typename C, typename T>
constexpr int count(C& c, T t) { return count(ALL(c), t); }
template<typename C, typename F>
constexpr int count_if(C& c, F f) { return count_if(ALL(c), f); }
template<typename C, typename T>
void erase(C& c, T t) { remove(ALL(c), t), c.end(); }
template<typename C>
void remove(vector<C>& c, unsigned int index) { c.erase(c.begin()+index); }
template<typename C, typename T, typename U>
constexpr void replace(C& c, T t, U u) { replace(ALL(c), t, u); }
template<typename C, typename F, typename U>
constexpr void replace_if(C& c, F f, U u) { (ALL(c), f, u); }
template<typename C>
constexpr void reverse(C& c) { reverse(ALL(c)); }
template<typename C>
constexpr void sort(C& c) { sort(ALL(c)); }
template<typename C, typename Pred>
constexpr void sort(C& c, Pred p) { sort(ALL(c), p); }
#pragma endregion

// ?????°
#pragma region CONST_VAL
#define PI (2*acos(0.0))
#define EPS (1e-9)
#define MOD (int)(1e9+7)
#pragma endregion


int main()
{
    map<string, int> d;
    string s;
    while(cin>>s) d[s]++;
    string ans1 = "";
    int mx_count1 = 0;
    string ans2 = "";
    int mx_count2 = 0;
    for (auto el : d) {
        if(el.second>=mx_count1) {
            ans1 = el.first;
            mx_count1 = el.second;
        }
        if(el.first.size()>=mx_count2) {
            ans2 = el.first;
            mx_count2 = el.first.size();
        }
    }
    cout << ans1 << " " << ans2 << endl;
    return 0;
}

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

int main() {
	string str[1000],tmp;
	int a[1000] = {}, flag = 0, max = 1, i, length = 0, num = 0;

	while (cin >> tmp) {
		if (flag == 0) {
			flag++;
			tmp[0] = tmp[0] + 'a' - 'A';
		}
		for (i = 0; i < max;i++) {
			if (tmp == str[i]) {
				a[i]++;
				break;
			}
		}

		if (i == max) {
			str[i] = tmp;
			max++;
		}

		if ((int)tmp.size() > length) {
			num = i;
			length = (int)tmp.size();
		}
	}

	cout << str[max] << " " << str[length] << endl;
	return 0;
}

C++: #include<iostream>
#include<cstring>
#include<stdio.h>
#include<algorithm>
using namespace std;
char a[1010][100];
char b[10000];
int main()
{
	int i,j,l,s,m,n,p,k,s1,s2;
	while(gets(b))
	{
		memset(a,0,sizeof(a));
		l=strlen(b);
		j=0;p=0;n=0;s=0;
		for(i=0;i<l;i++)
		{
			if(b[i]!=' ')
			{
				char t=b[i];
				a[j][p++]=b[i];
			}
			else
			{
			//	cout<<p<<" --"<<endl;
				if(p>n)
				{
					n=p;
					m=j;
				}
				j++;
				p=0;
			}
		}
          if(p>n)
				{
					n=p;
					m=j;
				}
		int t=0;
		for(i=0;i<=j;i++)
		{
			s=0;
			for(s1=0;s1<=j;s1++)
			{
				if(strcmp(a[i],a[s1])==0)
					s++;
			}
			if(s>t)
			{
				t=s;
				s2=i;
			}
		}
		printf("%s %s\n", a[s2], a[m]);
	}
}

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

const int MAX_NUM_OF_STR = 1010;

int main(){
	int len = 0, tango = 0;
	string str[MAX_NUM_OF_STR], max, maxlen;
	map<string, int> string_cnt;
	
	while(cin >>str[tango]){
		string_cnt[str[tango]]++;
		
		if(str[tango].size() > (unsigned)len){
			len = str[tango].size();
			maxlen = str[tango];
		}
		tango++;
	}
	
	map<string, int>::iterator it = string_cnt.begin();
	int cnt = -1;
	string tmp;
	for(int i = 0 ; i < string_cnt.size(); it++, i++){
		if((*it).second > cnt){
			cnt = (*it).second;
			tmp = (*it).first;
		}
	}
	max = tmp;
	
	cout <<max <<" " <<maxlen <<endl;
	return 0;
}

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

using namespace std;

int main() {
	string k[100];
	int kk[100][2];
	string a;
	int n = 0;
	int judge;
	int maxa = 0;
	int maxb = 0;
	string aa,bb;

	while(cin >> a) {
		if (n == 0) {
			k[0] = a;
			kk[0][0] = 1;
			kk[0][1] = a.size();
		} else {
			judge = 0;
			for (int i = 0; i < n; i++) {
				if (k[i] == a) {
					kk[i][0]++;
					judge = 1;
					break;
				}
			}
			if (judge == 0) {
				k[n] = a;
				kk[n][0] = 1;
				kk[n][1] = a.size();
			} else {
				continue;
			}
		}
		n++;
		
	}

	for (int i = 0; i < n; i++) {
		if (kk[i][0] > maxa) {
			aa = k[i];
			maxa = kk[i][0];
		}
		if (kk[i][1] > maxb) {
			bb = k[i];
			maxb = kk[i][1];
		}
	}
	
	cout << aa <<  " " << bb << endl;

	return 0;
}

C++: #include<iostream>
#include<cstring>
using namespace std;
int const N = 1001;
int main(){
  char str[N][50];
  int num[N],i=0,max=0,l=0;
  while(cin >> str[i]){
    i++;
  }
  for(int j =0;j<i;j++){
    num[j] =0;
  }
  for(int j=0;j<i;j++){
    for(int k=0;k<i;k++){
       if(strcmp(str[j],str[k]) == 0)
	num[j]++;
    }
    if(num[max] < num[j])
      max = j;
    if(strlen(str[l]) < strlen(str[j]))
      l = j;
  }
  cout <<  str[max] <<" "<< str[l] << endl;
}