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<string>

using namespace std;

string s[1001];
int count[1001];

int main(void){
	char temp[1002];
	
	while(fgets(temp,1001,stdin) != 0){
		int temp_n = strlen(temp);
		int c = 0;
		int max_h = 0;
		int max_H = 0;
		int max_l = 0;
		int max_L = 0;
		
		for(int i = 0; i < 1001; i++){
			s[i] = "";
			count[i] = 0;
		}
		
		for(int i = 0; i < temp_n; i++){
			for(int j = i; ; j++){
				if(temp[j] == ' '){
					i=j;
					c++;
					break;
				}else if(temp[j] == '\n'){
					i=j;
					c++;
					break;
				}
				s[c] += temp[j];
			}
		}
		/*
		for(int i = 0; i < c; i++){
			printf("%d s == %s[%d]\n",i,s[i].c_str(),s[i].size());
		}
		*/
		for(int i = 0; i < c; i++){
			for(int j = 0; j < c; j++){
				if(i == j)continue;
				if(s[i] == s[j])count[i]++;
			}
		}
		
		for(int i = 0 ; i < c; i++){
			if(s[i].size() > s[max_L].size() )max_l = i;
			if(count[i] > count[max_H])max_h = i;
		}
		
		printf("%s %s\n", s[max_h].c_str(), s[max_l].c_str() );
	}
	return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <math.h>
using namespace std;

int main(){
	int m[1000],n=0,M=0,N=0,w,I,J,j;
	string r[1000],s;
	while(cin>>s){
		w=0;
		if(s.size()>M){M=s.size();I=n;}
		for(int i=0;i<n;i++)if(s==r[i]){m[i]++;w=1;j=i;break;}
		if(w==0){r[n]=s;m[n]=1;j=n;n++;}
		if(m[j]>N){N=m[j];J=j;}
	}
	cout<<r[J]<<" "<<r[I]<<endl;
}

C++: #include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <iterator>
#include <array>
#include <memory>
#include <stack>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
int main(){
    string gotiusa;
    getline(cin,gotiusa);
    string temp;
    map<string,int>mp;
    string ans1;
    rep(i,gotiusa.size()){
        if(i==gotiusa.size()-1)temp.push_back(gotiusa[i]);
        if(gotiusa[i]==' '||i==gotiusa.size()-1){mp[temp]++;if(ans1.size()<temp.size())ans1=temp;temp.clear();continue;}
        temp.push_back(gotiusa[i]);
    }
    pair<string,int>maxi;
    maxi.second=0;
    for(auto itr=mp.begin();itr!=mp.end();itr++)if(itr->second>maxi.second)maxi=make_pair(itr->first,itr->second);
    cout<<maxi.first<<" "<<ans1<<endl;

}

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

int main(){
	char str[1001];
	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]) << endl;
	return 0;
}

C++: #include<iostream>
#include<map>
#include<cstring>
using namespace std;
int main(){
    map<string,int>M;
    pair<string,int>m_len,a;
    a.second=m_len.second=0;
    while(true){
        char str[33];
        if(!(cin>>str))break;
        M[str]++;
        if(strlen(str)>m_len.second){
            m_len.first=str;
            m_len.second=strlen(str);
        }
    }

    for(map<string,int>::iterator ite=M.begin();ite!=M.end();ite++){
        if(ite->second>a.second){
            a.first=ite->first;
            a.second=ite->second;
        }
    }
    cout<<a.first<<" "<<m_len.first<<endl;


    return 0;
}

C++: #include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define o(a) cout << a << endl
#define int long long
// #define first first
// #define second se
using namespace std;
typedef pair<int, int> P;
typedef vector<int> vi;

signed main(){
    string s;
    getline(cin, s);
    map<string, int> mp;
    stringstream ss;
    ss << s;
    string t;
    int l = 0;
    string lw;
    while(ss >> t){
        mp[t]++;
        if(t.size() > l){
            l = t.size(); lw = t;
        }
    }
    int MAX = 0;
    string ans;
    for(auto it = mp.begin(); it != mp.end(); it++){
        if(MAX < it -> second){
            MAX = it -> second;
            ans = it -> first;
        }
    }
    cout << ans << " " << lw << endl;
}

C++: //大文字と小文字は区別しない。
#include<iostream>
#include<string>

using namespace std;

string str[1050];
int type;

int cnt[1050];

int main(){
	int i;
	string input;
	
	while( cin >> input ){
		if( input[0] == '\n' )
			break;
		if( input[0] >= 'A' && input[0] < 'a' )
			input[0]+=32;
		
		for( i = 0;i < type;i++ ){
			if( str[i] == input ){
				cnt[i]++;
				break;
			}
		}
		if( i == type ){
			str[type] = input;
			cnt[type]++;
			type++;
		}
	}
	
	int mmax = 0;
	
	for( i = 0;i < type;i++ ){
		mmax = max( mmax, cnt[i] );
	}
	
	for( i = 0;i < type;i++ ){
		if( mmax == cnt[i] ){
			cout << str[i] << " ";
			break;
		}
	}
	
	int maxlen = 0;
	
	for( i = 0;i < type;i++ ){
		maxlen = max( maxlen, (int)str[i].length() );
	}
	
	for( i = 0;i < type;i++ ){
		if( maxlen == (int)str[i].length() ){
			cout << str[i] << endl;
			break;
		}
	}
	return 0;
}

C++:  
 #include<iostream>
 #include<stdio.h>
 #include<string>
 #include<math.h>
 #include<iomanip>
 #include<algorithm>
 #include<string.h>
 #include<cctype>
 #include<map>
 #include<set>
 #include<vector>
 #include<sstream>
 #include<stack>
 #include<queue>
 
 using namespace std;
  
 int main()
 {
   map<string,int> mymap;
   int max=0;
   int fre=-100000000;
   string str;
   string str_max;
   string str_fre;
   while(cin>>str)
   {
     if(str.length()>max) 
     {
       max=str.length();
       str_max=str;                     
     }             
     mymap[str]++;      
   }             
   map<string,int>::iterator  iter;  
   for(iter = mymap.begin();iter!= mymap.end(); iter++)  
   {  
     if(iter->second>fre) 
     {
       str_fre=iter->first;
       fre=iter->second;                     
     }  
   }  
   cout<<str_max<<" "<<str_fre<<endl;
   //while(1);     
   return 0;  
 }