Go: package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	words := strings.Split(scanner.Text(), " ")
	wordMap := make(map[string]int)
	for _, v := range words {
		wordMap[v]++
	}
	key := ""
	value := -1
	l := -1
	word := ""
	for k, v := range wordMap {
		// fmt.Println(k, v)
		if value < v {
			key = k
			value = v
		}
		if l < len(k) {
			l = len(k)
			word = k
		}
	}

	fmt.Println(key, word)
	// fmt.Println(wordMap)
}

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

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

struct Sentence {
  string s;
  int len = 0;
  int n = 0;
};

int main() {
  Sentence a[1000];
  string e;

  int j = 0;
  while (cin >> e) {
    for (int i = 0; i < 1000; i++) {
      if (e == a[i].s) {
        a[i].s = e;
        a[i].len = e.size();
        a[i].n++;
      } else if (i == 999) {
        a[j].s = e;
        a[j].len = e.size();
        a[j].n++;
      }
    }

    j++;
  }

  int maxi_n = 0, maxi_len = 0;
  for (int i = 0; i < 1000; i++) {
    if (a[i].n > maxi_n) maxi_n = i;
    if (a[i].len > maxi_len) maxi_len = i;
  }

  cout << a[maxi_n].s << " " << a[maxi_len].s << endl;
}

C++: #include<cstdio>
#include<cstring>
#include<string>

using namespace std;

string s[1001];
int count[1001];

int main(void){
	char temp[1024];
	
	while(fgets(temp,1024,stdin) != 0){
		int temp_n = strlen(temp);
		int c = 0;
		int max_h = 0;
		int max_H = 0;
		int max_l = 0;
		int max_L = 0;
		
		for(int i = 0; i < 1001; i++){
			s[i] = "";
			count[i] = 0;
		}
		
		for(int i = 0; i < temp_n; i++){
			for(int j = i; ; j++){
				if(temp[j] == ' '){
					i=j;
					c++;
					break;
				}else if(temp[j] == '\n'){
					i=j;
					c++;
					break;
				}else if(temp[j] == '\0'){
					i = j;
					break;
				}
				s[c] += temp[j];
			}
		}
		/*
		for(int i = 0; i < c; i++){
			printf("%d s == -%s-[%d]\n", i, s[i].c_str(), s[i].size());
		}
		*/
		for(int i = 0; i < c; i++){
			for(int j = 0; j < c; j++){
				if(s[i] == s[j])count[i]++;
			}
		}
		/*
		for(int i = 0; i < c; i++){
			printf("[[%d]]\n", count[i]);
		}
		*/
		for(int i = 0 ; i < c; i++){
			if(s[i].size() > s[max_l].size() )max_l = i;
			if(count[i] > count[max_h])max_h = i;
		}
		
		printf("%s %s\n", s[max_h].c_str(), s[max_l].c_str() );
	}
	return 0;
}

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

int main(){
  vector<string> S;
  vector<int> cnt;

  string s, ans1, ans2; int mode = 0, longest = 0;
  while(cin >> s){
    bool new_word = true;

    for(int i=0; i<S.size(); i++){
      if(S[i] == s){
        new_word = false;
        cnt[i]++; 
        break;
      }
    }

    if(new_word){
      S.push_back(s);
      cnt.push_back(1);
      if(s.length() > longest){
        longest = s.length();
        ans2 = s;
      }
    }
  }

  for(int i=0; i<cnt.size(); i++) mode = max(mode, cnt[i]);

  for(int i=0; i<cnt.size(); i++){
    if(mode == cnt[i]) ans1 = S[i];
  }

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

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

int main(){
	map<string, int> all;
	string buf;
	int maxlength = 0;
	string maxstring;
	while(cin>>buf){
		if(!all.count(buf)){
			all.insert( map<string, int>::value_type(buf, 1) );
			if(maxlength < buf.size()){
				maxlength = buf.size();
				maxstring = buf;
			}
		} else {
			all[buf]++;
		}
	}
	map<string, int>::iterator it = all.begin();
	int maxf = 0;
	string maxsf;
	while( it != all.end() )
	{
		if(maxf < (*it).second){
			maxf = (*it).second;
			maxsf = (*it).first;
		}
		++it;
	}
	cout<<maxsf<<" "<<maxstring<<endl;
	return 0;
}

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

int main(void) {
    string a;
    map<string, int> data;

    while (cin >> a)
        ++data[a];

    int max_count = 0;
    string max_str = "";
    int max_len = 0;
    string max_len_str = "";

    for (auto itr = data.begin(); itr != data.end(); ++itr) {
        const pair<string, int>& hoge = *itr;
        if (hoge.second > max_count) {
            max_count = hoge.second;
            max_str = hoge.first;
        }
        if (hoge.first.length() > max_len) {
            max_len = hoge.first.length();
            max_len_str = hoge.first;
        }
    }

    cout << max_str << " " << max_len_str << endl;

    return 0;
}