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 <string>
#include <map>
#include <vector>
using namespace std;

int main(){
    // word[s] で 文字列sの出現回数が返ってくる
    map<string, int> word;
    vector<string> v;
    string s;
    
    while( cin >> s ){
        v.push_back(s);
        
        //入力した単語がすでにあるか探す
        // countはすでに文字列sがキーとして存在すれば1が、そうでなければ0が返ってくる
        if( word.count(s) ){ 
            word[s]++;
        }else{
            word[s] = 1;
        }
    }
    // 最頻出の単語を調べる
    int mode = 0;
    for(int i=0 ; i < v.size() ; i++ ){
        mode = max( mode , word[ v[i] ] );
    }
    for(int i=0 ; i < v.size() ; i++ ){
        if( mode == word[ v[i] ] ){
            cout << v[i];
            break;
        }
    }
    // 最長の単語を求める
    int length = 0;
    for(int i=0 ; i < v.size() ; i++ ){
        // v[i].size()で返ってくる数値はint型でなくsize_t型なので注意！
        length = max( length , (int)v[i].size() );
    }
    for(int i=0 ; i < v.size() ; i++ ){
        if( length == v[i].size() ){
            cout << " " << v[i] << endl;
        }
    }
}

C++: #include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <string>
#include <algorithm>
#include <climits>
#include <utility>

#define PRINT(STR) cout << STR << endl;
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); (i)++)
#define REG(i, a, b) for (int (i) = ((int)(a)); (i) < ((int)(b)); i++)
#define ALL(V) (V).begin(), (V).end()
#define SPACE " "

typedef long long ll;

using namespace std;

int nextInt() { int n = -1; cin >> n; return n; }
double nextDouble() { double d = -1; cin >> d; return d; }
ll nextll() { ll n = -1; cin >> n; return n; }
string nextString() { string str; cin >> str; return str; }

int INF = 1LL << 25;
double EPS = 1e-9;

// BEGIN //////////////////////////////////////////////////////////////
int main() {
	map<string, int> d;
	string str;
	while (cin >> str) {
		d[str]++;
	}
	int d_max = -1;
	string ans = "";
	for (auto it = d.begin(); it != d.end(); it++) {
		d_max = max(d_max, it->second);
		if (ans.size() < it->first.size()) {
			ans.assign(it->first);
		}
	}
	for (auto it = d.begin(); it != d.end(); it++) {
		if (it->second == d_max) {
			cout << it->first << SPACE;
			break;
		}
	}
	PRINT(ans);

	return 0;
}
// END   //////////////////////////////////////////////////////////////

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++: #define _USE_MATH_DEFINES

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <utility>
#include <vector>
#include <numeric>

using namespace std;

struct Data
{
	string word;
	int count;

	Data()
	{
		
	}

	Data(string word)
	{
		this->word = word;
		this->count = 1;
	}
};

int main()
{
	vector<Data> d;

	string str;
	getline(cin, str);

	stringstream ss;
	ss << str;

	string s;
	for (; ss >> s;)
	{
		int i;
		bool b = false;
		for (i = 0; i < d.size(); i++)
		{
			if (d.at(i).word == s)
			{
				b = true;
				break;
			}
		}

		if (b)
		{
			d.at(i).count++;
		}
		else
		{
			d.push_back(Data(s));
		}
	}

	int maxw = 0;
	int maxl = 0;

	string w, l;
	for (int i = 0; i < d.size(); i++)
	{
		if (d.at(i).count > maxw)
		{
			w = d.at(i).word;
			maxw = d.at(i).count;
		}

		if (d.at(i).word.size() > maxl)
		{
			l = d.at(i).word;
			maxl = d.at(i).word.size();
		}
	}

	cout << w << " " << l << endl;
}

C++: #include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	map<string,int> M;
	string S,MS("");
	while(cin>>S){
		M[S]++;
		if(S.size()>MS.size()){
			MS = S;
		}
	}
	
	int num=0;
	for(auto& x:M){
		if(x.second>num){
			S = x.first;
			num = x.second;
		}
	}
	out(S,MS);
	return 0;
}

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

int main() {
	string s;
	vector<string>sa;
	vector<int>h;
	int z;
	string b,m;
	cin >> b;
	sa.push_back(b);
	h.push_back(1);
	z = b.size();
	m = b;
	while (cin >> s) {
		if (s.size() > z) {
			z = s.size();
			m = s;
		}
		int flg = 0;
		for (int i = 0;i < sa.size();i++) {
			if (sa[i] == s) {
				h[i]++;
				flg = 1;
				break;
			}
		}
		if (flg == 0) {
			sa.push_back(s);
			h.push_back(1);
		}

	}
	int va = 0;
	string xs;
	for (int i = 0;i < sa.size();i++) {
		if (va < h[i]) {
			va = h[i];
			xs = sa[i];
		}
	}
	cout << xs << ' ' << m << endl;
	return 0;
}

C++: #include<iostream>
#include<map>
#include<string>
using namespace std;
int main()
{
  map<string,int>m;
  string a[1000];
  char c;
  while(true){
    int i=0;
    while(true){
      cin>>a[i];
      i++;
      if((c=getchar())=='\n')
	break;   
    }
    m.clear();
    for(int j=0;j<i;++j)
      m[a[j]]++;
    int max=0,temp;
    for(int j=0;j<i;++j)
      if(max<m[a[j]]){
	max=m[a[j]];
	temp=j;
      }
    cout<<a[temp]<<' ';
    max=0;
    for(int j=0;j<i;++j)
      if(max<a[j].size()){
	max=a[j].size();
	temp=j;
      }
    cout<<a[temp]<<endl;
  }
  return 0;
}

C++: #include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;
// English Sentence (0029)
int main()
{
	map<string,int>a;
	string ret1,ret2;
	int maxnum=0,maxlen=0;
	string s;
	while (1){
		if(!(cin>>s)) break;;
		int num=++a[s];
		if(maxnum<num){ 
			maxnum=num;
			ret1=s;
		}
		if(maxlen < s.size()){
			maxlen=s.size();
			ret2=s;
		}
	}
	cout<<ret1<<" "<<ret2<<endl;
	return 0;
}

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

void countword(string s){
    map<string, int>m;
    stringstream ss(s);
    string word, maximum, maximum_l;
    int Max1 = 0, Max2 = 0;
    while(ss >> word){
        if(word.size() > Max1){
            Max1 = word.size();
            maximum_l = word;
        }
        m[word]++;
    }
    map<string, int>::iterator it;


        for(it = m.begin(); it != m.end(); it++){
        if(Max2 < it->second){
            Max2 = it->second;
            maximum = it->first;
        }
    }
    cout<<maximum<<" "<<maximum_l<<endl;
}


int main()
{
    string s;
    getline(cin, s);
    countword(s);
}