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 <map>
#include <string>
using namespace std;
int main(){
    string s,max("");
    map<string,int> word;
    map<int,string> tmp;
    while(cin >> s){
        if(s.size() > max.size())max=s;
        word[s]++;
    }
    map<string,int>::iterator it;
    for(it=word.begin();it!=word.end();it++){
        tmp[(*it).second] = (*it).first;
    }
    cout << (*tmp.rbegin()).second << " "<< max << endl;
    return 0;
}

C++: #include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<stack>
#include<cmath>
#include<iomanip>
#include<set>
#include<numeric>
#include<sstream>
#include<random>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;
//const int inf = 1e9 + 7;
//int dy[] = {0, 0, -1, 1};
//int dx[] = {1, -1, 0, 0};

int main() {
    string s;
    getline(cin, s);
    istringstream ss(s + "\n");
    map<string, int> mp;
    string longer;
    while (1) {
        string t; ss >> t;
        if (!ss.good()) break;
        mp[t]++;
        if (t.size() > longer.size()) longer = t;
    }
    string freq;
    int lerger = 0;
    for (auto it : mp) {
        if (it.second > lerger) {
            lerger = it.second;
            freq = it.first;
        }
    }
    cout << freq << " " << longer << endl;
}

C++: #include<iostream>
#include<cstring>
using namespace std;
int const N = 1001;
int main(){
	char str[N][50];
	int num[N],i=0,max=0,l=0;
	while(cin >> str[i]){
		i++;
	}
	for(int j=0;j<i;j++){
		num[j]=0;
	}
	for(int j=0;j<i;j++){
		for(int k=0;k<i;k++){
			if(strcmp(str[j],str[k])==0)
		num[j]++;
		}
		if(num[max] < num[j])
			max = j;
		if(strlen(str[l]) < strlen(str[j]))
			l=j;
	}
	cout << str[max] << " " << str[l] << endl;
}

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

int main(){
	string in[1001];
	int num[1001], i=0, max=0, lon=0, ansa, ansb;

	for(int i=0;i<1001;i++){
		num[i] = 0;
	}

	while (true)
	{
		cin >> in[i];
		if (cin.eof()||in[i] == "0") { break; }
		for(int j=0;j<i;j++){
			if(in[i] == in[j]){
				num[j]++;
				continue;
			}
		}
		i++;
	}
	for(int j=0;j<i;j++){
		if (max < num[j]) {
			max = num[j];
			ansa = j;
		}
		if (lon < in[j].size()) {
			lon = in[j].size();
			ansb = j;
		}
	}
	cout << in[ansa] << " " << in[ansb] << endl;
	return 0;
}

C++: 
// mapはキー／値の対を保持する理想コンテナ
// 連想配列

#include <iostream>
#include <string>
#include <map>
#include <algorithm>

using namespace std;

int main(void){

  string s;
  map< string , int > count; // キーがstring型、値がintのmap
  string num;
  string len;

  while( cin >> s ){
    int c = ++count[s];                    //初期化は必要なし？  
    if( c > count[num] ) num = s;          //ここで単語
    if( s.size() > len.size() ) len = s;   //ここで文字数
  }
  cout << num << " " << len << endl;
  return 0;
}

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

int main() {
	map<string, long long> mp;
	string S;
	while (cin >> S) mp[S]++;
	long long MAXA = 0, MAXB = 0;
	for (auto it = mp.begin(); it != mp.end(); it++) {
		MAXA = max(MAXA, it->second);
		MAXB = max(MAXB, (long long)(it->first.size()));
	}
	for (auto it = mp.begin(); it != mp.end(); it++) {
		if (it->second == MAXA) cout << it->first << " ";
	}
	for (auto it = mp.begin(); it != mp.end(); it++) {
		if (it->first.size() == MAXB) cout << it->first << endl;
	}
}

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

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

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

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

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

C++: #include<cstdio>
#include<cstring>
#include<string>

using namespace std;

string s[1001];
int count[1001];

int main(void){
	char temp[1002];
	
	while(fgets(temp,1001,stdin) != 0){
		int temp_n = strlen(temp);
		int c = 0;
		int max_h = 0;
		int max_H = 0;
		int max_l = 0;
		int max_L = 0;
		
		for(int i = 0; i < 1001; i++){
			s[i] = "";
			count[i] = 0;
		}
		
		for(int i = 0; i < temp_n; i++){
			for(int j = i; ; j++){
				if(temp[j] == ' '){
					i=j;
					c++;
					break;
				}else if(temp[j] == '\n'){
					i=j;
					c++;
					break;
				}
				s[c] += temp[j];
			}
		}
		/*
		for(int i = 0; i < c; i++){
			printf("%d s == %s[%d]\n",i,s[i].c_str(),s[i].size());
		}
		*/
		for(int i = 0; i < c; i++){
			for(int j = 0; j < c; j++){
				if(i == j)continue;
				if(s[i] == s[j])count[i]++;
			}
		}
		
		for(int i = 0 ; i < c; i++){
			if(s[i].size() > s[max_L].size() )max_l = i;
			if(count[i] > count[max_H])max_h = i;
		}
		
		printf("%s %s\n", s[max_h].c_str(), s[max_l].c_str() );
	}
	return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <math.h>
using namespace std;

int main(){
	int m[1000],n=0,M=0,N=0,w,I,J,j;
	string r[1000],s;
	while(cin>>s){
		w=0;
		if(s.size()>M){M=s.size();I=n;}
		for(int i=0;i<n;i++)if(s==r[i]){m[i]++;w=1;j=i;break;}
		if(w==0){r[n]=s;m[n]=1;j=n;n++;}
		if(m[j]>N){N=m[j];J=j;}
	}
	cout<<r[J]<<" "<<r[I]<<endl;
}

C++: #include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <iterator>
#include <array>
#include <memory>
#include <stack>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
int main(){
    string gotiusa;
    getline(cin,gotiusa);
    string temp;
    map<string,int>mp;
    string ans1;
    rep(i,gotiusa.size()){
        if(i==gotiusa.size()-1)temp.push_back(gotiusa[i]);
        if(gotiusa[i]==' '||i==gotiusa.size()-1){mp[temp]++;if(ans1.size()<temp.size())ans1=temp;temp.clear();continue;}
        temp.push_back(gotiusa[i]);
    }
    pair<string,int>maxi;
    maxi.second=0;
    for(auto itr=mp.begin();itr!=mp.end();itr++)if(itr->second>maxi.second)maxi=make_pair(itr->first,itr->second);
    cout<<maxi.first<<" "<<ans1<<endl;

}