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<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define INF 1000000
using namespace std;
typedef pair<int,string> P;;
int main(){
    string str;
    getline(cin,str);
    vector<P> ans(1000);
    bool flag = true;
    int tmp_first = 0,tmp_end = 0,pos = 0;
    rep(i,str.size()){
        if(str[i] == ' ' || i == str.size()-1) {
            string tmp = str.substr(tmp_first,tmp_end);
            ans[pos].first = tmp.size();
            ans[pos].second = tmp;
            flag = true;
            pos++;
            tmp_end = 0;
        }
        else {
            if(flag == true){
                tmp_first = i;
                flag = false;
            }
        }
        tmp_end++;
    }
    int cnt1 = 0;
    int cnt2 = 0;
    string str_ans1,str_ans2;
    rep(i,pos) {
        int tmp_cnt = 0;
        rep(j,pos) {
            if(ans[i].second == ans[j].second) tmp_cnt++;
        }
        if(tmp_cnt > cnt1) {
            cnt1 = tmp_cnt;
            str_ans1 = ans[i].second;
        }
        //cout << ans[i].second << " " << ans[i].first  << endl;
        if(ans[i].first > cnt2){
            cnt2 = ans[i].first;
            str_ans2 = ans[i].second;
        }
    }
    cout << str_ans1 << " " << str_ans2 << endl;
    return 0;
}

C++: #include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<map>

using namespace std ;

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl

#define rep(i,n) for(int i = 0; i < (n);++i)
#define repc(i,a,b) for(int i = (a);i <(b);++i)
#define repa(n,array) for(auto n :(array))

long long typedef ll ;
typedef vector<int> vi ;
typedef vector<ll> vl ;
template<class Value>
using dict = std::map< string, Value >;

constexpr int IMAX = ((1<<30)-1)*2+1 ;
constexpr int INF = 100000000;
double EPS = 1e-10 ;

typedef const pair<string, int> PSI;
bool cmpCount(PSI &T1, PSI &T2) {
    return T1.second < T2.second;
}

bool cmpLength(PSI &T1, PSI &T2) {
    return T1.first.length() < T2.first.length();
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string str ;
  dict<int> M;
  while(cin >> str){
    if(M.count(str) == 0){
      M[str] = 0 ;
    }
    else{
      auto it = M.find(str) ;
      ++it->se ;
    }
  }
  PSI maxCount = *max_element(M.begin(), M.end(), cmpCount);
  PSI maxLength = *max_element(M.begin(), M.end(), cmpLength);

  cout << maxCount.first << " " << maxLength.first << endl;
  return 0;
}

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

#define REP(i, n) for(int i = 0; i < n; i++)
using namespace std;

int main()
{   
    string s, res, res2;
    int s_max, cnt = 0;
    map<string, int> mp;

    while (cin >> s) {
        if (s_max < s.size()) {
            s_max = s.size();
            res = s;
        }

        mp[s]++;
    }

    for (const auto &x: mp) {
        if (cnt < x.second) {
            cnt = x.second;
            res2 = x.first;
        }
    }

    cout << res2 << " " << res << endl;
    
}

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

map<string,int> table;

int main()
{
	string word, frequent, longest;
	size_t 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++: /*
 *	
 *	Created by Ziyi Tang
 *
 */

#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
using namespace std;
#define INF 1E18
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
typedef vector<vpi> vvpi;
const int dir[4][2] = {{1,0},{-1,0},{0,1},{0,-1}};

map<string,int> freq;
string maxletter1;
int maxletter2 = 0;

bool comp(pair<string,int> a, pair<string,int> b){
	if (a.second > b.second){
		return true;
	}
	else{
		return false;
	}
}
int main(){
	string tmp;
	//cin >> tmp;
	while (cin >> tmp){
		int sz = tmp.size();
		if (sz > maxletter2){
			maxletter1 = tmp;
			maxletter2 = sz;
		}
		freq[tmp] += 1;
		
	}
	auto maxfreq = min_element(freq.begin(), freq.end(), comp);
	cout << (*maxfreq).first << " " << maxletter1 << endl;

	

	return 0;
}

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


map<string,int>data;
int main(){
	
	string str;
	int ma;
	string ans1,ans2;
	while(cin>>str){
		data[str]++;
		if(ma<data[str]){
			ma=data[str];
			ans1=str;
		}
		if(ans2.size()<str.size())ans2=str;
	}
	cout<<ans1<<" "<<ans2<<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=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[t];
        }
    }
    cout<<answer<<" "<<ans<<endl;
    return 0;
}

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=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;
}