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 <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <iostream>


using namespace std;

int main()
{
	map<string, int> count;
	int m = 0;
	string first;
	string second("");
	while (!cin.eof())
	{
		string s;
		cin >> s;
		if (count.count(s) == 0)
			count.insert(make_pair(s, 1));
		else
			count.find(s)->second++;

		if (count.find(s)->second > m)
		{
			first = s;
			m = count.find(s)->second;
		}

		if (s.size() > second.size())
			second = s;
	}
	cout << first << second << endl;
	
	return 0;
}

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

using namespace std;

int main(void){
  vector<string> s;
  vector<int> cnt;
  string ss,str;
  getline(cin,str);
  string longest="";
  string max;
  int maxv=-1;
  str+=" ";
  for(int i = 0; i < str.size() ; i ++  ){
    if(str[i] == ' '){
      bool used=true;
      
      for(int j = 0 ; j < s.size() ; j ++){
	//second time
	if(s[j] == ss){
	  cnt[j]++;
	  //cout<<ss<<cnt[j]<<maxv<<endl;
	   
	  if(maxv<cnt[j]){
	    longest=ss;
	    maxv=cnt[j];
	  }
	  
	  ss="";
	  used=false;
	}
      }
      if(used){
	//first time
	s.push_back(ss);
	cnt.push_back(1);
	//cout<<ss<<cnt[cnt.size()-1]<<endl;
	/*
	if(s.size() == 1){
	  longest=ss;
	  max=ss;
	  maxv=ss.size();
	}
	//*/
	if(ss.size()>max.size())max=ss;
	ss="";
      }
      
    }else{
      ss+=str[i];
    }
    // cout<<str[i]<<endl;
  }
  cout<<longest<<" ";
  cout<<max<<endl;
  /*
  for(int i = 0 ; i < s.size() ; i ++){
    cout<<s[i]<<endl;;
  }
  cout<<endl;
  //*/
}

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

using namespace std;

typedef unsigned long long ull;
#define loop(i,a,b) for(int i=(a);i<ull(b);++i)
#define rep(i,n) loop(i,0,n)
#define all(a) (a).begin(), (a).end()

const double eps = 1e-10;
const double pi  = acos(-1.0);
const double inf = (int)1e8;

int main(){
	vector<pair<int, string> > v;
	string s;
	getline(cin, s);
	string ret = "";
	while(s.size() != 0){
		int n = 0;
		while(n < s.size() && s[n] != ' ') n++;
		string t = s.substr(0, n);
		bool b = false;
		for(int i=0; i < v.size(); i++) if(v[i].second == t){b = true; v[i].first++; break;}
		if(!b) v.push_back(make_pair(1, t));
		if(t.size() > ret.size()) ret = t;
		if(n == s.size()) break;
		s = s.substr(n+1);
	}
	sort(v.begin(), v.end(), greater<pair<int, string> >());
	cout << v[0].second << " ";
	cout << ret << endl;
}

C++: #include <iostream>
#include <iomanip>
#include <cassert>
#include <algorithm>
#include <functional>
#include <vector>
#include <string>
#include <cstring>
#include <stack>
#include <queue>
#include <map>
#include <bitset>
#include <sstream>
#include <istream>
#include <cmath>
#include <cstdio>

using namespace std;

#define vci vector<int>
#define vcs vector<string>
#define pb push_back
#define sz size()
#define mapii map<int, int>
#define mapci map<char, int>
#define mapsi map<string, int>
#define all(x) x.begin(), x.end()
#define minit(a, i) memset(a, i, sizeof(a));

#define for_(i, a, b) for (int i=(int)a; i<(int)b; i++)
#define for_d(i, a, b) for (int i=(int)a-1; i>=b; i--)
#define for_r(i, a, b, c) for (int i=(int)a; i<(int)b; i += c)
#define for_dr(i, a, b, c) for (int i=(int)a-1; i>=b; i -= c)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

typedef long long ll;

const int iINF = 2147483647;
const ll lINF = 9223372036854775807;

template <class T> inline void dbg(T t) { cout << t << endl; }


int main() {
	vcs let(1010); mapsi freq;
	int i = 0;
	while (cin>>let[i]) { freq[let[i]]++; i++; }
	
	string ret1 = "", ret2 = "";
	int mf = 0, ml = 0;
	FOR(it, freq) {
		if (mf < (*it).second) {
			mf = (*it).second; ret1 = (*it).first;
		}
		if (ml < (*it).first.sz) {
			ml = (*it).first.sz; ret2 = (*it).first;
		}
	}
	cout << ret1 << " " << ret2 << endl;

	
	return 0;
}

C++: #include <iostream>
#include <string>
#include <map>
using namespace std;
map<string, int> table;
int main() {
	string word, frequent,longest;
	size_t N = 0; /*? ? ? 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<string>
#include<map>

int main() {
	std::map<std::string, int> words;
	int maxlen = 0, maxfreq = 0;
	std::string word, letword, freqword;
	while (std::cin >> word) {
		if (maxlen < word.length()) {
			maxlen = word.length();
			letword = word;
		}
		if (words.find(word) == words.end()) {
			words[word] = 1;
		}
		else {
			words[word] += 1;
		}
		if (maxfreq < words[word]) {
			maxfreq = words[word];
			freqword = word;
		}
	}
	std::cout << freqword << " " << letword << std::endl;

	return 0;
}

C++: // 2011/07/02 Tazoe

#include <iostream>
#include <string>
#include <map>
using namespace std;

int main()
{
	string frqW = "";
	int frqM = 0;
	string lenW = "";
	int lenM = 0;

	map<string, int> frq;

	while(true){
		string wrd;
		cin >> wrd;
		if(cin.eof())
			break;

		if(frq.find(wrd)==frq.end())
			frq[wrd] = 1;
		else
			frq[wrd]++;

		if(frq[wrd]>frqM){
			frqW = wrd;
			frqM = frq[wrd];
		}

		if(wrd.size()>lenM){
			lenW = wrd;
			lenM = wrd.size();
		}
	}

	cout << frqW << ' ' << lenW << endl;

	return 0;
}

C++: #include<iostream>
#include<vector>
using namespace std;
#define rep(i,a) for(int i = 0 ; i < a ; i ++)
#define loop(i,a,b) for(int i = a ; i < b ; i ++)

int main(void){
  string s;
  string len = "";
  int aryi[32];
  string arys[32];
  int n = 0;
  rep(i,32)aryi[i] = 0;
  while(cin>>s){
    arys[n++] = s;
    if(s.size()>len.size())len=s;
  }
  int used = 0;
  int index = -1;
  rep(i,n){
    loop(j,i+1,n){
      if(arys[i] == arys[j]){
        aryi[i]++;
        if(used < aryi[i]){
          index = i;
        }
      }
    }
  }

  cout<<arys[index]<<" "<<len<<endl;

}

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


int main(){

	string s[40];
	int k=0,size_max=0,s_max=0,count_max=0,count_max_number;
	int scount[40]={0};
	
	
	
	while (cin>>s[k]){
		k++;
	}
	for (int i=0; i<k; i++) {
		for (int j=i+1; j<k; j++) {
			if (s[i]==s[j]) {
				scount[i]++;
			}
		}
	}
	
	for (int i=0; i<k; i++) {
		if (count_max<scount[i]) {
			count_max=scount[i];
			count_max_number=i;
		}
		if (size_max<s[i].size()) {
			size_max=s[i].size();
			s_max=i;
		}
	}
	
	cout << s[count_max_number] << ' '<< s[s_max] << endl;
	
	return 0;
}

C++: #pragma warning(disable:4786)  // VisualC++6.0の警告対策
#include<string>
#include<map>
#include<iostream>
#include<cstdio>

using namespace std;

int main(void){
	map<int,string>ward;

	string in,out,siz,space;
	string::size_type poi=0;
	int x,j,i=0;
	int cnt=0,data=0;
	
	space=' ';
	//mapを使って入力
	while((cin>>in)!=0){
		ward.insert(map<int,string>::value_type(i,in));
		i++;
	}
	poi=ward[i].size();
	siz=ward[i];
	for(j=0;j<i-1;j++){
		if(poi<ward[j].size()){
			poi=ward[j].size();
			siz=ward[j];
		}
		for(x=1;x<i;x++){
			if(ward[j]==ward[x])	cnt++;
		}
		if(data<cnt){
			out=ward[j];
			data=cnt;
		}
		cnt=0;
	}
	
	cout<<out<<space<<siz<<endl;

	return 0;
}