Go: package main

import (
	"bufio"
	"os"
	"strings"
	"fmt"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	words := strings.Split(scanner.Text(), " ")
	wordMap := make(map[string]int)
	for _, v := range words {
		wordMap[v]++
	}
	key := ""
	value := -1
	l := -1
	word := ""
	for k, v := range wordMap {
		// fmt.Println(k, v)
		if value < v {
			key = k
			value = v
		}
		if l < len(k) {
			l = len(k)
			word = k
		}
	}

	fmt.Println(key, word)
	// fmt.Println(wordMap)
}

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