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>
#define rep(i,n) for(int i=0; i<n; i++)
#define INF 1000000
using namespace std;
typedef pair<int,string> P;;
int main(){
    string str;
    getline(cin,str);
    vector<P> ans(1000);
    bool flag = true;
    int tmp_first = 0,tmp_end = 0,pos = 0;
    rep(i,str.size()){
        if(str[i] == ' ' || i == str.size()-1) {
            string tmp = str.substr(tmp_first,tmp_end);
            ans[pos].first = tmp.size();
            ans[pos].second = tmp;
            flag = true;
            pos++;
            tmp_end = 0;
        }
        else {
            if(flag == true){
                tmp_first = i;
                flag = false;
            }
        }
        tmp_end++;
    }
    int cnt1 = 0;
    int cnt2 = 0;
    string str_ans1,str_ans2;
    rep(i,pos) {
        int tmp_cnt = 0;
        rep(j,pos) {
            if(ans[i].second == ans[j].second) tmp_cnt++;
        }
        if(tmp_cnt > cnt1) {
            cnt1 = tmp_cnt;
            str_ans1 = ans[i].second;
        }
        //cout << ans[i].second << " " << ans[i].first  << endl;
        if(ans[i].first > cnt2){
            cnt2 = ans[i].first;
            str_ans2 = ans[i].second;
        }
    }
    cout << str_ans1 << " " << str_ans2 << endl;
    return 0;
}

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

using namespace std;

int main()
{
	string str[10000],mstr,lstr;
	int size=0,max=0,i,j;
	
	for(i=0;cin >> str[i];i++)
	{
		if(size<str[i].size())
			lstr=str[i];
	}
	for(j=0;j<i;j++)
	{
		int count=0;
		for(int k=0;k<i;k++)
			if(str[j]==str[k])
				count++;
		if(max<count)
		{
			max=count;
			mstr=str[j];
		}
	}
	cout << mstr << " " << lstr << endl;
}

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

int main()
{
	std::map<std::string, int> count_map;
	std::string str{};
	int max_length = 0;
	std::string max_str{};
	int hist_max_count = 0;
	std::string hist_max_str{};

	while (std::cin >> str)
	{
		if (count_map.count(str) == 0)
		{
			count_map[str] = 1;
		}
		else
		{
			count_map[str]++;
		}

		if (max_length < str.length())
		{
			max_length = str.length();
			max_str = str;
		}

		if (hist_max_count < count_map[str])
		{
			hist_max_count = count_map[str];
			hist_max_str = str;
		}
	}

	std::cout << hist_max_str << " " << max_str << std::endl;
	return 0;
}

C++: #include<iostream>
#include<cstring>
#include<string>
#define MAX 1060
using namespace std;
typedef struct{
	char s[MAX];
	int sum;
} gg;
char mstr[MAX],lstr[MAX],str[MAX],pre[MAX];
int lon=0,r,gs=0,mx=0;
gg sp[MAX];
void func(int x){
	int i;
	for(i=0;i<gs;i++){
		if(strncmp(sp[i].s,&str[x],r)==0){
			sp[i].sum++;
			break;
		}
	}
	if(i==gs){
		strncpy(sp[gs].s,&str[x],r);
		sp[gs].s[r]='\0';
		sp[gs++].sum=1;
	}
	if(sp[i].sum>mx){
		mx=sp[i].sum;
		strcpy(mstr,sp[i].s);
		mstr[strlen(sp[i].s)]='\0';
	}
}
int lo(int x){
	int i;
	for(i=x;isalpha(str[i]);i++)
		;
		return i-x;
}
void solve(){
	for(int i=0;str[i]!='\0';i++){
		if(isalpha(str[i])){
			r=lo(i);
			if(r>lon){
				lon=r;
				strncpy(lstr,&str[i],r);
				lstr[r]='\0';
			}
			func(i);
			i+=(r-1);
		}
	}
}
int main(){
	cin.getline(str,MAX);
		gs=0;mx=0;lon=0;
		solve();
		cout<<mstr<<' '<<lstr<<endl;
	return 0;
}

C++: #include<cstdio>
#include<cstring>
#include<functional>
#include<algorithm>
using namespace std;
int main(void)
{
	char s[1001],ss[1001][1001];
	int len,max,x,i,cnt[1001],mx;
	max=-1;
	mx=-1;
	x=0;
	while(scanf("%s ",s)!=EOF) {
		len=strlen(s);
		if(max<len) max=len;
		strcpy(ss[x],s);
		for(i=0;i<x;i++) {
			if(strcmp(ss[i],s)==0) cnt[i]++;
			if(mx<cnt[i]) mx=cnt[i];
		}
		x++;
	}
	for(i=0;i<x;i++) {
		if(mx==cnt[i]) {
			printf("%s ",ss[i]);
			break;
		}
	}
	for(i=0;i<x;i++) {
		if(max==strlen(ss[i])) {
			printf("%s\n",ss[i]);
			break;
		}
	}
	return 0;
}

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

map<string,int> table;

int main(){
	string word, frequent, longest;
	int frequent_length = 0;
	while (cin >> word){
		table[word] += 1;
		if (table[word] > frequent_length){
			frequent_length = table[word];
			frequent = word;
		}
		longest = (word.size() > longest.size()) ? word : longest;
	}	
	cout << frequent << longest << endl;
	return 0;
}

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

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

struct tWord{
	string w;
	int cnt;
};

bool operator<( const tWord& l, const tWord &r ){
	return l.cnt > r.cnt;
}

int main(){
	vector<tWord> words;
	string in, max="";
	while( cin >> in ){
		int i;
		for( i=0; i<words.size(); i++ ){
			if( words[i].w == in ){
				words[i].cnt++;
			}
		}
		if( i == words.size() ){
			tWord w;
			w.w = in; w.cnt = 1;
			words.push_back(w);
			if( max.length() < in.length() ){
				max = in;
			}
		}
	}
	sort( words.begin(), words.end() );
	cout << words[0].w << " " << max << endl;
	return 0;
}

C++: #include <string.h>
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>
#include <utility>

#define ll (long lon
#define REP(i,n) for(int i = 0;i<(int)n;i++)
#define FOR(i,a,b) for(int i = (a);i < (b);i++)
#define RFOR(i,a,b) for(int i = (a);i>(b);i--)
#define INT_MIN_A -999999

using namespace std;

int main (void){
    
    char str[1000];
    gets(str);
    char tango[1000][33];
    int i = 0,j = 0,k = 0,l = 0, temp = 0,m = 0;
    int max_l = INT_MIN_A;
    int max_numer = 0;
    int yokuderu = 0;
    int yokuderu_temp = 0;
    int yokuderu_number = 0;
    while(str[i++] != '\0')
    {
        if(str[i-1] == ' ')
        {
            if((i-1)-temp>max_l)
            {
                max_l = (i-1) -temp;
                max_numer = j;
            }
            while(temp<i-1)
                tango[j][l++] = str[temp++];
            temp = i;
            j++;
            l = 0;
        }
    }
    
 
        if((i-1)-temp>max_l)
        {
            max_l = (i-1) -temp;
            max_numer = j;
        }
        while(temp<i-1)
            tango[j][l++] = str[temp++];
        temp = i;
        j++;
        l = 0;
    /*???????????§??????????????????*/
    //cout <<"number is " << j << endl;
    
    for(int m = 0; m < j;m++)
    {
        for(int k = 0; k<j;k++)
        {
            if(m != k)
            {
                if(strcmp(tango[m], tango[k]) == 0)
                {
                    yokuderu_temp++;
                }
            }
        }
        if(yokuderu_temp >= yokuderu)
        {
            yokuderu = yokuderu_temp;
            yokuderu_number = m;
        }
        yokuderu_temp = 0;
    }
    REP(i,32)
    cout << tango[yokuderu_number][i];
    cout << " ";
    while(tango[max_numer][m++] != '\0')
        cout << tango[max_numer][m-1];
    m = 0;
        cout << endl;
    
    
    return 0;
}