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 <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <sstream>
#include <utility>
#include <cstdlib>
#include <cctype>
#include <climits>
#include <fstream>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<double> vd;
typedef vector<pair<int, int> > vpii;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define foreach(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); itr++)
#define dbg(x) cout << #x"="<< (x) << endl
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back(a) 
#define in(x) cin >> x;
#define all(x) (x).begin(), (x).end()
#define INF 2147483600
#define fi first
#define se second
using namespace std;

map <string,int> ans;
int l=0;
int k=0;

int main(){
    string str;
    string a,b;
    while(cin>>str){
        if(str.size()>=l){
            b = str;
            l=str.size();
        }
        ans[str]++;
        if(ans[str]>=k){
            k=ans[str];
            a=str;
        }
    }
    cout<<a<<" "<<b<<endl;
}

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

typedef map<string, int> M;
typedef M::value_type MV;
int main()
{
    M word_counts;
    string max_letters = "";

    for (string s; cin >> s;) {
        if (s.size() > max_letters.size())
            max_letters = s;
        word_counts[s]++;
    }
    cout << (*max_element(word_counts.begin(), word_counts.end(),
                          [](MV &a, MV &b){return a.second < b.second;})).first
        << " " << max_letters << endl;

    return 0;
}

C++: #include<iostream>
#include<vector>
#include<utility>
#include<string>
#include<algorithm>

using namespace std;

// 単語の区切りはistreamに任せる
// 単語はベクターに保持する。
// 出現頻度最多、最長文字数の単語はそれぞれ1つなので、
// すべての単語を入力後、それぞれに該当するものを探す。

int main() {
	// 単語の入力
	string input_str;
	vector<string> units;
	while (cin >> input_str) {
		units.push_back(move(input_str));
	}

	// 文字列は無駄にコピーさせないためポインタで記録しておく
	string* max_count_str = nullptr;
	auto max_count = 0;
	string* max_len_str = nullptr;
	auto max_len = 0;
	for (auto& a : units) {
		// 出現頻度が多いものを探す
		int temp_count = count(units.begin(), units.end(), a);
		if (max_count < temp_count) {
			max_count = temp_count;
			max_count_str = &a;
		}
		// 最も長い文字列を探す
		if (max_len < a.length()) {
			max_len = a.length();
			max_len_str = &a;
		}
	}

	cout << *max_count_str << ' ' << *max_len_str << endl;

	return 0;
}

C++: #include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>

using namespace std;

const int M = 33;
const int N = 333001;

char text[N];
char word[N][M];
char tmp[N], ansm[N], ansl[N]; 

int cmp(const void *a, const void *b) {
	return strcmp((char *)a, (char *)b);
}

void solve(char text[]) {
	int len = strlen(text);
	for (int i=0; i<len; ++i) {
		if (text[i] >= 'A' && text[i] <= 'Z') text[i] = text[i] - 'A' + 'a';
	}
	int j = 0, k = 0;
	for (int i=0; i<len; ++i) {//分解文章 
		if (text[i] != ' ') word[k][j++] = text[i];
		else {
			if (j == 0) continue;
			word[k++][j] = '\0', j = 0;
		}
	}
	if (j) word[k++][j] = '\0';
	qsort(word, k, sizeof(word[0]), cmp);
	int maxs = -1;
	int cnt = 1;
	strcpy(tmp, word[0]);
	strcpy(ansl, word[0]);
	int maxl = strlen(word[0]);
	for (int i=1; i<k; ++i) {
		if (maxl < strlen(word[i])) maxl = strlen(word[i]), strcpy(ansl, word[i]);
		if (!strcmp(tmp, word[i])) ++cnt;
		else {
			if (maxs < cnt) {
				maxs = cnt;
				strcpy(ansm, tmp);
			}
			strcpy(tmp, word[i]);
		}
	}
	if (maxs < cnt) strcpy(ansm, tmp);
}

int main() {
//	cin.getline(text, N, '\n');
	while (cin.getline(text, N, '\n')) {
		solve(text);
		cout<<ansm<<" "<<ansl<<endl;
	}
	return 0;
}

C++: #include<iostream>
#include <stdio.h>
#include<string>
using namespace std;
string s[1000], t,ma,hi; int i=0,j[1000],times=0;
int main() {
	while (cin>>s[i])
	{
		for (int q=0; q < i; q++) {
			if (s[i] == s[q]) { j[q]++; }if (j[q] > times) { hi = s[q]; times = j[q]; }
	}
		if (ma.size() < s[i].size())ma = s[i];
		i++;
	}
	cout << hi << " " << ma<<endl;
	return 0;
}

C++: #include <iostream>
#include <cstring>
#include <string.h>
#include <cstdio>
using namespace std;
int main(){
  char c[1111];
  int len=0;
  int k=0;
  char maxc;
  int iti[1111]={0};//頻度高いよう
  char ans[1111];
  char ans1[1111];
  char cpy[111][111];
  while(scanf("%s",c)!=EOF){
    if(len<strlen(c)){//最長のもの
      len=strlen(c);
      strcpy(ans,c);
    }
    
    for(int i=0;i<k+1;i++){
      if(strcmp(cpy[i],c)==0){//すでに一度でていたら
	iti[i]++;
      }else if(i==k){//一度もでていなかったら
	strcpy(cpy[i],c);
      }
    }
    k++;
  }
  
  strcpy(ans1,cpy[0]);
  for(int i=0;i<k-1;i++){
    if(iti[i]<iti[i+1]){
      strcpy(ans1,cpy[i+1]);
    }
  }
  
  cout << ans1 << " " << ans << endl;
}

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

int main(){
  string s;
  map<string, int> mp;
  while (cin >> s) {
    mp[s]++;
  }
  string maxv = mp.rbegin()->first;

  int maxstr = 0;
  string ansstr;
  for (auto x : mp) {
    if (x.first.size() >= maxstr) {
      maxstr = x.first.size();
      ansstr = x.first;
    }

  }
  cout << maxv << " " << ansstr << endl;
  return 0;
}

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

int main() {
	string s;
	int maxlen = 0;
	string maxstr = "";
	vector<pair<int, string> > v(1000, pair<int, string>(0, "-"));

	while (cin >> s) {
		if (s.size() > maxlen) {
			maxlen = s.size();
			maxstr = s;
		}

		for (int i = 0; i < v.size(); i++) {
			string &s2 = v.at(i).second;
			int &cnt = v.at(i).first;

			if (s2 == "-") {
				s2 = s;
				cnt = 1;
				break;
			}
			else {
				if (s2 == s) {
					cnt++;
					break;
				}
			}
		}
	}
	/*
	for (int i = 0; i < 10; i++) {
		int x = v.at(i).first;
		string s0 = v.at(i).second;

		cout << x << ' ' << s0 << endl;
	}*/

	sort(v.begin(), v.end());
	reverse(v.begin(), v.end());

	cout << v.at(0).second << ' ' << maxstr << endl;
}

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
	string s;
	string ans = "";
	map <string ,int> mp;
	while(cin >> s){
		if(ans.size() < s.size())
			ans = s;
		mp[s]++;
	}
	int va = 0;
	string asdf;
	for(auto itr = mp.begin() ; itr != mp.end() ; itr++)
		if((*itr).second > va){
			asdf = (*itr).first;
			va = (*itr).second;
		}
	cout << asdf << " " << ans << endl;
}

C++: #include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <string>
#include <cstdio>
#include <cmath>
#include <map>
using namespace std;

int main()
{
	int max_s = 0;
	map<string, int> n;
	string s1, s2 = "", s3;
	while(cin >> s1){
		n[s1]++;
		if (s1.size() > s2.size())
		{
			s2 = s1;
		}
		if(max_s < n[s1]){
			s3 = s1;
			max_s = n[s1];
		}
	}
	cout << s3 << " " << s2 << endl;
}