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++: #include <iostream>
#include <string>
#include <map>
#include <vector>
using namespace std;

int main(){
	// word[s] Å ¶ñsÌo»ñªÔÁÄ­é
	map<string, int> word;
	vector<string> v;
	string s;

	while( cin >> s ){
		v.push_back(s);
		
		//üÍµ½Pêª·ÅÉ é©T·
		if( word.count(s) ){
			word[s]++;
		}else{
			word[s] = 1;
		}
	}
	// ÅpoÌPêð²×é
	int mode=0;
	for(int i=0 ; i < v.size() ; i++ ){
		mode = max( mode , word[ v[i] ] );
	}
	for(int i=0 ; i < v.size() ; i++ ){
		if( mode == word[ v[i] ] ){
			cout << v[i];
		}
	}
	// Å·ÌPêðßé
	int length = 0;
	for(int i=0 ; i < v.size() ; i++ ){
		length = max( length , (int)v[i].size() );
	}
	for(int i=0 ; i < v.size() ; i++ ){
		if( length == v[i].size() ){
			cout << " " << v[i] << endl;
		}
	}
}

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

bool compare(const pair<string, int> T1, const pair<string, int> T2) {
	return T1.second < T2.second;
}

int main (void){

	string str,maxByLength("");
	//map<int,string> X; //¶Ì·³
	map<string,int> Y; //¶Ì
	//int mm;

	while (cin>>str){
		if (str.size()>maxByLength.size())	maxByLength=str;
		Y[str]++;
	}

	// string maxByCount("");
	// int cnt = 0;
	pair<string, int> maxCountPair = *max_element(Y.begin(), Y.end(), compare);

	// cout << (*Y.rbegin()).first << " " << maxByLength << endl;
	// cout << maxByCount << " " << maxByLength << endl;
	cout << maxCountPair.first << " " << maxByLength << endl;

	return 0;

}

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