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 <map>
#include <algorithm>
using namespace std;

int main() {
  string s;
  map<string, int> word;

  while(cin >> s) {
    if(word.find(s) == word.end()) {
      word.insert(make_pair(s, 1));
    } else {
      word[s]++;
    }
  }

  string longs, manys;
  int longn = 0, manyn = 0;

  map<string, int>::iterator it = word.begin();
  while(it != word.end()) {
    if(it->first.length() > longn) {
      longn = it->first.length();
      longs = it->first;
    }
    if(it->second > manyn) {
      manyn = it->second;
      manys = it->first;
    }
    it++;
  }
  cout << manys << ' ' << longs << endl;
}

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

main(){
    string str, maxs;
    int maxl = 0;
    map<string, int> M;
    while( cin >> str ){
	if ( maxl < str.size()){
	    maxl = str.size(); maxs = str;
	}
	M[str]++;
    }
    int m = 0;
    string fs;
    for ( map<string, int>::iterator it = M.begin(); it != M.end(); it++ ){
	if ( m < (*it).second ){
	    fs = (*it).first;
	    m = (*it).second;
	}
    }
    cout << fs << " " << maxs << endl;
}

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

#define ll (long lon
#define REP(i,n) for(int i = 0;i<(int)n;i++)
#define FOR(i,a,b) for(int i = (a);i < (b);i++)
#define RFOR(i,a,b) for(int i = (a);i>(b);i--)

using namespace std;

int main (void){
    
    char str[1000];
    gets(str);
    char tango[500][33];
    int i = 0,j = 0,k = 0,l = 0, temp = 0,m = 0;
    char max[33];
    int max_l = INT_MIN;
    int max_numer = 0;
    int yokuderu = 0;
    int yokuderu_temp = 0;
    int yokuderu_number = 0;
    while(str[i++] != '\0')
    {
        if(str[i-1] == ' ')
        {
            if((i-1)-temp>max_l)
            {
                max_l = (i-1) -temp;
                max_numer = j;
            }
            while(temp<i-1)
                tango[j][l++] = str[temp++];
            temp = i;
            j++;
            l = 0;
        }
    }
    
 
        if((i-1)-temp>max_l)
        {
            max_l = (i-1) -temp;
            max_numer = j;
        }
        while(temp<i-1)
            tango[j][l++] = str[temp++];
        temp = i;
        j++;
        l = 0;
    /*???????????§??????????????????*/
    //cout <<"number is " << j << endl;
    
    for(int m = 0; m < j;m++)
    {
        for(int k = 0; k<j;k++)
        {
            if(m != k)
            {
                if(strcmp(tango[m], tango[k]) == 0)
                {
                    yokuderu_temp++;
                }
            }
        }
        if(yokuderu_temp >= yokuderu)
        {
            yokuderu = yokuderu_temp;
            yokuderu_number = m;
        }
        yokuderu_temp = 0;
    }
    REP(i,32)
    cout << tango[yokuderu_number][i];
    cout << " ";
    while(tango[max_numer][m++] != '\0')
        cout << tango[max_numer][m-1];
    m = 0;
        cout << endl;
    
    
    return 0;
}

C++: #include<iostream>
#include<cstring>
using namespace std;
int const N = 1001;
int main(){
    char str[N][50];
    int num[N],i=0,max=0,l=0;
    while(cin >> str[i]){//????????????
        i++;
    }
    for(int j=0;j<i;j++){//????????????????????????????????§????????????????§£???????????????????????????
        num[j]=0;
    }
    for(int j=0;j<i;j++){
        for(int k=0;k<i;k++){
            if(strcmp(str[j],str[k])==0)
			num[j]++;
		}
        if(num[max] < num[j])
            max = j;
        if(strlen(str[l]) < strlen(str[j]))
            l=j;
    }
    cout << str[max] << " " << str[l] << endl;
}

C++: 
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <vector>
#include <map>
#include <utility>
#include <complex>
#include <stack>
#include <climits>
#include <set>

using namespace std;

double sq(double x){return x*x;}

int main(){
	string x;
	map<string,int> s;
	int max_len = 0;
	string m_str;
	while(cin>>x){
		s[x]++;
		if(max_len < x.length()){
			max_len = x.length();m_str = x;
		}
	}

	int m = 0;
	string r;
	for(map<string,int>::iterator it = s.begin(); it != s.end(); ++it){
		if(m < (*it).second)
			m = (*it).second,r = (*it).first;
	}

	cout << r << " " << m_str << endl;

	return 0;
}

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

using namespace std;

int main(void){
    char *l,*m,t[33];
    char s[500][33];
    int c[500]={0},n=0,cnt=0,max=0,lm=0;
    while(scanf("%s",s[n++])!=EOF)if(s[n-1][0]=='0')break;
    for(int i=n;i>0;i--){
        for(int j=0;j<i;j++){
            if(i!=j && strcmp(s[i],s[j])<0){
                strcpy(t,s[i]);
                strcpy(s[i],s[j]);
                strcpy(s[j],t);
            }
        }
    }
    for(int i=0;i<n;i++){
        int ln = strlen(s[i]);
        if(ln>lm){
            m=s[i];
            lm = ln;
        }
        if(i==0)continue;
        if(strcmp(s[i],s[i-1])==0){
            cnt++;
            if(cnt>max){
                max=cnt;
                l = s[i];
            }
        }else cnt = 0;
    }
    printf("%s %s\n",l,m);
    return 0;
}