Go: package main

import (
	"bufio"
	"os"
	"strings"
	"fmt"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	words := strings.Split(scanner.Text(), " ")
	wordMap := make(map[string]int)
	for _, v := range words {
		wordMap[v]++
	}
	key := ""
	value := -1
	l := -1
	word := ""
	for k, v := range wordMap {
		// fmt.Println(k, v)
		if value < v {
			key = k
			value = v
		}
		if l < len(k) {
			l = len(k)
			word = k
		}
	}

	fmt.Println(key, word)
	// fmt.Println(wordMap)
}

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

using namespace std;

int main(int argc, char *argv[]) {
  map<string, int> words;
  string tmp, line;

  getline(cin, line);
  stringstream ss(line);
  while (ss >> tmp)
    if (words.count(tmp) == 0)
      words.insert(pair<string, int>(tmp, 1));
    else
      words[tmp]++;

  map<string, int>::iterator itr = words.begin();
  string longest = (*itr).first;
  map<string, int>::iterator freq = itr;
  while (itr != words.end()) {
    if (longest.size() < (*itr).first.size())
      longest = (*itr).first;
    if ((*freq).second < (*itr).second)
      freq = itr;
    itr++;
  }

  cout << (*freq).first << ' ' << longest << endl;
  return 0;
}

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

using namespace std;

int main(){
	string s;
	string word[500];
	int a[500]={};
	int i,j,k,l;
	int n,m,len;
	i=0;
	while(cin>>s){
		if(i==0){	//????????????????????????
			word[0]=s;
			a[0]++;
			i++;
			len=s.size();
			n=0;
		}
		else {
			if(len<s.size()){	//?????????????????????????????°??´??°
				len=s.size();
				n=i;
			}
			for(j=0; j<i; j++){
				if(s==word[j]){	//?????§????????????????????????
					a[j]++;
					break;
				}
				if(j==i-1){			//??°?????????????????????
					word[i]=s;
					a[i]++;
					i++;
					break;
				}
			}
		}
	}
	m=0;
	for(j=0; j<i; j++){		//????????????????????????????????????
		if(m<a[j])m=j;
	}
	cout<<word[m]<<" "<<word[n]<<endl;
	// for(j=0; j<i; j++){
	// 	cout<<word[j]<<":"<<a[j]<<endl;
	// }
	//cout<<"len:"<<len<<" "<<word[n]<<endl;
	return 0;
}

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

using namespace std;

const int M = 33;
const int N = 1001;

char text[N];
char word[N][N];
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() {
	while (cin.getline(text, N, '\n')) {
		solve(text);
		cout<<ansm<<" "<<ansl<<endl;
	}
	return 0;
}

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() ,::tolower);
		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 <string>
#include <map>

using namespace std;

int main()
{
	string s,max("");
	map<string,int> w;
	map<int,string> x;
	
	while(cin>>s){
		if(s.size()>max.size()) max=s;
		w[s]++;
	}
	
	for(map<string,int>::iterator it=w.begin();it!=w.end();it++)
		x[(*it).second] = (*it).first;
	
	cout<<(*x.rbegin()).second<<"" ""<<max<<endl;
	return 0;
}

C++: #include <stdio.h>
#include <string.h>

int main(void)
{
	int i, j, x, num, same;
	int count[1000] = {0}, big, place;
	int l_count[1000] = {0}, l_place;
	char c;
	char words[1000][40], l_word[1000][40];
	
	j = 0;
	i = 0;
	num = 0;
	
	while (1){
		scanf("%c", &c);
		
		if (c == '\n'){
			break;
		}
		else if (c == ' '){
			if (num != 0){
				same = 0;
				for (x = 0; x < num; x++){
					if (strcmp(l_word[x], words[j]) == 0){
						l_count[x]++;
						same = 1;
						break;
					}
				}
				
				if (same != 1) {
					strcpy(l_word[num], words[j]);
					l_count[num]++;
					num++;
				}
				
			}
			else {
				strcpy(l_word[0], words[0]);
				l_count[num]++;
				num++;
			}
			
			i = 0;
			j++;
			
		}
		else {
			words[j][i] = c;
			i++;
			count[j]++;
		}
		
	}
	
	big = 0;
	place = 0;
	
	for (i = 0; count[i] != 0; i++){
		if (count[i] > big){
			big = count[i];
			place = i;
		}
	}
	
	big = 0;
	l_place = 0;
	
	for (i = 0; l_count[i] != 0; i++){
		if (l_count[i] > big){
			big = l_count[i];
			l_place = i;
		}
	}
	
	printf("%s %s\n", words[l_place], words[place]);
	
	return (0);
}

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