Reng v.3.2, 88 bytes
(Noncompeting, postdates question.)
This is one heckuvan answer.
Stores 2 to
y (the temporary counter) and
z (the overall counter), and initiates the stack with
"a" then goes to the next line.
:1+ duplicates the previously made run of characters and increments it to work with the next one. Then...
Generating N copies of a number
This loops until
y == 0. Once
y is zero, we exit the loop. Otherwise, we put
y - 1 back into
y and duplicate the character being worked with it.
Breaking out of this loop
y from the conditional and increments and duplicates
z, which is then put into y and z. Then, if
R (26 + 1) is
z, we go to the next part. Otherwise, the loop continues again.
This goes out of the loop, pushes
1 (our equality counter), reverses the stack, and goes to the third line.
i sve(*?v) loops until (a) there is no input or (b) the equality counter is 0. In the first case, the first
v is met, and we drop the -1 bit, skip over the
>0 bit (
2.), and output 42 (
~ with a conditional. Otherwise, the second
v is encountered, and a zero is pushed before the
76**, so this makes it zero. The conditional activates the
~ (exit program) command because the TOS is falsey, and thus no output is given.