[Question]
  [
The input is a word of lowercase letters not separated by whitespace. A newline at the end is optional.
The same word must be output in a modified version: For each character, double it the second time it appears in the original word, triple it the third time etc.
Example input:
```
bonobo
```
Example output:
```
bonoobbooo
```
Standard I/O rules apply. The shortest code in bytes wins.
Tests provided by @Neil :
```
tutu -> tuttuu
queue -> queuuee
bookkeeper -> boookkkeeepeeer
repetitive -> repeetittiiveee
uncopyrightables -> uncopyrightables
abracadabra -> abraacaaadaaaabbrraaaaa
mississippi -> misssiisssssssiiipppiiii
```
  
[Answer]
# [Jelly](http://github.com/DennisMitchell/jelly), 4 [bytes](https://github.com/DennisMitchell/jelly/wiki/Code-page)
```
;\f"
```
[Try it online!](http://jelly.tryitonline.net/#code=O1xmIg&input=&args=bWlzc2lzc2lwcGk)
### How it works
```
;\f"  Main link. Argument: S (string)
;\    Cumulatively reduce by concatenation.
      This yields the array of all prefixes of S.
  f"  Vectorized filter.
      Keep only occurrences of the nth letter in the nth prefix.
```
[Answer]
# Pyth, 6 bytes
Thanks to [@Doorknob](https://codegolf.stackexchange.com/users/3808/doorknob) for taking off 1 byte.
Thanks to [@Maltysen](https://codegolf.stackexchange.com/users/31343/maltysen) for taking off 5 bytes.
```
s@VQ._
```
[Try it online!](http://pyth.herokuapp.com/?code=s%40VQ._&input=%22bonobo%22&debug=0)
## How it works
---
For example, take the string `"bonobo"`.
`._` makes a list: `['b', 'bo', 'bon', 'bono', 'bonob', 'bonobo']`
`VQ._` means "the preceding function vectorized (applied in parallel) over `Q` and `._`", which means `Q` (the input evaluated) will be treated as a list: `['b', 'o', 'n', 'o', 'b', 'o']`, and then they will be paired by the `@` like this:
```
     Q      ._         @ (intersect)
0:  'b'     'b'       'b'
1:  'o'     'bo'      'o'
2:  'n'     'bon'     'n'
3:  'o'     'bono'    'oo'
4:  'b'     'bonob'   'bb'
5:  'o'     'bonobo'  'ooo'
```
Therefore, `@VQ._` will produce `['b', 'o', 'n', 'oo', 'bb', 'ooo']`.
The `s` then joins them all together, creating a string `'bonoobbooo'`, which is then implicitly printed out to become `bonoobbooo`.
[Answer]
## [Retina](https://github.com/mbuettner/retina), ~~34~~ 19 bytes
*Saved 15 bytes by taking some inspiration from isaacg's solution.*
Byte count assumes ISO 8859-1 encoding.
```
$`¶
(\D)(?!.*\1¶)
```
The leading and trailing empty lines are significant.
[Try it online!](http://retina.tryitonline.net/#code=CiRgwrYKKFxEKSg_IS4qXDHCtikK&input=Ym9va2tlZXBlcg)
### Explanation
```
$`¶
```
This is a replace stage which matches the empty regex (i.e. every zero-width position in the string) and substitutes `$`¶` for it, where `$`` is the prefix of the match and `¶` inserts a linefeed. This basically computes all the prefixes and puts them on a separate line together with the last character of that prefix:
```
bb
obo
oboo
kbook
kbookk
ebookke
ebookkee
pbookkeep
ebookkeepe
rbookkeeper
```
There will be some leading and trailing linefeeds, but we can ignore them.
From each of these prefixes we want to keep the characters that are equal to the last character. For that we use another replace stage:
```
(\D)(?!.*\1¶)
```
This matches everything we *don't* want to keep and replaces it with a nothing. We match any character (using `\D` since we know there won't be digits in the input) and then make sure that there *isn't* another copy of that character at the end of the line.
[Answer]
## Haskell, 39 bytes
```
f""=""
f x=f(init x)++filter(==last x)x
```
Usage example: `f "bonobo"` -> `"bonoobbooo"`.
Different enough from [@Damien's answer](https://codegolf.stackexchange.com/a/77047/34531). Builds the string from the right by extracting all occurrences of the last character from the string and prepending a recursive call with all but the last character. 
[Answer]
## Python, 56 bytes
I seem to be stuck with two answers of the same length:
```
f=lambda x,*y:x and-~y.count(x[0])*x[0]+f(x[1:],x[0],*y)
f=lambda x,y=0:x[y:]and-~x[:y].count(x[y])*x[y]+f(x,y+1)
```
Edit: See [@pacholik's answer](https://codegolf.stackexchange.com/a/77059/21487) for a shorter, alternative Python approach.
[Answer]
## [><>](http://esolangs.org/wiki/Fish), 27 bytes
```
>i:0g1+:\
:{-1v!?:<}o
/p${/
```
Requires the official interpreter which exits with an error when trying to print code point -1. [Try it online!](http://fish.tryitonline.net/#code=Pmk6MGcxKzpcCjp7LTF2IT86PH1vCi9wJHsv&input=c2VzcXVpY2VudGVubmlhbA)
The code reads input one char at a time and uses the first row of the codebox as a large array which stores the number of times each char has been seen so far (><> initialises non-program cells to 0). The second row is a loop for outputting a char multiple times.
Alternatively, here's a version which exits cleanly (37 bytes, not properly golfed):
```
>i:0(?;:0g1+:\
}o:{-1v!?:   <
v  p${<
```
[Answer]
## JavaScript (ES6), ~~48~~ 45 bytes
```
s=>s.replace(n=/./g,c=>c.repeat(n[c]=-~n[c]))
```
Edit: Saved 3 bytes thanks to @user81655.
[Answer]
# Haskell, ~~50~~ ~~42~~ 41 bytes
Saved 8 bytes thanks to Lynn
```
f t=[c|(i,c)<-zip[1..]t,x<-take i t,c==x]
```
[Answer]
# [MATL](https://esolangs.org/wiki/MATL), 8 bytes
```
tt!=RsY"
```
[Try it online!](http://matl.tryitonline.net/#code=dHQhPVJzWSI&input=J2Jvbm9ibyc) Or [verify all test cases at once](http://matl.tryitonline.net/#code=YGkKdHQhPVJzWSIKdEQ&input=J3R1dHUnCidxdWV1ZScKJ2Jvb2trZWVwZXInCidyZXBldGl0aXZlJwondW5jb3B5cmlnaHRhYmxlcycKJ2FicmFjYWRhYnJhJwonbWlzc2lzc2lwcGkn).
### Explanation
```
t    % take input string implictly. Duplicate
t!   % duplicate and transpose into a column
=    % test for equality with broadcast. Gives an NxN array, where N is
     % input string length
R    % upper triangular part: set entries below the diagonal to 0
s    % sum of each column. For each postion in the input, gives how many
     % times that letter has appeared up to that position
Y"   % replicate elements (run-length decoding). Display implicitly
```
[Answer]
## [Labyrinth](https://github.com/mbuettner/labyrinth), ~~54~~ 25 bytes
```
<#; "#: ={},>
 }=}(.);("@
```
Another collab with @MartinBüttner, who actually did ~~most~~ almost all of the golfing for this one. By revamping the algorithm, we've managed to cut down the program size by quite a bit!
[Try it online!](http://labyrinth.tryitonline.net/#code=PCM7ICIjOiA9e30sPgogfT19KC4pOygiQA&input=c2VzcXVpY2VudGVubmlhbA)
### Explanation
A quick Labrinth primer:
* Labyrinth is a stack-based 2D language. There are two stacks, a main and auxiliary stack, and popping from an empty stack yields zero.
* At each junction, where there are multiple paths for the instruction pointer to move down, the top of the main stack is checked to see where to go next. Negative is turn left, zero is straight ahead and positive is turn right.
The two stacks of arbitrary-precision integers isn't much flexibility in terms of memory options. To perform the counting, this program actually uses the two stacks as a tape, with shifting a value from one stack to the other being akin to moving a memory pointer left/right by a cell. It's not quite the same as that though, since we need to drag a loop counter with us on the way up.
[![enter image description here](https://i.stack.imgur.com/doALR.png)](https://i.stack.imgur.com/doALR.png)
First off, the `<` and `>` on either end pop an offset and rotate the row of code that offset away by one either left or right. This mechanism is used to make the code run in a loop - the `<` pops a zero and rotates the current row left, putting the IP at the right of the code, and the `>` pops another zero and fixes the row back.
Here's what happens each iteration, in relation to the diagram above:
```
[Section 1]
,}    Read char of input and shift to aux - the char will be used as a counter
      to determine how many elements to shift
[Section 2 - shift loop]
{     Shift counter from aux
"     No-op at a junction: turn left to [Section 3] if char was EOF (-1), otherwise
      turn right
(     Decrement counter; go forward to [Section 4] if zero, otherwise turn right
=     Swap tops of main and aux - we've pulled a value from aux and moved the
      decremented counter to aux, ready for the next loop iteration
[Section 3]
@     Terminate
[Section 4]
;     Pop the zeroed counter
)     Increment the top of the main stack, updating the count of the number of times
      we've seen the read char
:     Copy the count, to determine how many chars to output
[Section 5 - output loop]
#.    Output (number of elements on stack) as a char
(     Decrement the count of how many chars to output; go forward to [Section 6]
      if zero, otherwise turn right
"     No-op
[Section 6]
}     Shift the zeroed counter to aux
[Section 7a]
This section is meant to shift one element at a time from main to aux until the main
stack is empty, but the first iteration actually traverses the loop the wrong way!
Suppose the stack state is [... a b c | 0 d e ...].
=     Swap tops of main and aux               [... a b 0 | c d e ...]
}     Move top of main to aux                 [... a b | 0 c d e ...]
#;    Push stack depth and pop it (no-op)
=     Swap tops of main and aux               [... a 0 | b c d e ...]
      Top is 0 at a junction - can't move
      forwards so we bounce back
;     Pop the top 0                           [... a | b c d e ... ]
The net result is that we've shifted two chars from main to aux and popped the
extraneous zero. From here the loop is traversed anticlockwise as intended.
[Section 7b - unshift loop]
#     Push stack depth; if zero, move forward to the <, else turn left
}=    Move to aux and swap main and aux, thus moving the char below (stack depth)
      to aux
;     Pop the stack depth
```
[Answer]
## Perl, 17
**(16 bytes code, +1 for -p)**
```
s/./${$&}.=$&/ge
```
### Usage:
```
perl -pe 's/./${$&}.=$&/ge' <<< 'bonobo'
bonoobbooo
```
[Answer]
# Pyth, 7 bytes
```
s@Led._
```
[Test suite](https://pyth.herokuapp.com/?code=s%40Led._&input=%22bonobo%22&test_suite=1&test_suite_input=%22tutu%22%0A%22queue%22%0A%22uncopyrightables%22%0A%22bookkeeper%22%0A%22repetitive%22%0A%22abracadabra%22%0A%22mississippi%22&debug=0)
*Test suite thanks to DenkerAffe*
Explanation:
```
s@Led._
     ._    All prefixes, implicitly applied to the input.
 @L        Filter each prefix for characters equal to
   ed      the last character of the prefix
s          Concatenate and implicitly print.
```
[Answer]
# Python 3, 52
```
def f(s):*s,x=s;return s and f(s)+x+x*s.count(x)or x
```
[Answer]
## PowerShell v2+, ~~52~~ 47 bytes
```
$b=@{};-join([char[]]$args[0]|%{"$_"*++$b[$_]})
```
Constructs an empty hashtable, stores it in `$b`. This is our "counter" of what letters we've seen. We then take input `$args[0]`, cast it as a char-array, and send it through a loop. Each iteration, we take the current character `"$_"` and multiply it by the pre-incremented counter at the given value, which will make the first occurrence be multiplied by `1`, the second by `2` and so on. We encapsulate that with a `-join` so it's all one word being output.
Saved 5 bytes thanks to [TessellatingHeckler](https://codegolf.stackexchange.com/users/571/tessellatingheckler) by using a hashtable instead of an array, so we didn't need to decrement the ASCII character by `97` to reach the appropriate index. This works because pre-incrementing the hash index implicitly calls `.Add()` in the background if that index doesn't exist, since hashtables are mutable.
```
PS C:\Tools\Scripts\golfing> .\stretch-the-word.ps1 tessellatingheckler
tessseelllattingheeeckllleeeer
```
[Answer]
# [Dyalog APL](http://goo.gl/9KrKoM), 6 bytes
```
∊,\∩¨⊢
```
[TryAPL!](http://tryapl.org/?a=f%u2190%u220A%2C%5C%u2229%A8%u22A2%20%u22C4%20f%27bonobo%27%20%u22C4%20f%27uncopyrightables%27&run)
4 functions is an atop (2-train) of a fork (3-train):
```
┌──┴──┐  
∊ ┌───┼─┐
  \   ¨ ⊢
┌─┘ ┌─┘  
,   ∩    
```
First `⊢` (right – a no-op) on the given string, giving `'bonobo'`
Then `,\` (concatenation scan) on the string, giving `'b' 'bo' 'bon' 'bono' 'bonob' 'bonobo'`
The two are forked together with (given as right and left arguments to) `∩¨` (intersection each), i.e. `('b'∩'b') ('bo'∩'o') ('bon'∩'n') ('bono'∩'o') ('bonob'∩'b') ('bonobo'∩'o')`, which is `'b' 'o' 'n' 'oo' 'bb' 'ooo'`
Finally, `∊` (enlist) is applied to the result to flatten it, giving `'bonoobbooo'`
Hey, at least it matches [Pyth](https://codegolf.stackexchange.com/a/77064/43319)! Obviously [Jelly](https://codegolf.stackexchange.com/a/77072/43319) is shorter as it is a golf version of J, which in turn is an advanced 2-character-per-function dialect of APL.
[Answer]
# Pyth, 11 bytes
```
s.e*b/<Qhkb
```
[Try it here!](http://pyth.herokuapp.com/?code=s.e*b%2F%3CQhkb&input=%22bonobo%22&test_suite=1&test_suite_input=%22tutu%22%0A%22queue%22%0A%22uncopyrightables%22%0A%22bookkeeper%22%0A%22repetitive%22%0A%22abracadabra%22%0A%22mississippi%22&debug=0)
## Explanation
```
s.e*b/<Qhkb    # Q = input
 .e            # map over input with b as value and k as index (Q get appended at the end inplicitly)
      <Qhk     # take the first k+1 chars of Q
     /    b    # count occurences of b in there
   *b          # repeat b that many times
s              # join resulting list into one string
```
[Answer]
## J, 11 bytes
```
#~+/@(={:)\
```
This is a monadic verb. [Try it here.](http://tryj.tk/) Usage:
```
   f =: #~+/@(={:)\
   f 'tutu'
'tuttuu'
```
## Explanation
```
#~+/@(={:)\
     (   )\  For each non-empty prefix:
       {:      Take last element,
      =        compare for equality to the others and itself
  +/@          and take sum (number of matches).
#~           Replicate original elements wrt the resulting array.
```
[Answer]
# [05AB1E](http://github.com/Adriandmen/05AB1E), 10 bytes
Code:
```
$vy«Dy¢y×?
```
Explanation:
```
$           # Push the number 1 and input
 v          # Map over the input string
  y«        # Concat the letter to the previous string (initial 1)
    D       # Duplicate this string
     y¢     # Count the occurences of the current character in the string
       y×   # Multiply this number with the current character
         ?  # Pop and print without a newline
```
Uses the **CP-1252** encoding. [Try it online!](http://05ab1e.tryitonline.net/#code=JHZ5wqtEecKiecOXPw&input=Ym9ub2Jv)
[Answer]
# CJam, 14
```
q:A,{)A<_)--}/
```
[Try it online](http://cjam.aditsu.net/#code=q%3AA%2C%7B)A%3C_)--%7D%2F&input=bonobo)
**Explanation:**
```
q:A      read the input and store in A
,        get the string length
{…}/     for each number from 0 to length-1
  )      increment the number
  A<     get the prefix of A with that length
  _      duplicate it
  )      separate the last character
  -      remove it from the rest of the prefix
  -      remove all the remaining characters (different from the last one)
          from the prefix
```
[Answer]
# Perl 6, 37 bytes
```
{.split('').map({$_ x++%.{$_}}).join}
```
[Answer]
# [><>](https://esolangs.org/wiki/Fish), 52 bytes
```
i:0(?;&l:?!v1-$:&:&=?\}70.>
6f+0.00o:&~/         \:o
```
It stacks every letter read, prints them once and once again for every similar letter in the stack.  
It uses the `&` register, because having to handle 3 variables on the stack (current read letter, position in the stack, letter at this position) is a pain. 
You can try it [here](https://fishlanguage.com/playground)!
[Answer]
# Rust, 176 Bytes
```
fn s(w:&str)->String{let mut m=std::collections::HashMap::new();w.chars().map(|c|{let mut s=m.remove(&c).unwrap_or(String::new());s.push(c);m.insert(c,s.clone());s}).collect()}
```
This uses a map to store a string for every character in the input. For each character, the string will be removed from the map, concatenated with the character, inserted back into the map and appended to the output.
I would have liked to use `get(...)` instead of `remove(...)`, but the borrow checker had me change my mind.
[Answer]
# Mathcad, 66 bytes
Unfortunately, Mathcad doesn't have particularly good string handling, so I've converted the input string to a vector and then used a (character code indexed) vector to keep track of the number of times a character is encountered, adding the character that number of times to a result vector. Finally, the result vector is converted back to a string. Quite lenghty unfortunately.
[![enter image description here](https://i.stack.imgur.com/80uU2.jpg)](https://i.stack.imgur.com/80uU2.jpg)
Note that Mathcad uses a 2D "whiteboard" interface, with a mix of normal text and operators; operators are normally entered via a toolbar or keyboard shortcut; for example, ctl-# enters the for loop operator, which comprises the keyword for, the element-of symbol and 3 empty "placeholders" for the iteration variable, range and body expressions respectively. Typing [ after a variable name enters array index mode, Typing ' enters a matched pair of parentheses (*mostly ... there are exceptions depending upon what else is in the surrounding expression*)
[Answer]
# Javascript ES6 44 bytes
```
q=>q.replace(/./g,a=>x[a]=(x[a]||'')+a,x=[])
```
---
old answer
Javascript ES6 46 bytes
```
q=>(x=[...q]).map(a=>x[a]=(x[a]||'')+a).join``
//thanks user81655 for -1 byte
```
[Answer]
# Ruby, 35 bytes
```
->s{s.gsub(/./){$&*-~$`.count($&)}}
```
It's an anonymous function using regex and some magical variables. Usage:
```
->s{s.gsub(/./){$&*-~$`.count($&)}}["bonobo"]
=> "bonoobbooo" 
```
[Answer]
# Julia, ~~38~~ 35 bytes
```
!s=[]==s?s:[!s[1:end-1];s∩s[end]]
```
I/O is in the from of character arrays. [Try it online!](http://julia.tryitonline.net/#code=IXM9W109PXM_czpbIXNbMTplbmQtMV07c-KIqXNbZW5kXV0KCmZvciBzIGluICgidHV0dSIsInF1ZXVlIiwiYm9va2tlZXBlciIsInJlcGV0ZXRpdmUiLCJ1bmNvcHlyaWdodGFibGVzIiwiYWJyYWNhZGFicmEiLCJtaXNzaXNzaXBwaSIpCiAgICAhW3MuLi5dIHw-IGpvaW4gfD4gcHJpbnRsbgplbmQ&input=)
### How it works
We (re)define the monadic operator **!** for our purposes.
When **!** is called, it checks if its argument **s** is empty. If it is, it returns its argument.
If **s** is non-empty, we intersect **s** with its last character (`s[end]`), which yields all occurrences of that character in **s**. This result is concatenated with the return value of a recursive call to **!** with **s** minus its last character (`s[1:end-1]`) as argument.
[Answer]
# PHP, ~~54~~ ~~51~~ ~~50~~ 47 bytes
```
for(;$C=$argn[$X++];)echo str_repeat($C,++$$C);
```
Run like this:
```
echo abracadabra | php -nR 'for(;$C=$argn[$X++];)echo str_repeat($C,++$$C); echo"\n";'
```
## Tweaks
* Saved 3 bytes by using variable variables. Changed used variables to uppercase to prevent collision
* Saved a byte by removing type cast `null` to `int` for string offset, as string offset is cast to int anyway
* Saved 3 bytes by using `$argn` instead of `$argv` (thx Titus)
[Answer]
## Mathematica, 57 bytes
```
StringReplace[Clear@c;c@_=0;#,x_:>x~StringRepeat~++c[x]]&
```
We use `c[x]` as a lookup table of how often character `x` has already occurred. This is incremented each time it's retrieved in `x~StringRepeat~++c[x]`. Unfortunately, to make the function reusable, we need to reset the lookup table each time with `Clear@c;c@_=0;`, which is quite expensive.
[Answer]
# awk, 72 bytes
```
BEGIN{FS=""}{for(i=1;i<=NF;i++){a[$i]++;for(j=0;j<a[$i];j++)printf $i}}
```
The idea is to store the count of the appearing character in an associative array and print the character this count times.
[Answer]
# Beam, 32 ~~33~~ ~~42~~ bytes
This should have been smaller, but I lost some bytes initializing the memory slots to 0. Swapping some flow directions managed to eliminate a lot of empty space.
```
 >+\
vus/
>rnH
  >g'\
(@v's/
^`<
```
[Try it in this snippet](https://codegolf.stackexchange.com/a/57190)
General explanation.
* Set all the memory slots from 0-255 to 0
* Read in the input ascii value into the beam
* If beam is 0 halt (beam = store)
* Get the memory[beam] value into the store, increment it and save back
* Decrement the store to 0 printing out the beam character
* Repeat
]