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<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<map>

using namespace std ;

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl

#define rep(i,n) for(int i = 0; i < (n);++i)
#define repc(i,a,b) for(int i = (a);i <(b);++i)
#define repa(n,array) for(auto n :(array))

long long typedef ll ;
typedef vector<int> vi ;
typedef vector<ll> vl ;
//template<class Value>
//using dict = std::map< string, Value >;
typedef map<string,int> dict ;

constexpr int IMAX = ((1<<30)-1)*2+1 ;
constexpr int INF = 100000000;
double EPS = 1e-10 ;

typedef const pair<string, int> PSI;
bool cmpCount(PSI &T1, PSI &T2) {
    return T1.second < T2.second;
}

bool cmpLength(PSI &T1, PSI &T2) {
    return T1.first.length() < T2.first.length();
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string str ;
  dict M;
  while(cin >> str){
    if(M.count(str) == 0){
      M[str] = 0 ;
    }
    else{
      auto it = M.find(str) ;
      ++it->se ;
    }
  }
  PSI maxCount = *max_element(M.begin(), M.end(), cmpCount);
  PSI maxLength = *max_element(M.begin(), M.end(), cmpLength);

  cout << maxCount.first << " " << maxLength.first << endl;
  return 0;
}

C++: #include<iostream>
#include<cstdio>
#include<queue>
#include<cmath>
#include<string>
#include<cstring>
#include<cctype>
using namespace std;

int main(){
	string ss;
	getline(cin,ss);
	int num=0;
	queue<string> spot;
	string str="";
	for(int i=0;i<=ss.size();i++){
		if(!isalpha(ss[i]) || ss[i]=='\0'){
			if(i>0){
				spot.push(str);
				str="";
			}
		}else{
			str+=ss[i];
		}
	}
	int often[spot.size()];
	int ll=spot.size();
	string ansoften="",anslen="";
	int flg=0;
	for(int a=0;a<ll-1;a++){
		string now=spot.front();
		spot.pop();
		for(int j=0;j<ll-1;j++){
			string rig=spot.front();
			spot.pop();
			if(now==rig)often[a]++;
			if(flg==0 && rig.size()>anslen.size())anslen=rig;
			spot.push(rig);
		}
		flg++;
		spot.push(now);
	}
	int aa=0;
	often[ll-1]=1;
	for(int b=0;b<ll;b++){
		if(aa<often[b])ansoften=spot.front();
		spot.pop();
	}
	cout<<ansoften<<" "<<anslen<<endl;
	return 0;
}

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

using namespace std;

int main (void) {
    vector<string> words;
    vector<int> count;
    int N = 0;
    while (1) {
        string w;
        cin >> w;
        if (cin.eof()) break;
        int index = 0;
        while (index < N && words[index] != w) index++;
        if (index == N) {
            words.push_back(w);
            count.push_back(1);
            N++;
        } else {
            count[index]++;
        }
    }
    string frequent;
    string longest;
    int freq = 0, size = 0, s;
    for (int i = 0; i < N; i++) {
        if (count[i] > freq) {
            freq = count[i];
            frequent = words[i];
        }
        s = words[i].size();
        if (s > size) {
            size = s;
            longest = words[i];
        }
    }
    cout << frequent << ' ' << longest << endl;
    return 0;
}

C++: #include <iostream>
#include <functional>
#include <sstream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <utility>

using namespace std;
typedef pair<int,string> strpair;

int main(){
  vector<strpair> data;
  string str;
  getline(cin,str);
  istringstream iss(str);
  string word;
  while(iss>>word){
    auto it= find_if(data.begin(),data.end(),[word](pair<int,string> p){return p.second==word;});
    if(it==data.end()){
      data.push_back(pair<int,string>(1,word));
    }else{
      (*it).first++;
    }
  }

  sort(data.begin(),data.end(),greater<pair<int,string> >());
  int maxlength=0;
  string maxlengthword;
  for(auto word:data){
    int length=word.second.length();
    if(length>maxlength){
      maxlength=length;
      maxlengthword=word.second;
    }
  }
  cout<<data[0].second<<" "<<maxlengthword<<endl;

}

C++: #include <iostream>
#include <string>
#include <map>
using namespace std;
map<string, int> table;
int main()
{
	string word, frequent, longest;
	size_t N = 0;
	while (cin >> word)
	{
		table[word]++;
		if (table[word] > N)frequest = word;
		if (word.size() > longest.size())longest = word;
	}
	cout >> frequent >> longest >> endl;
}

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

int main() {
	string in;
	vector <string>s;
	vector <int>a;
	int maxH = 0, maxL = 0;
	while (cin >> in) {
		s.push_back(in);
		a.push_back(0);
	}
	for (int i = 0; i < s.size(); i++) {
		if (a[i] == 0) {
			for (int j = i + 1; j < s.size(); j++) {
				if (s[i] == s[j])
					a[j] = ++a[i];
			}
			if (maxH < a[i])
				maxH = a[i];
		}
		if (maxL < s[i].length())
			maxL = s[i].length();
	}
	for (int i = 0; i < s.size(); i++) {
		if (maxH == a[i]) {
			cout << s[i] << " ";
			break;
		}
	}
	for (int i = 0; i < s.size(); i++) {
		if (maxL == s[i].length())
			cout << s[i]<<endl;
	}
	return 0;
}

C++: #include <algorithm>
#include <cctype>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <functional>
#include <queue>
#include <string>
#include <map>
#include <vector>

using namespace std;

int main() {
  string s, f, l("");
  map<string, int> ws;
  getline(cin, s);
  s.push_back(' ');
  int b = -1;
  for (int i = 0; i < s.length(); i++) {
    if (b == -1 && s[i] != ' ')
      b = i;
    if (b >= 0 && s[i] == ' ') {
      ws[s.substr(b, i-b)]++;
      b = -1;
    }
  }
  int maxc = 0;
  for (map<string, int>::iterator it = ws.begin(); it != ws.end(); ++it) {
    if (it->first.length() > l.length())
      l = it->first;
    if (it->second > maxc) {
      f = it->first;
      maxc = it->second;
    }
  }
  cout << f << ' ' << l << endl;
  return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
	string str[1001],mx("a");
	int i=0,cnt[1001]={0},ms;
	while(cin >> str[i]){
		if(mx.size()<str[i].size())mx=str[i];	
	
		for(int j=0;j<i;j++){
			if(str[i]==str[j]){
				cnt[j]++;
			}
		}
		i++;
	}
	for(int j=0;j<i;j++){
		for(int k=0;k<i;k++){
			if(cnt[j]<cnt[k])ms=k;
		}
	}
	cout << str[ms] << " " <<mx << endl;
return 0;
}