Go: package main

import (
	"bufio"
	"os"
	"strings"
	"fmt"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	words := strings.Split(scanner.Text(), " ")
	wordMap := make(map[string]int)
	for _, v := range words {
		wordMap[v]++
	}
	key := ""
	value := -1
	l := -1
	word := ""
	for k, v := range wordMap {
		// fmt.Println(k, v)
		if value < v {
			key = k
			value = v
		}
		if l < len(k) {
			l = len(k)
			word = k
		}
	}

	fmt.Println(key, word)
	// fmt.Println(wordMap)
}

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

int main(){
  string s;
  map<string,int> m;
  while(cin>>s){
    if(m.find(s)==m.end()){
      m[s]=1;
    }else{
      m[s]+=1;
    }
  }
  int max_len=0;
  int max_frequency=0;
  //イテレータに不等号は使えない
  //ポインタなら使えるので勘違いした
  //max_len、max_frequencyにそれぞれペアを入れればfor文を三回回す必要がないかと思ったが、pairの作成に時間がかかるので、三回回しても大して時間はかからないと判断した
  for(auto i=m.begin();i!=m.end();i++){
    max_len=max(max_len,(int)((i->first).length()));//stringのlengthはsize_t型
    max_frequency=max(max_frequency,i->second);
  }
  for(auto i=m.begin();i!=m.end();i++){
    if(i->second==max_frequency){
      cout << i->first << " ";
      break;
    }
  }
  for(auto i=m.begin();i!=m.end();i++){
    if((int)((i->first).length())==max_len){
      cout << i->first << endl;
      break;
    }
  }
}

C++: #include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <set>
using namespace std;
#define rep2(x,from,to) for(int x=(from); x<(to); (x)++)
#define rep(x,to) rep2(x,0,to)
int main() {
	string s;
	vector<string> str1;
	set<string> str2;
	while(cin >> s) {
		str1.push_back(s);
		str2.insert(s);
	}
	int w = 0;
	string ret;
	rep(i,str1.size()) {
		if(w < str1[i].length()) {
			w = str1[i].length();
			ret = str1[i];
		}
	}

	int cnt[1000];
	rep(i,1000) {
		cnt[i] = 0;
	}
	int c = 0;
	for(auto it=str2.begin(); it != str2.end(); ++it) {
		rep(j,str1.size()) {
			if(*it == str1[j]) cnt[c]++;
		}
		c++;
	}
	int max = 0, r = 0;
	string ret2;
	for(auto it=str2.begin(); it != str2.end(); ++it) {
		if(max < cnt[r]) {
			max = cnt[r];
			ret2 = *it;
		}
		r++;
	}
	cout << ret2 << " " << ret<< endl;
	return 0;
}

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

int main() {
	string str[1001], tmp;
	int max_num = 0, max_length = 0, i, max = 1, max_str = 0, a[1001] = {};
	
	while (cin >> tmp) {
		for (i = 0; i < tmp.size(); i++) {
			if ('A' <= tmp[i] && tmp[i] <= 'Z')
				tmp[i] = tmp[i] + 'a' - 'A';
		}

		for (i = 0; i < max; i++) {
			if (str[i] == tmp) {
				a[i]++;
				if (max_str < a[i]) {
					max_str = a[i];
					max_num = i;
				}
				if (tmp.size() > max_length)
					max_length = (int)tmp.size();
				break;
			}
		}
		if (i >= max) {
			str[i-1] = tmp;
			max++;
			a[i - 1]++;
			if (max_str < a[i-1]) {
				max_str = a[i - 1];
				max_num = i - 1;
			}
			if (tmp.size() > max_length)
				max_length = (int)tmp.size();
		}
	}
	cout << str[max_num] << endl;

	for (i = 0; i < max; i++) {
		if ((int)str[i].size() == max_length)
			cout << str[i] << endl;
	}
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
int m;
map<string, int> f;
int main()
{
	string s, t, u;
	int N=0;
	while(cin >> s)
	{
		f[s]++;
		if(f[s]>N)
		{
			N++;
			t=s;
		}
		if(s.size()>u.size())
		{
			u=s;
		}
	}
	cout << t << ' ' << u << endl;
	return 0;
}

C++: #include <iostream>
#include <string>
using namespace std;
int main(){
    long saidai=0;
    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++){
                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]=="0"))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<<answer<<" "<<ans<<endl;
    return 0;
}

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

using namespace std;

int main()
{
	string a;
	string max;
	map<string, int> n;
//	map<int, string>::iterator i;

	max = "";
	while (cin>>a) {
		n[a] ++;
		if ( a.size() > max.size() ) max = a;
	}

	map<string, int>::iterator i = --n.end();
	cout<<(*i).first<<" "<<max<<endl;

	return 0;
}

C++: #include<iostream>
#include<cstring>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdio>
#include<cmath>
#define pb(in,tmp) in.push_back(tmp)
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) loop(i,0,b)
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
using namespace std;
int main(){
string s;
vector<string>a;
vector<int>b,c;
while(cin>>s){
int no=-1;
rep(j,a.size())if(a[j]==s)no=j;
if(no+1)b[no]++;
else{
pb(a,s);
pb(b,0);
pb(c,s.size());
}
}
int m=0,mi=0;
rep(i,b.size())if(m<b[i]){m=b[i];mi=i;}
cout<<a[mi]<<" ";
m=mi=0;
rep(i,c.size())if(m<c[i]){m=c[i];mi=i;}
cout<<a[mi]<<endl;
}

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

int main()
{	
	string s, t;
	map<string, int> p;

	while (cin >> s) {
		transform(s.begin(), s.end(), s.begin(), tolower);
		if (p.find(s) != p.end())
			p[s]++;
		else
			p[s] = 1;

		if (s.size() > t.size())
			t = s;
	}

	int m = 0;

	for (map<string, int>::iterator itr = p.begin(); itr != p.end(); itr++)
		m = max(m, itr->second);

	for (map<string, int>::iterator itr = p.begin(); itr != p.end(); itr++)
		if (itr->second == m)
			cout << itr->first << endl;

	cout << t << endl;

	return 0;
}

C++: #include <iostream>
#include <string>
#include <map>
using namespace std;
map<string,int> table;
int main () {
  string word, frequent, longest;
  size_t N=0; //??????????????????
  while (cin >> word) {
    table[word] += 1;
    if (table[word] > N) {
      N = table[word];
      frequent = word;
    }
    if (word.size() > longest.size()) longest = word;
  }
  cout << frequent << " " << longest << endl;
}

C++: #include<set>
#include<cmath>
#include<stack>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<cstdlib>
#include<numeric>
#include<vector>
#include<ctime>
#include<queue>
#include<list>
#include<map>
#define pi acos(-1)
#define INF 0x7fffffff
#define clr(x)  memset(x,0,sizeof(x));
#define clrto(x,siz,y)  for(int xx=0;xx<=siz;xx++)  x[xx]=y;
#define clrset(x,siz)  for(int xx=0;xx<=siz;xx++)  x[xx]=xx;
#define clrvec(x,siz) for(int xx=0;x<=siz;xx++)  x[xx].clear();
#define fop   freopen("in.txt","r",stdin);freopen("out.txt","w",stdout);
#define myprogram By_135678942570
#define clrcpy(x,siz,y)  for(int xx=0;xx<siz;xx++)  x[xx]=y[xx];
using namespace std;
map<string,int>mp;
main()
{
     string tt;
     string maxstr=" ";
     string maxstr2=" ";
     int maxn=0;
     while(cin>>tt)
     {
         mp[tt]++;
         if(mp[tt]>mp[maxstr])
            maxstr=tt;
         if(tt.size()>maxn)
            maxn=tt.size(),maxstr2=tt;
     }
     cout<<maxstr<<" "<<maxstr2<<endl;
     return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
int main(){
      string s,nmax,gmax;
      map<string,int> m;
      int nm = -1, gm = -1;
      while(cin >> s){
            if(nm < (int)s.length()){
                  nm = (int)s.length();
                  nmax = s;
            }
            if(m.count(s))m[s]++;
            else m[s] = 0;
      }
      for(auto it = m.begin(); it != m.end(); it++){
            if(gm < it->second){
                  gm = it->second;
                  gmax = it->first;
            }
      }
      cout <<gmax<<' '<<nmax<<endl;
}