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 <sstream>
#include <vector>

using namespace std;

struct Info {
  string word;
  int length;
  int hist;
};

vector<Info> words;
vector<Info>::iterator it;

void init(string s) {
  string word;
  stringstream ss;

  for (ss << s; !ss.eof();) {
    ss >> word;
    bool flag = false;
    for (it = words.begin(); it != words.end(); it++) {
      if (it->word == word) {
        flag = true;
        it->hist += 1;
      }
    }
    if (!flag) {
      Info info = { word, word.length(), 1 };
      words.push_back(info);
    }
  }
}

string find() {
  string mode = "", max = "";
  int m1 = 0, m2 = 0;
  
  for (it = words.begin(); it != words.end(); it++) {
    if (m1 < it->hist) m1 = it->hist;
    if (m2 < it->length) m2 = it->length;
  }
  
  for (it = words.begin(); it != words.end(); it++) {
    if (m1 == it->hist) mode = it->word;
    if (m2 == it->length) max = it->word;
  }

  return mode + " " + max;
}

int main() {
  string line, r;

  getline(cin, line);
  init(line);
  r = find();

  cout << r << endl;

  return 0;
}

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;
}