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++: #include<iostream>
#include<string>
#include<map>
using namespace std;

int main(){
    map<string, int> word;
    string s;
    string outen;
    string outlen;
    int maxen;
    int maxlen;
    maxen = 0;
    maxlen = 0;
    while(cin >> s){
        if(word.find(s) != word.end()){
            word[s]++;
            if(word[s] > maxen){
                outen = s;
                maxen = word[s];
            }
            if(s.size() > maxlen){
                outlen = s;
                maxlen = s.size();
            }
        }else{
            word.insert(map<string, int>::value_type(s, 1));
            if(s.size() > maxlen){
                outlen = s;
                maxlen = s.size();
            }
            if(word[s] > maxen){
                outen = s;
                maxen = word[s];
            }
        }
    }
    cout << outen << " " << outlen << endl;
    return 0;
}

C++: #include<cstdio>
#include<algorithm>
#include<vector>
#include<string>
#include<iostream>
#include<queue>
#include<map>
#include<set>
#include<complex>
#include<stack>
#include<cmath>

using namespace std;

#define reps(i,f,n) for(int i=f;i<int(n);i++)
#define rep(i,n) reps(i,0,n)


#define X real()
#define Y imag()
typedef complex<double> P;

int main(){
	
	typedef pair<int,string> pis;
	vector<pis> a;
	vector<pis> b;
	
	map<string,int> m;
	
	string str;
	while(cin>>str){
		a.push_back( pis((int)str.size(),str) );
		m[str]++;
	}
	
	map<string,int>::iterator it=m.begin();
	while(it!=m.end()){
		b.push_back(pis(-it->second,it->first));
		it++;
	}
	
	sort(a.begin(),a.end());
	sort(b.begin(),b.end());
	
	cout<<b[0].second<<endl<<a[a.size()-1].second<<endl;
	
	
}

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

using namespace std;

void solve()
{
	map<string, int> Map;
	string str;
	getline(cin, str);
	str += ' ';
	int n = str.size();
	string temp;
	string LongestWord;
	for(int i = 0; i < n; ++i)
	{
		if(str[i] == ' ')
		{
			++Map[temp];
			if(LongestWord.size() < temp.size())
			{
				LongestWord = temp;
			}
			temp.clear();
		}
		else
		{
			temp += str[i];
		}
	}
	int Max = 0;
	string FrequentWord;
	for(map<string, int>::iterator Ite = Map.begin(); Ite != Map.end(); ++Ite)
	{
		if(Max < Ite->second)
		{
			Max = Ite->second;
			FrequentWord = Ite->first;
		}
	}
	cout << FrequentWord << " " << LongestWord << endl;
}

int main()
{
	solve();
	return(0);
}

C++: #include <iostream>
#include <string>
#include <map>
using namespace std;
map<string, int> table;
int main() {
  string word, frequent, longest; // input, max frequency, and longest
  size_t N=0; // frequency of the string "frequent"
  while (cin >> word) {
    table[word] += 1;
    if (table[word] > N) {
      N = table[word];
      frequent = word;
    }
    if (word.size() > longest.size()) 
      longest = word;
  }
  cout << frequent << " " << longest << endl;
}

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

map<string, int>mp;
int main() {
	string s; getline(cin, s);
	istringstream iss(s);
	int Max = 0; string Max_st;
	while (getline(iss, s, ' ')) {
		mp[s]++;
		if (s.size() > Max) { Max = s.size(); Max_st = s; }
	}
	int MAX = 0; string MAX_st;
	for (auto i : mp) {
		if (i.second > MAX) { MAX = i.second; MAX_st = i.first; }
	}
	cout << MAX_st << ' ' << Max_st << endl;
	return 0;
}

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

int main() {
  string word,freq,longest;
  size_t N=0;
  while (cin >> word) {
    table[word] += 1;
    if (table[word]>N) {
      N = table[word];
      freq = word;
    }
    if (word.size()>longest.size())
      longest = word;
  }
  cout << freq << " " << longest << endl;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef complex<double> P;
typedef pair<int,int> pii;
#define REP(i,n) for(ll i=0;i<n;++i)
#define REPR(i,n) for(ll i=1;i<n;++i)
#define FOR(i,a,b) for(ll i=a;i<b;++i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define MOD (ll)(1e9+7)
#define ADD(a,b) a=((a)+(b))%MOD
#define FIX(a) ((a)%MOD+MOD)%MOD

int main(){
  string s;
  map<string,int> yey;
  string mxlen;
  string mostlen;
  int cnt = 0;
  while(cin){
    cin>>s;
    yey[s]++;
    if(mxlen.size() < s.size())mxlen = s;
    if(yey[s]>cnt){
      mostlen = s;
      cnt = yey[s];
    }
  }
  cout<<mostlen<<" "<<mxlen<<endl;
  return 0;
}

C++: // clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define forever for (;;)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
typedef std::pair<int, int> pii;
typedef std::vector<int> vi;
typedef std::vector<double> vd;
typedef std::vector<std::string> vs;
typedef std::vector<pii> vpii;
typedef std::vector<vi> vvi;
typedef std::vector<vpii> vvpii;
const int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
const int MOD = 1000000007;
const double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
template<typename T> std::istream &operator>>(std::istream &is, std::vector<T> &v) { rep(i,v.size()) is >> v[i]; return is; }
template<typename A, typename B> std::istream &operator>>(std::istream &is, std::pair<A, B> &p) { is >> p.first; is >> p.second; return is; }
using namespace std;
// clang-format on

main {
  vs v;
  string s;
  while (cin >> s) transform(all(s), s.begin(), ::tolower), v.push_back(s);
  map<string, int> m;
  int freq = 0, len = 0;
  string topFreq, topLen;
  rep(i, v.size()) {
    if (cmax(freq, ++m[v[i]])) topFreq = v[i];
    if (cmax(len, v[i].size())) topLen = v[i];
  }
  cout << topFreq << ' ' << topLen << endl;
}

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

int main(){
  multiset<string> words;
  string wmuch,wlong,w;
  int msize = 0,mcount=0;
  while(cin>>w){
    words.insert(w);
    if (mcount<words.count(w)){
      mcount = words.count(w);
      wmuch = w;
    }
    if (msize<w.size()){
      msize = w.size();
      wlong = w;
    }
  }
  cout << wmuch << " " << wlong << endl;
  return 0;
}

C++: #include<iostream>
#include<algorithm>
#include<string>
#include<map>
using namespace std;
int main(){
  
  string s,str1,str2;
  map<string,int> mp;

  while(cin >> s){

    if(mp.find(s) == mp.end()) mp[s] = 1;
    else mp[s]++;

    if(mp[s] > mp[str1]) str1 = s;
    if(s.size() > str2.size()) str2 = s;

  }
  
  cout << str1 << ' ' << str2 << endl;
  return (0);
}