Language: C

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define wall_max 100
#define pos(a)
typedef struct wall{
	int iti;
	int catid;
	int catleng;
	struct wall* nextcat;
};

int typechk(char record[], int* num1, int* num2){
	char *wkptr = NULL;
	char wkchar[256];
	int wknum = 0;
	int slen = 0;

	if(strncmp(record,"0",1) == 0){
		return 1;
	}else if(strncmp(record,"s",1) == 0){
		wkptr = strrchr(record, ' ');
		if(wkptr!=NULL){
			(*num2) = atoi(wkptr+1);
			(*wkptr) = NULL;
		}
		wkptr = strrchr(record, ' ');
		if(wkptr!=NULL){
			(*num1) = atoi(wkptr+1);
			(*wkptr) = NULL;
		}
		return 2;
	}else if(strncmp(record,"w",1) == 0){
		wkptr = strrchr(record, ' ');
		if(wkptr!=NULL){
			(*num1) = atoi(wkptr+1);
			(*wkptr) = NULL;
		}
		return 3;
	}else{
		wkptr = strrchr(record, ' ');
		if(wkptr!=NULL){
			(*num2) = atoi(wkptr+1);
			(*wkptr) = NULL;
		}
			(*num1) = atoi(record);
		return 4;
	}
}

void initwall(wall* rewall){
	int i=0;

	for(i=0;i<wall_max;i++){
		rewall[i].iti= i;
		rewall[i].catid = -1;
		rewall[i].catleng = 0;
		rewall[i].nextcat = NULL;
	}
	return;
}
int main(){
	int num1, num2;
	int i=0;
	int type=0;
	char kiroku[256];
	int dataset = 0;
	wall myhouse[wall_max];
	int wallend;
	wall *bfpt = NULL;
	wall *nxpt = NULL;
	wall *curpt = NULL;
	int cmcatid;
	int cmcatleng;
	int tindex;
	int flg=0;

	while(1){
		// ?¨????????????????
		gets_s(kiroku);
		type = typechk(kiroku, &num1, &num2);
		if(type == 1){ // ???????????????
			printf("END\n");
			break;
		}
		else if(type == 4){ // ??\?????\
			if(flg!=0){
				printf("END\n");
			}else{
				flg = 1;
			}
			initwall(myhouse);
			wallend = num1;
		}
		else if(type == 2){ // ?????\???
			cmcatid = num1;
			cmcatleng = num2;
			curpt = myhouse;
			while(1){
				if(curpt->catid == -1){
					if(curpt->nextcat != NULL){
						if(cmcatleng <= (curpt->nextcat->iti - (curpt->iti))){
							curpt->catid = cmcatid;
							curpt->catleng = cmcatleng;
							printf("%d\n",curpt->iti);
							break;
						}
						else{
							curpt = curpt->nextcat;
						}
					}
					else{
						if(cmcatleng <= (wallend - curpt->iti)){ // ????????????
							curpt->catid = cmcatid;
							curpt->catleng = cmcatleng;
							printf("%d\n",curpt->iti);
							break;
						}
					}
				}
				else{
					if(curpt->nextcat == NULL){ // ??????????????????????????£???
						if(cmcatleng <= (wallend - (curpt->iti + curpt->catleng))){ // ?¬??????????
							bfpt = curpt;
							curpt+=curpt->catleng;
							bfpt->nextcat = curpt;
							curpt->catid = cmcatid;
							curpt->catleng = cmcatleng;
							printf("%d\n",curpt->iti);
							break;
						}
						else{
							printf("impossible\n"); // ????????°???
							break;
						}
					}
					else{ // ?¬???????
						// ??????????????????
						if(cmcatleng <= (curpt->nextcat->iti - (curpt->iti+curpt->catleng))){
							bfpt = curpt;
							nxpt = curpt->nextcat;
							curpt+=curpt->catleng;
							bfpt->nextcat = curpt;
							curpt->catid = cmcatid;
							curpt->catleng = cmcatleng;
							curpt->nextcat = nxpt;
							printf("%d\n",curpt->iti);
							break;
						}
						else{
							curpt = curpt->nextcat;
						}
					}
				}
			}
		}
		else if(type == 3){ // ?????°??£???
			cmcatid = num1;
			bfpt = NULL;
			curpt = myhouse;
			while(1){
				if(curpt->catid == cmcatid){
					if(bfpt!=NULL){
						bfpt->nextcat = curpt->nextcat;
					}
					curpt->catid = -1;
					curpt->catleng = 0;
					if( curpt->iti != 0){
						curpt->nextcat = NULL;
					}
					break;
				}
				else{
					bfpt = curpt;
					if(curpt->nextcat!=NULL){
						curpt = curpt->nextcat;
					}
					else{
						break; // ?????????????????????
					}
				}
			}
		}
	}
  
  return 0;
}

Compiler output:
main.c:11:1: warning: useless storage class specifier in empty declaration
   11 | };
      | ^
main.c: In function 'typechk':
main.c:25:34: error: assignment to 'char' from 'void *' makes integer from pointer without a cast [-Wint-conversion]
   25 |                         (*wkptr) = NULL;
      |                                  ^
main.c:30:34: error: assignment to 'char' from 'void *' makes integer from pointer without a cast [-Wint-conversion]
   30 |                         (*wkptr) = NULL;
      |                                  ^
main.c:37:34: error: assignment to 'char' from 'void *' makes integer from pointer without a cast [-Wint-conversion]
   37 |                         (*wkptr) = NULL;
      |                                  ^
main.c:44:34: error: assignment to 'char' from 'void *' makes integer from pointer without a cast [-Wint-conversion]
   44 |                         (*wkptr) = NULL;
      |                                  ^
main.c: At top level:
main.c:51:15: error: unknown type name 'wall'
   51 | void initwall(wall* rewall){
      |               ^~~~
main.c: In function 'main':
main.c:68:9: error: unknown type name 'wall'; use 'struct' keyword to refer to the type
   68 |         wall myhouse[wall_max];
      |         ^~~~
      |         struct 
main.c:70:9: error: unknown type name 'wall'; use 'struct' keyword to refer to the type
   70 |         wall *bfpt = NULL;
      |         ^~~~
      |         struct 
main.c:71:9: error: unknown type name 'wall'; use 'struct' keyword to refer to the type
   71 |         wall *nxpt = NULL;
      |         ^~~~
      |         struct 
main.c:72:9: error: unknown type name 'wall'; use 'struct' keyword to refer to the type
   72 |         wall *curpt = NULL;
      |         ^~~~
      |         struct 
main.c:80:17: error: implicit declaration of function 'gets_s' [-Wimplicit-function-declaration]
   80 |                 gets_s(kiroku);
      |                 ^~~~~~
main.c:92:25: error: implicit declaration of function 'initwall' [-Wimplicit-function-declaration]
   92 |                         initwall(myhouse);
      |                         ^~~~~~~~
main.c:95:17: error: 'else' without a previous 'if'
   95 |                 else if(type == 2){ // ?????\???
      |                 ^~~~
main.c:100:41: error: request for member 'catid' in something not a structure or union
  100 |                                 if(curpt->catid == -1){
      |                                         ^~
main.c:101:49: error: request for member 'nextcat' in something not a structure or union
  101 |                                         if(curpt->nextcat != NULL){
      |                                                 ^~
main.c:102:71: error: request for member 'nextcat' in something not a structure or union
  102 |                                                 if(cmcatleng <= (curpt->nextcat->iti - (curpt->iti))){
      |                                                                       ^~
main.c:102:94: error: request for member 'iti' in something not a structure or union
  102 |                                                 if(cmcatleng <= (curpt->nextcat->iti - (curpt->iti))){
      |                                                                                              ^~
main.c:103:62: error: request for member 'catid' in something not a structure or union
  103 |                                                         curpt->catid = cmcatid;
      |                                                              ^~
main.c:104:62: error: request for member 'catleng' in something not a structure or union
  104 |                                                         curpt->catleng = cmcatleng;
      |                                                              ^~
main.c:105:76: error: request for member 'iti' in something not a structure or union
  105 |                                                         printf("%d\n",curpt->iti);
      |                                                                            ^~
main.c:109:70: error: request for member 'nextcat' in something not a structure or union
  109 |                                                         curpt = curpt->nextcat;
      |                                                                      ^~
main.c:113:81: error: request for member 'iti' in something not a structure or union
  113 |                                                 if(cmcatleng <= (wallend - curpt->iti)){ // ????????????
      |                                                                                 ^~
main.c:114:62: error: request for member 'catid' in something not a structure or union
  114 |                                                         curpt->catid = cmcatid;
      |                                                              ^~
main.c:115:62: error: request for member 'catleng' in something not a structure or union
  115 |                                                         curpt->catleng = cmcatleng;
      |                                                              ^~
main.c:116:76: error: request for member 'iti' in something not a structure or union
  116 |                                                         printf("%d\n",curpt->iti);
      |                                                                            ^~
main.c:122:49: error: request for member 'nextcat' in something not a structure or union
  122 |                                         if(curpt->nextcat == NULL){ // ??????????????????????????£???
      |                                                 ^~
main.c:123:82: error: request for member 'iti' in something not a structure or union
  123 |                                                 if(cmcatleng <= (wallend - (curpt->iti + curpt->catleng))){ // ?¬??????????
      |                                                                                  ^~
main.c:123:95: error: request for member 'catleng' in something not a structure or union
  123 |                                                 if(cmcatleng <= (wallend - (curpt->iti + curpt->catleng))){ // ?¬??????????
      |                                                                                               ^~
main.c:125:69: error: request for member 'catleng' in something not a structure or union
  125 |                                                         curpt+=curpt->catleng;
      |                                                                     ^~
main.c:126:61: error: request for member 'nextcat' in something not a structure or union
  126 |                                                         bfpt->nextcat = curpt;
      |                                                             ^~
main.c:127:62: error: request for member 'catid' in something not a structure or union
  127 |                                                         curpt->catid = cmcatid;
      |                                                              ^~
main.c:128:62: error: request for member 'catleng' in something not a structure or union
  128 |                                                         curpt->catleng = cmcatleng;
      |                                                              ^~
main.c:129:76: error: request for member 'iti' in something not a structure or union
  129 |                                                         printf("%d\n",curpt->iti);
      |                                                                            ^~
main.c:139:71: error: request for member 'nextcat' in something not a structure or union
  139 |                                                 if(cmcatleng <= (curpt->nextcat->iti - (curpt->iti+curpt->catleng))){
      |                                                                       ^~
main.c:139:94: error: request for member 'iti' in something not a structure or union
  139 |                                                 if(cmcatleng <= (curpt->nextcat->iti - (curpt->iti+curpt->catleng))){
      |                                                                                              ^~
main.c:139:105: error: request for member 'catleng' in something not a structure or union
  139 |                                                 if(cmcatleng <= (curpt->nextcat->iti - (curpt->iti+curpt->catleng))){
      |                                                                                                         ^~
main.c:141:69: error: request for member 'nextcat' in something not a structure or union
  141 |                                                         nxpt = curpt->nextcat;
      |                                                                     ^~
main.c:142:69: error: request for member 'catleng' in something not a structure or union
  142 |                                                         curpt+=curpt->catleng;
      |                                                                     ^~
main.c:143:61: error: request for member 'nextcat' in something not a structure or union
  143 |                                                         bfpt->nextcat = curpt;
      |                                                             ^~
main.c:144:62: error: request for member 'catid' in something not a structure or union
  144 |                                                         curpt->catid = cmcatid;
      |                                                              ^~
main.c:145:62: error: request for member 'catleng' in something not a structure or union
  145 |                                                         curpt->catleng = cmcatleng;
      |                                                              ^~
main.c:146:62: error: request for member 'nextcat' in something not a structure or union
  146 |                                                         curpt->nextcat = nxpt;
      |                                                              ^~
main.c:147:76: error: request for member 'iti' in something not a structure or union
  147 |                                                         printf("%d\n",curpt->iti);
      |