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<iostream>
#include<string>
#include<map>
 
using namespace std;
 
int main( ){
    string l;
    int t=0;
    string max="???";
    map<string,int> str;
    string s;
    while(cin>>s){
      if(s.length()>max.length())max=s;
        str[s]++;
        if(str[s]>t){
           t=str[s];
           l=s;
            }
    }
    cout<<l<<" "<<max<<endl;
    return 0;
}

C++: #include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<queue>
#include<stack>
#include<complex>
#include<utility>
#include<cmath>
#include<map>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define pi acos(-1)
#define all(v) v.begin(),v.end()
using namespace std;

const double eps = 1e-8;
const double INF = 1e12;

typedef pair<int,int> P;
typedef double Real;
typedef complex<Real> Point;
typedef vector<Point> G;

double cross(const Point& a,const Point& b){//calculate ad-bc(vector product)
	return imag(conj(a)*b);
}

struct L:public vector<Point>{//line data
	L(const Point &a,const Point &b){
		push_back(a);
		push_back(b);
	}
};


int main(){
	string s;
	getline(cin,s);
	int count=0;
	map<string,int> mp;
	vector<string> vec;
	string lenmax="";
	rep(i,s.size()+1){
		if(i==s.size()){
			string sub=s.substr(count,i+1-count);
			count=i+1;
			vec.push_back(sub);
			mp[sub]=0;
			if(lenmax.size()<sub.size()){
				lenmax=sub;
			}
		}else if(s[i]==' '){
			string sub=s.substr(count,i-count);
			count=i+1;
			vec.push_back(sub);
			mp[sub]=0;
			if(lenmax.size()<sub.size()){
				lenmax=sub;
			}
		}
	}
	rep(i,vec.size()){
		mp[vec[i]]++;
	}
	string fremax="";
	rep(i,vec.size()){
		if(mp[vec[i]]>mp[fremax]){
			fremax=vec[i];
		}
	}
	cout<<fremax<<" "<<lenmax<<endl;
	return 0;
}

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

using namespace std;

map<string, int> cnt;
string ans[2];
int num_max;
int main() {
    string str;
    while (cin >> str) {
        cnt[str]++;
    }

    for (auto e : cnt) {
        if (num_max < e.second) {
            ans[0] = e.first;
            num_max = e.second;
        }
        if (ans[1].size() < e.first.size()) {
            ans[1] = e.first;
        }
    }
    cout << ans[0] << " " << ans[1] << endl;
}

C++: #include <iostream>
#include <string>
#include <map>
using namespace std;
int main(){
      string s,nmax,gmax;
      map<string,int> m;
      map<string,int>::iterator it;
      int nm=-1,gm=-1;
      while(cin>>s){
            if(nm<(int)s.length()){
                  nm = (int)s.length();
                  nmax = s;
            }
            if(m.count(s))m[s]++;
            else m[s]=0;
      }
      for(it = m.begin();it!=m.end();it++){
            if(gm<it->second){
                  gm = it->second;
                  gmax = it->first;
            }
      }
      cout <<gmax<<' '<<nmax<<endl;
}

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

using namespace std;

int main() {

  string buf;
  
  string str;

  map<string,int> word;
  string max_frequent_str;
  string max_letters_str;
  int max_frequent;
  int max_letters;

  
  max_letters=0;

  while(cin >> str) {
    
    if(str.length()>max_letters) max_letters=str.length();

    word[str]++;

  }
  
  max_frequent=0;

  for(map<string,int>::iterator it=word.begin();it!=word.end();it++) {

    if(max_frequent<(*it).second) {

      max_frequent=(*it).second;
      max_frequent_str=(*it).first;

    }

    if((*it).first.length()==max_letters) max_letters_str=(*it).first;

  }

  cout << max_frequent_str << " " << max_letters_str << endl;

  return 0;

}

C++: #include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <stack>
#include <functional>
#include <queue>
#include <cmath>

#define rep(i,j,k) for(int i=j;i<k;i++)
#define drep(n,m) for(int i=0;i<n;i++)for(int j=0;j<m;j++)
#define fi first
#define se second
#define vi vector<int>
#define INF 1000000000
#define MOD 1000000009
#define pb push_back
#define mp make_pair
typedef long long ll;
int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

using namespace std;

ll gcd(ll a,ll b){
    if(a<b){
        int t=a;a=b;b=t;
    }
    int c=a%b;
    while(c!=0){
        a=b;
        b=c;
        c=a%b;
    }
    return b;
}

ll lcm(ll a,ll b){
    return a*b/gcd(a,b);
}

bool isPrime(int x){
    if(x==1)return false;
    if(x==2)return true;
    if(x%2==0)return false;
    for(int i=3;i<=sqrt(x);i+=2){
        if(x%i==0)return false;
    }
    return true;
}

int main() {
    string s;
    vector<pair<string,int>> v;
    string ma="";
    for(int i=0;cin>>s;i++){
        if(ma.length()<s.length())ma=s;
        
        if(i==0)v.pb(mp(s,1));
        else {
            bool f=true;
            rep(j,0,v.size()){
                if(v[j].fi==s){
                    f=false;
                    v[j].se++;
                    break;
                }
            }
            if(f)v.pb(mp(s,1));
        }
    }
    
    string ans;
    int temp=0;
    rep(i,0,v.size()){
        if(temp<v[i].se){
            ans=v[i].fi;
            temp=v[i].se;
        }
    }
    cout<<ans<<" "<<ma<<endl;
    
  
    return 0;
}

C++: #include <bits/stdc++.h> //biblioteka kotoraya vkluchaet vse v sebe

using namespace std;

int main(){

 freopen("input.txt", "r", stdin);
 string x;
 string winner;
 string winner1;
 map<string,int> m;
 map<string,int>:: iterator it;
 while(cin>>x){
  m[x]++;
  if(winner.size()<x.size()){
   winner=x;
  }
 }
 for(it=m.begin();it!=m.end();it++){
  int mval = INT_MIN; 
  if (mval < (*it).second)
   mval = (*it).second;
   winner1 = (*it).first;
 }

 cout << winner1 << " " << winner;


 return 0;
}