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<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<time.h>
#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()
const double PI=acos(-1);
const double EPS=1e-10;
const int inf=1e8;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
vector<vector<char> >tmp;
vector<vector<int> >scr;
int main(){
	string s;
	string nagai;
	int naga=-1;
	map<string,int>m;
	while(cin>>s){
		if(naga<s.size()){naga=s.size();nagai=s;}
		m[s]++;
	}
	int ma=-1;
	string mas;
	map<string,int>::iterator it=m.begin();
	for(;it<m.end();it++){
		string t=it->first;
		if(ma<m[t]){ma=m[t];mas=t;}
	}
	cout<<mas<<" "<<nagai<<endl;
}

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

int main(){
	char str[1000];
	char word[33][33]={0};
	int longest=0;
	int check[33]={0};
	char *tmp;
	int freq=0;
	int count=0;
	int i,j;
	size_t len , prev;
	fgets(str , sizeof(str) , stdin);
		tmp=str;
		for(i=0 ; str[i]!='\0' ;i++){
			if(str[i]==' '){
				str[i]='\0';
				strcpy((char*)&word[count] , (const char*)tmp);
				tmp=str+i+1;
				count++;
			}
		}
		strcpy((char*)&word[count],(const char*)tmp);
		count++;
	for(i=0 ; i<count ; i++){
		for(j=i ; j<count ; j++){
			if(strcmp((const char*)&word[i] , (const char*)&word[j])==0){
				check[i]++;
			}
		}
	}
	for(i=count; i>=0 ; i--){
		for(j=0 ; j<i-1 ; j++){
			if(check[j]>check[j+1]){
				check[j]^=check[j+1];
				check[j+1]^=check[j];
				check[j]^=check[j+1];
				freq=j;
			}
		}
	}
		prev=strlen(word[0]);
	for (i=0 ; i<count ; i++){
		len=strlen(word[i]);
		if(len > prev){
			prev = len;
			longest=i;
		}	
	}
	
	cout << (char*)&(word[freq]) << " "<< (char*)&(word[longest]) << endl;
	return 0;
}

C++: /*AOJ 0029*/

#include<iostream>
#include<vector>
#include<string>

using namespace std;

int main(){

	vector<string> data;

	char str[35];

	while(cin>>str){
		data.push_back(str);
	}

	int max=0;
	int max1 = 0;
	int maxNum = 0;
	int maxNum1 = 0;
	int sum=0;

	for(int i=0;i<data.size();i++){
		sum = 0;
		for(int j=i+1;j<data.size();j++){
			if(data.at(i) == data.at(j)){
				sum++;
			}
		}
		if(max<=sum){
			max = sum;
			maxNum = i;
		}
	}

	max1 = 0;
	maxNum1 = 0;

	for(int i=0;i<data.size();i++){
		if(max1 <= data.at(i).size()){
			max1 = data.at(i).size();
			maxNum1 = i;
		}
	}



	cout<<data.at(maxNum)<<" "<<data.at(maxNum1)<<endl;

	return 0;
}

C++: #include<iostream>
#include<string>
#include<map>
using namespace std;
int main(){
  map<string,int> t;
  string s, mxc, mxl;
  int freq = 1, len = 0;
  while(cin >> s){
    if(t.find(s) == t.end()){
      t[s] = 1;
    }
    else{
      t[s]++;
    }

    if(t[s] > freq){
      freq = t[s];
      mxc = s;
    }
    if(s.size() > len){
      len = s.size();
      mxl = s;
    }
  }
  cout << mxc << " " << mxl << endl;
}

C++: #include<stdio.h>
#include<string>
#include<iostream>
#include <ctype.h>


using namespace std;
struct ST{string str;int c;int z;};

int main(){

int i=0;
string str,sth,stl;
struct ST P[1001];
int max=0;
while(cin>>str){
//	for(int j=0;j<str.size();j++)
//	str[i] = tolower( str[i] );

P[i].str=str;P[i].c=0;P[i].z=(int)str.size();
i++;
}
for(int j=0;j<i;j++)
for(int k=i-1;k>j;k--)
	if(P[k-1].str>P[k].str)
//if(P[k-1].str>P[k].str)
//if(strcmp(P[k-1].str,P[k].str)>0)
{


struct ST TEM=P[k-1];P[k-1]=P[k];P[k]=TEM;
cout<<"*";
}

for(int j=1;j<i;j++)
{if(P[j-1].str==P[j].str)P[j].c++;

}
max=0;
for(int j=0;j<i;j++)
{if(max<P[j].c){max=P[j].c;sth=P[j].str;}}
max=0;
for(int j=0;j<i;j++)
	if(P[j].z>max){max=P[j].z;stl=P[j].str;}

cout<<sth<<" "<<stl<<endl;

for(int j=0;j<i;j++)
	cout<<P[j].str<<P[j].z<<endl;

return 0;
}

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

int main(){
  string str[1000];
  int appear[1000];
  int i, j, n=0;
  int maxlen, maxleni;
  int maxappear, maxappeari;

  while(cin>>string[n]){
    for(i=0; i<string[n].size(); i++) string[n][i]=tolower(string[n][i]);
    n++;
  }
  maxlen=0;
  for(i=0; i<n; i++){
    if(maxlen<string[i].size()){
      maxlen=string[i].size();
      maxleni=i;
    }
  }
  for(i=0; i<n; i++) appear[i]=0;
  for(i=0; i<n; i++){
    if(string[i].empty()) continue;
    for(j=i+1; j<n; j++)
      if(string[i]==string[j]){
        appear[i]++;
        string[j][0]='\0';
      }
  }
  maxappear=0;
  for(i=0; i<n; i++){
    if(maxappear<appear[i]){
      maxappear=appear[i];
      maxappeari=i;
    }
  }
  cout<<string[maxappeari]<<" "<<string[maxlen]<<endl;

  return 0;
}

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

using namespace std;

int main(){
	string in[10000];
	int max=0;
	string ml_str;
	int tmp;
	string ans;
	int i=0;
	for(i=0;cin>>in[i];i++){
		if(in[i].size()>max){
			max=in[i].size();
			ml_str=in[i];
		}
	}
	sort(in,in+i);
	tmp=1;
	max=0;
	for(int j=1;j<i;j++){
	cout<<in[j]<<" ";
		if(in[j]==in[j-1]){
			tmp++;
		}else{
			if(max<tmp){
				max=tmp;
				ans=in[j-1];
				tmp=1;
			}
		}
	}
	cout<<endl<<ans<<" "<<ml_str<<endl;
}

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

using namespace std;

int main(void){
  vector<string> s;
  vector<int> cnt;
  string ss,str;
  getline(cin,str);
  string longest="";
  string max;
  int maxv=-1;
  str+=" ";
  for(int i = 0; i < str.size() ; i ++  ){
    if(str[i] == ' '){
      bool used=true;
      
      for(int j = 0 ; j < s.size() ; j ++){
	//second time
	if(s[j] == ss){
	  cnt[j]++;
	  //cout<<ss<<cnt[j]<<maxv<<endl;
	   
	  if(maxv<cnt[j]){
	    longest=ss;
	    maxv=cnt[j];
	  }
	  
	  ss="";
	  used=false;
	}
      }
      if(used){
	//first time
	s.push_back(ss);
	cnt.push_back(1);
	//cout<<ss<<cnt[cnt.size()-1]<<endl;
	/*
	if(s.size() == 1){
	  longest=ss;
	  max=ss;
	  maxv=ss.size();
	}
	//*/
	if(ss.size()>max.size())max=ss;
	ss="";
      }
      
    }else{
      ss+=str[i];
    }
    // cout<<str[i]<<endl;
  }
  cout<<longest<<" ";
  cout<<max<<endl;
  /*
  for(int i = 0 ; i < s.size() ; i ++){
    cout<<s[i]<<endl;;
  }
  cout<<endl;
  //*/
}

C++: #include <iostream>
#include <cstdio>
#include <cstdlib>
#include <time.h>
#include <math.h>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <sstream>
#include <string>
#include <bitset>
using namespace std;
#define FOR(I,F,N) for(int I = F; I < (int)(N); I++)
#define rep(i, n) FOR(i, 0, n)
#define FIN(V) cout<<V<<endl
#define pb push_back
#define INF (1 << 30)
typedef pair<int, int> P;
typedef long long ll;
typedef priority_queue<int> pq;
int StrToInt(string);
string IntToStr(int);
int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, 1, -1};

int main(void){
	string s, l, m;
	map<string, int> map;
	int mxl = 0;
	int tmp = 0;
	while(cin >> s){
		map[s]++;
		if(map[s] > tmp){
			m = s;
			tmp = map[s];
		}
		int tmp_s = s.size();
		if(s.size() > mxl){
			mxl = max(mxl,tmp_s);
			l = s;
		}
	}
	cout << m << " " << l << endl;
	return 0;
}