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;
map<string, int> table;
int main() {
  string word, frequent, longest; // input, max frequency, and longest
  size_t N=0; // frequency of the string "frequent"
  while (cin >> word) {
    table["word"] += 1;
    if (table["word"] > N) {
      N = table["word"];
      frequent = word;
    }
    if (word.size() > longest.size()) longest = word;
  }
  cout << frequent << " " << longest << endl;
}

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

int main(){
	map<string, int> word;
	int mfrec=0;
	string mfs, ls, in;
	while(cin>>in){
		if(word.count(in)==0) word[in]=0;
		word[in]++;
		if(mfrec<word[in]){
			mfrec=word[in];
			mfs=in;
		}
		if(ls.length()<in.length()) ls=in;
	}
	cout << mfs << " " << ls << endl;
	return 0;
}

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

//define-----------------------------------------------------------------------------------------------------------------------
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define FOR(i, s, n) for(int i = s; i < (int)n; i++)
#define per(i, n) for(int i = n; i >= 0; i--)
#define ROF(i, s, n) for(int i = s; i >= (int)n; i--)
#define FORIT(i, A) for (auto i : A)
#define PRINT(x) cout << (x) << "\n"
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define EACH(i, n) for (__typeof((n).begin()) i = (n).begin(); i != (n).end(); ++i)
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define dump(x) cout << #x << " = " << (x) << "\n";
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << "\n";
#define sq(n) (n) * (n)

//typedef----------------------------------------------------------------------------------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef priority_queue<int> maxpq;
typedef priority_queue< int, vector<int>, greater<int> > minpq;
//const------------------------------------------------------------------------------------------------------------------------
static const double EPS = 1e-10;
static const double PI = acos( -1.0 );
static const int mod = 1000000007;
static const int INF = 1 << 25;

//global-----------------------------------------------------------------------------------------------------------------------
char a[ 10000 ];
map<string, int> ar;
int most_lengh = 0;
string most_str;
//#define DEBUG
//function--------------------------------------------------------------------------------------------------------------------

int main() {
	while ( scanf( "%s", a ) != EOF ) {
		string str = (string)a;
		ar[ str ]++;
		if ( most_lengh < str.size() ) {
			most_lengh = str.size();
			most_str = str;
		}
		
	}
	string ans;
	int b = 0;
	map<string, int>::iterator it;
	for ( it = ar.begin(); it != ar.end(); it++ ) {
		if ( b < it->second ) {
			b = it->second;
			ans = it->first;
		}
	}
	cout << ans << " " << most_str << "\n";
	return 0;
}

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

int main() {
	std::string s;
	int max=0;
	int maxv=0;
	string maxval;
	string maxlen;
	map<string,int> m;
	while(cin>>s){
		if(s.length()>max){
			max=s.length();
			maxlen=s;
		}
		m[s]++;
		if(maxv<m[s]){
			maxval=s;
			maxv=m[s];
		}
	}
	cout<<maxval<<" "<<maxlen<<endl;
}

C++: #include<iostream>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<functional>
using namespace std;
int main() {
	vector<pair<int,string>> x(1000);
	string a;
	int j=1,s=0,m=0;
	while(cin >> a) {
		for (int i = 0; i <j ; i++) {
			if (x[i].second == a) {
				x[i].first++;
				break;
			}
			if (i == j - 1) {
				x[i].second = a;
				x[i].first = 1;
				j++;
				break;
			}
		}
	}
	sort(x.begin(), x.end(), greater<pair<int, string>>());
	for (int i = 0; i < j; i++) {
		if (x[i].second.size() > s) {
			s = x[i].second.size();
		}
	}
	for (int i = 0; i < j; i++) {
		if (x[i].first > m) {
			m = x[i].first;
		}
	}
	for (int i = 0; i < j; i++) {
		if (x[i].first == m) {
			cout << x[i].second << ' ';
		}
	}
	for (int i = 0; i < j; i++) {
		if (x[i].second.size() == s) {
			cout << x[i].second << endl;
		}
	}
	return 0;
}

C++: #include <iostream>
#include <string>
#include <map>
using namespace std;
int main(){
	map<string,int>m;
	string s,t,u;
	int a,b=0;
	for(;cin>>s;){
		if(s.length()>u.length())u=s;
		a=++m[s];
		if(a>b){b=a;t=s;}
	}
	cout<<t<<" "<<u<<endl;
}

C++: #include <iostream>
#include <map>
#include <queue>

using namespace std;

int main() {
  string max_word;
  map<string, int> m;
  string str;
  while (cin >> str) {
    m[str]++;
    if (str.size() > max_word.size()) max_word = str;
  }
  priority_queue<pair<int, string> > que;
  for (map<string, int>::iterator it = m.begin() ; it != m.end(); it++) {
    que.push(pair<int, string>(it->second, it->first));
  }
  cout << que.top().second << ' ' << max_word << 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;
int main(){
  string s,ans1="",ans2;
  map<string,int> mp;
  while(cin >> s){
    if(ans1==""){
      ans1=s;
      ans2=s;
    }
    mp[s]++;
    if(mp[s]>mp[ans1]){
      ans1=s;
    }
    if(s.size()>ans2.size()){
      ans2=s;
    }
  }
  cout << ans1 << " " << ans2 << endl;
  return 0;
}