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<vector>
#include<utility>
#include<string>
#include<algorithm>

using namespace std;

// 単語の区切りはistreamに任せる
// 単語はベクターに保持する。
// 出現頻度最多、最長文字数の単語はそれぞれ1つなので、
// すべての単語を入力後、それぞれに該当するものを探す。

int main() {
	// 単語の入力
	string input_str;
	vector<string> units;
	while (cin >> input_str) {
		units.push_back(move(input_str));
	}

	// 文字列は無駄にコピーさせないためポインタで記録しておく
	string* max_count_str = nullptr;
	auto max_count = 0;
	string* max_len_str = nullptr;
	auto max_len = 0;
	for (auto& a : units) {
		// 出現頻度が多いものを探す
		int temp_count = count(units.begin(), units.end(), a);
		if (max_count < temp_count) {
			max_count = temp_count;
			max_count_str = &a;
		}
		// 最も長い文字列を探す
		if (max_len < a.length()) {
			max_len = a.length();
			max_len_str = &a;
		}
	}

	cout << *max_count_str << ' ' << *max_len_str << endl;

	return 0;
}

C++: #include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>

using namespace std;

const int M = 33;
const int N = 333001;

char text[N];
char word[N][M];
char tmp[N], ansm[N], ansl[N]; 

int cmp(const void *a, const void *b) {
	return strcmp((char *)a, (char *)b);
}

void solve(char text[]) {
	int len = strlen(text);
	for (int i=0; i<len; ++i) {
		if (text[i] >= 'A' && text[i] <= 'Z') text[i] = text[i] - 'A' + 'a';
	}
	int j = 0, k = 0;
	for (int i=0; i<len; ++i) {//分解文章 
		if (text[i] != ' ') word[k][j++] = text[i];
		else {
			if (j == 0) continue;
			word[k++][j] = '\0', j = 0;
		}
	}
	if (j) word[k++][j] = '\0';
	qsort(word, k, sizeof(word[0]), cmp);
	int maxs = -1;
	int cnt = 1;
	strcpy(tmp, word[0]);
	strcpy(ansl, word[0]);
	int maxl = strlen(word[0]);
	for (int i=1; i<k; ++i) {
		if (maxl < strlen(word[i])) maxl = strlen(word[i]), strcpy(ansl, word[i]);
		if (!strcmp(tmp, word[i])) ++cnt;
		else {
			if (maxs < cnt) {
				maxs = cnt;
				strcpy(ansm, tmp);
			}
			strcpy(tmp, word[i]);
		}
	}
	if (maxs < cnt) strcpy(ansm, tmp);
}

int main() {
//	cin.getline(text, N, '\n');
	while (cin.getline(text, N, '\n')) {
		solve(text);
		cout<<ansm<<" "<<ansl<<endl;
	}
	return 0;
}

C++: #include<iostream>
#include <stdio.h>
#include<string>
using namespace std;
string s[1000], t,ma,hi; int i=0,j[1000],times=0;
int main() {
	while (cin>>s[i])
	{
		for (int q=0; q < i; q++) {
			if (s[i] == s[q]) { j[q]++; }if (j[q] > times) { hi = s[q]; times = j[q]; }
	}
		if (ma.size() < s[i].size())ma = s[i];
		i++;
	}
	cout << hi << " " << ma<<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[111][111];
  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]++;
      }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]);
    }
  }
  
  cout << ans1 << " " << ans << endl;
}

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

int main(){
  string s;
  map<string, int> mp;
  while (cin >> s) {
    mp[s]++;
  }
  string maxv = mp.rbegin()->first;

  int maxstr = 0;
  string ansstr;
  for (auto x : mp) {
    if (x.first.size() >= maxstr) {
      maxstr = x.first.size();
      ansstr = x.first;
    }

  }
  cout << maxv << " " << ansstr << endl;
  return 0;
}

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

int main() {
	string s;
	int maxlen = 0;
	string maxstr = "";
	vector<pair<int, string> > v(1000, pair<int, string>(0, "-"));

	while (cin >> s) {
		if (s.size() > maxlen) {
			maxlen = s.size();
			maxstr = s;
		}

		for (int i = 0; i < v.size(); i++) {
			string &s2 = v.at(i).second;
			int &cnt = v.at(i).first;

			if (s2 == "-") {
				s2 = s;
				cnt = 1;
				break;
			}
			else {
				if (s2 == s) {
					cnt++;
					break;
				}
			}
		}
	}
	/*
	for (int i = 0; i < 10; i++) {
		int x = v.at(i).first;
		string s0 = v.at(i).second;

		cout << x << ' ' << s0 << endl;
	}*/

	sort(v.begin(), v.end());
	reverse(v.begin(), v.end());

	cout << v.at(0).second << ' ' << maxstr << endl;
}

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
	string s;
	string ans = "";
	map <string ,int> mp;
	while(cin >> s){
		if(ans.size() < s.size())
			ans = s;
		mp[s]++;
	}
	int va = 0;
	string asdf;
	for(auto itr = mp.begin() ; itr != mp.end() ; itr++)
		if((*itr).second > va){
			asdf = (*itr).first;
			va = (*itr).second;
		}
	cout << asdf << " " << ans << endl;
}

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

int main()
{
	int max_s = 0;
	map<string, int> n;
	string s1, s2 = "", s3;
	while(cin >> s1){
		n[s1]++;
		if (s1.size() > s2.size())
		{
			s2 = s1;
		}
		if(max_s < n[s1]){
			s3 = s1;
			max_s = n[s1];
		}
	}
	cout << s3 << " " << s2 << endl;
}

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

map<string, int> m;

int main(){
	char buf[33];
	while (scanf("%s", buf, 33) != EOF) {
		if (m.find(buf) != m.end()) {
			m[buf] += 1;
		}
		else {
			m[buf] = 0;
		}
	}
	map<string, int>::iterator itr = m.begin();
	string sl, sc;
	int l, c;
	sl = sc = (*itr).first;
	c = (*itr).second;
	l = (*itr).first.size();
	while (++itr != m.end()) {
		if ((*itr).first.size() > l) {
			sl = (*itr).first;
			l = (*itr).first.size();
		}
		if ((*itr).second > c) {
			sc = (*itr).first;
			c = (*itr).second;
		}	
	}
	printf("%s %s\n", sc.c_str(), sl.c_str());

	return 0;
}

C++: #include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <string>
#include <stdio.h>
#include <math.h>
#include <map>

using namespace std;

vector<string> split(string source, string pattern) {
    unsigned i, base = 0;
    vector<string> ret;
    string buff;

    for(i = 0; i < source.size(); i++) {
        if(source.substr(i, pattern.size()) == pattern) {
            ret.push_back(buff);
            i += pattern.size() - 1;
            buff.clear();
        } else {
            buff += source[i];
        }
    }
    ret.push_back(buff);
    return ret;
}

int main(void) {
    string w, big_occ, big_size;
    int ml = 0, occ = 0;
    map<string, int> m;

    getline(cin, w);

    vector<string> sp = split(w, " ");

    for(int i = 0; i < (int) sp.size(); i++) {
        m[sp[i]] += 1;
    }

    for(map<string, int>::iterator it = m.begin(); it != m.end(); it++) {
        if(it->second > occ) {
            big_occ = it->first;
            occ = it->second;
        }
        if(it->first.size() >= ml) {
            big_size = it->first;
            ml = it->first.size();
        }
    }

    cout << big_occ << " " << big_size << endl;

    return 0;
}