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 <bits/stdc++.h>
using namespace std;
int main(void){
   std::deque<string> deq;
   string s,tmps,tmpss;
   int count,max,length;
   count = 0;
   max = 0;
   length = 0;
   while (cin >> s) {
       deq.emplace_back(s);
   }
   for (int i=0;i<deq.size();i++) {
       for (int j=0;j<deq.size();j++) {
           if (deq[i]==deq[j]) {
               count++;
           }
           if (count>max) {
               max = count;
               tmps = deq[i];
           }
           if (deq[i].size()>length) {
               length = deq[i].size();
               tmpss = deq[i];
           }
       }
       count = 0;
   }
   cout << tmps << " " << tmpss << endl;
}

C++: #include<iostream>
#include<algorithm>
#include<stdio.h>
#include<string>
using namespace std;
int main()
{
	string p[1001],s;
	int c;
	int st[1001] = { 0 }, l = 0, i,maxl=0,maxn=0;
	while ((c = getchar()) != '\n'){
		if (c == ' '){
			for (i = 0; i < l; i++){
				if (p[i] == s){
					st[i]++;
					s.clear();
					break;
				}
			}
			if (i == l){
				int size = s.size();
				p[l] = s;
				maxl = max(maxl,size);
				if (maxl == s.size())maxn = l;
				s.clear();
				l++;
			}
		}
		else{
			s += c;
		}
	}
	for (i = 0; i < l; i++){
		if (p[i] == s){
			st[i]++;
			break;
		}
	}
	if (i == l){
		int size = s.size();
		p[l] = s;
		maxl = max(maxl, size);
		if (maxl == s.size())maxn = l;
		s.clear();
		l++;
	}
	int maxb=0,maxnum;
	for (int i = 0; i < l; i++){
		maxb = max(maxb, st[i]);
		if (maxb == st[i]){
			maxnum = i;
		}
	}
	cout << p[maxnum] << endl;
	cout << p[maxn] << endl;
}

C++: #include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <map>
using namespace std;

#define FOR(i,a,b) for(long long int i=(a);i<(b);i++)
#define REP(i,n) for(long long int i=0;i<(n);i++)
#define ALL(s) (s).begin(),(s).end()

#define PI 3.14159265358479

typedef long long ll;
typedef vector<long long int> vi;
typedef vector<long long int>::iterator vit;

int main(){
	map<string, int>table;
	string s, f, l;
	string::iterator it = s.begin();
	size_t n = 0;
	while (cin >> s){
		table[s]++;
		if (table[s] > n){
			n = table[s];
			f = s;
		}
		if (s.size() > l.size()){
			l = s;
		}
	}
	cout << f << " " << l << endl;
}

C++: #include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
using namespace std;

int main(){
    string s;
    string longest;
    map<string,int> m;
    while(cin >> s){
        m[s]++;
        if(longest.size() < s.size()) longest = s;
    }
    string freq;
    for(auto & e : m){
        if(m[freq] < e.second) freq = e.first;
    }
    cout << freq << " " << longest << endl;
}

C++: #include<stdio.h>
#include<string.h>
char str[33];
int lmax=0;
char mword[33];
typedef struct{
	char word[33];
	int time;
}data;
data d[1000];
int cd=0;
int i;
int main(){
	while(scanf("%s",str)!=EOF){
		if(strlen(str)>lmax){
			lmax=strlen(str);
			strcpy(mword,str);
		}
		for(i=0;i<cd;i++)if(strcmp(d[i].word,str)==0){
			d[i].time++;
			break;
		}
		if(i==cd){
			strcpy(d[cd].word,str);
			d[cd++].time=1;
		}
		}
	}
	int fm=0;
	for(i=0;i<cd;i++)if(d[i].time>d[fm].time)fm=i;
	printf("%s %s\n",d[fm].word,mword);
}

C++: #define _USE_MATH_DEFINES
 
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>

using namespace std;

int main(){
	vector<string> str;
	int count[1000]={0};
	int length[1000]={0};

	string s;
	while(cin >> s){
		int i;
		for(i=0;i<str.size();i++){
			if(str[i]==s){
				count[i]++;
				break;
			}
		}
		if(i>=str.size()){
			str.push_back(s);
			length[i]=s.size();
		}
	}

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

C++:  
 #include<iostream>
 #include<stdio.h>
 #include<string>
 #include<math.h>
 #include<iomanip>
 #include<algorithm>
 #include<string.h>
 #include<cctype>
 #include<map>
 #include<set>
 #include<vector>
 #include<sstream>
 #include<stack>
 #include<queue>
 
 using namespace std;
  
 int main()
 {
   multiset<string> kk;
   int max=0;
   int fre=-100000000;
   string str;
   string str_max;
   string str_fre;
   multiset<string>::iterator iter; 
   while(cin>>str)
   {
     if(str.length()>max) 
     {
       max=str.length();
       str_max=str;                     
     }             
     kk.insert(str);      
   }              
   for(iter = kk.begin();iter!= kk.end(); iter++)  
   {  
     string str=*iter;
     int num=kk.count(str);
     if(num>fre) 
     {
       fre=num;
       str_fre=str;                
     }
   }  
   cout<<str_max<<" "<<str_fre<<endl;
   //while(1);     
   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=count; i>=0 ; i--){
		for(j=0 ; j<i-1 ; j++){
			if(check[j]>check[j+1]){
				check[j]^=check[j+1];
				check[j+1]^=check[j];
				check[j]^=check[j+1];
				freq=j;
			}
		}
	}
		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]) << endl;
	return 0;
}

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