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<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1e8;
int main(){
	string s;
	map<string,int>m;
	int out=0;
	while(cin>>s){
		m[s]++;
		out=max(out,s.size());
	}
	int ma=0;
	string ans;
	for(auto it=m.begin();it!=m.end();it++){
		ma=max(ma,it->second);
		if(out==it->first.size());ans=it->first;
	}
	for(auto it=m.begin();it!=m.end();it++){
		if(it->second==ma)cout<<(it->first)<<" ";
	}
	cout<<ans<<endl;
}

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

using namespace std;

int main() {
  string s;
  unordered_map<string, int> cnt;
  vector<string> v;

  while (cin >> s) {
    cnt[s] += 1;
    v.push_back(s);
  }

  int max_freq = 0;
  int max_len = 0;

  for (auto p: cnt) {
    max_freq = max(max_freq, p.second);
    max_len = max(max_len, (int)p.first.size());
  }

  for (auto p: cnt) {
    if (p.second == max_freq) {
      cout << p.first << ' ';
    }
  }

  for (auto p: cnt) {
    if (p.first.size() == max_len) {
      cout << p.first << endl;
    }
  }
}

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

int main(){

  std::vector<string> word;
  std::vector<int> count;
  string now;
  int num=0,most=0;
  bool aaa;

  while(cin >> now){
    aaa = true;
    for(int i=0;i<num;i++)
      if(word[i] == now){
	count[i]++;
	aaa = false;
      }

    if(aaa){
      word.push_back(now);
      count.push_back(1);
      num = word.size();
    }
  }

  now = " ";

  for(int i=0,mmm=0,nnn=0;i<num;i++){
    if(mmm < count[i]){
      mmm = count[i];
      most = i;
    }
    if(now.size() < word[i].size()){
      now = word[i];
    }
  }

  cout << word[most] << ' ' << now << endl;

  return 0;
}

C++: #include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<complex>
#include<iomanip>
 
#define EPS (1e-10)
using namespace std;
#define PI (3.1415926535)

int main(){
	vector<string> word;
	vector<int> count;

	int imax = 0;
	string s;

	while(cin >> s){
		for(int i = 0; i < s.size(); i++){
			s[i] = tolower(s[i]);
		}
		bool b = true;
		int num;
		for(int i = 0; i < word.size(); i++){
			if(word[i] == s){
				b = false;
				num = i;
				break;
			}
		}
		if(b){
			word.push_back(s);
			count.push_back(0);
		}else{
			count[num]++;
			if(count[num] > count[imax]){
				imax = num;
			}
		}
	}

	int l = 0;
	for(int i = 0; i < word.size(); i++){
		if(word[l].size() < word[i].size()){
			l = i;
		}
	}

	cout << word[imax] << ' ' << word[l] << endl;

	return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <string>
#include <map>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)

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

C++: #include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;
#define tr(c, i) for(auto i = (c).begin(); i != (c).end(); i++)

int main(int argc, char **argv)
{
  map<string, int> words;
  string s;
  string maxword;

  maxword = "";
  for (;;) {
    cin >> s;
    if (cin.eof())
      break;

    if (s.length() > maxword.length())
      maxword = s;
    words[s]++;
  }

  int most = 0;
  string mostword = "";
  tr (words, i) {
    if (i->second > most) {
      most = i->second;
      mostword = i->first;
    }
  }
  cout << mostword << " " << maxword << endl;
  return 0;
}

C++: #include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef pair<string, int> PAIR;

int main(){
	vector<PAIR> vec;
	vector<PAIR>::iterator ite;
	string st;
	while(cin >> st){
		ite = vec.begin();
		if(vec.empty()){
			vec.push_back(PAIR(st, 1));
		}else{
			while(1){
				if((*ite).first == st){
					(*ite).second++;
					break;
				}
				ite++;
				if(ite == vec.end()){
					vec.push_back(PAIR(st, 1));
					break;
				}
			}
		}

		vector<PAIR>::iterator max = vec.begin();
		vector<PAIR>::iterator mim = vec.begin();
		for(ite = vec.begin(); ite != vec.end(); ite++){
			if((*max).second < (*ite).second) max = ite;
			if((*mim).second >= (*ite).second) mim = ite;
		}

		cout << (*max).first << " " << (*mim).first << endl;

	}
	return 0;
}

C++: #include<iostream>
#include<map>
using namespace std;
int main(){
  map<string,int> word;
  string s,as,bs;
  int an = 0;
  while(cin >>s){
    word[s]++;
    if(word[s]>an){
      an = word[s];
      as = s;
    }
    if(s.size()>bs.size()) bs = s;
  }
  cout <<as<<" "<<bs<<endl;
  return 0;
}

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

using namespace std;

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

int main(void){
	char temp[1002];
	
	while(fgets(temp,1001,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;
				}
				s[c] += temp[j];
			}
		}
		
		for(int i = 0; i < c; i++){
			for(int j = 0; j < c; j++){
				if(i == j)continue;
				if(s[i] == s[j])count[i]++;
			}
		}
		
		for(int i = 0 ; i < c; i++){
			if(s[i].size() > max_L)max_l = i;
			if(count[i] > max_H)max_h = i;
		}
		
		printf("%s %s\n", s[max_h].c_str(), s[max_l].c_str() );
	}
	return 0;
}

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

int main()
{
    map<string,int> m1;
    string str1, str2, str3;        //入力、頻度最大文字列、最長文字列

    int length = 0;
    while( cin >> str1 )
    {
        m1[str1]++;                 //出現頻度
        if( length < str1.size() )
        {
            length = str1.size();
            str3 = str1;
        }
    }

    int max = 0;
    for( map<string,int>::iterator itr = m1.begin(); itr != m1.end(); itr++ )
    {
        if( max < itr -> second )
        {
            max = itr -> second;
            str2 = itr -> first;
        }
    }

    cout << str2 << " " << str3 << endl;

    return 0;
}