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 <bits/stdc++.h>

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))

using namespace std;

using i32 = int;
using i64 = long long;
using u64 = unsigned long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vu64 = vector<u64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
inline u64 xorshift() { static u64 x = 88172645463325252ull; x = x ^ (x << 7); return x = x ^ (x >> 9); }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T power(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
template <typename T, typename S> istream& operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
template <typename T, typename S> ostream& operator<<(ostream &os, pair<T, S> &p) { os << p.first << ' ' << p.second; return os; }

void solve() {
  map<string, int> ma;
  string s;
  while (cin >> s) {
    ma[s]++;
  }
  string ans1, ans2;
  int maxx = 0;
  each(m, ma) if (maxx < m.second) {
    maxx = (int) m.second;
    ans1 = m.first;
  }
  maxx = 0;
  each(m, ma) if (maxx < (int) m.first.size()) {
    maxx = (int) m.first.size();
    ans2 = m.first;
  }
  cout << ans1 << " " << ans2 << '\n';
}

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

int main(){
	string s, str1, str2;
	int maxn = 0, maxl = 0;
	map<string, int> mp;
	while(cin >> s){
		
		
		//if(s == "0")break;
		
		
		
		mp[s]++;
		if(mp[s] > maxn){maxn = mp[s];str1 = s;}
		int size = s.size();
		if(size > maxl){maxl = size;str2 = s;}
		cout << s << " ";
	}
	
	//cout << mp["have"];
	cout << str1 << " " << str2 << endl;
	return 0; 
}

C++: #include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>

using namespace std;
typedef long long ll;

int main(){
    char in[500];
    int ans_max=0,ans_long=0;
    string s_max,s_long;
    map<string,int> mm;
    
    while(EOF!=scanf("%s",in)){
        
        string S = in;
        
        if((int)S.size() > ans_long){
            s_long = S;
            ans_long = (int)S.size();
        }
        
        mm[S]++;
    }
    
    for(map<string,int>::iterator it = mm.begin();it!=mm.end();it++){
        if( (it->second) > ans_max ){
            ans_max = it->second;
            s_max = it->first;
        }
    }
    
    cout << s_max <<  " " << s_long << endl;
    
    return 0;
}

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

int main(void){
  map<string,int>m;
  map<string,int>::iterator it,cit,sit;
  string s;
  int maxS=0,maxC=0;
  while(cin >>s){
    m[s]+=1;
  }
  for(it=m.begin();it!=m.end();it++){
    int size=(*it).first.size();
    if(size>maxS)sit=it;maxS=size;
    int cou=(*it).second;
    if(cou>maxC)cit=it;maxC=cou;
  }
  cout <<(*cit).first <<" "<<(*sit).first<<endl;
}

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

using namespace std;

int main()
{
    vector<string> data;
    
    string S, T = "", W; int max_ = 0, c;
    
    while(cin >> S)
    {
        if(T.size() < S.size()) { T = S; }
        
        data.push_back(S);
    }
    
    sort(data.begin(), data.end());
    
    c = 1;
    
    if(data.size() != 1)
    {
        for(int i = 1; i < data.size(); i++)
        {
            if(data[i - 1] == data[i])
            {
                c++;
                
                if(max_  < c)
                {
                    max_ = c;
                    
                    W = data[i];
                }
            }
            else
            {
                c = 1;
            }
        }
    }
    else
    {
        W = S;
    }
    
    cout << W << ' ' << T << endl;
    
    return 0;
}

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

typedef pair<int,string> Pis ;
#define f first
#define s second

vector<Pis> VC ;

int main(){
	
	string str,Astr ;
	getline( cin , str ) ;
	str += ' ' ;
	
	bool f = false ;
	string tmp ;
	for( int i=0 ; i < str.size() ; i++ ){
		if( str[i] != ' ' ) tmp += str[i] ;
		else {
			for( int j=0 ; j<VC.size() ; j++ ){
				if( VC[j].s == tmp ){
					VC[i].f++;
					f = true ;
					break    ;
				}
			}
			if( f ) f = false ;
			else {
				VC.push_back( Pis(1,tmp) ) ;
				if( Astr.size() < tmp.size() ) Astr = tmp ;
			}
			tmp.erase();
		}
	}
	
	sort( VC.begin() , VC.end() );
	
	cout << VC[VC.size()-1].s << " " ;
	cout << Astr << endl ;
	
	return 0;
}

C++: #include<iostream>
#include<cstring>
using namespace std;
int const N = 1001;
int main(){
	char str[N][50];
	int num[N],i=0,max=0,l=0;
	while(cin >> str[i]){
		i++;
	}
	for(int j=0;j<i;j++){
		num[j]=0;
	}
	for(int j=0;j<i;j++){
		for(int k=0;k<i;k++){
			if(strcmp(str[j],str[k])==0)
		num[j]++;
		}
		if(num[max] < num[j])
			max = j;
		if(strlen(str[l]) < strlen(str[j]))
			l=j;
	}
	cout << str[max] << " " << str[l] << endl;
}
[tebora@tebora