#!/usr/bin/perl
use 5.016;
use warnings;
sub prestr
{ $_[1] >= 0 ? substr($_[0], 0, $_[1]) : '' }
sub f {
my $p = index $_[0], '01'; return prestr
($_[0], $p) . '10' . poststr
($_[0], $p + 2); }
say f('111');
say f('1110');
say f('101100');
say f('1101');
IyEvdXNyL2Jpbi9wZXJsCnVzZSA1LjAxNjsKdXNlIHdhcm5pbmdzOwoKc3ViIHByZXN0ciB7ICRfWzFdID49IDAgPyBzdWJzdHIoJF9bMF0sIDAsICRfWzFdKSA6ICcnIH0Kc3ViIHBvc3RzdHIgeyBqb2luICcnLCBzb3J0IHNwbGl0IC8vLCBzdWJzdHIoJF9bMF0sICRfWzFdKSB9CgpzdWIgZiB7CglteSAkcCA9IGluZGV4ICRfWzBdLCAnMDEnOwoJcmV0dXJuIHByZXN0cigkX1swXSwgJHApIC4gJzEwJyAuIHBvc3RzdHIoJF9bMF0sICRwICsgMik7Cn0KCnNheSBmKCcxMTEnKTsKc2F5IGYoJzExMTAnKTsKc2F5IGYoJzEwMTEwMCcpOwpzYXkgZignMTEwMScpOwo=