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 <string>
#include <map>
#include <vector>
using namespace std;

int main(){
	// word[s] Å ¶ñsÌo»ñªÔÁÄ­é
	map<string, int> word;
	vector<string> v;
	string s;

	while( cin >> s ){
		v.push_back(s);
		
		//üÍµ½Pêª·ÅÉ é©T·
		if( word.count(s) ){
			word[s]++;
		}else{
			word[s] = 1;
		}
	}
	// ÅpoÌPêð²×é
	int mode=0;
	for(int i=0 ; i < v.size() ; i++ ){
		mode = max( mode , word[ v[i] ] );
	}
	for(int i=0 ; i < v.size() ; i++ ){
		if( mode == word[ v[i] ] ){
			cout << v[i];
			break;
		}
	}
	// Å·ÌPêðßé
	int length = 0;
	for(int i=0 ; i < v.size() ; i++ ){
		length = max( length , (int)v[i].size() );
	}
	for(int i=0 ; i < v.size() ; i++ ){
		if( length == v[i].size() ){
			cout << " " << v[i] << endl;
		}
	}
}

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

int main(void) {
    vector<string> vec;
    string input, ans1;
    int maxLen = 0;
    while(cin >> input) {
        vec.push_back(input);
        if(input.length() > maxLen) {
            maxLen = (int)input.length();
            ans1 = input;
        }
    }
    map<int, string> hm;
    vector<string>::iterator ite;
    int max = 0;
    for(ite = vec.begin(); ite != vec.end(); ite++) {
        string now = *ite;
        int cnt = (int)count(vec.begin(), vec.end(), now);
        if(cnt > max) max = cnt;
        hm.insert(make_pair(cnt, now));
    }
    map<int, string>::iterator ite2;
    for(ite2 = hm.begin(); ite2 != hm.end(); ite2++) {
        if(ite2->first == max) {
            cout << ite2->second << " "; break;
        }
    }
    cout << ans1 << 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() {
	while (cin.getline(text, N, '\n')) {
		solve(text);
		cout<<ansm<<" "<<ansl<<endl;
	}
	return 0;
}

C++: #include<iostream>
#include<string>
#include<map>
#include<cctype>
using namespace std;
int main(){
	map<string, int> mpa;
	string most_frequent_word, longest_word;
	string s;
	int max_frequency = 0, max_length = 0;
	while(cin >> s){
		if(s.length() > max_length){
			max_length = s.length();
			longest_word = s;
		}
		for(int i = 0; i < s.length(); i++) s[i] = tolower(s[i]);
		mpa[s]++;
	}
	map<string, int>::iterator itr;
	for(itr = mpa.begin(); itr != mpa.end(); itr++){
		if(itr -> second > max_frequency){
			max_frequency = itr -> second;
			most_frequent_word = itr -> first;
		}
	}
	cout << most_frequent_word << ' ' << longest_word << endl;
	return 0;
}

C++: #include<iostream>
#include<map>
using namespace std;
map<string,int>mp;
string ans,s,amins;
int maxn=0,minn=0;
int main()
{
    while(cin>>s)
    {
        mp[s]++;
        if(mp[s]>maxn)
        {
                      maxn=mp[s];
                      ans=s;
        }
        if(s.size()>minn)
        {
                         minn=s.size();
                         amins=s;
        }
    }
    cout<<ans<<" "<<amins<<endl;
    return 0;
}

C++: #include <iostream>
#include <string>
#include <map>
using namespace std;
int main(){
	string str,s,mls,mcs,input[32];
	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<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    string ans0,ans1;
    string str;
    string lis[1000];
    int lissize=0;
    getline(cin,str);
    str.push_back(' ');
    for(int i=0;i<str.size();i++){
        for(int j=i;j<str.size();j++){
            if(str[j]==' '){
                lis[lissize]=str.substr(i,j-i);
                lissize++;
                i=j+1;
            }
        }
    }
    sort(lis,lis+lissize);
    int ans=0,karians=1;
    for(int i=1;i<lissize;i++){
        if(lis[i]==lis[i-1])karians++;
        else karians=1;
        if(ans<karians){
            ans=karians;
            ans0=lis[i];
        }
    }
    if(ans<karians)ans0=lis[lissize-1];
    karians=0;
    for(int i=0;i<lissize;i++){
        if(karians<lis[i].size()){
            karians=lis[i].size();
            ans1=lis[i];
        }
    }
    cout<<ans0<<' '<<ans1<<endl;
    return 0;
}

C++: #include <iostream>
#include <string>
#include <map>
using namespace std;
int M,l;main(){string s,t,u;map<string,int>m;for(;cin>>u;t=t.size()<u.size()?u:t)if(++m[u]>M)M=m[u],s=u;cout<<s<<' '<<t<<endl;}

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

int main(){
	char str[1001];
	char word[100][100]={0};
	int longest=0;
	int check[100]={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=1 ; i<count ; i++){
		len=strlen(word[i]);
		if(len > prev){
			prev = len;
			longest=i;
		}
	}
	cout << (char*)&(word[freq]) << " "<< (char*)&(word[longest]) << endl;
	return 0;
}