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 <fstream>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <iterator>
#include <stack>
typedef long long int lli;
using namespace std;

//1
/*
int main(){
	int hoge[5];
	int sum=0;
	for(int i=0; i<5; ++i){
		cin >> hoge[i];
		if(hoge[i]<40) hoge[i]=40;
		sum+=hoge[i];
	}
	cout << sum/5 << "\n";
	return 0;
}*/

//2
/*
int main(){
	int N,M;
	cin >> N >> M;
	vector<int> cost(N);
	vector<int> border(M);
	vector<int> pnt(N);
	for(int i=0; i<N; ++i){
		cin >> cost[i];
	}
	for(int i=0; i<M; ++i){
		cin >> border[i];
	}
	for(int i=0; i<M; ++i){
		for(int j=0; j<N; ++j){
			if(border[i]>=cost[j]){
				++pnt[j];
				break;
			}
		}
	}
	int max_p=-1;
	int ans;
	for(int i=0; i<N; ++i){
		if(pnt[i]>max_p) {
			max_p=pnt[i];
			ans=i+1;
		}
	}
	cout << ans << "\n";
	return 0;
}*/

/*
const int INF=10000000;
const int MAX_W=10000;
const int MAX_H=10000;
int dx[6]={-1,-1,0,1,1,0};
int dy[6]={0,-1,-1,0,1,1};
int H,W,N;
int maze[MAX_W+1][MAX_H+1];
int d[MAX_W+1][MAX_H+1];

int main(){
	cin >> W >> H >> N;
	vector<int> ans(N+1);
	vector<int> gx(N+1);
	vector<int> gy(N+1);
	for(int i=1; i<N+1; ++i){
		cin >> gx[i] >> gy[i];
	}
	for(int i=0; i<W+1; ++i)
		for(int j=0; j<H+1; ++j) d[i][j]=INF;
	int sx=gx[1],sy=gy[1];
	d[sx][sy]=0;
	for(int i=2; i<N+1; ++i){
		queue<int> qux;
		queue<int> quy;
		int x;
		int y;
		qux.push(sx);
		quy.push(sy);
		while(qux.size()&&quy.size()){
			//cout << "ok";
			x=qux.front();
			y=quy.front();
			qux.pop();
			quy.pop();

			if(x==gx[i]&&y==gy[i]){
				ans[i]=d[x][y];
				for(int j=0; j<W+1; ++j)
					for(int k=0; k<H+1; ++k) d[j][k]=INF;
				sx=x;
				sy=y;
				d[sx][sy]=0;
				break;
			}
			for(int j=0; j<6; ++j){
				int nx=x+dx[j],ny=y+dy[j];
				if(1<=nx&&nx<=W&&1<=ny&&ny<=H&&d[nx][ny]==INF){
					if((x<=nx&&nx<=gx[i]&&y<=ny&&ny<=gy[i])||(gx[i]<=nx&&nx<=x&&y<=ny&&ny<=gy[i])||(gx[i]<=nx&&nx<=x&&gy[i]<=ny&&ny<=y)||(x<=nx&&nx<=gx[i]&&gy[i]<=ny&&ny<=y)){
					qux.push(nx);
					quy.push(ny);
					d[nx][ny]=d[x][y]+1;
					}
				}
			}
		}
	}
	long long int ANS=0;
	for(int i=1; i<=N; ++i){
		//cout << ans[i] << "\n";
		ANS+=ans[i];
	}
	cout << ANS << "\n";
}*/

int main(){
	string word,LONG="",MAX_S;
	map<string,int> cnt;
	int MAX_I=0;
	while(cin>>word){
		if(word.size()>LONG.size()){
			LONG=word;
		}
		++cnt[word];
	}
	map<string,int>::iterator it=cnt.begin();
	for( ; it!=cnt.end(); ++it){
		if(it->second>MAX_I) {
			MAX_I=it->second;
			MAX_S=it->first;
		}
	}
	cout << MAX_S << " " << LONG << "\n";
	return 0;
}

C++: #include<iostream>
#include<map>
#include<string>
#include<stdio.h>

#include<algorithm>

using namespace std;

bool compare(const pair<string, int> T1, const pair<string, int> T2) {
	return T1.second < T2.second;
}

int main (void){

	string str,maxByLength("");
	//map<int,string> X; //¶Ì·³
	map<string,int> Y; //¶Ì
	//int mm;

	while (cin>>str){
		if (str.size()>maxByLength.size())	maxByLength=str;
		Y[str]++;
	}

	// string maxByCount("");
	// int cnt = 0;
	pair<string, int> maxCountPair = *max_element(Y.begin(), Y.end(), compare);

	// cout << (*Y.rbegin()).first << " " << maxByLength << endl;
	// cout << maxByCount << " " << maxByLength << endl;
	cout << maxCountPair.first << " " << maxByLength << endl;

	return 0;

}

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

int main(){
	string s;
	map<string,int> m;
	int maxi = 0;
	int maxu = 0;
	string ansi;
	string ansu;
	while(cin >> s){
		m[s]++;
		if(maxi < m[s]){
			maxi = m[s];
			ansi = s;
		}
		if(maxu < s.size()){
			maxu = s.size();
			ansu = s;
		}
	}
	cout << ansi << " " << ansu << endl;
	return 0;
}

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

using namespace std;

int maxlen = 0, mode = 0;
map<string,int> mp;

int main()
{   
    string len_key, mode_key, s2;
    int m = 9;
    while( cin >> s2 )
    {
        mp[s2]++;
        if( mode < mp[s2] )
        {
            mode = mp[s2];
            mode_key = s2;
        }
        if( maxlen < s2.size() )
        {
            maxlen = s2.size();
            len_key = s2; 
        } 
    }

    cout << mode_key << ' ' << len_key << '\n';
    return 0;
}

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

struct word{
	char s[32];
	int count;
	int appear;
};
struct word w[1000];
void init(int i)
{
	w[i].appear = 0;

}
void appear(int i)
{
	for(int l=0;l<i;l++){
		bool flag = false;
		if(w[i].s[0]==w[l].s[0]){
			flag = true;
			for(int m=1;m<32;m++){
				if(w[i].s[m]!=w[l].s[m])
					flag = false;
			}
		}
		if(flag)
			w[i].appear++;
	}
}
void l(int i)
{
	for(int l=0;l<32;l++){
		if(w[i].s[l] != 0)
			w[i].count++;
	}
}
int main()
{
	int i=0;
	while(cin >> w[i].s){
		init(i);
		appear(i);
		l(i);
		i++;
	}
	int remi=0,remj=0;
	for(int j=1;j<i;j++){
		if(w[j].appear>w[remi].appear)
			remi = j;
		if(w[j].count>w[remj].count)
			remj = j;
	}
	cout << w[remi].s << " " << w[remj].s << endl;
	return 0;
}

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

//#include <fstream>
int main(void)
{
	string currStr;
	string strMostFrequenty;
	string strLongest;
	map<string, int> strCount;

	//ifstream ifs("data.txt");
	istream& in=cin;

	while(!in.eof())
	{
		in >> currStr;
		if(currStr.length() > strLongest.length())
			strLongest=currStr;

		if(strCount.count(currStr)==1)
		{
			strCount[currStr]++;
			if(strCount[currStr] > strCount[strMostFrequenty])
				strMostFrequenty=currStr;
		}
		else
			strCount.insert(map<string, int>::value_type(currStr, 1));
	}

	cout << strMostFrequenty << ' ' << strLongest << endl;
	return 0;
}

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

int main() {
  map<string, int> mp;
  string s;
  while (cin >> s) {
    mp[s]++;
  }
  string frq, lng;
  for (auto& e : mp) {
    if (e.second > mp[frq]) {
      frq = e.first;
    }
    if (e.first.size() > lng.size()) {
      lng = e.first;
    }
  }
  cout << frq << " " << lng << "\n";
}

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

int main(){
  
  int cma = 0, lma = 0;
  string s, ans1, ans2;
  map<string, int> mp;
  map<string, int>::iterator it;
  
  while(cin >> s){
    cma = max(cma, ++mp[s]);
    lma = max(lma, (int)s.length());
  }
  
  for(it = mp.begin();it != mp.end();it++){
    if(it->second == cma) ans1 = it->first;
    if(it->first.length() == lma) ans2 = it->first;
  }
  
  cout << ans1 << " " << ans2 << endl;
  
  return 0;
}

C++: #include <iostream>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <map>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,b) FOR(i,0,b)
#define PB push_back
#define MP make_pair
typedef pair<double,double> P;
int main(){
  map<string,int> data;
  string s[10000];
  int cnt=0;
  while(cin>>s[cnt]){
    if(data[s[cnt]]==1)data[s[cnt]]++;
    else data[s[cnt]]=1;
    cnt++;
  }
  string ans[2];
  int m[2]={0,0};
  for(int i=0;i<cnt;i++){
    string now=s[i];
    if(now.size()>m[1]){
      ans[1]=now;
      m[1]=now.size();
    }
    if(data[now]>m[0]){
      ans[0]=now;
      m[0]=data[now];
    }
  }
  cout<<ans[0]<<" "<<ans[1]<<endl;
}