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"

#define ALL(a) (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define DESCSORT(c) sort(c.begin(), c.end(), greater<int>())

using namespace std;

using LL = long long int;
using LD = long double;

using pii = pair<int, int>;
using pll = pair<LL, LL>;
using pdd = pair<double, double>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vl = vector<LL>;
using vvl = vector<vl>;
using vvvl = vector<vvl>;
using vd = vector<double>;
using vvd = vector<vd>;
using vs = vector<string>;
using vb = vector<bool>;
using vvb = vector<vb>;

const int INF = (1 << 30) - 1;
const LL INF64 = ((LL)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
LL gcd(LL x, LL y) { return y ? gcd(y, x % y) : x; }

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);

	map<string, int> mp;
	string s;

	while (cin >> s) {
		mp[s]++;
	}

	pair<string, int> ma = make_pair("nanashi", 0);
	pair<string, int> ma2 = make_pair("nanashi2", 0);
	for (auto v : mp) {
		if (ma.second < v.second) {
			ma = v;
		}
		if (ma2.second < v.first.size()) {
			ma2 = make_pair(v.first, v.first.size());
		}
	}

	cout << ma.first << " " << ma2.first << endl;
	return 0;
}

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

using namespace std;

int main(){
    map<string, int> data;
    string mxlen, mst, str;
    while(cin >> str){
        data[str]++;
        if(data[str] > data[mst]){
            mst = str;
        }
        if(str.size() > mxlen.size()){
            mxlen = str;
        }
    }
    cout << mst << ' ' << mxlen << endl;
    return 0;
}

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

int main(){
	string s;
	int m;
	map<string,int> mp;
	while(cin>>s){
		mp[s]++;
		int asd=s.size();
		m=max(m,asd);
	}
	
	int x=0;
	
	for(auto &el:mp){
		if(x<el.second){
			x=el.second;
		}
	}
	
	for(auto &el:mp){
		if(x==el.second){
			cout<<el.first<<" ";
			break;
		}
	}
	
	for(auto &el:mp){
		if(m==el.first.size()){
			cout<<el.first<<endl;
		}
	}
	
	return 0;
}

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

int main()
{
	map<string, int> mp;
	string s;
	string max, len;
	
	while (cin >> s){
		mp[s]++;
		if (mp[max] < mp[s]){
			max = s;
		}
		else if (len.size() < s.size()){
			len = s;
		}
	}
	
	cout << max << ' ' << len << endl;
	
	return (0);
}

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

C++: //#include<bits/stdc++.h>
#include<iostream>
#include <vector>
#include <cstdio>
#include<algorithm>
#include <utility>
#include<string>
using namespace std;
string str[10000] = { "" };
char ch[10000];
int input();
int main() {
	int a,most=0;
	a = input();
	string  longest;
	int m[10000] = { 0 }, l;
	for (int i = 0; i <= a + 1; i++) {
		for (int j = i + 1; j <= a; j++) {
			if (str[i] == str[j]) {
				m[i]++;
			}
		}
	}int k,ma=0,locate,memo;
	for (k = 0; k <= a+1; k++) {
		if (m[k] > ma) {
			ma = m[k];
			locate= k;
		}
	}
	for (int f = 0; f <= a+1; f++) {
		if (str[f].size()> most) {
			most = str[f].size();
			memo = f;
		}
	}
	longest = str[memo];
	cout << str[locate] << " " << longest << endl;
	return 0;
}
int input() {
	int i = 0, j = 0;
	while (1) {
		scanf("%c", &ch[i]);
		if (isupper(ch[i])) {
			ch[i] += 'a' - 'A';
		}
		if (ch[i] == ' ') {
			j++;
		}
		else if (ch[i] == '\n') {
			break;
		}
		else {
			str[j] += ch[i];
		}
		
	}
	return j;
}

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

#define MAX(x,y) ((x,y)? x:y)

using namespace std;

string date[1000];

int main()
{
	char c[35];
	int i=0;
	while(cin>>c){
		date[i]=c;
		i++;
	}
	sort(date,date+1000);
	int weitline=0;
	int maxline=0;
	string str;
	int str_i=0;
	for(int i=0;i<1000;i++)
	{
		if(str==date[i])str_i++;
		else 
		{
			str_i=1;
			str=date[i];
		}
		weitline =MAX(weitline,str_i);
		maxline=MAX(maxline,date[i].length());
	}
	string weitanswer;
	string maxanswer;

	for(int i=0;i<1000;i++)
	{
		if(str==date[i])str_i++;
		else 
		{
			str_i=1;
			str=date[i];
		}
		if(str_i==weitline)weitanswer=date[i];
		if(maxline==date[i].length()) maxanswer=date[i];
	}
	printf("%s %s\n");
	return 0;
}

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

int main(){
	int max = 0;
	string max_str;

	string str;
	vector<string> v;
	while(cin >> str){
		transform(str.begin(), str.end(), str.begin(), ::tolower);

		v.push_back(str);

		if(v.size() > max){
			max_str = str;
		}
	}
	sort(v.rbegin(), v.rend());
	cout << v[0] << " " << max_str << endl;
}

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

struct Sentence {
  string s;
  int len = 0;
  int n = 0;
};

int main() {
  Sentence a[1000];
  string e;

  int j = 0;
  while (cin >> e) {
    for (int i = 0; i < 1000; i++) {
      if (e == a[i].s) {
        a[i].s = e;
        a[i].len = e.size();
        a[i].n++;
      } else if (i == 999) {
        a[j].s = e;
        a[j].len = e.size();
        a[j].n++;
      }
    }

    j++;
  }

  int maxi_n = 0, maxi_len = 0;
  for (int i = 0; i < 1000; i++) {
    if (a[i].n > maxi_n) maxi_n = i;
    if (a[i].len > maxi_len) maxi_len = i;
  }

  cout << a[maxi_n].s << " " << a[maxi_len].s << endl;
}

C++: #include <string>
#include <vector>
#include <iostream>
#include <sstream>
#include <chrono>
 
typedef struct LettersInfo {
    std::string letters;
    unsigned int count;?°
} lettersInfo_s;
 
int main()
{
    std::string paramStr;
    std::getline(std::cin, paramStr);
 
    std::vector<lettersInfo_s*> lettersList;
 
    std::string letters;
    std::istringstream stream(paramStr);
 
    unsigned int maxLength = 0;
    std::string maxLengthStr;
 
    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);
            }
        }
    }
 
    unsigned int maxCount = 0;
    std::string maxCountStr;
    while( lettersList.size() > 0 ) {

        lettersInfo_s* plettersInfo = lettersList.erase(0);

        unsigned int count = plettersInfo->count;
        if (maxCount < count) {
            maxCountStr = plettersInfo->letters;
            maxCount = count;
        }
        delete plettersInfo;
    }
 
    std::cout << maxCountStr << " " << maxLengthStr << std::endl;
 
    return 0;
}