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<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<vector>
#include<functional>
#include<cmath>
#include<map>
#include<stack>
#include<set>
#include<numeric>
#include<limits>
#include<iterator>
#include<iterator>

#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define rep(i,n) for(int i=0; i<n; i++)
#define INF (1<<20)

using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ll, char> plc;

map<string, int> table;

int main()
{
	string word, frequent, longest="";
	int n = 0;
	while (cin >> word) {
		table[word]++;
		if (table[word] > n) {
			n = table[word];
			frequent = word;
		}
		if (word.size() > longest.size()) {
			longest = word;
		}
	}
	cout << frequent << " " << longest << endl;
	return 0;
}

C++: #define _CRT_SECURE_NO_WARNINGS
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#define int ll
//#define endl "\n"
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
#define all(c) (c).begin(), (c).end()
#define loop(i,a,b) for(ll i=a; i<ll(b); i++)
#define rep(i,b) loop(i,0,b)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
template<class T> ostream & operator<<(ostream & os, vector<T> const &);
template<int n, class...T> typename enable_if<(n>=sizeof...(T))>::type _ot(ostream &, tuple<T...> const &){}
template<int n, class...T> typename enable_if<(n< sizeof...(T))>::type _ot(ostream & os, tuple<T...> const & t){ os << (n==0?"":" ") << get<n>(t); _ot<n+1>(os, t); }
template<class...T> ostream & operator<<(ostream & os, tuple<T...> const & t){ _ot<0>(os, t); return os; }
template<class T, class U> ostream & operator<<(ostream & os, pair<T,U> const & p){ return os << "(" << p.first << ", " << p.second << ") "; }
template<class T> ostream & operator<<(ostream & os, vector<T> const & v){ rep(i,v.size()) os << v[i] << (i+1==(int)v.size()?"":" "); return os; }
template<class T> inline bool chmax(T & x, T const & y){ return x<y ? x=y,true : false; }
template<class T> inline bool chmin(T & x, T const & y){ return x>y ? x=y,true : false; }
#ifdef DEBUG
#define dump(...) (cerr<<#__VA_ARGS__<<" = "<<mt(__VA_ARGS__)<<" ["<<__LINE__<<"]"<<endl)
#else
#define dump(...)
#endif
// ll const mod = 1000000007;
// ll const inf = 1LL<<60;

/*
  ch は小さいほうが良い
 */

struct Trie {
    int ctoi(char c){
        return isupper(c) ? c-'A' : c-'a'+26;
    }
    struct Node {
        int val;
        Node * ch[26*2];
        Node() : val(0) {
            for(auto & p : ch) p = nullptr;
        }
        ~Node(){
            for(auto & p : ch) if(p != nullptr) delete p;
        }
    };
    Node *r;

    Node* insert(string const &s){
        auto p = s.begin();
        auto cur = r;
        while(1){
            if(p == s.end()){
                return cur;
            } else {
                auto &nxt = cur->ch[ctoi(*p)];
                if(nxt == nullptr) nxt = new Node();
                cur = nxt;
                ++p;
            }
        }
    }
    bool erase(string const &s){
        auto p = s.begin();
        auto cur = r;
        while(1){
            if(p == s.end()) return cur->val > 0 ? (cur->val--, true) : false;
            auto &nxt = cur->ch[ctoi(*p)];
            if(nxt == nullptr) return false;
            cur = nxt;
            ++p;
        }
    }
    Node* find(string const& s){
        auto p = s.begin();
        auto cur = r;
        while(1){
            if(p == s.end()) return cur;
            auto &nxt = cur->ch[ctoi(*p)];
            if(nxt == nullptr) return nullptr;
            cur = nxt;
            ++p;
        }
    }
    Trie() : r(new Node()) {}
    ~Trie() { delete r; }
};

int main(){
    Trie t;
    string s;
    string freq;
    string aaa;
    int freq_c = 0;
    while(cin >> s){
        auto res = t.find(s);
        Trie::Node * p = res ? res : t.insert(s);
        p->val++;
        if(freq_c < p->val){
            freq = s;
            freq_c = p->val;
        }
        if(aaa.size() < s.size()){
            aaa = s;
        }
    }
    cout << freq << " " << aaa << endl;
}

C++: #include<iostream>

int main(){
  std::string str;
  std::string maxlen;
  std::string maxocc;
  map<std::string, int> occ;
  //std::cin >> str;
  //std::cout << str << std::endl;

  std::cin >> str;
  maxlen = str;
  maxocc = str;

  while(std::cin >> str){
    if(str.size()>maxlen.size()){
      maxlen = str;
    }
    occ[str]++;
    if(occ[str]>occ[maxocc]){
      maxocc = str;
    }
  }

  std::cout << maxlen << std::endl;
}

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

#define pb         push_back
#define mp         make_pair
#define ll         long long
#define PI         acos(-1.0)
#define ALL(A)     ((A).begin(), (A).end())
#define vsort(v)   sort(v.begin(),v.end())
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)


int main(){
    int i, j, times=0;
    string tmp,maxLength,maxTimes;
    map<string, int> sentences;
    maxLength=""
    while(cin>>tmp){
        if(tmp.length()>maxLength.length()){
            maxLength=tmp;
        }
        if(sentences.count(tmp)==0){
            sentences.insert(map<string,int>::value_type(tmp,1));
        }else{
            sentences[tmp]++;
        }
        if(sentences[tmp]>times){
            times=sentences[tmp];
            maxTimes=tmp;
        }
    }
    cout << maxTimes << maxLength << endl;
}

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

using namespace std;

int main()
{
	vector<string> words;

	string str,tmp,tmpl;
	int max=0;
	int maxl=0;

	while(cin>>str)
		words.push_back(str);
	for(int i=0;i<words.size();i++){
		int c=0;
		int cl=words.at(i).size();
		for(int j=i+1;j<words.size();j++){
			if(words.at(i)==words.at(j)){
				c++;
			}
		}
		if(c>max){
			max=c;
			tmp=words.at(i);
		}
		if(cl>maxl){
			maxl=cl;
			tmpl=words.at(i);
		}
	}

	cout<<tmp<<" "<<tmpl<<endl;
	return 0;
}

C++: #include<stdio.h>
#include<string>
#include<iostream>
#include <ctype.h>




using namespace std;
struct ST{string str;int c;int z;};

int main(){

int i=0;
string str,sth,stl;
struct ST P[1001];
int max=0;
while(cin>>str){
	for(int  j=0;j<str.size();j++)
	str[j]=tolower(str[j]);
 
//	for(int j=0;j<str.size();j++)
//	str[i] = tolower( str[i] );

P[i].str=str;P[i].c=0;P[i].z=(int)str.size();
i++;
}
for(int j=0;j<i;j++)
for(int k=i-1;k>j;k--)
	if(P[k-1].str>P[k].str)
//if(P[k-1].str>P[k].str)
//if(strcmp(P[k-1].str,P[k].str)>0)
{


struct ST TEM=P[k-1];P[k-1]=P[k];P[k]=TEM;
//cout<<"*";
}

for(int j=1;j<i;j++)
{if(P[j-1].str==P[j].str)P[j].c++;

}
max=0;
for(int j=0;j<i;j++)
{if(max<P[j].c){max=P[j].c;sth=P[j].str;}}
max=0;
for(int j=0;j<i;j++)
	if(P[j].z>max){max=P[j].z;stl=P[j].str;}

cout<<sth<<" "<<stl<<endl;

//for(int j=0;j<i;j++)
//	cout<<P[j].str<<P[j].z<<endl;

return 0;
}

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

map<string,int> table;

int main(){
	string word, frequent, longest;
	int frequent_length = 0;
	while (cin >> word){
		table[word] += 1;
		if (table[word] > frequent_length){
			frequent_length = table[word];
			frequent = word;
		}
		longest = (word.size() > longest.size()) ? word : longest;
	}	
	cout << frequent << longest << endl;
}