Go: package main

import (
	"bufio"
	"fmt"
	"os"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Scan()
	l := sc.Text()
	words := strings.Split(l, " ")

	frequency := map[string]int{}
	long := map[string]int{}
	var maxFrequency, longest int
	var frequentWord, longestWord string
	for _, w := range words {
		frequency[w]++
		long[w] = len(w)
		if frequency[w] > maxFrequency {
			maxFrequency = frequency[w]
			frequentWord = w
		}
		if len(w) > longest {
			longest = long[w]
			longestWord = w
		}
	}

	fmt.Println(frequentWord + " " + longestWord)
}

C++: #include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cmath>
#include <stack>
#include <map>
#include <sstream>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
using namespace std;

int main(){
    map<string, int> dic;
    string str, sfmax, slmax, tmp;
    int fmax = 0, lmax = 0;
    getline(cin, tmp);
    stringstream stream(tmp);
    while (getline(stream, str, ' ')){
    	dic[str]++;
    	if (fmax < dic[str]){
    		fmax = dic[str];
    		sfmax = str;
    	}
    	if (lmax < str.length()){
    		lmax = str.length();
    		slmax = str;
    	}
    }
    cout << sfmax << ' ' << slmax << endl;
}

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;
}