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 <iostream>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;

int main() {
	string tmp;
	string longest;
	int mlength=0;
	map<string,int> m;
	while(cin >> tmp)
	{
		m[tmp]++;
		if (tmp.size()>mlength)
		{
			mlength=tmp.size();
			longest=tmp;
		}
	}
	string frequent;
	int mfreq=0;
	for (map<string,int>::iterator it=m.begin(); it!=m.end(); ++it)
	{
		if (it->second > mfreq)
		{
			mfreq=it->second;
			frequent=it->first;
		}
	}
	cout << frequent << " " << longest << endl;
	return 0;
}

C++: #include <iostream>
#include <string>
#include <unordered_map>
#define int long long
using namespace std;
int n;
unordered_map<string,int> h_m;
signed main(){
    string word;
    int m_len = 0, m_count = 0;
    string w_len = "", w_count = "";
    while(cin >> word){
        h_m[word] += 1;
        if(m_len < word.size()){
            m_len = word.size();
            w_len = word;
        }
        if(m_count < h_m[word]){
            m_count = h_m[word];
            w_count = word;
        }
    }
    cout << w_count << " " << w_len << endl;
}

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