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 <map>
#include <string>

using namespace std;

map<string, int> cnt;
string max_str;
int num_max;
int main() {
    string str;
    while (cin >> str) {
        cnt[str]++;
        num_max = max(num_max, cnt[str]);
        if (max_str.size() < str.size()) {
            max_str = str;
        }
    }

    for (auto e : cnt) {
        if (e.second == num_max) {
            cout << e.first << " ";
        }
    }
    cout << max_str << endl;
}

C++: #include <iostream>
#include <sstream>
#include <string>
#include <map>
using namespace std;
int main( void )
{
	map <string, int> TABLE;

	int max_length = 0;
	string max_length_word = "";
	int max_count = 0;
	string max_count_word = "";

	string text;
	string word;
	getline( cin, text );
	istringstream is( text );

	while ( is >> word )
	{
		if ( word.length() > max_length )
		{
			max_length_word = word;
			max_length = word.length();
		}

		if ( TABLE.find( word ) == TABLE.end() )
		{
			TABLE[word] = 0;
		}
		else
		{
			TABLE[word]++;
			if ( TABLE[word] > max_count )
			{
				max_count_word = word;
				max_count = TABLE[word];
			}
		}
	}

	cout << max_count_word << " " << max_length_word << endl;

	return 0;
}

C++: #include <bits/stdc++.h>
 
using namespace std;
 
/*-------------------------------*/
#define FOR(i, a, b) for(int i = (a); i < (b); i++) 
#define RFOR(i, a, b) for(int i = (b) - 1; i >= (a); i--)
#define REP(i, n) for(int i = 0; i < (n); i++)
#define RREP(i, n) for(int i = (n) - 1; i >= 0; i--)
#define all(i) (i).begin(),(i).end()
#define pb push_back
#define mp make_pair 
 
typedef long long ll;
typedef pair<int, int> pint;
typedef vector<int> vi;
typedef vector<vector<int> > vii;
typedef vector<long long> llv;
typedef vector<pint> vpint;
typedef vector<string> vs;
/*-------------------------------*/
 
int main(void)
{
  vs s;
  string a, smax;
  cin >> smax;
  while (cin >> a){
    if (a.size() > smax.size()) smax = a;
    s.pb(a);
  }

  string x = s[0];
  int bcnt = 0;
  FOR(i, 0, s.size()){
    int cnt = 0;
    FOR(j, 0, s.size()){
      if (s[i] == s[j]) cnt++;
    }
    if (i == 0) bcnt = cnt;
    if (bcnt < cnt) x = s[i];
    bcnt = cnt;
  }
  cout << x << " " << smax << endl;

  return 0;
}

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

struct DataBox
{
	int frequentCount;
	int maxLength;
	string frequentWord;
	string maxLengthWord;

	DataBox() : frequentCount(0), maxLength(0)	/* constructer */
	{
	}
};

int main(void)
{
	struct DataBox dataBox;
	string sentence;
	int count = 0;

	int maxSentenceWord = 1000;
	int maxWord = 32;
	int sentenceWordCount = 0;
	int wordCount = 0;
	string wordBox[1000];

	while(cin >> sentence)	/* input */
	{
		sentenceWordCount++;
		
		/* check */
		wordCount = (int)sentence.size();
		if(dataBox.maxLength < wordCount)
		{
			dataBox.maxLength = wordCount;
			dataBox.maxLengthWord = sentence;
		}

		wordBox[count] = sentence;
		count++;
	}

	/* check */
	int freCount = 0;
	for(int boxNum = 0; boxNum < count; boxNum++)
	{
		string str = wordBox[boxNum];
		for(int word = 0; word < count; word++)
		{
			if(str == wordBox[word])
			{
			    freCount++;
			}
			
			if(dataBox.frequentCount < freCount)
			{
				dataBox.frequentCount = freCount;
				dataBox.frequentWord = str;
			}  
		}
		freCount = 0;
	}

	cout << dataBox.frequentWord << ' ' << dataBox.maxLengthWord << endl;
	return 0;
}

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

using namespace std;

int main()
{
	map<string,int> mp;
	string s;
	while(cin>>s){
		if(mp.count(s)==0)	mp.insert(make_pair(s,1));
		else				mp.find(s)->second++;
	}
	int fmax=0,lmax=0;
	string sfmax,slmax;
	map<string,int>::iterator it;
	for(it=mp.begin();it!=mp.end();it++){
		if(fmax<it->second)			sfmax=it->first,fmax=it->second;
		if(lmax<it->first.length())	slmax=it->first,lmax=it->first.length();
	}
	cout<<sfmax<<" "<<slmax<<endl;
	return 0;
}

C++: #include<iostream>
#include<fstream>
#include<sstream>
#include<cstdio>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<algorithm>
#include<string>
#include<cmath>
#include<cstdlib>
using namespace std;

int main(){
	char mat[50];
	map<string,int> table;
	int maxi=0;
	string longest="",most="";
	while(scanf("%s",mat)!=EOF){
		string word(mat);
		table[word]++;
		if(table[word]>maxi){
			maxi = table[word];
			most = word;
		}
		if(word.size()>longest.size()){
			longest = word;
		}
	}
	cout<<most<<" "<<longest<<endl;
	return 0;
}

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

using namespace std;

int main(){
    string str, mostfind = "", mostlong = "";
    map<string, int> many;
    while(cin >> str){
        if(many[mostfind] < ++many[str]){
            mostfind = str;
        }
        if(mostlong.size() < many.size()){
            mostlong = str;
        }
    }
    cout << mostfind << " " << mostlong << "\n";
}

C++: #include <bits/stdc++.h>
using namespace std;

#define iota(i,n,b,s) for(int i=int(b);i!=int((b)+(s)*(n));i+=(s))
#define range(i,n,m) iota(i,(((n)>(m))?((n)-(m)):((m)-(n))),(n),((n)>(m)?-1:1))
#define rep(i,n) iota(i,(n),0,1)
#define loop for(;;)

#define INF (1e9)
#define EPS (1e-9)
#define cons(a,b) (make_pair(a,b))
#define car(a) (a.first)
#define cdr(a) (a.second)
#define cadr(a) (car(cdr(a)))
#define cddr(a) (cdr(cdr(a)))
#define all(a) a.begin(), a.end()
#define trace(var) cerr<<">>> "<<#var<<" = "<<var<<endl;

typedef long long Integer;
typedef double Real;
typedef vector<int> vi;
typedef vector<string> vs;
typedef map<string,int> Dictionary;
const Real PI = acos(-1);

template<class S, class T>
ostream& operator<<(ostream& os, pair<S,T> p) {
  os << '(' << car(p) << ", " << cdr(p) << ')';
  return os;
}

template<class T>
ostream& operator<<(ostream& os, vector<T> v) {
  if (v.size() == 0) {
    os << "(empty)";
    return os;
  }
  os << v[0];
  for (int i=1, len=v.size(); i<len; ++i) os << ' ' << v[i];
  return os;
}

int dx[] = { -1, 0, 1, 0 };
int dy[] = {  0, -1, 0, 1 };

int main() {

  Dictionary d;

  int freq = 0;
  string longest = "";
  int longest_length = 0;

  for (string s; cin>>s, cin;) {
    d[s]++;
    freq = max(freq, d[s]);
    if (longest_length < s.size()) {
      longest = s;
      longest_length = s.size();
    }
  }

  string most_freq;
  for (auto&p : d) {
    if (freq == cdr(p)) {
      most_freq = car(p);
      break;
    }
  }

  cout << most_freq << ' ' << longest << endl;

  return 0;
}

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

using namespace std;

int main()
{
  string s[1001], ms, fs;
  int m, c;
  for (int i = 0, m = 0; (c = getchar()) != EOF; i++){
      cin >> s[i];
      if(s[i].size() > m){
	m = s[i].size();
	ms = s[i];
      }
  }
  for(int i = 0, c = 0; i < 1001; i++){
    for(int j = i + 1; j < 1001; j++){
      if(s[i].compare(s[j]) == 0){
	int nc = 0;
	nc++;
	if(nc > c){
	  c = nc;
	  fs = s[i];
	}
      }
    }
  }
  cout << fs << " " << ms << endl;
  return 0;
}