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<iostream>
#include<vector>
#include<string>

using namespace std;

int main(void){
  vector<string> s;
  vector<int> cnt;
  string ss,str;
  getline(cin,str);
  string longest="";
  string max;
  int maxv=-1;
  str+=" ";
  for(int i = 0; i < str.size() ; i ++  ){
    if(str[i] == ' '){
      bool used=true;
      
      for(int j = 0 ; j < s.size() ; j ++){
	if(s[j] == ss){
	  cnt[j]++;
	  //cout<<ss<<cnt[j]<<endl;
 
	  if(maxv>cnt[j]){
	    longest=ss;
	  }

	  ss="";
	  used=false;
	}
      }
      if(used){
	s.push_back(ss);
	cnt.push_back(1);
	//cout<<ss<<cnt[cnt.size()-1]<<endl;
	if(s.size() == 1){
	  longest=ss;
	  max=ss;
	  maxv=ss.size();
	}
	if(ss.size()>max.size())max=ss;
	ss="";
      }
      
    }else{
      ss+=str[i];
    }
    // cout<<str[i]<<endl;
  }
  cout<<longest<<" ";
  cout<<max<<endl;
  /*
  for(int i = 0 ; i < s.size() ; i ++){
    cout<<s[i]<<endl;;
  }
  cout<<endl;
  //*/
}

C++: #include<stdio.h>
#include<string.h>
int main()
{
	int c=0,r=0,n=0,max=0,most=0,p,q;
	char str[1000][32],now;
	while(scanf("%c",&now)!=EOF)
	{
		if(now==' ')
		{
			str[r][c]='\0';
			r++;
			c=0;
			n++;
		}
		else
		{
			str[r][c++]=now;
		}
	}
	str[r][c]='\0';
	for(int i=0;i<=n;i++)
	{
		int same=0,temp=strlen(str[i]);
		if(temp>max)
		{
			max=temp;
			q=i;
		}
		for(int j=i+1;j<n;j++)
		{
			if(strcmp(str[i],str[j])==0)
				same++;
		}
		if(same>most)
		{
			most=same;
			p=i;
		}
	}
	printf("%s %s\n",str[p],str[q]);
}

C++: #include <iostream>
#include <cstring>
#include <string.h>
#include <cstdio>
using namespace std;
int main(){
  char c[1111];
  int len=0;
  int k=0;
  char maxc;
  int iti[1111]={0};//頻度高いよう
  char ans[1111];
  char ans1[1111];
  char cpy[1111][1111];
  while(scanf("%s",c)!=EOF){
    if(len<strlen(c)){//最長のもの
      len=strlen(c);
      strcpy(ans,c);
    }
    
    for(int i=0;i<k+1;i++){
      if(strcmp(cpy[i],c)==0){//すでに一度でていたら
	iti[i]++;
      }else if(i==k){//一度もでていなかったら
	strcpy(cpy[i],c);
      }
    }
    k++;
  }
  
  strcpy(ans1,cpy[0]);
  for(int i=0;i<k-1;i++){
    if(iti[i]<iti[i+1]){
      strcpy(ans1,cpy[i+1]);
    }
  }
  
  cout << ans1 << " " << ans << endl;
}

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

#define all(c) (c).begin(), (c).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second

const int INF=100000000;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
using namespace std;
typedef pair<int ,int > P;
typedef long long ll;

map<int,string> map1;
map<string,int> map2;
int main() {
    string s;
    while(cin>>s) {
        map1[-s.size()]=s;
        map2[s]++;
    }

    auto it = map2.begin();
    int maxi=0;
    string ans;
    while(it!=map2.end()) {
        if(maxi<it->sc) {
            maxi = it->sc;
            ans=it->fr;
        }
        it++;

    }
    cout<<ans<<" ";
    cout<<(map1.begin()->sc)<<endl;

    return 0;
}

C++: #include<iostream>
#include<map>
#include<string>
using namespace std;
int main(){
	string b,mx; map<string,int> d;
	while(cin>>b){
		d[b]++; if(b.size()>mx.size())mx=b;
	}
	cout<<max_element(d.begin(),d.end())->first<<" "<<mx<<endl;
	return 0;
}

C++: #include<iostream>
#include<string>
#include<map>
using namespace std;
int main(){
  map<string,int> map;
  string s, mxc, mxl;
  int freq,len;
  while(cin >> s){
    if(map.find(s) == map.end()){
      map[s] = 1;
    }
    else{
      map[s]++;
    }

    if(map[s] > freq){
      freq = map[s];
      mxc = s;
    }
    if(s.size() > len){
      len = s.size();
      mxl = s;
    }

  }
  cout << mxc << " " << mxl << endl;
}

C++: #include<iostream>
#include<string>
#include<map>
using namespace std;
int main(){
  map<string,int> m;
  map<string,int>::iterator p;
  int ans=0,count=0; 
  string ans1 ,ans2;
  string s;
  while(cin >> s){
    ++m[s];
    if(ans<s.size()){
      ans = s.size();
      ans2 = s;
    }
  }
  p = m.begin();
  for(p=m.begin();p!=m.end();p++){
    if(count<p->second){
      count = p->second;
      ans1 = p->first;
    }
  }
  cout << ans1 << ' ' << ans2 << endl;
  return 0;
}

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]++;
		int d=s.size();
		out=max(out,d);
	}
	int ma=0;
	string ans="";
	for(map<string,int>::iterator it=m.begin();it!=m.end();it++){
		ma=max(ma,it->second);
		if(out==it->first.size())ans=it->first;
	}
	for(map<string,int>::iterator it=m.begin();it!=m.end();it++){
		if(it->second==ma)cout<<(it->first)<<" ";
	}
	cout<<ans<<endl;
}

C++: #include<iostream>
#include<map>
#include<string>

using namespace std;

int main() {
  map<string, int> M;
  string word, fword, lword = "";
  int s = 0;
  while(cin >> word) {
    M[word]++;
    if(M[word] > s) {
      s = M[word];
      fword = word;
    }
    if(word.size() > lword.size()) lword = word;
  }
  cout << fword << " " << lword << endl;
  return 0;
}

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

int main(){
    string w,ans="";
    int n=0;
    map<string,int> s;
    while(cin>>w){
        s[w]++;
        n=max(n,s[w]);
        if(ans.size()<w.size()){ans=w;}
    }
    for(auto p=s.begin();p!=s.end();++p){
        if(p->second==n){cout<<p->first<<' ';}
    }
    cout<<ans<<endl;
}