Go: package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
)

var scanner = bufio.NewScanner(os.Stdin)

func nextString() string {
	scanner.Scan()
	return scanner.Text()
}

type Pair struct {
	key   string
	value int
}

func main() {
	scanner.Split(bufio.ScanWords)
	counts := map[string]int{}
	maxLen := 0
	maxLenWord := ""
	for {
		word := nextString()
		if word == "" {
			break
		}

		counts[word]++

		if len(word) > maxLen {
			maxLen = len(word)
			maxLenWord = word
		}
	}

	mapPairs := []Pair{}
	for k, v := range counts {
		mapPairs = append(mapPairs, Pair{k, v})
	}
	sort.Slice(mapPairs, func(i, j int) bool { return mapPairs[i].value > mapPairs[j].value })

	fmt.Println(mapPairs[0].key, maxLenWord)
}

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

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