C++ 338328
Edits:
- Thanks to @algorithmshark for lots of help making the original shorter
- Thanks to @Adalynn for a good suggestion to save bytes
- Thanks to @ceilingcat for many, many very nice pieces of golfing - now even shorter
Here is the code:
#import<bits/stdc++.h> #define N(x)o[i]);else if(n<x)o[i]==92? #define O (o[++i]):o[i]==47?n++: char p[198],*q=p,*s=p+99;int i,t;main(int n,char**m){for(std::string o=m[1];o[i];++i){if(!N(3)putchar O putchar(N(4)*q++=O(*q++=N(5)*s++=O*s++=o[i];if(n>4){for(n=2;~(t=o.find(p,i+1));o=o;)o.substrreplace(0,t)+s+&o[t+strlen,strlen(p)],s=p+99)s=p+99;bzero;bzero(q=p,198);}}}