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 <iostream>
#include <map>
#include <algorithm>
int main()
{
	typedef std::map<std::string, int>	simap;
	typedef std::pair<std::string, int> 	sipair;
	simap 		words; 
	std::string 	input;

	while (std::cin >> input) 
		++words[input]; 
	
	auto result  = std::minmax_element(words.begin(), words.end(), [](const sipair & a, const sipair & b) { return a.first.length() < b.first.length(); });
	auto result2 = std::minmax_element(words.begin(), words.end(), [](const sipair & a, const sipair & b) { return a.second < b.second; });

	std::cout << result2.second->first << ' ' << result.second->first << std::endl;
}

C++: #include <bits/stdc++.h>

using namespace std;

int main() {
	int mval = 0;
	string s, buf, a, b;
	map<string, int> m;
	getline(cin, s);
	stringstream ss(s);
	while(ss >> buf) {
		m[buf] += 1;
		if(mval < m[buf]) mval = m[buf];
	}
	for(auto &v: m) {
		if(v.first.length() > b.length()) b = v.first;
		if(v.second == mval) a = v.first;
	}
	cout << a << " " << b << endl;
	return 0;
}

C++:  
 #include<iostream>
 #include<stdio.h>
 #include<string>
 #include<math.h>
 #include<iomanip>
 #include<algorithm>
 #include<string.h>
 #include<cctype>
 #include<map>
 #include<set>
 #include<vector>
 #include<sstream>
 #include<stack>
 #include<queue>
 
 using namespace std;
  
 int main()
 {
   map<string,int> mymap;
   int max=0;
   int fre=0;
   string str;
   string str_max;
   string str_fre;
   while(cin>>str)
   {
     if(str.length()>max) 
     {
       max=str.length();
       str_max=str;                     
     }             
     mymap[str]++;      
   }             
   map<string,int>::iterator  iter;  
   for(iter = mymap.begin();iter!= mymap.end(); iter++)  
   {  
     if(iter->second>fre) 
     {
       str_fre=iter->first;
       fre=iter->second;                     
     }  
   }  
   cout<<str_max<<" "<<str_fre<<endl;
   //while(1);     
   return 0;  
 }

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

void wordProcess(std::map<std::string, int> &wordCount,
	std::string &word, std::string &modeWord, std::string &maxLenWord) {
	if (wordCount.find(word) == wordCount.end()) {
		wordCount[word] = 0;
		if (word.length() > maxLenWord.length()) {
			maxLenWord = word;
		}
	}
	++wordCount[word];
	if (wordCount[word] > wordCount[modeWord]) {
		modeWord = word;
	}
}

int main() {
	std::string sentence, word, modeWord, maxLenWord;
	std::map<std::string, int> wordCount;
	std::getline(std::cin, sentence);
	for (std::string::iterator it = sentence.begin(); it != sentence.end(); ++it) {
		if (isspace(*it)) {
			if (!word.empty()) {
				wordProcess(wordCount, word, modeWord, maxLenWord);
			}
			word = "";
		} else {
			word += tolower(*it);
		}
	}
	wordProcess(wordCount, word, modeWord, maxLenWord);
	std::cout << modeWord << ' ' << maxLenWord << '\n';
	return 0;
}

C++: #include<stdio.h>
#include<string>
#include<iostream>
using namespace std;
struct ST{string str;int c;int z;};

int main(){

int i=0;
string str,sth,stl;
struct ST P[1001];
int max=0;
while(cin>>str){
P[i].str=str;P[i].c=0;P[i].z=(int)str.size();
i++;
}
for(int j=0;j<i;j++)
for(int k=i-1;k>i;k--)
if(P[k-1].str>P[k].str){
struct ST TEM=P[k-1];P[k-1]=P[k];P[k]=TEM;
}

for(int j=1;j<i;j++)
{if(P[j-1].str==P[j].str)P[j].c++;

}
max=0;
for(int j=0;j<i;j++)
{if(max<P[j].c)sth=P[j].c;}
if(P[j].z>max)stl=P[j].str;

cout<<sth<<" "<<stl<<endl;

return 0;
}

C++: #include <iostream>
#include <string>
#include <unordered_map>
using namespace std;
int main() {
  unordered_map<string,int> count;
  unordered_map<string,int> length;
  string word;
  int max1 = 0;
  int max2 = 0;
  string answer1, answer2;

  while (cin >> word) { // 入力がある限り読み込む
    count[word] += 1;
    length[word] = word.size();
    if (count[word] > max1) {
      max1 = count[word];
      answer1 = word;
    }
    if (length[word] > max2) {
      max2 = length[word];
      answer2 = word;
    }
    
  }

  cout << answer1 << " " << answer2 << endl;
 }

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

using namespace std;

map<string,int> words;

int alltoupper(char *s){
  int i,l=strlen(s);
  for(i=0;i<l;i++){
    s[i] = tolower(s[i]);
  }
  //printf("%s\n", s);
}

int main(){
  char s[32];
  int max=0;
  string my;
  int maxlength=0;
  string self;
  while(scanf(" %s", s)!=EOF){
    alltoupper(s);
    string tmp(s);
    if(words.find(tmp) != words.end()){
      words[tmp]++;
      if(words[tmp] > max) max = words[tmp],my = tmp;
    }else{
      words.insert(pair<string,int>(tmp,1));
      if(maxlength < tmp.length()) maxlength = tmp.length(),self=tmp;
    }
  }
  
  printf("%s %s\n", my.c_str(), self.c_str());
}

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

using namespace std;

int main() {
	map<string, int> letters;
	string in;
	while(cin>>in){
		if(letters.count(in) == 0) letters.insert(make_pair(in, 0));
		else letters.find(in)->second++;
	}

	int maxChar = 0;
	int maxLength = 0;
	map<string, int>::iterator it, foo, bar;
	for(it=letters.begin(); it!=letters.end(); it++){
		maxChar = max(maxChar, it->second);
		if(maxChar == it->second) foo = it;
	}
	for(it=letters.begin(); it!=letters.end(); it++){
		maxLength = max(maxLength, (int)it->first.size());
		if(maxLength == it->first.size()) bar = it;
	}

	cout<<foo->first<<" "<<bar->first<<endl;
	return 0;
}

C++: #include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <sstream>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <numeric>
#include <cmath>
#include <climits>
#include <limits>
#include <cfloat>
#include <fstream>
using namespace std;

int main()
{
//	cut here before submit 
//	freopen("testcase.es", "r", stdin);
	string str = "";

	while ( getline (cin, str ) ){

		map <string, int> freq, leng;
		if (str.find('.') != string::npos){
			str = str.erase (str.find('.'), 1);
		} // end if
		stringstream ss(str);
		string s = "";

		while (ss >> s){
			++freq[s];
			leng[s] = s.length();
		} // end while

		if (freq.size() == 2){
			cout << "The two words separated by a space." << endl;
			continue;
		} // end if		
		if (!freq.empty() && !leng.empty() ){ 
			multimap <int, string, greater<int> > rank;
			map <string, int>::iterator itf = freq.begin();
			for (; itf != freq.end(); ++itf){
				rank.insert (make_pair ((*itf).second, (*itf).first ) );
			} // end for
			multimap<int, string, greater<int> > mlen;
			map<string, int>::iterator itl = leng.begin();
			for (; itl != leng.end(); ++itl){
				mlen.insert (make_pair ((*itl).second, (*itl).first ) );
			} // end for
			multimap<int, string, greater<int> >::iterator itr = rank.begin();
			multimap<int, string, greater<int> >::iterator itm = mlen.begin();
			cout << (*itr).second << ' ' << (*itm).second << endl;
		}else{
			cout << ' ' << endl;
		} // end if
	} // end while
		
	return 0;
}