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>
using namespace std;
int main(){
	string str,s,mls,mcs,input[31];
	map <string,int> dic;
	int n,c,a,ml,mc;
	while(getline(cin,str)){
		c = a = mc = ml = 0;
		str += ' ';
		while(str.length()){
			n = str.find(' ');
			s = str[c];
			++c;
			for(;c < n;++c){
				s += str[c];
			}
			str.erase(0,n+1);
			c = 0;
			input[a] = s;
			++a;
			++dic[s];
			if(s.length() > ml) {
				ml = s.length();
				mls = s;
			}
		}
		for(int i = 0;i < a;++i){
			if(mc < dic[input[i]]){
				mc = dic[input[i]];
				mcs = input[i];
			}
		}
		cout << mcs << " " << mls << endl;
	}
	return 0;
}

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

int main(void){
	map<string, int> word;
	string instr, mfstr, maxl = "";
	int noo = 0;
	
	while(cin >> instr){
		if(word.find(instr) != word.end()){
			word[instr]++;
		}
		else{
			word.insert(pair<string, int>(instr, 1));
		}

		if(instr.size() > maxl.size())	maxl = instr;
	}

	map<string, int>::iterator p;
	for(p = word.begin(); p != word.end(); p++){
		if(noo < p->second){
			noo = p->second;
			mfstr = p->first;
		}
	}

	cout << mfstr << " " << maxl << endl;
  return 0;
}

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

using namespace std;

int main(void)
{
	char word[1000][32];
	char tmp[32];
	int length[1000];
	int freq[1000]={0};
	int maxlen=0;
	int maxfreq=0;
	int wordnum=0;
	while(cin>>tmp)
	{
		int i;
		for(i=0;i<wordnum;i++)
		{
			if(strcmp(word[i],tmp)==0)
			{
				break;
			}
		}
		strcpy(word[i],tmp);
		wordnum++;
		freq[i]++;
		length[i]=0;
		for(int j=0;word[i][j]!='\0';j++)
		{
			length[i]++;
		}
		if(freq[maxfreq]<freq[i])
		{
			maxfreq=i;
		}
		if(length[maxlen]<length[i])
		{
			maxlen=i;
		}
	}
	cout<<word[maxfreq]<<" "<<word[maxlen]<<endl;
}

C++: #include <iostream>
#include <string>
using namespace std;
int main(){
    long saidai=0;
    char f;
    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++){
                if(j==0){
                    f=str[j];
                    f=f+32;
                    str[j]=f;
                }
                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<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;
}