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<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<numeric>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<functional>

#define MP make_pair
#define PB push_back
#define ALL(x) (x).begin(),(x).end()
#define REP(i,n) for(int i=0;i<(n);i++)
#define REP1(i,n) for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n) for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))

using namespace std;

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

const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;

const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};

int main(){
	int cnt=0,tmp=0,anss1=0,anss2=0;
	string str,ans1,ans2,a;
	getline(cin,str);
	for(int i=0;i<str.size()+1;i++){
		if(str[i]==' ' || i==str.size()){
			a=str.substr(tmp,i-tmp);
			tmp=i+1;
			for(int j=0;j<str.size();j++){
				if(str.find(a,j)){
					cnt++;
				}
			}
			if(anss1<cnt){
				anss1=cnt;
				ans1=a;
			}
			if(anss2<a.length()){
				anss2=a.length();
				ans2=a;
			}
			a.clear();
		}
		cnt=0;
	}
	cout << ans1 << " " << ans2 << endl;
	return 0;
}

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

int main(){
	map<string, int> word;
	vector<string> w;
	string str;
	int max=0,length=0;

	while(cin >> str){
			
		w.push_back(str);
		
		//üÍµ½Pêª·ÅÉ é©T·
		if(word.find(str) != word.end() ){
			word[str]++;
		}else{
			word.insert( pair<string, int>(str,1));
		}
	}
	
	map<string,int>::iterator p;
	for(p = word.begin() ; p != word.end() ; p++){
		if( max < p->second) max = p->second;
	}
	for(p = word.begin() ; p != word.end() ; p++){
		if( max == p->second){
			cout << p->first << " ";
			break;
		}
	}
	for(int i=0 ; i<w.size() ; i++){
		if( length < w[i].size() ) length = w[i].size();
	}
	for(int i=0 ; i<w.size() ; i++){
		if( length==w[i].size() ){
			cout << w[i] << endl;
			break;
		}
	}
	
	return 0;
}

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

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    string str, longest="";
    map<string, int> words;
    while(cin>>str){
        if(longest.length()<str.length()) longest=str;
        if(words.find(str)==words.end()) words[str]=1;
        else ++words[str]; 
    }
    auto max = words.begin();
    for(auto it=words.begin(); it!=words.end(); ++it){
        if(max->second<it->second) max=it;
    }
    cout<<max->first<<' '<<longest<<'\n';
    return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
	string s;
	string ans = "";
	map <string ,int> mp;
	while(cin >> s){
		if(ans.size() < s.size())
			ans = s;
		mp[s]++;
	}
	int va = 0;
	string asdf;
	for(auto itr = mp.begin() ; itr != mp.end() ; itr++)
		if((*itr).second > va)
			asdf = (*itr).first;
	cout << asdf << " " << ans << endl;
}

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

char str[1100][34];
int  len[1100];
int n ;


string ans1 ="";

map<string,int> mp ;
void init_map(){
     mp.clear();
    for(int i=1;i<=n;i++){
        mp[str[i]] = 0 ;
    }
    for(int i=1;i<=n;i++){
       mp[str[i]]++;
    }
    int l =0;
    for( map<string,int>::iterator it = mp.begin();it!= mp.end();it++){
        if((it->second)>l){
	   ans1 = it->first;
	   l = it->second;
	}
    }            
}
int main(){
  int idx =1;
  while(~scanf("%s",str[idx])){
      len[idx] = strlen(str[idx]);
      idx ++;	
      
  }
   n = idx-1;
   init_map();
   cout << ans1<<" ";
    int l = 0;
    int maxidx  =0 ;
   for(int i=1;i<=n;i++){
      if(len[i]>l){
         maxidx = i;
	 l = len[i];
      }
   }
   cout << str[maxidx]<<endl;
 return 0;
}

C++: #include<iostream>
#include<vector>
#include<sstream>
#include<string>
using namespace std;
int main(){
  string str;
  getline(cin,str);
  stringstream ss(str);
  vector<string> v;
  vector<int> n;
  while(ss >> str){
    bool f=false;
    for(int i=0;i<v.size();i++){
      if(str==v[i]) {
	n[i]++;
	f=true;
      }
    }
    if(!f){
      v.push_back(str);
      n.push_back(1);
    }
  }
  str="";
  int c=0;
  for(int i=0;i<v.size();i++){
    if(c<n[i]) c=n[i];
  }
  for(int i=0;i<v.size();i++){
    if(n[i]==c) cout << v[i];
    if(str.size()<v[i].size()) str=v[i];
  }
  cout << " " << str << endl;
}

C++: #include<iostream>
#include<string>
#include<vector>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int main(){
	string s,alt="",lenm="",encm="";
	getline(cin,s);
	vector<string> vec;
	rep(i,s.size()){
		if(i==s.size()-1){
			alt+=s[i];
			vec.push_back(alt);
			alt="";
		}else if(s[i]==' '){
			vec.push_back(alt);
			alt="";
		}else alt+=s[i];
	}
	int cnt[vec.size()];
	rep(i,vec.size())cnt[i]=0;
	rep(i,vec.size()){
		if(vec[i].size()>lenm.size())lenm=vec[i];
		rep(j,vec.size()){
			if(vec[i]==vec[j])cnt[i]++;
		}
	}
	int ma=-1;
	rep(i,vec.size()){
		if(ma<cnt[i]){
			ma=cnt[i];
			encm=vec[i];
		}
	}
	cout<<encm<<" "<<lenm<<endl;
	return 0;
}

C++: #include<iostream>
#include<cstring>
#include<string>
#define MAX 1060
using namespace std;
typedef struct{
	char s[MAX];
	int sum;
} gg;
char mstr[MAX],lstr[MAX],str[MAX],pre[MAX];
int lon=0,r,gs=0,mx=0;
gg sp[MAX];
void func(int x){
	int i;
	for(i=0;i<gs;i++){
		if(strncmp(sp[i].s,&str[x],r)==0){
			sp[i].sum++;
			break;
		}
	}
	if(i==gs){
		strncpy(sp[gs].s,&str[x],r);
		sp[gs++].sum=1;
	}
	if(sp[i].sum>mx){
		mx=sp[i].sum;
		strcpy(mstr,sp[i].s);
	}
}
int lo(int x){
	int i,k=0;
	for(i=x;isalpha(str[i]);i++)
		pre[k++]=str[i];
		return i-x;
}
void solve(){
	for(int i=0;str[i]!='\0';i++){
		if(isalpha(str[i])){
			r=lo(i);
			if(r>lon){
				lon=r;
				strcpy(lstr,&str[i]);
			}
			func(i);
			i+=(r-1);
		}
	}
	
	
}
int main(){
	cin.getline(str,MAX);
		solve();
		cout<<mstr<<' '<<lstr<<endl;
	
	return 0;
}

C++: #include <utility>
#include <iostream>
#include <unordered_map>



int main()
{
    using map_type = std::unordered_map< std::string, int > ;
    map_type map ;

    std::string longest_word ;

    std::string word ;
    while ( std::cin >> word )
    {
        ++map[word] ;
        if ( longest_word.size() < word.size() )
        {
            longest_word = word ;
        }
    }

    std::pair< map_type::key_type, map_type::mapped_type> most_frequent_word ;
    for ( auto && elem : map )
    {
        if ( most_frequent_word.second < elem.second )
        {
            most_frequent_word = elem ;
            
        }
    }

    std::cout << most_frequent_word.first << ' ' << longest_word << '\n' ;
    
}