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 <map>
using namespace std;

int main(void){

  int max_size=0,max_cnt=0;
  string word,result_cnt,result_size;
  map<string , int> word_cnt;

  while(cin >> word){

    cout << word << endl;
    if(word_cnt.find(word) != word_cnt.end()){
      word_cnt[word]++;      
    }else{
      int tmp = 1;
      word_cnt.insert(make_pair(word,tmp));
    }
  }

    for (map<string,int>::iterator ite=word_cnt.begin(); ite!=word_cnt.end(); ite++){
      if(max_cnt <  ite->second){
	//max_cnt = ite->second;
	result_cnt = ite->first;
      }
      string w = ite->first;
      int w_size = w.size();
      if(max_size < w_size){
	max_size = w_size;
	result_size = ite->first;
      }
    }

    cout << result_cnt << ' ' << result_size << endl;



  return 0;
}

C++: //
//  main.cpp
//  kazane
//
//  Created by h3036136 on 2017/07/27.
//  Copyright ?? 2017??´ h3036136. All rights reserved.
#include <iostream>
#include <string>
using namespace std;
int main(){
    long saidai=0;
    //char f;
    int a=0,cnt=0,num=0,max=0,t;
    string str,tango[1000]={""},answer,ans;
    getline(cin,str);
    for(int i=0;i<str.size();i++){
        if(str[i]==' '){
            for(int j=a;j<i;j++){
                /*if(isupper(str[a])){
                    f=str[a];
                    f=f+32;
                    str[a]=f;
                }*/
                tango[cnt]+=str[j];
            }
            cnt=cnt+1;
            a=i+1;
        }
    }
    for(int p=a;p<str.size();p++){
        tango[cnt]+=str[p];
    }
    
    
    
    for(int k=0;k<=cnt;k++){
        if(saidai<tango[k].size()){
            saidai=tango[k].size();
            ans=tango[k];
        }
    }
    
    for(int s=0;s<cnt;s++){
        for(t=s+1;t<=cnt;t++){
            if(tango[s]==tango[t]){
                num=num+1;
            }
        }
        if(max<num){
            max=num;
            answer=tango[s];
        }
    }
    cout<<max<<" "<<saidai<<endl;
    cout<<answer<<" "<<ans<<endl;
    return 0;
}

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

int main(){
	// word[s] Å ¶ñsÌo»ñªÔÁÄ­é
	map<string, int> word;
	vector<string> v;
	string s;
	int max=0,length=0;

	while( cin >> s ){
		v.push_back(s);
		
		//üÍµ½Pêª·ÅÉ é©T·
		if( word.count(s) ){
			word[s]++;
		}else{
			word[s] = 1;
		}
	}
	// ÅpoÌPêð²×é
	int mode=0;
	for(int i=0 ; i < v.size() ; i++ ){
		mode = max( mode , word[ v[i] ] );
	}
	for(int i=0 ; i < v.size() ; i++ ){
		if( mode == word[ v[i] ] ){
			cout << v[i];
		}
	}
	// Å·ÌPêðßé
	int length = 0;
	for(int i=0 ; i < v.size() ; i++ ){
		length = max( length , v[i].size() );
	}
	for(int i=0 ; i < v.size() ; i++ ){
		if( length == v[i].size() ){
			cout << " " << v[i] << endl;
		}
	}
}

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

using namespace std;

string s1, s2;
int maxlen = 0, mode = 0;
map<string,int> mp;

int main()
{   
    int m = 9;
    while( cin >> s2 )
    {
        if( s2 == "\n" )break;
        mp[s2]++;
    }
    for( auto x : mp )
    {
        if( maxlen < sizeof( x.first ) )
        {
            maxlen = sizeof( x.first ); 
        } 
        if( mode < x.second )
        {
            mode = x.second;
        }
        printf( "%d", x.second );
    }

    for( auto x : mp )
    {
        if( maxlen == sizeof( x.first ) )
        {
            printf( "%s", x.first );
        }
        if( mode == x.second )
        {
            printf( "%s ", x.first );
        }
    }
    return 0;
}

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

int main()
{
	int longest=0;
	string str,tmp="",freq="";
	vector<string> strs;
	map<string,int> m;
	
	getline(cin,str);

	for(int i=0;i<str.size(); ++i){
		if((str[i] != ' ' )&&(i != str.size()-1)){
			tmp += str[i];
		}else{
			strs.push_back(tmp);
			tmp = "";
		}
	}
	
	for(int i=0;i<strs.size();++i){
		if(strs[i].size() > strs[longest].size())
			longest = i;
		
		bool flag = false;
		for(map<string,int>::iterator it = m.begin();it != m.end();++it){
			if(strs[i] == it->first){
				flag == true;
				it->second++;
			}
		}
		if(flag == false)
			m.insert(make_pair<string,int>(strs[i],0));
	}

	for(map<string,int>::iterator it = m.begin();it != m.end();++it){
		if(it->second > freq.size())
			freq = it->first;
	}
	
	cout << freq << " " << strs[longest] << endl;
	
	return 0;
}

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

#define rep(i,a,n) for(int i=a; i<n; i++)
#define repr(i,a,n) for(int i=a; i>=n; i--)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 999999999

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long int ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

int const MOD = 1000000007;

int main() {
    string s;
    multiset<string> v;

    int max_num = 0;
    int max_len = 0;

    while(cin >> s) {
        v.insert(s);
        max_num = max((int)v.count(s), max_num);
        max_len = max((int)s.length(), max_len);
    }

    for(auto x : v) {
        if(v.count(x) == max_num) cout << x << endl;
    }
    for(auto x : v) {
        if(s.length() == max_len) cout << x << endl;
    }
    return 0;
}