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 <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cstdint>

typedef std::map<std::string, std::uint32_t> OccurenceWordMap;

class compare_second {
		typedef OccurenceWordMap::value_type value_type;
	public:
		bool operator()(value_type const& lhs, value_type const& rhs) const
		{
			return lhs.second < rhs.second;
		}
};

class compare_length {
		typedef std::string value_type;
	public:
		bool operator()(value_type const& lhs, value_type const& rhs) const
		{
			return lhs.length() < rhs.length();
		}
};

int main()
{
	std::string input_text;
	std::getline(std::cin, input_text);
	typedef std::vector<std::string> StringVec;
	StringVec word_vec;
	std::string::size_type pos1 = 0;
	std::string::size_type pos2;
	while ((pos2 = input_text.find(' ', pos1)) != std::string::npos) {
		word_vec.push_back(input_text.substr(pos1, pos2 - pos1));
		pos1 = pos2 + 1;
	}
	word_vec.push_back(input_text.substr(pos1, input_text.size() - pos1));
	OccurenceWordMap ow_map;
	for (std::string const& word : word_vec) {
		auto i = ow_map.lower_bound(word);
		if (i != ow_map.end() && !(ow_map.key_comp()(word, i->first))) {
			++i->second;
		}
		else {
			ow_map.emplace(word, 0);
		}
	}
	std::cout << std::max_element(ow_map.begin(), ow_map.end(), compare_second())->first << ' '
			  << *std::max_element(word_vec.begin(), word_vec.end(),  compare_length()) << std::endl;
	return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(){
	string str, longest, s, most;
	int m=0, count=0;
	vector<string> vs;
	vector<int>vi;
	getline(cin, str);
	for(int i=0; i<str.length(); i++){
		if(str[i]!=' ' && str[i]!='\n'){
			s+=str[i];
		}
		else{
			vs.push_back(s);
			if(s.length()>m){
				m=s.length();
				longest=s;
			}
			s="";
		}
	}
	if(s.length()>m){
		m=s.length();
		longest=s;
	}
	m=0;
	for(int i=0; i<vs.size()-1; i++){
		count=0;
		for(int j=i+1; j<vs.size(); j++){
			if(vs[i]==vs[j])
				count++;
		}
		if(count>m){
			m=count;
			most=vs[i];
		}
	}
	cout<<most<<" "<<longest<<endl;
	return 0;
}

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

int main(void){
  string s;
  getline(cin,s);
  string n;
  string maxs;
  string longs ="";
  int maxv;
  vector<string> ss;
  vector<int> ii;
  s += " ";
  for(int i = 0 ; i < s.size() ; i ++){
    if(s[i] == ' '){
      if(!ss.size()){
	maxv = 0;
	maxs = n;
      }
      if(longs.size() < n.size()){
	longs = n;
	//cout<<n<<endl;
      }
      bool used = false;
      for(int i = 0 ; i < ss.size() ; i ++){
	if(n == ss[i]){
	  ii[i] ++;
	  if(maxv < ii[i]){
	    maxv = ii[i];
	    maxs = n;
	  }
	  used = true;
	  break;
	}
      }
      if(!used){
	ii.push_back(1);
	ss.push_back(n);
      }
      n = "";
    }else{
      n += s[i];
    }
  }
  cout<<maxs<<" "<<longs<<endl;
}

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

int main(void) {
  string mcs;
  int maxlength;
  string mls;
  map<string, int> index;
  string s;
  int flag;
  flag = 0;
  maxlength = -1;
  while(cin >> s) {
    index[s]++;
    if((int)s.length() > maxlength) {
      maxlength = s.length();
      mls = s;
    }
    if(flag) {
      if(index[s] > index[mcs]) {
	mcs = s;
      }
    }else {
      mcs = s;
      flag = 1;
    }
  }
  cout << mcs << " " << mls << endl;

  return 0;
}

C++: #include<stdio.h>
#include <string.h>
int main(){
	int i,n=0,q=0,c[500],a=0,b=0;
	char s[1000],t[500][32],*p;
	fgets(s,1024,stdin);
	while(1){
		p=strchr(s+q,' ');
		if(!p)
			p=s+strlen(s)-1;
		strncpy(t[n],s+q,p-s-q);
		for(i=0;i<n;i++)
			if(strcmp(t[i],t[n])==0){
				c[i]++;
				break;
			}
			if(i==n){ 
				c[i]=1;
				n++; 
			}
			q=p-s+1;
			if(p==s+strlen(s)-1) 
				break;
	}  
	for(i=1;i<n;i++){
		if(c[i]>c[a])  
			a=i; 
		if(strlen(t[i])>strlen(t[b]))    
			b=i; 
	} 
	printf("%s %s\n",t[a],t[b]); 
	return 0;
}

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

int main(void){
  map<string,int>m;
  map<string,int>::iterator it,cit,sit;
  string s;
  int maxS=0,maxC=0;
  while(cin >>s){
    m[s]+=1;
  }
  for(it=m.begin();it!=m.end();it++){
    int size=(*it).first.size();
    if(size>maxS){
      sit=it;
      maxS=size;
    }
    int cou=(*it).second;
    if(cou>maxC){
      cit=it;
      maxC=cou;
    }
  }

  /*
 for(it=m.begin();it!=m.end();it++){
   cout <<(*it).first.size() <<" "<<(*it).second<<endl;
  }
  */
  cout <<(*cit).first <<" "<<(*sit).first<<endl;
}

C++: #include<iostream>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<functional>
using namespace std;
int main() {
	vector<pair<int,string>> x(1000);
	string a;
	int j=1,s=0,m=0;
	while(cin >> a) {
		for (int i = 0; i <j ; i++) {
			if (x[i].second == a) {
				x[i].first++;
				break;
			}
			if (i == j - 1) {
				x[i].second = a;
				x[i].first = 1;
				j++;
				break;
			}
		}
	}
	sort(x.begin(), x.end(), greater<pair<int, string>>());
	for (int i = 0; i < j; i++) {
		if (x[i].second.size() > s) {
			s = x[i].second.size();
		}
	}
	for (int i = 0; i < j; i++) {
		if (x[i].first > m) {
			m = x[i].first;
		}
	}
	for (int i = 0; i < j; i++) {
		if (x[i].first == m) {
			cout << x[i].second << ' ';
		}
	}
	for (int i = 0; i < j; i++) {
		if (x[i].second.size() == s) {
			cout << x[i].second << endl;
		}
	}
	return 0;
}

C++: //
//  main.cpp
//  kazane
//
//  Created by h3036136 on 2017/07/27.
//  Copyright ?? 2017??´ h3036136. All rights reserved.
#include <iostream>
#include <string>
using namespace std;
int main(){
    long saidai=0;
    //char f;
    int a=0,cnt=0,num=0,max=0;
    string str,tango[1000]={""},answer,ans;
    getline(cin,str);
    for(int i=0;i<str.size();i++){
        if(str[i]==' '){
            for(int j=a;j<i;j++){
                /*if(isupper(str[j])){
                    f=str[j];
                    f=f+32;
                    str[j]=f;
                }*/
                tango[cnt]+=str[j];
            }
            cnt=cnt+1;
            a=i+1;
        }
    }
    for(int p=a;p<str.size();p++){
        tango[cnt]+=str[p];
    }
    
    for(int k=0;k<1000;k++){
        if((tango[k]==""))break;
        if(saidai<tango[k].size()){
            saidai=tango[k].size();
            ans=tango[k];
        }
    }
    
    for(int s=0;s<=cnt;s++){
        for(int t=s+1;t<=cnt;t++){
            if(tango[s]==tango[t]){
                num=num+1;
            }
        }
        if(max<num){
            max=num;
            answer=tango[s];
        }
    }
    cout<<max<<" "<<saidai<<endl;
    cout<<answer<<" "<<ans<<endl;
    return 0;
}

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

int main(){
  int m=0,f=0;
  multiset<string> a;
  string s,ms,mf;
  while(cin>>s){
    if(m<s.size())ms=s;m=s.size();
    if(f<a.count(s)+1)mf=s;f=a.count(s)+1;a.insert(s);
  }
  cout<<mf<<" "<<ms<<endl;
  return 0;
}