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 <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <iostream>


using namespace std;

int main()
{
	map<string, int> count;
	int m = 0;
	string first;
	string second("");
	while (!cin.eof())
	{
		string s;
		cin >> s;
		if (count.count(s) == 0)
			count.insert(make_pair(s, 1));
		else
			count.find(s)->second++;

		if (count.find(s)->second > m)
		{
			first = s;
			m = count.find(s)->second;
		}

		if (s.size() > second.size())
			second = s;
	}
	cout << first << " " << second << endl;
	
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;

typedef pair<int, int> Pii;
typedef pair<string, string> Pss;

map <string, Pii> dic;

int main() {
  string str;
  Pss result;
  while ( cin >> str ) {
    dic[str].first++;
    dic[str].second = str.size();

    if ( dic[result.first].first < dic[str].first ) result.first = str;
    if ( dic[result.second].second < dic[str].second ) result.second = str;

  }

  cout << result.first << " " << result.second << endl;
  return 0;
}

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

map<string, int > hindo;

int main()
{
  string str;
  while (cin >> str) {
    hindo[str]++;
  }
  int mx = 0, mx_l = 0;
  for (map<string, int>::iterator it = hindo.begin(); it != hindo.end(); it++) {
    mx = max(it->second, mx);
    mx_l = max(mx_l, (int)it->first.size());
  }
  for (map<string, int>::iterator it = hindo.begin(); it != hindo.end(); it++) {
    if (mx == it->second) {
      cout << it->first << " ";
    }
  }
  for (map<string, int>::iterator it = hindo.begin(); it != hindo.end(); it++) {
    if (mx_l == it->first.size()) {
      cout << it->first << endl;
    }
  }
  return 0;
}

C++: #include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(){
string in[1000];
int max=0;
string ml_str;
int tmp;
string ans;
int i=0;
for(i=0;cin>>in[i];i++){
if(in[i].size()>max){
max=in[i].size();
ml_str=in[i];
}
}
sort(in,in+i);
tmp=1;
max=0;
for(int j=1;j<i;j++){
if(in[j]==in[j-1]){
tmp++;
}else{
if(max<tmp){
max=tmp;
ans=in[j-1];
tmp=1;
}
}
}
cout<<ans<<" "<<ml_str<<endl;
}

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

struct P {
  string s;
  int n;
};

int main(){
  vector<P> v;
  string s,d="";
  P p;
  int f=0, l=0;

  getline( cin,s );
  //  cout << "input : "<< s << endl;

  for( unsigned int i=0;i<s.length();i++ ){
    if( s[i]==' ' || i==s.length()-1 ){
      if( s[i]!=' ' ) d += s[i];
      p.s = d;

      //      cout << d << endl;
      unsigned int j;
      for( j=0;j<v.size();j++ ){
	if( v[j].s==d ){
	  v[j].n++;
	  f = max( f,v[j].n ); break;
	}
      }
      if( j==v.size() ){
	p.s = d; p.n=1;
	v.push_back( p );
	l = max( l,(int)d.length() );
      }
      d="";
    }else{
      d = d + s[i];
    }
  }

  for( unsigned int i=0;i<v.size();i++ ){
    if( v[i].n==f ){
      cout << v[i].s << " "; break;
    }
  }
  for( unsigned int i=0;i<v.size();i++ ){
    if( (int)v[i].s.length()==l ){
      cout << v[i].s << endl; break;
    }
  }

  return 0;
}

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[M][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 <iostream>
#include <string>

using namespace std;

int main(void){
    int i,j,k=0,l;
    int f=0;
    string str;
    string max="\0";
    int count[100]={0};
    string count_str[100];
    int count_max=0;
    
    while(cin>>str){
        if(max.size()<str.size()){
            max=str;
        }
        for(i=0;i<k;i++){
            if(count_str[i]==str){
                count[i]++;
                f=1;
                break;
            }
        }
        if(f==0){
            count_str[k]=str;
            k++;
        }
    }
    
    for(i=0;i<k;i++){
        if(count[count_max]<=count[i]){
            count_max=i;
        }
    }
    cout<<count_str[count_max]<<" "<<max<<endl;
    return(0);
}

C++: #include<iostream>
#include<string.h>
#include<vector>
#include<algorithm>
#include<map>
using namespace std;
int main()
{
    map<string,int> m;
    string s;
    getline(cin,s);
    string tem="";
    for(int i=0;i<s.length();i++){
        if(s[i]!=' '&&s[i]!='\n')
            tem+=s[i];
        else{
            if(m.find(tem)!=m.end()){
                (m.find(tem))->second++;
            }
            else{
                m.insert(pair<string,int>(tem,1));
            }
            tem="";
        }
    }
    if(m.find(tem)!=m.end()){
        (m.find(tem))->second++;
    }
    else{
        m.insert(pair<string,int>(tem,1));
    }
    string most,longest;
    map<string,int>::iterator it = m.begin();
    int mo=0;
    for(;it!=m.end();it++){
        if(it->first.length()>longest.length())
            longest=it->first;
        if(it->second>mo){
            most=it->first;
            mo=it->second;
        }
     //   cout<<it->first<<"    "<<it->second<<endl;
    }
    cout<<most<<" "<<longest<<endl;
    return 0;
}

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

int main(){
  std::string str;
  std::string maxlen;
  std::string maxocc;
  std::map<std::string, int> occ;
  //std::cin >> str;
  //std::cout << str << std::endl;

  while(std::cin >> str){
    if(str.size()>maxlen.size()){
      maxlen = str;
    }
    occ[str]++;
    if(occ[str]>occ[maxocc]){
      maxocc = str;
    }
  }
  std::cout << maxocc << ' ' << maxlen << std::endl;
}