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>
using namespace std;
int main(){
    long saidai=0;
    char f;
    int a=0,cnt=0,num=0,max=0;
    string str,tango[1000]={""},answer,ans;
    getline(cin,str);
    for(int i=0;i<str.size();i++){
        if(str[i]==' '){
            for(int j=a;j<i;j++){
                if(isupper(str[j])){
                    f=str[j];
                    f=f+32;
                    str[j]=f;
                }
                tango[cnt]+=str[j];
            }
            cnt=cnt+1;
            a=i+1;
        }
    }
    for(int p=a;p<str.size();p++){
        tango[cnt]+=str[p];
    }
    
    for(int k=0;k<1000;k++){
        if((tango[k]==""))break;
        if(saidai<tango[k].size()){
            saidai=tango[k].size();
            ans=tango[k];
        }
    }
    
    for(int s=0;s<=cnt;s++){
        for(int t=s+1;t<=cnt;t++){
            if(tango[s]==tango[t]){
                num=num+1;
            }
        }
        if(max<num){
            max=num;
            answer=tango[s];
        }
    }
    cout<<answer<<" "<<ans<<endl;
    return 0;
}

C++: #define _USE_MATH_DEFINES
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<list>
#include<stack>
#include<queue>
#include<cctype>
#include<iomanip>
#include<functional>
#include<numeric>
#include<map>
#include<set>
#define EPS 1e-10
using namespace std;
typedef long long llong;
int main() {
	map<string, int>a;
	int len = 0, freq = 0;
	string s;
	while (cin>>s) {
		a[s]++;
		if (len < s.length())len = s.length();
		if (freq < a[s])freq = a[s];
	}
	for (auto it = a.begin(); it != a.end(); it++) {
		if (freq == it->second)cout << it->first << " ";
	}
	for (map<string, int>::iterator it = a.begin(); it != a.end(); it++) {
		if (len == it->first.length())cout << it->first << endl;
	}
	return 0;
}

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

int main() {
  string s;
  vector<string> s_list;
  map<string, int> s_map;
  while (cin >> s) {
    s_map[s]++;
    s_list.push_back(s);
  }
  int max_s = 0;
  int i;
  for (i = 0; i < s_list.size(); i++) {
    max_s = max(max_s, s_map[s_list[i]]);
  }
  for (i = 0; i < s_list.size(); i++) {
    if (s_map[s_list[i]] == max_s) {
      cout << s_list[i] << ' ';
      break;
    }
  }
  int max_length = 0;
  for (i = 0; i < s_list.size(); i++) {
    max_length = max(max_length, (int)(s_list[i].length()));
  }
  for (i = 0; i < s_list.size(); i++) {
    if (max_length == s_list[i].length()) {
      cout << s_list[i] << endl;
      break;
    }
  }
  return 0;
}

C++: #define _USE_MATH_DEFINES
#include <iostream>
#include <queue>
#include <vector>
#include <math.h>
#include <algorithm>
#include <iomanip>
#include <string>
#include <stack>
#include <cctype>
#include <cstdlib>
#include <string.h>
#include <utility>
#include <cstdio>
#include <set>
#include <map>
#include <boost/multiprecision/cpp_int.hpp>
#include <assert.h>
using namespace std;
namespace mp = boost::multiprecision;

#define INF (1 << 20)
#define EPS (1e-10)
#define EQ(a,b) (fabs((a)-(b)) < EPS)

#define ll long long
#define LL long long

int main() {
	string s;
	map<string, int> n;
	int maxl = 0;
	string maxls;
	while (cin >> s) {
		transform(s.begin(), s.end(), s.begin(), (int (*)(int))tolower);
		if (s.length() > maxl) {
			maxl = s.length();
			maxls = s;
		}
		auto res = n.find(s);
		if (res == n.end()) n.insert(make_pair(s, 1));
		else res->second++;
	}
	int maxn = 0;
	string maxns;
	for_each(n.begin(), n.end(), [&](pair<string, int> p) {
			if (p.second > maxn) {
			maxn = p.second;
			maxns = p.first;
			}
			});
	cout << maxns << ' ' << maxls << endl;
	return 0;
}

C++: #include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
using namespace std;
vector<string> st;
map<string,int> stm;
main(){
  char hoge[1001];
  string str;
  fgets(hoge,sizeof(hoge),stdin);
  str=hoge;
  int stp=0;
  int n=str.size();
  for(int i=0;i<n;i++){
    if(str.at(i)==' '){
      st.push_back(str.substr(stp,i-stp));
      stp=i+1;
      stm[st.back()]++;
    }
  }
  st.push_back(str.substr(stp,n-stp-1));

  int m=st.size();

  string strmax;
  string stres;
  int count=0;
  int tc=0;
  for(int i=0;i<m;i++){
    if(i==0){
      strmax=st[0];
      stres=st[0];

    }else{
      if(strmax.size() < st[i].size()){
	strmax=st[i];
      } 
      if(stm[st[i]] > stm[stres]){
	stres=st[i];
      }
    }
    
  } 
  cout << stres <<" "<<strmax<<endl;
}

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

int main() {
    string s;
    map<string, int> m;
    while(cin >> s) {
        m[s]++;
    }
    string r1, r2;
    for(auto& p : m) {
        if(m[r1] < p.second) {
            r1 = p.first;
        }
        if(r2.size() < p.first.size()) {
            r2 = p.first;
        }
    }
    cout << r1 << ' ' << r2 << endl;
}