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>

int main()
{
    std::map<std::string, int> m;

    std::string s, max_len_str = "";
    int max_freq = 0;
    while (std::cin >> s) {
        if (max_len_str.size() < s.size()) max_len_str = s;
        ++m[s];
        if (max_freq < m[s]) max_freq = m[s];
    }

    for (std::map<std::string, int>::iterator it = m.begin(); it != m.end(); ++it) {
        if (it->second == max_freq) {
            std::cout << it->first << ' ' << max_len_str << std::endl;
            break;
        }
    }
}

C++: 
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <stack>
#include <cctype>
#include <complex>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <cassert>

using namespace std;


bool solve(){
	int maxsize=0;
	int maxcnt=0;
	int ans_num;
	int ans_num2;
	vector<string> str_v;
	
	string in;
	while(cin>>in){
		str_v.push_back(in);
		if(maxsize < str_v.size()){
			maxsize = str_v.size();
			ans_num = str_v.size()-1;
		}
	}
	for(int i=0;i<str_v.size();i++){
		int cnt=0;
		for(int j=0;j<str_v.size();j++){
			if(str_v[i] == str_v[j]) cnt++;
		}
		if(maxcnt < cnt){
			maxcnt = cnt;
			ans_num2 = i;
		}
	}
	
	cout<< str_v[ans_num2]<< " "<< str_v[ans_num]<< endl;
	
	return true;
}

int main(){
	cout.setf(ios::fixed);
	cout.precision(10);
	solve();

	return 0;
}

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

int main() {
  map<string, int> words;
  string input, word_l, word_f;
  int length, freq;
  while(cin >> input) {
    words[input]++;
    if (words[input] > freq) {
      word_f = input;
      freq = words[input];
    }
    if (input.size() > length) {
      word_l = input;
      length = input.size();
    }
  }
  cout << word_f << " " << word_l << endl;
  return 0;
}

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

int main() {
	string str;
	string longstr;
	string maxwordstr;
	int maxword=0;
	map<string, int> words;
	while (cin >> str) {
		if (str.size() > longstr.size()) {
			longstr = str;
		}
		auto itr = words.find(str);
		if (itr != words.end()) {
			words[str]++;
		}
		else {
			words[str] = 1;
		}
		if (maxword < words[str]) {
			maxword = words[str];
			maxwordstr = str;
		}
	}
	cout << maxwordstr << " " << longstr;
	return 0;
}

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

int main()
{
	string in,large="";
	map<string,int> cnt;
	getline(cin,in);
	string tmp="";
	for(int i=0;i<in.size();i++)
	{
		if(in[i]==' '||i==in.size()-1)
		{
			if(i==in.size()-1&&in[i]!=' ') tmp+=in[i];
			large=large.size()<tmp.size()?tmp:large;
			cnt[tmp]++;
			tmp="";
		}
		else
		{
			tmp+=in[i];
		}
	}
	map<string,int>::iterator it=cnt.begin();
	string ans; int num=0;
	while(it!=cnt.end())
	{
		//cout<<(*it).first<<" "<<(*it).second<<endl;
		if((*it).second>num)
		{
			ans=(*it).first;
			num=(*it).second;
		}
		it++;
	}
	cout<<ans<<" "<<large<<endl;
	return 0;
}

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

//文章が与えられた時、出現頻度の高い単語と最長の単語を出力するもの。
//文章に現れる単語リストを作ってそれぞれの文字列をカウントすればよい。

int main(){
	string sentence[1000];
	int sentenceNum[1000];
	int array[1000];
	string input;
	int count = 0;
	bool flag;　//単語リストから単語が見つかったどうか
	int maxLength = 0;

	for(int i=0; i < 1000; i++) sentenceNum[i] = 0;

	while(cin >> input){
		flag = false;

		//count == 0 文頭の単語の処理
		if(!count){
			sentence[0] = input;
			sentenceNum[0]++;
			count++;
			int inputSize = input.size();
			maxLength = max(maxLength, inputSize);
		}

		//文頭でない場合
		else {
			for(int i=0; i < count; i++){
				if(sentence[i] == input){
					sentenceNum[i]++;
					flag = true;
					break;
				}
			}
			if(!flag){
				sentence[count] = input;
				sentenceNum[count]++;
				count++;
				int inputSize = input.size();
				maxLength = max(maxLength, inputSize);
			}
		}
	}

	for(int i=0; i < 1000; i++) array[i] = sentenceNum[i];

	sort(array, array+1000, greater<int>());

	for(int i=0; i< count; i++){
		if(array[0] == sentenceNum[i]){
			cout << sentence[i];
		}
	}
	for(int i=0; i< count; i++){
		int sentenceSize = sentence[i].size();
		if(maxLength == sentenceSize){
			cout << " " << sentence[i] << endl;
		}
	}
}

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

using namespace std;

typedef long long ll;
typedef long double real;
typedef pair<int, int> duo;

#define TT template<typename T>
TT T    sq(T x){ return x*x; }
TT int  ubnd(vector<T>& v,T x){ return upper_bound(v.begin(), v.end(), x) - v.begin(); }
TT int  lbnd(vector<T>& v,T x){ return lower_bound(v.begin(), v.end(), x) - v.begin(); }
TT void sort(T& v){ sort(v.begin(), v.end()); }
TT void revs(T& v){ reverse(v.begin(), v.end()); }
TT void uniq(T& v){ sort(v); v.erase(unique(v.begin(), v.end()), v.end()); }
TT void show(T& v,char d=' ',char e='\n'){for(int i=0;i<v.size();++i)cout<<v[i]<<((i==v.size()-1)?e:d);}
TT void inpt(vector<T>& v,int n){ v.reserve(n);for(int i=0;i<n;++i){T x; cin>>x; v.push_back(x);} }
TT T In(){ T x; cin >> x; return x; }

static inline void fast_io(){ ios::sync_with_stdio(0); cin.tie(0); }
static inline int in(){ int x; scanf("%d", &x); return x; }
static inline string instr(){ string x; cin >> x; return x; }
static inline ll pow_mod(ll a, ll k, ll m){ll r=1;for(;k>0;a=a*a%m,k>>=1)if(k&1)r=r*a%m;return r;}
static inline ll mod_inv(ll a, ll p){ return pow_mod(a,p-2,p); }
static const int dx[] = {0, 0, 1, -1, 1, 1, -1, -1};
static const int dy[] = {1, -1, 0, 0, 1, -1, 1, -1};
static const int Mod = 1000000000;

int main()
{
  map<string, int> cnt;
  string word;
  while (cin >> word){
    cnt[word]++;
  }
  int freq, length;
  string freq_s, length_s;
  length = freq = -1;
  for (const auto& v : cnt){
    if (freq < v.second){
      freq = v.second;
      freq_s = v.first;
    }
    if (length < (int)v.first.size()){
      length = v.first.size();
      length_s = v.first;
    }
  }
  cout << freq_s << " " << length_s << endl;
  return (0);
}

// priority_queue queue deque first second front top push pop map set stringstream max_element min_element insert count find

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

int main()
{
	map<string, int> m;
	string s;
	while(cin>>s){
		m[s]++;
	}
	string often, longest;
	for(map<string, int>::iterator it=m.begin();it!=m.end();it++){
		if(longest.length() < it->first.length() ){
			longest = it->first;
		}
		if(m[often] < it->second){
			often = it->first;
		}
	}
	cout<<often<<' '<<longest<<endl;
	
	return 0;
}

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

using namespace std;
typedef long long ll;

int main(){
    char in[500];
    int ans_max=0,ans_long=0;
    string s_max,s_long;
    map<string,int> mm;
    
    while(EOF!=scanf("%s",in)){
        
        string S = in;
        
        if((int)S.size() > ans_long){
            s_long = S;
            ans_long = (int)S.size();
        }
        
        mm[S]++;
    }
    
    for(map<string,int>::iterator it = mm.begin();it!=mm.end();it++){
        if( (it->second) > ans_max ){
            ans_max = it->second;
            s_max = it->first;
        }
    }
    
    cout << s_max <<  " " << s_long << endl;
    
    return 0;
}