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

int main()
{
    string line;
    string field;
    map<string, int> mp;
    string frequently_word;
    string max_num_word;
    int freq_count = 0;
    int max_letter_num = 0;

    getline(cin, line);    
    istringstream stream(line);

    /* ??????????????????????????? */
    while (getline(stream, field, ' '))
    {
        /* ?????§????????°?????????????????? */
        if(field.size() > max_letter_num)
        {
            max_num_word = field;
        }
        /* ????????????????????°??????????????? */
        if(mp.count(field)) 
        {
            mp[field]++; 
        }
        else
        {
            mp[field] = 1;
        }
 
    }
    /* ??????????????????????????? */
    for(auto itr = mp.begin(); itr != mp.end(); ++itr)
    {
        if(itr->second > freq_count)
        {
            frequently_word = itr->first;
        }
    }
    cout << frequently_word << " " << max_num_word << endl;

    return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <vector>
#include <list>
#include <algorithm>
#include <cmath>
#include <stack>
#include <map>
using namespace std;

#define REP(i,n) for(int (i)=0; (i)<(n); (i)++)
#define FOR(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define PUSH(n,v) for(int i=0; i<(n); i++) {int j; cin >> j; v.push_back(j);}
#define ALL(v) v.begin(), v.end()

int main() {
    vector<string> words;
    string s;
    while(cin >> s) words.push_back(s);
    string longest;
    int longestlen = 0;
    REP(i,words.size()) {
        if (words[i].size() > longestlen) {
            longest = words[i];
            longestlen = words[i].size();
        }
    }
    
    map<string, int> mp;
    string frequent;
    int frequency = 0;
    REP(i,words.size()) {
        mp[words[i]] = 0;
    }
    REP(i,words.size()) {
        mp[words[i]]++;
        if (mp[words[i]] > frequency) {
            frequent = words[i];
            frequency = mp[frequent];
        }
    }
    
    cout << frequent << " " << longest << endl;

    return 0;
}

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

using namespace std;

int main(){
	string in[10000];
	int max=0;
	string ml_str;
	int tmp;
	string ans;
	int i=0;
	for(i=0;cin>>in[i];i++){
		if(in[i].size()>max){
			max=in[i].size();
			ml_str=in[i];
		}
	}
	sort(in,in+i);
	tmp=1;
	max=0;
	for(int j=1;j<=i;j++){
	cout<<in[j]<<" ";
		if(in[j]==in[j-1]){
			tmp++;
		}else{
			if(max<tmp){
				max=tmp;
				ans=in[j-1];
				tmp=1;
			}
		}
	}
	cout<<endl<<ans<<" "<<ml_str<<endl;
}

C++: #include <iostream>
#include <string>
#include <cstdio>
#include <cmath>
#include <map>
using namespace std;
#define make_pair mk
typedef pair<int, int> P;

int main(){
	string input;
	map<string, P> data;
	int maxlen = 0, maxcnt= 0;
	string lenst, cntst;
	while( cin >> input ){	
		if( data.find(input) == data.end() ){
			data.insert( pair<string, P>(input, P(input.size(), 1)) );
			//maxlen = max(maxlen, (int)input.size());
			if( maxlen < input.size() ){
				maxlen = input.size();
				lenst = input;
			}
		}else{
			//data[input].second++;
			if( maxcnt < data[input].second++ ){
				maxcnt = data[input].second;
				cntst = input;
			}
		}
	}
	/*map<string, P>::iterator it = data.begin();
	for( ; it != data.end(); it++ ){
		cout << (*it).first << "," << (*it).second.first << "," << (*it).second.second << endl;
	}*/
	cout << cntst << " " << lenst << endl;
}

C++: #define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl;
typedef long long ll;
typedef unsigned long long ull;

int main()
{
    string s, ans1 = "", ans2 = "";
    map<string, int> mp;
    int n1 = 0, n2 = 0;
    while (cin >> s)
    {
        if (ans2.size() <= s.size())
            ans2 = s;
        mp[s]++;
        if (mp[s] >= mp[ans1])
            ans1 = s;
    }
    cout << ans1 << " " << ans2 << endl;

    return 0;
}

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

using namespace std;

map<string, int> wordCount;

int main() {
	string input = "";
	
	cin >> input;
	
	string maxWord = "";
	
	while (input.size() > 0) {
		
		if (wordCount.find(input) == wordCount.end()) {
			wordCount[input] = 1;
		} else {
			wordCount[input] = wordCount[input] + 1;
		}
		
		if (input.size() > maxWord.size()) {
			maxWord = input;
		}
		
		input = "";
		cin >> input;
	}
	
	int freqCount = 0;
	string freqWord;
	
	for (map<string, int>::iterator it = wordCount.begin(); it != wordCount.end(); it++) {
		if ((*it).second > freqCount) {
			freqCount = (*it).second;
			freqWord = (*it).first;
		}
	}
	
	cout << freqWord << " " << maxWord << endl;
	
	return 0;
}

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

typedef pair<int,string> P;

int main(void)
{

	char c;
	string str,maxstr;
	P d[1001] = {};	

	while(scanf("%c", &c), c != '\n'){
		if(c != ' '){
			str += c;
		}
		else {
			if(strlen(str.c_str()) > strlen(maxstr.c_str())){
				maxstr.clear();
				maxstr = str;
			}
			int i;
			for(i = 0; d[i].first != 0; i++){
				if(d[i].second == str){
					d[i].first++;
					break;
				}
			}
			if(d[i].first == 0){
				d[i] = P(1,str);
			}
			str.clear();
		}
	}
	if(strlen(str.c_str()) > strlen(maxstr.c_str())){
		maxstr.clear();
		maxstr = str;
	}
	int i;
	for(i = 0; d[i].first != 0; i++){
		if(d[i].second == str){
			d[i].first++;
			break;
		}
	}
	if(d[i].first == 0){
		d[i] = P(1,str);
	}
	str.clear();

	sort(d,d+1001);
	cout << d[1000].second << ' ' << maxstr << endl;

	return 0;
}

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

using namespace std;

int main()
{
	string s,max("");
	map<string,int> w;
	map<int,string> x;
	
	while(cin>>s){
		if(s.size()>max.size()) max=s;
		w[s]++;
	}
	
	for(map<string,int>::iterator it=w.begin();it!=w.end();it++)
		x[(*it).second] = (*it).first;
	
	cout<<(*x.rbegin()).second<<" "<<max<<endl;
	return 0;
}