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++: using namespace std;
#include <iostream>
#include <string>
#include <set>
#include <functional>
#include <vector>
#include <algorithm>
struct word{
	string spell;
	int count;
};
int main()
{
	vector<word> w;
	string s;
	while(cin>>s){
		bool find=false;
		for(int i=0;i<(int)w.size();i++){
			//cout<<"OK"<<endl;
			word* tmp=&w.at(i);
			if(tmp->spell==s){
				tmp->count++;
				find=true;
				break;
			}
		}
		if(find)continue;
		word a={s,1};
		w.push_back(a);
	}
	cout<<"OK"<<endl;
	string l="";
	word m={"",0};
	for(int i=0;i<(int)w.size();i++){
		word tmp=w.at(i);
		if(tmp.count>m.count)m=tmp;
		if(tmp.spell.length()>l.length())l=tmp.spell;
	}
	cout<<m.spell<<" "<<l<<endl;
    return 0;
}

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

int main(){
  string s,t;
  map<string,int>m;
  for(;cin>>s;)m[s]++;
  s=t=(*m.begin()).first;
  int M=(*m.begin()).second,l=s.length();
  for(map<string,int>::iterator it=m.begin();it!=m.end();it++){
    if(M<(*it).second)M=(*it).second,s=(*it).first;
    if(l<(*it).first.length())l=(*it).first.length(),t=(*it).first;
  }
  cout<<s<<' '<<t<<endl;
}

C++: #include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++) 
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
int main()
{
    string S;
    vector<string> vc;
    map<string, int> cnt;
    while( cin >> S ){
        vc.emplace_back( S );
        cnt[ S ]++;
    }
    int MAX{}, MAX2{};
    string res, res2;
    for( const auto &x: cnt )
    {
        if( MAX < x.second )
        {
            MAX = x.second;
            res = x.first;
        }
        if( MAX2 < (int)(x.first).size() )
        {
            MAX2 = (int)(x.first).size();
            res2 = x.first;
        }
    }
    cout << res << " " << res2 << endl;
    return 0;
}

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