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 <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    map<string, int> m;
    int maxNum = 0;
    string ret1;
    int maxLength = 0;
    string ret2;

    for(;;){
        string s;
        if(!(cin >> s))
            break;

        int num = ++ m[s];
        if(num > maxNum){
            maxNum = num;
            ret1 = s;
        }

        if(s.size() > maxLength){
            maxLength = s.size();
            ret2 = s;
        }
    }

    cout << ret1 << ' ' << ret2 << endl;
    return 0;
}

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

int main(){
	map<string,int> data;
	string ans1,ans2,str;
	while(cin >> str){
		data[str]++;
		if(data[ans1] < data[str]) ans1 = str;
		if(ans2.size() < str.size() ) ans2 = str;
	}
	cout << ans1 << " " << ans2 << endl;
}

C++: #if 0

#endif

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;

map<string, int> M;

int main() {
  string word, long_word, freq_word;
  int cnt = 0, length = 0;
  while (cin >> word) {
    if (M.count(word))
      M[word]++;
    else
      M[word] = 1;
    if (M[word] > cnt) {
      cnt = M[word];
      freq_word = word;
    }
    if (word.length() > length) {
      length = word.length();
      long_word = word;
    }
  }
  cout << freq_word << ' ' << long_word << endl;
}

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

using namespace std;

int main(void){

	string str[1010];
	int num[1010]={0};
	char inp[41];
	int max=0,max2=0;
	while(scanf("%s",&inp)!=EOF){
		for(int i=0;;i++){
			if(str[i].empty()==1){
				str[i]=inp;
				num[i]++;
				break;
			}
			if(str[i]==inp){
				num[i]++;
				break;
			}
		}
	}

		for(int i=1;!str[i].empty();i++){
			if(str[max].size()<str[i].size()) max=i;
			if(num[max2]<num[i]) max2=i;
		}
	cout<<str[max2]<<" "<<str[max]<<endl;

	return 0;
}

C++: #include <stdio.h>
#include <string.h>
#include <string>
#include <map>
using namespace std;
#define TT 35

map <string, int> S;

int max_len,  max_time;
char str[TT], tmp_max_len[TT], tmp_max_time[TT];

void init(){
	max_len = 0,  max_time = 0;
}

void solve(){
	S[str] ++;
	if (max_time < S[str]){
		strcpy(tmp_max_time, str);
		max_time = S[str];
	}
	int len = strlen(str);
	if (max_len < len){
		strcpy(tmp_max_len, str); 
		max_len = len;
	}
}

int main (){
	init();
	while (~scanf("%s", str)){
		solve();
	}
	printf("%s %s\n", tmp_max_time, tmp_max_len);
	return 0;
}

C++: #include <iostream>
#include <sstream>
#include <map>
using namespace std;
int main(){
	string s,tmp,lw,histw;
	map<string,int> count;
	int maxh=0,maxl=0;
	getline(cin,s);
	stringstream ss;
	ss<<s;
	while(ss>>tmp){
		if(count.find(tmp)!=count.end())++count[tmp];
		else count[tmp]=1;
		if(count[tmp]>maxh){
			maxh=count[tmp];
			histw=tmp;
		}
		if(tmp.length()>lw.length())lw=tmp;
	}
	cout<<histw<<" "<<lw<<"\n";
	return 0;
}

C++: a=[],m=l=0,n=c='';require("fs").readFileSync("/dev/stdin","utf8").trim().split(' ').map(function(i){a[i]?++a[i]>m?m=a[n=i]:0:a[i]=1;(t=i.length)>l?(c=i,l=t):0});console.log(n+' '+c)

C++: #include <cstdio>
#include <vector>
#include <algorithm>
#include <cstring>
#include <string>
#include <cctype>
#include <sstream>
#include <cmath>
#include <climits>
#include <map>

using namespace std;

#define reep(i,f,n) for(int i=f; i<int(n); ++i)
#define rep(i,n) reep(i,0,n)

typedef vector<int> vi;

int main()
{
	map<string, int> m;
	string best;
	string longest;
	
	char word[33];
	while(scanf("%s", word) != EOF){
		string s(word);
		if(m.count(s))
			m[s]++;
		else
			m[s] = 1;

		if(m[best] < m[s])
			best = s;
		if(longest.size() < s.size())
			longest = s;
	}
	printf("%s %s\n", best.c_str(), longest.c_str());

	return 0;
}

C++: #include <iostream>
#include <map>
using namespace std;
#define F first
#define S second
int main(){
    string s,ans,lon;
    map<string,int>m;
    int top=0;
    while(cin>>s){
        m[s]++;
        if(s.size()>lon.size())lon=s;
    }
    for(pair<string,int> i:m){
        if(i.S>top){
            top=i.S;
            ans=i.F;
        }
    }
    cout<<ans<<' '<<lon<<endl;
}

C++: #include<iostream>
#include<string>
#include<map>
#include<cctype>
using namespace std;
int main(){
	map<string, int> mpa;
	string most_frequent_word, longest_word;
	string s;
	int max_frequency = 0, max_length = 0;
	while(cin >> s){
		if(s.length() > max_length){
			max_length = s.length();
			longest_word = s;
		}
		for(int i = 0; i < s.length(); i++) s[i] = tolower(s[i]);
		mpa[s]++;
	}
	for(auto e : mpa){
		if(e.second > max_frequency){
			max_frequency = e.second;
			most_frequent_word = e.first;
		}
	}
	cout << most_frequent_word << ' ' << longest_word << endl;
	return 0;
}

C++: #include <iostream>
#include <string>
using namespace std;
int main(){
    long saidai=0;
    int a=0,cnt=0,num=0,max=0;
    string str,tango[1000]={"0"},answer,ans;
    getline(cin,str);
    for(int i=0;i<str.size();i++){
        if(str[i]==' '){
            for(int j=a;j<i;j++){
                tango[cnt]+=str[j];
            }
            cnt=cnt+1;
            a=i+1;
        }
    }
    for(int p=a;p<str.size();p++){
        tango[cnt]+=str[p];
    }
    for(int k=0;k<1000;k++){
        if((tango[k]=="0"))break;
        if(saidai<tango[k].size()){
            saidai=tango[k].size();
            ans=tango[k];
        }
    }
    
    for(int s=0;s<=cnt;s++){
        for(int t=s+1;t<=cnt;t++){
            if(tango[s]==tango[t]){
                num=num+1;
            }
        }
        if(max<num){
            max=num;
            answer=tango[s];
        }
    }
    cout<<answer<<" "<<ans<<endl;
    return 0;
}

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

int main()
{
  int i = 0;
  string str;
  string freqstr;//最頻文字
  string longest;
  map<string,int> Map;
  while(cin >>str){
    if(i < ++Map[str]){
      i = Map[str];
      freqstr = str;
  }
    if(str.size() > longest.size())
      longest = str;
  }
  cout <<freqstr <<" "<<longest<<endl;
  return 0;
}

C++: #include <iostream>
#include <string>
#include <map>
#include <set>
 
using namespace std;
 
set<string> dic;
map<string,int> times;
 
int main(){
  int msize = 0;
  string str;
  string a,b;
  while(!cin.eof()){
    string in; cin >> in;
    dic.insert(in);
    times[in]++;
    if(msize < in.size()){
      str = in;
      msize = str.size();
    }
  }
  a = str;
  int mfreq = 0;
  for(set<string>::iterator it = dic.begin(); it != dic.end(); ++it){
    if(mfreq < times[*it]){
      mfreq = times[*it];
      str = *it;
    }
  }
  b = str;
  cout << b << " " << a << endl;
 
  return 0;
}