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<vector>
#include<string>
#include<sstream>
#include<algorithm>

struct WordRanking
{
	WordRanking(){}

	WordRanking(std::string word, int count):m_word(word),m_count(count)
	{
	}

	std::string m_word;

	int m_count;
};

int MaxNum(std::vector<WordRanking> rank)
{
	if(rank.empty())
	{
		return 0;
	}

	int max = rank[0].m_count;

	int maxNum=0;

	for(size_t i=1; i<rank.size(); ++i)
	{
		if(rank[i].m_count>max)
		{
			max = rank[i].m_count;

			maxNum = i;
		}
	}

	return maxNum;
}


int main()
{
	std::string str;

	while(1)
	{
		getline(std::cin,str);

		if(std::cin.eof())
		{
			break;
		}

		std::stringstream ss;

		std::vector<std::string> word;

		ss << str;

		std::string hoge;

		for(; !(ss.eof());)
		{
			ss >> hoge;

			word.push_back(hoge);
		}

		std::sort(word.begin(),word.end());

		std::string temp = "";

		std::vector<WordRanking> rankFriq;

		for(size_t i=0; i<word.size(); ++i)
		{
			if(temp != word[i])
			{
				rankFriq.push_back(WordRanking(word[i],1));
			}
			else
			{
				++rankFriq[rankFriq.size()-1].m_count;
			}

			temp = word[i]; 
		}

		std::vector<WordRanking> rankLength;

		for(size_t i=0; i<word.size(); ++i)
		{
			rankLength.push_back(WordRanking(word[i],word[i].length()));
		}

		std::cout << rankFriq[MaxNum(rankFriq)].m_word << ' ' << rankLength[MaxNum(rankLength)].m_word << '\n';
		
	}
}

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
	string s;
	string ans = "";
	map <string ,int> mp;
	while(cin >> s){
		transform(s.begin(), s.end() ,s.begin() ,::toupper);
		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;
	cout << asdf << " " << ans << endl;
}

C++: #include<iostream>
#include<cstring>
const int MAX_STR = 35;
const int MAX_NUM_OF_STR = 1010;
using namespace std;

int main(){
	int cnt = -1, len = 0, tango = 0;
	char str[MAX_NUM_OF_STR][MAX_STR], max[MAX_STR], maxlen[MAX_STR];
	
	while(cin >>str[tango]){
		int tmpcnt = 0;
		for(int i = 0; i <= tango; i++){
			if(strcmp(str[i], str[tango]) == 0){
				tmpcnt++;
			}
		}
		if(cnt < tmpcnt){
			strcpy(max, str[tango]);
			cnt = tmpcnt;
		}
		
		if(strlen(str[tango]) > (unsigned)len){
			len = strlen(str[tango]);
			strcpy(maxlen, str[tango]);
		}
		tango++;
	}
	cout <<max <<" " <<maxlen <<endl;
	return 0;
}

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;
}

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

using namespace std;

vector<string> split(string str, const char ch) {
	vector<string> res;
	string s = "";
	for (int i = 0; i < str.length(); i++) {
		if (str[i] == ch) {
			res.push_back(s);
			s = "";
		}else{
			s += str[i];
		}
	}
	res.push_back(s);
	return res;
}

int main() {
	string source;
	getline(cin, source);
	
	string maxl = "", mode = "";
	int max = 0;
	vector<string> str = split(source, ' ');
	map<string, int> m;
	
	for (int i = 0; i < str.size(); i++) {
		if (m[str[i]] == 0) {
			m[str[i]] = 1;

			if (str[i].length() > maxl.length()) {
				maxl = str[i];
			}
		}else{
			m[str[i]]++;

			if (m[str[i]] > max) {
				max = m[str[i]];
				mode = str[i];
			}
		}
	}
	cout << mode << " " << maxl << endl;
	return 0;
}

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

#define MAX(x,y) ((x,y)? x:y)

using namespace std;

string date[1000];

int main()
{
	for(int i=0;!cin.eof();i++){
		cin>>date[i];
	}
	sort(date,date+1000);
	int weitline=0;
	int maxline=0;
	string str;
	int str_i=0;
	for(int i=0;i<1000;i++)
	{
		if(str==date[i])str_i++;
		else 
		{
			str_i=1;
			str=date[i];
		}
		weitline =MAX(weitline,str_i);
		maxline=MAX(maxline,date[i].length());
	}
	string weitanswer;
	string maxanswer;

	for(int i=0;i<1000;i++)
	{
		if(str==date[i])str_i++;
		else 
		{
			str_i=1;
			str=date[i];
		}
		if(str_i==weitline)weitanswer=date[i];
		if(maxline==date[i].length()) maxanswer=date[i];
	}
	printf("%s %s\n");
	return 0;
}

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,k=0;
	for(i=x;isalpha(str[i]);i++)
		pre[k++]=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;
				strcpy(lstr,&str[i]);
			}
			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 <map>

using namespace std;

int main() {
	map<string, int> words;
	string word;
	int longest = 0, aliance = 0;
	while (cin >> word) {
		if (words.find(word) == words.end()) {
			int len = word.size();
			words[word] = 1;
			longest = max(longest, len);
		} else {
			int n = words[word];
			words[word] = n + 1;
		}
	}
	map<string, int>::iterator it;
	for (it = words.begin(); it != words.end(); it++)
		aliance = max(aliance, it->second);
	for (it = words.begin(); it != words.end(); it++)
		if (it->second == aliance) {
			cout << it->first;
			break;
		}
	for (it = words.begin(); it != words.end(); it++) {
		string s = it->first;
		if (s.size() == longest) {
			cout << " " << s << endl;
		}
	}

	return 0;
}

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

int main() {
  string strMxWC, strMxWL, str;
  map<string,int> mp;
  
  while(cin>>str) {
    mp[str]++;
    if(mp[strMxWC]<mp[str]) strMxWC=str;
    if(strMxWL.size()<str.size()) strMxWL=str;
  }
  cout << strMxWC << " " << strMxWL << endl;
  
  return 0;
}

C++: #include <fstream>
#include <sstream>
#include <iostream>
#include <cmath>
#include <vector>
#include <queue>
#include <map>
#include <utility>
#include <algorithm>
using namespace std;

vector<string> split(const string &str, char delim){
  istringstream iss(str); string tmp; vector<string> res;
  while(getline(iss, tmp, delim)) res.push_back(tmp);
  return res;
}

int main() {
  string snt;
  getline(cin, snt);

  vector<string> words = split(snt, ' ');
  words[0][0] = tolower( words[0][0] );

  // for (int i = 0; i < words.size(); i++)
  //   cout << words[i] << endl;

  map<string, int> cnt;

  int M = words.size();
  int l;
  int mx_len = 0;
  for (int i = 0; i < M; i++) {
    // 最頻値
    if (cnt.count(words[i])) {
      cnt[ words[i] ]++;
    } else {
      cnt[ words[i] ] = 0;
    }
    // 最大長さの単語
    if (words[i].length() > mx_len) {
      mx_len = words[i].length();
      l = i;
    }
  }

  int f;
  int mx_f = 0;
  for (int i = 0; i < M; i++) {
    if (mx_f < cnt[ words[i] ]) {
      f = i;
      mx_f = cnt[ words[i] ];
    }
  }

  cout << words[f] << " " << words[l] << endl;
}