Go: package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
)

var scanner = bufio.NewScanner(os.Stdin)

func nextString() string {
	scanner.Scan()
	return scanner.Text()
}

type Pair struct {
	key   string
	value int
}

func main() {
	scanner.Split(bufio.ScanWords)
	counts := map[string]int{}
	maxLen := 0
	maxLenWord := ""
	for {
		word := nextString()
		if word == "" {
			break
		}

		counts[word]++

		if len(word) > maxLen {
			maxLen = len(word)
			maxLenWord = word
		}
	}

	mapPairs := []Pair{}
	for k, v := range counts {
		mapPairs = append(mapPairs, Pair{k, v})
	}
	sort.Slice(mapPairs, func(i, j int) bool { return mapPairs[i].value > mapPairs[j].value })

	fmt.Println(mapPairs[0].key, maxLenWord)
}

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

int main() {
  int k=0,times[1000] = {0},top,topsoeji,hantei,sizetop,sizetopsoeji,size[1000] = {0};
  char word[1000][32];
  string str;
  while (cin >> str) {
    //cout << str.size();
    for(int i=0;i<str.size();i++) {
      //      word[k][i] = str.substr(i,1);
      word[k][i] = str[i];
      size[k] = str.size();
      if(size[k] > sizetop) {
        sizetop = size[k];
        sizetopsoeji = k;
      }
    }
    //cout << word[k] << endl;
    k++;
  }


  for(int i=0;i<k;i++) {
    for(int j=i+1;j<k;j++) {
      if(strcmp(word[i],word[j]) == 0)
        hantei = 1;
      else
        hantei = 0;
      if(hantei) {
        times[i]++;
        times[j]++;
      }
    }
  }
  //  for(int i=0;i<k;i++)
    //  cout << times[i] << endl;

  top = times[0];
  topsoeji = 0;
  for(int i=0;i<k;i++) {
    if(times[i] > top) {
      top = times[i];
      topsoeji = i;
    }
  }
  cout << word[topsoeji] << " " << word[sizetopsoeji] << endl;

}

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);
			}
			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;
	}
	cout<<ansm<<" "<<ansl<<endl;
/*	map<string,int> data;
	string ans1,ans2,str;
	while(cin >> str){
		data[str]++;
		if(data[ans1] < data[str]) ans1 = str;
		if(ans2.size() < str.size() ) ans2 = str;
	}
	cout << ans1 << " " << ans2 << endl;*/
	return 0;
}






/*
#include <map>
using namespace std;

int main(){
	map<string,int> data;
	string ans1,ans2,str;
	while(cin >> str){
		data[str]++;
		if(data[ans1] < data[str]) ans1 = str;
		if(ans2.size() < str.size() ) ans2 = str;
	}
	cout << ans1 << " " << ans2 << endl;
}
*/

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

int main() {
	//??£?¨?
	int most_views = 0,views=0,most_long=0,len=0;
	char tmp_sentence[1000];
	string sentence,mo_ma_word,longest_word,word="";
	vector<string> words;

	cin.getline(tmp_sentence, sizeof(tmp_sentence));
	sentence = tmp_sentence;
	for (int i = 0; i < sentence.size(); i++) {
		if (sentence[i] == ' ') { words.push_back(word); word = ""; }
		else word = word + sentence[i];
	}
	words.push_back(word);
	for (int i = 0; i < words.size(); i++) {
		for (int j = 0; j < words.size(); j++) {
			if (words[i] == words[j])views++;
		}
		if (most_views < views) {
			most_views = views;
			mo_ma_word = words[i];
		}
		views = 0;
	}
	for (int i = 0; i < words.size(); i++) {
		if (most_long < words[i].size()) {
			most_long = words[i].size();
			longest_word = words[i];
		}
	}
	cout << mo_ma_word <<' '<<longest_word;
}

C++: #include<iostream>
#include<string>
#include<map>
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;
    return 0;
}

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

int main(){
	map<string, int> word;
	vector<string> w;
	string str;
	int max,length=0;

	while(cin >> str){
			
		w.push_back(str);
		
		//üÍµ½Pêª·ÅÉ é©T·
		if(word.find(str) != word.end() ){
			word[str]++;
		}else{
			word.insert( pair<string, int>(str,1));
		}
	}
	
	map<string,int>::iterator p = word.end();
	p--;
	cout << p->first << " ";
	for(int i=0 ; i<w.size() ; i++){
		if( length < w[i].size() ) length = w[i].size();
	}
	for(int i=0 ; i<w.size() ; i++){
		if( length==w[i].size() ){
			cout << w[i] << endl;
			break;
		}
	}
	
	return 0;
}

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

#define rep(x,to) for(int x=0;x<to;x++)
#define rep2(x,from,to) for(x=from;x<to;x++)

using namespace std;

typedef pair<string,int> mypair;

int main(void){
vector< mypair> vvc(1,mypair("",0));
string wst, qst="", mst;

	while(cin >> wst){
		if(wst.size() > qst.size()) qst = wst;
		int sszz=vvc.size();
		rep(i,sszz){
			if(wst == vvc[i].first){
				vvc[i].second++;
				break;
			}
			else vvc.push_back(mypair(wst,1));
		}
	}
	int mx = -999, sszz = vvc.size();
	rep(i,sszz){
		if(mx < vvc[i].second){
			mx = vvc[i].second;
			mst = vvc[i].first;
		}
	}
	cout <<  mst << " " << qst << endl;
	return 0;
}

C++: #include<cstdio>
#include<iostream>
#include<cstdlib>
#include<algorithm>
#include<string>
using namespace std;
string str[1001],s,anss,lon;
int ans,num[1001],ma,i,a;
int main(){
    while(cin>>s){
        if(ma<s.size()){
            lon=s;
        }
        str[i]=s;
        i++;
    }
    for(int j=0;j<i;j++){
        if(num[j]!=0)continue;
        a=0;
        for(int k=j+1;k<i;k++){
            if(str[j]==str[k]){
                a++;
                num[k]=1;
            }
            if(ans<a){
                ans=a;
                anss=str[k];
            }
        }
    }
    cout<<anss<<" "<<lon<<endl;
    return 0;
}

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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);

	string str;
	getline(cin, str);

	vector<P> vec;
	int m = 0;
	string longest;
	for(size_t i = 0; i < str.size(); ++i){
		if(i == 0 || str[i - 1] == ' '){
			int end = 0;
			for(size_t j = 0; i + j < str.size(); ++j){
				if(i + j == str.size() - 1 || str[i + j + 1] == ' '){
					end = j + 1;
					break;
				}
			}

			string s = str.substr(i, end);

			if(end > m){
				m = end;
				longest = s;
			}

			bool check = true;
			for(size_t i = 0; i < vec.size(); ++i){
				if(vec[i].first == s){
					vec[i].second ++;
					check = false;
					break;
				}
			}

			if(check){
				vec.push_back(P(s, 1));
			}
		}
	}

	int m2 = 0;
	string most;
	for(size_t i = 0; i < vec.size(); ++i){
		//cout << vec[i].first << endl;
		if(vec[i].second > m2){
			m2 = vec[i].second;
			most = vec[i].first;
		}
	}

	cout << most << " " << longest << endl;

	return 0;
}