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

C++: #include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<deque>
using namespace std;

int main() {

    vector<string> words;
    string word; 
    string longest = "";

    while(cin >> word) {
        words.push_back(word);
        if(word.length() > longest.length()) {
                longest = word;
        }
    }

    string freq;
    int frequency = 0;
    for(int i = 0; i < words.size(); i++) {
        int tmp = count(words.begin(), words.end(), words[i]);
        if (tmp > frequency) {
            frequency = tmp;
            freq = words[i];
        }
    }

    cout << freq << " " << longest << endl;

    return 0;
}

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

map <string, int> dic;

string lowerword(string word){
    for (int i=0; i<(int)word.size(); i++)
        word[i] = tolower(word[i]);
    return word;
}

int main(void){

	while (true){
		string s;
		cin>>s;
		if (cin.eof()) break;
		dic[lowerword(s)]++;
	}

	int l=0, m=0, tmp;
	string w1, w2;
	map <string, int> ::iterator it=dic.begin();
	while (it!=dic.end()){
		tmp = (*it).second;
		if (tmp>m){
			m = tmp;
			w1 = (*it).first;
		}
		tmp = (*it).first.size();
		if (tmp>l){
			l = tmp;
			w2 = (*it).first;
		}
		it++;
	}
	cout<<w1<<" "<<w2<<endl;
	return 0;
}

C++: #include <map>
#include <string>
#include <iostream>
using namespace std;
map<string,int> table;
int main()
{
    string word, frequent, longest;
    size_t N=0;
    while (cin >> word)
    {
        table[word]++;
        if(table[word]>N)
        {
            N=table[word];
            frequent=word;
}
            if(word.size()>longest.size())
                longest=word;
    }
        cout<<frequent<<" "<<longest<<endl;
    }

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

using namespace std;

int main(){
    int max = 0;
    string s,longests,frequents;
    map<string,int> dict;
    while(cin >>s){
        dict[s] +=1;
        if(s.size() >= max){
            longests = s;
            max = s.size();
        }
        if(dict[s] >= dict[frequents]){
            frequents = s;
        }
    }
    cout << frequents << " " << longests << endl;
}