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 <string>
#include <cstring>
#include <vector>
#include <set>
using namespace std;
#define rep2(x,from,to) for(int x=(from); x<(to); (x)++)
#define rep(x,to) rep2(x,0,to)
int main() {
	string s;
	vector<string> str1;
	set<string> str2;
	while(cin >> s && s != "0") {
		str1.push_back(s);
		str2.insert(s);
	}
	int w = 0;
	string ret;
	rep(i,str1.size()) {
		if(w < str1[i].length()) {
			w = str1[i].length();
			ret = str1[i];
		}
	}

	int cnt[1000];
	rep(i,1000) {
		cnt[i] = 0;
	}
	int c = 0;
	for(auto it=str2.begin(); it != str2.end(); ++it) {
		rep(j,str1.size()) {
			if(*it == str1[j]) cnt[c]++;
		}
		c++;
	}
	int max = 0, r = 0;
	string ret2;
	for(auto it=str2.begin(); it != str2.end(); ++it) {
		if(max < cnt[r]) {
			max = cnt[r];
			ret2 = *it;
		}
		r++;
	}
	cout << ret << " " << ret2 << endl;
	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();
		bool addsw = true;
		rep(i,sszz){
			if(wst == vvc[i].first){
				vvc[i].second++;
				addsw=false;
				break;
			}
		}
		if(addsw) vvc.push_back(mypair(wst,1));
	}
	int mx = -999, sszz = vvc.size();
//	rep(i,sszz) cout << i << ": " << vvc[i].first << "- " << vvc[i].second << endl;
	rep(i,sszz){
		if(mx < vvc[i].second){
			mx = vvc[i].second;
			mst = vvc[i].first;
		}
	}
	cout <<  mst << " " << qst << endl;
	return 0;
}

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

int main(void){


    string str,ans1,ans2;
    map<string,int> dict;
    int maxi = 0;
    while(cin >> str){
        if(maxi < str.size()){
            maxi = str.size();
            ans1 = str;
        }
        dict[str]++;
        int count = 0;
        map<string,int>::iterator itr;
        for(itr = dict.begin();itr != dict.end();itr++){
            if(count < (*itr).second){
                ans2 = (*itr).first;
                count = (*itr).second;
            }
        }
    }
    cout << ans2 << " " << ans1 << endl;
    return 0;
}

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]; 

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() {
	while (cin.getline(text, N, '\n')) {
		solve(text);
		cout<<ansm<<" "<<ansl<<endl;
	}
	return 0;
}

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

int main() {
	vector<string> words;
	string stock;

	while (cin >> stock) {
		words.push_back(stock);
	}

	vector<int> times(words.size(), 0);
	
	for (unsigned int i = 0;i < words.size();i++) {  //times??????????????°????¨????
		for (unsigned int j = i;j < words.size();j++) {
			if (words.at(i) == words.at(j)) times.at(i)++;
		}
	}

	int mode_times = 0;//?????§???????????°
	int mode_num;  //?????§??????????????????

	for (unsigned int i = 0;i < times.size();i++) {
		if (times.at(i) > mode_times) {
			mode_times = times.at(i);
			mode_num = i;
		}
	}//??????

	int max_length = 0;
	int max_num;

	for (unsigned int i = 0;i < words.size();i++) {
		if (words.at(i).length() > max_length) {
			max_length = words.at(i).length();
			max_num = i;
		}
	} //??????

	cout << words.at(mode_num) << " " << words.at(max_num) << endl;
	
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
int main(){
  map<string,int>a;
  string s,p,q;
  int k=0;
  while(cin>>s){
    a[s]++;
    if(p.size()<s.size())p=s;
    if(k<a[s]){
      k=a[s];
      q=s;
    }
  }
  cout<<q<<' '<<s<<endl;
}

C++: #include<iostream>
#include<string>
#include<map>
using namespace std;
int main()
{
	string s, mode, longest;
	typedef map<string, int> dic_t;
	dic_t dic;
	while (cin >> s) {
		if (++ dic[s] > dic[mode])
			mode = s;
		if (s.size() > longest.size())
			longest = s;
	}
	cout << mode << ' ' << longest << endl;
	return 0;
}