#include <stdio.h>#include <stdlib.h>#include <string.h>#define F(I)I=*--c,#define P(C),q-*#C||(char**c,**d,**e=NULL,*f,*g,*h,*i,*j=NULL,*p;int k,l,q,z=-1;size_t n,o,y=sizeof*d;FILE*m=NULL;int main(int a,char**b){c=d=e,f=g=h=i=j,a&&(p=strchr(b[1],'.'))&&!(strcmp(p,".bak")&&strcmp(p,".BAK"))&&(m=fopen(b[1],"r")),(l=!m)&&(m=stdin);for(n=o=0;o>=n;h=(g=realloc(g,n+=256))?&g[o+=fread(&g[o],1,256,m)]:(exit(2),g));for(f=g;f-h||c-d;f=p)q=z[p=f+1],(k=q-'$')&&q-'*'||(c<e||((d=realloc(d,((o=c-d)+10)*y))?(e=(c=d+o)+10):(exit(2),d)),*c=k?c[z]:f,c++)P(:)p=*--c)P(<)F(j)F(i)*c++=j<i?j:i)P(>)F(j)F(i)*c++=j>i?j:i)P(;)F(j)F(i)c[z]+=j-i)P(+)F(j)F(i)(k=getchar())-EOF?(*i=k,p):(p=j))P(-)putchar(**--c))P(@)F(j)F(i)i=memchr(i,*c[z],j-i),c[z]=i?i:j)P(=)F(j)*j=**--c)P(/)i=c[-2],c[-2]=c[z],c[z]=i)P(\\)i=c[z],c[z]=c[-2],c[-2]=c[-3],c[-3]=i)P(!)--c)P(|)i=c[z],c[z]=*d,*d=i)P([)i=c[z],memmove(d+1,d,y*(c-d-1)),*d=i)P(])i=*d,memmove(d,d+1,y*(c-d-1)),c[z]=i)P(^)(i=c[z])<*d||(c[z]=*d,*d=i,0));l||fclose(m),free(d),free(g),exit(0);}