Go: package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Scan()
	l := sc.Text()
	words := strings.Split(l, " ")

	frequency := map[string]int{}
	long := map[string]int{}
	var maxFrequency, longest int
	var frequentWord, longestWord string
	for _, w := range words {
		frequency[w]++
		long[w] = len(w)
		if frequency[w] > maxFrequency {
			maxFrequency = frequency[w]
			frequentWord = w
		}
		if len(w) > longest {
			longest = long[w]
			longestWord = w
		}
	}

	fmt.Println(frequentWord + " " + longestWord)
}

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

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