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 <map>
#include <string>
#include <sstream>


using namespace std;


int main (int argc, char const* argv[]){
    int n;
    map<string, int> words;
    string sentence, word;
    int max=0, min = 0;
    string maxFreq, maxWord; //最多頻度単語, 最長単語
    
    //文章取得
    getline(cin,sentence);
    stringstream ss(sentence);
    
    while(getline(ss,word,' ')){
        //words内にwordが既に存在するならインクリメント
        if(words.find(word) != words.end()) {
            words[word] += 1;
        }
        //words内にwordがまだ存在しない場合に新たに挿入する
        else{
            words.insert(map<string, int>::value_type(word,1));
        }
    }
    
    
    //最多出現頻度の単語を探す
    map<string, int>::iterator it = words.begin();
    while(it != words.end()){
        if(max < (*it).second){
            max = (*it).second;
            maxFreq = (*it).first;
        }
        if(min < (*it).first.size()){
            min = (*it).first.size();
            maxWord = (*it).first;
        } 
        it++;
    }
    
    
    
    //最多頻度単語と最長単語の出力
    cout <<  maxFreq << " " << maxWord <<  endl;
    
    return 0;
}

C++: #include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<stdio.h>
#include<queue>
#include <climits>
#include <map>
#include <set>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int mod = 1e9 + 7;
const long long INF = 1LL << 60;

int main() 
{
    string s;
    pair<string,int> p;
    vector<string> v;
    vector<string> u;
    while(cin >> s){
        v.push_back(s);
        bool e = true;
        for(int i = 0; i < u.size(); i++){
            if(u[i] == s){
                e = false;
            }
        }
        if(e) u.push_back(s);
    }
    int n = u.size();

    int cnt[n];
    for(int i = 0; i < n; i++){
        cnt[i] = 0;
    }
    int l = 0;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < v.size(); j++){
            if(u[i] == v[j]){
                cnt[i]++;
            }
            int m = v[j].size();
            l = max(l,m);
        }
    }
    int k = 0;
    for(int i = 0; i < n; i++){
        k = max(k,cnt[i]);
    }
    for(int i = 0; i < n; i++){
        if(cnt[i] == k){
            cout << u[i] << ' ';
        }
    }
    for(int i = 0; i < n; i++){
        if(u[i].size() == l){
            cout << u[i] << endl;
        }
    }
}

C++: #include<iostream>
#include<string>
using namespace std;
string a,b[1000],d;
int c[1000];
int main(){
	int top=0;
	d=" ";
	while(cin>>a){
		if(a.size()>=d.size())
			d=a;
		bool t=true;
		for(int i=0;i<top;i++){
			if(b[i]==a){
				t=false;
				c[i]++;
			}
		}
		if(t==true){
			b[top]=a;
			c[top]=1;
			top++;
		}
	}
	int best=0,set;
	for(int i=0;i<top;i++){
		if(c[i]>best)
			set=i;
	}
	cout<<b[set]<<" "<<d<<endl;
	return 0;
}

C++: #include<iostream>

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;

  std::cin >> str;
  maxlen = str;
  maxocc = str;

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

  std::cout << maxlen << std::endl;
}

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

int main() {
	string sp,st,hw,ew;
	map<string,int> sd;
	int s=0,e=0,k=0,h=0,m=0;
    getline(cin,st);
	st=st+"  ";
	while(e!=st.size()) {
	 for(e; st[e]!=' ' ;e++);
	 sp.append(st,s,e-s);
	 if (sp.length()>h) { h=sp.length(); hw=sp; }
	 if (sd.find(sp)==sd.end()) sd.insert(map<string,int>::value_type(sp,1));
	 else {sd[sp]++ ; if (sd[sp]>m) m=sd[sp]; }
	 e++; s=e; sp=""; 
	}
	map<string,int>::iterator it=sd.begin();
	for (h=0;it!=sd.end();it++) if (h<(*it).second) { h=(*it).second; ew=(*it).first;}
	cout << ew << " " << hw << endl;
	return 0;
}

C++: #include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <math.h>
#include <functional>
#include <algorithm>
#include <utility>

typedef long long Int;
#define REP(i,n) for(int i = 0 ; i < n ; ++i)
using namespace std;


map<string, int> aa;
set<string> dic;

int main(){
	string a;

	while (cin >> a){
		dic.insert(a);
		++aa[a];
	}

	int m = 0;
	string ms;

	int m2 = 0;
	string ms2;


	for (auto x : dic){
		if (m < x.length()){
			m = x.length();
			ms = x;
		}
	}

	for (auto x : aa){
		if (m2 < x.second){
			ms2 = x.first;
			m2 = x.second;
		}
	}

	cout << ms << " " << ms2 << endl;

	return 0;
}

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

int main(){
  map< string, int > m;
  string tmp;
  string max_len = "";

  while(cin >> tmp){
    m[tmp] += 1;
    if(max_len.length() < tmp.length()) max_len = tmp;
  }

  map< string, int >::iterator it, it_max_fre = m.begin();
  for(it = m.begin(); it != m.end(); it++){
    if(it_max_fre->second < it->second) it_max_fre = it;
  }

  cout << it_max_fre->first << " " << max_len << endl;
}

C++: #include <string.h>
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>
#include <utility>

#define ll (long lon
#define REP(i,n) for(int i = 0;i<(int)n;i++)
#define FOR(i,a,b) for(int i = (a);i < (b);i++)
#define RFOR(i,a,b) for(int i = (a);i>(b);i--)
#define INT_MIN_A -999999

using namespace std;

int main (void){
    
    char str[2001];
    gets(str);
    char tango[1000][33];
    int i = 0,j = 0,k = 0,l = 0, temp = 0,m = 0;
    int max_l = INT_MIN_A;
    int max_numer = 0;
    int yokuderu = 0;
    int yokuderu_temp = 0;
    int yokuderu_number = 0;
    while(str[i++] != '\0')
    {
        if(str[i-1] == ' ')
        {
            if((i-1)-temp>max_l)
            {
                max_l = (i-1) -temp;
                max_numer = j;
            }
            while(temp<i-1)
                tango[j][l++] = str[temp++];
            temp = i;
            j++;
            l = 0;
        }
    }
    
 
        if((i-1)-temp>max_l)
        {
            max_l = (i-1) -temp;
            max_numer = j;
        }
        while(temp<i-1)
            tango[j][l++] = str[temp++];
        temp = i;
        j++;
        l = 0;
    /*???????????§??????????????????*/
    //cout <<"number is " << j << endl;
    
    for(int m = 0; m < j;m++)
    {
        for(int k = 0; k<j;k++)
        {
            if(m != k)
            {
                if(strcmp(tango[m], tango[k]) == 0)
                {
                    yokuderu_temp++;
                }
            }
        }
        if(yokuderu_temp >= yokuderu)
        {
            yokuderu = yokuderu_temp;
            yokuderu_number = m;
        }
        yokuderu_temp = 0;
    }
    cout << tango[yokuderu_number] << " " << tango[max_numer] << endl;
    return 0;
}

C++: #include<iostream>
#include<cstdio>
#include<string>
#include<map>
using namespace std;
int main(){
  map<string,int> t;
  string s, mxc, mxl;
  int freq = 0, len = 0;
  while(cin >> s){
    if(t.find(s) == t.end()){
      t[s] = 1;
    }
    else{
      t[s]++;
    }

    if(t[s] > freq){
      freq = t[s];
      mxc = s;
    }
    if(s.size() > len){
      len = s.size();
      mxl = s;
    }
  }
  cout << mxc << " " << mxl << endl;
}