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 <map>

using namespace std;

/** Application main entry point. */
int main (
  int     argc,
  char  * argv[ ]
  )
{
  map < string, int >
    wordTable;
  string  longest = "";
  string  popular = "";
  int     freqctr = 0;

  while ( true )
  {
    string __tmp;

    if ( !( cin >> __tmp ) ) break;

    if ( wordTable.count ( __tmp ) )
    {
      wordTable[ __tmp ] = wordTable[ __tmp ] + 1;
      if ( wordTable[ __tmp ] > freqctr )
      {
        freqctr = wordTable[ __tmp ];
        popular = __tmp;
      }
    }
    else
    {
      wordTable[ __tmp ] = 1;
    }

    if ( __tmp.length ( ) > longest.length ( ) )
    {
      longest = __tmp;
    }
  }

  cout << popular << " " << longest << endl;

  return ( 0 );
}

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

bool great(const pair<string, int>& left, const pair<string, int>& right){
	return left.second > right.second;
}

int main(){
	string max = "";
	string s;
	map<string, int> m;
	vector<pair<string, int> >v;
	while (cin >> s){
		if (max.size() < s.size()) max = s;
		if (m.find(s) == m.end()) m[s] = 1;
		else m[s]++;
	}
	map<string, int>::iterator it = m.begin();
	while (it != m.end()){
		v.push_back(make_pair((*it).first, (*it).second));
		it++;
	}
	sort(v.begin(),v.end(),great);
	cout << v[0].first << " " << max << endl;
}

C++: //
//  main.cpp
//  kazane
//
//  Created by h3036136 on 2017/07/27.
//  Copyright ?? 2017??´ h3036136. All rights reserved.
#include <iostream>
#include <string>
using namespace std;
int main(){
    long saidai=0;
    //char f;
    int a=0,cnt=0,num=0,max=0;
    string str,tango[1000]={""},answer,ans;
    getline(cin,str);
    for(int i=0;i<str.size();i++){
        if(str[i]==' '){
            for(int j=a;j<i;j++){
                /*if(isupper(str[j])){
                    f=str[j];
                    f=f+32;
                    str[j]=f;
                }*/
                tango[cnt]+=str[j];
            }
            cnt=cnt+1;
            a=i+1;
        }
    }
    for(int p=a;p<str.size();p++){
        tango[cnt]+=str[p];
    }
    
    
    
    for(int k=0;k<=cnt;k++){
        if(saidai<tango[k].size()){
            saidai=tango[k].size();
            ans=tango[k];
        }
    }
    
    for(int s=0;s<=cnt;s++){
        for(int t=s+1;t<=cnt;t++){
            if(tango[s]==tango[t]){
                num=num+1;
            }
        }
        if(max<num){
            max=num;
            answer=tango[s];
        }
    }
    cout<<answer<<" "<<ans<<endl;
    return 0;
}

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

using namespace std;

int main()
{
    string s;
    unordered_map<string, int> m;
    string longest;
    while (cin >> s) {
        m[s] += 1;
        if (s.size() > longest.size()) {
            longest = s;
        }
    }
    cout << max_element(begin(m), end(m),
                        [](const decltype(m)::value_type& a,
                           const decltype(m)::value_type& b) {
                            return a.second < b.second;
                        })
                ->first
         << ' ' << longest << endl;
}

C++: #include <iostream>
#include <string>
#include <math.h>
#include <stdio.h>
#include <ctype.h>

using namespace std;

int main() {
    string E[1000];

    int n=0;
    while(cin>>E[n]){
        n++;
    }
//    for(int i=0; i<n; i++){
//        cout<<E[i]<<" ";
//    }
    
    int B[1000]={0};
    for(int i=0; i<n; i++){
        for(int j=i; j<n; j++){
            if(E[i]==E[j]){
                B[i]++;
            }
        }
    }
    
    int max=0;
    int max_num=0;
    for(int i=0; i<n; i++){
        if(B[i]>max){
            max=B[i];
            max_num=i;
        }
    }
    cout<<E[max_num]<<" ";
    
    max=0;
    max_num=0;
    for(int i=0; i<n; i++){
        if((int)E[i].length()>max){
            max=(int)E[i].length();
            max_num=i;
        }
    }
    cout<<E[max_num]<<endl;
    return 0;
}

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

int main()
{
	int mc=0;
	string str,mlstr="";
	map<string,int> m;
	while(cin >> str)
	{
		if(!(m.insert(pair<string,int>(str,1)).second))
		{
			m[str]++;
		}
		mc = (m[str]>mc ? m[str] : mc);
		mlstr = (str.length()>mlstr.length() ? str : mlstr); 
	}
	
	map<string,int>::iterator it;
	for(it=m.begin(); it!=m.end(); it++)
	{
		if(mc==it->second)
		{
			cout << it->first;
		}
	}
	cout << " " << mlstr << endl;
}

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

int main(void)
{
	string str, lon = "", most = "";
	map <string, int> count;
	while (cin >> str)
	{
		if (str.size() > lon.size()) lon = str;
		count[str]++;
		if (count[most] < count[str]) most = str;
	}
	cout << most << " " << lon << endl;
	return 0;
}

C++: #include <cstdio>
#include <string>
#include <map>
using namespace std;
typedef map<string, int> MyMap;

MyMap hash;

void print_map(char* msg, int begin, int end) {
	char t_msg[1001] = {'\0'};
	string t_str;
	int cnt = 0;
	
	for (int i = begin; i < end; i++) {
		t_msg[cnt] = msg[i];
		cnt++;
	}
	t_msg[end] = '\0';
	
	t_str = string(t_msg);
	// Key isnt exist.
	if ((int)hash.count(t_str) == 0) {
		hash.insert(MyMap::value_type(t_str, 1));
	}
	// Key is exist. (return number is 1.)
	else {
		hash[t_str]++;
	}
}

int main(int argc, char *argv[]) {
	char msg[1001];
	fgets(msg, 1001, stdin);
	// Load
	int cnt = 0;
	for (int i = 0; i < 1001; i++) {
		if (msg[i] == '\n') {
			print_map(msg, cnt, i);
			break;
		}
		if (msg[i] == ' ') {
			print_map(msg, cnt, i);
			cnt = i+1;
		}
	}
	// Map print
	MyMap::iterator itr = hash.begin();
	MyMap::iterator max_sz_itr;
	MyMap::iterator max_fq_itr;
	int max_str_size = 0;
	int max_freq = 0;
	while (itr != hash.end()) {
		// max size
		if ((*itr).second > max_str_size) {
			max_str_size = (*itr).second;
			max_sz_itr = itr;
		}
		// max freq
		int t_freq = static_cast<int>((*itr).first.size());
		if (t_freq > max_freq) {
			max_freq = t_freq;
			max_fq_itr = itr;
		}
		itr++;
	}
	// print
	printf("%s %s\n",
	(*max_sz_itr).first.c_str(), (*max_fq_itr).first.c_str());
	return 0;
}

C++: #include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<cstring>
using namespace std;
int main(){
	char ans[50][1100] = {{0}};
	char a[1100] = {0};
	scanf("%[^\n]",a);
	int cnt = 0;
	int mx_len = 0;
	char date[1100] = {0};
	int j = 0;
	int len = 0;
	for(int i = 0; a[i] != 0; i++) len++;
	a[len] = ' ';
	for(int i = 0; i <= len; i++){
        if(a[i] != ' '){
            ans[cnt][j] = a[i];
            j++;
        }
        else{
            cnt++;
            j = 0;
        }
	}
	for(int i = 0; i < cnt; i++) cout << ans[i] << endl;
	return 0;
}