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

C++: #include<iostream>
#include<algorithm>
using namespace std;
main(){
	string str[33],tmp;
	int data[33];
	for(int i=0;i<=33;++i)data[i]=0;
	int k=0;
	while(cin>>tmp){
		//if(tmp=="nil")break;
		for(int i=0;i<=k;++i){
			if(str[i]==tmp){
				data[i]++;
				break;
			}
			if(i==k){
				str[i]=tmp;
				data[i]++;
				++k;
				break;
			}
		}
	}
	string a;
	int ans[2]={0,0};
	for(int i=0;i<=k;++i){
		if(data[i]>data[ans[0]]){
			ans[1]=data[i];
			ans[0]=i;
		}
	}
	a=str[ans[0]];
	ans[0]=ans[1]=0;
	for(int i=0;i<=k;++i){
		if(ans[1]<str[i].size()){
			ans[1]=str[i].size();
			ans[0]=i;
		}
	}
	cout<<a<<" "<<str[ans[0]]<<endl;
	
}

C++: #include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <set>
#include <queue>
#include <cstring>
#include <climits>
#include <cmath>
#include <cfloat>

using namespace std;

multiset<string> se;
string mast = "";
string manumst = "";
int manum = 0;

int main()
{
	string str;
	
	while( cin >> str, !cin.eof())
	{
		
		if( mast.size() < str.size() )
			mast = str;
		
		se.insert(str);
		if( se.count(str) > manum )
		{
			manum = se.count(str);
			manumst = str;
		}
	}
	
	cout << manumst << " " << mast << endl;
	
	
	return 0;
}