Un-de-duplicating strings Introduction

Let's observe the following string:

AABBCCDDEFFGG


You can see that every letter has been duplicated, except for the letter E. That means that the letter E has been de-duplicated. So, the only thing we need to do here is to reverse that process, which gives us the following un-de-duplicated string:

AABBCCDDEEFFGG




Let's take a harder example:

AAAABBBCCCCDD


You can see that there is an uneven number of consecutive B's, so that means that one of the BB was de-duplicated from the original string. We only need to un-de-duplicate this letter, which gives us:

AAAABBBBCCCCDD




The challenge

Given a non-empty de-duplicated string, consisting of only alphabetic characters (either only uppercase or only lowercase), return the un-de-duplicated string. You can assume that there will always be at least one de-duplicated character in the string.



Test cases

AAABBBCCCCDDDD    --&gt;    AAAABBBBCCCCDDDD
HEY               --&gt;    HHEEYY
AAAAAAA           --&gt;    AAAAAAAA
N                 --&gt;    NN
OOQQO             --&gt;    OOQQOO
ABBB              --&gt;    AABBBB
ABBA              --&gt;    AABBAA


This is code-golf, so the shortest valid submission in bytes wins!
MATL, 7 bytes

Y'to+Y"


Try it online! Or verify all test cases.

Let's take 'ABBA' as example input.

Y'   % Implicit input. Run-length decoding
     % STACK: 'ABA', [1 2 1]
t    % Duplicate top of the stack
     % STACK: 'ABA', [1 2 1], [1 2 1]
o    % Modulo 2
     % STACK: 'ABA', [1 2 1], [1 0 1]
+    % Add, element-wise
     % STACK: 'ABA', [2 2 2]
Y"   % Run-length encoding. Implicit display
     % STACK: 'AABBAA'