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>
using namespace std;

#define rep(i,a,n) for(int i=a; i<n; i++)
#define repr(i,a,n) for(int i=a; i>=n; i--)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 999999999

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long int ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

int const MOD = 1000000007;

int main() {
    string s;
    multiset<string> v;

    int max_num = 0;
    int max_len = 0;

    while(cin >> s) {
        v.insert(s);
        max_num = max((int)v.count(s), max_num);
        max_len = max((int)s.length(), max_len);
    }

    for(auto x : v) {
        if(v.count(x) == max_num) cout << x << endl;
    }
    for(auto x : v) {
        if(s.length() == max_len) cout << x << endl;
    }
    return 0;
}

C++: #include <string>
#include <vector>
#include <iostream>
#include <sstream>
#include <chrono>

// ???????????????????????°????????????????§???????
typedef struct LettersInfo {
    std::string letters; // ??????
    unsigned int count; // ???????????°
} lettersInfo_s;

int main()
{
    /////////////////
    // 1. ??\????????????
    /////////////////
    std::string paramStr;
    std::getline(std::cin, paramStr);

    // ???????¨???¬????§?
    //auto start = std::chrono::system_clock::now();

    // ???????????????????????°?????????
    std::vector<lettersInfo_s*> lettersList;

    // ?????????????????????????´???????
    std::string letters;
    std::istringstream stream(paramStr);

    // ?????????????????¨????????????????£????????´???????
    unsigned int maxLength = 0;
    std::string maxLengthStr;

    ////////////////////////////////////////////////////////////////////////
    // 2. ??????????????????????????????????????????????´¢???????????????????????????????????°???????????????
    ////////////////////////////////////////////////////////////////////////
    while (std::getline(stream, letters, ' ')) {
        unsigned int len = letters.size();
        if ( len != 0) {
            // ????????????????£???¨?????????
            if ( maxLength < len ) {
                // ????????????????£??????\?????????
                maxLengthStr = letters;
                maxLength = len;
            }
            // ?????????????????¢???????????¨??????????????¢???????????§????????°???????????°????¢??????????
            unsigned int loopCount;
            for (loopCount = 0; loopCount < lettersList.size(); loopCount++) {
                if ( lettersList[loopCount]->letters == letters ) {
                    ++lettersList[loopCount]->count;
                    break;
                }
            }
            // ??°?????????????????????????????????????????°??????????????????
            if (loopCount == lettersList.size()) {
                lettersInfo_s* plettersInfo = new lettersInfo_s();
                plettersInfo->letters = letters;
                ++plettersInfo->count;
                lettersList.push_back(plettersInfo);
            }
        }
    }

    ////////////////////////////////////////
    // 3. ???????????????????????°?????????????????????????´¢
    ////////////////////////////////////////
    unsigned int maxCount = lettersList[0]->count;
    std::string maxCountStr = lettersList[0]->letters;
    for (unsigned int i = 1; i < lettersList.size(); i++) {
        unsigned int count = lettersList[i]->count;
        if (maxCount < count) {
            // ????????????????£??????\?????????
            maxCountStr = lettersList[i]->letters;;
            maxCount = count;
        }
    }

    ///////////////////////////////
    // 4. ????????????????????????????????¨???
    ///////////////////////////////
    std::cout << maxCountStr << " " << maxLengthStr << std::endl;

    // ???????¨???¬??????
    //auto end = std::chrono::system_clock::now();
    //auto dur = end - start;

    // ??????????????¨???
    //auto msec = std::chrono::duration_cast<std::chrono::milliseconds>(dur).count();
    //std::cout << msec << "[ms]" << std::endl;

    //std::getline(std::cin, paramStr);

    return 0;
}

C++: #include<iostream>
#include<string>
#include<algorithm>
using namespace std;
string S, T[1000], U; int sum, maxn; int k, p[1000];
int main() {
	getline(cin, S);
	S += ' ';
	for (int i = 0; i <= S.size(); i++) {
		if (S[i] == ' ') {
			if (maxn < T[sum].size()) {
				maxn = T[sum].size(); U = T[sum]; 
			}
			sum++;
		}
		else {
			T[sum] += S[i];
		}
	}
	for (int i = 0; i < sum; i++) {
		p[i] = i;
		for (int j = 0; j < i; j++) {
			if (T[i] == T[j]) {
				p[j] += 10000; break;
			}
		}
	}
	sort(p, p + sum);
	cout << T[p[sum - 1] % 10000] << ' ' << U;
	return 0;
}

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

using namespace std;

/** Problem0029 : English Sentence **/
int main()
{
	map<string, int> sentences;
	pair<string, int> t;
	string tmp, maxLength;
	maxLength="";
	
	while (cin >> tmp) {
		if (tmp.length() > maxLength.length())
			maxLength = tmp;
		
		if (sentences.count(tmp) == 0) {
			sentences.insert(map<string,int>::value_type(tmp, 1));
		} else {
			sentences[tmp]++;
		}
	}
	
	t = *max_element(sentences.begin(), sentences.end());
	cout << t.first << " " << maxLength << endl;
	
	return 0;
}

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

int main() {
    vector<string> s;
    string tmps;
    set<string> st;
    //int i = 0;
    size_t maxl = 0;
    while(cin >>tmps) {
        s.push_back(tmps);
        st.insert(tmps);
        //maxl = max(maxl, s.at(i).size());
        //i++;
        //cout << tmp;
    }
    
    int ans = 0, maxv = 0;
    string maxs ="";
    string maxL = "";
    for (auto ss : st) {
        int tmp = 0;
        rep(i, s.size()) {
            //int tmp = 0;
            if (ss == s.at(i)) {
                tmp++;
            }
        }
        if (maxv < tmp) {
            maxv = tmp;
            maxs = ss;
        }
        if (maxL.size() < ss.size()) {
            maxL = ss;
        }
    }

    cout << maxs << " " <<maxL << endl;
}

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
  map<string,int> a;
  string s,maxs,maxms;
  while(cin>>s){
    a[s]++;
    if(a[maxs]<a[s])maxs=s;
    if(maxms.size()<s.size()) maxms=s;
  }
  cout<<maxs<<' '<<maxms<<endl;
}

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

int main(){
  string s;
  string ansstr;
  string maxv;
  map<string, int> mp;
  while (cin >> s) {
    mp[s]++;
    maxv = mp.rbegin()->first;

    int maxstr = 0;
    for (auto x : mp) {
      if (x.first.size() >= maxstr) {
        maxstr = x.first.size();
        ansstr = x.first;
      }
    }
  }
  cout << maxv << " " << ansstr << endl;
  return 0;
}