A0A0, 165 150150 142 bytes
A0A0
A0C3G1G1A0
A0I1A6V0P0G6C6A0
A0A1G-3G-3A0
G-3
A0A0
C3G1G1A0C3G1G1A0
A0A1G-3G-3A0
G-3
A0A0
C3G1G1A0C3G1G1A0
G-10G1G1A0G10A0G-10G1G1A010A0
A0A1G-3G-3A0
G-3
The program consists of three loops right after one another. The first loop does the following:
I1A6V0P0G6C6
I1 ; take character input, store in V0
A6 ; append this line to the line six below
V0 ; operand, holds input
P0 ; prints input
G6 ; jumps to six lines below
C6 ; removes all instructions on the six lines below
We duplicate the operand and print instructions a little lower, so we can print it twice. We then jump to there and the last C6
is to get rid of any other instructions that we didn't need afterwards.
The second loop is empty and is constructed from the first loop. The loop is also partially executed so we can enter the loop at the same place each time. This loop will print the character a second time. Because there is a nice G6
instruction inside the copied instructions that will also be executed, we use that as a way to escape from the infinite loop. This is because six lines below is yet another loop.
G-10G1G1
G-10 ; jumps 10 lines up, back to the first loop
G1 ; no-op
G1 ; no-op
This is a simple infinite loop (also partially executed) that takes us back to the first loop. It's padded with no-ops, since the loops needs at least three instructions. Because the first loop contains a C6
, any redundant instructions in the second loop will be removed once we get back to the first loop.
Edit: Optimized by 15 bytes. I misunderstood the default loop template I make use of in the code. I was under the impression that the amount of G1 and G-3 instructions on line 2 and 4 of the loop resp. needed to match the amount of instructions inside the loop. This is not the case, you only need two of them (although more also work, as long as each line has an equal amount of them). This change removes these extra instructions.
Edit 2: Optimized by 8 bytes. Because of edit one, it turns out that there's actually no minimum of three instructions in the loop. This allows us to drop four instructions (not two, since the loop at the bottom is partially evaluated), totalling eight bytes.