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

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

int main(void){

  int max_size=0,max_cnt=0;
  string word,result_cnt,result_size;
  map<string , int> word_cnt;

  while(cin >> word){
    if(word_cnt.find(word) != word_cnt.end()){
      int tmp = word_cnt.find(word)->second;
      tmp++;
      word_cnt.insert(make_pair(word,tmp));
    }else{
      int tmp = 1;
      word_cnt.insert(make_pair(word,tmp));
    }
  }

    for (map<string,int>::iterator ite=word_cnt.begin(); ite!=word_cnt.end(); ite++){
      if(max_cnt <  ite->second) result_cnt = ite->first;
      string w = ite->first;
      int w_size = w.size();
      if(max_size < w_size){
	max_size = w_size;
	result_size = ite->first;
      }
    }

    cout << result_cnt << ' ' << result_size << endl;



  return 0;
}

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

int main() {
	std::string word, longest, freqest;
	std::map<std::string, int> table;
	//入力
	while (std::cin >> word) ++table[word];
	//演算
	longest = table.begin()->first;
	freqest = table.begin()->first;
	for (std::map<string, int>::iterator it = table.begin(); it != table.end(); ++it) {
		if (longest.length < it->first.length) longest = it;
		if (table[freqest] < it->second) freqest = it;
	}
	//出力
	std::cout << freqest << " " << longest << std::endl;
	return 0;
}

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

using namespace std;
int main()
{
	map<string,int> table;
	string S;
	int mostAppear = 0;
	string mostAppearW;
	int maxSize = 0;
	string maxSizeW;
	while(cin >> S)
	{
		if (table.count(S))
		{
			table[S]++;
		}
		else
		{
			table[S] = 1;
		}

		if (table[S] > mostAppear)
		{
			mostAppear = table[S];
			mostAppearW = S;
		}		

		if (S.size() > maxSize)
		{
			maxSize = S.size();
			maxSizeW = S;
		}
	}

	cout << mostAppearW << " " << maxSizeW << endl;

	return 0;
}

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

int main(){
	string in[1000];
	int max=0;
	string ml_str;
	int tmp;
	string ans;
	int i=0;
	for(i=0;cin>>in[i];i++){
		if(in[i].size()>max){
			max=in[i].size();
			ml_str=in[i];
		}
	}
	sort(in,in+i);
	tmp=1;
	max=0;
	for(int j=1;j<i;j++){
		if(in[j]==in[j-1]){
			tmp++;
		}else{
			if(max<tmp){
				max=tmp;
				ans=in[j-1];
				tmp=1;
			}
		}
	}
	cout<<ans<<" "<<ml_str<<endl;
}

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

int main(){
	string in[1000];
	int max=0;
	int max_num;
	int tmp;
	string ans;
	int i=0;
	for(i=0;cin>>in[i];i++){
		if(in[i].size()>max){
			max=in[i].size();
			max_num=i;
		}
	}
	sort(in,in+i-1);
	tmp=1;
	max=0;
	for(int j=1;j<i;j++){
		if(in[j]==in[j-1]){
			tmp++;
		}else{
			if(max<tmp){
				max=tmp;
				ans=in[j-1];
				tmp=1;
			}
		}
	}
	cout<<ans<<" "<<in[max_num]<<endl;
}