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<cstdio>
#include<algorithm>
#include<string>
#include<iostream>

#define MAX(x,y) ((x,y)? x:y)

using namespace std;

string date[1000];

int main()
{
	char c[35];
	for(int i=0;scanf("%s",c)!=EOF;i++){
		date[i]=c;
	}
	sort(date,date+1000);
	int weitline=0;
	int maxline=0;
	string str;
	int str_i=0;
	for(int i=0;i<1000;i++)
	{
		if(str==date[i])str_i++;
		else 
		{
			str_i=1;
			str=date[i];
		}
		weitline =MAX(weitline,str_i);
		maxline=MAX(maxline,date[i].length());
	}
	string weitanswer;
	string maxanswer;

	for(int i=0;i<1000;i++)
	{
		if(str==date[i])str_i++;
		else 
		{
			str_i=1;
			str=date[i];
		}
		if(str_i==weitline)weitanswer=date[i];
		if(maxline==date[i].length()) maxanswer=date[i];
	}
	printf("%s %s\n");
	return 0;
}

C++: #include<iostream>
#include<string.h>
#include<vector>
#include<algorithm>
#include<map>
using namespace std;
int main()
{
    map<string,int> m;
    string s;
    getline(cin,s);
    string tem="";
    for(int i=0;i<s.length();i++){
        if(s[i]!=' '&&s[i]!='\n')
            tem+=s[i];
        else{
            if(m.find(tem)!=m.end()){
                (m.find(tem))->second++;
            }
            else{
                m.insert(pair<string,int>(tem,1));
            }
            tem="";
        }
    }
    if(m.find(tem)!=m.end()){
        (m.find(tem))->second++;
    }
    else{
        m.insert(pair<string,int>(tem,1));
    }
    string most,longest;
    map<string,int>::iterator it = m.begin();
    int mo=0;
    for(;it!=m.end();it++){
        if(it->first.length()>longest.length())
            longest=it->first;
        if(it->second>mo){
            most=it->first;
            mo=it->second;
        }
     //   cout<<it->first<<"    "<<it->second<<endl;
    }
    cout<<most<<endl<<longest<<endl;
    return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
string s;
long long base=311,MOD=1e9+7,slen;
long long hashs[1005],lt[1005],Pow[1005];
int res1,res2,max1,max2,dau[1005],cuoi[1005],kc[1005],dem;
void nhap()
{
    getline(cin,s);
    s=' '+s;
    slen=s.length()-1;
}
void taohash()
{
    Pow[0]=1;
    for (long long i=1;i<=slen;i++) Pow[i]=(Pow[i-1]*base)%MOD;
    for (long long i=1;i<=slen;i++){
        hashs[i]=(hashs[i-1]*base+s[i])%MOD;
    }
}
long long get(long long i,long long j)
{
    return ((hashs[j]-hashs[i-1]*Pow[j-i+1])+MOD*MOD)%MOD;
}
bool kt(int x,int y)
{
    if (kc[x]!=kc[y]) return false;
    return get(dau[x],cuoi[x])==get(dau[y],cuoi[y]);
}
void push(int u,int v)
{
    dem++;
    dau[dem]=u;
    cuoi[dem]=v;
    kc[dem]=v-u;
}
void khoitao()
{
    int u=1,v;
    for (int i=1;i<=slen;i++){
        if (s[i]==' '||i==slen){
            v=i-1;
            if (i==slen) v=i;
            push(u,v);
            if (kc[dem]>max2){
                res2=dem;
                max2=kc[dem];
            }
            u=i+1;
        }
    }
}
void xuli()
{
    khoitao();
    taohash();
    for (int i=1;i<=dem;i++){
        int kq=0;
        for (int j=1;j<=dem;j++){
            if (j!=i) if (kt(i,j)) kq++;
        }
        if (kq>max1){
            res1=i;
            max1=kq;
        }
    }
    for (int i=dau[res1];i<=cuoi[res1];i++) printf("%c",s[i]);
    printf(" ");
    for (int i=dau[res2];i<=cuoi[res2];i++) printf("%c",s[i]);
    printf("\n");
}
int main()
{
    nhap();
    xuli();
}

C++: #include<iostream>
#include<string.h>
#include<vector>
#include<list>
#include<stdio.h>
#include<math.h>
#include<iomanip>
#include<map>
#include<stack>
#include<queue>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define debug(x) cout << "debug " << x << endl;
using namespace std;

int main(){
    string s, ans1, ans2;
    int longest = 0, many = 0;
    map<string, int> time;
    while(cin >> s){
        if(longest < s.size()){
            longest = s.size();
            ans2 = s;
        }
        time[s]++;
        if(many < time[s]){
            many = time[s];
            ans1 = s;
        }
    }
    rep(i, ans1.size()){
        cout << ans1[i];
    }
    cout << ' ';
    rep(i, ans2.size()){
        cout << ans2[i];
    }
    cout << endl;
}

C++: #include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef pair<string, int> PAIR;

int main(){
	vector<PAIR> vec;
	vector<PAIR>::iterator ite;
	vector<PAIR>::iterator max;
	string st, siz;
	while(cin >> st){
		if(st == "0") break;
		if(vec.empty()){
			vec.push_back(PAIR(st, 1));
			//max = vec.begin();
			//siz = st;
		}else{
			ite = vec.begin();
			while(1){
				if((*ite).first == st){
					(*ite).second++;
					//if((*max).second < (*ite).second) max = ite;
					break;
				}
				ite++;
				if(ite == vec.end()){
					vec.push_back(PAIR(st, 1));
					//if(siz.size() < st.size()) siz = st;
					break;
				}
			}
		}

		ite = vec.begin();
		max = vec.begin();
		siz = (*ite).first;
		while(ite != vec.end()){
			if((*max).second < (*ite).second) max = ite;
			if(siz.size() < (*ite).first.size()) siz = (*ite).first;
			ite++;
		}


	}
		cout << (*max).first << " " << siz << endl;
	return 0;
}

C++: /*AOJ 0029*/

#include<iostream>
#include<vector>
#include<string>

using namespace std;

int main(){

	vector<string> data;

	char str[35];

	while(cin>>str){
		data.push_back(str);
	}

	int max=0;
	int maxNum = 0;
	int sum=0;

	for(int i=0;i<data.size();i++){
		sum = 0;
		for(int j=i+1;j<data.size();j++){
			if(data.at(i) == data.at(j)){
				sum++;
			}
		}
		if(max<=sum){
			max = sum;
			maxNum = i;
		}
	}

	cout<<data.at(maxNum)<<endl;

	max = 0;
	maxNum = 0;

	for(int i=0;i<data.size();i++){
		if(max <= data.at(i).size()){
			max = data.at(i).size();
			maxNum = i;
		}
	}

	cout<<data.at(maxNum)<<endl;


	return 0;
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cmath>

#define rep(i, n) for(int i = 0; i < n; i ++)
#define ALL(T) T.begin(), T.end()
#define mp make_pair
#define N first
#define L second

using namespace std;

typedef pair<int, int> pii;
typedef pair<string, string> pss;
typedef unsigned long long ull;

int main(void){
    map<string, pii> dic;
    pss res;

    for(string in; cin >> in;){
        dic[in].N ++;
        dic[in].L = in.size();

        if(dic[res.N].N < dic[in].N)
            res.N = in;
        if(dic[res.L].L < dic[in].L)
            res.L = in;
    }
    cout << res.N << " " << res.L << endl;

    return 0;
}