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

using namespace std;

const int M = 33;
const int N = 3001;

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

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

void solve(char text[]) {
	int len = strlen(text);
	for (int i=0; i<len; ++i) {
		if (text[i] >= 'A' && text[i] <= 'Z') text[i] = text[i] - 'A' + 'a';
	}
	int j = 0, k = 0;
	for (int i=0; i<len; ++i) {//分解文章 
		if (text[i] != ' ') word[k][j++] = text[i];
		else {
			if (j == 0) continue;
			word[k++][j] = '\0', j = 0;
		}
	}
	if (j) word[k++][j] = '\0';
	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);
			}
			strcpy(tmp, word[i]);
		}
	}
	if (maxs < cnt) strcpy(ansm, tmp);
}

int main() {
	cin.getline(text, N, '\n');
//	while (cin.getline(text, N, '\n')) {
		solve(text);
		cout<<ansm<<" "<<ansl<<endl;
//	}
	return 0;
}

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

std::map<std::string, int> mp;

void split(const std::string &str, char sep) {
    std::stringstream ss(str);
    std::string buf;
    while ( std::getline(ss, buf, sep)  ) {
        std::transform(buf.begin(), buf.end(), buf.begin(), tolower);
        if (mp.find(buf) != mp.end()) {
            mp[buf]++;
        } else {
            mp[buf] = 1;
        }
    }
    /*
    for (std::map<std::string, int>::iterator itr=mp.begin();itr!=mp.end(); itr++) {
        std::cout << itr->first << " : " << (itr->first).length() << std::endl;
    }
    */
}

void solve() {
    int m_freq = -1;
    std::string freq, len_str;
    std::string tmp_f;
    int         tmp_s;
    int m_len  = 0;
    for (std::map<std::string, int>::iterator itr=mp.begin(); itr!=mp.end(); itr++) {
        tmp_f = itr->first;
        tmp_s = itr->second;
        if (m_freq < tmp_s) {
            m_freq = tmp_s;
            freq   = tmp_f;
        }
        // std::cout << tmp_f << " : length ... " << tmp_f.length() << std::endl;
        if (m_len < tmp_f.length()) {
            m_len   = tmp_f.length();
            len_str = tmp_f;
        }
    }
    std::cout << freq << ' ';
    std::cout << len_str << std::endl;
}

int main() {
    std::string s;
    std::getline(std::cin, s);
    split(s, ' ');
    solve();
}

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

int main(){
    map<string, int> table;
    string word,frequent, longest;
    int 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;
}

C++: #include <stdio.h>
#include <string.h>
 
int main(){
    char str[1000][50], max[50], strtemp[50], mfstr[50];
    int len = 0, len1 = 0, n=0, cnt = 0, mfreq = 0, i = 0, j = 0;

    while(scanf("%s", str[n]) != EOF){
        len = strlen(str[n]);
        if(len1 < len){
            len1 = len;
            strcpy(max, str[n]);
        }
        n++;
    }
    for(i=0; i < n; i++){
        cnt = 0;
        strcpy(strtemp, str[i]);
        for(j=0; j < n; j++){
            if(strcmp(str[j], strtemp) == 0) cnt++;
        }   
        if(mfreq < cnt){
            mfreq = cnt;
            strcpy(mfstr, strtemp);
        }
    }
     
    printf("%s %s\n", mfstr, max);
     
    return 0;
}

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

int main() {
  string text;
  map<string, int> table;
  string f_word, l_word;
  while (cin >> text) {
    table[text]++;
    if (table[text] > table[f_word])
      f_word = text;
    if (text.size() > l_word.size())
      l_word = text;
  }
  cout<<f_word<<" "<<l_word<<endl;
}

C++: #include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <string>
#include <algorithm>
#include <climits>
#include <utility>

#define PRINT(STR) cout << STR << endl;
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); (i)++)
#define REG(i, a, b) for (int (i) = ((int)(a)); (i) < ((int)(b)); i++)
#define ALL(V) (V).begin(), (V).end()
#define SPACE " "

typedef long long ll;

using namespace std;

int nextInt() { int n = -1; cin >> n; return n; }
double nextDouble() { double d = -1; cin >> d; return d; }
ll nextll() { ll n = -1; cin >> n; return n; }
string nextString() { string str; cin >> str; return str; }

int INF = 1LL << 25;
double EPS = 1e-9;

// BEGIN //////////////////////////////////////////////////////////////
int main() {
	map<string, int> d;
	string str;
	while (cin >> str) {
		d[str]++;
	}
	int d_max = -1;
	string ans = "";
	for (auto it = d.begin(); it != d.end(); it++) {
		d_max = max(d_max, it->second);
		if (ans.size() < it->first.size()) {
			ans.assign(it->first);
		}
	}
	for (auto it = d.begin(); it != d.end(); it++) {
		if (it->second == d_max) {
			PRINT(it->first);
			break;
		}
	}
	PRINT(ans);

	return 0;
}
// END   //////////////////////////////////////////////////////////////

C++: #include<iostream>
#include<string>
#include<map>
#include<vector>
using namespace std;
template <class T>
bool find(vector<T> v, T key) {
	for (size_t i = 0; i < v.size(); i++)
		if (v[i] == key)return true;
	return false;
}
int main() {
	string s;
	getline(cin, s);
	vector<string>v;
	map<string, int>mp;
	int m = 0;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == ' ') {
			string str = s.substr(m, i - m);
			if (find(v, str))mp[str]++;
			else { v.push_back(str); mp[str] = 1; }
			m = i + 1;
		}
	}
	string str = s.substr(m, s.size() - m);
	if (find(v, str))mp[str]++;
	else { v.push_back(str); mp[str] = 1; }
	string ans1, ans2;
	int splatoon = 0;
	for (int i = 0; i < v.size(); i++) {
		if (mp[v[i]] > splatoon) { ans1 = v[i]; splatoon = mp[v[i]]; }
		if (ans2.size() < v[i].size())ans2 = v[i];
	}
	cout << ans1 << ' ' << ans2 << '\n';
	char ch; cin >> ch;
}