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;

typedef pair<int, int> Pii;
typedef pair<string, string> Pss;

map <string, Pii> dic;

int main() {
  string str;
  Pss result;
  while ( cin >> str ) {
    dic[str].first++;
    dic[str].second = str.size();

    if ( dic[result.first].first < dic[str].first ) result.first = str;
    if ( dic[result.second].second < dic[str].second ) result.second = str;

  }

  cout << result.first << " " << result.second << endl;
  return 0;
}

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

map<string, int > hindo;

int main()
{
  string str;
  while (cin >> str) {
    hindo[str]++;
  }
  int mx = 0, mx_l = 0;
  for (map<string, int>::iterator it = hindo.begin(); it != hindo.end(); it++) {
    mx = max(it->second, mx);
    mx_l = max(mx_l, (int)it->first.size());
  }
  for (map<string, int>::iterator it = hindo.begin(); it != hindo.end(); it++) {
    if (mx == it->second) {
      cout << it->first << " ";
    }
  }
  for (map<string, int>::iterator it = hindo.begin(); it != hindo.end(); it++) {
    if (mx_l == it->first.size()) {
      cout << it->first << endl;
    }
  }
  return 0;
}

C++: #include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(){
string in[1000];
int max=0;
string ml_str;
int tmp;
string ans;
int i=0;
for(i=0;cin>>in[i];i++){
if(in[i].size()>max){
max=in[i].size();
ml_str=in[i];
}
}
sort(in,in+i);
tmp=1;
max=0;
for(int j=1;j<i;j++){
if(in[j]==in[j-1]){
tmp++;
}else{
if(max<tmp){
max=tmp;
ans=in[j-1];
tmp=1;
}
}
}
cout<<ans<<" "<<ml_str<<endl;
}

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

struct P {
  string s;
  int n;
};

int main(){
  vector<P> v;
  string s,d="";
  P p;
  int f=0, l=0;

  getline( cin,s );
  //  cout << "input : "<< s << endl;

  for( unsigned int i=0;i<s.length();i++ ){
    if( s[i]==' ' || i==s.length()-1 ){
      if( s[i]!=' ' ) d += s[i];
      p.s = d;

      //      cout << d << endl;
      unsigned int j;
      for( j=0;j<v.size();j++ ){
	if( v[j].s==d ){
	  v[j].n++;
	  f = max( f,v[j].n ); break;
	}
      }
      if( j==v.size() ){
	p.s = d; p.n=1;
	v.push_back( p );
	l = max( l,(int)d.length() );
      }
      d="";
    }else{
      d = d + s[i];
    }
  }

  for( unsigned int i=0;i<v.size();i++ ){
    if( v[i].n==f ){
      cout << v[i].s << " "; break;
    }
  }
  for( unsigned int i=0;i<v.size();i++ ){
    if( (int)v[i].s.length()==l ){
      cout << v[i].s << endl; break;
    }
  }

  return 0;
}

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

using namespace std;

const int M = 33;
const int N = 1001;

char text[N];
char word[M][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() {
	while (cin.getline(text, N, '\n')) {
		solve(text);
		cout<<ansm<<" "<<ansl<<endl;
	}
	return 0;
}

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

using namespace std;

int main(void){
    int i,j,k=0,l;
    int f=0;
    string str;
    string max="\0";
    int count[100]={0};
    string count_str[100];
    int count_max=0;
    
    while(cin>>str){
        if(max.size()<str.size()){
            max=str;
        }
        for(i=0;i<k;i++){
            if(count_str[i]==str){
                count[i]++;
                f=1;
                break;
            }
        }
        if(f==0){
            count_str[k]=str;
            k++;
        }
    }
    
    for(i=0;i<k;i++){
        if(count[count_max]<=count[i]){
            count_max=i;
        }
    }
    cout<<count_str[count_max]<<" "<<max<<endl;
    return(0);
}

C++: #include<iostream>
#include<string.h>
#include<vector>
#include<algorithm>
#include<map>
using namespace std;
int main()
{
    map<string,int> m;
    string s;
    getline(cin,s);
    string tem="";
    for(int i=0;i<s.length();i++){
        if(s[i]!=' '&&s[i]!='\n')
            tem+=s[i];
        else{
            if(m.find(tem)!=m.end()){
                (m.find(tem))->second++;
            }
            else{
                m.insert(pair<string,int>(tem,1));
            }
            tem="";
        }
    }
    if(m.find(tem)!=m.end()){
        (m.find(tem))->second++;
    }
    else{
        m.insert(pair<string,int>(tem,1));
    }
    string most,longest;
    map<string,int>::iterator it = m.begin();
    int mo=0;
    for(;it!=m.end();it++){
        if(it->first.length()>longest.length())
            longest=it->first;
        if(it->second>mo){
            most=it->first;
            mo=it->second;
        }
     //   cout<<it->first<<"    "<<it->second<<endl;
    }
    cout<<most<<" "<<longest<<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;

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

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

int main(){
	string str;
	string max_len_str;
	string most_many_str;
	int most=-1;
	int i;
	vector<pair<string, int> > v;
	string::iterator vi;
	cin>>str;
	v.push_back(pair<string, int>(str, 0));
	max_len_str == v[0].first;
	while(cin>>str){
		for(i=0;i<v.size();i++){
			if(v[i].first == str){
				v[i].second++;
				break;
			}
		}
		if(i==v.size()){
			if(max_len_str.size() < strlen(str.c_str())){
				max_len_str = str;
			}
			v.push_back(pair<string, int>(str, 0));
		}
	}
	for(i=0;i<v.size();i++){
		if(most < v[i].second){
			most = v[i].second;
			most_many_str = v[i].first;
		}
	}
	cout << most_many_str << " " << max_len_str << endl;
	
	return 0;
}

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

using namespace std;

int main(void) {
	int n = 0;
	string str, maxi;
	vector<string> v;
	vector<int> mode;

	while (cin >> str) {
		v.push_back(str);
		mode.push_back(1);
		if (str.size() > maxi.size()) {
			maxi = str;
		}
	}
	for (int i = 0; i < v.size(); i++) {
		for (int j = 0; j < v.size(); j++) {
			if (v[i] == v[j] && i != j) {
			 mode[i]++;
			}
		}
	}
	for (int i = 0; i < v.size(); i++) {
		if (mode[n] < mode[i]) {
			n = i;
		}
	}

	cout << v[n] << " " << maxi << endl;
}