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<cstdio>
#include<queue>
#include<cmath>
#include<string>
#include<cstring>
#include<cctype>
using namespace std;

int main(){
	string ss;
	getline(cin,ss);
	int num=0;
	queue<string> spot;
	string str="";
	for(int i=0;i<=ss.size();i++){
		if(!isalpha(ss[i]) || ss[i]=='\0'){
			if(i>0){
				spot.push(str);
				str="";
			}
		}else{
			str+=ss[i];
		}
	}
	int often[spot.size()];
	int ll=spot.size();
	string ansoften="",anslen="";
	int flg=0;
	for(int a=0;a<ll-1;a++){
		string now=spot.front();
		spot.pop();
		for(int j=0;j<ll-1;j++){
			string rig=spot.front();
			spot.pop();
			if(now==rig)often[a]++;
			if(flg==0 && rig.size()>anslen.size())anslen=rig;
			spot.push(rig);
		}
		flg++;
		spot.push(now);
	}
	int aa=0;
	often[ll-1]=1;
	for(int b=0;b<ll;b++){
		if(aa<often[b])ansoften=spot.front();
		spot.pop();
	}
	cout<<ansoften<<" "<<anslen<<endl;
	return 0;
}

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

using namespace std;

int main (void) {
    vector<string> words;
    vector<int> count;
    int N = 0;
    while (1) {
        string w;
        cin >> w;
        if (cin.eof()) break;
        int index = 0;
        while (index < N && words[index] != w) index++;
        if (index == N) {
            words.push_back(w);
            count.push_back(1);
            N++;
        } else {
            count[index]++;
        }
    }
    string frequent;
    string longest;
    int freq = 0, size = 0, s;
    for (int i = 0; i < N; i++) {
        if (count[i] > freq) {
            freq = count[i];
            frequent = words[i];
        }
        s = words[i].size();
        if (s > size) {
            size = s;
            longest = words[i];
        }
    }
    cout << frequent << ' ' << longest << endl;
    return 0;
}

C++: #include <iostream>
#include <functional>
#include <sstream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <utility>

using namespace std;
typedef pair<int,string> strpair;

int main(){
  vector<strpair> data;
  string str;
  getline(cin,str);
  istringstream iss(str);
  string word;
  while(iss>>word){
    auto it= find_if(data.begin(),data.end(),[word](pair<int,string> p){return p.second==word;});
    if(it==data.end()){
      data.push_back(pair<int,string>(1,word));
    }else{
      (*it).first++;
    }
  }

  sort(data.begin(),data.end(),greater<pair<int,string> >());
  int maxlength=0;
  string maxlengthword;
  for(auto word:data){
    int length=word.second.length();
    if(length>maxlength){
      maxlength=length;
      maxlengthword=word.second;
    }
  }
  cout<<data[0].second<<" "<<maxlengthword<<endl;

}

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)frequest = word;
		if (word.size() > longest.size())longest = word;
	}
	cout >> frequent >> longest >> endl;
}

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

int main() {
	string in;
	vector <string>s;
	vector <int>a;
	int maxH = 0, maxL = 0;
	while (cin >> in) {
		s.push_back(in);
		a.push_back(0);
	}
	for (int i = 0; i < s.size(); i++) {
		if (a[i] == 0) {
			for (int j = i + 1; j < s.size(); j++) {
				if (s[i] == s[j])
					a[j] = ++a[i];
			}
			if (maxH < a[i])
				maxH = a[i];
		}
		if (maxL < s[i].length())
			maxL = s[i].length();
	}
	for (int i = 0; i < s.size(); i++) {
		if (maxH == a[i]) {
			cout << s[i] << " ";
			break;
		}
	}
	for (int i = 0; i < s.size(); i++) {
		if (maxL == s[i].length())
			cout << s[i]<<endl;
	}
	return 0;
}

C++: #include <algorithm>
#include <cctype>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <functional>
#include <queue>
#include <string>
#include <map>
#include <vector>

using namespace std;

int main() {
  string s, f, l("");
  map<string, int> ws;
  getline(cin, s);
  s.push_back(' ');
  int b = -1;
  for (int i = 0; i < s.length(); i++) {
    if (b == -1 && s[i] != ' ')
      b = i;
    if (b >= 0 && s[i] == ' ') {
      ws[s.substr(b, i-b)]++;
      b = -1;
    }
  }
  int maxc = 0;
  for (map<string, int>::iterator it = ws.begin(); it != ws.end(); ++it) {
    if (it->first.length() > l.length())
      l = it->first;
    if (it->second > maxc) {
      f = it->first;
      maxc = it->second;
    }
  }
  cout << f << ' ' << l << endl;
  return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
	string str[1001],mx("a");
	int i=0,cnt[1001]={0},ms;
	while(cin >> str[i]){
		if(mx.size()<str[i].size())mx=str[i];	
	
		for(int j=0;j<i;j++){
			if(str[i]==str[j]){
				cnt[j]++;
			}
		}
		i++;
	}
	for(int j=0;j<i;j++){
		for(int k=0;k<i;k++){
			if(cnt[j]<cnt[k])ms=k;
		}
	}
	cout << str[ms] << " " <<mx << endl;
return 0;
}

C++: #include<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<numeric>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<functional>

#define MP make_pair
#define PB push_back
#define ALL(x) (x).begin(),(x).end()
#define REP(i,n) for(int i=0;i<(n);i++)
#define REP1(i,n) for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n) for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;

const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;

const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};

int main(){
	int cnt=0,tmp=0,anss1=0,anss2=0;
	string str,ans1,ans2,a;
	getline(cin,str);
	for(int i=0;i<str.size()+1;i++){
		if(str[i]==' ' || i==str.size()){
			a=str.substr(tmp,i-tmp);
			tmp=i+1;
			for(int j=0;j<str.size();j++){
				if(str.find(a,j)){
					cnt++;
				}
			}
			if(anss1<cnt){
				anss1=cnt;
				ans1=a;
			}
			if(anss2<a.length()){
				anss2=a.length();
				ans2=a;
			}
			a.clear();
		}
		cnt=0;
	}
	cout << ans1 << " " << ans2 << 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=0,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;
	for(p = word.begin() ; p != word.end() ; p++){
		if( max < p->second) max = p->second;
	}
	for(p = word.begin() ; p != word.end() ; p++){
		if( max == p->second){
			cout << p->first << " ";
			break;
		}
	}
	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;
}