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 <string>
#include <map>
using namespace std;
map<string,int> table;
int main () {
  string word, frequent, longest;
  size_t N=0; //??????????????????
  while (cin >> word) {
    table[word] += 1;
    if (table[word] > N) {
      N = table[word];
      frequent = word;
    }
    if (word.size() > longest.size()) longest = word;
  }
  cout << frequent << " " << longest << endl;
}

C++: #include <iostream>
#include <algorithm>
#include <string>
#include <stack>
#include <cstdlib>
#include <queue>
#include <vector>
#include <map>
using namespace std;
int main() {
	string s,f,l;
	map<string,int> table;
	size_t n = 0;
	while( cin  >> s ) { 
		table[s] += 1;
		if ( table[s] > n ) {
			n = table[s];
			f = s;
		}
		if (s.size() > l.size() ) l = s;
	}
	cout << f << " " << l << endl;
}

C++: #include<map>
#include<iostream>
using namespace std;
int main(){
    map<string,int> sm;
    string in,freq,len;
    int maxfreq=0,maxlen=0;
    while(!cin.eof()){
       cin>>in;
       sm[in]++;
    }
    sm[in]--;
    for(map<string,int>::iterator it=sm.begin();it!=sm.end();it++){
        if(it->second>maxfreq){
            maxfreq=it->second;
            freq=it->first;
        }
        if(it->first.size()>maxlen){
            maxlen=it->first.size();
            len=it->first;
        }
    }
    cout<<freq<<" "<<len<<endl;
}

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

using namespace std;

map<string, int> table;

int main() {
  string word, frequent, longest;
  size_t N = 0; // size_t represents size in bytes of word (length)
  while (cin >> word) {
    table[word] += 1;
    if (table[word] > N) {
      N = table[word];
      frequent = word;
    }
    if (word.size() > longest.size()) longest = word;
  }
  cout << frequent << " " << longest << endl;
}

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

using namespace std;

void solve()
{
	string str;
	getline(cin, str);
	string word[1000];

	int pos = 0;
	int n = str.size();
	for(int i = 0; i < n; ++i)
	{
		if(str[i] == ' ')
		{
			pos++;
		}
		else
		{
			word[pos] += str[i];
		}
	}
	pos++;
	map<string, int> Map;
	for(int i = 0; i < pos; ++i)
	{
		Map[word[i]]++;
	}
	int frequency = 0;
	for(map<string, int>::iterator Ite = Map.begin(); Ite != Map.end(); ++Ite)
	{
		if(frequency < (*Ite).second)
		{
			frequency = (*Ite).second;
		}
	}
	int max_length = 0;
	for(int i = 0; i < pos; ++i)
	{
		if(max_length < word[i].size())
		{
			max_length = word[i].size();
		}
	}
	for(map<string, int>::iterator Ite = Map.begin(); Ite != Map.end(); ++Ite)
	{
		if(frequency == (*Ite).second)
		{
			cout << (*Ite).first << " ";
			break;
		}
	}
	for(int i = 0; i < pos; ++i)
	{
		if(max_length == word[i].size())
		{
			for(int j = 0; j < max_length; ++j)
			{
				cout << word[i][j];
			}
			cout << endl;
			break;
		}
	}
}

int main()
{
	solve();
	return(0);
}

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

using namespace std;

int main()
{
	int i = 0, max_num = 0, max_length_string_num = 0, tmp_num = 0;
	map< string, int > input_word;
	string tmp, max_length_string, max_num_string;

	while ( cin >> tmp )
	{
		input_word[tmp] = input_word[tmp] + 1;
		if ( tmp.length() > max_length_string_num )
		{
			max_length_string = tmp;
			max_length_string_num = tmp.length();
		}
	}

	map< string, int >::iterator it = input_word.begin();
	while ( it != input_word.end() )
	{
		tmp_num = (*it).second;
		if ( tmp_num > max_num )
		{
			max_num_string = (*it).first;
			max_num = tmp_num;
		}
		++it;
	}

	cout << max_num_string << " " << max_length_string << endl;

	return 0;
}

C++: #include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <utility>
#include <algorithm>

using namespace std;

int main()
{
	int longlen = 0;
	string str, longstr;
	vector<pair<int, string> > vc;

	while (cin >> str)
	{
		if((int)strlen(str.c_str()) > longlen){
			longlen = strlen(str.c_str());
			longstr = str;
		}
		
		bool bl = true;
		vector<pair<int, string> >::iterator it = vc.begin();
		while(it != vc.end())
		{
			if(it->second == str){
				it->first--;
				bl = false;
			}
			it++;
		}

		if(bl){
			vc.push_back(make_pair(0, str));
		}
	}
	
	sort(vc.begin(), vc.end());

	cout << vc[0].second << " " << longstr << endl;

	return 0;
}

C++: #include <iostream>
#include <cstring>
#include <string.h>
#include <cstdio>
using namespace std;
int main(){
  char c[1111];
  int len=0;
  int k=0;
  char maxc;
  int iti[1111]={0};//頻度高いよう
  char ans[1111];
  char ans1[1111];
  char cpy[1111][1111];
  while(scanf("%s",c)!=EOF){
    if(len<strlen(c)){//最長のもの
      len=strlen(c);
      strcpy(ans,c);
    }
    
    for(int i=0;i<k+1;i++){
      if(strcmp(cpy[i],c)==0){//すでに一度でていたら
	iti[i]++;
	break;
      }else if(i==k){//一度もでていなかったら
	strcpy(cpy[i],c);
      }
    }
    k++;
  }
  
  strcpy(ans1,cpy[0]);
  for(int i=0;i<k-1;i++){
    if(iti[i]<iti[i+1]){
      strcpy(ans1,cpy[i+1]);
    }
  }
  /*for(int i=0;i<k;i++){
    cout << cpy[i] << " ";
    }*/

  cout << ans1 << " " << ans << endl;
}

C++: #include<bits/stdc++.h>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<algorithm>
#include<map>
using namespace std;

int main(){
    int mod=1000000007;
    int mc=0,ml=0;
    map<string, int> m;
    string s,a,b;
    while(cin>>s){
        m[s]++;
        if (mc<m[s]) {
            mc=m[s];
            a=s;
        }
        if (ml<s.length()){
            ml=s.length();
            b=s;
        }

    }
    cout<<a<<" "<<b<<"\n";
    return 0;
}

C++: #include <unordered_map>
#include <iostream>
#include <algorithm>

using namespace std;

int main(){
  unordered_map<string,int> us;
  string s;
  while(cin >> s){
    us[s]++;
  }
  string ans1;
  int times = 0;
  string ans2;
  int length = 0;
  for(auto i : us){
    if(i.second > times){
      ans1 = i.first;
      times = i.second;
    }
    if(i.first.length() > length){
      ans2 = i.first;
      length = i.first.length();
    }
  }
  cout << ans1 << ' ' << ans2 << '\n';
     
}

C++: #include <iostream>
#include <numeric>
#include <string>
#include <unordered_map>
#include <utility>

using namespace std;

void chomp(string *str) {
  if ((*str)[str->size() - 1] == '\n') { str->erase(str->end() - 1); }
}

int main() {
  string word;
  typedef pair<string, int> WordFrequency;
  unordered_map<string, int> word_frequencies;
  while (cin >> word) { ++word_frequencies[word]; }

  auto most_frequent_word = accumulate(
      word_frequencies.begin(),
      word_frequencies.end(),
      WordFrequency(),
      [&](const WordFrequency& a, const WordFrequency& b){
        return a.second > b.second ? a : b;
      }).first;
  auto longuest_word = accumulate(
      word_frequencies.begin(),
      word_frequencies.end(),
      WordFrequency(),
      [&](const WordFrequency& a, const WordFrequency& b){
        return a.first.size() > b.first.size() ? a : b;
      }).first;

  cout << most_frequent_word << ' ' << longuest_word << endl;

  return 0;
}