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

int main(){
	string str;
	string max_len_str;
	string most_many_str;
	int most=-1;
	int i;
	vector<pair<string, int> > v;
	string::iterator vi;
	cin>>str;
	v.push_back(pair<string, int>(str, 0));
	max_len_str == v[0].first;
	while(cin>>str){
		for(i=0;i<v.size();i++){
			if(v[i].first == str){
				v[i].second++;
				break;
			}
		}
		if(i==v.size()){
			if(max_len_str.size() < strlen(str.c_str())){
				max_len_str = str;
			}
			v.push_back(pair<string, int>(str, 0));
		}
	}
	for(i=0;i<v.size();i++){
		if(most < v[i].second){
			most = v[i].second;
			most_many_str = v[i].first;
		}
	}
	cout << most_many_str << " " << max_len_str << endl;
	
	return 0;
}

C++: 
#include<iostream>
#include<map>
#include<string>
using namespace std;
map<string, int> mem;
string m = "";
string ss = "";
int n = 0;
int main()
{
  string s;
  while(cin >> s)
  {
    if(mem.find(s) == mem.end())
      mem[s] = 1;
    else
      mem[s]++;
    if(mem[s] > n)
    {
      n = mem[s];
      ss = s;
    }
    m = m.length() < s.length() ? s : m; 
  }
  cout << ss << " " << m << endl;
}

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

char buf[1001];
map<string, int> cnt;
string mode;
string longest;

int main() {
  while (1) {
    if (scanf("%s", buf) != 1) break;

    string word = buf;
    int n = strlen(buf);
    if (n > longest.size()) longest = buf;
    ++cnt[word];
    if (cnt[word] > cnt[mode]) mode = word;
  }

  printf("%s %s\n", mode.c_str(), longest.c_str());
}

C++: #include<iostream>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<functional>
using namespace std;
int main() {
	vector<pair<int,string>> x(1000);
	string a;
	int j=1,s=0,m=0;
	while(cin >> a) {
		for (int i = 0; i <j ; i++) {
			if (x[i].second == a) {
				x[i].first++;
				break;
			}
			if (i == j - 1) {
				x[i].second = a;
				x[i].first = 1;
				j++;
				break;
			}
		}
	}
	sort(x.begin(), x.end(), greater<pair<int, string>>());
	for (int i = 0; i < j; i++) {
		if (x[i].second.size() > s) {
			s = x[i].second.size();
		}
	}
	for (int i = 0; i < j; i++) {
		if (x[i].first > m) {
			m = x[i].first;
		}
	}
	for (int i = 0; i < j; i++) {
		if (x[i].first == m) {
			cout << x[i].second << ' ';
		}
	}
	for (int i = 0; i < j; i++) {
		if (x[i].second.size() == s) {
			cout << x[i].second << endl;
		}
	}
	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
 
#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
 
typedef long long ll;
typedef pair<int, int> ii;

#define EPS 1e-8

int main(){
	
	map<string, int> mp;
	
	int maxi = 0;
	string s;
	string longest = "";
	while(cin >> s){
		mp[s]++;
		maxi = max(maxi, mp[s]);
		if(longest.size() < s.size()) longest = s;
	}
	
	for(auto it : mp){
		if(maxi == it.second) cout << it.first;
	}
	cout << " " << longest << endl;

	
	return 0;
}

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

int main(){

  int l, c, len, m_len, m_cnt;
  int cnt[500] = {};
  string str, word[500];

  while(cin >> str){
    for(int i=0; i<500; i++){
      if(word[i] == ""){
        word[i] = str;
        cnt[i] = 1;
        break;
      }
      else if(word[i] == str){
        cnt[i]++;
        break;
      }
    }
  }

  m_len = 0;
  m_cnt = 0;
  for(int i=0; word[i] != ""; i++){
    if(m_cnt < cnt[i]){
      m_cnt = cnt[i];
      c = i;
    }
    len = word[i].length();
    if(m_len < len){
      m_len = len;
      l = i;
    }
  }

  cout << word[c] << " " << word[l] << endl;

  return 0;
}