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 <cmath>
#include <vector>
#include <cstdio>
#include <algorithm>
using namespace std;
int main ()
{
	vector< pair<string, int> > a;
	string z;
	cin>>z;
	a.push_back(pair<string,int>(z,1));
	while(cin>>z)
	{
		for(int i=0;i<a.size();i++)
		{
			if(a[i].first==z)
			{
				a[i].second++;
			}
			if(i==a.size()-1)
			{
				a.push_back(pair<string,int>(z,1));
				break;
			}
		}
	}
	int m=-1;
	int s=-1;
	for(int i=0;i<a.size();i++)
	{
		m=max(m,a[i].second);
		s=max(s,(int)a[i].first.length());
	}
	for(int i=0;i<a.size();i++)
	{
		if(a[i].second==m)
		{
			cout<<a[i].first<<" ";
		}
	}
	for(int i=0;i<a.size();i++)
	{
		if(a[i].first.size()==s)
		{
			cout<<a[i].first<<endl;;
		}
	}
	return 0;
}

C++: #include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <sstream>
#include <utility>
#include <cstdlib>
#include <cctype>
#include <climits>
#include <fstream>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<double> vd;
typedef vector<pair<int, int> > vpii;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define foreach(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); itr++)
#define dbg(x) cout << #x"="<< (x) << endl
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back(a) 
#define in(x) cin >> x;
#define all(x) (x).begin(), (x).end()
#define INF 2147483600
#define fi first
#define se second
using namespace std;

map <string,int> ans;
int l=0;
int k=0;

int main(){
    string str;
    string a,b;
    while(cin>>str){
        if(str.size()>=l){
            b = str;
            l=str.size();
        }
        ans[str]++;
        if(ans[str]>=k){
            k=ans[str];
            a=ans[str];
        }
    }
    cout<<a<<" "<<b<<endl;
}

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

int comp(pair<string,int>a,pair<string,int>b){
	return a.second < b.second;
}
int main() {
	map<string,int> strtable;
	map<string,int>::iterator mnum;
	string word;
	string maxlw;

	while(cin>>word){
		if(strtable.find(word) == strtable.end())strtable[word]=1;
		else strtable[word]++;
		if(word.length() > maxlw.length())maxlw = word;
	}
	
	mnum = max_element(strtable.begin(),strtable.end(), comp);
	
	cout<<mnum->first<<" "<<maxlw<<endl;
	
	return 0;
}

C++: #include<cstdio>
#include<cstring>
#include<iostream>
#include<queue>
#include<string>
using namespace std;
struct Eng {
  string str;
  int count;
};
int main(){
  Eng data[1001],temp;
  string str,box="\0";
  int f=0,num=0,flag;
  getline(cin , str);
  int str_size = str.size();
  for(int i=0;i<str_size;i++){
    if(str[i] == ' '){
      data[num].str = str.substr( f , i - f );
      for(int j=0;j<num;j++){
	if(data[num].str == data[j].str){
	  data[j].count++;	
	}
      }
      f = i + 1;
      num++;
    }
    else if(i == str_size-1){
      data[num].str = str.substr( f , i - f + 1  );
      for(int j=0;j<num;j++){
	if(data[num].str == data[j].str)data[j].count++;
      }
      num++;
    }
  }
  for(int i=0;i<num-1;i++){
    for(int j=num-1;j>i;j--){
      if(data[j].count>data[j-1].count){
	temp = data[j];
	data[j] = data[j-1];
	data[j-1] = temp;
      }
    }
  }
  for(int i=0;i<num;i++)
    if(box.size()<data[num-1].str.size())box = data[i].str; // 長さ確保
  cout << data[0].str << ' ' << box << endl;
}

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

C++: #include <iostream>
#include <map>
#include <stdio.h>

using namespace std;


map <string, int> cnt;

int main() {
	
	string firstWord;
	string secondWord;
	
	int maxCount = 0;
	int maxLength = 0;
	
	string s;
	while (cin >> s) {
		cnt[s] = cnt[s] + 1;
		if (cnt[s] > maxCount) {
			maxCount = cnt[s];
			firstWord = s;
		}
		
		if ((int) s.size() > maxLength) {
			maxLength = s.size();
			secondWord = s;
		}
	}
	
	cout << firstWord << ' ' << secondWord << "\n";
	
	return 0;
}

C++: #include <bits/stdc++.h>

using namespace std;

int main() {
  string s;
  int mx1 = 0, mx2 = 0;
  map<string, int> m;
  while (cin >> s) ++m[s];
  for (auto i : m) mx1 = max(mx1, i.second);
  for (auto i : m) mx2 = max(mx2, (int)i.first.size());
  for (auto i : m) {
    if (i.second == mx1) cout << i.first << " ";
  }
  for (auto i : m) {
    if ((int)i.first.size() == mx2) cout << i.first << endl;
  }
}

C++: #include <iostream>
#include <string>
#include <map>
using namespace std;
map<string, int> table;
int main() {
  string word, frequent, longest; // input, max frequency, and longest
  size_t N=0; // frequency of the string "frequent"
  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 <vector>
#include <string>
#include <map>
using namespace std;

int main(){
    string s;
    vector<string> v;
    while(cin>>s){
        v.push_back(s);
    }
    sort(v.begin(),v.end());
    int l=0;
    for(int i=0;i<(int)v.size();i++){
        if(v[i].size() > v[l].size())l=i;
    }
    int f=0,fmax=0;
    for(int i=0;i<(int)v.size();i++){
        int j=i;
        while(j<(int)v.size() && v[i]==v[j])j++;
        if(j-i > fmax){
            fmax = j;
            f = i;
        }
        i=j;
    }
    cout << v[f] << " " << v[l] << endl;
}

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

using namespace std;

const int M = 33;
const int N = 1001;

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

void solve(char text[]) {
	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);
			}
			cnt = 1;
			strcpy(tmp, word[i]);
		}
	}
	if (maxs < cnt) strcpy(ansm, tmp);
}

int main() {
	int i = 0;
	while (scanf("%s", word[i++]) != EOF);
	solve(i);
	cout<<ansm<<" "<<ansl<<endl;
	return 0;
}