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 <bits/stdc++.h>
#include <iostream>
#include <utility>
#include <string>
#define MAX_N 1001
#define rep(i, n) for(int i=0; i<n; i++)
using namespace std;
typedef pair<string, int> P;
P p[MAX_N];
int n;

int main(){
    string s;
    n = 0;
    while(cin >> s){
        bool flag = false;
        rep(i, n){
            if(p[i].first == s){
                p[i].second++;
                flag = true;
            }
        }
        if(!flag){ 
            p[n].first = s;
            p[n].second++;
            n++;
        }
    }
    // rep(i, n) cout << p[i].first << " " << p[i].second << endl;
    sort(p, p+n, [](const P &left, const P &right){
        return left.second > right.second;
    });
    cout << p[0].first << " ";
    sort(p, p+n, [](const P &left, const P &right){
        return left.first.size() > right.first.size();
    });
    cout << p[0].first << endl;
    return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
int main(void){
   std::deque<string> deq;
   string s,tmps,tmpss;
   int count,max,length;
   count = 0;
   max = 0;
   length = 0;
   while (cin >> s) {
       deq.emplace_back(s);
   }
   for (int i=0;i<deq.size();i++) {
       for (int j=0;j<deq.size();j++) {
           if (deq[i]==deq[j]) {
               count++;
           }
           if (count>max) {
               max = count;
               tmps = deq[i];
           }
           if (deq[i].size()>length) {
               length = deq[i].size();
               tmpss = deq[i];
           }
       }
       count = 0;
   }
   cout << tmps << " " << tmpss << endl;
}

C++: #include<iostream>
#include<algorithm>
#include<stdio.h>
#include<string>
using namespace std;
int main()
{
	string p[1001],s;
	int c;
	int st[1001] = { 0 }, l = 0, i,maxl=0,maxn=0;
	while ((c = getchar()) != '\n'){
		if (c == ' '){
			for (i = 0; i < l; i++){
				if (p[i] == s){
					st[i]++;
					s.clear();
					break;
				}
			}
			if (i == l){
				int size = s.size();
				p[l] = s;
				maxl = max(maxl,size);
				if (maxl == s.size())maxn = l;
				s.clear();
				l++;
			}
		}
		else{
			s += c;
		}
	}
	for (i = 0; i < l; i++){
		if (p[i] == s){
			st[i]++;
			break;
		}
	}
	if (i == l){
		int size = s.size();
		p[l] = s;
		maxl = max(maxl, size);
		if (maxl == s.size())maxn = l;
		s.clear();
		l++;
	}
	int maxb=0,maxnum;
	for (int i = 0; i < l; i++){
		maxb = max(maxb, st[i]);
		if (maxb == st[i]){
			maxnum = i;
		}
	}
	cout << p[maxnum] << endl;
	cout << p[maxn] << endl;
}

C++: #include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <map>
using namespace std;

#define FOR(i,a,b) for(long long int i=(a);i<(b);i++)
#define REP(i,n) for(long long int i=0;i<(n);i++)
#define ALL(s) (s).begin(),(s).end()

#define PI 3.14159265358479

typedef long long ll;
typedef vector<long long int> vi;
typedef vector<long long int>::iterator vit;

int main(){
	map<string, int>table;
	string s, f, l;
	string::iterator it = s.begin();
	size_t n = 0;
	while (cin >> s){
		table[s]++;
		if (table[s] > n){
			n = table[s];
			f = s;
		}
		if (s.size() > l.size()){
			l = s;
		}
	}
	cout << f << " " << l << endl;
}

C++: #include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
using namespace std;

int main(){
    string s;
    string longest;
    map<string,int> m;
    while(cin >> s){
        m[s]++;
        if(longest.size() < s.size()) longest = s;
    }
    string freq;
    for(auto & e : m){
        if(m[freq] < e.second) freq = e.first;
    }
    cout << freq << " " << longest << endl;
}

C++: #include<stdio.h>
#include<string.h>
char str[33];
int lmax=0;
char mword[33];
typedef struct{
	char word[33];
	int time;
}data;
data d[1000];
int cd=0;
int i;
int main(){
	while(scanf("%s",str)!=EOF){
		if(strlen(str)>lmax){
			lmax=strlen(str);
			strcpy(mword,str);
		}
		for(i=0;i<cd;i++)if(strcmp(d[i].word,str)==0){
			d[i].time++;
			break;
		}
		if(i==cd){
			strcpy(d[cd].word,str);
			d[cd++].time=1;
		}
		}
	}
	int fm=0;
	for(i=0;i<cd;i++)if(d[i].time>d[fm].time)fm=i;
	printf("%s %s\n",d[fm].word,mword);
}

C++: #define _USE_MATH_DEFINES
 
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>

using namespace std;

int main(){
	vector<string> str;
	int count[1000]={0};
	int length[1000]={0};

	string s;
	while(cin >> s){
		int i;
		for(i=0;i<str.size();i++){
			if(str[i]==s){
				count[i]++;
				break;
			}
		}
		if(i>=str.size()){
			str.push_back(s);
			length[i]=s.size();
		}
	}

	int max = 0;
	for(int i=0;i<str.size();i++){
		if(count[i]>max){
			max=i;
		}
	}
	cout << str[max] << " ";
	
	max = 0;
	for(int i=0;i<str.size();i++){
		if(length[i]>max){
			max=i;
		}
	}
	cout << str[max] << endl;
	
	return 0;
}

C++:  
 #include<iostream>
 #include<stdio.h>
 #include<string>
 #include<math.h>
 #include<iomanip>
 #include<algorithm>
 #include<string.h>
 #include<cctype>
 #include<map>
 #include<set>
 #include<vector>
 #include<sstream>
 #include<stack>
 #include<queue>
 
 using namespace std;
  
 int main()
 {
   multiset<string> kk;
   int max=0;
   int fre=-100000000;
   string str;
   string str_max;
   string str_fre;
   multiset<string>::iterator iter; 
   while(cin>>str)
   {
     if(str.length()>max) 
     {
       max=str.length();
       str_max=str;                     
     }             
     kk.insert(str);      
   }              
   for(iter = kk.begin();iter!= kk.end(); iter++)  
   {  
     string str=*iter;
     int num=kk.count(str);
     if(num>fre) 
     {
       fre=num;
       str_fre=str;                
     }
   }  
   cout<<str_max<<" "<<str_fre<<endl;
   //while(1);     
   return 0;  
 }

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=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;
}