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 <cstdio>
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <ctime>
#include <string>
#include <map>
using namespace std;

int main(void){
	map<string, int> table;
	string word, frequent, longest;
	int N = 0;
	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;
	
    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){
    int word_size = word.size();
    for(int i = 0;i < word_size; i++){
      word[i] = tolower(word[i]);
    }

    cout << word << endl;
    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){
	//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 <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>

#include <map>

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

int main() {
	while (cin.getline(text, N, '\n')) {
		solve(text);
		cout<<ansm<<" "<<ansl<<endl;
	}
//	int i = 0;
//	while (scanf("%s", word[i++]) != EOF);
//	solve(i);
//	cout<<ansm<<" "<<ansl<<endl;
	return 0;
}

C++: #include<iostream>
#include<string>
#include<map>
 
using namespace std;
 
int main( ){
    string l;
    int t=0;
    string max="???";
    map<string,int> str;
    string s;
    while(cin>>s){
      if(s.length()>max.length())max=s;
        str[s]++;
        if(str[s]>t){
           t=str[s];
           l=s;
            }
    }
    cout<<l<<" "<<max<<endl;
    return 0;
}

C++: #include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<queue>
#include<stack>
#include<complex>
#include<utility>
#include<cmath>
#include<map>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define pi acos(-1)
#define all(v) v.begin(),v.end()
using namespace std;

const double eps = 1e-8;
const double INF = 1e12;

typedef pair<int,int> P;
typedef double Real;
typedef complex<Real> Point;
typedef vector<Point> G;

double cross(const Point& a,const Point& b){//calculate ad-bc(vector product)
	return imag(conj(a)*b);
}

struct L:public vector<Point>{//line data
	L(const Point &a,const Point &b){
		push_back(a);
		push_back(b);
	}
};


int main(){
	string s;
	getline(cin,s);
	int count=0;
	map<string,int> mp;
	vector<string> vec;
	string lenmax="";
	rep(i,s.size()+1){
		if(i==s.size()){
			string sub=s.substr(count,i+1-count);
			count=i+1;
			vec.push_back(sub);
			mp[sub]=0;
			if(lenmax.size()<sub.size()){
				lenmax=sub;
			}
		}else if(s[i]==' '){
			string sub=s.substr(count,i-count);
			count=i+1;
			vec.push_back(sub);
			mp[sub]=0;
			if(lenmax.size()<sub.size()){
				lenmax=sub;
			}
		}
	}
	rep(i,vec.size()){
		mp[vec[i]]++;
	}
	string fremax="";
	rep(i,vec.size()){
		if(mp[vec[i]]>mp[fremax]){
			fremax=vec[i];
		}
	}
	cout<<fremax<<" "<<lenmax<<endl;
	return 0;
}

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

using namespace std;

map<string, int> cnt;
string ans[2];
int num_max;
int main() {
    string str;
    while (cin >> str) {
        cnt[str]++;
    }

    for (auto e : cnt) {
        if (num_max < e.second) {
            ans[0] = e.first;
            num_max = e.second;
        }
        if (ans[1].size() < e.first.size()) {
            ans[1] = e.first;
        }
    }
    cout << ans[0] << " " << ans[1] << endl;
}

C++: #include <iostream>
#include <string>
#include <map>
using namespace std;
int main(){
      string s,nmax,gmax;
      map<string,int> m;
      map<string,int>::iterator it;
      int nm=-1,gm=-1;
      while(cin>>s){
            if(nm<(int)s.length()){
                  nm = (int)s.length();
                  nmax = s;
            }
            if(m.count(s))m[s]++;
            else m[s]=0;
      }
      for(it = m.begin();it!=m.end();it++){
            if(gm<it->second){
                  gm = it->second;
                  gmax = it->first;
            }
      }
      cout <<gmax<<' '<<nmax<<endl;
}

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

using namespace std;

int main() {

  string buf;
  
  string str;

  map<string,int> word;
  string max_frequent_str;
  string max_letters_str;
  int max_frequent;
  int max_letters;

  
  max_letters=0;

  while(cin >> str) {
    
    if(str.length()>max_letters) max_letters=str.length();

    word[str]++;

  }
  
  max_frequent=0;

  for(map<string,int>::iterator it=word.begin();it!=word.end();it++) {

    if(max_frequent<(*it).second) {

      max_frequent=(*it).second;
      max_frequent_str=(*it).first;

    }

    if((*it).first.length()==max_letters) max_letters_str=(*it).first;

  }

  cout << max_frequent_str << " " << max_letters_str << endl;

  return 0;

}