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 <iostream>
#include <string>
#include <map>

using namespace std;

int main() {
	string max = "";
	string mode;
	map <string, int> str;
	int count = 0;
	string a;
	while(cin >> a) {
		if(a == "EOF") {
			break;
		}
		if(a.size() > max.size()) {
			max = a;
		}
		str[a]++;
		if(str[a] > count) {
			count = str[a];
			mode = a;
		}
	}
	cout << mode << " " << max << endl;

	return 0;
}

C++: // includes
#include <cstdio>
#include <cstdint>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>
#include <climits>
#include <bitset>

// macros
#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue
#define FOR(i, a, b) for(int i=(a); i<(b);++i)
#define rep(i, n) FOR(i, 0, n)

using namespace std;

//  types
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
 
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;

// solve

int main(int argc, char const* argv[])
{
  string s;
  unordered_map<string, int> mp;
  int maxi = -1;
  string res = "";
  while(cin >> s){
    mp[s]++;
    if(maxi < int(s.size())){
      maxi = s.size();
      res = s;
    }
  }
  int maxi2 = -1;
  string res2 = "";
  for(auto itr = mp.begin(); itr != mp.end(); ++itr){
    if(maxi2 < itr->second){
      maxi2 = itr->second;
      res2 = itr->first;
    }
  }
  cout << res2 << " " << res << endl;
	return 0;
}

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

typedef std::map<std::string, std::uint32_t> OccurenceWordMap;

class compare_second {
		typedef OccurenceWordMap::value_type value_type;
	public:
		bool operator()(value_type const& lhs, value_type const& rhs) const
		{
			return lhs.second < rhs.second;
		}
};

class compare_length {
		typedef std::string value_type;
	public:
		bool operator()(value_type const& lhs, value_type const& rhs) const
		{
			return lhs.length() < rhs.length();
		}
};

int main()
{
	std::string input_text;
	std::getline(std::cin, input_text);
	typedef std::vector<std::string> StringVec;
	StringVec word_vec;
	std::string::size_type pos1 = 0;
	std::string::size_type pos2;
	while ((pos2 = input_text.find(' ', pos1)) != std::string::npos) {
		word_vec.push_back(input_text.substr(pos1, pos2 - pos1));
		pos1 = pos2 + 1;
	}
	word_vec.push_back(input_text.substr(pos1, input_text.size() - pos1));
	OccurenceWordMap ow_map;
	for (std::string const& word : word_vec) {
		auto i = ow_map.lower_bound(word);
		if (i != ow_map.end() && !(ow_map.key_comp()(word, i->first))) {
			++i->second;
		}
		else {
			ow_map.insert(std::make_pair(word, 0));
		}
	}
	std::cout << std::max_element(ow_map.begin(), ow_map.end(), compare_second())->first << ' '
			  << *std::max_element(word_vec.begin(), word_vec.end(),  compare_length()) << std::endl;
	return 0;
}

C++: #include <bits/stdc++.h>
 
using namespace std;
 
/*-------------------------------*/
#define FOR(i, a, b) for(int i = (a); i < (b); i++) 
#define RFOR(i, a, b) for(int i = (b) - 1; i >= (a); i--)
#define REP(i, n) for(int i = 0; i < (n); i++)
#define RREP(i, n) for(int i = (n) - 1; i >= 0; i--)
#define all(i) (i).begin(),(i).end()
#define pb push_back
#define mp make_pair 
 
typedef long long ll;
typedef pair<int, int> pint;
typedef vector<int> vi;
typedef vector<vector<int> > vii;
typedef vector<long long> llv;
typedef vector<pint> vpint;
/*-------------------------------*/
 
int main(void)
{
  map<string, int> m;
  string x = "", s, y = "";

  while (cin >> s){
    m[s] += 1;
    if (m[x] < m[s]) x = s;
    if (y.size() < s.size()) y = s;
  }
  cout << x << " "  << s << endl;
  
  return 0;
}

C++: /*****include*****/
#include <iostream>
#include <fstream>
#include <string>
#include <map>

/*****デバッグ定義*****/
//#define DEBUG
/*****マクロ定義*****/

/*****名前空間*****/
using namespace std;

/*****グローバル変数置き場*****/

/*****その他関数置き場*****/

/*****main関数*****/
int main(){
	/*****ファイルオープン*****/
#ifdef DEBUG
	ofstream fout("output.txt");
	ifstream fin("input.txt");
	if(!fout || !fin){
		cout << "Can't open the file.\n";
		return;
	}
#endif
	/*****変数置き場*****/
	string word;
	int max_length;
	int max_appear;
	string max_string;
	string max_word;
	map<string,int> appear;
	/*****処理部*****/
	max_length = 0;
	max_appear = 0;
	while(1){
		cin >> word;
		if(cin.eof())	break;
		if(appear.find(word) == appear.end()){
			appear[word] = 1;
		}else
			
			appear[word]++;
		if(appear[word] > max_appear){
			//cout << word << " " << appear[word] << " " << max_appear << endl;
			max_appear = appear[word];
			max_word = word;
			//cout << max_word << " " << max_appear << " " << appear[word] << endl;
		}
		if(word.length() > max_length){
			max_length = word.length();
			max_string = word;
		}
	}
	cout << max_word << " " << max_string << endl;
	/*****処理終了後*****/
#ifdef DEBUG
	fout.close();
	fin.close();
#endif
	return 0;
}

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

int main(){

  map < string, int > str;

  int j=0,a=0,max=0;
  string n,tmp,z,tmp2;

  getline(cin,n);

  for(int i=0; i<n.size(); i++){
    if(n[i]==' '){

      z = n.substr(j,i-j);
      str[z]++;

      if(a <= str[z]){
	a = str[z];
	tmp = z;
      }

      if(tmp2.size() < z.size() ){
	tmp2 = z;
      }

      j=i+1;

    } 

  }

      z = n.substr(j);
      str[z]++;

      if(a <= str[z]){
	a = str[z];
	tmp = z;
      }

      if(tmp2.size() < z.size() ){
	tmp2 = z;
      }   
  cout << tmp << ' ' << tmp2 <<  endl;
}

C++: #include<iostream>
#include<string>
#include<algorithm>	
#include<cmath>
#include<map>
#include<vector>
#define int long long
using namespace std;
int uiop[123456];
string test[123456];
signed main() {
	int n, b = 0, sum = 0, ans = 0; string s, t = "a", u = "a";
	for (int h = 0; h < 8; h++) {
		cin >> s; if (ans < s.size()) { ans = s.size(); t = s; }
		int a = 0;
		for (int i = 0; i < b; i++) {
			if (test[i] == s) {
				uiop[i]++; a++;
			}
		}
		if (a == 0) {
			test[b] = s; uiop[b]++; b++;
		}
	}
	for (int h = 0; h < b; h++) {
		sum = max(sum, uiop[h]);
	}
	for (int h = 0; h < b; h++) {
		if (uiop[h] == sum) {
			u = test[h];
		}
	}
	cout << u << ' ' << t << endl;
}

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 && s != "0") {
		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;
}