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<stdio.h>
#include<math.h>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
int main(){
	int i,i1,len,len1,check,max1,memo1,max2,memo2;
	max1 = 0;
	max2 = 0;
	memo1 = 0;
	memo2 = 0;
	string t;
	vector<string> s;
	vector<int> a,u;
	for (int h = 0; h < 500; h++) {
		u.push_back(0);
	}
	while (cin >> t) {
		check = 0;
		len = s.size();
		for (i = 0; i < len; i++) {
			if (t == s[i]) {
				u[i] += 1;
				check = 1;
			}
		}
		if (check == 0) {
			s.push_back(t);
			len1 = t.size();
			a.push_back(len1);
		}
	}
	len = s.size();
	for (i1 = 0; i1 < len; i1++) {
		if (max1 < u[i1]) {
			max1 = u[i1];
			memo1 = i1;
		}
		if (max2 < a[i1]) {
			max2 = u[i1];
			memo2 = i1;
		}
	}
	cout << s[memo1] << " " << s[memo2] << endl;
	return 0;
}

C++: #include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string.h>
#include <queue>
#include <string>
#include <stack>
#include <utility>
#include <queue>
#include <cmath>
#define mp make_pair
#define pii pair<int,int> 
#define ff first
#define ss second
#define ll long long 
#define vi vector<int>

using namespace std;

int counts[1000];
char str[1000][1000];
int maxl,i,indexml,indexma;

int main()
{
	maxl=0;
	indexml=0;
	indexma=0;
	i=0;
	memset(counts, 0, sizeof(counts));
	while(scanf("%s",str[i])!=EOF)
	{
		if(maxl<strlen(str[i]))
		{
			maxl=strlen(str[i]);
			indexml=i;
		}
		for(int z=0;z<=i;z++)
		{
			if(strcmp(str[i],str[z])==0)
			{
				counts[z]++;
				i--;
				break;
			}
		}
		i++;
	}
	for(int c=0;c<i;c++)
	{
		if(counts[indexma]<counts[c])
		indexma=c;
	}
	printf("%s %s\n",str[indexma],str[indexml]);
	return 0;
}

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;
}