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 <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
int main()
{
	int m=0,i,j,t=0,p=0,count,len,max_len=0;
	int dc[1001];
	for(i=0;i<1001;i++)
	{
		dc[i] = 0;
	}
	char str[1001],max_word[33],word[33],d[1001][33];
	fgets(str,sizeof(str),stdin);
	memset(d,'\0',sizeof(d));
	memset(word,'\0',sizeof(word));
	len = strlen(str);
	for(i=0;i<len;i++)
	{
		if(str[i] == ' '||i==len-1)
		{
			strcpy(d[p],word);
			p++;
			if(max_len < strlen(word))
			{
				max_len = strlen(word);
				memset(max_word,'\0',sizeof(max_word));
				strcpy(max_word,word);
				memset(word,'\0',sizeof(word));
				t=0;
			}
			else
			{
				memset(word,'\0',sizeof(word));
				t=0;
			}
		}
		else
		{
			word[t]=str[i];
			t++;
		}
	}
	for(i=0;i<p;i++)
	{
		for(j=i+1;j<p;j++)
		{
			if(strcmp(d[i],d[j]) == 0)
			{
				dc[i]++;
			}
		}
	}
	for(i=0;i<p;i++)
	{
		if(dc[i] > m)
		{
			m=i;
		}
	}
	printf("%s %s\n",d[m],max_word);
	return 0;

}

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

using namespace std;

int main() {
	string str, m_str = "", ans = "";
	map<string, int> word;
	while (cin >> str) {
		word[str]++;
		if (str.size() > m_str.size()) m_str = str;
		if (word[str] > word[ans]) ans = str;
	}
	cout << ans << " " << m_str << endl;
}

C++: #include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
using namespace std;
vector<string> c;
map<string,int> s;
int main(void)
{
  string str;
  while(cin >> str){
    s[str]++;
    if(s[str]==1) c.push_back(str);
  }
  int fbest=0,lbest=0;
  for(int i=1;i<c.size();i++){
    if(s[c[fbest]]<s[c[i]])fbest=i;
    if(c[lbest].size()<c[i].size())lbest=i;
  }
  cout << c[fbest] << " " << c[lbest] << endl;
}

C++: #include<iostream>
#include<math.h>
#include<string>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
using namespace std;
#define INF 1<<20

struct edge{
	int to;
	int cost;
	edge() {};
	edge(int a, int b) {
		to = a;
		cost = b;
	}
};

struct Node {
	int pos;
	int cost;
	Node() {};
	Node(int a, int b) {
		pos = a;
		cost = b;
	}
	bool operator <(const Node& rhs) const {
		return cost > rhs.cost;
	}
};

void dijkistra(int st, int TO,int V,vector<vector<edge> > graph) {
	priority_queue<Node> q;
	vector<int> d(V);
	for (int i = 0;i < V;i++) {
		d[i] = INF;
	}
	d[st] = 0;
	q.push(Node(st, 0));
	while (!q.empty()) {
		Node s = q.top(); q.pop();
		int pos = s.pos;
		for (int i = 0;i < graph[pos].size();i++) {
			int to = graph[pos][i].to;
			int cost = graph[pos][i].cost;
			if (d[pos] + cost < d[to]) {
				d[to] = d[pos] + cost;
				q.push(Node(to, d[to]));
			}

		}
	}
	cout << d[TO] << endl;
}
int partition(int A[],int p, int r) {
	int x = A[r];
	int i = p - 1;
	for (int j = p;j < r;j++) {
		if (x >= A[j]) {
			i = i + 1;
			swap(A[i], A[j]);
		}
	}
		swap(A[i + 1], A[r]);
		return i + 1;
}
void quicksort(int A[], int p, int r) {
	if (p < r) {
		int q = partition(A, p, r);
		quicksort(A, p, q-1);
		quicksort(A, q + 1, r);
	}
}

int getNumberOfCoin(int C[],int n,int m) {
	int T[50000];
	for (int j = 0;j <= n;j++) {
		T[j] = INF;
	}
	T[0] = 0;
	for (int i = 0;i < m;i++) {
		for (int j = 0;j <= n;j++) {
			if (j - C[i] >=0  ) {
				T[j] = min(T[j], T[j - C[i]] + 1);
			}
		}
	}
	return T[n];
}
int knapsack(int w, int n,int* v,int* ww) {
	int W[101][10001];
		for (int j = 0;j <= w;j++) {
			W[0][j] = 0;
		}
	for (int i = 0;i < n;i++) {
		for (int k = 0;k < n;k++){
			for (int j = 0;j <= w;j++) {
				if (j - ww[k] < 0) {
					W[i + 1][j] = W[i][j];
				}
				if (j - ww[i] >= 0) {
					W[i + 1][j] = max(W[i][j], W[i][j - ww[k]] + v[k]);

				}
			}
		}
	}
	return W[n][w];
}
int fib(int n) {
	vector<int> v(n+1);
	v[0] = 1;
	v[1] = 1;
	for (int i = 2;i < n+1;i++) {
		v[i] = v[i - 2] + v[i - 1];
	}
	return v[n];
}
int isPrime(int x) {
	if (x <= 1) return false;
	if (x>2 && x % 2 == 0) return false;
	for (int i = 2;i <= sqrt(x);i++) {
		if (x%i == 0) {
			return false;
		}
	}
	if (x == 2) return true;
	return true;
}
int Prime(int x) {
	vector<int> prime(x+1,1);
	int num = 2;
	while (num <= sqrt(x)) {
		for (int i = 2;i <= x / num;i++) {
			prime[num*i] = 0;
		}
		num++;
		while (prime[num] == 0)
			num++;
	}
	int count = 0;
	for (int i = 2;i < x + 1;i++) {
		if (prime[i] == 1) count++;
	}
	return count;
}
int main(){
	map<string, vector<int> > dic;
	string sent;
	string mlength="a";
	string moc;
	int max = 0;

	while (cin >> sent) {
		dic[sent].push_back(0);
		if (max < dic[sent].size()) {
			max = dic[sent].size();
			moc = sent;
		}
		if (mlength.length() < sent.length()) {
			mlength = sent;
		}
	}
	cout << moc << " " << mlength << endl;

}

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

int main (void){

	string str,maxByLength("");
	//map<int,string> X; //¶Ì·³
	map<string,int> Y; //¶Ì
	//int mm;

	while (cin>>str){
		if (str.size()>maxByLength.size())	maxByLength=str;
		Y[str]++;
	}

	string maxByCount("");
	int cnt = 0;
	for(map<string, int>::iterator it = Y.begin(); it != Y.end(); ++it) {
		if(it->second > cnt) {
			maxByCount = it->first;
		}
	}

	cout << maxByCount << " " << maxByLength << endl;

	// cout << (*Y.rbegin()).first << " " << maxByLength << endl;
	return 0;

}

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

using namespace std;

int main(){
	string sent;
	string word[500];
	int a[500]={};
	int i,j,k,l;
	int n,m,len;
	i=0;
	while(cin>>sent){
		if(i==0){	//????????????????????????
			word[0]=sent;
			a[0]++;
			i++;
			len=sent.size();
			n=0;
		}
		else {
			if(len<sent.size()){	//?????????????????????????????°??´??°
				len=sent.size();
				n=i;
			}
			for(j=0; j<i; j++){
				if(sent==word[j]){???//?????§????????????????????????
					a[j]++;
					break;
				}
				if(j==i-1){			//??°?????????????????????
					word[i]=sent;
					a[i]++;
					i++;
					break;
				}
			}
		}
	}
	m=0;
	for(j=0; j<i; j++){???	//????????????????????????????????????
		if(m<a[j])m=j;
	}
	cout<<word[m]<<" "<<word[n]<<endl;
	// for(j=0; j<i; j++){
	// 	cout<<word[j]<<":"<<a[j]<<endl;
	// }
	//cout<<"len:"<<len<<" "<<word[n]<<endl;
	return 0;
}

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

using namespace std;

class Word {
public:
	char w[33];
	int length;
	int freq;
public:	
	Word() {
		strcpy(w, "");
		length = 0;
		freq = 0;
	}
};

int main()
{
	char str[1001];
	char buf[32];
	char *p, *q;
	fgets(str, 1001, stdin);
	
	Word wl[32];
	
	for ( p = str; (q = strstr(p, " ")) != NULL; ) {
		*q = '\0'; strcpy(buf, p); 
		for (int i=0; i<32; i++) {
			if ( strcmp(wl[i].w, "") == 0 ) {
				strcpy(wl[i].w, buf);
				wl[i].length = strlen(buf);
				wl[i].freq = 1;
				break;
			}
			else if ( strcmp(wl[i].w, buf) == 0 ) {
				wl[i].freq++;
				break;
			}
		}
		p = q + 1;
	}
	
	strcpy(buf, p); 
	for (int i=0; i<32; i++) {
		if ( strcmp(wl[i].w, "") == 0 ) {
			strcpy(wl[i].w, buf);
			wl[i].length = strlen(buf);
			wl[i].freq = 1;
			break;
		}
		else if ( strcmp(wl[i].w, buf) == 0 ) {
			wl[i].freq++;
			break;
		}
	}

	
	int max_freq = 0;
	int max_length = 0;
	char max_freq_w[32];
	char max_length_w[32];
	
	for (int i=0; i<32; i++) {
		if (max_freq < wl[i].freq) {
			max_freq = wl[i].freq;
			strcpy(max_freq_w, wl[i].w);
		}
		if (max_length < wl[i].length) {
			max_length = wl[i].length;
			strcpy(max_length_w, wl[i].w);
		}
	}
	
	cout << max_freq_w << endl << max_length_w << endl;
	
	return 0;
}