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++: #define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
using namespace std;
///////////////////library zone!!!!!!!!!!!!!!!!!!!!!!!!!!!!
typedef long long ll;
typedef long double ld;
#define all(a) (a).begin(),(a).end()
#define EPS (1e-7)
const ll Mod = 1000000007;
const ll mod = 998244353;
struct H {
	ll x, y;
	bool operator<(const H &b) const {
		if (x != b.x) return x < b.x;
		return y < b.y;
	}
	bool operator>(const H &b) const {
		if (x != b.x) return x > b.x;
		return y > b.y;
	}
	bool operator==(const H &b) const { return x == b.x&&y == b.y; }
	bool operator!=(const H &b) const { return (*this) != b; }
};
struct P {
	ll pos, cost;
	bool operator<(const P &b) const { return cost < b.cost; }
	bool operator>(const P &b) const { return cost > b.cost; }
};
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
	bool operator<(const E &b) const { return cost < b.cost; }
	bool operator>(const E &b) const { return cost > b.cost; }
};
template<typename T, typename U>
void chmin(T &a, U b) {
	if (a > b) a = b;
}
template<typename T, typename U>
void chmax(T &a, U b) {
	if (a < b) a = b;
}
template<typename T>
T max_0(T a) {
	if (a < 0) return 0;
	return a;
}
template<typename T>
T min_0(T a) {
	if (a > 0) return 0;
	return a;
}
ll read() {
	ll u;
	ll k = scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j%i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
vector<string>split(string s, char c = ' ') {
	vector<string>vec;
	string h = "";
	for (int i = 0; i < s.size();) {
		int j = i;
		while (j < s.size() && s[j] != ' ') {
			h += s[j++];
		}
		if (h.size() > 0) vec.push_back(h);
		h = "";
		i = j + 1;
	}
	return vec;
}
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
class Vec2 {
public:
	ld x, y;
	Vec2() { x = 0, y = 0; }
	Vec2(ld x, ld y) :x(x), y(y) {}
	ld length() {
		return sqrt(x*x + y * y);
	}
	Vec2 normal() {
		ld len = this->length();
		if (len == 0) return Vec2(x, y);
		x /= len, y /= len;
		return *(this);
	}
	Vec2 operator+(Vec2 vec) {
		return Vec2(x + vec.x, y + vec.y);
	}
	Vec2 operator-(Vec2 vec) {
		return Vec2(x - vec.x, y - vec.y);
	}
	template<typename T>
	Vec2 operator*(T cons) {
		return Vec2(x*cons, y*cons);
	}
	ld operator*(Vec2 vec) {
		return x * vec.x + y * vec.y;
	}
	ld operator%(Vec2 vec) {
		return x * vec.y - y * vec.x;
	}
	bool operator==(Vec2 vec) {
		return abs(x - vec.x) < EPS && abs(y - vec.y) < EPS;
	}
};
ld dot(Vec2 a, Vec2 b) {
	return a.x*b.x + a.y*b.y;
}
ld cross(Vec2 a, Vec2 b) {
	return a.x*b.y - a.y*b.x;
}
ld areaIntegral(Vec2 a, Vec2 b) {
	return abs(a.x*b.y - a.y*b.x) / 2.0;
}
class Vec3 {
public:
	ld x, y, z;
	Vec3() { x = 0, y = 0, z = 0; }
	Vec3(ld x, ld y, ld z) :x(x), y(y), z(z) {}
	ld length() {
		return sqrt(x*x + y * y + z * z);
	}
	void normal() {
		ld len = this->length();
		if (len == 0) return;
		x /= len, y /= len, z /= len;
	}
	Vec3 operator+(Vec3 vec) {
		return Vec3(x + vec.x, y + vec.y, z + vec.z);
	}
	Vec3 operator-(Vec3 vec) {
		return Vec3(x - vec.x, y - vec.y, z - vec.z);
	}
	Vec3 operator*(int cons) {
		return Vec3(x*cons, y*cons, z*cons);
	}
	ld operator*(Vec3 vec) {
		return x * vec.x + y * vec.y + z * vec.z;
	}
};
ld dot(Vec3 a, Vec3 b) {
	return a.x*b.x + a.y*b.y + a.z*b.z;
}
class Line {
public:
	Vec2 from, to;
	Line(Vec2 from, Vec2 to) :from(from), to(to) {}
};
Line getPerpendicularBisector(Line line) {
	int cx = (line.from.x + line.to.x) / 2, cy = (line.from.y + line.to.y) / 2;
	Vec2 p = Vec2(cx + (line.from.y - line.to.y), cy + (line.to.x - line.from.x));
	return Line(Vec2(cx, cy), p);
}
int a[200];
signed main() {
	string a, b = "";
	int sum = 0;
	string s;
	map<string, int>mp;
	vector<string>c;
	while (cin >> s) {
		mp[s]++;
		c.push_back(s);
		if (s.size() > b.size()) b = s;
	}
	for (int i = 0; i < c.size(); i++) {
		if (sum < mp[c[i]]) {
			sum = mp[c[i]];
			a = c[i];
		}
	}
	cout << a << " " << b << endl;
}

C++: #include <iostream>
#include <cstdio>
#include <cstdlib>
#include <time.h>
#include <math.h>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <sstream>
#include <string>
#include <bitset>
using namespace std;
#define FOR(I,F,N) for(int I = F; I < (int)(N); I++)
#define rep(i, n) FOR(i, 0, n)
#define FIN(V) cout<<V<<endl
#define pb push_back
#define INF (1 << 30)
typedef pair<int, int> P;
typedef long long ll;
typedef priority_queue<int> pq;
int StrToInt(string);
string IntToStr(int);
int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, 1, -1};

int main(void){
	string s, l, m;
	map<string, int> map;
	int mxl = 0;
	int tmp = 0;
	while(cin >> s){
		map[s]++;
		if(map[s] > tmp){
			m = s;
			tmp = map[s];
		}
		int tmp_s = s.size();
		if(s.size() > mxl){
			mxl = max(mxl,tmp_s);
			l = s;
		}
	}
	cout << m << " " << l;
	return 0;
}

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

using namespace std;

int main()
{
	string wordMax;
	map<string, int> n;
	map<string, int>::iterator i, nMax;
	string a;

	wordMax = "";
	while (cin>>a) {
		if ( n.count(a) ) {	// aðkeyÉÂvfª éA»ÌlðCNg
			n[a] ++;
		} else {			// aðkeyÉÂvfªÈ¢A»ÌvfðÇÁ
			n.insert( map<string, int>::value_type(a, 1) );
		}
		if ( a.size() > wordMax.size() ) wordMax = a;
	}

	nMax = n.begin();
	for (i = n.begin(); i != n.end(); i++) {
		if ( (*i).second > (*nMax).second ) nMax = i;
	}

	cout<<(*nMax).first<<" "<<wordMax<<endl;

	return 0;
}

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

int main() {
	string str[50], tmp;
	int max_num = 0, max_length = 0, i, max = 1, max_str = 0, a[1001] = {};
	
	while (cin >> tmp) {
		for (i = 0; i < tmp.size(); i++) {
			if ('A' <= tmp[i] && tmp[i] <= 'Z')
				tmp[i] = tmp[i] + 'a' - 'A';
		}

		for (i = 0; i < max; i++) {
			if (str[i] == tmp) {
				a[i]++;
				if (max_str < a[i]) {
					max_str = a[i];
					max_num = i;
				}
				if (tmp.size() > max_length)
					max_length = (int)tmp.size();
				break;
			}
		}
		if (i >= max) {
			str[i-1] = tmp;
			max++;
			a[i - 1]++;
			if (max_str < a[i-1]) {
				max_str = a[i - 1];
				max_num = i - 1;
			}
			if (tmp.size() > max_length)
				max_length = (int)tmp.size();
		}
	}
	cout << str[max_num];

	for (i = 0; i < max; i++) {
		if ((int)str[i].size() == max_length)
			cout <<" "<< str[i] << endl;
	}
	return 0;
}

C++: #include<iostream>
#include<string>
#include<map>
using namespace std;int main(){string s,m,l;for(map<string,int>d;cin>>s;l=s.size()>l.size()?s:l)m=++d[s]>d[m]?s:m;cout<<m<<" "<<l<<endl;return 0;}