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> str;
  vector<int> cnt;
  string buf, maxstr;
  int max, ans, i;

  while(cin >> buf){
    bool f = true;

    if(max < buf.length()){
      max = buf.length();
      maxstr.append(buf);
    }
      
    for(i = 0; i < str.size(); i++){
      if(str[i] == buf){
	f = false;
	break;
      }
    }
    if(f){
      str.push_back(buf);
      cnt.push_back(1);
    }
    else{
      cnt[i]++;
    }
  }

  max = 0;
  for(i = 0; i < cnt.size(); i++){
    if(cnt[i] > max){
      max = cnt[i];
      ans = i;
    }
  }

  cout << str[i] << ' ' << maxstr << endl;

  return 0;
}

C++: #include <iostream>
#include <cstring>
#include <cstdio> //fgets
using namespace std;

int main(){
	char str[1000];
	char word[33][33]={0};
	int longest=0;
	int check[33]={0};
	char *tmp;
	int freq=0;
	int count=0;
	int i,j;
	size_t len , prev;
	fgets(str , sizeof(str) , stdin);
		tmp=str;
		for(i=0 ; str[i]!='\0' ;i++){
			if(str[i]==' '){
				str[i]='\0';
				strcpy((char*)&word[count] , (const char*)tmp);
				tmp=str+i+1;
				count++;
			}
		}
		strcpy((char*)&word[count],(const char*)tmp);
		count++;
	for(i=0 ; i<count ; i++){
		for(j=i ; j<count ; j++){
			if(strcmp((const char*)&word[i] , (const char*)&word[j])==0){
				check[i]++;
			}
		}
	}
	for(i=0 ; i<count-1 ; i++){
		if(check[freq]<check[i+1]){
			freq=i+1;
		}
	}
		prev=strlen(word[0]);
	for (i=0 ; i<count ; i++){
		len=strlen(word[i]);
		if(len > prev){
			prev = len;
			longest=i;
		}	
	}
	cout << (char*)&(word[freq]) << " "<< (char*)&(word[longest]);
	return 0;
}

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

int main(){
	map<string,int> m;
	string s;
	while(cin >> s){
		m[s]++;
	}
	int max_word = 0;
	string ans1;
	/*出現頻度が最大*/
	for(map<string,int>::iterator it = m.begin(); it != m.end(); ++it){
		if(it->second > max_word){
			ans1 = it->first;
			max_word = it->second;
		}
	}

	int max_length = 0;
	string ans2;
	/*文字数が最大*/
	for(map<string,int>::iterator it = m.begin(); it != m.end(); ++it){
		if(it->first.size() > max_length){
			ans2 = it->first;
			max_length = it->first.size();
		}
	}

	cout << ans1 << " " << ans2 << endl;
}

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

int main(){
	string w[1000];
	int max=0,maxc=0,maxi=0,idx=0;
	for(int i=0;cin>>w[i];i++){
		if(w[i].size()>w[max].size()) max=i;
		idx++;
	}for(int i=0;i<idx;i++){
		int cnt=0;
		for(int j=0;j<idx;j++){
			if(w[i]==w[j]) cnt++;
		}if(cnt>maxc){
			maxi=i;
			maxc=cnt;
		}
	}cout<<w[maxi]<<" "<<w[max]<<endl;
	return 0;
}

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

int main(void) {
    vector<string> vec;
    string input, ans1;
    int maxLen = 0;
    while(cin >> input) {
        vec.push_back(input);
        if(input.length() > maxLen) {
            maxLen = (int)input.length();
            ans1 = input;
        }
    }
    map<int, string> hm;
    vector<string>::iterator ite;
    int max = 0;
    for(ite = vec.begin(); ite != vec.end(); ite++) {
        string now = *ite;
        int cnt = (int)count(vec.begin(), vec.end(), now);
        if(cnt > max) max = cnt;
        hm.insert(make_pair(cnt, now));
    }
    map<int, string>::iterator ite2;
    for(ite2 = hm.begin(); ite2 != hm.end(); ite2++) {
        if(ite2->first == max) {
            cout << ite2->second << " "; break;
        }
    }
    cout << ans1 << endl;
    return(0);
}

C++: #include<iostream>
#include<map>
#include<cstring>
#include<stack>

using namespace std;

int main(){
  int max_c = 0;
  map<string, int> cnt;
  stack<string> words;
  string word, freq, max_l;
  
  while(cin >> word) {
    if(word.length() > max_l.length()) max_l = word;
    if(cnt[word] == 0) words.push(word);
    cnt[word]++;
  }
  
  while(!words.empty()){
    word = words.top();
    words.pop();
    if(max_c < cnt[word]) {
      max_c = cnt[word];
      freq = word;
    }
  }

  cout << freq << ' ' << max_l << endl;

  return 0;
}

C++: #include "bits/stdc++.h"

using namespace std;

typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;

#define dump(x)  cerr << #x << " = " << (x) << endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back

int main(){
	map<string,int> mp;
	string s;
	getline(cin,s);
	vector<string> sent;

	int len=s.size();




	string maxStr="";
	int maxNum=-1;

	string tmp="";
	rep(i,len){
		if(s[i]!=' '){
			tmp+=s[i];
		}
		else{
			mp[tmp]+=1;
			sent.pb(tmp);
			if(maxNum<(int)tmp.size()){
				sent.pb(tmp);
				maxStr=tmp;
				maxNum=tmp.size();
			}
			tmp="";
		}
	}
	mp[tmp]+=1;
	sent.pb(tmp);
	if(maxNum<(int)tmp.size()){
		sent.pb(tmp);
		maxStr=tmp;
		maxNum=tmp.size();
	}

	string str="";
	int num=-1;
	for(int i=0;i<sent.size();i++){
		if(num<mp[sent[i]]){
			str=sent[i];
			num=mp[sent[i]];
		}

	}
	cout<<str<<" "<<maxStr<<endl;


	return 0;
}

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

using namespace std;

int main(){
	string sent;
	string word[500];
	int a[500]={};
	int i,j,k,l;
	int n,m,len;
	i=0;
	while(cin>>sent){
		if(i==0){
			word[0]=sent;
			a[0]++;
			i++;
			len=sent.size();
			n=0;
		}
		else {
			if(len<sent.size()){
				len=sent.size();
				n=i;
			}
			for(j=0; j<i; j++){
				if(sent==word[j]){
					a[j]++;
					break;
				}
				if(j==i-1){
					word[i]=sent;
					a[i]++;
					i++;
					break;
				}
			}
		}
	}
	m=0;
	for(j=0; j<=i; j++){
		if(m<a[j])m=j;
	}
	cout<<word[m]<<" "<<word[n]<<endl;
	return 0;
}

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

using namespace std;

int main()
{
	map<string, int> counter;
	string longest;

	{
		string input;
		while(cin >> input)
		{
			if(longest.length() < input.length())
				longest = input;

			if(counter.find(input) == counter.end())
				counter[input] = 0;
			else
				counter[input]++;
		}
	}

	int frequency = 0;
	string word;
	for(auto i : counter)
		if(frequency < i.second)
		{
			frequency = i.second;
			word = i.first;
		}

	cout << word << ' ' << longest << endl;

	return 0;
}

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

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);

    int max_cnt = 0, cnt;
    std::string max_lenght_str = "";
    std::string max_cnt_str = "";
    std::string str;
    std::map<std::string, int> str2cnt;

    while (std::cin >> str) {
        std::transform(str.begin(), str.end(),
                       str.begin(), ::tolower);
        if (str.size() > max_lenght_str.size()) {
            max_lenght_str = str;
        }
        cnt = ++str2cnt[str];

        if (max_cnt < cnt) {
            max_cnt = cnt;
            max_cnt_str = str;
        }
    }

    std::cout << max_cnt_str << " " << max_lenght_str << std::endl;

    return 0;
}