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<map>
#include<cstring>
#include<cstdio>
using namespace std;
int main()
{
  map<string,int> str;
  string word;
  int big = 0;
  int cnt = 0;
  string keepword;
  string keepstr = "";
  string many = "";
  
  while(!cin.eof()){
    cin >> word;
    string kari(word);
    str[kari]++;
    
    if(cnt < str[kari]){
      cnt = str[kari];
      keepstr = kari;
    }
    
    if(big < word.size()){
      big = word.size();
      keepword = word;
    }
  }
  cout << keepstr << " " << keepword << endl;
}

C++: #include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <string>
using namespace std;

#define rep(i,n) for(int i=0;i<int(n);++i)


string t;
vector < string> st;
int s[1000]={0};
int max1=0;
int max2=0;

int main(){
	while(cin >>t){
		bool flag=true;
		int tmp = t.size();
		max1 = max(max1,tmp );
		rep(i,st.size()){
			if(t == st[i]){
				s[i]++;
				max2 = max(max2,s[i]);
				flag = false;
				break;
			}
		}
		if(flag){
			st.push_back(t);
		}
	}
	rep(i,st.size()){
		if(s[i]==max2){
			cout<<st[i]<<" ";
			break;
		}
	}
	rep(i,st.size()){
		if(st[i].size()==max1){
			cout<<st[i]<<endl;
			break;
		}
	}
	return 0;
}

C++: #include <unordered_map>
#include <iostream>
#include <algorithm>

using namespace std;

int main(){
  unordered_map<string,int> us;
  string s;
  while(cin >> s){
    us[s]++;
  }
  string ans1;
  int times = 0;
  string ans2;
  int length = 0;
  for(auto i : us){
    if(i.second > times){
      ans1 = i.first;
      times = i.second;
    }
    if(i.first.length() > length){
      ans2 = i.first;
      length = i.first.length();
    }
  }
  cout << ans1 << ' ' << ans2 << '\n';
     
}

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

using namespace std;

struct Info {
  string word;
  int length;
  int hist;
};

vector<Info> words;
vector<Info>::iterator it;

void init(string s) {
  string word;
  stringstream ss;

  for (ss << s; !ss.eof();) {
    ss >> word;
    bool flag = false;
    for (it = words.begin(); it != words.end(); it++) {
      if (it->word == word) {
        flag = true;
        it->hist += 1;
      }
    }
    if (!flag) {
      Info info = { word, word.length(), 1 };
      words.push_back(info);
    }
  }
}

string find() {
  string mode = "", max = "";
  int m1 = 0, m2 = 0;
  
  for (it = words.begin(); it != words.end(); it++) {
    if (m1 < it->hist) m1 = it->hist;
    if (m2 < it->length) m2 = it->length;
  }
  
  for (it = words.begin(); it != words.end(); it++) {
    if (m1 == it->hist) mode = it->word;
    if (m2 == it->length) max = it->word;
  }

  return mode + " " + max;
}

int main() {
  string line, r;

  getline(cin, line);
  init(line);
  r = find();

  cout << r << endl;

  return 0;
}

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

int main(void){

  int max_size=0,max_cnt=0;
  string word,result_cnt,result_size;
  map<string , int> word_cnt;

  while(cin >> word){

    cout << word << endl;
    if(word_cnt.find(word) != word_cnt.end()){
      word_cnt[word]++;      
    }else{
      int tmp = 1;
      word_cnt.insert(make_pair(word,tmp));
    }
  }

    for (map<string,int>::iterator ite=word_cnt.begin(); ite!=word_cnt.end(); ite++){
      if(max_cnt <  ite->second){
	//max_cnt = ite->second;
	result_cnt = ite->first;
      }
      string w = ite->first;
      int w_size = w.size();
      if(max_size < w_size){
	max_size = w_size;
	result_size = ite->first;
      }
    }

    cout << result_cnt << ' ' << result_size << 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,t;
    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[a])){
                    f=str[a];
                    f=f+32;
                    str[a]=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<=cnt;k++){
        if(saidai<tango[k].size()){
            saidai=tango[k].size();
            ans=tango[k];
        }
    }
    
    for(int s=0;s<cnt;s++){
        for(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 <string>
#include <map>
#include <vector>
using namespace std;

int main(){
	// word[s] Å ¶ñsÌo»ñªÔÁÄ­é
	map<string, int> word;
	vector<string> v;
	string s;
	int max=0,length=0;

	while( cin >> s ){
		v.push_back(s);
		
		//üÍµ½Pêª·ÅÉ é©T·
		if( word.count(s) ){
			word[s]++;
		}else{
			word[s] = 1;
		}
	}
	// ÅpoÌPêð²×é
	int mode=0;
	for(int i=0 ; i < v.size() ; i++ ){
		mode = max( mode , word[ v[i] ] );
	}
	for(int i=0 ; i < v.size() ; i++ ){
		if( mode == word[ v[i] ] ){
			cout << v[i];
		}
	}
	// Å·ÌPêðßé
	int length = 0;
	for(int i=0 ; i < v.size() ; i++ ){
		length = max( length , v[i].size() );
	}
	for(int i=0 ; i < v.size() ; i++ ){
		if( length == v[i].size() ){
			cout << " " << v[i] << endl;
		}
	}
}

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

using namespace std;

string s1, s2;
int maxlen = 0, mode = 0;
map<string,int> mp;

int main()
{   
    int m = 9;
    while( cin >> s2 )
    {
        if( s2 == "\n" )break;
        mp[s2]++;
    }
    for( auto x : mp )
    {
        if( maxlen < sizeof( x.first ) )
        {
            maxlen = sizeof( x.first ); 
        } 
        if( mode < x.second )
        {
            mode = x.second;
        }
        printf( "%d", x.second );
    }

    for( auto x : mp )
    {
        if( maxlen == sizeof( x.first ) )
        {
            printf( "%s", x.first );
        }
        if( mode == x.second )
        {
            printf( "%s ", x.first );
        }
    }
    return 0;
}

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

int main()
{
	int longest=0;
	string str,tmp="",freq="";
	vector<string> strs;
	map<string,int> m;
	
	getline(cin,str);

	for(int i=0;i<str.size(); ++i){
		if((str[i] != ' ' )&&(i != str.size()-1)){
			tmp += str[i];
		}else{
			strs.push_back(tmp);
			tmp = "";
		}
	}
	
	for(int i=0;i<strs.size();++i){
		if(strs[i].size() > strs[longest].size())
			longest = i;
		
		bool flag = false;
		for(map<string,int>::iterator it = m.begin();it != m.end();++it){
			if(strs[i] == it->first){
				flag == true;
				it->second++;
			}
		}
		if(flag == false)
			m.insert(make_pair<string,int>(strs[i],0));
	}

	for(map<string,int>::iterator it = m.begin();it != m.end();++it){
		if(it->second > freq.size())
			freq = it->first;
	}
	
	cout << freq << " " << strs[longest] << endl;
	
	return 0;
}