Language: C

X,Y,n;k[16];s[10][10];sd[10][10];dd;sx[16],sy[16];bf[16];bn;E(bx,by,w,h){int y;for(;w--;)for(y=h;y--;)if(s[bx+w][by+y])return 0;return 1;}F(bx,by,w,h,b){int y;for(;w--;)for(y=h;y--;)s[bx+w][by+y]=b;}SB(bx,by,w,h,b){if(bx+w<=X&&by+h<=Y&&bx+w>sx[b]&&by+h>sy[b]&&E(bx,by,w,h)){F(bx,by,w,h,b);bf[b]=1;++bn==n?dd++&&main(puts("NA")),memcpy(sd,s,sizeof(sd)):SP(bx,by+1);bn--;bf[b]=0;F(bx,by,w,h,0);}}SP(bx,by){int b,w,h;if(by==Y){by-=Y;if(++bx==X)return;}if(s[bx][by])SP(bx,by+1);elsefor(b=1;b<=n;b++)if(!bf[b]&&bx<=sx[b]&&by<=sy[b])for(w=1;h=k[b]/w,w<=h;w++)if(w*h==k[b]){SB(bx,by,w,h,b);w<h&&SB(bx,by,h,w,b);}}main(i,x,y){for(;scanf("%d%d%d",&X,&Y,&n),X;){memset(bf,dd=bn=0,sizeof(bf));for(i=n;i--;k[x]=y)scanf("%d%d",&x,&y);for(y=0;y<Y;y++)for(x=0;x<X;x++){s[x][y]=0;scanf("%d",&i);if(i){sx[i]=x;sy[i]=y;}}SP(0,0);if(dd)for(y=0;y<Y;y++)for(x=0;x<X;x++)printf("%d%c",sd[x][y],x<X-1?32:10);elseputs("NA");}exit(0);}

Compiler output:
main.c:1:1: warning: data definition has no type or storage class
    1 | X,Y,n;k[16];s[10][10];sd[10][10];dd;sx[16],sy[16];bf[16];bn;E(bx,by,w,h){int y;for(;w--;)for(y=h;y--;)if(s[bx+w][by+y])return 0;return 1;}F(bx,by,w,h,b){int y;for(;w--;)for(y=h;y--;)s[bx+w][by+y]=b;}SB(bx,by,w,h,b){if(bx+w<=X&&by+h<=Y&&bx+w>sx[b]&&by+h>sy[b]&&E(bx,by,w,h)){F(bx,by,w,h,b);bf[b]=1;++bn==n?dd++&&main(puts("NA")),memcpy(sd,s,sizeof(sd)):SP(bx,by+1);bn--;bf[b]=0;F(bx,by,w,h,0);}}SP(bx,by){int b,w,h;if(by==Y){by-=Y;if(++bx==X)return;}if(s[bx][by])SP(bx,by+1);elsefor(b=1;b<=n;b++)if(!bf[b]&&bx<=sx[b]&&by<=sy[b])for(w=1;h=k[b]/w,w<=h;w++)if(w*h==k[b]){SB(bx,by,w,h,b);w<h&&SB(bx,by,h,w,b);}}main(i,x,y){for(;scanf("%d%d%d",&X,&Y,&n),X;){memset(bf,dd=bn=0,sizeof(bf));for(i=n;i--;k[x]=y)scanf("%d%d",&x,&y);for(y=0;y<Y;y++)for(x=0;x<X;x++){s[x][y]=0;scanf("%d",&i);if(i){sx[i]=x;sy[i]=y;}}SP(0,0);if(dd)for(y=0;y<Y;y++)for(x=0;x<X;x++)printf("%d%c",sd[x][y],x<X-1?32:10);elseputs("NA");}exit(0);}
      | ^
main.c:1:1: error: type defaults to 'int' in declaration of 'X' [-Wimplicit-int]
main.c:1:3: error: type defaults to 'int' in declaration of 'Y' [-Wimplicit-int]
    1 | X,Y,n;k[16];s[10][10];sd[10][10];dd;sx[16],sy[16];bf[16];bn;E(bx,by,w,h){int y;for(;w--;)for(y=h;y--;)if(s[bx+w][by+y])return 0;return 1;}F(bx,by,w,h,b){int y;for(;w--;)for(y=h;y--;)s[bx+w][by+y]=b;}SB(bx,by,w,h,b){if(bx+w<=X&&by+h<=Y&&bx+w>sx[b]&&by+h>sy[b]&&E(bx,by,w,h)){F(bx,by,w,h,b);bf[b]=1;++bn==n?dd++&&main(puts("NA")),memcpy(sd,s,sizeof(sd)):SP(bx,by+1);bn--;bf[b]=0;F(bx,by,w,h,0);}}SP(bx,by){int b,w,h;if(by==Y){by-=Y;if(++bx==X)return;}if(s[bx][by])SP(bx,by+1);elsefor(b=1;b<=n;b++)if(!bf[b]&&bx<=sx[b]&&by<=sy[b])for(w=1;h=k[b]/w,w<=h;w++)if(w*h==k[b]){SB(bx,by,w,h,b);w<h&&SB(bx,by,h,w,b);}}main(i,x,y){for(;scanf("%d%d%d",&X,&Y,&n),X;){memset(bf,dd=bn=0,sizeof(bf));for(i=n;i--;k[x]=y)scanf("%d%d",&x,&y);for(y=0;y<Y;y++)for(x=0;x<X;x++){s[x][y]=0;scanf("%d",&i);if(i){sx[i]=x;sy[i]=y;}}SP(0,0);if(dd)for(y=0;y<Y;y++)for(x=0;x<X;x++)printf("%d%c",sd[x][y],x<X-1?32:10);elseputs("NA");}exit(0);}
      |   ^
main.c:1:5: error: type defaults to 'int' in declaration of 'n' [-Wimplicit-int]
    1 | X,Y,n;k[16];s[10][10];sd[10][10];dd;sx[16],sy[16];bf[16];bn;E(bx,by,w,h){int y;for(;w--;)for(y=h;y--;)if(s[bx+w][by+y])return 0;return 1;}F(bx,by,w,h,b){int y;for(;w--;)for(y=h;y--;)s[bx+w][by+y]=b;}SB(bx,by,w,h,b){if(bx+w<=X&&by+h<=Y&&bx+w>sx[b]&&by+h>sy[b]&&E(bx,by,w,h)){F(bx,by,w,h,b);bf[b]=1;++bn==n?dd++&&main(puts("NA")),memcpy(sd,s,sizeof(sd)):SP(bx,by+1);bn--;bf[b]=0;F(bx,by,w,h,0);}}SP(bx,by){int b,w,h;if(by==Y){by-=Y;if(++bx==X)return;}if(s[bx][by])SP(bx,by+1);elsefor(b=1;b<=n;b++)if(!bf[b]&&bx<=sx[b]&&by<=sy[b])for(w=1;h=k[b]/w,w<=h;w++)if(w*h==k[b]){SB(bx,by,w,h,b);w<h&&SB(bx,by,h,w,b);}}main(i,x,y){for(;scanf("%d%d%d",&X,&Y,&n),X;){memset(bf,dd=bn=0,sizeof(bf));for(i=n;i--;k[x]=y)scanf("%d%d",&x,&y);for(y=0;y<Y;y++)for(x=0;x<X;x++){s[x][y]=0;scanf("%d",&i);if(i){sx[i]=x;sy[i]=y;}}SP(0,0);if(dd)for(y=0;y<Y;y++)for(x=0;x<X;x++)printf("%d%c",sd[x][y],x<X-1?32:10);elseputs("NA");}exit(0);}
      |     ^
main.c:1:7: warning: data definition has no type or storage class
    1 | X,Y,n;k[16];s[10][10];sd[10][10];dd;sx[16],sy[16];bf[16];bn;E(bx,by,w,h){int y;for(;w--;)for(y=h;y--;)if(s[bx+w][by+y])return 0;return 1;}F(bx,by,w,h,b){int y;for(;w--;)for(y=h;y--;)s[bx+w][by+y]=b;}SB(bx,by,w,h,b){if(bx+w<=X&&by+h<=Y&&bx+w>sx[b]&&by+h>sy[b]&&E(bx,by,w,h)){F(bx,by,w,h,b);bf[b]=1;++bn==n?dd++&&main(puts("NA")),memcpy(sd,s,sizeof(sd)):SP(bx,by+1);bn--;bf[b]=0;F(bx,by,w,h,0);}}SP(bx,by){int b,w,h;if(by==Y){by-=Y;if(++bx==X)return;}if(s[bx][by])SP(bx,by+1);elsefor(b=1;b<=n;b++)if(!bf[b]&&bx<=sx[b]&&by<=sy[b])for(w=1;h=k[b]/w,w<=h;w++)if(w*h==k[b]){SB(bx,by,w,h,b);w<h&&SB(bx,by,h,w,b);}}main(i,x,y){for(;scanf("%d%d%d",&X,&Y,&n),X;){memset(bf,dd=bn=0,sizeof(bf));for(i=n;i--;k[x]=y)scanf("%d%d",&x,&y);for(y=0;y<Y;y++)for(x=0;x<X;x++){s[x][y]=0;scanf("%d",&i);if(i){sx[i]=x;sy[i]=y;}}SP(0,0);if(dd)for(y=0;y<Y;y++)for(x=0;x<X;x++)printf("%d%c",sd[x][y],x<X-1?32:10);elseputs("NA");}exit(0);}
      |       ^
main.c:1:7: error: type defaults to 'int' in declaration of 'k' [-Wimplicit-int]
main.c:1:13: warning: data definition has no type or storage class
    1 | X,Y,n;k[16];s[10][10];sd[10][10];dd;sx[16],sy[16];bf[16];bn;E(bx,by,w,h){int y;for(;w--;)for(y=h;y--;)if(s[bx+w][by+y])return 0;return 1;}F(bx,by,w,h,b){int y;for(;w--;)for(y=h;y--;)s[bx+w][by+y]=b;}SB(bx,by,w,h,b){if(bx+w<=X&&by+h<=Y&&bx+w>sx[b]&&by+h>sy[b]&&E(bx,by,w,h)){F(bx,by,w,h,b);bf[b]=1;++bn==n?dd++&&main(puts("NA")),memcpy(sd,s,sizeof(sd)):SP(bx,by+1);bn--;bf[b]=0;F(bx,by,w,h,0);}}SP(bx,by){int b,w,h;if(by==Y){by-=Y;if(++bx==X)return;}if(s[bx][by])SP(bx,by+1);elsefor(b=1;b<=n;b++)if(!bf[b]&&bx<=sx[b]&&by<=sy[b])for(w=1;h=k[b]/w,w<=h;w++)if(w*h==k[b]){SB(bx,by,w,h,b);w<h&&SB(bx,by,h,w,b);}}main(i,x,y){for(;scanf("%d%d%d",&X,&Y,&n),X;){memset(bf,dd=bn=0,sizeof(bf));for(i=n;i--;k[x]=y)scanf("%d%d",&x,&y);for(y=0;y<Y;y++)for(x=0;x<X;x++){s[x][y]=0;scanf("%d",&i);if(i){sx[i]=x;sy[i]=y;}}SP(0,0);if(dd)for(y=0;y<Y;y++)for(x=0;x<X;x++)printf("%d%c",sd[x][y],x<X-1?32:10);elseputs("NA");}exit(0);}
      |             ^
main.c:1:13: error: type defaults to 'int' in declaration of 's' [-Wimplicit-int]
main.c:1:23: warning: data definition has no type or storage class
    1 | X,Y,n;k[16];s[10][10];sd[10][10];dd;sx[16],sy[16];bf[16];bn;E(bx,by,w,h){int y;for(;w--;)for(y=h;y--;)if(s[bx+w][by+y])return 0;return 1;}F(bx,by,w,h,b){int y;for(;w--;)for(y=h;y--;)s[bx+w][by+y]=b;}SB(bx,by,w,h,b){if(bx+w<=X&&by+h<=Y&&bx+w>sx[b]&&by+h>sy[b]&&E(bx,by,w,h)){F(bx,by,w,h,b);bf[b]=1;++bn==n?dd++&&main(puts("NA")),memcpy(sd,s,sizeof(sd)):SP(bx,by+1);bn--;bf[b]=0;F(bx,by,w,h,0);}}SP(bx,by){int b,w,h;if(by==Y){by-=Y;if(++bx==X)return;}if(s[bx][by])SP(bx,by+1);elsefor(b=1;b<=n;b++)if(!bf[b]&&bx<=sx[b]&&by<=sy[b])for(w=1;h=k[b]/w,w<=h;w++)if(w*h==k[b]){SB(bx,by,w,h,b);w<h&&SB(bx,by,h,w,b);}}main(i,x,y){for(;scanf("%d%d%d",&X,&Y,&n),X;){memset(bf,dd=bn=0,sizeof(bf));for(i=n;i--;k[x]=y)scanf("%d%d",&x,&y);for(y=0;y<Y;y++)for(x=0;x<X;x++){s[x][y]=0;scanf("%d",&i);if(i){sx[i]=x;sy[i]=y;}}SP(0,0);if(dd)for(y=0;y<Y;y++)for(x=0;x<X;x++)printf("%d%c",sd[x][y],x<X-1?32:10);elseputs("NA");}exit(0);}
      |                       ^~
main.c:1:23: error: type defaults to 'int' in declaration of 'sd' [-Wimplicit-int]
main.c:1:34: warning: data definition has no type or storage class
    1 | X,Y,n;k[16];s[10][10];sd[10][10];dd;sx[16],sy[16];bf[16];bn;E(bx,by,w,h){int y;for(;w--;)for(y=h;y--;)if(s[bx+w][by+y])return 0;return 1;}F(bx,by,w,h,b){int y;for(;w--;)for(y=h;y--;)s[bx+w][by+y]=b;}SB(bx,by,w,h,b){if(bx+w<=X&&by+h<=Y&&bx+w>sx[b]&&by+h>sy[b]&&E(bx,by,w,h)){F(bx,by,w,h,b);bf[b]=1;++bn==n?dd++&&main(puts("NA")),memcpy(sd,s,sizeof(sd)):SP(bx,by+1);bn--;bf[b]=0;F(bx,by,w,h,0);}}SP(bx,by){int b,w,h;if(by==Y){by-=Y;if(++bx==X)return;}if(s[bx][by])SP(bx,by+1);elsefor(b=1;b<=n;b++)if(!bf[b]&&bx<=sx[b]&&by<=sy[b])for(w=1;h=k[b]/w,w<=h;w++)if(w*h==k[b]){SB(bx,by,w,h,b);w<h&&SB(bx,by,h,w,b);}}main(i,x,y){for(;scanf("%d%d%d",&X,&Y,&n),X;){memset(bf,dd=bn=0,sizeof(bf));for(i=n;i--;k[x]=y)scanf("%d%d",&x,&y);for(y=0;y<Y;y++)for(x=0;x<X;x++){s[x][y]=0;scanf("%d",&i);if(i){sx[i]=x;sy[i]=y;}}SP(0,0);if(dd)for(y=0;y<Y;y++)for(x=0;x<X;x++)printf("%d%c",sd[x][y],x<X-1?32:10);elseputs("NA");}exit(0);}
      |                                  ^~
main.c:1:34: error: type defaults to 'int' in declaration of 'dd' [-Wimplicit-int]
main.c:1:37: warning: data definition has no type or storage class
    1 | X,Y,n;k[16];s[10][10];sd[10][10];dd;sx[16],sy[16];bf[16];bn;E(bx,by,w,h){int y;for(;w--;)for(y=h;y--;)if(s[bx+w][by+y])return 0;return 1;}F(bx,by,w,h,b){int y;for(;w--;)for(y=h;y--;)s[bx+w][by+y]=b;}SB(bx,by,w,h,b){if(bx+w<=X&&by+h<=Y&&bx+w>sx[b]&&by+h>sy[b]&&E(bx,by,w,h)){F(bx,by,w,h,b);bf[b]=1;++bn==n?dd++&&main(puts("NA")),memcpy(sd,s,sizeof(sd)):SP(bx,by+1);bn--;bf[b]=0;F(bx,by,w,h,0);}}SP(bx,by){int b,w,h;if(by==Y){by-=Y;if(++bx==X)return;}if(s[bx][by])SP(bx,by+1);elsefor(b=1;b<=n;b++)if(!bf[b]&&bx<=sx[b]&&by<=sy[b])for(w=1;h=k[b]/w,w<=h;w++)if(w*h==k[b]){SB(bx,by,w,h,b);w<h&&SB(bx,by,h,w,b);}}main(i,x,y){for(;scanf("%d%d%d",&X,&Y,&n),X;){memset(bf,dd=bn=0,sizeof(bf));for(i=n;i--;k[x]=y)scanf("%d%d",&x,&y);for(y=0;y<Y;y++)for(x=0;x<X;x++){s[x][y]=0;scanf("%d",&i);if(i){sx[i]=x;sy[i]=y;}}SP(0,0);if(dd)for(y=0;y<Y;y++)for(x=0;x<X;x++)printf("%d%c",sd[x][y],x<X-1?32:10);elseputs("NA");}exit(0);}
      |                                     ^~
main.c:1:37: error: type defaults to 'int' in declaration of 'sx' [-Wimplicit-int]
main.c:1:44: error: type defaults to 'int' in declaration of 'sy' [-Wimplicit-int]
    1 | X,Y,n;k[16];s[10][10];sd[10][10];dd;sx[16],sy[16];bf[16];bn;E(bx,by,w,h){int y;for(;w--;)for(y=h;y--;)if(s[bx+w][by+y])return 0;return 1;}F(bx,by,w,h,b){int y;for(;w--;)for(y=h;y--;)s[bx+w][by+y]=b;}SB(bx,by,w,h,b){if(bx+w<=X&&by+h<=Y&&bx+w>sx[b]&&by+h>sy[b]&&E(bx,by,w,h)){F(bx,by,w,h,b);bf[b]=1;++bn==n?dd++&&main(puts("NA")),memcpy(sd,s,sizeof(sd)):SP(bx,by+1);bn--;bf[b]=0;F(bx,by,w,h,0);}}SP(bx,by){int b,w,h;if(by==Y){by-=Y;if(++bx==X)return;}if(s[bx][by])SP(bx,by+1);elsefor(b=1;b<=n;b++)if(!bf[b]&&bx<=sx[b]&&by<=sy[b])for(w=1;h=k[b]/w,w<=h;w++)if(w*h==k[b]){SB(bx,by,w,h,b);w<h&&SB(bx,by,h,w,b);}}main(i,x,y){for(;scanf("%d%d%d",&X,&Y,&n),X;){memset(bf,dd=bn=0,sizeof(bf));for(i=n;i--;k[x]=y)scanf("%d%d",&x,&y);for(y=0;y<Y;y++)for(x=0;x<X;x++){s[x][y]=0;scanf("%d",&i);if(i){sx[i]=x;sy[i]=y;}}SP(0,0);if(dd)for(y=0;y<Y;y++)for(x=0;x<X;x++)printf("%d%c",sd[x][y],x<X-1?32:10);elseputs("NA");}exit(0);}
      |                                            ^~
main.c:1:51: warning: data definition has no type or storage class
    1 | X,Y,n;k[16];s[10][10];sd[10][10];dd;sx[16],sy[16];bf[16];bn;E(bx,by,w,h){int y;for(;w--;)for(y=h;y--;)if(s[bx+w][by+y])return 0;return 1;}F(bx,by,w,h,b){int y;for(;w--;)for(y=h;y--;)s[bx+w][by+y]=b;}SB(bx,by,w,h,b){if(bx+w<=X&&by+h<=Y&&bx+w>sx[b]&&by+h>sy[b]&&E(bx,by,w,h)){F(bx,by,w,h,b);bf[b]=1;++bn==n?dd++&&main(puts("NA")),memcpy(sd,s,sizeof(sd)):SP(bx,by+1);bn--;bf[b]=0;F(bx,by,w,h,0);}}SP(bx,by){int b,w,h;if(by==Y){by-=Y;if(++bx==X)return;}if(s[bx][by])SP(bx,by+1);elsefor(b=1;b<=n;b++)if(!bf[b]&