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<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<complex>
#include<iomanip>
 
#define EPS (1e-10)
using namespace std;
#define PI (3.1415926535)

int main(){
	vector<string> word;
	vector<int> count;

	int imax = 0;
	string s;

	while(cin >> s){
		for(int i = 0; i < s.size(); i++){
			s[i] = tolower(s[i]);
		}
		bool b = true;
		int num;
		for(int i = 0; i < word.size(); i++){
			if(word[i] == s){
				b = false;
				num = i;
				break;
			}
		}
		if(b){
			word.push_back(s);
			count.push_back(0);
		}else{
			count[num]++;
			if(count[num] > count[imax]){
				imax = num;
			}
		}
	}

	int l = 0;
	for(int i = 0; i < word.size(); i++){
		if(word[l].size() < word[i].size()){
			l = i;
		}
	}

	cout << word[imax] << ' ' << word[l] << endl;

	return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <string>
#include <map>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)

int main(void)
{
    string s, max_s = "", most_s = "";
    int most = 0;
    map<string, int> count;
    
    while(cin >> s) {
        if (max_s.size() < s.size()) {
            max_s = s;
        }
        if (count.find(s) == count.end()) {
            count[s] = 0;
        }
        count[s]++;
        if (most < count[s]) {
            most = count[s];
            most_s = s;
        }
    }
    
    cout << most_s << " " << max_s << endl;
    
    return 0;
}

C++: #include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;
#define tr(c, i) for(auto i = (c).begin(); i != (c).end(); i++)

int main(int argc, char **argv)
{
  map<string, int> words;
  string s;
  string maxword;

  maxword = "";
  for (;;) {
    cin >> s;
    if (cin.eof())
      break;

    if (s.length() > maxword.length())
      maxword = s;
    words[s]++;
  }

  int most = 0;
  string mostword = "";
  tr (words, i) {
    if (i->second > most) {
      most = i->second;
      mostword = i->first;
    }
  }
  cout << mostword << " " << maxword << endl;
  return 0;
}

C++: #include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef pair<string, int> PAIR;

int main(){
	vector<PAIR> vec;
	vector<PAIR>::iterator ite;
	string st;
	while(cin >> st){
		ite = vec.begin();
		if(vec.empty()){
			vec.push_back(PAIR(st, 1));
		}else{
			while(1){
				if((*ite).first == st){
					(*ite).second++;
					break;
				}
				ite++;
				if(ite == vec.end()){
					vec.push_back(PAIR(st, 1));
					break;
				}
			}
		}

		vector<PAIR>::iterator max = vec.begin();
		vector<PAIR>::iterator mim = vec.begin();
		for(ite = vec.begin(); ite != vec.end(); ite++){
			if((*max).second < (*ite).second) max = ite;
			if((*mim).second >= (*ite).second) mim = ite;
		}

		cout << (*max).first << " " << (*mim).first << endl;

	}
	return 0;
}

C++: #include<iostream>
#include<map>
using namespace std;
int main(){
  map<string,int> word;
  string s,as,bs;
  int an = 0;
  while(cin >>s){
    word[s]++;
    if(word[s]>an){
      an = word[s];
      as = s;
    }
    if(s.size()>bs.size()) bs = s;
  }
  cout <<as<<" "<<bs<<endl;
  return 0;
}

C++: #include<cstdio>
#include<cstring>
#include<string>

using namespace std;

string s[1001];
int count[1001];

int main(void){
	char temp[1002];
	
	while(fgets(temp,1001,stdin) != 0){
		int temp_n = strlen(temp);
		int c = 0;
		int max_h = 0;
		int max_H = 0;
		int max_l = 0;
		int max_L = 0;
		
		for(int i = 0; i < 1001; i++){
			s[i] = "";
			count[i] = 0;
		}
		
		for(int i = 0; i < temp_n; i++){
			for(int j = i; ; j++){
				if(temp[j] == ' '){
					i=j;
					c++;
					break;
				}else if(temp[j] == '\n'){
					i=j;
					c++;
					break;
				}
				s[c] += temp[j];
			}
		}
		
		for(int i = 0; i < c; i++){
			for(int j = 0; j < c; j++){
				if(i == j)continue;
				if(s[i] == s[j])count[i]++;
			}
		}
		
		for(int i = 0 ; i < c; i++){
			if(s[i].size() > max_L)max_l = i;
			if(count[i] > max_H)max_h = i;
		}
		
		printf("%s %s\n", s[max_h].c_str(), s[max_l].c_str() );
	}
	return 0;
}

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

int main()
{
    map<string,int> m1;
    string str1, str2, str3;        //入力、頻度最大文字列、最長文字列

    int length = 0;
    while( cin >> str1 )
    {
        m1[str1]++;                 //出現頻度
        if( length < str1.size() )
        {
            length = str1.size();
            str3 = str1;
        }
    }

    int max = 0;
    for( map<string,int>::iterator itr = m1.begin(); itr != m1.end(); itr++ )
    {
        if( max < itr -> second )
        {
            max = itr -> second;
            str2 = itr -> first;
        }
    }

    cout << str2 << " " << str3 << endl;

    return 0;
}

C++: #include <string.h>
#include <string>
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>
#include <utility>

#define ll (long lon
#define REP(i,n) for(int i = 0;i<(int)n;i++)
#define FOR(i,a,b) for(int i = (a);i < (b);i++)
#define RFOR(i,a,b) for(int i = (a);i>(b);i--)

using namespace std;

int main (void){
    
    char str[1000];
    gets(str);
    char tango[500][33];
    int i = 0,j = 0,k = 0,l = 0, temp = 0,m = 0;
    char max[33];
    int max_l = INT_MIN;
    int max_numer = 0;
    int yokuderu = 0;
    int yokuderu_temp = 0;
    int yokuderu_number = 0;
    while(str[i++] != '\0')
    {
        if(str[i-1] == ' ')
        {
            if((i-1)-temp>max_l)
            {
                max_l = (i-1) -temp;
                max_numer = j;
            }
            while(temp<i-1)
                tango[j][l++] = str[temp++];
            temp = i;
            j++;
            l = 0;
        }
    }
    
 
        if((i-1)-temp>max_l)
        {
            max_l = (i-1) -temp;
            max_numer = j;
        }
        while(temp<i-1)
            tango[j][l++] = str[temp++];
        temp = i;
        j++;
        l = 0;
    /*???????????§??????????????????*/
    //cout <<"number is " << j << endl;
    
    for(int m = 0; m < j;m++)
    {
        for(int k = 0; k<j;k++)
        {
            if(m != k)
            {
                if(strcmp(tango[m], tango[k]) == 0)
                {
                    yokuderu_temp++;
                }
            }
        }
        if(yokuderu_temp >= yokuderu)
        {
            yokuderu = yokuderu_temp;
            yokuderu_number = m;
        }
        yokuderu_temp = 0;
    }
    REP(i,32)
    cout << tango[yokuderu_number][i];
    cout << " ";
    while(tango[max_numer][m++] != '\0')
        cout << tango[max_numer][m-1];
    m = 0;
        cout << endl;
    
    
    return 0;
}

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

int main() {
  string str, mf, ml;
  map<string, int> mp;
  while (cin >> str) {
    mp[str]++;
    if (mp[str] > mp[mf]) mf = str;
    if (str.length() > ml.length()) ml = str;
  }
  cout << mf << " " << ml << endl;
}