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 <string.h>
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>
#include <utility>

#define ll (long lon
#define REP(i,n) for(int i = 0;i<(int)n;i++)
#define FOR(i,a,b) for(int i = (a);i < (b);i++)
#define RFOR(i,a,b) for(int i = (a);i>(b);i--)
#define INT_MIN_A -999999

using namespace std;

int main (void){
    
    char str[2001];
    gets(str);
    char tango[1000][33];
    int i = 0,j = 0,k = 0,l = 0, temp = 0,m = 0;
    int max_l = INT_MIN_A;
    int max_numer = 0;
    int yokuderu = 0;
    int yokuderu_temp = 0;
    int yokuderu_number = 0;
    while(str[i++] != '\0')
    {
        if(str[i-1] == ' ')
        {
            if((i-1)-temp>max_l)
            {
                max_l = (i-1) -temp;
                max_numer = j;
            }
            while(temp<i-1)
                tango[j][l++] = str[temp++];
            temp = i;
            j++;
            l = 0;
        }
    }
    
 
        if((i-1)-temp>max_l)
        {
            max_l = (i-1) -temp;
            max_numer = j;
        }
        while(temp<i-1)
            tango[j][l++] = str[temp++];
        temp = i;
        j++;
        l = 0;
    /*???????????§??????????????????*/
    //cout <<"number is " << j << endl;
    
    for(int m = 0; m < j;m++)
    {
        for(int k = 0; k<j;k++)
        {
            if(m != k)
            {
                if(strcmp(tango[m], tango[k]) == 0)
                {
                    yokuderu_temp++;
                }
            }
        }
        if(yokuderu_temp >= yokuderu)
        {
            yokuderu = yokuderu_temp;
            yokuderu_number = m;
        }
        yokuderu_temp = 0;
    }
    REP(i,32)
    cout << tango[yokuderu_number][i];
    cout << " ";
    while(tango[max_numer][m++] != '\0')
        cout << tango[max_numer][m-1];
    m = 0;
        cout << endl;
    
    
    return 0;
}

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


int main()
{
	string s;
	map <string, int> m;
	map <string, int> m2;
	int maxlen = -1;

	pair<string, int> max_pair;
	pair<string, int> max2_pair;
	while (cin >> s){
		if (m.count(s) == 0){
			m.insert(pair<string, int>(s, 0));
			m2.insert(pair<string, int>(s, (int)s.length()));
		}
		else{
			m[s]++;
		}
	}

	for (auto pm = m.begin(); pm != m.end(); pm++){
		if (pm->second > max_pair.second){
			max_pair = *pm;
		}
	}
	for (auto pm = m2.begin(); pm != m2.end(); pm++){
		if (pm->second > max2_pair.second){
			max2_pair = *pm;
		}
	}
	cout << max_pair.first << endl<<max2_pair.first<<endl;
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++) 
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
//???????????????????????????????????¨?????????????????°?????????????????????????????????????????§????????£??????????????????
int main()
{
    string S;
    vector<string> vc;
    while( cin >> S ){
        vc.push_back( S );
    }
    int tmp{}, tmp2{}, MAX{}, MAXS{}, res{}, res2{};
    REP( i, (int)vc.size() )
    {
        tmp = count( ALL(vc), vc[ i ] );
        tmp2 = vc[ i ].size();
        if( MAX < tmp )
        {
            MAX = tmp;
            res = i;
        }
        if( MAXS < tmp2 )
        {
            MAXS = tmp2;
            res2 = i;
        }
    }
    cout << vc[ res ] << " " << vc[ res2 ] << endl;
    return 0;
}

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

using namespace std;

int main()
{
    string input[1001];
    int i = 0;

    while (cin >> input[i]) {i++;};

    sort(input, input+i);

    int max = 0, pos = 0, add = 1, len = 0, lenp = 0;
    for (int j = 1; j < i; j++) {
        if (input[j-1] == input[j]) {
            add++;
            if (max < add) {
                max = add;
                pos = j;
            }
        } else {
            add = 1;
        }
        if (len < input[j].length()) {
            len = input[j].length();
            lenp = j;
        }
    }
    cout << input[pos] << " " << input[lenp] << endl;

    return 0;
}

C++: #define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

#include <bits/stdc++.h>
using namespace std;
int main(){
  string s,t,u="";
  map<string,int> m;
  m[t]=0;
  while(cin>>s){
    m[s]++;
    if(m[s]>m[t]) t=s;
    if(s.size()>u.size()) u=s;
  }
  
  cout<<t<<" "<<u<<endl;
      
  return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;

#define iota(i,n,b,s) for(int i=int(b);i!=int((b)+(s)*(n));i+=(s))
#define range(i,n,m) iota(i,(((n)>(m))?((n)-(m)):((m)-(n))),(n),((n)>(m)?-1:1))
#define rep(i,n) iota(i,(n),0,1)
#define loop for(;;)

#define INF (1e9)
#define EPS (1e-9)
#define cons(a,b) (make_pair(a,b))
#define car(a) (a.first)
#define cdr(a) (a.second)
#define cadr(a) (car(cdr(a)))
#define cddr(a) (cdr(cdr(a)))
#define all(a) a.begin(), a.end()
#define trace(var) cerr<<">>> "<<#var<<" = "<<var<<endl;

typedef long long Integer;
typedef double Real;
typedef vector<int> vi;
typedef vector<string> vs;
typedef map<string,int> Dictionary;
const Real PI = acos(-1);

template<class S, class T>
ostream& operator<<(ostream& os, pair<S,T> p) {
  os << '(' << car(p) << ", " << cdr(p) << ')';
  return os;
}

template<class T>
ostream& operator<<(ostream& os, vector<T> v) {
  if (v.size() == 0) {
    os << "(empty)";
    return os;
  }
  os << v[0];
  for (int i=1, len=v.size(); i<len; ++i) os << ' ' << v[i];
  return os;
}

int dx[] = { -1, 0, 1, 0 };
int dy[] = {  0, -1, 0, 1 };

int main() {

  Dictionary d;

  int freq = 0;
  string longest = "";
  int longest_length = 0;

  for (string s; cin>>s, cin;) {
    d[s]++;
    freq = max(freq, d[s]);
    if (longest_length < s.size()) {
      longest = s;
      longest_length = s.size();
    }
  }

  string most_freq;
  for (auto&p : d) {
    if (freq == cdr(p)) {
      most_freq = car(p);
      break;
    }
  }

  cout << most_freq << ' ' << longest;

  return 0;
}