Go: package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
)

var scanner = bufio.NewScanner(os.Stdin)

func nextString() string {
	scanner.Scan()
	return scanner.Text()
}

type Pair struct {
	key   string
	value int
}

func main() {
	scanner.Split(bufio.ScanWords)
	counts := map[string]int{}
	maxLen := 0
	maxLenWord := ""
	for {
		word := nextString()
		if word == "" {
			break
		}

		counts[word]++

		if len(word) > maxLen {
			maxLen = len(word)
			maxLenWord = word
		}
	}

	mapPairs := []Pair{}
	for k, v := range counts {
		mapPairs = append(mapPairs, Pair{k, v})
	}
	sort.Slice(mapPairs, func(i, j int) bool { return mapPairs[i].value > mapPairs[j].value })

	fmt.Println(mapPairs[0].key, maxLenWord)
}

C++: #include<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<numeric>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<functional>

#define MP make_pair
#define PB push_back
#define ALL(x) (x).begin(),(x).end()
#define REP(i,n) for(int i=0;i<(n);i++)
#define REP1(i,n) for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n) for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;

const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;

const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};

int main(){
	int cnt1=0,cnt2=0,tmp=0,anss1=0,anss2=0;
	string str,ans1,ans2,a;
	vector<string> v;

	getline(cin,str);
	for(int i=0;i<str.size()+1;i++){
		if(str[i]==' ' || i==str.size()){
			a=str.substr(tmp,i-tmp);
			v.push_back(a);
			tmp=i+1;
			cnt1++;
		}
	}
	for(int i=0;i<cnt1;i++){
		for(int j=0;j<cnt1;j++){
			if(v[i]==v[j]){
				cnt2++;
			}
		}
		if(anss1<cnt2){
			anss1=cnt2;
			ans1=v[i];
		}
		if(anss2<v[i].length()){
			anss2=v[i].length();
			ans2=v[i];
		}
		cnt2=0;
	}
	cout << ans1 << ' ' << ans2 << endl;
	return 0;
}

C++: #include <iostream>
#include <string>
using namespace std;
int main(){
    long saidai=0;
    int a=0,cnt=0,num=0,max=0;
    string str,tango[1000]={"0"},answer,ans;
    getline(cin,str);
    for(int i=0;i<str.size();i++){
        if(str[i]==' '){
            for(int j=a;j<i;j++){
                tango[cnt]+=str[j];
            }
            cnt=cnt+1;
            a=i+1;
        }
    }
    for(int p=a;p<str.size();p++){
        tango[cnt]+=str[p];
    }
    for(int k=0;k<1000;k++){
        if((tango[k]=="0"))break;
        if(saidai<tango[k].size()){
            saidai=tango[k].size();
            ans=tango[k];
        }
    }
    
    for(int s=1;s<=cnt;s++){
        for(int t=s+1;t<=cnt;t++){
            if(tango[s]==tango[t]){
                num=num+1;
            }
        }
        if(max<num){
            max=num;
            answer=tango[s];
        }
    }
    cout<<answer<<" "<<ans<<endl;
    return 0;
}

C++: #include<iostream>
#include<cstring>
using namespace std;
int const N = 1000;
int main(){
  char str[N][29];
  int num[N],i=0,max=0,l=0;
  while(cin >> str[i]){
    i++;
  }
  for(int j =0;j<i;j++){
    num[j] =j;
  }
  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(l < strlen(str[j]))
      l = j;
  }

  cout <<  str[max] <<" "<< str[l] << endl;
}

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

int main() {
    unordered_map<string, int> table;
    string frequent;    // 最大頻度
    string longest;     // 最長
    string word;        // 入力
    while (cin >> word) {
        table[word]++;
        if (table[word] > table[frequent]) {
            frequent = word;
        }
        if (word.length() > longest.length()) {
            longest = word;
        }
    }
    cout << frequent << " " << longest << endl;
    return 0;
}

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

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()

int main() {
  multiset<string> mset;
  string s;
  int maxlen = 0, maxc = 0;
  string ans, ans2;
  while(cin>>s) {
    mset.insert(s);
    if (maxlen<s.length()) {
      maxlen = s.length();
      ans2 = s;
    }
    if (maxc<mset.count(s)) {
      maxc = mset.count(s);
      ans = s;
    }
  }
  cout << ans << " " << ans2 << endl;
  
  
}

C++: #include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1e8;
int main(){
	string s;
	map<string,int>m;
	int out=0;
	while(cin>>s){
		m[s]++;
		out=max(out,s.size());
	}
	int ma=0;
	string ans;
	for(auto it=m.begin();it!=m.end();it++){
		ma=max(ma,it->second);
		if(out==it->first.size());ans=it->first;
	}
	for(auto it=m.begin();it!=m.end();it++){
		if(it->second==ma)cout<<(it->first)<<" ";
	}
	cout<<ans<<endl;
}

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

using namespace std;

int main() {
  string s;
  unordered_map<string, int> cnt;
  vector<string> v;

  while (cin >> s) {
    cnt[s] += 1;
    v.push_back(s);
  }

  int max_freq = 0;
  int max_len = 0;

  for (auto p: cnt) {
    max_freq = max(max_freq, p.second);
    max_len = max(max_len, (int)p.first.size());
  }

  for (auto p: cnt) {
    if (p.second == max_freq) {
      cout << p.first << ' ';
    }
  }

  for (auto p: cnt) {
    if (p.first.size() == max_len) {
      cout << p.first << endl;
    }
  }
}

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

int main(){

  std::vector<string> word;
  std::vector<int> count;
  string now;
  int num=0,most=0;
  bool aaa;

  while(cin >> now){
    aaa = true;
    for(int i=0;i<num;i++)
      if(word[i] == now){
	count[i]++;
	aaa = false;
      }

    if(aaa){
      word.push_back(now);
      count.push_back(1);
      num = word.size();
    }
  }

  now = " ";

  for(int i=0,mmm=0,nnn=0;i<num;i++){
    if(mmm < count[i]){
      mmm = count[i];
      most = i;
    }
    if(now.size() < word[i].size()){
      now = word[i];
    }
  }

  cout << word[most] << ' ' << now << endl;

  return 0;
}