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 <stdio.h>
#include <ctype.h>
#include <string.h>

int main(void){
	char word[33];
	int len = 0;
	int mlen = 0;
	char mword[33];
	char dict[1000][33];
	int mode[1000];
	int st = 0;
	bool find = false;
	int i = 0;

	while(scanf("%s", word) != EOF){
		len = strlen(word);
		for(i=0; i<len; ++i){
			word[i] = tolower(word[i]);
		}

		if(mlen < len){
			mlen = len;
			strcpy(mword, word);
		}

		find = false;
		for(i=0; i<st; ++i){
			if(strcmp(dict[i], word) == 0){
				find = true;
				break;
			}
		}
		if(find){
			mode[i]++; 
		}else{
			strcpy(dict[st], word);
			mode[st] = 1;
			st++;
		}
	}

	int max = 0;
	int maxi = 0;
	for(i = 0; i<st; ++i){
		if(max < mode[i]){
			max = mode[i];
			maxi = i;
		}
	}
	printf("%s %s\n", dict[maxi], mword);

	getchar();
	return 0;
}

C++: #include<iostream>
#include<vector>
#include<string>
#include<sstream>
#include<algorithm>

struct WordRanking
{
	WordRanking(){}

	WordRanking(std::string word, int count):m_word(word),m_count(count)
	{
	}

	std::string m_word;

	int m_count;
};

int MaxNum(std::vector<WordRanking> rank)
{
	if(rank.empty())
	{
		return 0;
	}

	int max = rank[0].m_count;

	int maxNum=0;

	for(size_t i=1; i<rank.size(); ++i)
	{
		if(rank[i].m_count>max)
		{
			max = rank[i].m_count;

			maxNum = i;
		}
	}

	return maxNum;
}


int main()
{
	std::string str;

	//while(1){
		getline(std::cin,str);

		if(std::cin.eof())
		{
			exit(1);
		}

		std::stringstream ss;

		std::vector<std::string> word;

		ss << str;

		std::string hoge;

		for(; !(ss.eof());)
		{
			ss >> hoge;

			word.push_back(hoge);
		}

		std::sort(word.begin(),word.end());

		std::string temp = "";

		std::vector<WordRanking> rankFriq;

		for(size_t i=0; i<word.size(); ++i)
		{
			if(temp != word[i])
			{
				rankFriq.push_back(WordRanking(word[i],1));
			}
			else
			{
				++rankFriq[rankFriq.size()-1].m_count;
			}

			temp = word[i]; 
		}

		std::vector<WordRanking> rankLength;

		for(size_t i=0; i<word.size(); ++i)
		{
			rankLength.push_back(WordRanking(word[i],word[i].length()));
		}

		std::cout << rankFriq[MaxNum(rankFriq)].m_word << ' ' << rankLength[MaxNum(rankLength)].m_word << '\n';
		
	//}
}

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;
		} // end if
	} // end while
		
	return 0;
}

C++: #include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit atof atoi 
#include <cstdio>		// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>		// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>		// require srand
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

int main()
{
//	cut here before submit 
//	freopen ("testcase.ES", "r", stdin );
	string str = "";
	map<string, int> words; words.clear();
	int max_len = 0;
	int max_freq = 0;
	while (getline (cin, str ) ){

		int n = str.length();
		rep (i, n ){
			if (isalpha (str[i] ) )
				str[i] = tolower(str[i] );
		} // end rep

		string s = "";
		stringstream ss (str );
		while (ss >> s ){
			max_len = max (max_len, (int)s.length() );
			words[s]++;
			max_freq = max (max_freq, words[s] );
		} // end while
	} // end while
	map<string,int>::iterator it = words.begin();
	string res_f = "", res_l = "";
	for (; it != words.end(); it++ ){
		string w = (*it).first;
		int cnt = (*it).second;
		if (cnt == max_freq ){
			res_f = w;
		} // end if
		if (w.length() == max_len ){
			res_l = w;
		} // end if
	} // end for
	cout << res_f << ' ' << res_l << endl;

	return 0;
}

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

map <string, int> dic;

string lowerword(string word){
    for (int i=0; i<(int)word.size(); i++)
        word[i] = tolower(word[i]);
    return word;
}

int main(void){
	string s;

	while (cin>>s) dic[lowerword(s)]++;

	int l=0, m=0, tmp;
	string w1, w2;
	for (auto &x: dic){
		tmp = x.second;
		if (tmp>m){
			m = tmp;
			w1 = x.first;
		}
		tmp = x.first.size();
		if (tmp>l){
			l = tmp;
			w2 = x.first;
		}
	}
	cout<<w1<<" "<<w2<<endl;
	return 0;
}

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

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

  while(cin >> buf, buf.length() != 0){
    bool f = true;

    if(max < buf.length()){
      max = buf.length();
      maxstr.append(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[i] << ' ' << maxstr << endl;

  return 0;
}

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