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 <numeric>
#include <string>
#include <unordered_map>
#include <utility>

using namespace std;

void chomp(string *str) {
  if ((*str)[str->size() - 1] == '\n') { str->erase(str->end() - 1); }
}

int main() {
  string word;
  typedef pair<string, int> WordFrequency;
  unordered_map<string, int> word_frequencies;
  while (cin >> word) { ++word_frequencies[word]; }

  auto most_frequent_word = accumulate(
      word_frequencies.begin(),
      word_frequencies.end(),
      WordFrequency(),
      [&](const WordFrequency& a, const WordFrequency& b){
        return a.second > b.second ? a : b;
      }).first;
  auto longuest_word = accumulate(
      word_frequencies.begin(),
      word_frequencies.end(),
      WordFrequency(),
      [&](const WordFrequency& a, const WordFrequency& b){
        return a.first.size() > b.first.size() ? a : b;
      }).first;

  cout << most_frequent_word << ' ' << longuest_word << endl;

  return 0;
}

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

using namespace std;

int main(){
  int max = 0;
  string str,maxs;
  map<string,int> M;
  while( cin >> str ){
    if(max < (int)str.size()){
      max = str.size();
      maxs = str;
    }
    M[str]++;
  }
  string fs;
  int m = 0;
  for( map<string,int>::iterator it = M.begin(); it != M.end(); it++ ){
    if(m < (*it).second){
      m = (*it).second;
      fs = (*it).first;
    }
  }
  cout << fs << " " << maxs << endl;
}

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

int main() {
	typedef int Freqency;
	typedef string Name;
	map<Name, Freqency> table;
	string name, freqMax = "", lenMax = "";

	while (cin >> name) {
		table[name]++;
		if (table[name] > table[freqMax]) freqMax = name;

		if (name.size() > lenMax.size()) lenMax = name;
	}

	cout << freqMax << " " << lenMax << endl;
}

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;
        }
    }
    cout<<a<<" "<<b<<endl;
}

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

int main()
{
	char get[1000][40] ;
	char mode[40] ;
	char longest[40] ;

	int count = 0 ;
	int lest = -1 ;
	
	int tmp = 0 ;

	int most = 0 ;
	int mnum = -1 ;

	int i = 0 ;

	while( cin >> get[i] )
	{
		if( count < strlen(get[i]) )
		{
			count = strlen(get[i]) ;
			lest = i ;
		}

		for( int j = (i-1) ; j >= 0 ;  j -- )
		{
			if( strcmp( get[i], get[j] ) == 0 )
			{
				tmp ++ ;
			}
		}
		tmp = 0 ;

		if( most < tmp )
		{
			most = tmp ;
			mnum = i ;
		}

		i ++ ;
	}

	cout << get[mnum] << " " << get[lest] ;

	return 0 ;
}

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

int main(){
  std::string str;
  std::string maxlen;
  std::string maxocc;
  map<std::string, int> occ;
  //std::cin >> str;
  //std::cout << str << std::endl;

  std::cin >> str;
  maxlen = str;
  maxocc = str;

  while(std::cin >> str){
    if(str.size()>maxlen.size()){
      maxlen = str;
    }
    occ[str]++;
    if(occ[str]>occ[maxocc]){
      maxocc = str;
    }
  }

  std::cout << maxlen << std::endl;
}

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

int main(){
	char str[1000];
	char word[33][33]={0};
	int longest=0;
	int check[33]={0};
	char *tmp;
	int freq=0;
	int count=0;
	int i,j;
	size_t len , prev;
	fgets(str , sizeof(str) , stdin);
		tmp=str;
		for(i=0 ; str[i]!='\0' ;i++){
			if(str[i]==' '){
				str[i]='\0';
				strcpy((char*)&word[count] , (const char*)tmp);
				tmp=str+i+1;
				count++;
			}
		}
		strcpy((char*)&word[count],(const char*)tmp);
		count++;
	for(i=0 ; i<count ; i++){
		for(j=i ; j<count ; j++){
			if(strcmp((const char*)&word[i] , (const char*)&word[j])==0){
				check[i]++;
			}
		}
	}
	for(i=count; i>=0 ; i--){
		for(j=0 ; j<i-1 ; j++){
			if(check[j]>check[j+1]){
				check[j]^=check[j+1];
				check[j+1]^=check[j];
				check[j]^=check[j+1];
				freq=j;
			}
		}
	}
		prev=strlen(word[0]);
	for (i=0 ; i<count ; i++){
		len=strlen(word[i]);
		if(len > prev){
			prev = len;
			longest=i;
		}	
	}
	
	cout << (char*)&(word[freq]) << " "<< (char*)&(word[longest]) << endl;
	return 0;
}

C++: /*
	0029:English sentence
*/
#include	<iostream>
#include	<string>
#include	<map>

using namespace std;

typedef map<string, int> M_SI;

int main(void) {
	int maxlen = 0, maxcou = 0; 
	string buf_str, maxlenSen, maxcouSen;
	M_SI Sentence;
	
	while(1) {
		cin >> buf_str;
		if(cin.eof()) { break; }
		if(Sentence.empty() || Sentence.count(buf_str) == 0) {
			Sentence.insert( M_SI::value_type(buf_str, 1) );
		} else {
			M_SI::iterator it = Sentence.find(buf_str);
			(*it).second++;
		}
	}
	M_SI::iterator it = Sentence.begin();
	while(it != Sentence.end()) {
		string bff = (*it).first;
		int bfs = (*it).second, bfl = bff.size();
		
		if(maxlen < bfl) {
			maxlenSen = bff;
			maxlen = bfl;
		}
		if(maxcou < bfs) {
			maxcouSen = bff;
			maxcou = bfs;
		}
		it++;
	}
	cout << maxcouSen << ' ' << maxlenSen << endl;
	
	return 0;
}

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

int main(){

	int max=0;
	string a;
	map<string,int> s;
	string x,y;
	
	cin>>a;
	s[a]++;
	x=y=a;
	
	while(cin>>a){
		s[a]++;
		if(y.size()<a.size())
			y=a;
		if(s[a]>max){
			max=s[a];
			x=a;
		}
	}
	
		cout<<x<<" "<<y<<endl;
}

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

int main(void){
  vector<string> str;
  vector<int> cnt;
  string buf, maxstr;
  int max = 0, ans, i;

  while(cin >> buf){
    bool f = true;

    if(max < buf.length()){
      max = buf.length();
      maxstr = buf;
    }
    for(i = 0; i < str.size(); i++){
      if(str[i] == buf){
	f = false;
	break;
      }
    }
    if(f){
      str.push_back(buf);
      cnt.push_back(1);
    }
    else{
      cnt[i]++;
    }
  }

  max = 0;
  for(i = 0; i < cnt.size(); i++){
    if(cnt[i] > max){
      max = cnt[i];
      ans = i;
    }
  }

  cout << str[ans] << ' ' << maxstr << endl;

  return 0;
}