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<bits/stdc++.h>
#include<iostream>
#include <vector>
#include <cstdio>
#include<algorithm>
#include <utility>
#include<string>
using namespace std;
string str[33] = { "" };
char ch[10001];
int input();
int main() {
	int a,most=0;
	a = input();
	string  longest;
	int m[33] = { 0 }, l;
	for (int i = 0; i <= a + 1; i++) {
		for (int j = i + 1; j <= a; j++) {
			if (str[i] == str[j]) {
				m[i]++;
			}
		}
	}int k,ma=0,locate,memo;
	for (k = 0; k <= a+1; k++) {
		if (m[k] > ma) {
			ma = m[k];
			locate= k;
		}
	}
	for (int f = 0; f <= a+1; f++) {
		if (str[f].size()> most) {
			most = str[f].size();
			memo = f;
		}
	}
	longest = str[memo];
	cout << str[locate] << " " << longest << endl;
	return 0;
}
int input() {
	int i = 0, j = 0;
	while (1) {
		scanf("%c", &ch[i]);
		if (isupper(ch[i])) {
			ch[i] += 'a' - 'A';
		}
		if (ch[i] == ' ') {
			j++;
		}
		else if (ch[i] == '\n') {
			break;
		}
		else {
			str[j] += ch[i];
		}
		
	}
	return j;
}

C++: #include <iostream>
#include <string>
#include <map>
using namespace std;
map<string,int> table;
int main () {
  string word, frequent, longest;
  size_t N=0; //??????????????????
  while (cin >> word) {
    table[word] += 1;
    if (table[word] > N) {
      N = table[word];
      frequent = word;
    }
    if (word.size() > longest.size()) longest = word;
  }
  cout << frequent << " " << longest << endl;
}

C++: #include <iostream>
#include <algorithm>
#include <string>
#include <stack>
#include <cstdlib>
#include <queue>
#include <vector>
#include <map>
using namespace std;
int main() {
	string s,f,l;
	map<string,int> table;
	size_t n = 0;
	while( cin  >> s ) { 
		table[s] += 1;
		if ( table[s] > n ) {
			n = table[s];
			f = s;
		}
		if (s.size() > l.size() ) l = s;
	}
	cout << f << " " << l << endl;
}

C++: #include<map>
#include<iostream>
using namespace std;
int main(){
    map<string,int> sm;
    string in,freq,len;
    int maxfreq=0,maxlen=0;
    while(!cin.eof()){
       cin>>in;
       sm[in]++;
    }
    sm[in]--;
    for(map<string,int>::iterator it=sm.begin();it!=sm.end();it++){
        if(it->second>maxfreq){
            maxfreq=it->second;
            freq=it->first;
        }
        if(it->first.size()>maxlen){
            maxlen=it->first.size();
            len=it->first;
        }
    }
    cout<<freq<<" "<<len<<endl;
}

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

using namespace std;

map<string, int> table;

int main() {
  string word, frequent, longest;
  size_t N = 0; // size_t represents size in bytes of word (length)
  while (cin >> word) {
    table[word] += 1;
    if (table[word] > N) {
      N = table[word];
      frequent = word;
    }
    if (word.size() > longest.size()) longest = word;
  }
  cout << frequent << " " << longest << endl;
}

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

using namespace std;

void solve()
{
	string str;
	getline(cin, str);
	string word[1000];

	int pos = 0;
	int n = str.size();
	for(int i = 0; i < n; ++i)
	{
		if(str[i] == ' ')
		{
			pos++;
		}
		else
		{
			word[pos] += str[i];
		}
	}
	pos++;
	map<string, int> Map;
	for(int i = 0; i < pos; ++i)
	{
		Map[word[i]]++;
	}
	int frequency = 0;
	for(map<string, int>::iterator Ite = Map.begin(); Ite != Map.end(); ++Ite)
	{
		if(frequency < (*Ite).second)
		{
			frequency = (*Ite).second;
		}
	}
	int max_length = 0;
	for(int i = 0; i < pos; ++i)
	{
		if(max_length < word[i].size())
		{
			max_length = word[i].size();
		}
	}
	for(map<string, int>::iterator Ite = Map.begin(); Ite != Map.end(); ++Ite)
	{
		if(frequency == (*Ite).second)
		{
			cout << (*Ite).first << " ";
			break;
		}
	}
	for(int i = 0; i < pos; ++i)
	{
		if(max_length == word[i].size())
		{
			for(int j = 0; j < max_length; ++j)
			{
				cout << word[i][j];
			}
			cout << endl;
			break;
		}
	}
}

int main()
{
	solve();
	return(0);
}

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

using namespace std;

int main()
{
	int i = 0, max_num = 0, max_length_string_num = 0, tmp_num = 0;
	map< string, int > input_word;
	string tmp, max_length_string, max_num_string;

	while ( cin >> tmp )
	{
		input_word[tmp] = input_word[tmp] + 1;
		if ( tmp.length() > max_length_string_num )
		{
			max_length_string = tmp;
			max_length_string_num = tmp.length();
		}
	}

	map< string, int >::iterator it = input_word.begin();
	while ( it != input_word.end() )
	{
		tmp_num = (*it).second;
		if ( tmp_num > max_num )
		{
			max_num_string = (*it).first;
			max_num = tmp_num;
		}
		++it;
	}

	cout << max_num_string << " " << max_length_string << endl;

	return 0;
}

C++: #include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <utility>
#include <algorithm>

using namespace std;

int main()
{
	int longlen = 0;
	string str, longstr;
	vector<pair<int, string> > vc;

	while (cin >> str)
	{
		if((int)strlen(str.c_str()) > longlen){
			longlen = strlen(str.c_str());
			longstr = str;
		}
		
		bool bl = true;
		vector<pair<int, string> >::iterator it = vc.begin();
		while(it != vc.end())
		{
			if(it->second == str){
				it->first--;
				bl = false;
			}
			it++;
		}

		if(bl){
			vc.push_back(make_pair(0, str));
		}
	}
	
	sort(vc.begin(), vc.end());

	cout << vc[0].second << " " << longstr << endl;

	return 0;
}

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]++;
	break;
      }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]);
    }
  }
  /*for(int i=0;i<k;i++){
    cout << cpy[i] << " ";
    }*/

  cout << ans1 << " " << ans << endl;
}

C++: #include<bits/stdc++.h>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<algorithm>
#include<map>
using namespace std;

int main(){
    int mod=1000000007;
    int mc=0,ml=0;
    map<string, int> m;
    string s,a,b;
    while(cin>>s){
        m[s]++;
        if (mc<m[s]) {
            mc=m[s];
            a=s;
        }
        if (ml<s.length()){
            ml=s.length();
            b=s;
        }

    }
    cout<<a<<" "<<b<<"\n";
    return 0;
}

C++: #include <unordered_map>
#include <iostream>
#include <algorithm>

using namespace std;

int main(){
  unordered_map<string,int> us;
  string s;
  while(cin >> s){
    us[s]++;
  }
  string ans1;
  int times = 0;
  string ans2;
  int length = 0;
  for(auto i : us){
    if(i.second > times){
      ans1 = i.first;
      times = i.second;
    }
    if(i.first.length() > length){
      ans2 = i.first;
      length = i.first.length();
    }
  }
  cout << ans1 << ' ' << ans2 << '\n';
     
}