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>
using namespace std ;

int main()
{
	char get[1000][40] ;
	char mode[40] ;
	char longest[40] ;

	int count = 0 ;
	int lest = -1 ;
	
	int tmp = 0 ;

	int most = 0 ;
	int mnum = -1 ;

	int i = 0 ;

	while( cin >> get[i] )
	{
		if( count < strlen(get[i]) )
		{
			count = strlen(get[i]) ;
			lest = i ;
		}

		for( int j = (i-1) ; j >= 0 ;  j -- )
		{
			if( strcmp( get[i], get[j] ) == 0 )
			{
				tmp ++ ;
			}
		}
		tmp = 0 ;

		if( most < tmp )
		{
			most = tmp ;
			mnum = i ;
		}

		i ++ ;
	}

	cout << get[mnum] << " " << get[lest] ;

	return 0 ;
}

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

int main(){
    map<string, int> word;
    string s;
    string outen;
    string outlen;
    int maxen;
    int maxlen;
    maxen = 0;
    maxlen = 0;
    while(cin >> s){
        if(word.find(s) != word.end()){
            word[s]++;
            if(word[s] > maxen){
                outen = s;
            }
        }else{
            word.insert(map<string, int>::value_type(s, 1));
            if(s.size() > maxlen){
                outlen = s;
            }
            if(word[s] > maxen){
                outen = s;
            }
        }
    }
    cout << outen << " " << outlen << endl;
    return 0;
}

C++: #include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<cassert>
using namespace std;
int inf = 1000000000;

int main(void) {

  string s;
  getline(cin, s);
  s += ' ';
  string tmp = "";
  string maxword = "";
  vector< pair<string, int> > p;
  for(int i=0; i<s.size(); i++){
    if( s[i] != ' ' ) tmp += s[i];
    else{
      if( maxword.size() < tmp.size() ) maxword = tmp;
      bool f = false;
      for(int j=0; j<p.size(); j++){
        if( p[j].first == tmp ){
          f = true;
          p[j].second++;
        }
      }
      if( !f ) p.push_back( make_pair(tmp, 1) );
      tmp = "";
    }
  }
  int mx = 0;
  string med;
  for(int i=0; i<p.size(); i++){
    if( mx < p[i].second ){
      mx = p[i].second;
      med = p[i].first;
    }
  }
  cout << med << " " << maxword << endl;

  return 0;
}


// EOF

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

using namespace std;

int main(){
  string s;
  string max;
  int maxsize  = 0;
  map <string, int> m;
  while(cin >> s)
  	m[s]++;
   if(s.size() > maxsize){
       max = s;
       maxsize = s.size();
   }

   map<string,int>::iterator it = m.begin();
   string freq;
   int maxfreq = 0;
   for(it; it != m.end();it++){
   	 int k = (*it).second;
   	  if(k > maxfreq ){
   	  	maxfreq = k;
   	  	freq = (*it).first;
   	  }
   }
   cout << freq << " " << max << endl;
}

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

int main() {

    map<string,int> word_map;
    map<string,int>::iterator it;
    string s,freq_word,long_word;
    int freq_count=0;
    
    //cout << "???????????\?????????????????????" << endl;
    while (cin >> s) {
        it = word_map.find(s);
        if(it == word_map.end()){
            word_map.insert(map<string,int>::value_type(s,1));
            it = word_map.find(s);
        }
        else{
            (*it).second += 1;
        }
        //??????????????????
        if ((*it).second > freq_count) {
            freq_count = (*it).second;
            freq_word = s;
        }
        //?????°????¢????
        if (s.size() > long_word.size())
            long_word = s;
    
    }
    
    cout << freq_word << " " << long_word << endl;
}

C++: #include<stdio.h>
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
struct R{string word;
int nl;int ty;

};

int main(){

	struct R RR[1001]={};
	int i=0;
	string str;
	while(cin>>str){
		RR[i].word=str;RR[i].nl=str.size();RR[i].ty=0;
	i++;
	}
	
	for(int I=0;I<i;I++)
		for(int J=0;J<i;J++)
			if(RR[I].word==RR[J].word)RR[I].ty++;

	string x,y;
	int max1=0,max2=0;

	for(int I=0;I<i;I++)
	{//cout<<RR[I].ty<<endl;
		if(RR[I].nl>max1)x=RR[I].word;
	 if(RR[I].ty>max2)y=RR[I].word;}

	cout<<y<<" "<<x<<endl;
return 0;

}

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

using namespace std;

void solve()
{
	string word;
	map<string, int> Map;
	string ansLongWord;
	int maxLen = 0;
	while(cin >> word)
	{
		if(maxLen < word.size())
		{
			maxLen = word.size();
			ansLongWord = word;
		}
		++Map[word];
	}
	map<string, int>::iterator it = Map.begin();
	int maxCount = 0;
	string ansFreqWord;
	while(it != Map.end())
	{
		if(maxCount < it->second)
		{
			maxCount = it->second;
			ansFreqWord = it->first;
		}
		++it;
	}
	cout << ansFreqWord << " " << ansLongWord << endl;
}

int main()
{
	solve();
	return(0);
}

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

map<string,int> table;

int main(){
	string word, frequent, longest;
	int frequent_length = 0;
	while (cin >> word){
		table[word] += 1;
		if (table[word] > frequent_length){
			frequent_length = table[word];
			frequent = word;
		}
		longest = (word.size() > longest.size()) ? word : longest;
	}	
	cout << frequent << ' ' << longest << endl;
	return 0;
}

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

int main() {
	string str[1000],tmp;
	int a[1000] = {}, flag = 0, max = 1, i, length = 0, num = 0;

	while (cin >> tmp) {
		if (flag == 0) {
			flag++;
			tmp[0] = tmp[0] - 'a';
		}
		for (i = 0; i < max; i++) {
			if (tmp == str[i]){
				a[i]++;
				break;
			}
		}
		if (i == max)
			str[i] = tmp;
	}

	if ((int)size(tmp) > length) {
		num = i;
		length = size(tmp);
	}

	cout << str[max] << " " << str[length] << endl;
	return 0;
}

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

using namespace std;

int main()
{
	char s[1000];
	int n=0;
	cin.getline(s,1000);
	string tok[1000];
	char *sep=" ,.";
	char *word;
	word = strtok(s,sep);
	while(word != NULL)
	{
		tok[n] = word;
		n++;
		word=strtok(NULL,sep);
	}
	int f=1,fmax=1;
	string max, freq;
	max=tok[0]; freq=tok[0];
	for(int i=0;i<n;i++)
	{
		if(tok[i].length()>max.length())
			max=tok[i];
		f=1;
		for(int j=i+1;j<n;j++){
			if(tok[i]==tok[j])
				f++;
		}
		if(f>fmax)
		{
			fmax=f; freq=tok[i];
		}
	}
	cout << freq <<" " <<max;
}

C++: #include <iostream>
#include <iomanip>
#include <algorithm>
#include <stdio.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <cstring>
#include <map>
#include <cctype>
#include <string>
#include <cstdlib>
#include <math.h>
using namespace std;

#define REP(i,n)  for(int i=0; i<n; i++)

int main()
{
  cout << setprecision(6);
  cout << setiosflags(ios::scientific);
  cout.flags(ios::fixed);

  map<string, int> counts;

  string str;
  int maxLen=0;
  while(cin >> str){
    counts[str]++;
    maxLen = max((int)str.size(), maxLen);
  }

  string maxLenStr="";
  string maxCountStr = "";
  int maxCount=0;
  map<string, int>::iterator it = counts.begin();
  for(it=counts.begin(); it!=counts.end(); it++){
    if(it->first.size() == maxLen)
      maxLenStr = it->first;
    int m = max(maxCount, it->second);
    if(m!=maxCount){
      maxCountStr = it->first;
      maxCount = m;
    }
  }

  cout << maxCountStr << " " <<  maxLenStr << endl;
}