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 <utility>
#include <iostream>
#include <unordered_map>



int main()
{
    using map_type = std::unordered_map< std::string, int > ;
    map_type map ;

    std::string longest_word ;

    std::string word ;
    while ( std::cin >> word )
    {
        ++map[word] ;
        if ( longest_word.size() < word.size() )
        {
            longest_word = word ;
        }
    }

    std::pair< map_type::key_type, map_type::mapped_type> most_frequent_word ;
    for ( auto && elem : map )
    {
        if ( most_frequent_word.second < elem.second )
        {
            most_frequent_word = elem ;
            
        }
    }

    std::cout << most_frequent_word.first << ' ' << longest_word << '\n' ;
    
}

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

int main() {
	map<string,int> strtable;
	map<string,int>::iterator mnum;
	string word;
	string maxlw;

	while(cin>>word){
		if(strtable.find(word) == strtable.end())strtable[word]=1;
		else strtable[word]++;
		if(word.length() > maxlw.length())maxlw = word;
	}
	
	mnum = max_element(strtable.begin(),strtable.end(),[](pair<string,int> a,pair<string,int> b){return a.second < b.second;} );
	
	cout<<mnum->first<<" "<<maxlw<<endl;
	
	return 0;
}

C++: import java.io.*;
public class aoj0029 {
   public static void main(String[] args) throws IOException{
	   BufferedReader buf = new BufferedReader(new InputStreamReader(System.in));
	   String s;
	   String tmp = "";
	   String sizetmp = "";
	   int cmax = -1;
	   int max = -1;
	   int cnt;
	   s = buf.readLine();
	   String[] data = s.split(" ");
	   for(int i=0;i<data.length;i++){
		   cnt = 1;
		   if(cmax < data[i].length()-1){
			   cmax = data[i].length()-1;
			   sizetmp = data[i];
		   }
		   for(int j=0;j<data.length;j++){
			   if(data[i].equals(data[j]) && i != j) cnt++;
		   }
		   if(max < cnt){
			   tmp = data[i];
			   max = cnt;
		   }
	   }
	   System.out.println(tmp + " " + sizetmp);
   }
}

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

int main(void){
  map<string,int> mp;
  int len = 0;
  string s,t;
  while(cin >> s){
    ++mp[s];
    if(len < (int)s.size()){
      len = s.size();
      t = s;
    }
  }
  string u;
  for(map<string,int>::iterator it = mp.begin() ; it != mp.end() ; ++it){
    u = it->first;
  }
  cout << u << " " << t << endl;
  return 0;
}

C++: //#define scanf_s scanf
//#define gets_s gets
#include <stdio.h>
#include <string>
#include <iostream>
#include <math.h>
using namespace std;
#define MAX 1001
#define MIN -100001
#define _MAX 100
int main(void)
{
	int x, max = 0, max_n = 0, cou = 0, word_num[MAX / 2] = { 0 }, m_i, m_j;
	string word[MAX / 2];
	char str[MAX];
	gets_s(str, MAX);
	for (int i = 0; str[i] != '\0'; ++i) {
		for (int j = 0; str[i] != ' '; ++j, ++i) {
			word[cou][j] = str[i];
		}
		++cou;
	}
	for (int i = 0; i < cou; ++i) {
		if (word[i].size > max) {
			max = word[i].size; m_i = i;
		}
		for (int j = 0; j < i; ++j) {
			if (word[i] == word[j]) {
				++word_num[j];
				if (word_num[j] > max_n) { max_n = word_num[j]; m_j = j; }
			}
		}
	}
	cout << word[m_i] << " " << word[m_j] << "\n";
}

C++: #include<cstdio>
#include<cstring>

int main(){
	char word[380][33];
	int count[380] = {};
	int now = 0;
	int max = 0;
	int a, b = 0;
	char s[33];
	while(scanf("%s", &s) + 1){
		int t = 0;
		while(s[t]){
			if('A' <= s[t] && s[t] <= 'Z'){
				s[t] = s[t] + 'a' - 'A';
			}
			t++;
		}
		bool flug = true;
		for(int i = 0; i < now; i++){
			if(strstr(word[i], s)){
				count[i]++;
				if(count[i] > max){
					max = count[i];
					a = i;
				}
				flug = false;
				break;
			}
		}
		if(flug){
			strcpy(word[now], s);
			if(strlen(word[b]) < strlen(s)){
				b = now;
			}
			now++;
		}
	}
	printf("%s %s\n", word[a], word[b]);
	return 0;
}

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

int main()
{
	char get[1000][40] ;
	char mode[40] ;
	char longest[40] ;

	int count = 0 ;
	int lest = -1 ;
	
	int tmp = 0 ;

	int most = 0 ;
	int mnum = -1 ;

	int i = 0 ;

	while( cin >> get[i] )
	{
		if( count < strlen(get[i]) )
		{
			count = strlen(get[i]) ;
			lest = i ;
		}

		for( int j = (i-1) ; j >= 0 ;  j -- )
		{
			if( strcmp( get[i], get[j] ) == 0 )
			{
				tmp ++ ;
			}
		}
		tmp = 0 ;

		if( most < tmp )
		{
			most = tmp ;
			mnum = i ;
		}

		i ++ ;
	}

	cout << get[mnum] << " " << get[lest] ;

	return 0 ;
}

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

int main(){
    map<string, int> word;
    string s;
    string outen;
    string outlen;
    int maxen;
    int maxlen;
    maxen = 0;
    maxlen = 0;
    while(cin >> s){
        if(word.find(s) != word.end()){
            word[s]++;
            if(word[s] > maxen){
                outen = s;
            }
        }else{
            word.insert(map<string, int>::value_type(s, 1));
            if(s.size() > maxlen){
                outlen = s;
            }
            if(word[s] > maxen){
                outen = s;
            }
        }
    }
    cout << outen << " " << outlen << endl;
    return 0;
}

C++: #include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<cassert>
using namespace std;
int inf = 1000000000;

int main(void) {

  string s;
  getline(cin, s);
  s += ' ';
  string tmp = "";
  string maxword = "";
  vector< pair<string, int> > p;
  for(int i=0; i<s.size(); i++){
    if( s[i] != ' ' ) tmp += s[i];
    else{
      if( maxword.size() < tmp.size() ) maxword = tmp;
      bool f = false;
      for(int j=0; j<p.size(); j++){
        if( p[j].first == tmp ){
          f = true;
          p[j].second++;
        }
      }
      if( !f ) p.push_back( make_pair(tmp, 1) );
      tmp = "";
    }
  }
  int mx = 0;
  string med;
  for(int i=0; i<p.size(); i++){
    if( mx < p[i].second ){
      mx = p[i].second;
      med = p[i].first;
    }
  }
  cout << med << " " << maxword << endl;

  return 0;
}


// EOF

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

using namespace std;

int main(){
  string s;
  string max;
  int maxsize  = 0;
  map <string, int> m;
  while(cin >> s)
  	m[s]++;
   if(s.size() > maxsize){
       max = s;
       maxsize = s.size();
   }

   map<string,int>::iterator it = m.begin();
   string freq;
   int maxfreq = 0;
   for(it; it != m.end();it++){
   	 int k = (*it).second;
   	  if(k > maxfreq ){
   	  	maxfreq = k;
   	  	freq = (*it).first;
   	  }
   }
   cout << freq << " " << max << endl;
}