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<vector>
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(){
	vector<int> num;
	vector<string> word;
	string code;
	vector<string>::iterator place;
	int he;
	while(cin>>code){
		word.push_back(code);
		for(place=word.begin();*place!=word.back();++place);
		if(place==word.end()-1)num.push_back(1);
		else{
			he=place-word.begin();
			word.pop_back();
			++*(num.begin()+he);
		}
	}
	he=*(max_element(num.begin(),num.end()));
	int i;
	for(i=0;num[i]!=he;++i);
	cout<<word[i]<<' ';
	int siz=1;
	for(i=0;word.begin()+i!=word.end();++i){
		if(word[i].size()>siz)siz=word[i].size();
	}
	for(i=0;word[i].size()!=siz;++i);
	cout<<word[i]<<endl;
	return 0;
}

C++: #include <iostream>
#include <cmath>
#include <vector>
#include <cstdio>
#include <algorithm>
using namespace std;
int main ()
{
	vector< pair<string, int> > a;
	string z;
	cin>>z;
	a.push_back(pair<string,int>(z,1));
	while(cin>>z)
	{
		for(int i=0;i<a.size();i++)
		{
			if(a[i].first==z)
			{
				a[i].second++;
			}
			if(i==a.size()-1)
			{
				a.push_back(pair<string,int>(z,1));
				break;
			}
		}
	}
	int m=-1;
	int s=-1;
	for(int i=0;i<a.size();i++)
	{
		m=max(m,a[i].second);
		s=max(s,(int)a[i].first.length());
	}
	for(int i=0;i<a.size();i++)
	{
		if(a[i].second==m)
		{
			cout<<a[i].first<<" ";
		}
	}
	for(int i=0;i<a.size();i++)
	{
		if(a[i].first.size()==s)
		{
			cout<<a[i].first<<endl;;
		}
	}
	return 0;
}

C++: #include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <sstream>
#include <utility>
#include <cstdlib>
#include <cctype>
#include <climits>
#include <fstream>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<double> vd;
typedef vector<pair<int, int> > vpii;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define foreach(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); itr++)
#define dbg(x) cout << #x"="<< (x) << endl
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back(a) 
#define in(x) cin >> x;
#define all(x) (x).begin(), (x).end()
#define INF 2147483600
#define fi first
#define se second
using namespace std;

map <string,int> ans;
int l=0;
int k=0;

int main(){
    string str;
    string a,b;
    while(cin>>str){
        if(str.size()>=l){
            b = str;
            l=str.size();
        }
        ans[str]++;
        if(ans[str]>=k){
            k=ans[str];
            a=ans[str];
        }
    }
    cout<<a<<" "<<b<<endl;
}

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

int comp(pair<string,int>a,pair<string,int>b){
	return a.second < b.second;
}
int main() {
	map<string,int> strtable;
	map<string,int>::iterator mnum;
	string word;
	string maxlw;

	while(cin>>word){
		if(strtable.find(word) == strtable.end())strtable[word]=1;
		else strtable[word]++;
		if(word.length() > maxlw.length())maxlw = word;
	}
	
	mnum = max_element(strtable.begin(),strtable.end(), comp);
	
	cout<<mnum->first<<" "<<maxlw<<endl;
	
	return 0;
}

C++: #include<cstdio>
#include<cstring>
#include<iostream>
#include<queue>
#include<string>
using namespace std;
struct Eng {
  string str;
  int count;
};
int main(){
  Eng data[1001],temp;
  string str,box="\0";
  int f=0,num=0,flag;
  getline(cin , str);
  int str_size = str.size();
  for(int i=0;i<str_size;i++){
    if(str[i] == ' '){
      data[num].str = str.substr( f , i - f );
      for(int j=0;j<num;j++){
	if(data[num].str == data[j].str){
	  data[j].count++;	
	}
      }
      f = i + 1;
      num++;
    }
    else if(i == str_size-1){
      data[num].str = str.substr( f , i - f + 1  );
      for(int j=0;j<num;j++){
	if(data[num].str == data[j].str)data[j].count++;
      }
      num++;
    }
  }
  for(int i=0;i<num-1;i++){
    for(int j=num-1;j>i;j--){
      if(data[j].count>data[j-1].count){
	temp = data[j];
	data[j] = data[j-1];
	data[j-1] = temp;
      }
    }
  }
  for(int i=0;i<num;i++)
    if(box.size()<data[num-1].str.size())box = data[i].str; // 長さ確保
  cout << data[0].str << ' ' << box << endl;
}

C++: #include <map>
#include <string>
#include <iostream>
using namespace std;
map<string,int> table;
int main()
{
    string word, frequent, longest;
    size_t N=0;
    while (cin >> word)
    {
        table[word]++;
        if(table[word]>N)
        {
            N=table[word];
            frequent=word;
            if(word.size()>longest.size())
                longest=word;
    }
        cout<<frequent<<" "<<longest<<endl;
    }

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

using namespace std;


map <string, int> cnt;

int main() {
	
	string firstWord;
	string secondWord;
	
	int maxCount = 0;
	int maxLength = 0;
	
	string s;
	while (cin >> s) {
		cnt[s] = cnt[s] + 1;
		if (cnt[s] > maxCount) {
			maxCount = cnt[s];
			firstWord = s;
		}
		
		if ((int) s.size() > maxLength) {
			maxLength = s.size();
			secondWord = s;
		}
	}
	
	cout << firstWord << ' ' << secondWord << "\n";
	
	return 0;
}

C++: #include <bits/stdc++.h>

using namespace std;

int main() {
  string s;
  int mx1 = 0, mx2 = 0;
  map<string, int> m;
  while (cin >> s) ++m[s];
  for (auto i : m) mx1 = max(mx1, i.second);
  for (auto i : m) mx2 = max(mx2, (int)i.first.size());
  for (auto i : m) {
    if (i.second == mx1) cout << i.first << " ";
  }
  for (auto i : m) {
    if ((int)i.first.size() == mx2) cout << i.first << endl;
  }
}

C++: #include <iostream>
#include <string>
#include <map>
using namespace std;
map<string, int> table;
int main() {
  string word, frequent, longest; // input, max frequency, and longest
  size_t N=0; // frequency of the string "frequent"
  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 <vector>
#include <string>
#include <map>
using namespace std;

int main(){
    string s;
    vector<string> v;
    while(cin>>s){
        v.push_back(s);
    }
    sort(v.begin(),v.end());
    int l=0;
    for(int i=0;i<(int)v.size();i++){
        if(v[i].size() > v[l].size())l=i;
    }
    int f=0,fmax=0;
    for(int i=0;i<(int)v.size();i++){
        int j=i;
        while(j<(int)v.size() && v[i]==v[j])j++;
        if(j-i > fmax){
            fmax = j;
            f = i;
        }
        i=j;
    }
    cout << v[f] << " " << v[l] << endl;
}