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 <string>
#include <vector>
#include <iostream>
#include <sstream>
    
typedef struct LettersInfo {
    std::string letters;
    unsigned int count;
} lettersInfo_s;
    
int main()
{
    std::string paramStr;
    std::getline(std::cin, paramStr);
    
    std::vector<lettersInfo_s*> lettersList;
    
    std::string letters;
    std::istringstream stream(paramStr);
    
    unsigned int maxLength = 0;
    std::string maxLengthStr;
    
    while (std::getline(stream, letters, ' ')) {
        unsigned int len = letters.size();
        if ( len != 0) {
            if ( maxLength < len ) {
                maxLengthStr = letters;
                maxLength = len;
            }
   
            unsigned int loopCount;
            for (loopCount = 0; loopCount < lettersList.size(); loopCount++) {
                if ( lettersList[loopCount]->letters == letters ) {
                    ++lettersList[loopCount]->count;
                    break;
                }
            }
   
            if (loopCount == lettersList.size()) {
                lettersInfo_s* plettersInfo = new lettersInfo_s();
                plettersInfo->letters = letters;
                ++plettersInfo->count;
                lettersList.push_back(plettersInfo);
            }
        }
    }
    
    unsigned int maxCount = 0;
    std::string maxCountStr;
    while( lettersList.size() > 0 ) {
   
        lettersInfo_s* plettersInfo = lettersList.back();
   
        unsigned int count = plettersInfo->count;
        if (maxCount < count) {
            maxCountStr = plettersInfo->letters;
            maxCount = count;
        }
        delete plettersInfo;
        lettersList.pop_back();
    }
    
    std::cout << maxCountStr << " " << maxLengthStr << std::endl;
    
    return 0;
}

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

typedef pair<int,string> P;

int main(void)
{

	char c;
	string str,maxstr;
	P d[1001] = {};	

	while(scanf("%c", &c), c != '\n'){
		if(c != ' '){
			str += c;
		}
		else {
			if(strlen(str.c_str()) > strlen(maxstr.c_str())){
				maxstr.clear();
				maxstr = str;
			}
			int i;
			for(i = 0; d[i].first != 0; i++){
				if(d[i].second == str){
					d[i].first++;
					break;
				}
			}
			if(d[i].first == 0){
				d[i] = P(1,str);
			}
			str.clear();
		}
	}
	if(strlen(str.c_str()) > strlen(maxstr.c_str())){
		maxstr.clear();
		maxstr = str;
	}
	int i;
	for(i = 0; d[i].first != 0; i++){
		if(d[i].second == str){
			d[i].first++;
			break;
		}
	}
	if(d[i].first == 0){
		d[i] = P(1,str);
	}
	str.clear();

	sort(d,d+1001);
	cout << d[1000].second << ' ' << maxstr << endl;

	return 0;
}

C++: #include <iostream>
#include <string>
#include <map>
using namespace std;
int main(){
	string s;	getline(cin,s);
	string word;
	map<string,int> dic;
	for(int i=0;i<s.size();i++){
		if(s[i]!=' '){
			word+=s[i];
		}
		else{
			dic[word]++;
			word="";
		}
	}
	dic[word]++;
	int num=0;
	for(auto it:dic)	num=max(num,it.second);
	for(auto it:dic){
		if(num==it.second) 	cout<<it.first<<" ";
	}
	num=0;
	for(auto it:dic)	num=max(num,(int)it.first.size());
	for(auto it:dic){
		if(num==it.first.size())	cout<<it.first<<endl;
	}
	return 0;
}

C++: #define _USE_MATH_DEFINES
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<list>
#include<stack>
#include<queue>
#include<cctype>
#include<iomanip>
#include<functional>
#include<numeric>
#include<map>
#include<set>
#define EPS 1e-10
using namespace std;
typedef long long llong;
int main() {
	map<string, int>a;
	int len = 0, freq = 0;
	string s;
	while (cin>>s) {
		a[s]++;
		if (len < s.length())len = s.length();
		if (freq < a[s])freq = a[s];
	}
	for (auto it = a.begin(); it != a.end(); it++) {
		if (freq == it->second)cout << it->first << " ";
	}
	for (map<string, int>::iterator it = a.begin(); it != a.end(); it++) {
		if (len == it->first.length())cout << it->first << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <string>
#include <map>
using namespace std;
int main(){
	string str,s,mls,mcs,input[100];
	map <string,int> dic;
	int n,c,a,ml,mc;
	getline(cin,str);
	c = a = mc = ml = 0;
	str += ' ';
	while(str.length()){
		n = str.find(' ');
		s = str[c];
		++c;
		for(;c < n;++c){
			s += str[c];
		}
		str.erase(0,n+1);
		c = 0;
		input[a] = s;
		++a;
		++dic[s];
		if(s.length() > ml) {
			ml = s.length();
			mls = s;
		}
	}
	for(int i = 0;i < a;++i){
		if(mc < dic[input[i]]){
			mc = dic[input[i]];
			mcs = input[i];
		}
	}
	cout << mcs << " " << mls << endl;
	return 0;
}

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


typedef pair<string,int> p;
vector <p> ls(0);


int find(string s){
  for(int i=0; i<(int)ls.size(); i++){
    if(s==ls[i].first){
      return i;
    }
  }
  return -1;
}

int main(){

  string in;
  int max=0,indx=0;
  string maxs="";

  while(cin>>in){
    int tmp=find(in);
    if(tmp==-1){
      ls.push_back(p(in,1));
      if(in.size()>maxs.size()){ maxs = in;}
    }
    else{
      ls[tmp].second++;
      if(ls[tmp].second>max){
        max=ls[tmp].second;
        indx = tmp;
      }
    }

/*
    for(int i=0; i<(int)ls.size(); i++)
      cout << ls[i].first << " ";
      cout << endl;
    for(int i=0; i<(int)ls.size(); i++)
      cout << ls[i].second << " ";
      cout << endl;
*/
  }

  cout << ls[indx].first << " " << maxs << endl;

  return 0;
}

C++: //?\???°??????
//10???
#include <iostream>
#include <string>
#include <map>
#include <vector>
using namespace std;
int main(){
    map<string,int>m;
    string s;
    vector<string>v;
    while(cin>>s){
        if('A'<=s[0]&&s[0]<='Z'){
            s[0]=s[0]-'A'+'a';
        }
        m[s]++;
        v.push_back(s);
    }
    int ans1=-1;
    int ans2=-1;
    string ans1s;
    string ans2s;
    for(int i=0;i<v.size();i++){
        if(ans1<m[v[i]]){
            ans1=m[v[i]];
            ans1s=v[i];
        }
        if(ans2<v[i].size()){
            ans2=v[i].size();
            ans2s=v[i];
        }
    }
    cout<<ans1s<<" "<<ans2s<<endl;
}

C++: #include <bits/stdc++.h>
#include <iostream>
#include <utility>
#include <string>
#define MAX_N 1001
#define rep(i, n) for(int i=0; i<n; i++)
using namespace std;
typedef pair<string, int> P;
P p[MAX_N];
int n;

int main(){
    string s;
    n = 0;
    while(cin >> s){
        bool flag = false;
        rep(i, n){
            if(p[i].first == s){
                p[i].second++;
                flag = true;
            }
        }
        if(!flag){ 
            p[n].first = s;
            p[n].second++;
            n++;
        }
    }
    // rep(i, n) cout << p[i].first << " " << p[i].second << endl;
    sort(p, p+n, [](const P &left, const P &right){
        return left.second > right.second;
    });
    cout << p[0].first << " ";
    sort(p, p+n, [](const P &left, const P &right){
        return left.first.size() > right.first.size();
    });
    cout << p[0].first << endl;
    return 0;
}