words  = $<.each_line.map{|line| line.split}.flatten
counts = words.inject(Hash.new(0)){ |h, s| h[s] += 1; h }

longest_word = words.max_by(&:size)
mode_word    = counts.max[0]
puts "#{longest_word} #{mode_word}"