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

using namespace std;

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);

  map<string, int> word;
  string str;
  string lon = "", w = "";
  int cmax = 0;

  while (cin >> str){
    if (str.size() > lon.size()){
      lon = str;
    }
    word[str]++;
  }

  map<string, int>::iterator it = word.begin();
  
  while (it != word.end()){
    if (cmax < (*it).second){
      cmax = (*it).second;
      w = (*it).first;
    }

    
    ++it;
  }

  cout << w << ' ' << lon << endl;

  return (0);
}

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

int main(){
	map<string,int> mp;
	string str,tmp[1111];
	getline(cin,str);
	istringstream ss(str);
	int i=0;
	while(getline(ss,tmp[i],' ')){
		mp[tmp[i]]++;
	}
	map<string,int>::iterator itr;
	int ans=0,len=0;
	string s1,s2;
	for(itr = mp.begin(); itr != mp.end(); ++itr) {
	   	string w = itr->first;
    	int c = itr->second;
    	if(c > ans) {
    		ans = c;
    		s1 = w;
    	}
    	int s = w.size();
    	if(s > len) {
    		len = s;
    		s2 = w;
    	}
	}
	cout << s1 << " " << s2 << endl;
}

C++: #include <bits/stdc++.h>

using namespace std;

int main()
{
    map<string, int> mp;
    string w, word;
    while (cin >> word) {
        mp[word]++;
        if (w.size() < word.size()) {
            w = word;
        }
    }
    
    for (auto &x: mp) {
        word = x.first;
    }
    cout << word << " " << w << endl;
    return 0;
}

C++: #include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double ESP=1e-10;
using namespace std;
int main(){
  string s;
  vector<string> line;
  vector<int> cnt;
  getline(cin,s);
  string word = "";
  string longest = "";
  
  rep(i,s.size()){
    if(s[i] == ' '){
      if(longest.size() < word.size()){
	longest = word;
      }
      bool find = false;
      
      rep(j,line.size()){
	if(line[j] == word){
	  cnt[j] ++;
	  find = true;
	  word = "";
	}
      }
      
      if(find)continue;
      line.pb(word);
      word = "";
    }else{
      word += s[i];
      cnt.pb(1);
    }
  }
  
  int ma = 0;
  string res = "";
  
  rep(i,line.size()){
    if(ma < cnt[i]){
      ma = cnt[i];
      res = line[i];
    }
  }
  
  cout<<res<<" "<<longest<<endl;

}

C++: #include <bits/stdc++.h>

#define reps(v, f, l) for (int v = (f), v##_ = (l); v < v##_; ++v)
#define rep(v, n) reps(v, 0, n)
#define lep(v, n) reps(v, 1, n + 1)
#define rreps(v, f, l) for (int v = (l), v##_ = (f); v >= v##_; --v)
#define rrep(v, n) rreps(v, 0, n - 1)
#define rlep(v, n) rreps(v, 1, n)
#define show_a(a, size) rep(a##_it, size) std::cout << a[a##_it] << " \n"[a##_it == a##_it_ - 1];
#define show_v(v) show_a(v, v.size())
#define debug(x) std::cerr << #x << " = " << (x) << "\n";

using namespace std;

typedef long long int lint;

static inline int in(){ int x; scanf("%d", &x); return x; }
static inline lint inl(){ lint x; scanf("%lld", &x); return x; }

int main()
{
  map<string, int> dict;
  string word;
  while (cin >> word){
    if (dict.find(word) != dict.end()){
      dict[word] += 1;
    }
    else {
      dict.insert(make_pair(word, 1));
    }
  }
  int most_freq = 0;
  string most_string = "";
  string max_string = "";
  for (map<string, int>::iterator it = dict.begin(); it != dict.end(); it++){
    if (max_string.size() < (*it).first.size()){
      max_string = (*it).first;
    }
    if (most_freq < (*it).second){
      most_string = (*it).first;
      most_freq = (*it).second;
    }
  }
  cout << most_string << " " << max_string << endl;
  return 0;
}

C++: #include <iostream>
#include <map>
#include <string>
using namespace std;
int main()
{
	typedef map<string , int> IM;
	IM CounterMap;
	string s;
	string maxLengthSt;
	string maxCountSt;
	int c = 0;
	while(cin >> s){
		IM::iterator it = CounterMap.find(s);
		if(it == CounterMap.end())	CounterMap[s] = 1;
		else{
			++it->second;
			if(it->second > c){
				maxCountSt = s;
				c = it->second;
			}
		}
		if(maxLengthSt.size() < s.size() )
			maxLengthSt= s;
	}
	cout << maxCountSt << " " << maxLengthSt << "\n";
	return 0;
}

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

int main() {
    map<string, int> cnt;
    string x;
    while (cin >> x) cnt[x]++;
    int m = 0;
    for (map<string, int>::iterator it = cnt.begin(); it != cnt.end(); ++it) {
        if (m < it->second) m = it->second;
    }
    string a, b;
    for (map<string, int>::iterator it = cnt.begin(); it != cnt.end(); ++it) {
        if (a.size() < it->first.size()) a = it->first;
        if (m == it->second) b = it->first;
    }
    cout << b << ' ' << a << endl;
    return 0;
}

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

using namespace std;

int main(){
	string sent;
	string word[500];
	int a[500]={};
	int i,j,k,l;
	int n,m,len;
	i=0;
	while(cin>>sent){
		if(i==0){
			word[0]=sent;
			a[0]++;
			i++;
			len=sent.size();
			n=0;
		}
		else {
			if(len<sent.size()){
				len=sent.size();
				n=i;
			}
			for(j=0; j<i; j++){
				if(sent==word[j]){
					a[j]++;
					break;
				}
				if(j==i-1){
					word[i]=sent;
					a[i]++;
					i++;
				}
			}
		}
	}
	m=0;
	for(j=0; j<=i; j++){
		if(m<a[j])m=j;
	}
	cout<<word[m]<<" "<<word[n]<<endl;
	return 0;
}

C++: #include<iostream>
#include<string>
#include<map>
using namespace std;
int main(){
	string s, key="", max="";
	map<string, int> count;
	int ans_int=0;
	while(cin >> s){
		if(s.size() > max.size()) max = s;
		++count[s];
	}
	for(map<string,int>::iterator it = count.begin(); it != count.end(); it++){
		if(ans_int < it->second){
		ans_int = it->second;
		key = it -> first;
		}
	}
			cout << key << " " << max << endl;
}

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

int main(){
  string s,t;
  map<string,int>m;
  for(;cin>>s;)m[s]++;
  s=t=(*m.begin()).first;
  int M=(*m.begin()).second,l=s.length();
  for(map<string,int>::iterator it=m.begin();it!=m.end();it++){
    if(M<(*it).second)M=(*it).second,s=(*it).first;
    if(l<(*it).first.length())l=(*it).first.length(),t=(*it).first;
  }
  cout<<s<<' '<<t<<endl;
}