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 <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit atof atoi 
#include <cstdio>		// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>		// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>		// require srand
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

int main()
{
//	cut here before submit 
//	freopen ("testcase.ES", "r", stdin );
	string str = "";
	map<string, int> words; words.clear();
	int max_len = 0;
	int max_freq = 0;
	while (getline (cin, str ) ){

		int n = str.length();
		rep (i, n ){
			if (isalpha (str[i] ) )
				str[i] = tolower(str[i] );
		} // end rep

		string s = "";
		stringstream ss (str );
		while (ss >> s ){
			max_len = max (max_len, (int)s.length() );
			words[s]++;
			max_freq = max (max_freq, words[s] );
		} // end while
	} // end while
	map<string,int>::iterator it = words.begin();
	string res_f = "", res_l = "";
	for (; it != words.end(); it++ ){
		string w = (*it).first;
		int cnt = (*it).second;
		if (cnt == max_freq ){
			res_f = w;
		} // end if
		if (w.length() == max_len ){
			res_l = w;
		} // end if
	} // end for
	cout << res_f << ' ' << res_l << endl;

	return 0;
}

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

map <string, int> dic;

string lowerword(string word){
    for (int i=0; i<(int)word.size(); i++)
        word[i] = tolower(word[i]);
    return word;
}

int main(void){
	string s;

	while (cin>>s) dic[lowerword(s)]++;

	int l=0, m=0, tmp;
	string w1, w2;
	for (auto &x: dic){
		tmp = x.second;
		if (tmp>m){
			m = tmp;
			w1 = x.first;
		}
		tmp = x.first.size();
		if (tmp>l){
			l = tmp;
			w2 = x.first;
		}
	}
	cout<<w1<<" "<<w2<<endl;
	return 0;
}

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

int main(void){
  vector<string> str;
  vector<int> cnt;
  string buf, maxstr;
  int max, ans, i;

  while(cin >> buf, buf.length() != 0){
    bool f = true;

    if(max < buf.length()){
      max = buf.length();
      maxstr.append(buf);
    }
      
    for(i = 0; i < str.size(); i++){
      if(str[i] == buf){
	f = false;
	break;
      }
    }
    if(f){
      str.push_back(buf);
      cnt.push_back(1);
    }
    else{
      cnt[i]++;
    }
  }

  max = 0;
  for(i = 0; i < cnt.size(); i++){
    if(cnt[i] > max){
      max = cnt[i];
      ans = i;
    }
  }

  cout << str[i] << ' ' << maxstr << endl;

  return 0;
}

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

C++: #include<iostream>
#include<algorithm>
#include<map>
using namespace std;
string str,ans="",ans2="";
map < string,int > tab;
int main(){
  while(cin>>str){
    if(str.size()>ans2.size())ans2=str;
    tab[str]++;
    if(tab[ans]<tab[str])ans=str;
  }
  cout<<ans<<' '<<ans2<<endl;
  return 0;
}

C++: a=[],m=l=0,n=c='';require("fs").readFileSync("/dev/stdin","utf8").trim().split(' ').map(function(i){a[i]?++a[i]>m?m=a[n=i]:0:a[i]=1;(t=i.length)>l?(c=i,l=t):0});console.log(n+' '+c)

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)
        {
            N=table[word];
            frequent=word;
        }
        if(word.size()>longest.size())
          longest=word;
    }
    cout << frequent << " " << longest <<endl;
}

C++: #include<iostream>
#include<string>
#include<map>
using namespace std;
int main(){
  map<string,int> map;
  string s, mxc, mxl;
  int freq,len;
  while(cin >> s){
    //???????°??????§???????????????????????°
    if(map.find(s) == map.end()){
      map[s] = 1;
    }
    //???????????§??????????????°
    else{
      map[s]++;
    }

    //???????????°?????????Max????¶??????????
    if(map[s] > freq){
      freq = map[s];
      mxc = s;
    }
    //??????????????????Max????¶??????????
    if(s.size() > len){
      len = s.size();
      mxl = s;
    }

  }
  cout << mxc << " " << mxl << endl;
}

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

using namespace std;

int main(){
	string s;
	map<string, int> counter;
	string maxnum;
	string maxlen;
	while(cin >> s){
		int c = ++counter[s];
		if(c > counter[maxnum]){ maxnum = s; }
		if(s.size() > maxlen.size()){ maxlen = s; }
	}
	cout << maxnum << " " << maxlen << endl;
	return 0;
}

C++: //
//  main.cpp
//  kazane
//
//  Created by h3036136 on 2017/07/27.
//  Copyright ?? 2017??´ h3036136. All rights reserved.
#include <iostream>
#include <string>
using namespace std;
int main(){
    long saidai=0;
    int a=0,cnt=0,num=0,max=0,t;
    string str,tango[1000]={""},answer,ans;
    getline(cin,str);
    for(int i=0;i<str.size();i++){
        if(str[i]==' '){
            for(int j=a;j<i;j++){
                tango[cnt]+=str[j];
            }
            cnt=cnt+1;
            a=i+1;
        }
    }
    for(int p=a;p<str.size();p++){
        tango[cnt]+=str[p];
    }
    
    
    
    for(int k=0;k<=cnt;k++){
        if(saidai<tango[k].size()){
            saidai=tango[k].size();
            ans=tango[k];
        }
    }
    
    for(int s=0;s<cnt;s++){
        num=1;
        for(t=s+1;t<=cnt;t++){
            if(tango[s]==tango[t]){
                num=num+1;
            }
        }
        if(max<num){
            max=num;
            answer=tango[s];
        }
    }
    cout<<answer<<" "<<ans<<endl;
    return 0;
}