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<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++].sum=1;
	}
	if(sp[i].sum>mx){
		mx=sp[i].sum;
		strcpy(mstr,sp[i].s);
	}
}
int lo(int x){
	int i;
	for(i=x;isalpha(str[i]);i++)
		pre[i-x]=str[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);
			}
			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 <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <complex>
#include <string.h>
#include <numeric>
using namespace std;

//#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(itr,v) for(auto &(itr):(v))
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}
#define zero(a) memset(a,0,sizeof(a))
#define unq(a) sort(all(a)),a.erase(unique(all(a)),a.end())

//typedef complex<double> P;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b,ll m=mod) {ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a*b/gcd(a,b);}
bool ool(int x,int y,int h,int w) {return((x<0)||(h<=x)||(y<0)||(w<=y));}
bool deq(double a,double b) {return abs(a-b)<eps;}

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;



string s;
map<string,int> c;
int mx;

signed main() {
	while (!cin.eof()) {
		cin >> s;
		c[s]++;
	}
	s = "";
	each(i,c) {
		chmax(mx,i.second);
		if (s.size()<i.first.size()) s = i.first;
	}
	each(i,c) if (i.second==mx) cout << i.first << ' ';
	cout << s << endl;
}

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

using namespace std;

/** Problem0029 : English Sentence **/
int main()
{
	map<string, int> sentences;
	pair<string, int> t;
	string tmp, maxLength;
	
	while (cin >> tmp) {
		if (tmp.length() > maxLength.length())
			maxLength = tmp;
		
		if (sentences.count(tmp) == 0) {
			sentences.insert(map<string,int>::value_type(tmp, 1));
		} else {
			sentences[tmp]++;
		}
	}
	
	t = *max_element(sentences.begin(), sentences.end());
	cout << t.first << " " << maxLength << endl;
	
	return 0;
}

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

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
#define rrep(i, m, n) for(int (i)=(m); (i)<(n);  (i)++)
#define erep(i, m, n) for(int (i)=(m); (i)<=(n); (i)++)
#define  rep(i, n)    for(int (i)=0; (i)<(n);  (i)++)
#define  rev(i, n)    for(int (i)=(n)-1; (i)>=0; (i)--)
#define vrep(i, c)    for(__typeof((c).begin())i=(c).begin(); i!=(c).end(); i++)
#define  ALL(v)       (v).begin(), (v).end()
#define mp            make_pair
#define pb            push_back
template<class T1, class T2> inline void minup(T1& m, T2 x){ if(m>x) m=static_cast<T2>(x); }
template<class T1, class T2> inline void maxup(T1& m, T2 x){ if(m<x) m=static_cast<T2>(x); }

#define INF 1000000000
#define MOD 1000000009
#define EPS 1E-9

string s;
string res;
map<string, int> word;
pair<string, int> mx;

int main()
{
  while(cin >> s){
    if(++word[s] > mx.second) mx.first = s, mx.second = word[s];
    if(s.size() > res.size()) res = s;
  }

  cout << mx.first << " " << res << endl;

  return 0;
}

C++: #include <bits/stdc++.h>

using namespace std;

#define int long long
#define PB push_back
#define PPB pop_back
typedef pair<int, int> pii;
static const int INF = 1LL<<61;

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);

  string ans1, ans2, in;
  int tm = 0;
  map<string, int> gedo;
  while (cin >> in) {
    if (ans2.size() < in.size()) ans2 = in;
    if (tm < ++gedo[in]) {ans1 = in;tm = gedo[in];}
  }

  cout << ans1 << " " << ans2 << endl;

  return 0;
}

C++: 
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <stack>
#include <cctype>
#include <complex>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <cassert>

using namespace std;


bool solve(){
	int maxsize=0;
	int maxcnt=0;
	int ans_num;
	int ans_num2;
	vector<string> str_v;
	
	string in;
	while(cin>>in){
		str_v.push_back(in);
		if(maxsize < in.size()){
			maxsize = in.size();
			ans_num = str_v.size()-1;
		}
	}
	for(int i=0;i<str_v.size();i++){
		int cnt=0;
		for(int j=0;j<str_v.size();j++){
			if(str_v[i] == str_v[j]) cnt++;
		}
		if(maxcnt < cnt){
			maxcnt = cnt;
			ans_num2 = i;
		}
	}
	
	cout<< str_v[ans_num2]<< " "<< str_v[ans_num]<< endl;
	
	return true;
}

int main(){
	cout.setf(ios::fixed);
	cout.precision(10);
	solve();

	return 0;
}

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

typedef pair<string, int> P;

bool pairCompare(const P& firstElof, const P& secondElof)
{
	return firstElof.second > secondElof.second;
}

int main(void)
{
	string s, m;
	vector<P> v;
	while (cin >> s) {
		if (m.size() < s.size()) m = s;
		bool flag = true;
		for (int i = 0; i < v.size(); i++) {
			if (v[i].first == s) {
				flag = false;
				v[i].second++;
			}
		}
		if (flag) v.push_back(P(s,1));
	}
	sort(v.begin(), v.end(), pairCompare);
	cout << v[0].first << " " << m << endl;
	
	return 0;
}