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 read() freopen("input", "r", stdin)
using namespace std;

int main(void)
{
	read();
	string s;
	map<string, int> m;
	int hm = 0;
	string mx, f;
	while(cin >> s){
		m[s] += 1;

		if(m[s] > hm){
			hm = m[s];
			f = s;
		}
		if(s.length() > mx.length())
			mx = s;
	}

	cout << f << " " << mx << endl;

	return 0;
}

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

using namespace std;

int main(){
  map<string,int> table;
  string word,ans1,ans2;
  int freq=0,len=0;
  while(cin >> word){


    if(table.find(word)==table.end()){
      table[word] = 1;
    }else{
      table[word]++;
    }
    if(table[word]>freq){
      freq = table[word];
      ans1 = word;
    }
    if(word.size()>len){
      len = word.size();
      ans2 = word;
    }
  }
  cout << ans1 << " " << ans2 << endl;
}

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

class word_cnt{
public:
  int cnt;
  string word;

  word_cnt() {
    cnt = 0;
  }

  bool operator < (const word_cnt& right) const {
    return cnt < right.cnt;
  }

};

int main() {

  vector<word_cnt> words;
  word_cnt add;
  string input;

  int len_max = 0;
  string word_max;

  while(cin >> input) {

    for ( int i = 0; i < input.size(); i++ ) {

      if ( input[i] >= 'A' && input[i] <= 'Z' ) input[i] -= ( 'A' - 'a' );

    }

    bool flag = true;
    for ( int i = 0; i < words.size(); i++ ) {

      if ( words[i].word == input ) {
	words[i].cnt++;
	flag = false;
	break;
      }

    }

    if ( flag ) {

      add.cnt = 1;
      add.word = input;
      words.push_back(add);

    }

    if ( len_max < input.size() ) {
      len_max = input.size();
      word_max = input;
    }

  }

  sort( words.begin(), words.end() );

  cout << words[ words.size()-1 ].word << " " << word_max << endl;

  return 0;
}

C++: #include <iostream>
#include <string>
#include <map>
using namespace std;
int main(){
	string s,t,u;
	int M=0,l=0;
	map<string,int>m;
	for(;cin>>u;){
		if(++m[u]>M)M=m[u],s=u;
		if(t.size()<u.size())t=u;
	}
	cout<<s<<' '<<t<<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;
    }
    int ma3=0;
    for(map<string,int>::iterator it=M.begin();it!=M.end();it++){
        if(ma3<it->second){
            ma3=it->second;
            ma2=it->first;
        }
    }
    cout<<ma2<<" "<<ma<<endl;

    return 0;
}

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

using namespace std;

const int M = 33;
const int N = 33001;

char text[N];
char word[N][M];
char tmp[N], ansm[N], ansl[N]; 

int cmp(const void *a, const void *b) {
	return strcmp((char *)a, (char *)b);
}

void solve(char text[]) {
	int len = strlen(text);
//	for (int i=0; i<len; ++i) {
//		if (text[i] >= 'A' && text[i] <= 'Z') text[i] = text[i] - 'A' + 'a';
//	}
	int j = 0, k = 0;
	for (int i=0; i<len; ++i) {//分解文章 
		if (text[i] != ' ') word[k][j++] = text[i];
		else {
			if (j == 0) continue;
			word[k++][j] = '\0', j = 0;
		}
	}
	if (j) word[k++][j] = '\0';
	qsort(word, k, sizeof(word[0]), cmp);
	int maxs = -1;
	int cnt = 1;
	strcpy(tmp, word[0]);
	strcpy(ansl, word[0]);
	int maxl = strlen(word[0]);
	for (int i=1; i<k; ++i) {
		if (maxl < strlen(word[i])) maxl = strlen(word[i]), strcpy(ansl, word[i]);
		if (!strcmp(tmp, word[i])) ++cnt;
		else {
			if (maxs < cnt) {
				maxs = cnt;
				strcpy(ansm, tmp);
			}
			strcpy(tmp, word[i]);
		}
	}
	if (maxs < cnt) strcpy(ansm, tmp);
}

int main() {
	cin.getline(text, N, '\n');
//	while (cin.getline(text, N, '\n')) {
		solve(text);
		cout<<ansm<<" "<<ansl<<endl;
//	}
	return 0;
}

C++: #define _USE_MATH_DEFINES
 
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>

using namespace std;

int main(){
	vector<string> str;
	int count[1000]={0};
	//int length[1000]={0};
	string max_length="";

	string s;
	while(cin >> s){
		int i;
		for(i=0;i<str.size();i++){
			if(str[i]==s){
				count[i]++;
				break;
			}
		}
		if(i>=str.size()){
			str.push_back(s);
			if(s.size()>max_length.size()){
				max_length = s;
			}
		}
	}
	/*
	for(int i=0;i<str.size();i++){
		cout << str[i] <<" ";
	}
	cout <<endl;
	*/
	int max = 0;
	for(int i=0;i<str.size();i++){
		if(count[i]>max){
			max=i;
		}
	}
	cout << str[max] << " " << max_length << endl;
	
	return 0;
}

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

int main()
{
  std::map<std::string,int> count;
  std::string run;
  int maxlen=0;
  std::string maxstr;
  while(std::cin>>run)
  {
    if(run.size()>maxlen)
    {
      maxlen = run.size();
      maxstr = run;
    }
    if(count.find(run)!=count.end())
      ++count[run];
    else
      count[run]=0;
  }
  std::map<int,std::string> rcount;
  std::map<std::string, int>::iterator itr;
  for(itr=count.begin();itr!=count.end();++itr)
    rcount.insert(std::pair<int,std::string>(itr->second,itr->first));
  std::map<int,std::string>::iterator print=rcount.end();;
  std::cout<<(--print)->second<<" "<<maxstr<<std::endl;
  return 0;
}

C++: #include<iostream>
#include<cstring>
using namespace std;
main(){
  char str[10005][40];
  char cp[100];
  int max=0;
  int mpos=0;
  int saihin=1;
  int spos=0;
  int i=0;
  int ruiseki=1;
  while(cin>>str[i]){
    i++;
  }
  for(int j=0;j<i-1;j++){
    for(int k=i-1;k>j;k--){
      if(strcmp(str[k],str[k-1])<0){
	strcpy(cp,str[k]);
	strcpy(str[k],str[k-1]);
	strcpy(str[k-1],cp);
      }
    }
  }
  for(int j=1;j<i;j++){
    if(strlen(str[j])>max){
      max=strlen(str[j]);
      mpos=j;
    }
    if(strcmp(str[j],str[j-1])==0){
      ruiseki++;
    }
    else{
      ruiseki=1;
    }
    if(ruiseki>saihin){
      saihin=ruiseki;
      spos=j;
    }
  }
  cout<<str[spos]<<" "<<str[mpos]<<endl;
}

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

using namespace std;

const int M = 33;
const int N = 3001;

char text[N];
char word[N][N];
char tmp[N], ansm[N], ansl[N]; 

int cmp(const void *a, const void *b) {
	return strcmp((char *)a, (char *)b);
}

void solve(char text[]) {
	int len = strlen(text);
	for (int i=0; i<len; ++i) {
		if (text[i] >= 'A' && text[i] <= 'Z') text[i] = text[i] - 'A' + 'a';
	}
	int j = 0, k = 0;
	for (int i=0; i<len; ++i) {//分解文章 
		if (text[i] != ' ') word[k][j++] = text[i];
		else {
			if (j == 0) continue;
			word[k++][j] = '\0', j = 0;
		}
	}
	if (j) word[k++][j] = '\0';
	qsort(word, k, sizeof(word[0]), cmp);
	int maxs = -1;
	int cnt = 1;
	strcpy(tmp, word[0]);
	strcpy(ansl, word[0]);
	int maxl = strlen(word[0]);
	for (int i=1; i<k; ++i) {
		if (maxl < strlen(word[i])) maxl = strlen(word[i]), strcpy(ansl, word[i]);
		if (!strcmp(tmp, word[i])) ++cnt;
		else {
			if (maxs < cnt) {
				maxs = cnt;
				strcpy(ansm, tmp);
			}
			strcpy(tmp, word[i]);
		}
	}
	if (maxs < cnt) strcpy(ansm, tmp);
}

int main() {
	cin.getline(text, N, '\n');
//	while (cin.getline(text, N, '\n')) {
		solve(text);
		cout<<ansm<<" "<<ansl<<endl;
//	}
	return 0;
}