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<cstring>

using namespace std;

char moji[10000][1000] = {{0}}; int mojis = 0;

int main(void)
{
	
	int i = 0;

	int m_cnt[1000] = {0},m_cnts = 0;
	int m_cntss = 0;

	char a[10000] = {0};
	scanf("%[^\n]",a);
	int as = strlen(a);

	int m_long = 0,m_longs;
	kitune:;//kariの初期化
	char kari[10000] = {0}; int karis = 0;
	while(i < as)
	{
		if(a[i] == ' ' || i == as - 1)
		{
			if(i == as -1) kari[karis] = a[i];
			int k_flag = 0;
			for(int j = 0;j < mojis;j++)
			{
				if(strcmp(&moji[j][0],kari) == 0) 
				{
					m_cnt[j]++;
					k_flag = 1;
					break;
				}
			}

			if(k_flag == 0)
			{
				strcpy(moji[mojis],kari);
				if(m_long < strlen(moji[mojis]))
				{
					m_long = strlen(moji[mojis]);
					m_longs = mojis;
				}
				mojis++;
			}
			i++;
			goto kitune;
		}
		else
		{
			kari[karis] = a[i];
			karis++;
			i++;
		}
	}

	for(int k = 0;k < mojis;k++)
	{
		if(m_cnts < m_cnt[k])
		{
			m_cnts = m_cnt[k];
			m_cntss = k;
		}
	}

	printf("%s %s\n",&moji[m_cntss][0],&moji[m_longs][0]);
	return 0;
}

C++: #include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1'000'000'007
using ll = long long;
using namespace std;
const int INF32       = 1'050'000'000;
const long long INF64 = 4'000'000'000'000'000'000;
const int MOD7        = 1'000'000'007;
const int MOD9        = 1'000'000'009;
template <class T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

vector<string> split(string s, char remove) {
    istringstream stream(s);
    string field;
    vector<string> ans;
    while (getline(stream, field, remove)) {
        ans.emplace_back(field);
    }
    return ans;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    string s;
    getline(cin, s);

    string many, lng;
    int mxcnt = 0, lngcnt = 0;
    auto st = split(s, ' ');
    SORT(st);
    for (auto &&i : st) {
        if (chmax(mxcnt,
                  (int)(upper_bound(ALL(st), i) - lower_bound(ALL(st), i))))
            many = i;
        if (chmax(lngcnt, (int)i.size()))
            lng = i;
    }
    std::cout << many << " " << lng << '\n';

    return 0;
}

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

int main(){
    string s, longest="";
    map<string, int> mp;
    while(cin >> s){
        mp[s]++;
        if(longest.size() < s.size())
            longest = s;
    }
    int maxi=0;
    string mode="";
    for(auto e : mp){
        if(e.second > maxi){
            maxi = e.second;
            mode = e.first;
        }
    }
    cout << mode << " " << longest << endl;

    return 0;
}

C++: #include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<map>

using namespace std ;

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl

#define rep(i,n) for(int i = 0; i < (n);++i)
#define repc(i,a,b) for(int i = (a);i <(b);++i)
#define repa(n,array) for(auto n :(array))

long long typedef ll ;
typedef vector<int> vi ;
typedef vector<ll> vl ;
template<class Value>
using dict = std::map< string, Value >;

constexpr int IMAX = ((1<<30)-1)*2+1 ;
constexpr int INF = 100000000;
double EPS = 1e-10 ;

typedef const pair<string, int> PSI;
bool cmpCount(PSI &T1, PSI &T2) {
    return T1.second < T2.second;
}

bool cmpLength(PSI &T1, PSI &T2) {
    return T1.first.length() < T2.first.length();
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string str ;
  dict<int> M;
  while(cin >> str){
    if(M.count(str) == 0){
      M[str] = 0 ;
    }
    else{
      auto it = M.find(str) ;
      ++it->se ;
    }
  }
  PSI maxCount = *max_element(M.begin(), M.end(), cmpCount);
  PSI maxLength = *max_element(M.begin(), M.end(), cmpLength);

  cout << maxCount.first << " " << maxLength.first << endl;
  return 0;
}

C++: #include<cstdio>
#include<iostream>
#include<cstdlib>
#include<algorithm>
#include<string>
using namespace std;
string str[1001],s,anss,lon;
int ans,num[1001],ma,i,a;
int main(){
    while(cin>>s){
        if(ma<s.size()){
            ma=s.size();
            lon=s;
        }
        str[i]=s;
        i++;
    }
    for(int j=0;j<i;j++){
        if(num[j]!=0)continue;
        a=0;
        for(int k=j+1;k<i;k++){
            if(str[j]==str[k]){
                a++;
                num[k]=1;
            }
            if(ans<a){
                ans=a;
                anss=str[k];
            }
        }
    }
    cout<<anss<<" "<<lon<<endl;
    return 0;
}

C++: #include<iostream>
#include<map>
using namespace std;
int main(){
  map<string,int> m;
  string s;
  while(cin>>s){
    int& count = m[s];
    if(count==0) count=1;
    else count++;
  }
  int max_count=0,max_length=0;
  string max_count_s;
  string max_length_s;
  for(auto p:m){
    if(p.second>max_count){
      max_count=p.second;
      max_count_s=p.first;
    }
    if((int)p.first.size()>max_length){
      max_length=(int)p.first.size();
      max_length_s=p.first;
    }
  }
  cout << max_count_s << " " << max_length_s << "\n";
}

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

#define rep(i,a,n) for(int i=a; i<n; i++)
#define repr(i,a,n) for(int i=a; i>=n; i--)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 999999999

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long int ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

int const MOD = 1000000007;

int main() {
    string s;
    multiset<string> v;

    int max_num = 0;
    int max_len = 0;

    while(cin >> s) {
        v.insert(s);
        max_num = max((int)v.count(s), max_num);
        max_len = max((int)s.length(), max_len);
    }

    for(auto x : v) {
        if(v.count(x) == max_num) cout << x << endl;
    }
    for(auto x : v) {
        if(s.length() == max_len) cout << x << endl;
    }
    return 0;
}

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

int main() {
	ios_base::sync_with_stdio( false );

	string a;
	string b;
	map<string, int> mp;
	int x = 0;

	string s;
	while( cin >> s ) {
		mp[s] += 1;
		if( mp[s] > x ) {
			x = mp[s];
			a = s;
		}

		if( s.size() > b.size() ) {
			b = s;
		}
	}

	cout << a << ' ' << b << endl;
}