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

int main(){
	string st;
	map<string, int> cnt;
	string len_max, freq_max;
	int len = 0;
	while( cin >> st ){
		cnt[st]++;
		if(len < st.size()){
			len = st.size();
			len_max = st;
		}
		freq_max = (cnt[freq_max] < cnt[st]) ? st : freq_max;
	}
	cout << freq_max << " " << len_max << endl;
}

C++: #include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<cstring>
using namespace std;
int main(){
    char a[1100] = {0};
    scanf("%[^\n]",a);
    int cnt = 0;
    int mx = 0;
    int len[1100] = {0};
    string ans[1100];
    for(int i = 0,j = 0; i <= strlen(a); i++){
        if('a' <= a[i] && a[i] <= 'z' || 'A' <= a[i] && a[i] <= 'Z'){
            ans[cnt] += a[i];
            j++;
        }
        else{
            len[cnt] = j;
            cnt++;
            mx = max(mx,j);
            j = 0;
        }
    }
    string date;
    for(int i = 0; i < cnt; i++){
        if(len[i] == mx){
            date = ans[i];
            break;
        }
    }
    sort(ans,ans+cnt);
    fill(len,len+50,0);
    string mx_date = ans[0];
    ans[cnt] = ' ';
    mx = 0;
    for(int i = 1; i <= cnt; i++){
        if(mx_date == ans[i]){
            mx++;
        }
        else{
            mx_date = ans[i];
            len[i-1] = mx;
            mx = 0;
        }
    }
    for(int i = 0; i < cnt; i++){
        mx = max(mx,len[i]);
    }
    for(int i = 0; i < cnt; i++){
        if(len[i] == mx){
            cout << ans[i] << ' ' << date << endl;
            break;
        }
    }

    return 0;
}

C++: #include <string.h>
#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--)
#define INT_MIN_A -999999

using namespace std;

int main (void){
    
    char str[2001];
    gets(str);
    char tango[1000][33];
    int i = 0,j = 0,k = 0,l = 0, temp = 0,m = 0;
    int max_l = INT_MIN_A;
    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 <<" ";
    REP(j,32)
    cout << tango[max_numer][j];
    cout << endl;
    
    
    return 0;
}

C++: #include <iostream>
#include <string>
#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<cstdio>
#include<algorithm>
#include<string>
#include<cstring>
using namespace std;
int main(){
	char ans[50][10000] = {{0}};
	char a[10000] = {0};
	scanf("%[^\n]",a);
	int cnt = 0;
	int mx_len = 0;
	char date[10000] = {0};
	a[strlen(a)] = ' ';
	for(int i = 0,j = 0; i <= strlen(a); i++){
        if(a[i] >= 'a' && a[i] <= 'z' || a[i] >= 'A' && a[i] <= 'Z'){
            ans[cnt][j] = a[i];
            j++;
        }
        else{
            if(mx_len < j){
                strncpy(date,a+i-j,j);
                mx_len = max(mx_len,j);
            }
            cnt++;
            j = 0;
        }
	}
	int check[10000] = {0};
	for(int i = 0; i < cnt; i++){
        for(int j = i; j < cnt; j++){
            if(i != j){
                if(strcmp(ans[i],ans[j]) == 0){
                    fill(ans[j],ans[j]+1000,0);
                    check[i]++;
                }
            }
        }
	}
	mx_len = 0;
	char mx_date[10000] = {0};
	for(int i = 0; i < cnt; i++){
	    if(mx_len < check[i]){
	        strcpy(mx_date,ans[i]);
            mx_len = max(mx_len,check[i]);
	    }
	}
    cout << mx_date << " "<< date << endl;
	return 0;
}

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

int main(){
	string str;
	string word[1000];
	int rate[1000], kind = 0;
	int M_leng = 0, mode;
	string res_mod, res_len;
	bool new_word;
	
	for(int i = 0; i < 1000; i++) rate[i] = 0;
	while((cin >> str)){
		new_word = true;
		for(int i = 0; i < kind; i++){
			if(str == word[i]){
				new_word = false;
				rate[i]++;
				break;
			}
		}
		
		if(new_word){
			word[kind] = str;
			rate[kind]++;
			kind++;
		}
	}
	
	mode = 0;
	for(int i = 0; i < kind; i++){
		if(mode < rate[i]){
			res_mod = word[i];
			mode = rate[i];
		}
		if(M_leng < word[i].size()){
			res_len = word[i];
			M_leng = word[i].size();
		}
	}
	
	cout << res_mod << " " << res_len << endl;
	
	return 0;
}

C++: #include<iostream>
#include<string>
#include<map>
using namespace std;int main(){map<string,int>m;string s,t,u;for(;cin>>s;s.length()>u.length()?u=s:u)++m[s]>m[t]?t=s:s;cout<<t<<" "<<u<<endl;}