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++: /*AOJ 0029*/

#include<iostream>
#include<vector>
#include<string>

using namespace std;

int main(){

	vector<string> data;

	char str[35];

	while(cin>>str){
		data.push_back(str);
	}

	int max=0;
	int max1 = 0;
	int maxNum = 0;
	int maxNum1 = 0;
	int sum=0;

	for(int i=0;i<data.size();i++){
		sum = 0;
		for(int j=i+1;j<data.size();j++){
			if(data.at(i) == data.at(j)){
				sum++;
			}
		}
		if(max<=sum){
			max = sum;
			maxNum = i;
		}
	}

	max1 = 0;
	maxNum1 = 0;

	for(int i=0;i<data.size();i++){
		if(max1 <= data.at(i).size()){
			max1 = data.at(i).size();
			maxNum1 = i;
		}
	}



	cout<<data.at(maxNum)<<" "<<data.at(maxNum1)<<endl;

	return 0;
}

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

    if(t[s] > freq){
      freq = t[s];
      mxc = s;
    }
    if(s.size() > len){
      len = s.size();
      mxl = s;
    }
  }
  cout << mxc << " " << mxl << endl;
}

C++: #include<stdio.h>
#include<string>
#include<iostream>
#include <ctype.h>


using namespace std;
struct ST{string str;int c;int z;};

int main(){

int i=0;
string str,sth,stl;
struct ST P[1001];
int max=0;
while(cin>>str){
//	for(int j=0;j<str.size();j++)
//	str[i] = tolower( str[i] );

P[i].str=str;P[i].c=0;P[i].z=(int)str.size();
i++;
}
for(int j=0;j<i;j++)
for(int k=i-1;k>j;k--)
	if(P[k-1].str>P[k].str)
//if(P[k-1].str>P[k].str)
//if(strcmp(P[k-1].str,P[k].str)>0)
{


struct ST TEM=P[k-1];P[k-1]=P[k];P[k]=TEM;
cout<<"*";
}

for(int j=1;j<i;j++)
{if(P[j-1].str==P[j].str)P[j].c++;

}
max=0;
for(int j=0;j<i;j++)
{if(max<P[j].c){max=P[j].c;sth=P[j].str;}}
max=0;
for(int j=0;j<i;j++)
	if(P[j].z>max){max=P[j].z;stl=P[j].str;}

cout<<sth<<" "<<stl<<endl;

for(int j=0;j<i;j++)
	cout<<P[j].str<<P[j].z<<endl;

return 0;
}

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

int main(){
  string str[1000];
  int appear[1000];
  int i, j, n=0;
  int maxlen, maxleni;
  int maxappear, maxappeari;

  while(cin>>string[n]){
    for(i=0; i<string[n].size(); i++) string[n][i]=tolower(string[n][i]);
    n++;
  }
  maxlen=0;
  for(i=0; i<n; i++){
    if(maxlen<string[i].size()){
      maxlen=string[i].size();
      maxleni=i;
    }
  }
  for(i=0; i<n; i++) appear[i]=0;
  for(i=0; i<n; i++){
    if(string[i].empty()) continue;
    for(j=i+1; j<n; j++)
      if(string[i]==string[j]){
        appear[i]++;
        string[j][0]='\0';
      }
  }
  maxappear=0;
  for(i=0; i<n; i++){
    if(maxappear<appear[i]){
      maxappear=appear[i];
      maxappeari=i;
    }
  }
  cout<<string[maxappeari]<<" "<<string[maxlen]<<endl;

  return 0;
}

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

using namespace std;

int main(){
	string in[10000];
	int max=0;
	string ml_str;
	int tmp;
	string ans;
	int i=0;
	for(i=0;cin>>in[i];i++){
		if(in[i].size()>max){
			max=in[i].size();
			ml_str=in[i];
		}
	}
	sort(in,in+i);
	tmp=1;
	max=0;
	for(int j=1;j<i;j++){
	cout<<in[j]<<" ";
		if(in[j]==in[j-1]){
			tmp++;
		}else{
			if(max<tmp){
				max=tmp;
				ans=in[j-1];
				tmp=1;
			}
		}
	}
	cout<<endl<<ans<<" "<<ml_str<<endl;
}

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

using namespace std;

int main(void){
  vector<string> s;
  vector<int> cnt;
  string ss,str;
  getline(cin,str);
  string longest="";
  string max;
  int maxv=-1;
  str+=" ";
  for(int i = 0; i < str.size() ; i ++  ){
    if(str[i] == ' '){
      bool used=true;
      
      for(int j = 0 ; j < s.size() ; j ++){
	//second time
	if(s[j] == ss){
	  cnt[j]++;
	  //cout<<ss<<cnt[j]<<maxv<<endl;
	   
	  if(maxv<cnt[j]){
	    longest=ss;
	    maxv=cnt[j];
	  }
	  
	  ss="";
	  used=false;
	}
      }
      if(used){
	//first time
	s.push_back(ss);
	cnt.push_back(1);
	//cout<<ss<<cnt[cnt.size()-1]<<endl;
	/*
	if(s.size() == 1){
	  longest=ss;
	  max=ss;
	  maxv=ss.size();
	}
	//*/
	if(ss.size()>max.size())max=ss;
	ss="";
      }
      
    }else{
      ss+=str[i];
    }
    // cout<<str[i]<<endl;
  }
  cout<<longest<<" ";
  cout<<max<<endl;
  /*
  for(int i = 0 ; i < s.size() ; i ++){
    cout<<s[i]<<endl;;
  }
  cout<<endl;
  //*/
}

C++: #include <iostream>
#include <cstdio>
#include <cstdlib>
#include <time.h>
#include <math.h>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <sstream>
#include <string>
#include <bitset>
using namespace std;
#define FOR(I,F,N) for(int I = F; I < (int)(N); I++)
#define rep(i, n) FOR(i, 0, n)
#define FIN(V) cout<<V<<endl
#define pb push_back
#define INF (1 << 30)
typedef pair<int, int> P;
typedef long long ll;
typedef priority_queue<int> pq;
int StrToInt(string);
string IntToStr(int);
int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, 1, -1};

int main(void){
	string s, l, m;
	map<string, int> map;
	int mxl = 0;
	int tmp = 0;
	while(cin >> s){
		map[s]++;
		if(map[s] > tmp){
			m = s;
			tmp = map[s];
		}
		int tmp_s = s.size();
		if(s.size() > mxl){
			mxl = max(mxl,tmp_s);
			l = s;
		}
	}
	cout << m << " " << l << endl;
	return 0;
}

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

int main() {
	string tmp;
	string longest;
	int mlength=0;
	map<string,int> m;
	while(cin >> tmp)
	{
		m[tmp]++;
		if (tmp.size()>mlength)
		{
			mlength=tmp.size();
			longest=tmp;
		}
	}
	string frequent;
	int mfreq=0;
	for (map<string,int>::iterator it=m.begin(); it!=m.end(); ++it)
	{
		if (it->second > mfreq)
		{
			mfreq=it->second;
			frequent=it->first;
		}
	}
	cout << frequent << " " << longest << endl;
	return 0;
}

C++: #include <iostream>
#include <string>
#include <unordered_map>
#define int long long
using namespace std;
int n;
unordered_map<string,int> h_m;
signed main(){
    string word;
    int m_len = 0, m_count = 0;
    string w_len = "", w_count = "";
    while(cin >> word){
        h_m[word] += 1;
        if(m_len < word.size()){
            m_len = word.size();
            w_len = word;
        }
        if(m_count < h_m[word]){
            m_count = h_m[word];
            w_count = word;
        }
    }
    cout << w_count << " " << w_len << endl;
}

C++: #include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>

using namespace std;

class LongerString
{
public:
	bool operator () ( const string &a, const string &b ) const
	{
		return a.length() < b.length();
	}
};

int main()
{
	string word;
	map<string,int> wordsCount;
	vector<string> words;

	while ( cin >> word )
	{
		wordsCount[ word ]++;
		words.push_back( word );
	}

	int max = 0;
	for ( map<string,int>::iterator it = wordsCount.begin(); it != wordsCount.end(); it++ )
	{
		if ( max < (*it).second )
		{
			max = (*it).second;
		}
	}

	for ( map<string,int>::iterator it = wordsCount.begin(); it != wordsCount.end(); it++ )
	{
		if ( max == (*it).second )
		{
			cout << (*it).first << ' ';
		}
	}

	sort( words.begin(), words.end(), LongerString() );

	cout << *words.rbegin() << endl;

	return 0;
}