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 <string>
#include <sstream>
using namespace std;

#define SAFE_DELETE( x ){ if ( x ){ delete x; x = NULL; } }

struct tCell{
	tCell() : count( 0 ), prev( NULL ), next( NULL ){}

	int count;
	string s;
	tCell *prev, *next;
};

class Database{
public:
	Database() : size( 0 ), head( NULL ), tail( NULL ){
		head = new tCell;
		tail = new tCell;
		head->next = tail;
		tail->prev = head;
	}
	~Database(){
		init();
		SAFE_DELETE( tail );
		SAFE_DELETE( head );
	}

	void init(){
		for ( int i = size; i > 0; --i ){
			--size;
			tCell* cell = tail->prev;
			cell->prev->next = cell->next;
			cell->next->prev = cell->prev;
			SAFE_DELETE( cell );
		}
	}
	void store( string& s ){
		bool stored = false;
		tCell* cell = head;
		for ( int i = 0; i < size; ++i ){
			cell = cell->next;
			if ( cell->s == s ){
				++cell->count;
				stored = true;
				break;
			}
		}
		if ( !stored ){
			pushBack( s );
		}
	}
	string getMaxCount(){
		if ( !size ) return "";
		int c = 0;
		tCell* cell = head;
		tCell* maxc = NULL;
		for ( int i = 0; i < size; ++i ){
			cell = cell->next;
			if ( c < cell->count ){
				c = cell->count;
				maxc = cell;
			}
		}
		return maxc->s;
	}
	string getMaxCharSize(){
		if ( !size ) return "";
		unsigned c = 0;
		tCell* cell = head;
		tCell* maxc = NULL;
		for ( int i = 0; i < size; ++i ){
			cell = cell->next;
			if ( c < cell->s.size() ){
				c = cell->s.size();
				maxc = cell;
			}
		}
		return maxc->s;
	}

private:
	void pushBack( string& s ){
		++size;
		tCell* cell = new tCell;
		cell->s = s;
		++cell->count;
		cell->prev = tail->prev;
		cell->next = tail;
		cell->prev->next = cell;
		cell->next->prev = cell;
	}

	int size;
	tCell *head, *tail;
};

int main(){
	string s;
	Database db;

	getline( cin, s );

	istringstream iss( s );
	while ( !iss.eof() ){
		iss >> s;
		db.store( s );
	}

	cout << db.getMaxCount() << " " << db.getMaxCharSize() << endl;

	return 0;
}

C++: #include<iostream>
#include<cstring>
using namespace std;
struct word{
	int len;
	int num;
	char w[32];
};
int main(){
	word vo[1000];
	char vol[32];
	int k = 0,max[2]={0,0};
	while(cin>>vol){
		int i;
		for(i=0; i<k; i++){
			if(strcmp(vo[i].w,vol) == 0){
				vo[i].num++;
				break;
			}
		}
		if(i == k){
			i++;
			strcpy(vo[i].w,vol);
			vo[i].num = 1;
			vo[i].len = strlen(vo[i].w);
		}
	}
	for(int i=1; i<k; i++){
		if(vo[max[0]].len<vo[i].len){max[0] = i;}
		if(vo[max[1]].num<vo[i].num){max[1] = i;}
	}
	cout <<vo[max[1]].w<<" "<<vo[max[0]].w<<endl;
	return 0;
}

C++: #include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

int main() {
map<string,int> msi;
string s;
int ma=0;
int ma2=0;
string ans;
string ans2;
while (cin >> s,){
	if (!EXIST(msi,s))
		msi[s]=1;
	else{
		msi[s] = msi[s]+1;
		if (ma2<msi[s]){
		ans2=s;
		ma2 = msi[s];
		}
		}
	if (ma < s.length()){
	ans=s;
	ma = s.length();
	}
}
cout << ans2 << " "<<ans<<endl;
	return 0;
}

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

int main() {
	string str[1000],tmp;
	int a[1000] = {}, flag = 0, max = 1, i, length = 0, num = 0;

	while (cin >> tmp) {
		if (flag == 0) {
			flag++;
			tmp[0] = tmp[0] - 'a';
		}
		for (i = 0; i < max; i++) {
			if (tmp == str[i]){
				a[i]++;
				break;
			}
		}
		if (i == max)
			str[i] = tmp;
	}
	if (size(tmp) > length) {
		num = i;
		length = size(tmp);
	}

	cout << str[max] << " " << str[length] << endl;
	return 0;
}

C++: #include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<map>
using namespace std;
char a[1005];
int main()
{

    string b,c;
    int i,j;
    while(gets(a))
    {
        map<string,int>M;
        int len = strlen(a);
        string s;
        a[len]=' ';
        s="";
        int m = -1,g=0,gg=-1;
        j=0;
        for(i=0;i<len+1;i++)
        {
            //cout<<a[i]<<"&&"<<j<<endl;
            if(a[i]==' ')
            {
                if(M[s]==0&&s!="")
                  M[s]++;
                else M[s]++;
                //cout<<s<<"^^"<<M[s]<<endl;
                if(g>gg)
                {
                    gg=g;
                    c=s;
                    //cout<<g<<" "<<s<<endl;
                }
                if(M[s]>m)
                {
                    m=M[s];
                    b=s;
                    //cout<<m<<" ** "<<b<<endl;
                }
                s="";
                g=0;
            }
            else if((a[i]>='a'&&a[i]<='z')||(a[i]>='A'&&a[i]<='Z'))
            {
                s+=a[i];
                g++;
            }

        }

        cout<<b<<" "<<c<<endl;
    }
}

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

int main(){
    string in;
    string p,q;
    int ma=0;
    map<string,int>mp;

    while(cin>>in){
        if(in.size()>q.size())q=in;
        mp[in]++;
        if(ma<mp[in]){
            ma=mp[in];
            p=in;
        }
    }
    cout<<p<<" "<<q<<endl;
}

C++: #include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef pair<string, int> PAIR;

int main(){
	vector<PAIR> vec;
	vector<PAIR>::iterator ite;
	string st;
	while(cin >> st){
		ite = vec.begin();
		if(vec.empty()){
			vec.push_back(PAIR(st, 1));
		}else{
			while(1){
				if((*ite).first == st){
					(*ite).second++;
					break;
				}
				ite++;
				if(ite == vec.end()){
					vec.push_back(PAIR(st, 1));
					break;
				}
			}
		}

		vector<PAIR>::iterator max = vec.begin();
		vector<PAIR>::iterator mim = vec.begin();
		for(ite = vec.begin(); ite != vec.end(); ite++){
			if((*max).second < (*ite).second) max = ite;
			if((*mim).second > (*ite).second) mim = ite;
		}

		cout << (*max).first << " " << (*mim).first << endl;

	}
	return 0;
}

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

int main(void){
  map<string,int>m;
  map<string,int>::iterator it,cit,sit;
  string s;
  int maxS=0,maxC=0;
  while(cin >>s){
    m[s]+=1;
  }
  for(it=m.begin();it!=m.end();it++){
    int size=(*it).first.size();
    if(size>maxS)sit=it;maxS=size;
    int cou=(*it).second;
    if(cou>maxC)cit=it;maxC=cou;
  }
  cout <<(*cit).first <<" "<<(*sit).first<<endl;
}