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 <string>
#include <vector>
#include <iostream>
#include <sstream>
#include <chrono>

// ???????????????????????°????????????????§???????
typedef struct LettersInfo {
    std::string letters; // ??????
    unsigned int count; // ???????????°
} lettersInfo_s;

int main()
{
    /////////////////
    // 1. ??\????????????
    /////////////////
    std::string paramStr;
    std::getline(std::cin, paramStr);

    // ???????¨???¬????§?
    //auto start = std::chrono::system_clock::now();

    // ???????????????????????°?????????
    std::vector<lettersInfo_s*> lettersList;

    // ?????????????????????????´???????
    std::string letters;
    std::istringstream stream(paramStr);

    // ?????????????????¨????????????????£????????´???????
    unsigned int maxLength = 0;
    std::string maxLengthStr;

    ////////////////////////////////////////////////////////////////////////
    // 2. ??????????????????????????????????????????????´¢???????????????????????????????????°???????????????
    ////////////////////////////////////////////////////////////////////////
    while (std::getline(stream, letters, ' ')) {
        unsigned int len = letters.size();
        if ( len != 0) {
            // ????????????????£???¨?????????
            if ( maxLength < len ) {
                // ????????????????£??????\?????????
                maxLengthStr = letters;
                maxLength = len;
            }
            // ?????????????????¢???????????¨??????????????¢???????????§????????°???????????°????¢??????????
            unsigned int loopCount;
            for (loopCount = 0; loopCount < lettersList.size(); loopCount++) {
                if ( lettersList[loopCount]->letters == letters ) {
                    ++lettersList[loopCount]->count;
                    break;
                }
            }
            // ??°?????????????????????????????????????????°??????????????????
            if (loopCount == lettersList.size()) {
                lettersInfo_s* plettersInfo = new lettersInfo_s();
                plettersInfo->letters = letters;
                ++plettersInfo->count;
                lettersList.push_back(plettersInfo);
            }
        }
    }

    ////////////////////////////////////////
    // 3. ???????????????????????°?????????????????????????´¢
    ////////////////////////////////////////
    unsigned int maxCount = lettersList[0]->count;
    std::string maxCountStr = lettersList[0]->letters;
    for (unsigned int i = 1; i < lettersList.size(); i++) {
        unsigned int count = lettersList[i]->count;
        if (maxCount < count) {
            // ????????????????£??????\?????????
            maxCountStr = lettersList[i]->letters;;
            maxCount = count;
        }
    }

    ///////////////////////////////
    // 4. ????????????????????????????????¨???
    ///////////////////////////////
    std::cout << maxCountStr << " " << maxLengthStr << std::endl;

    // ???????¨???¬??????
    //auto end = std::chrono::system_clock::now();
    //auto dur = end - start;

    // ??????????????¨???
    //auto msec = std::chrono::duration_cast<std::chrono::milliseconds>(dur).count();
    //std::cout << msec << "[ms]" << std::endl;

    //std::getline(std::cin, paramStr);

    return 0;
}

C++: #include<iostream>
#include<string>
#include<algorithm>
using namespace std;
string S, T[1000], U; int sum, maxn; int k, p[1000];
int main() {
	getline(cin, S);
	S += ' ';
	for (int i = 0; i <= S.size(); i++) {
		if (S[i] == ' ') {
			if (maxn < T[sum].size()) {
				maxn = T[sum].size(); U = T[sum]; 
			}
			sum++;
		}
		else {
			T[sum] += S[i];
		}
	}
	for (int i = 0; i < sum; i++) {
		p[i] = i;
		for (int j = 0; j < i; j++) {
			if (T[i] == T[j]) {
				p[j] += 10000; break;
			}
		}
	}
	sort(p, p + sum);
	cout << T[p[sum - 1] % 10000] << ' ' << U;
	return 0;
}

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

using namespace std;

/** Problem0029 : English Sentence **/
int main()
{
	map<string, int> sentences;
	pair<string, int> t;
	string tmp, maxLength;
	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]++;
		}
	}
	
	t = *max_element(sentences.begin(), sentences.end());
	cout << t.first << " " << maxLength << endl;
	
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
    vector<string> s;
    string tmps;
    set<string> st;
    //int i = 0;
    size_t maxl = 0;
    while(cin >>tmps) {
        s.push_back(tmps);
        st.insert(tmps);
        //maxl = max(maxl, s.at(i).size());
        //i++;
        //cout << tmp;
    }
    
    int ans = 0, maxv = 0;
    string maxs ="";
    string maxL = "";
    for (auto ss : st) {
        int tmp = 0;
        rep(i, s.size()) {
            //int tmp = 0;
            if (ss == s.at(i)) {
                tmp++;
            }
        }
        if (maxv < tmp) {
            maxv = tmp;
            maxs = ss;
        }
        if (maxL.size() < ss.size()) {
            maxL = ss;
        }
    }

    cout << maxs << " " <<maxL << endl;
}

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
  map<string,int> a;
  string s,maxs,maxms;
  while(cin>>s){
    a[s]++;
    if(a[maxs]<a[s])maxs=s;
    if(maxms.size()<s.size()) maxms=s;
  }
  cout<<maxs<<' '<<maxms<<endl;
}

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

int main(){
  string s;
  string ansstr;
  string maxv;
  map<string, int> mp;
  while (cin >> s) {
    mp[s]++;
    maxv = mp.rbegin()->first;

    int maxstr = 0;
    for (auto x : mp) {
      if (x.first.size() >= maxstr) {
        maxstr = x.first.size();
        ansstr = x.first;
      }
    }
  }
  cout << maxv << " " << ansstr << endl;
  return 0;
}

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

int main(){
	// word[s] Å ¶ñsÌo»ñªÔÁÄ­é
	map<string, int> word;
	vector<string> v;
	string s;

	while( cin >> s ){
		v.push_back(s);
		
		//üÍµ½Pêª·ÅÉ é©T·
		if( word.count(s) ){
			word[s]++;
		}else{
			word[s] = 1;
		}
	}
	// ÅpoÌPêð²×é
	int mode=0;
	for(int i=0 ; i < v.size() ; i++ ){
		mode = max( mode , word[ v[i] ] );
	}
	for(int i=0 ; i < v.size() ; i++ ){
		if( mode == word[ v[i] ] ){
			cout << v[i];
		}
	}
	// Å·ÌPêðßé
	int length = 0;
	for(int i=0 ; i < v.size() ; i++ ){
		length = max( length , (int)v[i].size() );
	}
	for(int i=0 ; i < v.size() ; i++ ){
		if( length == v[i].size() ){
			cout << " " << v[i] << endl;
		}
	}
}