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

#define INPUT_FROM_FILE (0) 
#if INPUT_FROM_FILE
#include <fstream>
#endif

int main(int argc, char **argv){
	std::string str;

#if INPUT_FROM_FILE
	std::ifstream ifs("test.txt");
	//FILE *fp = fopen("test.txt", "r");
#endif

	
#if INPUT_FROM_FILE
	std::getline(ifs, str);
#else
	std::getline(std::cin, str);
#endif
	
	std::istringstream stream(str);
	int max_length = 0;
	int max_count = 0;
	std::string longest_str;
	std::string most_frequent_str;
	std::multiset<std::string> mset;

	while(std::getline(stream, str, ' ')){
		if(max_length < str.size()){
			max_length = str.size();
			longest_str = str;
		}
		mset.insert(str);
	}

	for(std::multiset<std::string>::const_iterator it = mset.begin();
		it != mset.end(); it++){
		std::string s = *it;
		int c = mset.count(s);
		if(max_count < c){
			max_count = c;
			most_frequent_str = s;
		}
	}

	std::cout << most_frequent_str << " " << longest_str << std::endl;
	return 0;
}

C++: #include <iostream>
#include <string>
#include <map>
#include <vector>
using namespace std;
int main(){
    map<string,int>m;
    string s;
    vector<string>v;
    while(cin>>s){
        if('A'<=s[0]&&s[0]<='Z'){
            s[0]=s[0]-'A'+'a';
        }
        m[s]++;
        v.push_back(s);
    }
    int ans1=-1;
    int ans2=-1;
    string ans1s;
    string ans2s;
    for(int i=0;i<v.size();i++){
        if(ans1<m[v[i]]){
            ans1=m[v[i]];
            ans1s=v[i];
        }
        if(ans2<(int)v[i].size()){
            ans2=v[i].size();
            ans2s=v[i];
        }
    }
    cout<<ans1s<<" "<<ans2s<<endl;
}

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

using namespace std;

int main(void){
  char s[1001][33];
  map<string,int>wd;
  int i=0;

  while(~scanf("%s",&s[i][0])){i++;}

  for(int j=0;j<i;j++)
    wd[s[j]]=0;

  for(int j=0;j<i;j++)
    wd[s[j]]++;

  int ans=0,len=0;
  for(int j=0;j<i;j++){
    ans=max(wd[s[j]],ans);
    len=max(len,(int)strlen(&s[j][0]));
  }

  string s1,s2;
  for(int j=0;j<i;j++){
    if(ans==wd[s[j]])s1=s[j];
    if(len==strlen(s[j]))s2=s[j];
  }
  cout << s1 << " " << s2 << endl;
  return 0;
}

C++: #include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <boost/algorithm/string.hpp>
#include <cstdint>

typedef std::map<std::string, std::uint32_t> OccurenceWordMap;

class compare_second {
		typedef OccurenceWordMap::value_type value_type;
	public:
		bool operator()(value_type const& lhs, value_type const& rhs) const
		{
			return lhs.second < rhs.second;
		}
};

class compare_length {
		typedef std::string value_type;
	public:
		bool operator()(value_type const& lhs, value_type const& rhs) const
		{
			return lhs.length() < rhs.length();
		}
};

int main()
{
	std::string input_text;
	std::getline(std::cin, input_text);
	typedef std::vector<std::string> StringVec;
	StringVec word_vec;
	boost::algorithm::split(word_vec, input_text, boost::algorithm::is_space());
	OccurenceWordMap ow_map;
	for (std::string const& word : word_vec) {
		auto i = ow_map.lower_bound(word);
		if (i != ow_map.end() && !(ow_map.key_comp()(word, i->first))) {
			++i->second;
		}
		else {
			ow_map.emplace(word, 0);
		}
	}
	std::cout << std::max_element(ow_map.begin(), ow_map.end(), compare_second())->first << ' '
			  << *std::max_element(word_vec.begin(), word_vec.end(),  compare_length()) << std::endl;
	return 0;
}

C++: #include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>

using namespace std;
typedef long long ll;

int paper[10][10]={0};

int main(){
    char in[50];
    int ans_max=0,ans_long=0;
    string s_max,s_long;
    map<string,int> mm;
    
    while(EOF!=scanf("%s",in)){
        
        string S = in;
        
        if((int)S.size() > ans_long){
            s_long = S;
        }
        
        mm[S]++;
    }
    
    for(map<string,int>::iterator it = mm.begin();it!=mm.end();it++){
        if(it->second > ans_max){
            ans_max = it->second;
            s_max = it->first;
        }
    }
    
    cout << s_max <<  " " << s_long << endl;
    
    return 0;
}

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

int main(void){
	map<string, int> sentence;
	 
	string maxFrequentSentence="";
	string maxCharacterSentence="";
	string inputSentence;
	
	/* Input */
	while( cin >> inputSentence )
	{
		/* CountUp Sentence*/
		if( sentence.count(inputSentence) != 0 )
		{
			sentence[inputSentence] = sentence[inputSentence] + 1;
		}
		else
		{
			sentence[inputSentence] = 0;
		}
		
		/* Update Max Characters Sentence */
		if( maxCharacterSentence.size() < inputSentence.size() )
		{
			maxCharacterSentence = inputSentence;
		}
		
		/* Update Max Frequent Sentence */
		if( sentence[maxFrequentSentence] < sentence[inputSentence] )
		{
			maxFrequentSentence = inputSentence;
		}
	}
	
	/* Output */
	cout << maxFrequentSentence << " " << maxCharacterSentence << endl;
 
	return 0;
}

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

int main() {
	map<string,int> len,times;
	vector<string> brain;

	string ts;
	int maxlength = 0;
	int maxcount = 0;
	string AL,AC;

	while(cin >> ts) {
		if(times.count(ts)>0) {
			times[ts] += 1;
		} else {
			times.insert(make_pair(ts,1));
			len.insert(make_pair(ts,ts.length()));
			brain.push_back(ts);
		}

	}
	for(int i=0;i<len.size(); i++) {
		if(len[brain[i]] > maxlength) {
			maxlength = len[brain[i]];
			AL = brain[i];
		}
		if(times[brain[i]] > maxcount) {
			maxcount = times[brain[i]];
			AC = brain[i];
		}
	}
	cout << AC << " " << AL << endl;
}

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

int main() {
    map<string, int> words;
    string word;
    while (cin >> word) {
        words[word]++;
    }
    pair<string, int> mode = make_pair("", 0);
    string maxLength = "";
    for (map<string, int>::iterator it = words.begin(); it != words.end(); it++) {
        if (it->second > mode.second) {
            mode = *it;
        }
        if (it->first.length() > maxLength.length()) {
            maxLength = it->first;
        }
    }
    cout << mode.first << " " << maxLength << endl;
}