Go: package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	words := strings.Split(scanner.Text(), " ")
	wordMap := make(map[string]int)
	for _, v := range words {
		wordMap[v]++
	}
	key := ""
	value := -1
	l := -1
	word := ""
	for k, v := range wordMap {
		// fmt.Println(k, v)
		if value < v {
			key = k
			value = v
		}
		if l < len(k) {
			l = len(k)
			word = k
		}
	}

	fmt.Println(key, word)
	// fmt.Println(wordMap)
}

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

using namespace std;

struct WordCount{
  string word;
  int count;
};

void PushWordCount(const vector<string>, vector<WordCount>&);
vector<string> split(string);
bool space(char);
bool not_space(char);

int main(){
  int max=0, longest=0;
  string s, Max, Longest;
  vector<string> str;
  vector<WordCount> data;

  getline(cin, s);
  str = split(s);
  PushWordCount(str, data);

  for(vector<WordCount>::size_type i=0; i != data.size(); ++i){
    if(data[i].count > max){
      max = data[i].count;
      Max = data[i].word;
    }
    if(data[i].word.size() > longest){
      longest = data[i].word.size();
      Longest = data[i].word;
    }
  }

  cout << Max << " " << Longest << endl;
  return 0;
}

void PushWordCount(const vector<string> s, vector<WordCount>& words){
  int isFound;
  WordCount NewWord;
  vector<WordCount>::iterator iter;

  for(string::size_type i=0; i != s.size(); ++i){
    isFound = 0;
    iter = words.begin();
    while(iter != words.end()){
      if(iter->word == s[i]){
        ++iter->count;
        break;
      }
      ++iter;
    }
    if(isFound == 0){
      NewWord.word = s[i];
      NewWord.count = 1;
      words.push_back(NewWord);
    }
  }
}

vector<string> split(string str){
  string _str;
  vector<string> Str;
  string::iterator i, j;

  j = str.begin();
  while(i < str.end() || j < str.end()){
    i = find_if(j, str.end(), not_space);
    j = find_if(i, str.end(), space);
    copy(i, j, back_inserter(_str));
    Str.push_back(_str);
    _str.clear();
  }
  return Str;
}

bool space(char c){
  return (isspace(c));
}

bool not_space(char c){
  return (!isspace(c));
}

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;
    // table[word] を一つ増やす
    if(table[word] > N){
      N = table[word];
      frequent = word;
    }
    // table[word] がN より大きければ，N とfrequent を更新
    if(word.size() > longest.size()){
      longest = word;
    }
    // word.size() > longest.size() ならlongest を更新
  }
  cout << frequent << " " << longest << endl;
  //frequent とlongest を出力
}

C++: #include <cstdio>
#include <cstring>

using namespace std;

int main(void){
	char buf[1000][33], word[33];
	int bufnum = 0, same[1000], i, smax, lmax;
	memset(same,0,sizeof(same));
	while(scanf("%s",word) != EOF){
		for(i = 0;i < bufnum;i++){
			if(!strcmp(word,buf[i])){
				same[i]++;
				break;
			}
		}
		if(bufnum == i){
			strcpy(buf[bufnum],word);
			same[bufnum++]++;
		}
	}
	smax = 0, lmax = 0;
	for(i = 0;i < bufnum;i++){
		if(smax < same[i]){
			smax = same[i];
		}
		if(lmax < strlen(buf[i])){
			lmax = strlen(buf[i]);
		}
	}
	for(i = 0;i < bufnum;i++){
		if(smax == same[i])
			printf("%s ",buf[i]);
	}
	int cnt1 = 0, cnt2 = 0;
	for(i = 0;i < bufnum;i++){
		if(lmax == strlen(buf[i]))
			cnt1++;
	}
	for(i = 0;i < bufnum;i++){
		if(lmax == strlen(buf[i])){
			printf("%s",buf[i]);
			cnt2++;
			if(cnt1 != cnt2){
				printf(" ");
			}
		}
	}
	printf("\n");
	return 0;
}

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

int main()
{
	string str;
	vector<string> cstr;
	getline(cin, str);

	int start = 0;
	for (int i = 0; i < str.size(); ++i){
		if (str[i] == ' '){
			cstr.push_back(str.substr(start,i - start));
			start = i+1;
		}
		if (i == str.size()-1){
			cstr.push_back(str.substr(start, i - start));
			start = i + 1;
		}
	}

	int maxl = 0,maxf = 0;
	for (auto& n : cstr){
		if (maxf < count(cstr.begin(), cstr.end(),n))			maxf = count(cstr.begin(), cstr.end(), n);
		if (n.size() > maxl)													maxl = n.size();
	}

	for (auto& n : cstr){
		vector<string> outs;
		if (maxf == count(cstr.begin(), cstr.end(), n)){
			cout << n << " ";
			break;
		}
	}

	for (auto& n : cstr){
		if (n.size() == maxl)
			cout << n << endl;
	}
	return 0;
}

C++: //#define _USE_MATH_DEFINES
//#include <cmath>
#include <iostream>
//#include <stdio.h>
//#include <stdlib.h>
//#include <iomanip>
//#include <vector>
#include <string>
//#include <algorithm>
//#include <functional>
//#include <time.h>
//#include <sstream>
//#include <queue>
#include <map>

using namespace std;


int main(){

	string in;
	map  <string, int> maps;
	string longer = "";
	string mead;
	int cnt = 0;


	while (cin >> in){
		maps[in]++;
		if (maps[in] > cnt){
			cnt = maps[in];
			mead = in;
		}
		if (in.size() > longer.size())longer = in;
	}

	cout << mead << " " << longer << endl;

	return 0;
}

C++: #include <iostream>
#include <string>
#include <map>
using namespace std;
int main(){
	string str,s,mls,mcs,input[32];
	map <string,int> dic;
	int n,c,a,ml,mc;
	getline(cin,str);
		c = a = mc = ml = 0;
		str += ' ';
		while(str.length()){
			n = str.find(' ');
			s = str[c];
			++c;
			for(;c < n;++c){
				s += str[c];
			}
			str.erase(0,n+1);
			c = 0;
			input[a] = s;
			++a;
			++dic[s];
			if(s.length() > ml) {
				ml = s.length();
				mls = s;
			}
		}
		for(int i = 0;i < a;++i){
			if(mc < dic[input[i]]){
				mc = dic[input[i]];
				mcs = input[i];
			}
		
		cout << mcs << " " << mls << endl;
	}
	return 0;
}

C++: #include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

int main() {
	multimap<int,string> words;
	string str;
	string maxstr="";
	for(;cin>>str;){
		if(maxstr.size()<str.size())maxstr=str;
		multimap<int,string>::iterator it;
		bool nw=true;
		for(it=words.begin();it!=words.end();it++){
			if(it->second==str){
				words.insert(map<int,string>::value_type(it->first-1,str));
				nw=false;
break;
			}
		}
		if(nw)words.insert(map<int,string>::value_type(-1,str));
		/*for(it=words.begin();it!=words.end();it++){
			cout<<it->second<<endl;
			cout<<1<<endl;
		}*/
		//cout<<str<<endl;
	}
	cout<<words.begin()->second<<" "<<maxstr<<endl;
	return 0;
}