Go: package main

import (
	"bufio"
	"fmt"
	"os"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Scan()
	l := sc.Text()
	words := strings.Split(l, " ")

	frequency := map[string]int{}
	long := map[string]int{}
	var maxFrequency, longest int
	var frequentWord, longestWord string
	for _, w := range words {
		frequency[w]++
		long[w] = len(w)
		if frequency[w] > maxFrequency {
			maxFrequency = frequency[w]
			frequentWord = w
		}
		if len(w) > longest {
			longest = long[w]
			longestWord = w
		}
	}

	fmt.Println(frequentWord + " " + longestWord)
}

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

using namespace std;

int main() {
	map<string, int> letters;
	string in;
	while(cin>>in){
		if(letters.count(in) == 0) letters.insert(make_pair(in, 0));
		else letters.find(in)->second++;
	}

	int maxChar = 0;
	int maxLength = 0;
	map<string, int>::iterator it, foo, bar;
	for(it=letters.begin(); it!=letters.end(); it++){
		maxChar = max(maxChar, it->second);
		if(maxChar == it->second) foo = it;
	}
	for(it=letters.begin(); it!=letters.end(); it++){
		maxLength = max(maxLength, (int)it->first.size());
		if(maxLength == it->first.size()) bar = it;
	}

	cout<<foo->first<<" "<<bar->first<<endl;
	return 0;
}

C++: #include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <sstream>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <numeric>
#include <cmath>
#include <climits>
#include <limits>
#include <cfloat>
#include <fstream>
using namespace std;

int main()
{
//	cut here before submit 
//	freopen("testcase.es", "r", stdin);
	string str = "";

	while ( getline (cin, str ) ){

		map <string, int> freq, leng;
		if (str.find('.') != string::npos){
			str = str.erase (str.find('.'), 1);
		} // end if
		stringstream ss(str);
		string s = "";

		while (ss >> s){
			++freq[s];
			leng[s] = s.length();
		} // end while

		if (freq.size() == 2){
			cout << "The two words separated by a space." << endl;
			continue;
		} // end if		
		if (!freq.empty() && !leng.empty() ){ 
			multimap <int, string, greater<int> > rank;
			map <string, int>::iterator itf = freq.begin();
			for (; itf != freq.end(); ++itf){
				rank.insert (make_pair ((*itf).second, (*itf).first ) );
			} // end for
			multimap<int, string, greater<int> > mlen;
			map<string, int>::iterator itl = leng.begin();
			for (; itl != leng.end(); ++itl){
				mlen.insert (make_pair ((*itl).second, (*itl).first ) );
			} // end for
			multimap<int, string, greater<int> >::iterator itr = rank.begin();
			multimap<int, string, greater<int> >::iterator itm = mlen.begin();
			cout << (*itr).second << ' ' << (*itm).second << endl;
		}else{
			cout << ' ' << endl;
		} // end if
	} // end while
		
	return 0;
}

C++: #include<iostream>
#include<map>
using namespace std;
int main(){
  map<string,int> word;
  string s,ss;
  int a = 0,b = 0;
  while(cin >>s) word[s]++;
  for(map<string,int>::iterator it = word.begin(); it!=word.end(); it++){
    if(a < it->second){a = it->second;ss = it->first;}
    if(b < (it->first).size()){b =  (it->first).size();s = (it->first);}
  }
  cout <<ss<<" "<<s<<endl;
  return 0;
}