/* Integral-height transfer. Each state fixes current vertical steps and the incoming horizontal offsets. Global height negation puts offset 0 at +1. This implementation uses only standard C library functions; declarations are provided explicitly for the minimal clang runtime bundled with Lean. */ typedef unsigned long long U64; typedef unsigned int U32; typedef __SIZE_TYPE__ Size; extern int printf(const char *, ...); extern int atoi(const char *); extern void *calloc(Size, Size); extern void *malloc(Size); extern void free(void *); extern void exit(int); typedef struct {int word, incoming, offset, finish;} State; static void checked_add(U64 *target, U64 amount) { U64 old=*target; *target+=amount; if (*target14||maxn<2||d<2||d>30) return 1; int words=1<<(m-1), columns=1<>1))&edges; if(((l>>1)^x)&flip) continue; st[count].word=x;st[count].incoming=l; st[count].finish=__builtin_popcount((plus[x]&~l)|(minus[x]&l)); id[(U64)x*columns+l]=count++; } } if(count!=nstate) return 3; int *startR=calloc(words+1,sizeof(int)); int *rights=calloc(2*nstate,sizeof(int)); count=0; for(int x=0;x>1))&edges; if(!((x^r)&flip)) rights[count++]=r; } } startR[words]=count; if(count!=2*nstate) return 4; U64 num_arcs=0; for(int s=0;s2000000000ULL) return 5; U32 *arc=malloc(num_arcs*sizeof(U32)); U64 *old=calloc((U64)nstate*K,sizeof(U64)),*next=calloc((U64)nstate*K,sizeof(U64)); if(!arc||!old||!next) return 6; int at=0; for(int s=0;s>1))&edges); int begin=__builtin_popcount((plus[prev]&l)|(minus[prev]&~l)); if(begin<=d) old[(U64)s*K+begin]=2; st[s].offset=at; for(int rix=startR[x];rix>1))&edges,xx=x^flip,ll=r; if(!(ll&1)) {xx^=edges;ll^=full;} int weight=__builtin_popcount((plus[x]&~l&r)|(minus[x]&l&~r)); arc[at++]=(id[(U64)xx*columns+ll]<<5)|weight; } } st[nstate].offset=at; free(id);free(rights);free(startR); printf("height %d states %d arcs %d\n",m,nstate,at); for(int n=2;n<=maxn;n++) { U64 coeff[32]={0}; for(int s=0;sd) continue; for(int i=st[s].offset;i>5)*K; for(int k=low;k+cost<=d;k++) checked_add(to+k+cost,from[k]); } } printf("%d",n);for(int k=0;k<=d;k++)printf(" %llu",coeff[k]);printf("\n"); U64 *temp=next;next=old;old=temp; for(U64 k=0;k<(U64)nstate*K;k++)next[k]=0; } free(st);free(plus);free(minus);free(arc);free(old);free(next);return 0; }