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<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<deque>
using namespace std;

int main() {

    vector<string> words;
    string word; 
    string longest = "";

    while(cin >> word) {
        words.push_back(word);
        if(word.length() > longest.length()) {
                longest = word;
        }
    }

    string freq;
    int frequency = 0;
    for(int i = 0; i < words.size(); i++) {
        int tmp = count(words.begin(), words.end(), words[i]);
        if (tmp > frequency) {
            frequency = tmp;
            freq = words[i];
        }
    }

    cout << freq << " " << longest << endl;

    return 0;
}

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

map <string, int> dic;

string lowerword(string word){
    for (int i=0; i<(int)word.size(); i++)
        word[i] = tolower(word[i]);
    return word;
}

int main(void){

	while (true){
		string s;
		cin>>s;
		if (cin.eof()) break;
		dic[lowerword(s)]++;
	}

	int l=0, m=0, tmp;
	string w1, w2;
	map <string, int> ::iterator it=dic.begin();
	while (it!=dic.end()){
		tmp = (*it).second;
		if (tmp>m){
			m = tmp;
			w1 = (*it).first;
		}
		tmp = (*it).first.size();
		if (tmp>l){
			l = tmp;
			w2 = (*it).first;
		}
		it++;
	}
	cout<<w1<<" "<<w2<<endl;
	return 0;
}

C++: #include <map>
#include <string>
#include <iostream>
using namespace std;
map<string,int> table;
int main()
{
    string word, frequent, longest;
    size_t N=0;
    while (cin >> word)
    {
        table[word]++;
        if(table[word]>N)
        {
            N=table[word];
            frequent=word;
}
            if(word.size()>longest.size())
                longest=word;
    }
        cout<<frequent<<" "<<longest<<endl;
    }

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

using namespace std;

int main(){
    int max = 0;
    string s,longests,frequents;
    map<string,int> dict;
    while(cin >>s){
        dict[s] +=1;
        if(s.size() >= max){
            longests = s;
            max = s.size();
        }
        if(dict[s] >= dict[frequents]){
            frequents = s;
        }
    }
    cout << frequents << " " << longests << endl;
}

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

using namespace std;

class Word {
public:
	char w[33];
	int length;
	int freq;
public:	
	Word() {
		strcpy(w, "");
		length = 0;
		freq = 0;
	}
};

int main()
{
	char str[1001];
	char buf[32];
	char *p, *q;
	fgets(str, 1001, stdin);
	
	Word wl[32];
	
	for ( p = str; (q = strstr(p, " ")) != NULL; ) {
		*q = '\0'; strcpy(buf, p); 
		for (int i=0; i<32; i++) {
			if ( strcmp(wl[i].w, "") == 0 ) {
				strcpy(wl[i].w, buf);
				wl[i].length = strlen(buf);
				wl[i].freq = 1;
				break;
			}
			else if ( strcmp(wl[i].w, buf) == 0 ) {
				wl[i].freq++;
				break;
			}
		}
		p = q + 1;
	}
	
	strcpy(buf, p); 
	for (int i=0; i<32; i++) {
		if ( strcmp(wl[i].w, "") == 0 ) {
			strcpy(wl[i].w, buf);
			wl[i].length = strlen(buf);
			wl[i].freq = 1;
			break;
		}
		else if ( strcmp(wl[i].w, buf) == 0 ) {
			wl[i].freq++;
			break;
		}
	}

	
	int max_freq = 0;
	int max_length = 0;
	char max_freq_w[32];
	char max_length_w[32];
	
	for (int i=0; i<32; i++) {
		if (max_freq < wl[i].freq) {
			max_freq = wl[i].freq;
			strcpy(max_freq_w, wl[i].w);
		}
		if (max_length < wl[i].length) {
			max_length = wl[i].length;
			strcpy(max_length_w, wl[i].w);
		}
	}
	
	cout << max_freq_w << " " << max_length_w << endl;
	
	return 0;
}

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

int main(){
  map<string,int> table;
  string word;
  int k1 = 0;
  int k2 = 0;
  string answer1;
  string answer2;
  while(cin >> word){
    table[word]+=1;
    if(table[word] > k1){
      k1 = table[word];
      answer1 = word;
    }
    int len = sizeof(word);
    if (len > k2){
      k2 = len;
      answer2 = word;
    }
  }
  cout << answer1 << " " << answer2 << endl;
}

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

int main()
{
	std::map<std::string,int> word_frequency;
	std::string word;
	while (std::cin >> word) {
		word_frequency[word]++;
	}

	std::string most_frequent_word;
	std::string longest_word;
	int max_frequency = 0;
	for (std::map<std::string,int>::iterator i = word_frequency.begin(); i != word_frequency.end(); ++i) {
		if (i->second > max_frequency) {
			most_frequent_word = i->first;
		}
		if (i->first.size() > longest_word.size()) {
			longest_word = i->first;
		}
	}

	std::cout << most_frequent_word << ' ' << longest_word << std::endl;

	return 0;
}

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

int main()
{
	std::string str;
	std::map<std::string,int> frequency;
	std::string longest,frequent;
	int freq=0;
	int len=0;
	
	std::getline(std::cin,str);
	
	str+=' ';
	
	int begin=0;
	bool inword=false;
	for(int i=0;i<str.size();i++)
	{
		std::string word;
		if(!inword&&isalpha(str[i]))
		{
			inword=true;
			begin=i;
		}
		else if(!isalpha(str[i]))
		{
			inword=false;
			word=str.substr(begin,i-begin);
			if(word.size()>len)
			{
				len=word.size();
				longest=word;
			}
			if(frequency.find(word)==frequency.end())
			{
				frequency.insert(std::pair<std::string,int>(word,0));
			}
			if(++frequency[word]>freq)
			{
				freq=frequency[word];
				frequent=word;
			}
		}
	}
	std::cout<<frequent<<' '<<longest<<std::endl;
	return 0;
}