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 <map>
#include <string>

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){
            N = table[word];
            frequent = word;
        }
        if(word.size()>longest.size()){
            longest = word;
        }
    }
    cout << frequent << " " << longest << endl;
}

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

using namespace std;

unordered_map<string, int> table;

int main() {
  string word, frequent, longest;
  size_t N = 0; // size_t represents size in bytes of word (length)
  while (cin >> word) {
    table[word] += 1;
    if (table[word] > N) {
      N = table[word];
      frequent = word;
    }
    if (word.size() > longest.size()) longest = word;
  }
  cout << frequent << " " << longest << endl;
}

C++: #include <iostream>
#include <cstring>
#include <cstdio> //fgets
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=0 ; i<count-1 ; i++){
		if(check[freq]<check[i+1]){
			freq=i+1;
		}
	}
		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++: #include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#define MAX 100000
typedef long long int ll;

using namespace std;

map < string , int > mp;

struct node{
    char st[50];
}a[1005];

int main()
{
    freopen("in.txt","r",stdin);
    char s[10000],str[50];
    while(gets(s)){
        strcat(s," ");
        mp.clear();
        int len=strlen(s);
        int j=0;
        int k=0;
        for(int i=0;i<len;i++){
            if(s[i]==' '){
                str[j]='\0';
                mp[str]++;
                strcpy(a[k++].st,str);
                j=0;
            }
            else{
                str[j++]=s[i];
            }
        }
        int index1,index2,x=0,z=0;
        for(int i=0;i<k;i++){
            int s=strlen(a[i].st);
            if(s>x)x=s,index1=i;
            if(mp[a[i].st]>z)z=mp[a[i].st],index2=i;
        }
        printf("%s %s\n",a[index2].st,a[index1].st);
    }
    return 0;
}

C++: #include<iostream>
#include<cstring>
using namespace std;
struct word{
	int len;
	int num;
	char w[32];
};
int main(){
	word vo[1000];
	char vol[32];
	int k = 0,max[2]={0,0};
	while(cin>>vol){
		int i;
		for(i=0; i<k; i++){
			if(strcmp(vo[i].w,vol) == 0){
				vo[i].num++;
				break;
			}
		}
		if(i == k){
			strcpy(vo[k].w,vol);
			vo[k].num = 1;
			vo[k].len = strlen(vo[k].w);
			k++;
		}
	}
	for(int i=1; i<k; i++){
		if(vo[max[0]].len<vo[i].len){max[0] = i;}
		if(vo[max[1]].num<vo[i].num){max[1] = i;}
	}
	cout <<vo[max[1]].w<<" "<<vo[max[0]].w<<endl;
	return 0;
}

C++: #include<iostream>
#include<string>
#include<map>
int main(){std::map<string,int>m;string s,t,u;for(;cin>>s;s.length()>u.length()?u=s:u)++m[s]>m[t]?t=s:s;std::cout<<t<<" "<<u<<"\n";}

C++: #include<bits/stdc++.h>
using namespace std;

int main(){
	int max = 0;
	string max_str;

	string str;
	vector<string> v;
	while(cin >> str){
		transform(str.begin(), str.end(), str.begin(), ::tolower);

		v.push_back(str);

		if(str.length() > max){
			max = str.length();
			max_str = str;
		}
	}
	sort(v.rbegin(), v.rend());
	cout << v[0] << " " << max_str << endl;
}

C++: #include <utility>
#include <iostream>
#include <unordered_map>



int main()
{
    using map_type = std::unordered_map< std::string, int > ;
    map_type map ;

    std::string longest_word ;

    std::string word ;
    while ( std::cin >> word )
    {
        ++map[word] ;
        if ( longest_word.size() < word.size() )
        {
            longest_word = word ;
        }
    }

    std::pair< map_type::key_type, map_type::mapped_type> most_frequent_word ;
    for ( auto && elem : map )
    {
        if ( most_frequent_word.second < elem.second )
        {
            most_frequent_word = elem ;
            
        }
    }

    std::cout << most_frequent_word.first << ' ' << longest_word << '\n' ;
    
}

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

int main() {
	map<string,int> strtable;
	map<string,int>::iterator mnum;
	string word;
	string maxlw;

	while(cin>>word){
		if(strtable.find(word) == strtable.end())strtable[word]=1;
		else strtable[word]++;
		if(word.length() > maxlw.length())maxlw = word;
	}
	
	mnum = max_element(strtable.begin(),strtable.end(),[](pair<string,int> a,pair<string,int> b){return a.second < b.second;} );
	
	cout<<mnum->first<<" "<<maxlw<<endl;
	
	return 0;
}

C++: import java.io.*;
public class aoj0029 {
   public static void main(String[] args) throws IOException{
	   BufferedReader buf = new BufferedReader(new InputStreamReader(System.in));
	   String s;
	   String tmp = "";
	   String sizetmp = "";
	   int cmax = -1;
	   int max = -1;
	   int cnt;
	   s = buf.readLine();
	   String[] data = s.split(" ");
	   for(int i=0;i<data.length;i++){
		   cnt = 1;
		   if(cmax < data[i].length()-1){
			   cmax = data[i].length()-1;
			   sizetmp = data[i];
		   }
		   for(int j=0;j<data.length;j++){
			   if(data[i].equals(data[j]) && i != j) cnt++;
		   }
		   if(max < cnt){
			   tmp = data[i];
			   max = cnt;
		   }
	   }
	   System.out.println(tmp + " " + sizetmp);
   }
}

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

int main(void){
  map<string,int> mp;
  int len = 0;
  string s,t;
  while(cin >> s){
    ++mp[s];
    if(len < (int)s.size()){
      len = s.size();
      t = s;
    }
  }
  string u;
  for(map<string,int>::iterator it = mp.begin() ; it != mp.end() ; ++it){
    u = it->first;
  }
  cout << u << " " << t << endl;
  return 0;
}

C++: //#define scanf_s scanf
//#define gets_s gets
#include <stdio.h>
#include <string>
#include <iostream>
#include <math.h>
using namespace std;
#define MAX 1001
#define MIN -100001
#define _MAX 100
int main(void)
{
	int x, max = 0, max_n = 0, cou = 0, word_num[MAX / 2] = { 0 }, m_i, m_j;
	string word[MAX / 2];
	char str[MAX];
	gets_s(str, MAX);
	for (int i = 0; str[i] != '\0'; ++i) {
		for (int j = 0; str[i] != ' '; ++j, ++i) {
			word[cou][j] = str[i];
		}
		++cou;
	}
	for (int i = 0; i < cou; ++i) {
		if (word[i].size > max) {
			max = word[i].size; m_i = i;
		}
		for (int j = 0; j < i; ++j) {
			if (word[i] == word[j]) {
				++word_num[j];
				if (word_num[j] > max_n) { max_n = word_num[j]; m_j = j; }
			}
		}
	}
	cout << word[m_i] << " " << word[m_j] << "\n";
}