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 <cstdio>
#include <vector>
#include <algorithm>
#include <cstring>
#include <string>
#include <cctype>
#include <sstream>
#include <cmath>
#include <climits>
#include <map>

using namespace std;

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

typedef vector<int> vi;

int main()
{
	map<string, int> m;
	string best;
	string longest;
	
	char word[33];
	while(scanf("%s", word) != EOF){
		string s(word);
		if(m.count(s))
			m[s]++;
		else
			m[s] = 1;

		if(m[best] < m[s])
			best = s;
		if(longest.size() < s.size())
			longest = s;
	}
	printf("%s %s\n", best.c_str(), longest.c_str());

	return 0;
}

C++: #include <iostream>
#include <map>
using namespace std;
#define F first
#define S second
int main(){
    string s,ans,lon;
    map<string,int>m;
    int top=0;
    while(cin>>s){
        m[s]++;
        if(s.size()>lon.size())lon=s;
    }
    for(pair<string,int> i:m){
        if(i.S>top){
            top=i.S;
            ans=i.F;
        }
    }
    cout<<ans<<' '<<lon<<endl;
}

C++: #include<iostream>
#include<string>
#include<map>
#include<cctype>
using namespace std;
int main(){
	map<string, int> mpa;
	string most_frequent_word, longest_word;
	string s;
	int max_frequency = 0, max_length = 0;
	while(cin >> s){
		if(s.length() > max_length){
			max_length = s.length();
			longest_word = s;
		}
		for(int i = 0; i < s.length(); i++) s[i] = tolower(s[i]);
		mpa[s]++;
	}
	for(auto e : mpa){
		if(e.second > max_frequency){
			max_frequency = e.second;
			most_frequent_word = e.first;
		}
	}
	cout << most_frequent_word << ' ' << longest_word << 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]={"0"},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<cstdio>
#include<map>
using namespace std;

int main()
{
  int i = 0;
  string str;
  string freqstr;//最頻文字
  string longest;
  map<string,int> Map;
  while(cin >>str){
    if(i < ++Map[str]){
      i = Map[str];
      freqstr = str;
  }
    if(str.size() > longest.size())
      longest = str;
  }
  cout <<freqstr <<" "<<longest<<endl;
  return 0;
}

C++: #include <iostream>
#include <string>
#include <map>
#include <set>
 
using namespace std;
 
set<string> dic;
map<string,int> times;
 
int main(){
  int msize = 0;
  string str;
  string a,b;
  while(!cin.eof()){
    string in; cin >> in;
    dic.insert(in);
    times[in]++;
    if(msize < in.size()){
      str = in;
      msize = str.size();
    }
  }
  a = str;
  int mfreq = 0;
  for(set<string>::iterator it = dic.begin(); it != dic.end(); ++it){
    if(mfreq < times[*it]){
      mfreq = times[*it];
      str = *it;
    }
  }
  b = str;
  cout << b << " " << a << endl;
 
  return 0;
}

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

int main(void){
  vector<string> str;
  vector<int> cnt;
  string buf, maxstr;
  int max, ans, i;

  while(cin >> buf){
    bool f = true;

    if(max < buf.length()){
      max = buf.length();
      maxstr.append(buf);
    }
      
    for(i = 0; i < str.size(); i++){
      if(str[i] == buf){
	f = false;
	break;
      }
    }
    if(f){
      str.push_back(buf);
      cnt.push_back(1);
    }
    else{
      cnt[i]++;
    }
  }

  max = 0;
  for(i = 0; i < cnt.size(); i++){
    if(cnt[i] > max){
      max = cnt[i];
      ans = i;
    }
  }

  cout << str[i] << ' ' << maxstr << endl;

  return 0;
}

C++: #include <iostream>
#include <cstring>
#include <cstdio> //fgets
using namespace std;

int main(){
	char str[1000];
	char word[33][33]={0};
	int longest=0;
	int check[33]={0};
	char *tmp;
	int freq=0;
	int count=0;
	int i,j;
	size_t len , prev;
	fgets(str , sizeof(str) , stdin);
		tmp=str;
		for(i=0 ; str[i]!='\0' ;i++){
			if(str[i]==' '){
				str[i]='\0';
				strcpy((char*)&word[count] , (const char*)tmp);
				tmp=str+i+1;
				count++;
			}
		}
		strcpy((char*)&word[count],(const char*)tmp);
		count++;
	for(i=0 ; i<count ; i++){
		for(j=i ; j<count ; j++){
			if(strcmp((const char*)&word[i] , (const char*)&word[j])==0){
				check[i]++;
			}
		}
	}
	for(i=0 ; i<count-1 ; i++){
		if(check[freq]<check[i+1]){
			freq=i+1;
		}
	}
		prev=strlen(word[0]);
	for (i=0 ; i<count ; i++){
		len=strlen(word[i]);
		if(len > prev){
			prev = len;
			longest=i;
		}	
	}
	cout << (char*)&(word[freq]) << " "<< (char*)&(word[longest]);
	return 0;
}

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

int main(){
	map<string,int> m;
	string s;
	while(cin >> s){
		m[s]++;
	}
	int max_word = 0;
	string ans1;
	/*出現頻度が最大*/
	for(map<string,int>::iterator it = m.begin(); it != m.end(); ++it){
		if(it->second > max_word){
			ans1 = it->first;
			max_word = it->second;
		}
	}

	int max_length = 0;
	string ans2;
	/*文字数が最大*/
	for(map<string,int>::iterator it = m.begin(); it != m.end(); ++it){
		if(it->first.size() > max_length){
			ans2 = it->first;
			max_length = it->first.size();
		}
	}

	cout << ans1 << " " << ans2 << endl;
}

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

int main(){
	string w[1000];
	int max=0,maxc=0,maxi=0,idx=0;
	for(int i=0;cin>>w[i];i++){
		if(w[i].size()>w[max].size()) max=i;
		idx++;
	}for(int i=0;i<idx;i++){
		int cnt=0;
		for(int j=0;j<idx;j++){
			if(w[i]==w[j]) cnt++;
		}if(cnt>maxc){
			maxi=i;
			maxc=cnt;
		}
	}cout<<w[maxi]<<" "<<w[max]<<endl;
	return 0;
}

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

int main(void) {
    vector<string> vec;
    string input, ans1;
    int maxLen = 0;
    while(cin >> input) {
        vec.push_back(input);
        if(input.length() > maxLen) {
            maxLen = (int)input.length();
            ans1 = input;
        }
    }
    map<int, string> hm;
    vector<string>::iterator ite;
    int max = 0;
    for(ite = vec.begin(); ite != vec.end(); ite++) {
        string now = *ite;
        int cnt = (int)count(vec.begin(), vec.end(), now);
        if(cnt > max) max = cnt;
        hm.insert(make_pair(cnt, now));
    }
    map<int, string>::iterator ite2;
    for(ite2 = hm.begin(); ite2 != hm.end(); ite2++) {
        if(ite2->first == max) {
            cout << ite2->second << " "; break;
        }
    }
    cout << ans1 << endl;
    return(0);
}