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 <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define pb         push_back
#define mp         make_pair
#define ll         long long
#define PI         acos(-1.0)
#define ALL(A)     ((A).begin(), (A).end())
#define vsort(v)   sort(v.begin(),v.end())
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)


int main(){
    int i, j, times=0;
    string tmp,maxLength,maxTimes;
    map<string, int> sentences;
    maxLength=""
    while(cin>>tmp){
        if(tmp.length()>maxLength.length()){
            maxLength=tmp;
        }
        if(sentences.count(tmp)==0){
            sentences.insert(map<string,int>::value_type(tmp,1));
        }else{
            sentences[tmp]++;
        }
        if(sentences[tmp]>times){
            times=sentences[tmp];
            maxTimes=tmp;
        }
    }
    cout << maxTimes << maxLength << endl;
}

C++: #include<bits/stdc++.h>
using namespace std;
int main()
{
    int sen=0,maxe[2]={0,0},lo=0;
    string str[1000],s;
    while(cin>>s){
        lo=s.size();
        if(maxe[0]<lo){
            maxe[0]=lo;
            maxe[1]=sen;
        }
        str[sen]=s;
        sen++;
    }
    int co=-1,num;
    for(int i=0;i<=sen;i++){
        int cou=0;
        for(int j=i;j<=sen;j++)if(str[i]==str[j])cou++;
        if(co<=cou){
            co=cou;
            num=i;
        }
    }
    cout<<str[num]<<" "<<str[maxe[1]]<<endl;
}

C++: #include<iostream>
#include<algorithm>
#include<map>
using namespace std;
string str,ans="",ans2="";
map < string,int > tab;
int main(){
  while(cin>>str){
    if(str.size()>ans2.size())ans2=str;
    tab[str]++;
    if(tab[ans]<tab[str])ans=str;
  }
  cout<<ans<<' '<<ans2<<endl;
  return 0;
}

C++: #if 0
#endif

#include <iostream>
#include <string>
#include <map>
using namespace std;
map<string, int> table;
int main()
{
    string /*入力用*/ word, /*最大頻度*/ frequent, /*最長*/ longest;
    size_t N = 0; /*文字列frequentの頻度*/
    while (cin >> word)
    {
        // table[word]を一つ増やす
        table[word] += 1;
        // table[word]がNより大きければ，Nとfrequentを更新
        if (table[word] > N)
        {
            N = table[word];
            frequent = word;
        }
        // word.size() > longest.size() ならlongest を更新
        if (word.size() > longest.size())
        {
            longest = word;
        }
    }
    //frequent と longest を出力
    cout << frequent << ' ' << longest << endl;
}

C++: #include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define pb         push_back
#define mp         make_pair
#define ll         long long
#define PI         acos(-1.0)
#define ALL(A)     ((A).begin(), (A).end())
#define vsort(v)   sort(v.begin(),v.end())
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)


int main(){
    int i, j, lmax=0, lind=0, nmax=0, nind=0, cnt=0, vsize;
    string s,vv;
    vector<string> v;
    while(cin>>s){
        v.pb(s);
    }
    for(i=0;i<int(v.size());i++){
        cnt=0;
        vv=v[i];
        for(j=0;j<int(vv.size());j++){
            if(v[i]==v[j]){
                cnt++;
            }
        }
        if(nmax<cnt){
            nmax=max(cnt,nmax);
            nind=i;
        }
        if(lmax<int(vv.size())){
            lmax=max(lmax,int(vv.size()));
            lind=i;
        }
    }
    cout << v[lind] << v[nind] << endl;
}

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

//文章が与えられた時、出現頻度の高い単語と最長の単語を出力するもの。
//文章に現れる単語リストを作ってそれぞれの文字列をカウントすればよい。

int main(){
	string sentence[1000];
	int sentenceNum[1000];
	int array[1000];
	string input;
	int count = 0;
	bool flag; //単語リストから単語が見つかったどうか
	int maxLength = 0;

	for(int i=0; i < 1000; i++) sentenceNum[i] = 0;

	while(cin >> input){
		flag = false;

		//count == 0 文頭の単語の処理
		if(!count){
			sentence[0] = input;
			sentenceNum[0]++;
			count++;
			int inputSize = input.size();
			maxLength = max(maxLength, inputSize);
		}

		//文頭でない場合
		else {
			for(int i=0; i < count; i++){
				if(sentence[i] == input){
					sentenceNum[i]++;
					flag = true;
					break;
				}
			}
			if(!flag){
				sentence[count] = input;
				sentenceNum[count]++;
				count++;
				int inputSize = input.size();
				maxLength = max(maxLength, inputSize);
			}
		}
	}

	for(int i=0; i < 1000; i++) array[i] = sentenceNum[i];

	sort(array, array+1000, greater<int>());

	for(int i=0; i< count; i++){
		if(array[0] == sentenceNum[i]){
			cout << sentence[i];
		}
	}
	for(int i=0; i< count; i++){
		int sentenceSize = sentence[i].size();
		if(maxLength == sentenceSize){
			cout << " " << sentence[i] << endl;
		}
	}
}

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

int main()
{
    map<string, int> dict;
    string s, max_s, max_e_s;
    int max_length = 0, max_emerge = 0;
    while (cin >> s)
    {
        dict[s]++;
        if (s.size() > max_length)
        {
            max_length = s.size();
            max_s = s;
        }
    }
    for (auto t = dict.begin(); t != dict.end(); t++)
    {
        if (t->second > max_emerge)
        {
            max_emerge = t->second;
            max_e_s = t->first;
        }
    }
    cout << max_e_s << " " << max_s << endl;
    return 0;
}

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

using namespace std;

int main(){
	string s;
	string word[500];
	int a[500]={};
	int i,j,k,l;
	int n,m,len;
	i=0;
	while(cin>>s){
		if(i==0){	//????????????????????????
			word[0]=s;
			a[0]++;
			i++;
			len=s.size();
			n=0;
		}
		else {
			if(len<s.size()){	//?????????????????????????????°??´??°
				len=s.size();
				n=i;
			}
			for(j=0; j<i; j++){
				if(s==word[j]){	//?????§????????????????????????
					a[j]++;
					break;
				}
				if(j==i-1){			//??°?????????????????????
					word[i]=s;
					a[i]++;
					i++;
					break;
				}
			}
		}
	}
	m=0;
	for(j=0; j<i; j++){		//????????????????????????????????????
		if(m<a[j]){
			m=a[j];
			l=j;
			//cout<<l<<" "<<a[j]<<endl;
		}
	}
	cout<<word[l]<<" "<<word[n]<<endl;
	// for(j=0; j<i; j++){
	// 	cout<<word[j]<<":"<<a[j]<<endl;
	// }
	//cout<<m<<endl;
	//cout<<"len:"<<len<<" "<<word[n]<<endl;
	return 0;
}

C++: #include <stddef.h>
#include <iostream>
#include <map>
#include <string>
#include <utility>
using namespace std;
int main() {
  map<string, int> word;
  string s, s1 = "", s2 = "";
  int a = 0;
  size_t b = 0;
  while (cin >> s)
    word[s]++;
  for (auto e : word) {
    if (a < e.second) {
      s1 = e.first;
      a = e.second;
    }
    if (b < e.first.size()) {
      s2 = e.first;
      b = e.first.size();
    }
  }
  cout << s1 << ' ' << s2 << endl;
  return 0;
}