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 <cstdio>
#include <map>
#include <string>
using namespace std;

map<string, int> m;

int main(){
	char buf[33];
	while (scanf("%s", buf, 33) != EOF) {
		if (m.find(buf) != m.end()) {
			m[buf] += 1;
		}
		else {
			m[buf] = 0;
		}
	}
	map<string, int>::iterator itr = m.begin();
	string sl, sc;
	int l, c;
	sl = sc = (*itr).first;
	c = (*itr).second;
	l = (*itr).first.size();
	while (++itr != m.end()) {
		if ((*itr).first.size() > l) {
			sl = (*itr).first;
			l = (*itr).first.size();
		}
		if ((*itr).second > c) {
			sc = (*itr).first;
			c = (*itr).second;
		}	
	}
	printf("%s %s\n", sc.c_str(), sl.c_str());

	return 0;
}

C++: #include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <string>
#include <stdio.h>
#include <math.h>
#include <map>

using namespace std;

vector<string> split(string source, string pattern) {
    unsigned i, base = 0;
    vector<string> ret;
    string buff;

    for(i = 0; i < source.size(); i++) {
        if(source.substr(i, pattern.size()) == pattern) {
            ret.push_back(buff);
            i += pattern.size() - 1;
            buff.clear();
        } else {
            buff += source[i];
        }
    }
    ret.push_back(buff);
    return ret;
}

int main(void) {
    string w, big_occ, big_size;
    int ml = 0, occ = 0;
    map<string, int> m;

    getline(cin, w);

    vector<string> sp = split(w, " ");

    for(int i = 0; i < (int) sp.size(); i++) {
        m[sp[i]] += 1;
    }

    for(map<string, int>::iterator it = m.begin(); it != m.end(); it++) {
        if(it->second > occ) {
            big_occ = it->first;
            occ = it->second;
        }
        if(it->first.size() >= ml) {
            big_size = it->first;
            ml = it->first.size();
        }
    }

    cout << big_occ << " " << big_size << endl;

    return 0;
}

C++:  #include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<cstring>
#include<map>
#define inf 0x3fffffff
#define M 10000
using namespace std;

char str[40];
map<string,int>ss;
int main()
{
	char ans[40],ans2[40];
	char a;
	int maxi,l_maxi;
	while(scanf("%s",str)!=EOF)
	{
		a = getchar();
		maxi = l_maxi = 0;
		ss.clear();
		while(scanf("%s",str))
		{
			a = getchar();
			ss[str]++;
			if(ss[str] > maxi)
			{
				maxi = ss[str];
				strcpy(ans,str);
		//		cout<<ans<<endl;
			}
			if(strlen(str) > l_maxi)
			{
				l_maxi = strlen(str);
				strcpy(ans2,str);
			}
			if(a == '\n')
			{
				cout<<ans<<" "<<ans2<<endl;
			  	break;	
				
			}
		}
	}
	return 0;
}

C++: #include <stdio.h>
#include<string.h>

typedef struct
{
	char word[32];
	int cnt = 0;
	int len = 0;
}str;

int main()
{
	int i = 0;
	int max1=0,max2=0;
	str w[1024];
	while ((scanf("%s", w[i].word)) != EOF)
	{
		w[i].len = strlen(w[i].word);
		for (int j = 0; j < i; j++)
		{
			if (strcmp(w[j].word, w[i].word)) { w[j].cnt++; w[i].cnt++; }
		}
		i++;
	}
	for (int j = 0; j < i; j++)   //???i????????§???
	{
		if (max1 < w[j].cnt) max1 = w[j].cnt;
		if (max2 < w[j].len) max2 = w[j].len;
	}
	for (int j = 0; j < i; j++)
	{
		if (w[j].cnt == max1) printf("%s ", w[j].word);
		if (w[j].len == max2) printf("%s\n", w[j].word);

	}
	return 0;
}

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

int main()
{
	std::map<std::string,int> word_frequency;
	std::string word;
	while (std::cin >> word) {
		std::transform(word.begin(), word.end(), word.begin(), tolower);
		word_frequency[word]++;
	}

	std::string most_frequent_word;
	std::string longest_word;
	int max_frequency = 0;
	for (std::map<std::string,int>::iterator i = word_frequency.begin(); i != word_frequency.end(); ++i) {
		if (i->second > max_frequency) {
			most_frequent_word = i->first;
		}
		if (i->first.size() > longest_word.size()) {
			longest_word = i->first;
		}
	}

	std::cout << most_frequent_word << ' ' << longest_word << std::endl;

	return 0;
}

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