Go: package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
)

var scanner = bufio.NewScanner(os.Stdin)

func nextString() string {
	scanner.Scan()
	return scanner.Text()
}

type Pair struct {
	key   string
	value int
}

func main() {
	scanner.Split(bufio.ScanWords)
	counts := map[string]int{}
	maxLen := 0
	maxLenWord := ""
	for {
		word := nextString()
		if word == "" {
			break
		}

		counts[word]++

		if len(word) > maxLen {
			maxLen = len(word)
			maxLenWord = word
		}
	}

	mapPairs := []Pair{}
	for k, v := range counts {
		mapPairs = append(mapPairs, Pair{k, v})
	}
	sort.Slice(mapPairs, func(i, j int) bool { return mapPairs[i].value > mapPairs[j].value })

	fmt.Println(mapPairs[0].key, maxLenWord)
}

C++: #include <iostream>
#include <cstdio>
#include <string>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <ctime>
using namespace std;

#define rep(i,a,n) for(int i=a; i<n; i++)
#define repr(i,a,n) for(int i=a; i>=n; i--)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 999999999

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long int ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

int const MOD = 1000000007;

int main() {
    string s;
    multiset<string> v;

    int max_num = 0;
    int max_len = 0;

    while(cin >> s) {
        v.insert(s);
        max_num = max((int)v.count(s), max_num);
        max_len = max((int)s.length(), max_len);
    }

    for(auto x : v) {
        if(v.count(x) == max_num) {cout << x << " "; break;}
    }
    for(auto x : v) {
        if(x.length() == max_len) {cout << x << endl; break;}
    }
    return 0;
}

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

int main(){
	string s, str1, str2;
	map<string, int> mp;
	while(cin >> s){
		mp[s]++;
		if(mp[s] > mp[str1])str1 = s;
		if(s.size() > str2.size())str2 = s;
	}
	cout << str1 << " " << str2 << endl;
	return 0; 
}

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

map<string,int> table;

int main(){
	string word, frequent, longest;
	int frequent_length = 0;
	while (cin >> word){
		table[word] += 1;
		if (table[word] > frequent_length){
			frequent_length = table[word];
			frequent = word;
		}
		longest = (word.size() > longest.size()) ? word : longest;
	}	
	cout << frequent << longest << endl;
	return 0;
}

C++: #include <algorithm>
#include <map>
#include <vector>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <cctype>
#include <cstdlib>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define IREP(it,array) for(vector<int>::iterator it=array.begin(); it!=array.end(); ++it)
#define SREP(it,array) for(vector<string>::iterator it=array.begin(); it!=array.end(); ++it)
#define MP make_pair
typedef long long LL;
#define EPS (1e-6)
double zero(double d){
  return d < EPS ? 0.0 : d;
}

typedef pair<int,int> P;


int main()
{
  cout.setf(ios::fixed, ios::floatfield);
  cout.precision(7);
  int INF = 1000000;

  map<string,int> data;
  string str;
  while(cin >> str){
    data[str]++;
  }

  map<string,int>::iterator freq=data.begin();
  map<string,int>::iterator len=data.begin();

  for(map<string,int>::iterator it=data.begin(); it!=data.end(); ++it){
    if( (*freq).second < (*it).second )
      freq = it;
    if( (*len).first.length() < (*it).first.length() )
      len = it;
  }

  cout << (*freq).first << " " << (*len).first << endl;

  return 0;
}

C++: #define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include "bits/stdc++.h"
#define REP(i,a,b) for(int i=a;i<b;++i)
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define ALL(a) begin(a),end(a)
#define ifnot(a) if(not (a))
#define dump(x)  cerr << #x << " = " << (x) << endl
using namespace std;

// #define int ll
#ifdef _MSC_VER
const bool test = true;
#else 
const bool test = false;
#endif

int dx[] = { 0,1,0,-1 };
int dy[] = { 1,0,-1,0 };
#define INF (1 << 28)
ull mod = (int)1e9 + 7;
//.....................
const int MAX = (int)2e5 + 5;

int main() {
	string s;
	getline(cin, s);
	stringstream ss(s);
	map<string, int> m;
	string s2;
	string max_size_s;
	// dump(max_size_s.size());
	while (ss >> s2) {
		m[s2]++;
		if (s2.size() > max_size_s.size()) {
			max_size_s = s2;
		}
	}
	string most_fre_s;
	int most_fre_cnt = 0;
	for (auto p : m) {
		if (p.second > most_fre_cnt) {
			most_fre_s = p.first;
			most_fre_cnt = p.second;
		}
	}
	cout << most_fre_s << " " << max_size_s << endl;
	return 0;
}

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

using namespace std;

/** Problem0029 : English Sentence **/
int main()
{
	map<string, int> sentences;
	string tmp, maxLength, a;
	maxLength="";
	int A=0;
	
	while (cin >> tmp) {
		if (tmp.length() > maxLength.length())
			maxLength = tmp;
		
		if (sentences.count(tmp) == 0) {
			sentences.insert(map<string,int>::value_type(tmp, 1));
		} else {
			sentences[tmp]++;
		}
		
		if (sentences[tmp] > A) {
			A = sentences[tmp];
			a = tmp;
		}
	}
	
	cout << a << " " << maxLength << endl;
	
	return 0;
}

C++: #include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <vector>
#include <set>
#include <map>

using namespace std;
typedef long long LL;
static const double EPS = 1e-9;

#define FOR(i,k,n) for (int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n) 

int main(void){
  vector<int> count;
  vector<string> word;
  string tmp;
  while(cin>>tmp){
    if(find(word.begin(),word.end(),tmp) != word.end()){
      int d = distance(word.begin(), find(word.begin(),word.end(),tmp));
      count[d]++;
    }else{
      word.push_back(tmp);
      count.push_back(1);
    }
  }
  int maxn = 0,maxl = 0, mni, mli;
  
  REP(i,count.size()){
    if(count[i] > maxn) {
      maxn = count[i];
      mni = i;
    }
    if(word[i].size() > maxl){
      maxl = word[i].size();
      mli = i;
    }
  }
  cout << word[mni] << " " << word[mli] << endl;
  return 0;
}

C++: 
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <time.h>
#include <stdlib.h>
#include <set>
#include <stack>
#include <sstream>
#include <map>

using namespace std;

int main()
{
	map<string,int> mp;
	string s;
	getline(cin,s);
	string t,ls,ms;
	int n = 0;
	istringstream ss(s);
	while ( ss >> t )
	{
		int tn = ++mp[t];
		if ( t.size() > ls.size() )
			ls = t;
		if ( tn > n )
		{
			ms = t;
			n = tn;
		}
	}
	cout << ms << " " << ls;
	return 0;
}

C++: #include <iostream>
#include <cstring>
#include <string.h>
#include <cstdio>
using namespace std;
int main(){
  char c[1111];
  int len=0;
  int k=0;
  char maxc;
  int iti[1111]={0};//頻度高いよう
  char ans[1111];
  int sai=0;
  char ans1[1111];
  char cpy[1111][1111];
  while(scanf("%s",c)!=EOF){
    if(len<strlen(c)){//最長のもの
      len=strlen(c);
      strcpy(ans,c);
    }
    
    for(int i=0;i<k+1;i++){
      if(strcmp(cpy[i],c)==0){//すでに一度でていたら
	iti[i]++;
	break;
      }else if(i==k){//一度もでていなかったら
	strcpy(cpy[i],c);
      }
    }
    k++;
  }
  
  strcpy(ans1,cpy[0]);
  sai=iti[0];
  for(int i=0;i<k;i++){
    if(sai<iti[i]){
      sai=iti[i];
      strcpy(ans1,cpy[i]);
    }
  }
  /*for(int i=0;i<k;i++){
    cout << cpy[i] << " ";
    }*/

  cout << ans1 << " " << ans << endl;
}