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>

using namespace std;

int main()
{
	char s[1000];
	int n=0;
	cin.getline(s,1000);
	string tok[1000];
	char *sep=" ,.";
	char *word;
	word = strtok(s,sep);
	while(word != NULL)
	{
		tok[n] = word;
		n++;
		word=strtok(NULL,sep);
	}
	int f=1,fmax=1;
	string max, freq;
	max=tok[0]; freq=tok[0];
	for(int i=0;i<n;i++)
	{
		if(tok[i].length()>max.length())
			max=tok[i];
		f=1;
		for(int j=i+1;j<n;j++){
			if(tok[i]==tok[j])
				f++;
		}
		if(f>fmax)
		{
			fmax=f; freq=tok[i];
		}
	}
	cout << freq <<" " <<max<<endl;
}

C++: #include <iostream>
#include <string>
#include <map>
using namespace std;
int main(){
  string s,a,b="";
  int c=0;
  map<string,int> m;
  while(cin>>s){
    if(s.length()>b.length())b=s;
    m[s]++;
  }
  map<string,int>::iterator it = m.begin();
  while(it!=m.end()){
    if((*it).second>c)c=(*it).second,a=(*it).first;
    it++;
  }
  cout<<a<<" "<<b<<endl;
  return 0;
}

C++: #include <bits/stdc++.h>
#define read() freopen("input", "r", stdin)
using namespace std;

int main(void)
{
	string s;
	map<string, int> m;

	string mx, f;
	while(cin >> s){
		m[s] += 1;

		if(s.length() > mx.length())
			mx = s;
	}

	map<string, int>::iterator it;
	int mn = 0;
	for(it = m.begin(); it != m.end(); it++)
		if(mn < it->second)
			f = it->first;

	cout << f << " " << mx << endl;

	return 0;
}

C++: #include<iostream>
#include<cstring>
#include<string>
#define MAX 1060
using namespace std;
typedef struct{
	char s[MAX];
	int sum;
} gg;
char mstr[MAX],lstr[MAX],str[MAX],pre[MAX];
int lon=0,r,gs=0,mx=0;
gg sp[MAX];
void func(int x){
	int i;
	for(i=0;i<gs;i++){
		if(strncmp(sp[i].s,&str[x],r)==0){
			sp[i].sum++;
			break;
		}
	}
	if(i==gs){
		strncpy(sp[gs].s,&str[x],r);
		sp[gs].s[r]='\0';
		sp[gs++].sum=1;
	}
	if(sp[i].sum>mx){
		mx=sp[i].sum;
		strcpy(mstr,sp[i].s);
		mstr[strlen(sp[i].s)]='\0';
	}
}
int lo(int x){
	int i;
	for(i=x;isalpha(str[i]);i++)
		;
		return i-x;
}
void solve(){
	for(int i=0;str[i]!='\0';i++){
		if(isalpha(str[i])){
			r=lo(i);
			if(r>lon){
				lon=r;
				strncpy(lstr,&str[i],r);
				lstr[r]='\0';
			}
			func(i);
			i+=(r-1);
		}
	}
}
int main(){
	while(cin.getline(str,MAX)){
		gs=0;mx=0;lon=0;
		solve();
		cout<<mstr<<' '<<lstr<<endl;
	}
	return 0;
}

C++: #include<iostream>
#include<string>
#include<algorithm>
using namespace std;
string S, T[1000], U; int sum, maxn; int k, p[1000];
int main() {
	getline(cin, S);
	S += ' ';
	for (int i = 0; i <= S.size(); i++) {
		if (S[i] == ' ') {
			if (maxn < T[sum].size()) {
				maxn = T[sum].size(); U = T[sum]; 
			}
			sum++;
		}
		else {
			T[sum] += S[i];
		}
	}
	for (int i = 0; i < sum; i++) {
		p[i] = i;
		for (int j = 0; j < i; j++) {
			if (T[i] == T[j]) {
				p[j] += 10000; break;
			}
		}
	}
	sort(p, p + sum);
	cout << T[p[sum - 1] % 10000] << ' ' << U << endl;
	return 0;
}

C++: #include <string>
#include <map>
#include <iostream>
using namespace std;
int main() 
{
	map<string,int> table;
	string word,frequent,longest;
	size_t 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;
}

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

map<string,int> table;

int main() {

	string word, frequent, longest;
	size_t N=0;

	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,l,n) for(int i=l;i<n;i++)
#define rer(i,l,n) for(int i=l;i<=n;i++)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pii;

int main(){
	map<string,int> table;
	string s,f,l;
	size_t n=0;
	while(cin>>s){
		//if(s=="0") break;
		table[s]++;
		if(table[s]>n){
			n=table[s]; f=s;
		}if(s.size()>l.size()) l=s;
	}
	o(f<<" "<<l);
}

C++: #include<iostream>
#include<string>
#include<map>
#include<cstring>
#include<cstdio>
using namespace std;
int main()
{
  map<string,int> str;
  string word;
  int big = 0;
  int cnt = 0;
  string keepword;
  string keepstr = "";
  string many = "";
  
  while(!cin.eof()){
    cin >> word;
    string kari(word);
    str[kari]++;
    
    if(cnt < str[kari]){
      cnt = str[kari];
      keepstr = kari;
    }
    
    if(big < word.size()){
      big = word.size();
      keepword = word;
    }
  }
  cout << keepstr << " " << keepword << endl;
}

C++: #include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <string>
using namespace std;

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


string t;
vector < string> st;
int s[1000]={0};
int max1=0;
int max2=0;

int main(){
	while(cin >>t){
		bool flag=true;
		int tmp = t.size();
		max1 = max(max1,tmp );
		rep(i,st.size()){
			if(t == st[i]){
				s[i]++;
				max2 = max(max2,s[i]);
				flag = false;
				break;
			}
		}
		if(flag){
			st.push_back(t);
		}
	}
	rep(i,st.size()){
		if(s[i]==max2){
			cout<<st[i]<<" ";
			break;
		}
	}
	rep(i,st.size()){
		if(st[i].size()==max1){
			cout<<st[i]<<endl;
			break;
		}
	}
	return 0;
}

C++: #include <unordered_map>
#include <iostream>
#include <algorithm>

using namespace std;

int main(){
  unordered_map<string,int> us;
  string s;
  while(cin >> s){
    us[s]++;
  }
  string ans1;
  int times = 0;
  string ans2;
  int length = 0;
  for(auto i : us){
    if(i.second > times){
      ans1 = i.first;
      times = i.second;
    }
    if(i.first.length() > length){
      ans2 = i.first;
      length = i.first.length();
    }
  }
  cout << ans1 << ' ' << ans2 << '\n';
     
}

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

using namespace std;

struct Info {
  string word;
  int length;
  int hist;
};

vector<Info> words;
vector<Info>::iterator it;

void init(string s) {
  string word;
  stringstream ss;

  for (ss << s; !ss.eof();) {
    ss >> word;
    bool flag = false;
    for (it = words.begin(); it != words.end(); it++) {
      if (it->word == word) {
        flag = true;
        it->hist += 1;
      }
    }
    if (!flag) {
      Info info = { word, word.length(), 1 };
      words.push_back(info);
    }
  }
}

string find() {
  string mode = "", max = "";
  int m1 = 0, m2 = 0;
  
  for (it = words.begin(); it != words.end(); it++) {
    if (m1 < it->hist) m1 = it->hist;
    if (m2 < it->length) m2 = it->length;
  }
  
  for (it = words.begin(); it != words.end(); it++) {
    if (m1 == it->hist) mode = it->word;
    if (m2 == it->length) max = it->word;
  }

  return mode + " " + max;
}

int main() {
  string line, r;

  getline(cin, line);
  init(line);
  r = find();

  cout << r << endl;

  return 0;
}