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 <stdio.h>
#include <string.h>
#include <string>
#include <map>
#include <algorithm>

using namespace std;

int
main(void)
{
	char line[1002];

	if (fgets(line, sizeof line, stdin) == NULL) {
		return 0;
	}

	char* token = strtok(line, " \n");

	map<string, int> s;
	int m = 0;
	string ms;

	while (token) {
		string ts(token);

		if (s.find(ts) == s.end()) {
			s[ts] = 0;
		}
		s[ts] ++;

		if (m < (int)(ts.size())) {
			m = ts.size();
			ms = ts;
		}
		
		token = strtok(NULL, " \n");
	}

	if (!s.empty()) {
		auto itr = max_element(s.begin(), s.end(),
			[](const pair<string, int>& a, const pair<string, int>& b)
				-> bool {
					return (a.second < b.second);
				});
				
		printf("%s %s\n", (*itr).first.c_str(), ms.c_str());
	}

	return 0;
}

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

int main()
{
	map<string, int> cnt;
	string s;
	while (cin >> s) {
		cnt[s]++;
	}
	int ma = 0, le = 0;
	string res1, res2;
	for (auto p : cnt) {
		if (p.second > ma) {
			ma = p.second;
			res1 = p.first;
		}
		if ((int)p.first.size() > le) {
			le = p.first.size();
			res2 = p.first;
		}
	}
	cout << res1 << ' ' << res2 << endl;
	return 0;
}

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

map<string, int> mp;

int main()
{
	string str;
	string maxi;
	string maxl;
	
	while (!cin.eof()){
		cin >> str;
		mp[str]++;
		if (mp[maxi] < mp[str]){
			maxi = str;
		}
		if (maxl.size() < str.size()){
			maxl = str;
		}
	}
	
	cout << maxi << " " << maxl << 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<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<map>

using namespace std ;

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl

#define rep(i,n) for(int i = 0; i < (n);++i)
#define repc(i,a,b) for(int i = (a);i <(b);++i)
#define repa(n,array) for(auto n :(array))

long long typedef ll ;
typedef vector<int> vi ;
typedef vector<ll> vl ;
template<class Value>
using dict = std::map< string, Value >;

constexpr int IMAX = ((1<<30)-1)*2+1 ;
constexpr int INF = 100000000;
double EPS = 1e-10 ;

typedef const pair<string, int> PSI;
bool cmpCount(PSI &T1, PSI &T2) {
    return T1.second < T2.second;
}

bool cmpLength(PSI &T1, PSI &T2) {
    return T1.first.length() < T2.first.length();
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string str ;
  dict<int> M;
  while(cin >> str){
    if(M.count(str) == 0){
      M[str] = 0 ;
    }
    else{
      auto it = M.find(str) ;
      ++it->se ;
    }
  }
  PSI maxCount = *max_element(M.begin(), M.end(), cmpCount);
  PSI maxLength = *max_element(M.begin(), M.end(), cmpLength);

  cout << maxCount.first << " " << maxLength.first << endl;
  return 0;
}

C++: #include <bits/stdc++.h>

#define REP(i, n) for(int i = 0; i < n; i++)
using namespace std;

int main()
{   
    string s, res, res2;
    int s_max, cnt = 0;
    map<string, int> mp;

    while (cin >> s) {
        if (s_max < s.size()) {
            s_max = s.size();
            res = s;
        }

        mp[s]++;
    }

    for (const auto &x: mp) {
        if (cnt < x.second) {
            cnt = x.second;
            res2 = x.first;
        }
    }

    cout << res2 << " " << res << endl;
    
}

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

map<string,int> table;

int main()
{
	string word, frequent, longest;
	size_t N=0;
	
	while(cin>>word){
		table[word]++;
		if(table[word]>N){
			N=table[word];
			frequent=word;
		}
		if(word.size()>longest.size()){
			longest=word;
		}
	}

	cout<<frequent<<" "<<longest<<endl;
	
	return 0;
}

C++: /*
 *	
 *	Created by Ziyi Tang
 *
 */

#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
using namespace std;
#define INF 1E18
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
typedef vector<vpi> vvpi;
const int dir[4][2] = {{1,0},{-1,0},{0,1},{0,-1}};

map<string,int> freq;
string maxletter1;
int maxletter2 = 0;

bool comp(pair<string,int> a, pair<string,int> b){
	if (a.second > b.second){
		return true;
	}
	else{
		return false;
	}
}
int main(){
	string tmp;
	//cin >> tmp;
	while (cin >> tmp){
		int sz = tmp.size();
		if (sz > maxletter2){
			maxletter1 = tmp;
			maxletter2 = sz;
		}
		freq[tmp] += 1;
		
	}
	auto maxfreq = min_element(freq.begin(), freq.end(), comp);
	cout << (*maxfreq).first << " " << maxletter1 << endl;

	

	return 0;
}

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


map<string,int>data;
int main(){
	
	string str;
	int ma;
	string ans1,ans2;
	while(cin>>str){
		data[str]++;
		if(ma<data[str]){
			ma=data[str];
			ans1=str;
		}
		if(ans2.size()<str.size())ans2=str;
	}
	cout<<ans1<<" "<<ans2<<endl;
}