# C++ 353

**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];i<=o.size();++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.substr(0,t)+(p+99)+&o[t+strlen(p)];bzero(q=p,198);s=p+99;}}}

[Try it online!](https://tio.run/##PY9Bb4JAEIXv/RVrTJoZlkq1Ni2sq4mnnjDxChwUFt0EdldY00Zj/zpdxPQ0M29e8t6XG/NyyPOuG8va6MYu9tK2QWuLnNLJcfk0LkQplSAx/KBOZIZMVK0gsgS1GBTOw9nq37choBNKnTEanvOPlaI0esqPu4aYZBp@Zr534sb3Wm5oGDKpLJG@ZfVOKugP5fdez6vxWuoGXJcoam0j1YFoXifTjMkF15NWXgQgc1l4dXVGMbyhOdt7zoY8Nohhjt6JUr6B@4jhHb12uPsxMPU4y/mQp/iM/YJ1CQ6oAONLOkVkqPvM8941gVffIoW@PdJnnVjqxEooMJix/UU0GnpAh4rsAXm73bquC0qtgy9RVdon37qpilEQrNMgTbf3zzpIt38 "C++ (gcc) – Try It Online")