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 <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>

using namespace std;

class LongerString
{
public:
	bool operator () ( const string &a, const string &b ) const
	{
		return a.length() < b.length();
	}
};

int main()
{
	string word;
	map<string,int> wordsCount;
	vector<string> words;

	while ( cin >> word )
	{
		wordsCount[ word ]++;
		words.push_back( word );
	}

	int max = 0;
	for ( map<string,int>::iterator it = wordsCount.begin(); it != wordsCount.end(); it++ )
	{
		if ( max < (*it).second )
		{
			max = (*it).second;
		}
	}

	for ( map<string,int>::iterator it = wordsCount.begin(); it != wordsCount.end(); it++ )
	{
		if ( max == (*it).second )
		{
			cout << (*it).first << ' ';
		}
	}

	sort( words.begin(), words.end(), LongerString() );

	cout << *words.rbegin() << endl;

	return 0;
}

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