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

int main(void){
	map<string,int> ans;
	char a[40];
	string best,high;
	while(!cin.eof()){
		cin>>a;
		string kari(a);
		if(ans.count(kari))
			ans[kari]++;
		else
			ans[kari]=1;
		if(ans[best]<ans[kari])
			best=kari;
		if(high.size()<kari.size())
			high=kari;
	}
	cout<<best.c_str()<<" "<<high.c_str()<<endl;
	return 0;
}

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;
}