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

#define LENGTH_INPUT 1000
#define LENGTH_WORD 33 //単語最大長32+ヌル文字=33

#define compile 1

void initialize(char array[], int n); //char型配列の初期化
void separate(char input[], char word[][LENGTH_WORD]);
int search_common(char word[][LENGTH_WORD], int item, int maximum[]);
int search_length(char word[][LENGTH_WORD], int item, int maximum[]);
void output_common(char word[][LENGTH_WORD], int item, int maximum[], int max_common);
void output_longest(char word[][LENGTH_WORD], int item, int maximum[], int max_longest);

main()
{
	char input_str[LENGTH_INPUT]; //入力文字列を格納する配列
	initialize(input_str, LENGTH_INPUT); //配列の初期化
	
	gets(input_str); //入力文字列の取得
	
	int i = 0, spaces = 0;
	for(i = 0; input_str[i] != 0x00; i++)
	{
		if(input_str[i] == 0x20)
		{
			spaces++;
			//printf("spaces = %d\n", spaces);
		}
	}
	spaces++; //スペースの数と終端記号の合計の値→単語数
	
	char word[spaces][LENGTH_WORD]; //単語をそれぞれ格納する為に配列を動的に宣言
	for(i = 0; i < spaces; i++) //初期化
	{
		initialize(word[i], LENGTH_WORD);
	}
	
	separate(input_str, word); //入力文字列を分割して配列に代入
	
	int maximum_common[spaces]; //単語数分int型の変数を宣言
	for(i = 0; i < spaces; i++) //初期化
	{
		maximum_common[i] = 0;
	}
	int max_common = 0; //出現頻度が最も高い単語の出現回数
	max_common = search_common(word, spaces, maximum_common); //出現頻度が最も高い単語の出現回数をmaxに代入※ついでに配列maximumも操作
	
	int maximum_length[spaces]; //単語数分int型の変数を宣言
	for(i = 0; i < spaces; i++) //初期化
	{
		maximum_length[i] = 0;
	}
	int max_length = 0;
	max_length = search_longest(word, spaces, maximum_length);
	
	output_common(word, spaces, maximum_common, max_common); //最多出現回数の単語を出力
	output_longest(word, spaces, maximum_length, max_length); //最長単語を出力
	
	return 0;
}

void initialize(char array[], int n) //char型配列の初期化
{
	int i = 0;
	for(i = 0; i < n; i++)
	{
		array[i] = 0x00;
	}
}

void separate(char input[], char word[][LENGTH_WORD])
{
	int i = 0, j = 0, k = 0;;
	for(i = 0; input[i] != 0x00; i++)
	{
		if(input[i] == 0x20)
		{
			word[j][k] = 0x00;
			k = 0;
			j++;
		}
		else
		{
			word[j][k] = input[i];
			k++;
		}
	}
}

int search_common(char word[][LENGTH_WORD], int item, int maximum[])
{
	int i = 0, j = 0, result = 0;
	for(i = 0; i < item; i++)
	{
		for(j = i + 1; j < item; j++)
		{
			if(strcmp(word[i], word[j]) == 0)
			{
				maximum[i]++;
				//printf("maximum[%d] = %d\n", i, maximum[i]);
				if(result < maximum[i])
				{
					result = maximum[i];
				}
			}
		}
	}
	//printf("result = %d\n", result);
	return result;
}

int search_longest(char word[][LENGTH_WORD], int item, int maximum[])
{
	int i = 0, result = 0;
	for(i = 0; i < item; i++)
	{
		maximum[i] = strlen(word[i]);
		//printf("word[%d] length = %d\n", i, maximum[i]);
		if(result < maximum[i])
		{
			result = maximum[i];
		}
	}
	//printf("result = %d\n", result);
	return result;
}

void output_common(char word[][LENGTH_WORD], int item, int maximum[], int max_common)
{
	int i = 0;
	for(i = 0; i < item; i++)
	{
		if(max_common == maximum[i])
		{
			printf("%s ", word[i]);
			return;
		}
	}
}
void output_longest(char word[][LENGTH_WORD], int item, int maximum[], int max_longest)
{
	int i = 0;
	for(i = 0; i < item; i++)
	{
		if(max_longest == maximum[i])
		{
			printf("%s\n", word[i]);
			return;
		}
	}
}

Measured memory_bytes: 540