Go: package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
)

var scanner = bufio.NewScanner(os.Stdin)

func nextString() string {
	scanner.Scan()
	return scanner.Text()
}

type Pair struct {
	key   string
	value int
}

func main() {
	scanner.Split(bufio.ScanWords)
	counts := map[string]int{}
	maxLen := 0
	maxLenWord := ""
	for {
		word := nextString()
		if word == "" {
			break
		}

		counts[word]++

		if len(word) > maxLen {
			maxLen = len(word)
			maxLenWord = word
		}
	}

	mapPairs := []Pair{}
	for k, v := range counts {
		mapPairs = append(mapPairs, Pair{k, v})
	}
	sort.Slice(mapPairs, func(i, j int) bool { return mapPairs[i].value > mapPairs[j].value })

	fmt.Println(mapPairs[0].key, maxLenWord)
}

C++: #include <iostream>
#include <cstdio>
#include <cstring>

using namespace std;

class Word {
public:
	char w[33];
	int length;
	int freq;
public:	
	Word() {
		strcpy(w, "");
		length = 0;
		freq = 0;
	}
};

int main()
{
	char str[1001];
	char buf[32];
	char *p, *q;
	fgets(str, 1001, stdin);
	
	Word wl[32];
	
	for ( p = str; (q = strstr(p, " ")) != NULL; ) {
		*q = '\0'; strcpy(buf, p); 
		for (int i=0; i<32; i++) {
			if ( strcmp(wl[i].w, "") == 0 ) {
				strcpy(wl[i].w, buf);
				wl[i].length = strlen(buf);
				wl[i].freq = 1;
				break;
			}
			else if ( strcmp(wl[i].w, buf) == 0 ) {
				wl[i].freq++;
				break;
			}
		}
		p = q + 1;
	}
	
	strcpy(buf, p); 
	for (int i=0; i<32; i++) {
		if ( strcmp(wl[i].w, "") == 0 ) {
			strcpy(wl[i].w, buf);
			wl[i].length = strlen(buf);
			wl[i].freq = 1;
			break;
		}
		else if ( strcmp(wl[i].w, buf) == 0 ) {
			wl[i].freq++;
			break;
		}
	}

	
	int max_freq = 0;
	int max_length = 0;
	char max_freq_w[32];
	char max_length_w[32];
	
	for (int i=0; i<32; i++) {
		if (max_freq < wl[i].freq) {
			max_freq = wl[i].freq;
			strcpy(max_freq_w, wl[i].w);
		}
		if (max_length < wl[i].length) {
			max_length = wl[i].length;
			strcpy(max_length_w, wl[i].w);
		}
	}
	
	cout << max_freq_w << endl << max_length_w << endl;
	
	return 0;
}

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

int main()
{
  map<string, int> m;
  string str, most, w_ct;


  while (cin >> str){
    m[str]++;
    if (m[most] < m[str]){
      most = str;
    }
    else if(w_ct.size() < str.size()){
      w_ct = str;
    }
  }
  cout << most << ' ' << w_ct << endl;
}

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

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int dx[] = { -1, 0, 1, 0 }; const int dy[] = { 0, 1, 0, -1 };

int main() {
map<string,int> msi;
string s;
int ma=0;
int ma2=0;
string ans;
string ans2;
while (cin >> s){
	if (EXIST(msi,s))
		msi[s]=1;
	else{
		msi[s]++;
		if (ma2<msi[s]){
		ans2=s;
		ma2 = msi[s];
		}
		}
	if (ma < s.length()){
	ans=s;
	ma = s.length();
	}
}
cout << ans2 << " "<<ans<<endl;
	return 0;
}

C++: #include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define LOOP(i,x,n) for(int i=x;i<n;i++)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define MP make_pair
#define FR first
#define SC second
#define int long long
using namespace std;
const int MOD=1000000007;
const int INF=9000000009;

signed main(){
  map<string,int> mp;
  string s;
  getline(cin,s);
  string maxsent="";
  REP(i,s.size()){
    string t;
    while(s[i]!=' '){
      t+=s[i];
      i++;
    }
    mp[t]++;
    if(maxsent.size()<t.size())maxsent=t;
  }
  string mostsent;
  int mode=0;
  for(auto x:mp){
    if(x.SC>mode){
      mode=x.SC;
      mostsent=x.FR;
    }
  }
  cout<<mostsent<<' '<<maxsent<<endl;
  return 0;
}

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

int main(){
  std::string str;
  std::string maxlen;
  std::string maxocc;
  std::map<std::string, int> occ;
  //std::cin >> str;
  //std::cout << str << std::endl;

  std::cin >> str;
  maxlen = str;
  maxocc = str;

  while(std::cin >> str){
    if(str.size()>maxlen.size()){
      maxlen = str;
    }
    occ[str]++;
    if(occ[str]>occ[maxocc]){
      maxocc = str;
    }
  }

  std::cout << maxlen << std::endl;
}

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

int main(){
    map<string,int>M;
    string in,ma,ma2;
    while(cin>>in){
        M[in]++;
        if(ma.size()<in.size())ma=in;
    }

    for(map<string,int>::iterator it=M.begin();it!=M.end();it++){
        ma2=it->first;
    }
    cout<<ma2<<" "<<ma<<endl;

    return 0;
}

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

int main(){
	string s;
	string longest = "";
	int most = 0;
	string most_str;
	map<string, int> h;
	while(cin >> s){
		if(s.size() > longest.size()){
			longest = s;
		}
		if (h.find(s) == h.end()) {
			h[s] = 0;
		}
		h[s]++;
		if (most < h[s]) {
			most = h[s];
			most_str = s;
		}
	}
	cout << most_str << " " << longest << endl;
	return 0;
}

C++: #include <iostream>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <map>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,b) FOR(i,0,b)
#define PB push_back
#define MP make_pair
typedef pair<double,double> P;
int main(){
  map<string,int> data;
  string s[1000];
  int cnt=0;
  while(cin>>s[cnt]){
    if(data[s[cnt]]==1)data[s[cnt]]++;
    else data[s[cnt]]=1;
    cnt++;
  }
  string ans[2];
  int m[2]={0,0};
  for(int i=0;i<cnt;i++){
    if(s[i].size()>m[1]){
      ans[1]=s[i];m[1]=s[i].size();
    }
    if(data[s[i]]>m[0]){
      ans[0]=s[i];m[0]=data[s[i]];
    }
  }
  cout<<ans[0]<<" "<<ans[1]<<endl;
}

C++: //
//  main.c
//  EngSent
//
//  Created by x16017xx on 2016/11/10.
//  Copyright ?? 2016??´ AIT. All rights reserved.
//

#include <stdio.h>
#include <string.h>

int main(int argc, const char * argv[]) {
    char str[1000][33]={};
    int strId[1000]={};
    char strTmp[33]={};
    int i, j, l = 0;
    int mt=0;
    int cm=0;
    int mm=0;
    char ch;
    // ???????????\???
    for(i=0;i<1000;i++){
        scanf("%c", &ch);
        if(ch==' '||ch=='\n'){
            strTmp[l]='\0';
            for(j=0;strcmp(str[j],"\0")!=0;j++){
                if(0==strcmp(str[j], strTmp)){
                    l=0;
                    break;
                }
            }
            strcpy(str[j], strTmp);
            strId[j]++;
            l=0;
            if(ch=='\n'){
                break;
            }
        }else{
            strTmp[l]=ch;
            l++;
        }
    }
    
    // ????????°????????????????????????
    for(i=0;strcmp(str[i],"\0")!=0;i++){
        if(mt<strId[i]){
            mt=strId[i];
        }
    }
    for(i=0;strcmp(str[i],"\0")!=0;i++){
        if(mt==strId[i]){
            printf("%s ",str[i]);
        }
    }
    // ????????°????????????????????????
    for(i=0;strcmp(str[i],"\0")!=0;i++){
        cm=(int)strlen(str[i]);
        if(mm<cm){
            mm=cm;
        }
    }
    for(i=0;strcmp(str[i],"\0")!=0;i++){
        if(mm==strlen(str[i])){
            printf("%s\n",str[i]);
        }
    }
    return 0;
}