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<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;
		for(it=words.begin();it!=words.end();it++){
			if(it->second==str){words.insert(map<int,string>::value_type(it->first-1,str));}
			
		}
		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;
}

C++: #include <iostream>
#include <sstream>
#include <map>
using namespace std;
int main(){
  string s,S;
  int mx = 0;
  map<string,int>mp;
  getline(cin,S);
  stringstream ss(S);
  string ans2,ans1;
  while(ss >> s){
    if((int)s.size() > mx){
      mx = s.size();
      ans1 = s;
    }
    mp[s]++; 
  }

  map<string,int>::iterator it = mp.begin();
  int mx2 = 0;

  for(;it != mp.end();it++){
    if((*it).second > mx2){
      mx2 = (*it).second;
      ans2 = (*it).first;
    }
  }
  cout << ans2 << ' ' << ans1 << endl;
}

C++: #include <iostream>
#include <string>
using namespace std;
int main(){
    long saidai=0;
    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++){
                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++){
        num=1;
        for(t=s+1;t<=cnt;t++){
            if(tango[s]==tango[t]){
                num=num+1;
            }
        }
        if(max<num){
            max=num;
            answer=tango[s];
        }
    }
    
    for(int x=0;x<=cnt;x++){
        cout<<" "<<tango[x];
    }cout<<endl;
    cout<<max<<" "<<saidai<<endl;
    cout<<answer<<" "<<ans<<endl;
    return 0;
}

C++: #include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <deque>
#include <ctime>

using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define pb push_back
#define mp make_pair
#define all(r) (r).begin(),(r).end()
#define rall(r) (r).rbegin(),(r).rend()
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;
const double PI = acos(-1);

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

vector<string> split(const string& s, char c = ' '){
	vector<string> ret;
	string t; 
	stringstream ss(s);
	while(getline(ss, t, c)){
		ret.pb(t);
	}
	return ret;
}

int main(){
	string s;
	getline(cin,s);
	map<string, int> mp;
	vector<string> v = split(s);
	rep(i, v.size()){
		mp[v[i]]++;
	}
	string m, l;
	int a = 0;
	for(auto p : mp){
		if(a < p.se) m = p.fi, a = p.se;
		if(l.size() < p.fi.size()) l = p.fi;
	}
	cout<<m<<" "<<l<<endl;
}

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

int main() {
	//??£?¨?
	int most_views = 0,views=0,most_long=0,len=0;
	char tmp_sentence[1000];
	string sentence,mo_ma_word,longest_word,word="";
	vector<string> words;

	cin.getline(tmp_sentence, sizeof(tmp_sentence));
	sentence = tmp_sentence;
	for (int i = 0; i < sentence.size(); i++) {
		if (sentence[i] == ' ') { words.push_back(word); word = ""; }
		else word = word + sentence[i];
	}
	words.push_back(word);
	for (int i = 0; i < words.size(); i++) {
		for (int j = 0; j < words.size(); j++) {
			if (words[i] == words[j])views++;
		}
		if (most_views < views) {
			most_views = views;
			mo_ma_word = words[i];
		}
		views = 0;
	}
	for (int i = 0; i < words.size(); i++) {
		if (most_long < words[i].size())longest_word = words[i];
	}
	cout << mo_ma_word <<' '<<longest_word;
}

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

using namespace std;

#define REP(i,a,b) for((i)=(a);(i)<(int)(b);(i)++)
#define rep(i,n) REP(i,0,n)
// BEGIN CUT HERE
#define foreach(itr,c) for(typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
// END CUT HERE

int main(){
  int i, mlen = 0, mdeta = 0, deta = 0, len = 0, leni,j, detai;
  string str;
  vector<string> data;

  while(cin >> str) data.push_back(str);

  rep(i,data.size()){
    deta = 0;
    rep(j,data.size()){
      if(data[i] == data[j]) deta++;
      len = data[i].size();
      if(mlen < len){
        mlen = len;
        leni = i;
      }
      if(mdeta < deta){
        mdeta = deta;
        detai = i;
      }
    }
  }

  cout << data[detai] << " " << data[leni] << endl;

  return 0;
}

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

using namespace std;

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

int main()
{   
    string len_key, mode_key, s2;
    int m = 9;
    while( cin >> s2 )
    {
        mp[s2]++;
        if( mode < mp[s2] )
        {
            mode = mp[s2];
            mode_key = s2;
        }
        if( maxlen < s2.size() )
        {
            maxlen = s2.size();
            len_key = s2; 
        } 
    }

    cout << mode_key << ' ' << len_key << '\n';
    return 0;
}

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

int main(){
	int max = 0;
	string max_str;

	string str;
	vector<string> v;
	while(cin >> str){
		transform(str.begin(), str.end(), str.begin(), ::tolower);

		v.push_back(str);

		if(str.length() > max){
			max_str = str;
		}
	}
	sort(v.rbegin(), v.rend());
	cout << v[0] << " " << max_str << endl;
}