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<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1e8;
int main(){
	string s;
	map<string,int>m;
	int out=0;
	while(cin>>s){
		m[s]++;
		out=max(out,s.size());
	}
	int ma=0;
	string ans;
	for(auto it=m.begin();it!=m.end();it++){
		ma=max(ma,it->second);
		if(out==it->first.size());ans=it->first;
	}
	for(auto it=m.begin();it!=m.end();it++){
		if(it->second==ma)cout<<(it->first)<<" ";
	}
	cout<<ans<<endl;
}

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]++;
		if (table[word] > N){
			N = table[word];
			frequent = word;
		}
		if (word.size() > longest.size())
			longest = word;
	}
	cout << frequent << " " << longest << endl;
}

C++: #include<cstdio>
#include<cstring>
#include<iostream>
#include<queue>
#include<string>
using namespace std;
struct Eng {
  string str;
  int count;
};
int main(){
  Eng data[3333],temp;
  string str,box="\0";
  int f=0,num=0,flag;
  getline(cin , str);
  int str_size = str.size();
  for(int i=0;i<str_size;i++){
    if(str[i] == ' '){
      data[num].str = str.substr( f , i - f );
      for(int j=0;j<num;j++){
	if(data[num].str == data[j].str){
	  data[j].count++;	
	}
      }
      f = i + 1;
      num++;
    }
    else if(i == str_size-1){
      data[num].str = str.substr( f , i - f + 1  );
      for(int j=0;j<num;j++){
	if(data[num].str == data[j].str)data[j].count++;
      }
      num++;
    }
  }
  for(int i=0;i<num-1;i++){
    for(int j=num-1;j>i;j--){
      if(data[j].count>data[j-1].count){
	temp = data[j];
	data[j] = data[j-1];
	data[j-1] = temp;
      }
    }
  }
  for(int i=0;i<num;i++)
    if(box.size()<data[i].str.size())box = data[i].str; // 長さ確保
  cout << data[0].str << ' ' << box << endl;
}

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

using namespace std;

struct WordCount{
  string word;
  int count;
};

void PushWordCount(const vector<string>, vector<WordCount>&);
vector<string> split(string);
bool space(char);
bool not_space(char);

int main(){
  int max=0, longest=0;
  string s, Max, Longest;
  vector<string> str;
  vector<WordCount> data;

  getline(cin, s);
  str = split(s);
  PushWordCount(str, data);

  for(vector<WordCount>::size_type i=0; i != data.size(); ++i){
    if(data[i].count > max){
      max = data[i].count;
      Max = data[i].word;
    }
    if(data[i].word.size() > longest){
      longest = data[i].word.size();
      Longest = data[i].word;
    }
  }

  cout << Max << " " << Longest << endl;
  return 0;
}

void PushWordCount(const vector<string> s, vector<WordCount>& words){
  int isFound;
  WordCount NewWord;
  vector<WordCount>::iterator iter;

  for(string::size_type i=0; i != s.size(); ++i){
    isFound = 0;
    iter = words.begin();
    while(iter != words.end()){
      if(iter->word == s[i]){
        ++iter->count;
        break;
      }
      ++iter;
    }
    if(isFound == 0){
      NewWord.word = s[i];
      NewWord.count = 1;
      words.push_back(NewWord);
    }
  }
}

vector<string> split(string str){
  string _str;
  vector<string> Str;
  string::iterator i, j;

  j = str.begin();
  while(i < str.end() || j < str.end()){
    i = find_if(j, str.end(), not_space);
    j = find_if(i, str.end(), space);
    copy(i, j, back_inserter(_str));
    Str.push_back(_str);
    _str.clear();
  }
  return Str;
}

bool space(char c){
  return (isspace(c));
}

bool not_space(char c){
  return (!isspace(c));
}

C++: #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] += 1;
    // table[word] を一つ増やす
    if(table[word] > N){
      N = table[word];
      frequent = word;
    }
    // table[word] がN より大きければ，N とfrequent を更新
    if(word.size() > longest.size()){
      longest = word;
    }
    // word.size() > longest.size() ならlongest を更新
  }
  cout << frequent << " " << longest << endl;
  //frequent とlongest を出力
}

C++: #include <cstdio>
#include <cstring>

using namespace std;

int main(void){
	char buf[1000][33], word[33];
	int bufnum = 0, same[1000], i, smax, lmax;
	memset(same,0,sizeof(same));
	while(scanf("%s",word) != EOF){
		for(i = 0;i < bufnum;i++){
			if(!strcmp(word,buf[i])){
				same[i]++;
				break;
			}
		}
		if(bufnum == i){
			strcpy(buf[bufnum],word);
			same[bufnum++]++;
		}
	}
	smax = 0, lmax = 0;
	for(i = 0;i < bufnum;i++){
		if(smax < same[i]){
			smax = same[i];
		}
		if(lmax < strlen(buf[i])){
			lmax = strlen(buf[i]);
		}
	}
	for(i = 0;i < bufnum;i++){
		if(smax == same[i])
			printf("%s ",buf[i]);
	}
	int cnt1 = 0, cnt2 = 0;
	for(i = 0;i < bufnum;i++){
		if(lmax == strlen(buf[i]))
			cnt1++;
	}
	for(i = 0;i < bufnum;i++){
		if(lmax == strlen(buf[i])){
			printf("%s",buf[i]);
			cnt2++;
			if(cnt1 != cnt2){
				printf(" ");
			}
		}
	}
	printf("\n");
	return 0;
}

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

int main()
{
	string str;
	vector<string> cstr;
	getline(cin, str);

	int start = 0;
	for (int i = 0; i < str.size(); ++i){
		if (str[i] == ' '){
			cstr.push_back(str.substr(start,i - start));
			start = i+1;
		}
		if (i == str.size()-1){
			cstr.push_back(str.substr(start, i - start));
			start = i + 1;
		}
	}

	int maxl = 0,maxf = 0;
	for (auto& n : cstr){
		if (maxf < count(cstr.begin(), cstr.end(),n))			maxf = count(cstr.begin(), cstr.end(), n);
		if (n.size() > maxl)													maxl = n.size();
	}

	for (auto& n : cstr){
		vector<string> outs;
		if (maxf == count(cstr.begin(), cstr.end(), n)){
			cout << n << " ";
			break;
		}
	}

	for (auto& n : cstr){
		if (n.size() == maxl)
			cout << n << endl;
	}
	return 0;
}

C++: //#define _USE_MATH_DEFINES
//#include <cmath>
#include <iostream>
//#include <stdio.h>
//#include <stdlib.h>
//#include <iomanip>
//#include <vector>
#include <string>
//#include <algorithm>
//#include <functional>
//#include <time.h>
//#include <sstream>
//#include <queue>
#include <map>

using namespace std;


int main(){

	string in;
	map  <string, int> maps;
	string longer = "";
	string mead;
	int cnt = 0;


	while (cin >> in){
		maps[in]++;
		if (maps[in] > cnt){
			cnt = maps[in];
			mead = in;
		}
		if (in.size() > longer.size())longer = in;
	}

	cout << mead << " " << longer << endl;

	return 0;
}