Go: package main

import (
	"bufio"
	"os"
	"strings"
	"fmt"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	words := strings.Split(scanner.Text(), " ")
	wordMap := make(map[string]int)
	for _, v := range words {
		wordMap[v]++
	}
	key := ""
	value := -1
	l := -1
	word := ""
	for k, v := range wordMap {
		// fmt.Println(k, v)
		if value < v {
			key = k
			value = v
		}
		if l < len(k) {
			l = len(k)
			word = k
		}
	}

	fmt.Println(key, word)
	// fmt.Println(wordMap)
}

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();
}

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

int main() {
  string str;
  vector<string> v;
  vector<string>::iterator it_old;
  int l_max = 0;
  int c_max = 0;
  string l_str;
  string c_str;
  int count = 0;

  while (cin >> str) v.push_back(str);
  sort(v.begin(), v.end());
  it_old = v.begin();
  for (vector<string>::iterator it = v.begin(); it != v.end(); it++) {
    if (it->size() > l_max) {
      l_max = it->size();
      l_str = *it;
    }
    if (it != v.begin() && *it_old == *it) {
      count++;
      if (count > c_max) {
        c_max = count;
        c_str = *it;
      }
    }
    else {
      count = 0;
      it_old = it;
    }
  }
  cout << c_str << " " << l_str << endl;
}

C++: #define _USE_MATH_DEFINES
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>

typedef long long ll;
using namespace std;

typedef pair<int,int> P;

map<string,int> freq;

int main()
{
	char buf[64];
	while(~scanf("%s",buf)){
		string tmp = buf;
		freq[tmp]++;
	}

	int msize=0;
	string msize_str;
	int mfreq=0;
	string mfreq_str;
	for(map<string,int>::iterator it = freq.begin(); it != freq.end(); it++){
		if(msize < it->first.size()){
			msize_str = it->first;
			msize = it->first.size();
		}

		if(mfreq < it->second){
			mfreq_str = it->first;
			mfreq = it->second;
		}	
	}

	cout << mfreq_str << " " << msize_str << endl;
}