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 <cstdlib>
#include <cstring>
#include <iostream>

using namespace std;

const int M = 33;
const int N = 1001;

char text[N];
char word[N][M];
char tmp[M], ansm[M], ansl[M]; 

int cmp(const void *a, const void *b) {
	return strcmp((char *)a, (char *)b);
}

void solve(int k) {
	qsort(word, k, sizeof(word[0]), cmp);
	int maxs = -1;
	int cnt = 1;
	strcpy(tmp, word[0]);
	strcpy(ansl, word[0]);
	int maxl = strlen(word[0]);
	for (int i=1; i<k; ++i) {
		if (maxl < strlen(word[i])) maxl = strlen(word[i]), strcpy(ansl, word[i]);
		if (!strcmp(tmp, word[i])) ++cnt;
		else {
			if (maxs < cnt) {
				maxs = cnt;
				strcpy(ansm, tmp);
			}
			cnt = 1;
			strcpy(tmp, word[i]);
		}
	}
	if (maxs < cnt) strcpy(ansm, tmp);
}

int main() {
	int i = 0;
	while (scanf("%s", word[i++]) != EOF);
	solve(i);
	cout<<ansm<<" "<<ansl<<endl;
	return 0;
}

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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

int main() {
  string s, ml, ms;
  int maxl = 0, maxm = 0;  
  
  map<string, int> m;

  while(cin >> s) {
    if(s.size() > maxl) {
      ml = s;
      maxl = s.size();
    }

    bool b = true;
    map<string, int>::iterator it = m.begin();
    while(it != m.end()) {
      if(it->first == s) {
	it->second++;
	b = false;
	break;
      }
      it++;
    }
    if(b) m.insert(map<string, int>::value_type(s, 1));
    if(m[s] > maxm) {
      maxm = m[s];
      ms = s;
    }
  }
  cout << ms << ' ' << ml << endl;
}

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

C++: #include <bits/stdc++.h>

using namespace std;

#define int long long
#define PB push_back
#define PPB pop_back
typedef pair<int, int> pii;
static const int INF = 1LL<<61;

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);

  string ans1, ans2, in;
  map<string, int> gedo;
  while (cin >> in) {
    if (ans2.size() < in.size()) ans2 = in;
    gedo[in]++;
  }

  int tm = 0;
  for (auto it = gedo.begin(); it != gedo.end(); ++it)
    if (tm < (*it).second) ans1 = (*it).first;

  cout << ans1 << " " << ans2 << endl;

  return 0;
}

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

using namespace std;

/** Application main entry point. */
int main (
  int     argc,
  char  * argv[ ]
  )
{
  map < string, int >
    wordTable;
  string  longest = "";
  string  popular = "";
  int     freqctr = 0;

  while ( true )
  {
    string __tmp;

    if ( !( cin >> __tmp ) ) break;

    if ( wordTable.count ( __tmp ) )
    {
      wordTable[ __tmp ] = wordTable[ __tmp ] + 1;
      if ( wordTable[ __tmp ] > freqctr )
      {
        freqctr = wordTable[ __tmp ];
        popular = __tmp;
      }
    }
    else
    {
      wordTable[ __tmp ] = 1;
    }

    if ( __tmp.length ( ) > longest.length ( ) )
    {
      longest = __tmp;
    }
  }

  cout << popular << " " << longest << endl;

  return ( 0 );
}

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

bool great(const pair<string, int>& left, const pair<string, int>& right){
	return left.second > right.second;
}

int main(){
	string max = "";
	string s;
	map<string, int> m;
	vector<pair<string, int> >v;
	while (cin >> s){
		if (max.size() < s.size()) max = s;
		if (m.find(s) == m.end()) m[s] = 1;
		else m[s]++;
	}
	map<string, int>::iterator it = m.begin();
	while (it != m.end()){
		v.push_back(make_pair((*it).first, (*it).second));
		it++;
	}
	sort(v.begin(),v.end(),great);
	cout << v[0].first << " " << max << endl;
}

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;
    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[j])){
                    f=str[j];
                    f=f+32;
                    str[j]=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(int t=s+1;t<=cnt;t++){
            if(tango[s]==tango[t]){
                num=num+1;
            }
        }
        if(max<num){
            max=num;
            answer=tango[s];
        }
    }
    cout<<answer<<" "<<ans<<endl;
    return 0;
}

C++: #include <algorithm>
#include <iostream>
#include <string>
#include <unordered_map>

using namespace std;

int main()
{
    string s;
    unordered_map<string, int> m;
    string longest;
    while (cin >> s) {
        m[s] += 1;
        if (s.size() > longest.size()) {
            longest = s;
        }
    }
    cout << max_element(begin(m), end(m),
                        [](const decltype(m)::value_type& a,
                           const decltype(m)::value_type& b) {
                            return a.second < b.second;
                        })
                ->first
         << ' ' << longest << endl;
}