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<stdio.h>
#include<math.h>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
int main(){
	int i,i1,len,len1,check,max1,memo1,max2,memo2;
	max1 = 0;
	max2 = 0;
	memo1 = 0;
	memo2 = 0;
	string t;
	vector<string> s;
	vector<int> a,u;
	for (int h = 0; h < 500; h++) {
		u.push_back(0);
	}
	while (cin >> t) {
		check = 0;
		len = s.size();
		for (i = 0; i < len; i++) {
			if (t == s[i]) {
				u[i] += 1;
				check = 1;
			}
		}
		if (check == 0) {
			s.push_back(t);
			len1 = t.size();
			a.push_back(len1);
		}
	}
	len = s.size();
	for (i1 = 0; i1 < len; i1++) {
		while (max1 < u[i1]) {
			max1 = u[i1];
			memo1 = i1;
		}
	    while (max2 < a[i1]) {
			max2 = a[i1];
			memo2 = i1;
		}
	}
	cout << s[memo1] << " " << s[memo2] << endl;
	return 0;
}

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

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

C++: #include <iostream>
#include <string>
#include <map>
using namespace std;
int main(){
      string s,nmax,gmax;
      map<string,int> m;
      map<string,int>::iterator it;
      int nm=-1,gm=-1;
      while(cin>>s){
            if(nm<s.length()){
                  nm=s.length();
                  nmax=s;
            }
            if(m.count(s))m[s]++;
            else m[s]=0;
      }
      for(it = m.begin();it!=m.end();it++){
            if(gm<it->second){
                  gm = it->second;
                  gmax = it->first;
            }
      }
      cout <<gmax<<' '<<nmax<<endl;
}

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

using namespace std;

int main(){
  int max = 0, longest=0,i;
  map<string,int> word, cnt;
  string s, max_s, longest_s;
  while(cin>>s){
    word[s]++;
    if(word[s]>max){
      max = word[s];
      max_s = s;
    }
    i=0;
    while(s[i] != '\0' && s[i] != '\n'){
      i++;
    }
    cnt[s] = i;
    if(cnt[s]>longest){
      longest=cnt[s];
      longest_s=s;
    }
  }  
  cout<<max_s<<' '<<longest_s<<endl;
  return 0;
}

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

int main(void){
	string str;
	int mt=0,ml=0;
	string ms,mst;
	map<string,int> m;

	while(cin>>str){
		if(str.length()>ml){
			ml=str.length();
			ms=str;
		}
		m[str]++;
	}
	for(map<string,int>::iterator it=m.begin();it!=m.end();it++){
		if(it->second>mt){
			mt=it->second;
			mst=it->first;
		}
	}
	cout<<mst<<" "<<ms<<endl;

}

C++: #include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string.h>
#include <queue>
#include <string>
#include <stack>
#include <utility>
#include <queue>
#include <cmath>
#define mp make_pair
#define pii pair<int,int> 
#define ff first
#define ss second
#define ll long long 
#define vi vector<int>

using namespace std;

int counts[1000];
char str[1000][100];
int maxl,i,indexml,indexma;

int main()
{
	maxl=0;
	indexml=0;
	indexma=0;
	i=0;
	memset(counts, 0, sizeof(counts));
	while(scanf("%s",str[i])!=EOF)
	{
		//if(str[i][0]=='z')break;
		if(maxl<strlen(str[i]))
		{
			maxl=strlen(str[i]);
			indexml=i;
		}
		for(int z=0;z<i;z++)
		{
			if(strcmp(str[i],str[z])==0)
			{
				counts[z]++;
				i--;
				break;
			}
		}
		i++;
	}
	for(int c=0;c<i;c++)
	{
		if(counts[indexma]<counts[c])
		indexma=c;
	}
	printf("%s %s\n",str[indexma],str[indexml]);
	return 0;
}

C++: #include <bits/stdc++.h>
#define int long long
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define INF (((ll)1<<31)-1)
#define eps LDBL_EPSILON
#define moder (1000000007)
#define pie acos(-1)
#define P std::pair<int,int>
#define prique priority_queue
#define ggr getchar();getchar();return 0;
using namespace std;
string s;
map<string,int> mp;
signed main(){
	int maw=0;
	string mw;
	while(cin>>s){
		mp[s]++;
		if(s.size()>maw){
			mw=s;
			maw=s.size();
		}
	}
	int ofw=0;
	string ow;
	for(pair<string,int> p:mp){
		if(p.second>ofw){
			ofw=p.second;
			ow=p.first;
		}
	}
	cout<<ow<<" "<<mw<<endl;
	return 0;
}

C++: #ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

#include <array>

using namespace std;

int main ()
{
	string str,ans1="",ans2="";
	map<string , int>d;
	while( cin >> str )
	{
		d[str]++;
	}

	int p = 0;
	for( auto x : d )
	{
		if( p < x.second )
		{
			p = x.second;
			ans1 = x.first;
		}
		if( ans2.length () < x.first.length() )
		{
			ans2 = x.first;
		}
	}
	cout << ans1 << " " << ans2 << endl;
}