Go: package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Scan()
	l := sc.Text()
	words := strings.Split(l, " ")

	frequency := map[string]int{}
	long := map[string]int{}
	var maxFrequency, longest int
	var frequentWord, longestWord string
	for _, w := range words {
		frequency[w]++
		long[w] = len(w)
		if frequency[w] > maxFrequency {
			maxFrequency = frequency[w]
			frequentWord = w
		}
		if len(w) > longest {
			longest = long[w]
			longestWord = w
		}
	}

	fmt.Println(frequentWord + " " + longestWord)
}

C++: #define scanf_s scanf
#define gets_s gets
#include <stdio.h>
#include <string>
#include <iostream>
#include <math.h>
using namespace std;
#define MAX 1001
#define MIN -100001
#define _MAX 100
int main(void)
{
	int x, max = 0, max_n = 0, cou = 0, word_num[MAX / 2] = { 0 }, m_i, m_j;
	string word[MAX / 2];
	char str[MAX];
	gets_s(str);
	for (int i = 0; str[i] != '\0'; ++i) {
		for (int j = 0; str[i] != ' '; ++j, ++i) {
			word[cou][j] = str[i];
		}
		++cou;
	}
	for (int i = 0; i < cou; ++i) {
		if (word[i].size > max) {
			max = word[i].size; m_i = i;
		}
		for (int j = 0; j < i; ++j) {
			if (word[i] == word[j]) {
				++word_num[j];
				if (word_num[j] > max_n) { max_n = word_num[j]; m_j = j; }
			}
		}
	}
	cout << word[m_i] << " " << word[m_j] << "\n";
}

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

int main()
{
    string field;
    map<string, int> mp;
    string frequently_word;
    string max_num_word;
    int freq_count = 0;
    int max_letter_num = 0;

    while (cin >> field)
    {
        /* store the word which has the maximum number */
        if(field.size() > max_letter_num)
        {
            max_num_word = field;
        }
        /* search the word from map */
        if(mp.count(field)) 
        {
            mp[field]++; 
        }
        else
        {
            mp[field] = 1;
        }
 
    }
    /* get the most frequently word */
    for(auto itr = mp.begin(); itr != mp.end(); ++itr)
    {
        if(itr->second > freq_count)
        {
            frequently_word = itr->first;
        }
    }
    cout << frequently_word << " " << max_num_word << endl;

    return 0;
}

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

using namespace std;

int main() {
    int maxlen = 0, maxcount = 0;
    string s, lens, counts;
    map<string, int> mp;
    while (cin >> s) {
        if (maxlen < s.size()) {
            maxlen = s.size();
            lens = s;
        }
        mp[s]++;
        if (maxcount < mp[s]) {
            maxcount = mp[s];
            counts = s;
        }
    }
    cout << counts << " " << lens << endl;
    
    return 0;
}

C++: #include <iostream>
#include <cstring>
#include <sstream>
#include <vector>
using namespace std;

int main(void) {
  string str;   // 入力される原文
  getline(cin, str);
  stringstream sstr(str);  // sstrをstrで初期化
  vector<string> word;   // 出てきた単語を重複しないように保持するためのvecor
  vector<int> count;   // 出てきた単語の回数を保持するためのvector
  bool check;   // 出てきた単語が既出かどうかを判断するためのbool
  
  while(sstr >> str) {   // sstrからstrに単語ごとに代入される。strは毎回リセットされる。
    check = false;
    for(int i = 0; i < word.size(); ++i) {
      if(str == word[i]) {
        ++count[i];
        check = true;
      }
    }
    if(! check) {
      word.push_back(str);
      count.push_back(1);
    }
  }
  
  int often = 0;
  for(int i = 0; i < count.size(); ++i) {
    if(count[often] < count[i]) {
      often = i;
    }
  }
  cout << word[often] << " ";
  
  string longest = "";
  for(int i = 0; i < word.size(); ++i) {
    if(longest.size() < word[i].size()) {
      longest = word[i];
    }
  }
  cout << longest << endl;
}

C++: 
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<vector>
#include<functional>
#include<cmath>
#include<map>
#include<stack>
#include<set>
#include<numeric>
#include<limits>
#include<iterator>
#include<iterator>

#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define rep(i,n) for(int i=0; i<n; i++)
#define INF (1<<20)

using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ll, char> plc;

map<string, int> table;

int main()
{
	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;
	return 0;
}

C++: #define _CRT_SECURE_NO_WARNINGS
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#define int ll
//#define endl "\n"
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
#define all(c) (c).begin(), (c).end()
#define loop(i,a,b) for(ll i=a; i<ll(b); i++)
#define rep(i,b) loop(i,0,b)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
template<class T> ostream & operator<<(ostream & os, vector<T> const &);
template<int n, class...T> typename enable_if<(n>=sizeof...(T))>::type _ot(ostream &, tuple<T...> const &){}
template<int n, class...T> typename enable_if<(n< sizeof...(T))>::type _ot(ostream & os, tuple<T...> const & t){ os << (n==0?"":" ") << get<n>(t); _ot<n+1>(os, t); }
template<class...T> ostream & operator<<(ostream & os, tuple<T...> const & t){ _ot<0>(os, t); return os; }
template<class T, class U> ostream & operator<<(ostream & os, pair<T,U> const & p){ return os << "(" << p.first << ", " << p.second << ") "; }
template<class T> ostream & operator<<(ostream & os, vector<T> const & v){ rep(i,v.size()) os << v[i] << (i+1==(int)v.size()?"":" "); return os; }
template<class T> inline bool chmax(T & x, T const & y){ return x<y ? x=y,true : false; }
template<class T> inline bool chmin(T & x, T const & y){ return x>y ? x=y,true : false; }
#ifdef DEBUG
#define dump(...) (cerr<<#__VA_ARGS__<<" = "<<mt(__VA_ARGS__)<<" ["<<__LINE__<<"]"<<endl)
#else
#define dump(...)
#endif
// ll const mod = 1000000007;
// ll const inf = 1LL<<60;

/*
  ch は小さいほうが良い
 */

struct Trie {
    int ctoi(char c){
        return isupper(c) ? c-'A' : c-'a'+26;
    }
    struct Node {
        int val;
        Node * ch[26*2];
        Node() : val(0) {
            for(auto & p : ch) p = nullptr;
        }
        ~Node(){
            for(auto & p : ch) if(p != nullptr) delete p;
        }
    };
    Node *r;

    Node* insert(string const &s){
        auto p = s.begin();
        auto cur = r;
        while(1){
            if(p == s.end()){
                return cur;
            } else {
                auto &nxt = cur->ch[ctoi(*p)];
                if(nxt == nullptr) nxt = new Node();
                cur = nxt;
                ++p;
            }
        }
    }
    bool erase(string const &s){
        auto p = s.begin();
        auto cur = r;
        while(1){
            if(p == s.end()) return cur->val > 0 ? (cur->val--, true) : false;
            auto &nxt = cur->ch[ctoi(*p)];
            if(nxt == nullptr) return false;
            cur = nxt;
            ++p;
        }
    }
    Node* find(string const& s){
        auto p = s.begin();
        auto cur = r;
        while(1){
            if(p == s.end()) return cur;
            auto &nxt = cur->ch[ctoi(*p)];
            if(nxt == nullptr) return nullptr;
            cur = nxt;
            ++p;
        }
    }
    Trie() : r(new Node()) {}
    ~Trie() { delete r; }
};

int main(){
    Trie t;
    string s;
    string freq;
    string aaa;
    int freq_c = 0;
    while(cin >> s){
        auto res = t.find(s);
        Trie::Node * p = res ? res : t.insert(s);
        p->val++;
        if(freq_c < p->val){
            freq = s;
            freq_c = p->val;
        }
        if(aaa.size() < s.size()){
            aaa = s;
        }
    }
    cout << freq << " " << aaa << endl;
}