Language: C

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

typedef struct wordtree{
	struct wordtree *next;
	struct wordtree *prev;
	char *txt;
	int t_num;
	int t_size;
}wordtree;

wordtree *initTree(char *msg,int num,int size){
	wordtree *x;
	x=(wordtree *)malloc(sizeof(wordtree));
	x->prev=NULL;
	x->next=NULL;
	x->txt=(char *)malloc(sizeof(char)*32);
	strcpy(x->txt,msg);
	x->t_num=num;
	x->t_size=size;
	return x;
}
int cnt=0;often=0;length=0;
char *mod2,*mod3;
void graphtree(wordtree *tree,int mode){
	switch(mode){
		case 1:if(tree->txt!="")printf("msg=%s,num=%d,size=%d,depth=%d\n",tree->txt,tree->t_num,tree->t_size,cnt);
		case 2:if(tree->t_num>=often){often=tree->t_num;mod2=tree->txt;}
		case 3:if(tree->t_size>=length){length=tree->t_size;mod3=tree->txt;}
	}
	if(tree->next!=NULL){
		cnt++;
		graphtree(tree->next,mode);
	}
	if(tree->prev!=NULL){
		cnt--;
		graphtree(tree->prev,mode);
	}
	return ;
}
		
void addToTree(char *msg,wordtree *tree){
	wordtree *x;
	x=tree;
	if(strcmp(msg, x->txt)>0){
		if(x->next==NULL){
			x->next=initTree(msg,1,strlen(msg));
			return;
		}else{
			addToTree(msg,x->next);
		}
	}else{
		if(x->prev==NULL){
			x->prev=initTree(msg,1,strlen(msg));
			return;
		}else{
			addToTree(msg,x->prev);
		}
	}
}

wordtree *searchTree(char *msg,wordtree *tree){
	wordtree *x;
	x=tree;
	if(strcmp(msg,x->txt)>0){
		if(x->next==NULL)return NULL;
		else searchTree(msg,x->next);
	}else if(strcmp(msg,x->txt)<0){
		if(x->prev==NULL)return NULL;
		else searchTree(msg,x->prev);
	}else{
		return x;
	}
}

int main(){
	wordtree *r,*p;
	int i,j;
	char txt[1024],s[32];
	memset(s,'\0',sizeof(s));
	r=initTree("nn",0,0);//root
	while(fgets(txt,sizeof(txt),stdin)!=NULL){
		for(i=0,j=0;i<strlen(txt);i++){
			if((65<=txt[i]&&txt[i]<=90)||(97<=txt[i]&&txt[i]<=122)){
				if((65<=txt[i]&&txt[i]<=90))txt[i]+=32;
				s[j]=txt[i]; j++;
			}else{
				j=0;
				p=searchTree(s,r);
				if(p==NULL)	addToTree(s,r);
				else p->t_num++;
				memset(s,'\0',sizeof(s));
			}
		}
		//graphtree(r,1);
		graphtree(r,2);
		graphtree(r,3);
		printf("%s %s\n",mod2,mod3);
		return 0;	
	}
}


typedef struct wordtree{
	struct wordtree *next;
	struct wordtree *prev;
	char *txt;
	int t_num;
	int t_size;
}wordtree;

wordtree *initTree(char *msg,int num,int size){
	wordtree *x;
	x=(wordtree *)malloc(sizeof(wordtree));
	x->prev=NULL;
	x->next=NULL;
	x->txt=(char *)malloc(sizeof(char)*32);
	strcpy(x->txt,msg);
	x->t_num=num;
	x->t_size=size;
	return x;
}
int cnt=0;often=0;length=0;
char *mod2,*mod3;
void graphtree(wordtree *tree,int mode){
	switch(mode){
		case 1:if(tree->txt!="")printf("msg=%s,num=%d,size=%d,depth=%d\n",tree->txt,tree->t_num,tree->t_size,cnt);
		case 2:if(tree->t_num>=often){often=tree->t_num;mod2=tree->txt;}
		case 3:if(tree->t_size>=length){length=tree->t_size;mod3=tree->txt;}
	}
	if(tree->next!=NULL){
		cnt++;
		graphtree(tree->next,mode);
	}
	if(tree->prev!=NULL){
		cnt--;
		graphtree(tree->prev,mode);
	}
	return ;
}
		
void addToTree(char *msg,wordtree *tree){
	wordtree *x;
	x=tree;
	if(strcmp(msg, x->txt)>0){
		if(x->next==NULL){
			x->next=initTree(msg,1,strlen(msg));
			return;
		}else{
			addToTree(msg,x->next);
		}
	}else{
		if(x->prev==NULL){
			x->prev=initTree(msg,1,strlen(msg));
			return;
		}else{
			addToTree(msg,x->prev);
		}
	}
}

wordtree *searchTree(char *msg,wordtree *tree){
	wordtree *x;
	x=tree;
	if(strcmp(msg,x->txt)>0){
		if(x->next==NULL)return NULL;
		else searchTree(msg,x->next);
	}else if(strcmp(msg,x->txt)<0){
		if(x->prev==NULL)return NULL;
		else searchTree(msg,x->prev);
	}else{
		return x;
	}
}

int main(){
	wordtree *r,*p;
	int i,j;
	char txt[1024],s[32];
	memset(s,'\0',sizeof(s));
	r=initTree("nn",0,0);//root
	while(fgets(txt,sizeof(txt),stdin)!=NULL){
		for(i=0,j=0;i<strlen(txt);i++){
			if((65<=txt[i]&&txt[i]<=90)||(97<=txt[i]&&txt[i]<=122)){
				if((65<=txt[i]&&txt[i]<=90))txt[i]+=32;
				s[j]=txt[i]; j++;
			}else{
				j=0;
				p=searchTree(s,r);
				if(p==NULL)	addToTree(s,r);
				else p->t_num++;
				memset(s,'\0',sizeof(s));
			}
		}
		//graphtree(r,1);
		graphtree(r,2);
		graphtree(r,3);
		printf("%s %s\n",mod2,mod3);
	}		
	return 0;	
}

Compiler output:
main.c:4:19: warning: extra tokens at end of #include directive
    4 | #include<stdlib.h>#include<stdio.h>
      |                   ^
main.c:28:11: warning: data definition has no type or storage class
   28 | int cnt=0;often=0;length=0;
      |           ^~~~~
main.c:28:11: error: type defaults to 'int' in declaration of 'often' [-Wimplicit-int]
main.c:28:19: warning: data definition has no type or storage class
   28 | int cnt=0;often=0;length=0;
      |                   ^~~~~~
main.c:28:19: error: type defaults to 'int' in declaration of 'length' [-Wimplicit-int]
main.c:109:16: error: redefinition of 'struct wordtree'
  109 | typedef struct wordtree{
      |                ^~~~~~~~
main.c:9:16: note: originally defined here
    9 | typedef struct wordtree{
      |                ^~~~~~~~
main.c:115:2: error: conflicting types for 'wordtree'; have 'struct wordtree'
  115 | }wordtree;
      |  ^~~~~~~~
main.c:15:2: note: previous declaration of 'wordtree' with type 'wordtree'
   15 | }wordtree;
      |  ^~~~~~~~
main.c:117:11: error: conflicting types for 'initTree'; have 'wordtree *(char *, int,  int)'
  117 | wordtree *initTree(char *msg,int num,int size){
      |           ^~~~~~~~
main.c:17:11: note: previous definition of 'initTree' with type 'wordtree *(char *, int,  int)'
   17 | wordtree *initTree(char *msg,int num,int size){
      |           ^~~~~~~~
main.c:128:5: error: redefinition of 'cnt'
  128 | int cnt=0;often=0;length=0;
      |     ^~~
main.c:28:5: note: previous definition of 'cnt' with type 'int'
   28 | int cnt=0;often=0;length=0;
      |     ^~~
main.c:128:11: warning: data definition has no type or storage class
  128 | int cnt=0;often=0;length=0;
      |           ^~~~~
main.c:128:11: error: type defaults to 'int' in declaration of 'often' [-Wimplicit-int]
main.c:128:11: error: redefinition of 'often'
main.c:28:11: note: previous definition of 'often' with type 'int'
   28 | int cnt=0;often=0;length=0;
      |           ^~~~~
main.c:128:19: warning: data definition has no type or storage class
  128 | int cnt=0;often=0;length=0;
      |                   ^~~~~~
main.c:128:19: error: type defaults to 'int' in declaration of 'length' [-Wimplicit-int]
main.c:128:19: error: redefinition of 'length'
main.c:28:19: note: previous definition of 'length' with type 'int'
   28 | int cnt=0;often=0;length=0;
      |                   ^~~~~~
main.c:130:6: error: conflicting types for 'graphtree'; have 'void(wordtree *, int)'
  130 | void graphtree(wordtree *tree,int mode){
      |      ^~~~~~~~~
main.c:30:6: note: previous definition of 'graphtree' with type 'void(wordtree *, int)'
   30 | void graphtree(wordtree *tree,int mode){
      |      ^~~~~~~~~
main.c:147:6: error: conflicting types for 'addToTree'; have 'void(char *, wordtree *)'
  147 | void addToTree(char *msg,wordtree *tree){
      |      ^~~~~~~~~
main.c:47:6: note: previous definition of 'addToTree' with type 'void(char *, wordtree *)'
   47 | void addToTree(char *msg,wordtree *tree){
      |      ^~~~~~~~~
main.c:167:11: error: conflicting types for 'searchTree'; have 'wordtree *(char *, wordtree *)'
  167 | wordtree *searchTree(char *msg,wordtree *tree){
      |           ^~~~~~~~~~
main.c:67:11: note: previous definition of 'searchTree' with type 'wordtree *(char *, wordtree *)'
   67 | wordtree *searchTree(char *msg,wordtree *tree){
      |           ^~~~~~~~~~
main.c:181:5: error: redefinition of 'main'
  181 | int main(){
      |     ^~~~
main.c:81:5: note: previous definition of 'main' with type 'int()'
   81 | int main(){
      |     ^~~~