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<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<map>
using namespace std;
int main()
{
    char a[1005];
    string b,c;
    int i,j;
    while(cin.getline(a,1000))
    {
        map<string,int>M;
        int len = strlen(a);
        string s;
        s="";
        int m = -1,g=0,gg=-1;
        for(i=0;i<len;i++)
        {
            if(a[i]==' ')
            {
                if(M[s]==0)
                  M[s]++;
                else M[s]++;
                if(g>gg)
                {
                    gg=g;
                    c=s;
                    //cout<<g<<" "<<s<<endl;
                }
                if(M[s]>m)
                {
                    m=M[s];
                    b=s;
                }
                s="";
                g=0;
            }
            else
            {
                s+=a[i];
                g++;
            }
        }
        if(g>gg)
        {
            gg=g;
            c=s;
            //cout<<g<<" "<<s<<endl;
        }
        if(M[s]>m)
        {
            m=M[s];
            b=s;
        }
        cout<<b<<" "<<c<<endl;
    }
}

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

int main(){
    map<string, int> M;
    string s,slongest,smost;
    cin >> s;
    slongest = s;
    smost = s;
    M[s]++;

    while (cin >> s){
        M[s]++;
        if (s.size() >= slongest.size())
            slongest = s;
        if (M[s] > M[smost])
            smost = s;
    }
    cout << smost << " " << slongest << endl;
}

C++: #include<iostream>
#include<string>
#include<vector>
using namespace std;
int main(){
  vector<string> str;
  string s;
  int cnt=0;
  int pointer[1000]={};
  pair<int,string> pis;
  pis=make_pair(0,"");
  while(cin>>s){
    int flag=1;
    for(int i=0;i<str.size();i++){
      if(str[i]==s){
	pointer[i]++;
	flag=0;
	break;
      }
    }if(flag){
      str.push_back(s);
      pointer[str.size()-1]++;
      if(pis.first<s.size()){
	pis.first=s.size();
	pis.second=s;
      }
    }
  }
  pair<int,int> poin;
  poin=make_pair(0,0);
  for(int i=0;i<str.size();i++){
    if(poin.first<pointer[i]){
      poin.first=pointer[i];
      poin.second=i;
    }
  }
  cout<<str[poin.second]<<" "<<pis.second<<endl;
  return 0;
}

C++: #include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<cstring>
using namespace std;
int main(){
	char ans[50][10000] = {{0}};
	char a[10000] = {0};
	scanf("%[^\n]",a);
	int cnt = 0;
	int mx_len = 0;
	char date[10000] = {0};
	a[strlen(a)] = ' ';
	for(int i = 0,j = 0; i <= strlen(a); i++){
        if(a[i] >= 'a' && a[i] <= 'z' || a[i] >= 'A' && a[i] <= 'Z'){
            ans[cnt][j] = a[i];
            j++;
        }
        else{
            cnt++;
            j = 0;
        }
	}
	for(int i = 0; i < cnt; i++){
        cout << ans[i] << endl;
	}
	return 0;
}

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

int main(void){
  int max=0, length=0;
  map<string,int> word; //文字列と回数
  vector<string> w;
  string str;

  while(cin >> str){
    w.push_back(str);

    if(word.find(str) != word.end() ){ //単語が重複
      word[str]++;
    }else{
      word.insert( pair<string, int>(str, 1));
    }
  }

  map<string,int>::iterator p;
  for(p = word.begin() ; p != word.end() ; p++){
    if( max < p->second) {
      max = p->second;
    }
  }
  for(p = word.begin() ; p != word.end() ; p++){
    if( max == p->second){
      cout << p->first << " ";
      break;
    }
  }
  for(int i=0 ; i<w.size() ; i++){
    if( length < w[i].size() ) {
      length = w[i].size();
    }
  }
  for(int i=0 ; i<w.size() ; i++){
    if( length==w[i].size() ){
      cout << w[i] << endl;
      break;
    }
  }
  return 0;
}

C++: #include<stdio.h>
#include<string>
#include<iostream>
#include <ctype.h>


using namespace std;
struct ST{string str;int c;int z;};

int main(){

int i=0;
string str,sth,stl;
struct ST P[1001];
int max=0;
while(cin>>str){
//	for(int j=0;j<str.size();j++)
//	str[i] = tolower( str[i] );

P[i].str=str;P[i].c=0;P[i].z=(int)str.size();
i++;
}
for(int j=0;j<i;j++)
for(int k=i-1;k>j;k--)
	if(P[k-1].str>P[k].str)
//if(P[k-1].str>P[k].str)
//if(strcmp(P[k-1].str,P[k].str)>0)
{


struct ST TEM=P[k-1];P[k-1]=P[k];P[k]=TEM;
//cout<<"*";
}

for(int j=1;j<i;j++)
{if(P[j-1].str==P[j].str)P[j].c++;

}
max=0;
for(int j=0;j<i;j++)
{if(max<P[j].c){max=P[j].c;sth=P[j].str;}}
max=0;
for(int j=0;j<i;j++)
	if(P[j].z>max){max=P[j].z;stl=P[j].str;}

cout<<sth<<" "<<stl<<endl;

//for(int j=0;j<i;j++)
//	cout<<P[j].str<<P[j].z<<endl;

return 0;
}

C++: #include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <map>
using namespace std;

#define FOR(i,a,b) for(long long int i=(a);i<(b);i++)
#define REP(i,n) for(long long int i=0;i<(n);i++)
#define ALL(s) (s).begin(),(s).end()

#define PI 3.14159265358479

typedef long long ll;
typedef vector<long long int> vi;
typedef vector<long long int>::iterator vit;

int main(){
	map<string, int>table;
	string s, f, l;
	string::iterator it = s.begin();
	size_t n = 0;
	while (cin >> s){
		if (it == s.end())break;
		table[s]++;
		if (table[s] > n){
			n = table[s];
			f = s;
		}
		if (s.size() > l.size()){
			l = s;
		}
		it++;
	}
	cout << f << l << endl;
}

C++: #include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<time.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
const int inf=1e8;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
vector<vector<char> >tmp;
vector<vector<int> >scr;
int main(){
	string s;
	string nagai;
	int naga=-1;
	map<string,int>m;
	while(cin>>s){
		if(naga<s.size()){naga=s.size();nagai=s;}
		m[s]++;
	}
	int ma=-1;
	string mas;
	map<string,int>::iterator it=m.begin();
	for(;it<m.end();it++){
		string t=it->first;
		if(ma<m[t]){ma=m[t];mas=t;}
	}
	cout<<mas<<" "<<nagai<<endl;
}

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

int main(){
	char str[1000];
	char word[33][33]={0};
	int longest=0;
	int check[33]={0};
	char *tmp;
	int freq=0;
	int count=0;
	int i,j;
	size_t len , prev;
	fgets(str , sizeof(str) , stdin);
		tmp=str;
		for(i=0 ; str[i]!='\0' ;i++){
			if(str[i]==' '){
				str[i]='\0';
				strcpy((char*)&word[count] , (const char*)tmp);
				tmp=str+i+1;
				count++;
			}
		}
		strcpy((char*)&word[count],(const char*)tmp);
		count++;
	for(i=0 ; i<count ; i++){
		for(j=i ; j<count ; j++){
			if(strcmp((const char*)&word[i] , (const char*)&word[j])==0){
				check[i]++;
			}
		}
	}
	for(i=count; i>=0 ; i--){
		for(j=0 ; j<i-1 ; j++){
			if(check[j]>check[j+1]){
				check[j]^=check[j+1];
				check[j+1]^=check[j];
				check[j]^=check[j+1];
				freq=j;
			}
		}
	}
		prev=strlen(word[0]);
	for (i=0 ; i<count ; i++){
		len=strlen(word[i]);
		if(len > prev){
			prev = len;
			longest=i;
		}	
	}
	
	cout << (char*)&(word[freq]) << " "<< (char*)&(word[longest]) << endl;
	return 0;
}