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 <string.h>
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>
#include <utility>

#define ll (long lon
#define REP(i,n) for(int i = 0;i<(int)n;i++)
#define FOR(i,a,b) for(int i = (a);i < (b);i++)
#define RFOR(i,a,b) for(int i = (a);i>(b);i--)
#define INT_MIN_A -999999

using namespace std;

int main (void){
    
    char str[1100];
    gets(str);
    char tango[1000][33];
    int i = 0,j = 0,k = 0,l = 0, temp = 0,m = 0;
    int max_l = INT_MIN_A;
    int max_numer = 0;
    int yokuderu = 0;
    int yokuderu_temp = 0;
    int yokuderu_number = 0;
    while(str[i++] != '\0')
    {
        if(str[i-1] == ' ')
        {
            if((i-1)-temp>max_l)
            {
                max_l = (i-1) -temp;
                max_numer = j;
            }
            while(temp<i-1)
                tango[j][l++] = str[temp++];
            temp = i;
            j++;
            l = 0;
        }
    }
    
 
        if((i-1)-temp>max_l)
        {
            max_l = (i-1) -temp;
            max_numer = j;
        }
        while(temp<i-1)
            tango[j][l++] = str[temp++];
        temp = i;
        j++;
        l = 0;
    /*???????????§??????????????????*/
    //cout <<"number is " << j << endl;
    
    for(int m = 0; m < j;m++)
    {
        for(int k = 0; k<j;k++)
        {
            if(m != k)
            {
                if(strcmp(tango[m], tango[k]) == 0)
                {
                    yokuderu_temp++;
                }
            }
        }
        if(yokuderu_temp >= yokuderu)
        {
            yokuderu = yokuderu_temp;
            yokuderu_number = m;
        }
        yokuderu_temp = 0;
    }
    REP(i,32)
    cout << tango[yokuderu_number][i];
    cout << " ";
    while(tango[max_numer][m++] != '\0')
        cout << tango[max_numer][m-1];
    m = 0;
        cout << endl;
    
    
    return 0;
}

C++: #include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <deque>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <complex>
#include <functional>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cctype>

using namespace std;

#define dump(n) cout<<"# "<<#n<<"="<<(n)<<endl
#define debug(n) cout<<__FILE__<<","<<__LINE__<<": #"<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)
#define iter(c) __typeof((c).begin())
#define tr(c,i) for(iter(c) i=(c).begin();i!=(c).end();i++)
#define allof(c) (c).begin(),(c).end()
#define mp make_pair

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;

int main()
{
	map<string,int> m;
	for(string s;cin>>s;m[s]++)
		;
	
	string freq="",longest="";
	tr(m,i){
		if(m[freq]<i->second)
			freq=i->first;
		if(longest.size()<i->first.size())
			longest=i->first;
	}
	cout<<freq<<" "<<longest<<endl;
	
	return 0;
}

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

#define foreach_it(type,it,c) for(type::iterator it=c.begin(),c_end=c.end();it!=c_end;++it)
typedef map<string, int> MAPSI;

int main() {

	string in,s;
	long long int  max_length = 0;
	string max_s;
	map<string,int> ms;
	while (getline(cin,s,' ')) {
		// getline???????????????????°?????????????????????????????????????
		if (s[s.size() - 1] == '\n'|| s[s.size() - 1] == '\r') {
			s.erase(s.length() - 1);
		}
		// ????????°???????????????
		if (max_length < s.length()) {
			max_s = s;
			max_length = s.length();
		}
		// ???????????????????????????
		if (ms.find(s)!=ms.end()) {
			ms[s]++;
		}
		else {
			ms.insert(make_pair(s, 1));
		}
	}

	// ??????
	string max_hindo_s;
	int max_hindo = 0;
	foreach_it(MAPSI, it, ms) {
		if (max_hindo < it->second) {
			max_hindo_s = it->first;
			max_hindo = it->second;
		}
	}
	cout << max_hindo_s << " " << max_s << endl;
	return 0;
}

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

int main()
{
	string in,lon = "",mor = "";
	map<string,int> aa;
	while(cin >> in)
	{
		if(in.size() > lon.size())
			lon = in;
		aa[in]++;
		if(aa[mor] < aa[in])
			mor = in;
	}
	cout << mor << " " << lon << endl;
}

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

using namespace std;

int main( ){
    string l;
    int t=0;
	string max="";
	map<string,int> str;
	string s;
	while(cin>>s){
            if(s.length()>max.length())max=s;
            str[s]++;
            if(str[s]>t){
                t=str[s];
                l=s;
            }
	}
	cout<<l<<" "<<max<<endl;
	return 0;
}

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

int main()
{
	char text[32];
	string str[1001];
	map<string, int> test;
	int i = 0, len = 0, max = 0, now;
	
	while(scanf("%s", text) != EOF){
		str[i] = text;
		
		test[str[i]]++;
		
		now = str[i].size();
		if(max < now){
			len = i;
			max = str[len].size();
		}
		i++;
	}
	now = 0;
	for(i = 0; i < 1001; i++){
		if(test[str[i]] > test[str[now]]){
			now = i;
		}
	}
	
	printf("%s %s\n", str[now].c_str(), str[len].c_str());
	
	
	return(0);
}

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

int main(){
    map<string, int> set;
    string str;
    int mode = 0;
    int max_length = 0;

    while(cin >> str){
        if(set.find(str) != set.end()){
            set[str]++;
        }else{
            set.insert(pair<string, int>(str, 1));
        }
    }

    map<string, int>::iterator it = set.begin();
    map<string, int>::iterator mode_cursor = set.begin();
    map<string, int>::iterator max_cursor = set.begin();

    while(it != set.end()){
        if(mode < it->second){
            mode = it->second;
            mode_cursor = it;
        }
        if(max_length < it->first.size()){
            max_length = it->first.size();
            max_cursor = it;
        }
        it++;
    }

    cout << mode_cursor->first << " " << max_cursor->first << endl;

    return 0;
}

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

map < string, int > m;

int main(){

  string s;
  int lenmax = 0;
  int nummax = 0;
  string tmp = "";
  string anslen,ansnum;

  getline(cin, s);

  for(int i=0;i<=s.size();i++){
    if(s[i] == ' ' || s[i] == '\0'){
      m[tmp]++;

      if(tmp.size() > lenmax){
	anslen = tmp;
	lenmax = tmp.size();
      }

      if(m[tmp] > nummax){
	ansnum = tmp;
	nummax = m[tmp];
      }

      i++;
      tmp = "";
    }
    
    tmp += s[i];
  }

  cout << ansnum << " " << anslen << endl;
}

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

int main(void){
	int maxC=0,maxLen=0;
	string s,maxS1,maxS2;
	map<string,int> m;

	while(cin>>s){
		m[s]++;
		if(maxC < m[s]){
			maxC = m[s];
			maxS1 = s;
		}
		if(maxLen < s.length()){
			maxLen = s.length();
			maxS2 = s;
		}
	}

	cout<<maxS1<<" "<<maxS2<<endl;

	return 0;
}