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<bits/stdc++.h>
using namespace std;

int main(){
	int max = 0;
	string max_str;

	string str;
	vector<string> v;
	while(cin >> str){
		transform(str.begin(), str.end(), str.begin(), ::tolower);

		v.push_back(str);

		if(v.size() > max){
			max_str = str;
		}
	}
	sort(v.rbegin(), v.rend());
	cout << v[0] << endl;

	cout << max_str << endl;
}

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

map<string,int> mp; 
int main(){
  int maxcnt=0;
  string str,maxs="";
    //入力
  while(cin>>str){
    //文字数が一番多い文字判定
    if(maxs.size()<=str.size())maxs=str;
    //大文字を小文字に変換
    for(int i=0;i<str.size();i++){
      if(str[i]>='A' && str[i]<='Z'){
	str[i]+='a'-'A';
      }
    }
    mp[str]++;
    //頻繁判定
    if(maxcnt<mp[str])maxcnt=mp[str];
  }
    //出力
  for(map<string,int>::iterator it=mp.begin() ;it!=mp.end();++it){
    if((*it).second==maxcnt){
      cout<<(*it).first<<" "<<maxs<<endl;
      break;
    }
  }
  return 0;
}

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

int main() {
	std::string word, longest, freqest;
	std::map<std::string, int> table;
	//入力
	while (std::cin >> word) ++table[word];
	//演算
	longest = table.begin()->first;
	freqest = table.begin()->first;
	for (std::map<std::string, int>::iterator it = table.begin(); it != table.end(); ++it) {
		if (longest.length() < it->first.length()) longest = it->first;
		if (table[freqest] < it->second) freqest = it->first;
	}
	//出力
	std::cout << freqest << " " << longest << std::endl;
	return 0;
}

C++: #include<stdio.h>
#include<malloc.h>
#include<string.h>
#include<stdlib.h>

typedef struct wordtree{
	struct wordtree *next;
	struct wordtree *prev;
	char *txt;
	int t_num;
	int t_size;
}wordtree;

wordtree *initTree(char *msg,int num,int size){
	wordtree *x;
	x=(wordtree *)malloc(sizeof(wordtree));
	x->prev=NULL;
	x->next=NULL;
	x->txt=(char *)malloc(sizeof(char));
	strcpy(x->txt,msg);
	x->t_num=num;
	x->t_size=size;
	return x;
}
int cnt=0;often=0;length=0;
char *mod2,*mod3;
void graphtree(wordtree *tree,int mode){
	switch(mode){
		case 1:if(tree->txt!="")printf("msg=%s,num=%d,size=%d,depth=%d\n",tree->txt,tree->t_num,tree->t_size,cnt);
		case 2:if(tree->t_num>=often){often=tree->t_num;mod2=tree->txt;}
		case 3:if(tree->t_size>=length){length=tree->t_size;mod3=tree->txt;}
	}
	if(tree->next!=NULL){
		cnt++;
		graphtree(tree->next,mode);
	}
	if(tree->prev!=NULL){
		cnt--;
		graphtree(tree->prev,mode);
	}
	return ;
}
		
void addToTree(char *msg,wordtree *tree){
	wordtree *x;
	x=tree;
	if(strcmp(msg, x->txt)>0){
		if(x->next==NULL){
			x->next=initTree(msg,1,strlen(msg));
			return;
		}else{
			addToTree(msg,x->next);
		}
	}else{
		if(x->prev==NULL){
			x->prev=initTree(msg,1,strlen(msg));
			return;
		}else{
			addToTree(msg,x->prev);
		}
	}
}

wordtree *searchTree(char *msg,wordtree *tree){
	wordtree *x;
	x=tree;
	if(strcmp(msg,x->txt)>0){
		if(x->next==NULL)return NULL;
		else searchTree(msg,x->next);
	}else if(strcmp(msg,x->txt)<0){
		if(x->prev==NULL)return NULL;
		else searchTree(msg,x->prev);
	}else{
		return x;
	}
}

int main(){
	wordtree *r,*p;
	int i,j;
	char txt[1024],s[32];
	memset(s,'\0',sizeof(s));
	r=initTree("nn",0,0);//root
	while(fgets(txt,sizeof(txt),stdin)!=NULL){
		for(i=0,j=0;i<strlen(txt);i++){
			if((65<=txt[i]&&txt[i]<=90)||(97<=txt[i]&&txt[i]<=122)){
				if((65<=txt[i]&&txt[i]<=90))txt[i]+=32;
				s[j]=txt[i]; j++;
			}else{
				j=0;
				p=searchTree(s,r);
				if(p==NULL)	addToTree(s,r);
				else p->t_num++;
				memset(s,'\0',sizeof(s));
			}
		}
		//graphtree(r,1);
		graphtree(r,2);
		graphtree(r,3);
		printf("%s %s\n",mod2,mod3);
	}		
	return 0;	
}

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


int main(){

	string s[1002];
	int k=0,size_max=0,s_max=0,count_max=0,count_max_number;
	int scount[1002]={0};
	
	
	
	while (cin>>s[k]){
		k++;
	}
	for (int i=0; i<k; i++) {
		for (int j=i+1; j<k; j++) {
			if (s[i]==s[j]) {
				scount[i]++;
			}
		}
	}
	
	for (int i=0; i<k; i++) {
		if (count_max<scount[i]) {
			count_max=scount[i];
			count_max_number=i;
		}
		if (size_max<s[i].size()) {
			size_max=s[i].size();
			s_max=i;
		}
	}
	
	cout << s[count_max_number] << ' '<< s[s_max] << endl;
	
	return 0;
}

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

int main()
{
    map<string,int> str;
    map<string,int> :: iterator it;
    string s,t1,t2;
    int max1=0,max2=0;

    while(cin >> s)
    {
        str[s]++;
        if(s.size()>max1)
        {
            max1 = s.size();
            t1 = s;
        }
        if(str[s]>max2)
        {
            max2 = str[s];
            t2 = s;
        }
    }

    cout << t2 << " " << t1 << "\n";
    return 0;
}

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

typedef struct _string_mode
{
	char str[33] ;
	short num ;
} stm ;


int main()
{
	char get[33] ;
	char longest[33] = { '\0' } ;
	stm string[1000] ;
	int mode = 0;
	int i = 0, j ;

	while( cin >> get )
	{
		if( strlen(longest) < strlen(get) )	strcpy( longest,get ) ;

		i ++ ;
		strcpy( string[i].str, get ) ;
		string[i].num = 1 ;
		for( j = 0 ; j < i ; j ++ )
		{
			if( strcmp(string[j].str,string[i].str) == 0 )
			{
				string[j].num += string[i].num ;
				if( mode < string[j].num ){ mode = string[j].num ; }
				break ;
			}
		}
	}

	for( j = 0 ; j < i ; j ++ )
	{
		if( string[j].num == mode )
		{
			cout << string[j].str << " " << longest << endl ;
			break ;
		}
	}

	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;
                maxen = word[s];
            }
            if(s.size() > maxlen){
                outlen = s;
                maxlen = s.size();
            }
        }else{
            word.insert(map<string, int>::value_type(s, 1));
            if(s.size() > maxlen){
                outlen = s;
                maxlen = s.size();
            }
            if(word[s] > maxen){
                outen = s;
                maxen = word[s];
            }
        }
    }
    cout << outen << " " << outlen << endl;
    return 0;
}

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

using namespace std;

#define reps(i,f,n) for(int i=f;i<int(n);i++)
#define rep(i,n) reps(i,0,n)


#define X real()
#define Y imag()
typedef complex<double> P;

int main(){
	
	typedef pair<int,string> pis;
	vector<pis> a;
	vector<pis> b;
	
	map<string,int> m;
	
	string str;
	while(cin>>str){
		a.push_back( pis((int)str.size(),str) );
		m[str]++;
	}
	
	map<string,int>::iterator it=m.begin();
	while(it!=m.end()){
		b.push_back(pis(-it->second,it->first));
		it++;
	}
	
	sort(a.begin(),a.end());
	sort(b.begin(),b.end());
	
	cout<<b[0].second<<endl<<a[a.size()-1].second<<endl;
	
	
}