#include <stdio.h>
#include <string.h>

#define TEXT_MAXNUM 1000
#define WORD_MAXNUM 33

typedef struct tagStrings
{
	char	str[WORD_MAXNUM];
	int		length;
	int		count;
} Strings_t;

void main( void )
{
	char		inputString[TEXT_MAXNUM] = "";
	
	Strings_t	words[TEXT_MAXNUM / 2] = {{0}};	// words in text
	char		tmpStr[WORD_MAXNUM] = {0};		// work
	int			wordNum = 0;					// record word num
	int			readIdx = 0;					// text read pointer
	int			readWordCount = 0;				// readding word length
	
	while( readIdx < TEXT_MAXNUM )
	{
		if( inputString[readIdx] == '\0' )
		{	// end text
			// @todo
			break;
		}
		tmpStr[readWordCount] = inputString[readIdx];	// read char
		
		if( tmpStr[readWordCount] == ' ' )
		{	// space -> partition word
			if( readWordCount )
			{
				tmpStr[readWordCount] = '\0';
				// word grep & record
				int i=0;
				for( i; i < wordNum; i++)
				{
					if( strcmp(words[i].str, tmpStr) == 0 )
					{	// recorded
						words[i].count++;
						break;
					}
				}
				if( i >= wordNum )
				{	// new record
					strcpy(words[wordNum].str, tmpStr);
					words[wordNum].length = readWordCount;
					words[wordNum].count = 1;
					wordNum++;		// record num +1
				}
				
				readWordCount = 0;
			}
			// not readding word -> next read
			readIdx++;
		}
		else
		{
			readWordCount++;
			readIdx++;
		}
	}
	
	// most, max index
	int maxLenIdx = 0;
	int mostIdx = 0;
	
	for( int i = 0; i < wordNum; i++)
	{
		int maxMost = 0;
		int maxLen  = 0;
		
		if( maxMost < words[i].count )
		{
			maxMost = words[i].count;
			mostIdx = i;
		}
		if( maxLen < words[i].length )
		{
			maxLen = words[i].length;
			maxLenIdx = i;
		}
	}
	
	// dump
	printf("%s %s\n", words[mostIdx].str, words[maxLenIdx].str);
	
	return;
}