Thank you very much for your attention.
I'm facing a mental block to achieve this in a performant manner:
Input:
a
a
b
c
c
c
d
Desired output:
a 1
a 1
b 2
c 3
c 3
c 3
d 4
Any suggestions? Have a good day (night, afternoon or evening) and
greetings from México City.