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 <cstdio>
#include <algorithm>
#include <string>
#include <queue>
using namespace std;

int main(void)
{
    priority_queue <string> word;
    char str[35];
    int top_num = 0, now_num = 0, max_len = 0;
    string s, max, top, prev;
    
    while (scanf("%s", str) == 1){
        word.push(str);
        s = str;
		if(max_len < s.size()){
            max_len = (int)s.size();
            max = s;
        }

    }
    
    prev = word.top();
    while (!word.empty()){
        if (prev == word.top()){
            now_num++;
            if (top_num < now_num){ 
                top_num = now_num;
                top = word.top();
            }
        }
        else now_num = 0;
        prev = word.top();
        word.pop();
    }
    
    printf("%s %s\n", top.c_str(), max.c_str());
    
    return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;

int main()
{
	map<string, int> cnt;
	string s;
	while (cin >> s) {
		cnt[s]++;
	}
	int ma = 0, le = 0;
	string res1, res2;
	for (auto p : cnt) {
		if (p.second > ma) {
			ma = p.second;
			res1 = p.first;
		}
		if ((int)p.first.size() > le) {
			le = p.first.size();
			res2 = p.first;
		}
	}
	cout << res1 << ' ' << res2 << endl;
	return 0;
}

C++: #include "bits/stdc++.h"
using namespace std;

int main(){
	string s;
	int m;
	map<string,int> mp;
	while(cin>>s){
		mp[s]++;
		m=max(m,s,size());
	}
	
	int x=0;
	
	for(auto &el:mp){
		if(x<el.second){
			x=el.second;
		}
	}
	
	for(auto &el:mp){
		if(x==el.second){
			cout<<el.first<<" ";
			break;
		}
	}
	
	for(auto &el:mp){
		if(m==el.first.size()){
			cout<<el.first<<endl;
		}
	}
	
	return 0;
}

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

int main(void)
{
	std::map<std::string,int> words;
	char word[33];
	while(~scanf("%s",word))
	{
		if(words.find(word)==words.end())
			words[word]=0;
		words[word]++;
	}

	int max=0;
	std::string mode,longest;
	for(std::map<std::string,int>::iterator it = words.begin(); it != words.end(); it++)
	{
		if(it->second > max)
		{
			max = it->second;
			mode = it->first;
		}
		if(it->first.size() > longest.size())
		{
			longest = it->first;
		}
	}
	std::cout << mode << " " << longest << std::endl;
	return 0;
}

C++: #include <iostream>
#include <iostream>
#include <string>
#include <map>
using namespace std;
int main(){
  string s, max("");
  map<string, int> w; // stringÅsort³êé
  map<int, string, greater<int> > x; // int Åsort³êé = ÅÌÆ±ÉÅåo»ñ

  while(cin >> s){
    //Åå·Ì¶ðXV
    if(s.size() > max.size()) max = s;
    w[s]++;
  }
  
  for(map<string, int>::iterator it = w.begin() ; it != w.end() ; it++){
    x[(*it).second] = (*it).first;
    //cout << "first = " << (*it).first << ", second =  " << (*it).second << endl;
  }

  /*for(map<int, string>::iterator it = x.begin() ; it != x.end() ; it++){
    x[(*it).second] = (*it).first;
    cout << "first = " << (*it).first << ", second =  " << (*it).second << endl;
  }*/
  
  cout << (*x.begin()).second << " " << max << endl;
  return 0;
}

C++: #include<iostream>
#include<map>
#include<string>
using namespace std;

int main() {
	map<string,int> data;
	string n;
	while (cin >> n) 
		data[n]++;
	
	//出現頻度が最も多い単語
	int max = 0;
	string maxt;
	map<string,int>::iterator it = data.begin();
	for ( ; it != data.end(); it++ ) {
		if ( (*it).second > max ){
			max = (*it).second;
			maxt = (*it).first;
		}
	}
	cout << maxt << " ";
		
	max = 0;
	//文字数が最も多い単語
	for ( it = data.begin(); it != data.end(); it++ ) {
		if ( (*it).first.size() > max ){
			max = (*it).first.size();
			maxt = (*it).first;
		}
	}
	cout << maxt << endl;
}

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

using namespace std;

int debug = 0;

int main(void){
	string tmp;
	string max_len_word, max_times_word;
	unsigned int max_len = 0, max_times = 0;
	map<string, int> words;

	while(cin >> tmp){
		if(tmp.size() > max_len){
			max_len_word = tmp;
			max_len = tmp.size();
			if(debug) cout << "longest word overwritten." << endl;
		}
		++words[tmp]; 
		if(debug) cout << "count " << tmp << " is " << words[tmp] << endl;
	}

	map<string, int>::iterator it;
	max_times=0;
	for(it=words.begin(); it!=words.end(); ++it){
		if(max_times < it->second){
			max_times_word = it->first;
			max_times = it->second;
			if(debug) cout << "the most frequent word is now" << it->first << endl;
		}
		if(debug) cout << "count " << it->first << " is " << it->second << endl;
	}

	cout << max_times_word << " " << max_len_word << endl;

	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;

#define rep(i,a,n) for(int i=a; i<n; i++)
#define repr(i,a,n) for(int i=a; i>=n; i--)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 999999999

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long int ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

int const MOD = 1000000007;

int main() {
    string s;
    multiset<string> v;

    int max_num = 0;
    int max_len = 0;

    while(cin >> s) {
        v.insert(s);
        max_num = max((int)v.count(s), max_num);
        max_len = max((int)s.length(), max_len);
    }

    for(auto x : v) {
        if(v.count(x) == max_num) cout << x << " ";
    }
    for(auto x : v) {
        if(x.length() == max_len) cout << x << endl;
    }
    return 0;
}

C++: #include <iostream>
#include <map>
using namespace std;

int main()
{
    map<string, int> dict;
    string s, max_s, max_e_s;
    int max_length = 0, max_emerge = 0;
    while (cin >> s)
    {
        dict[s]++;
        if (s.size() > max_length)
        {
            max_length = s.size();
            max_s = s;
        }
    }
    for (auto t = dict.begin(); t != dict.end(); t++)
    {
        if (t->second > max_emerge)
        {
            max_emerge = t->second;
            max_e_s = t->first;
        }
    }
    cout << max_e_s << " " << max_s << endl;
    return 0;
}

C++: #include <iostream>
#include <string>
#include <map>
#include <vector>
using namespace std;

int main(){
	map<string, int> word;
	vector<string> w;
	string str;
	int max=0,length=0;

	while(cin >> str){
			
		w.push_back(str);
		
		//??\???????????????????????§??????????????¢???
		if(word.find(str) != word.end() ){
			word[str]++;
		}else{
			word.insert( pair<string, int>(str,1));
		}
	}
	
	map<string,int>::iterator p;
	for(p = word.begin() ; p != word.end() ; p++){
		if( max < p->second) max = p->second;
	}
	for(p = word.begin() ; p != word.end() ; p++){
		if( max == p->second){
			cout << p->first << " ";
			break;
		}
	}
	for(int i=0 ; i<w.size() ; i++){
		if( length < w[i].size() ) length = w[i].size();
	}
	for(int i=0 ; i<w.size() ; i++){
		if( length==w[i].size() ){
			cout << w[i] << endl;
			break;
		}
	}
}