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 <string>
using namespace std;
int main(){
    long saidai=0;
    int a=0,cnt=0,num=0,max=0;
    string str,tango[1000]={""},answer,ans;
    getline(cin,str);
    for(int i=0;i<str.size();i++){
        if(str[i]==' '){
            for(int j=a;j<i;j++){
                tango[cnt]+=str[j];
            }
            cnt=cnt+1;
            a=i+1;
        }
    }
    for(int p=a;p<str.size();p++){
        tango[cnt]+=str[p];
    }
    
    for(int k=0;k<1000;k++){
        if((tango[k]==""))break;
        if(saidai<tango[k].size()){
            saidai=tango[k].size();
            ans=tango[k];
        }
    }
    
    for(int s=0;s<=cnt;s++){
        for(int t=s+1;t<=cnt;t++){
            if(tango[s]==tango[t]){
                num=num+1;
            }
        }
        if(max<num){
            max=num;
            answer=tango[s];
        }
    }
    cout<<answer<<" "<<ans<<endl;
    return 0;
}

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

int main() {
  string sa[1000];
  int ia[1000] = {};

  int cnt = 0;
  string s, ss = "";
  while(cin >> s) {
    for(int i = 0; i < s.size(); i++) {
      if('A' <= s[i] && s[i] <= 'Z') s[i] += 'a'-'A';
    }

    int p = -1;
    for(int i = 0; i < cnt; i++) {
      if(sa[i] == s) p = i;
    }

    if(p != -1) ia[p]++;
    else {
      ia[cnt]++;
      sa[cnt++] = s;
    }

    if(s.size() > ss.size()) ss = s;
  }

  int f = -1;
  string fs;
  for(int i = 0; i < cnt; i++) {
    if(f < ia[i]) {
      fs = sa[i];
      f = ia[i];
    }
  }
  cout << fs << ' ' << ss << endl;
}

C++: #include <cstdio>
#include <cstring>
#include <string>
#include <algorithm>
using namespace std;
int main()
{
	int m=0,i,j,t=0,p=0,count,len,max_len=0;
	int dc[1001];
	for(i=0;i<1001;i++)
	{
		dc[i] = 0;
	}
	char str[1001],max_word[33],word[33],d[1001][33];
	fgets(str,sizeof(str),stdin);
	memset(d,'\0',sizeof(d));
	memset(word,'\0',sizeof(word));
	len = strlen(str);
	for(i=0;i<len;i++)
	{
		if(str[i] == ' '||i==len-1)
		{
			strcpy(d[p],word);
			p++;
			if(max_len < strlen(word))
			{
				max_len = strlen(word);
				memset(max_word,'\0',sizeof(max_word));
				strcpy(max_word,word);
				memset(word,'\0',sizeof(word));
				t=0;
			}
			else
			{
				memset(word,'\0',sizeof(word));
				t=0;
			}
		}
		else
		{
			word[t]=str[i];
			t++;
		}
	}
	for(i=0;i<p;i++)
	{
		for(j=i+1;j<p;j++)
		{
			if(strcmp(d[i],d[j]) == 0)
			{
				dc[i]++;
			}
		}
	}
	for(i=0;i<p;i++)
	{
		if(dc[i] > m)
		{
			m=i;
		}
	}
	printf("%s %s\n",d[m],max_word);
	return 0;

}

C++: 
// mapはキー／値の対を保持する理想コンテナ
// 連想配列
// 配列の添字？が数でなくても使えるイメージ？
// 

#include <iostream>
#include <string>
#include <map>
#include <algorithm>

using namespace std;

int main(void){

  string s;
  map< string , int > count; // キー(添字？)がstring型、値がintのmap
  string num;
  string len;

  while( cin >> s ){
    int c = ++count[s];                    //初期化は必要なし？  
    if( c > count[num] ) num = s;          //ここで単語
    if( s.size() > len.size() ) len = s;   //ここで文字数
  }
  cout << num << " " << len << endl;
  return 0;
}

C++: #include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>

using namespace std;

const int M = 33;
const int N = 2001;

char text[N];
char word[N][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() {
	cin.getline(text, N, '\n');
//	while (cin.getline(text, N, '\n')) {
		solve(text);
		cout<<ansm<<" "<<ansl<<endl;
//	}
	return 0;
}

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

int main(){
	char wo[1000][32], fa[32], len[32];
	int cnt = 0, maxlen = -1, nfwo = -1;
	while(cin >>wo[cnt]){
		cnt++;
	}
	for(int i = 0; i < cnt; i++){
		int cntwo = 0;
		for(int j = 0; wo[i][j] != '\0'; j++){
			cntwo++;
		}
		if(cntwo > maxlen){
			maxlen = cntwo;
			int k = 0;
			for(k = 0; wo[i][k] != '\0'; k++){
				len[k] = wo[i][k];
			}
			len[k] = '\0';
		}
		int cntnfwo = 0;
		for(int j = 0; j < cnt; j++){
			if(strcmp(wo[i], wo[j]) == 0){
				cntnfwo++;
			}
		}
		if(cntnfwo > nfwo){
			nfwo = cntnfwo;
			int k = 0;
			for(k = 0; wo[i][k] != '\0'; k++){
				fa[k] = wo[i][k];
			}
			fa[k] = '\0';
		}
	}
	cout <<fa <<" " <<len <<endl;
	return 0;
}

C++: 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=0 ; i<count-1 ; i++){
		if(check[freq]<check[i+1]){
			freq=i+1;
		}
	}
		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]);
	return 0;
}