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<stdio.h>
#include<string.h>

int main(){
	char maxc[33],maxl[33],ss[1001][33];
	int a,b,cmax,i,c,count;
	
	memset(ss,'\0',sizeof(ss));
	i=0;
	while(0<=scanf(" %s ",ss[i])){
		++i;
	}
	maxl[0]=maxc[0]='\0';
	cmax=0;
	a=i;
	for(b=0;b<=i;++b){
		if(strlen(maxl)<strlen(ss[b])){
			strcpy(maxl,ss[b]);
		}
		count=0;
		for(c=0;c<=i;c++){
			if(!strcmp(ss[b],ss[c]))++count;
		}
		if(count>cmax){
			cmax=count;
			strcpy(maxc,ss[b]);
		}
	}
	printf("%s %s\n",maxc,maxl);
	return 0;
}

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

using namespace std;

string s[1001];
int count[1001];

int main(void){
	char temp[1001];
	
	while(gets(temp) != 0){
		int temp_n = strlen(temp);
		int c = 0;
		int max_h = 0;
		int max_H = 0;
		int max_l = 0;
		int max_L = 0;
		
		for(int i = 0; i < 1001; i++){
			s[i] = "";
			count[i] = 0;
		}
		
		for(int i = 0; i < temp_n; i++){
			for(int j = i; ; j++){
				if(temp[j] == ' '){
					i=j;
					c++;
					break;
				}else if(temp[j] == '\0'){
					i=j;
					c++;
					break;
				}
				s[c] += temp[j];
			}
		}
		
		for(int i = 0; i < c; i++){
			for(int j = 0; j < c; j++){
				if(i == j)continue;
				if(s[i] == s[j])count[i]++;
			}
		}
		
		for(int i = 0 ; i < c; i++){
			if(s[i].size() > max_L)max_l = i;
			if(count[i] > max_H)max_h = i;
		}
		
		printf("%s %s\n", s[max_h].c_str(), s[max_l].c_str() );
	}
	return 0;
}

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

#define TEXT_MAXNUM 1000
#define WORD_MAXNUM 33

typedef struct tagStrings
{
	char	str[WORD_MAXNUM];
	int		length;
	int		count;
} Strings_t;

void main( void )
{
	char		inputString[TEXT_MAXNUM] = "";
	
	Strings_t	words[TEXT_MAXNUM / 2] = {{0}};	// words in text
	char		tmpStr[WORD_MAXNUM] = {0};		// work
	int			wordNum = 0;					// record word num
	int			readIdx = 0;					// text read pointer
	int			readWordCount = 0;				// readding word length
	
	while( readIdx < TEXT_MAXNUM )
	{
		if( inputString[readIdx] == '\0' )
		{	// end text
			// @todo
			break;
		}
		tmpStr[readWordCount] = inputString[readIdx];	// read char
		
		if( tmpStr[readWordCount] == ' ' )
		{	// space -> partition word
			if( readWordCount )
			{
				tmpStr[readWordCount] = '\0';
				// word grep & record
				int i=0;
				for( i; i < wordNum; i++)
				{
					if( strcmp(words[i].str, tmpStr) == 0 )
					{	// recorded
						words[i].count++;
						break;
					}
				}
				if( i >= wordNum )
				{	// new record
					strcpy(words[wordNum].str, tmpStr);
					words[wordNum].length = readWordCount;
					words[wordNum].count = 1;
					wordNum++;		// record num +1
				}
				
				readWordCount = 0;
			}
			// not readding word -> next read
			readIdx++;
		}
		else
		{
			readWordCount++;
			readIdx++;
		}
	}
	
	// most, max index
	int maxLenIdx = 0;
	int mostIdx = 0;
	
	for( int i = 0; i < wordNum; i++)
	{
		int maxMost = 0;
		int maxLen  = 0;
		
		if( maxMost < words[i].count )
		{
			maxMost = words[i].count;
			mostIdx = i;
		}
		if( maxLen < words[i].length )
		{
			maxLen = words[i].length;
			maxLenIdx = i;
		}
	}
	
	// dump
	printf("%s %s\n", words[mostIdx].str, words[maxLenIdx].str);
	
	return;
}

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;
            }
        }
    }
    cout << outen << " " << outlen << endl;
    return 0;
}

C++: #include <utility>
#include <iostream>
#include <unordered_map>



int main()
{
    // using map_type = std::unordered_map< std::string, int > ;
    typedef std::unordered_map< std::string, int > map_type ; 
    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 <string>
#include <vector>
using namespace std;
typedef pair<string, int> PAIR;

int main(){
	vector<PAIR> vec;
	vector<PAIR>::iterator ite;
	vector<PAIR>::iterator max;
	string st, siz;
	while(cin >> st){
		if(st == "0") break;
		ite = vec.begin();
		if(vec.empty()){
			vec.push_back(PAIR(st, 1));
			max = vec.begin();
			siz = st;
		}else{
			while(1){
				if((*ite).first == st){
					(*ite).second++;
					if((*max).second < (*ite).second) max = ite;
					break;
				}
				ite++;
				if(ite == vec.end()){
					vec.push_back(PAIR(st, 1));
					if(siz.size() < st.size()) siz = st;
					break;
				}
			}
		}

		cout << (*max).first << " " << siz << endl;

	}
	return 0;
}

C++: #include <iostream>
#include <string>
#include <map>
using namespace std;
int main(){
    string str,s,mls,mcs,input[32];
    map <string,int> dic;
    int n,c,a,ml,mc;
    getline(cin,str)
        c = a = mc = ml = 0;
        str += ' ';
        while(str.length()){
            n = str.find(' ');
            s = str[c];
            ++c;
            for(;c < n;++c){
                s += str[c];
            }
            str.erase(0,n+1);
            c = 0;
            input[a] = s;
            ++a;
            ++dic[s];
            if(s.length() > ml) {
                ml = s.length();
                mls = s;
            }
        }
        for(int i = 0;i < a;++i){
            if(mc < dic[input[i]]){
                mc = dic[input[i]];
                mcs = input[i];
            }
       
        cout << mcs << " " << mls << endl;
    }
    return 0;
}

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++: #include<iostream>
#include<string>
#include<map>
using namespace std;
map<string,int> table;

#if 0
所用時間:

感想:

#endif

void solve(){
  // typedef set<int> size_t;
  string word, frequent, longest;
  int N = 0;
  while(cin >> word){
    table[word] += 1;
    if(table[word] > N){
      frequent = word; N = table[word];
    }
    if(word.size() > longest.size()){
       longest = word;
    }
  }
  cout << frequent << " " << longest << endl;
}

int main(){
  solve();
}