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 <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
using namespace std;

int main() {
	string str;
	string longstr;
	string maxwordstr;
	int maxword=0;
	map<string, int> words;
	while (cin >> str) {
		if (str.size() > longstr.size()) {
			longstr = str;
		}
		auto itr = words.find(str);
		if (itr != words.end()) {
			words[str]++;
		}
		else {
			words[str] = 1;
		}
		if (maxword < words[str]) {
			maxword = words[str];
			maxwordstr = str;
		}
	}
	cout << maxwordstr << " " << longstr<<endl;
	return 0;
}

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

using namespace std;

struct word{
	char moji[32];
	int count;
};

int main(void){
	
	struct word dt[500];
	char temp[33],max[33];
	int tempC,maxC,cou;
	bool flag=true;

	memset(dt,0,sizeof(dt));
	memset(max,'\0',sizeof(max));
	
	cou=0;
	while(scanf("%s",temp)!=EOF){
		
		tempC=strlen(temp);
		maxC=strlen(max);
		
				
		if(tempC>maxC){
			strcpy(max,temp);
		}
			
		for(int i=0;i<cou+1;i++){
			if(strcmp(dt[i].moji,temp)==0){
				dt[i].count++;
				flag=false;
				break;
			}
		}
	
		if(flag){
			strcpy(dt[cou].moji,temp);	
			cou++;
		}
		flag=true;
		memset(temp,'\0',sizeof(temp));
	}
	
	//バブルソート
	for(int i=0;i<cou;i++){
		for(int j=cou;j>i;j--){
			if(dt[j-1].count<dt[j].count){
				struct word swap;
				swap=dt[j];
				dt[j]=dt[j-1];
				dt[j-1]=swap;
			}
		}
	}

	cout<<dt[0].moji<<" "<<max<<endl;
}

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

int main(){
  char s[1001];
  char word[1001][33];
  int cnt[1001],l[1001];
  char tmp[33];
  int len,pos,d,num,i,j;
  int mod,max;

  while(fgets(s,1001,stdin)){
    num = 0;
    len = strlen(s);
    pos = 0;
    while(pos<len){
      d = 0;
      while(pos+d<len && (s[pos+d]!=' ' && s[pos+d]!='\0')){
	tmp[d] = s[pos+d];
	d++;
      }
      tmp[d] = '\0';
      for(i=0;i<num;i++){
	if(d!=l[i])continue;
	for(j=0;j<l[i];j++)
	  if(tmp[j]!=word[i][j])break;
	if(j==l[i]){
	  cnt[i]++;
	  break;
	}
      }
      if(i==num){
	for(j=0;j<d;j++)word[num][j] = tmp[j];
	l[num] = d;
	cnt[num] = 0;
	num++;
      }
      pos+=d+1;
    }
    mod = 0;
    max = 0;
    for(i=1;i<num;i++){
      if(cnt[mod]<cnt[i])mod = i;
      if(l[max]<l[i])max = i;
    }
    printf("%s %s\n",word[mod],word[max]);
  }
  return 0;
}

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

using namespace std;

int main(){
  string n[1000];
  int i = 0;
  string m;

  map<string, int> M;

  while(cin >> n[i]){
    M[n[i]] += 1;
    i++;
  }


  int max = M[n[0]];
  m = n[0];

  for(int j = 1; j < i; j++){
    if(max < M[n[j]]){
      max = M[n[j]];
      m = n[j];
    }
  }
  cout << m;
  
  max = 0;
  
  for(int j = 0; j < i; j++){
    if(n[j].length() > max){
      max = n[j].length();
      m = n[j];
    }
  }
  
  cout << " " << m << endl;
  return 0;

}

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

const int INF = 1e+9 * 2;
double eps = 1e-10;

int main() {
	string s, t(""), ans_c(""), ans_s("");
	map<string, int> cnt;
	getline(cin, s);
	for(int i = 0; i < s.size(); ++i){
		if(s[i] == ' '){
			cnt[t]++;
			if(ans_s.length() < t.length())
				ans_s = t;
			t = "";
		}
		else{
			t += s[i];
		}
	}
	if(ans_s.length() < t.length())
		ans_s = t;
	int maxim = 0;
	for(auto it = cnt.begin(); it != cnt.end(); ++it){
		if(maxim < (*it).second){
			maxim = (*it).second;
			ans_c = (*it).first;
		}
	}
	cout << ans_c << " " << ans_s << endl;
	return 0;
}

C++: #include<iostream>
#include<stdio.h>
#include<math.h>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
int main(){
	int i,i1,len,len1,check,max1,memo1,max2,memo2;
	max1 = 0;
	max2 = 0;
	memo1 = 0;
	memo2 = 0;
	string t;
	vector<string> s;
	vector<int> a,u;
	for (int h = 0; h < 500; h++) {
		u.push_back(0);
	}
	while (cin >> t) {
		check = 0;
		len = s.size();
		for (i = 0; i < len; i++) {
			if (t == s[i]) {
				u[i] += 1;
				check = 1;
			}
		}
		if (check == 0) {
			s.push_back(t);
			len1 = t.size();
			a.push_back(len1);
		}
	}
	len = s.size();
	for (i1 = 0; i1 < len; i1++) {
		while (max1 < u[i1]) {
			max1 = u[i1];
			memo1 = i1;
		}
	    while (max2 < a[i1]) {
			max2 = u[i1];
			memo2 = i1;
		}
	}
	cout << s[memo1] << " " << s[memo2] << endl;
	return 0;
}

C++: #include<iostream>
#include <fstream>
#include <stdio.h>
#include <stdlib.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include<string>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<sstream>
#include<algorithm>
#include<map>
#include<complex>
using namespace std;


#define li			long long int
#define rep(i,to)	for(int i=0;i<((int)(to));i++)
#define repp(i,start,to)	for(int i=(int)(start);i<((int)(to));i++)
#define pb			push_back
#define sz(v)		((li)(v).size())
#define bgn(v)		((v).begin())
#define eend(v)		((v).end())
#define allof(v)	(v).begin(), (v).end()
#define dodp(v,n)		memset(v,(li)n,sizeof(v))
#define bit(n)		(1ll<<(li)(n))
#define mp(a,b)		make_pair(a,b)
#define rin	rep(i,n)
#define EPS 1e-10
#define ETOL 1e-8
#define MOD 1000000007
#define F first
#define S second
#define p2(a,b)		cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)		cout<<a<<"\t"<<b<<"\t"<<c<<endl

vector<string> split(const string &str, char delim){
  vector<string> res;
  size_t current = 0, found;
  while((found = str.find_first_of(delim, current)) != string::npos){
    res.push_back(string(str, current, found - current));
    current = found + 1;
  }
  res.push_back(string(str, current, str.size() - current));
  return res;
}

int main(){
	map<string,li> table;
	string sin;
	string longest="";
	getline(cin,sin);
	vector<string> ss=split(sin, ' ');
	
	rep(i,sz(ss)){
		table[ss[i]]++;
		if(sz(ss[i])>sz(longest))longest=ss[i];
	}
	
	vector<pair<li,string> > s;
	
	for(map<string, li>::iterator it=table.begin(); it!=table.end(); it++){
		s.pb(mp(it->S, (it->F)));
	}
	
	sort(allof(s) ,greater<pair<li,string> >());
	
	//rep(i,sz(s)){p2(s[i].F, s[i].S);}
	
	cout<<s[0].S<<" "<<longest<<endl;
	
	return 0;
}

C++: #include <iostream>
#include <string>
#include <map>
using namespace std;
int main( void )
{
  string s,t;
  int n=0;
  map<string,int> m;
  while( 1 ){
    cin>>s;
    if( cin.eof() ) break;
    if( m.find( s ) == m.end() ) m[s]=0;
    m[s]++;
    if( s.size() > n ){ t = s; n = s.size(); }
  }
  n=0;
  for( map<string,int>::iterator it = m.begin(); it != m.end(); ++it )
    if( it->second > n ) n = it->second;
  for( map<string,int>::iterator it = m.begin(); it != m.end(); ++it )
    if( it->second == n ) cout << it->first;
  cout << ' ' << t << endl;
  return 0;
}