[Question]
  [
## Input
A non-empty encoded string consisting of printable ASCII characters (in the range 32-126), where some missing letters have been replaced with `_`.
## Output
A decoded string of the same length with all letters in lowercase, including the missing ones.
## How?
*Edit: As mentioned by @Deusovi in the comments, this is a variant of [Bacon's cipher](https://en.wikipedia.org/wiki/Bacon%27s_cipher).*
* Gather all letters in the original string and group them by 5. Additional letters that do not fit in a full group of 5 are ignored.
* Convert each group into binary: lowercase = **0**, uppercase = **1**. This leads to a list of integers.
* Use each value **N** in this list to replace each `_` in the original string with the **N**-th letter of the alphabet (0-indexed), in order of appearance.
**Example:** `prOGraMMIng PuZZleS & cOde ____`
```
prOGr --> 00110 -->  6 -->  7th letter = 'g'
aMMIn --> 01110 --> 14 --> 15th letter = 'o'
gPuZZ --> 01011 --> 11 --> 12th letter = 'l'
leScO --> 00101 -->  5 -->  6th letter = 'f'
```
By replacing the missing letters and converting everything back to lowercase, the original string is unveiled:
```
programming puzzles & code golf
```
This is the expected output.
## Clarifications and rules
* The missing letters are guaranteed to appear at the end of the string. More formally: there will never be any letter after the first `_` in the input string. However, there may be other printable ASCII characters such as spaces and punctuation marks.
* The input is guaranteed not to contain any *useless* capital letter: all capital letters are bits set to **1** which are required to decode the missing letters. Everything else is in lowercase.
* The input string is guaranteed to be valid. Especially:
	+ It will always contain enough full groups of 5 letters to decode the underscores.
	+ The binary-encoded integers are guaranteed to be in the range **[0-25]**.
* There may be no `_` at all in the input string, in which case you just have to return the input.
* This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'"), so the shortest answer in bytes wins!
## Test cases
```
Input : hello!
Output: hello!
Input : helLO, worl_!
Output: hello, world!
Input : i aM yoUr faTh__.
Output: i am your father.
Input : prOGraMMIng PuZZleS & cOde ____
Output: programming puzzles & code golf
Input : Can YOu gUesS tHE ENd oF This ____?
Output: can you guess the end of this text?
Input : THe qUICk brown FOx JUMps oVEr the la__ ___.
Output: the quick brown fox jumps over the lazy dog.
Input : RoadS? wHERe we're goinG WE doN't need _____.
Output: roads? where we're going we don't need roads.
Input : thE greatESt Trick thE DeVIl EVer PUllEd wAs CONvInciNg tHe WorLD h_ ____'_ _____.
Output: the greatest trick the devil ever pulled was convincing the world he didn't exist.
```
Some extra test-cases:
```
Input : BInar_
Output: binary
Input : 12 MonKey_
Output: 12 monkeys
Input : hyPerbolIZ__
Output: hyperbolized
Input : {[One Last Test ca__]}
Output: {[one last test case]}
```
  
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E), 18 bytes
### Code:
```
√°S.u5√¥JC>.bv'_y.;l
```
Uses the **05AB1E** encoding. [Try it online!](https://tio.run/##MzBNTDJM/f//8MJgvVLTw1u8nO30ksrU4yv1rHP@/y/JcFVIL0pNLHENLlEIKcpMzlYACbmkhnnmKLiGpRYpBITm5LimKJQ7Fis4@/uVeeYlZ/qlK5R4pCqE5xf5uChkxCvEA4E6hIrXAwA "05AB1E ‚Äì Try It Online")
### Explanation:
```
√°                       # Remove non-letters from the input string.
 S                      # Split the result into individual characters.
  .u                    # Check if is uppercase for each character.
    5√¥J                 # Split into binary numbers of length 5.
       C                # Convert from binary to decimal.
        >               # Add one.
         .b             # Map 1 ‚Üí A, 2 ‚Üí B, 3 ‚Üí C, ..., 25 ‚Üí Y, 26 ‚Üí Z.
           v            # For each letter:
            '_y.;       #   Replace the first occurrence of '_' with the current letter.
                 l      #   Convert the string to lowercase.
```
[Answer]
# Perl 5 `-pF -MList::Util=sum`, 75 bytes
```
@a=grep!/\W|\d/,@F;s!_!(a..z)[sum map{a gt shift@a&&16/2**$_}0..4]!eg;$_=lc
```
[Try it online!](https://tio.run/##Fc3PCoIwHADgV/kNREtyVlQHRfKidagORXjIGCPXGqgbbiH059Vb9b3Ap1hXz61NacI7plBYFq@yCkdpHmtE0IBi/Bie9L2BhqonBW5A38TVpNR1J4tw6vsOeY8xnp0R47FDkvpi7V7S6rCEfp3tGfTM6xhwKdoVFBlUcucZaBmrgPzhj1RGyFbbQOUQbDdCmyg6GlEnv/UL)
## Explanation:
* `-pF` reads a line of input into the variable `$_` and, split into characters, into the array `@F`.
* `@a=grep!/\W|\d/,@F` sets the array `@a` equal to those members of `@F` that don't satisfy the regex `\W|\d`. `\W` is anything but letters, numbers, and `_`; `\d` is numbers. So `\W|\d` is anything but letters and `_`, and `@a` has all the letters and `_` characters. We will wind up never examining the `_` characters in `@a`. (Note that this only works because the input is guaranteed ASCII.)
* `map{a gt shift@a&&16/2**$_}0..4` does the following for 0 through 4: It shifts the next element off of `@a`, shortening it, and evaluates whether `a` is asciibetically greater than that element (i.e. whether that element is uppercase). If so, `&&` isn't short-circuited, so we get 16 divided by 2 to rhe power of the input value (0 through 4). Otherwise `&&` is short-circuited and we get 0. `map` returns the list of five numbers to `sum`, which adds them.
* That's the element we want from the list `a..z`, and that's what we get from `(a..z)[‚Ä¶]`.
* `s!_!‚Ä¶!eg` converts each `_` in `$_`, in turn, to the appropriate letter.
* `$_=lc` converts `$_` to the lowercase version of itself, and `-p` prints it.
[Answer]
# [Python 2](https://docs.python.org/2/), 113 bytes
```
s=input()
i=k=0
for c in s:
 if c.isalpha():k+=k+(c<'a');i+=1;s=s.replace('_',chr(k%32+97),i%5<1)
print s.lower()
```
[Try it online!](https://tio.run/##JcjLagIxFIDh/TzFQZAkjAxqKeIlC9EBBbEFb8shxGgOCZlwklZ8@qnSf/PBH5/ZtmHcdUliiD@ZiwKlk8Pi1hJowABpVgDeQFeYlI9WcTFzpXQl1wummJhjKUfzJFNFJnqlDWcNG2hL3PU/xuV0IgbY/1yMRBEJQ4ZU@fZhiIuu62Vbw52MyvUhw5FQO3ivtTlvPdRnQ/B98r6@wmOZYPW1/90Gjfs75I2BS0u7NdgGmlfsn6bq/QE "Python 2 ‚Äì Try It Online")
[Answer]
# [J](http://jsoftware.com/), ~~62~~ 61 bytes
```
tolower u:@]`(I.@t=.'_'=[)`[}+/@t$97+_5#.\3|0 2 4-.~'@Z`z'&I.
```
[Try it online!](https://tio.run/##TVBdT8JAEHz3V4zRcBq0Gj9iNCFg4IAa2hLaQgTNUenRVi89vB5WjfrXK2AM3bedndnZ2eeimNcMaClkzhWWN43H6YFpNHTNIIzUJofTyXf1pKH3r6@q7HLPeDj/OsUZLo6NH9IYTz9JxTQKPosl5iAxF0Lukp1S33OOkEslWAlOEFj4kL7CPPBixoztaKGcjgosy0wj9JfjseAuKpg5IQdb1ZbYDFLcO0tEPs9c6C4FtUPINrw4yTbc@pbsdTlefbP5gicl8xRt5x13vrXIIIdUQcccImBsLSvdMpBB6NaRd@mAI@eEKI5IJmkHI4pQ2oRopJyHG7eyUMcUkeKBpq6Gp5LZC9ZQiw9NATpcvbnvC0FD5LcZmo79ZqazxI5WKThGUvVaiNlfXML@lxe/)
[Answer]
# [Retina](https://github.com/m-ender/retina/wiki/The-Language), ~~91~~ 90 bytes
```
T`l`a
T`L`A
[^Aa]
L`.{5}
A
aA
+`Aa
aAA
+T`_lA`l_`[^A]A
^
$+¬∂
+`_(.*)¬∂a+(.)
$2$1
0G`
T`L`l
```
[Try it online!](https://tio.run/##K0otycxLNPz/PyQhJyGRKyTBJ8GRKzrOMTGWi8snQa/atJbLkSvRkUs7wTERSAMZIQnxOY4JOfEJQFWxjlxxXCrah7YB5eM19LQ0D21L1NbQ0@RSMVIx5DJwTwAbmPP/f0GRv3tRoq@vZ166QkBpVFROarCCmkKyf0qqQjwQAAA "Retina ‚Äì Try It Online") Explanation:
```
T`l`a
T`L`A
[^Aa]
```
Translate lowercase letters to `a` and uppercase letters to `A`, deleting everything else.
```
L`.{5}
```
Split the `Aa`s into groups of 5.
```
A
aA
+`Aa
aAA
```
Convert from binary into unary, treating `A` as 1 and `a` as 0. Since there were 5 `Aa`s originally, there are 5 `a`s left, plus a number of `A`s depending on the desired position in the alphabet.
```
+T`_lA`l_`[^A]A
```
Increment the last `a` according to the number of following `A`s.
```
^
$+¬∂
```
Prepend the original input.
```
+`_(.*)¬∂a+(.)
$2$1
```
Replace any `_`s with the next decoded letter.
```
0G`
```
Remove any spare decoded letters.
```
T`L`l
```
Lowercase everything.
# [Retina 0.8.2](https://github.com/m-ender/retina/wiki/The-Language/a950ad7d925ec9316e3e2fb2cf5d49fd15d23e3d), 117 bytes
```
.+
$&¬∂$&
T`L`l`^.*
T`l`a`.*$
T`L`A
T`aAp`aA_`.*$
(.*¬∂)?.{5}
$&;
A
aA
+`Aa
aAA
+T`_lA`l_`[^A]A
+`_(.*¬∂)a+(.);
$2$1
1G`
```
[Try it online!](https://tio.run/##K0otycxL/P9fT5tLRe3QNhU1rpAEn4SchDg9LSArJyExQU9LBSzmCCQTHQuAOB4spqGndWibpr1etWktUKs1lyNXoiOXdoJjIpAGMkIS4nMcE3LiE6LjHGNBEvEQDYnaGnqa1lwqRiqGXIbuCf//FxT5uxcl@vp65qUrBJRGReWkBiuoKST7p6QqxAMBAA "Retina 0.8.2 ‚Äì Try It Online") Explanation:
```
.+
$&¬∂$&
```
Duplicate the input.
```
T`L`l`^.*
```
Lowercase the first copy.
```
T`l`a`.*$
```
Translate lowercase letters to `a` in the second copy.
```
T`L`A
```
Translate uppercase letters to `A`. These must be in the second copy because the first copy was already lowercased.
```
T`aAp`aA_`.*$
```
Delete everything else in the second copy.
```
(.*¬∂)?.{5}
$&;
```
Split the second copy (now just `Aa`s) into groups of 5.
```
A
aA
+`Aa
aAA
+T`_lA`l_`[^A]A
+`_(.*¬∂)a+(.);
$2$1
1G`
```
Decode the letters and insert them as before.
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), ~~28 27~~ 26 [bytes](https://github.com/DennisMitchell/jelly/wiki/Code-page)
-1 thanks to Erik the Outgolfer & dylnan
Not a very Jelly-friendly challenge!
```
·∏ü≈ís$∆á<‚Äù[s5·∏Ñ+97·ªå≈º@·π£‚Äù_$F·πÅL≈íl
```
A monadic link accepting and returning lists of characters.
**[Try it online!](https://tio.run/##y0rNyan8///hjvlHJxWrHGu3edQwN7rY9OGOFm1L84e7e47ucXi4czFQMF7F7eHORp@jk3L@//8flJ@YEmyvUO7hGpSqUJ6qXpSqkJ6fmeeuEO6qkJLvp16ikJeamqIQDwJ6AA "Jelly ‚Äì Try It Online")**
### How?
```
·∏ü≈ís$∆á<‚Äù[s5·∏Ñ+97·ªå≈º@·π£‚Äù_$F·πÅL≈íl - Link: list of characters    e.g. "MfUNE_?"  (shorthand for ['M','f','U','N','E','_','?'])
    ∆á                      - filter keep each if:
   $                       -   last two links as a monad:
 ≈ís                        -     swap-case
·∏ü                          -     filter discard
                           - ...i.e. keep A-Z,a-z since they change when the case is swapped
                           -                                  "MfUNE"
      ‚Äù[                   - literal character                '['
     <                     - less than? (i.e. is upper-case?) [1,0,1,1,1]
        s5                 - split into fives                 [[1,0,1,1,1]]
          ·∏Ñ                - from base two (vectorises)       [[23]]
           +97             - add (vectorises) ninety-seven    [[120]]
              ·ªå            - from ordinals (vectorises)       [['x']]
                    $      - last two links as a monad:
                  ‚Äù_       -   literal character              '_'
                 ·π£         -   split at                       [['M','f','U','N','E'],['?']]
               ≈º@          - swapped @rgument zip             [[['M','f','U','N','E'],'x'],['?']]
                     F     - flatten                          "MfUNEx?"
                       L   - length (of input)                7
                      ·πÅ    - mould like                       "MfUNEx?"
                           - ...removes any excess characters
                        ≈íl - lower-case                       "mfunex?"
```
[Answer]
# [APL (Dyalog Unicode)](https://www.dyalog.com/), 46 [bytes](https://codegolf.meta.stackexchange.com/a/9429/43319 "When can APL characters be counted as 1 byte each?")[SBCS](https://github.com/abrudz/SBCS ".dyalog files using a single byte character set")
Anonymous lambda, Assumes `‚éïIO` (Index Origin) to be `0`.
```
{_‚Üê'_'=‚ä¢‚ãÑ819‚å∂A[2‚ä•‚çâ(+/_‚çµ)5‚ç¥A‚àä‚ç®‚çµ‚à©A,819‚å∂A‚Üê‚éïA]@_‚çµ}
```
[Try it online!](https://tio.run/##TY/NTttAFIX3fYrTDdOqQH9QpbKoqBsGYkTiKLaDSIVGQzyxLUaedGJwo4oVFYJQI1jwAkhIsGLT9gH6KPMi6cRm0VnM3HP0nXvn8pFciiZcqnhmLm9cz5xevZl9Z/YhjHw001tz8ePD21Xz84/z5Z2Z3pny/MWr18yUv1@@N@Uvx5xNTXlvpTl7cBafSJu2zZy9T3PueDac6/Ky7j89@fu4Yk6vrfK7DXsHTdefDUESIaV6Tp7V5ba3iEJpyWonBW9hokKNIQ8SxpYrd6S9Tc1bLTeL0Tns96XwsYCBFwkweyqmwTPseoeIQzH2kTcpaDuC2kCQpOMKW6u4oCnwNXQbB9jXqsiw4X3DVtgajaF6VCNPBCRnbJ6oh3cVj/w1FE3aFSgEIVogVmm2iR2KSLUJyZEJEVUznjJ5QhFrwXPq5wh0OjjA3FoXPVeC9oRGJ5SSRiicMRpe@8jNBmk7tt8W2FF6ex0Jq1cj7P@@n92M63rfZNIRel9Jt2@pfw "APL (Dyalog Unicode) ‚Äì Try It Online")
`{`‚Ä¶`‚ãÑ`‚Ä¶`}`‚ÄÉtwo-statement function; `‚çµ` is the argument, `‚ãÑ` separates statements
‚ÄÉ`‚ä¢`‚ÄÉargument (no-op function)  
‚ÄÉ`'_'=`‚ÄÉwhere equal to an underscore (i.e. a Boolean mapping function)  
‚ÄÉ`_‚Üê`‚ÄÉassign that function to `_`
‚ÄÉ`A[`‚Ä¶`]@_‚çµ`‚ÄÉput the following characters of `A` **at** positions of underscores in the argument  
‚ÄÉ‚ÄÉ`‚éïA`‚ÄÉthe uppercase **A**lphabet  
‚ÄÉ‚ÄÉ`A‚Üê`‚ÄÉassign that to `A`  
‚ÄÉ‚ÄÉ`819‚å∂`‚ÄÉlowercase it (*819 ‚âà BIg*, with no left argument means not big, i.e. lowercase)  
‚ÄÉ‚ÄÉ`A,`‚ÄÉprepend the uppercase alphabet; this gives us all letters  
‚ÄÉ‚ÄÉ`‚çµ‚à©`‚ÄÉintersection of the argument and that; just the letters of the argument  
‚ÄÉ‚ÄÉ`A‚àä‚ç®`‚ÄÉwhich of those are members of the uppercase alphabet; uppercase bits  
‚ÄÉ‚ÄÉ`(`‚Ä¶`)5‚ç¥`‚ÄÉ**r**eshape that to the following number of rows, and five columns:  
‚ÄÉ‚ÄÉ‚ÄÉ`_‚çµ`‚ÄÉthe mask of underscores in the argument  
‚ÄÉ‚ÄÉ‚ÄÉ`+/`‚ÄÉsum that; number of underscores  
‚ÄÉ‚ÄÉ`‚çâ`‚ÄÉtranspose (to treat each row as a number rather than as a bit position)  
‚ÄÉ‚ÄÉ`2‚ä•`‚ÄÉevaluate as base-2  
‚ÄÉ`819‚å∂`‚ÄÉlowercase everything
[Answer]
# [Scala](https://github.com/scala/scala), 189 bytes
```
def f(s:Array[Char])={var j=0;s.zipWithIndex.collect{case(95,i)=>s(i)=(Integer.parseInt(s.filter(_.isLetter)slice(j,j+5)map(k=>if(k<91)1 else 0)mkString,2)+97)toChar;j+=5};s.map(_.toLower)}
```
[Try it online!](https://tio.run/##rZBZawIxFIXf/RW3vjRBGVSQYu0IokKlLgW3B5EhHe84GeNkSIJLZX67jV1QW8GX5iHLufd8nBvtM8EO8i1C30CX8RhwazCea6gnCewzhzkGEBD9WFeK7aaNkKkZdfdrpiByC1XtvPNkwk3Yjue4dXwphAXtfaaRVMp5Tt2aJnYn7djgApWTMKXRPoh2Ai4MKuI5XHfQ2CvVgvtIonyUK9MVS8jSrfGALJ8qRVoEFBqhQFfLgVE8XuRLNFd5oEYeI1WjnFtObZqjy3OM7MiN5aUHgMQ2GxGTbIhCyDtwa5CFnB3pW8ja7s/ZqPODpplLW6efh41UwvvlPum3IBxYF3ZypCBgw9DznDPQn9otmAlbsFDITGtgYKi4v4Sj1MRxW0BrjApeR0K05rCpa2j0e@t27PPeAswzwkSqThNCDzy77r@OizT/D781TrEEXRm/4M47i3ESb/7tfloszdIrjMvCVUx6@AA)
Explanation:
```
def f(s: Array[Char]) = {                // takes a String in input
  var j = 0                              // j stores at which block of 5 letters we're currently at
  s.zipWithIndex.collect {               // Array('h', 'e', ...) => Array(('h', 0) ('e', 1), ...) and we apply a collect transformation (filter/map)
    case (95, i) =>                      // we only handle cases where the char is '_' (95)
      s(i) = (                           // we modify the char at index i with the following
        Integer.parseInt(                // Integer.parseInt("00110", 2) = 6
          s                              //
            .filter(_.isLetter)          // filter out non letter chars (spaces, punct, figures, ...) from the input string (thanks @Arnauld for the fix)A
            .slice(j, j+5)               // "substring" the array to the block of 5 letters in question
            .map(                        // map on the current block of 5 letters
              k =>                       // the index of the next char in the block f 5 (e.g. 13)
                if (k < 91) 1 else 0     // if the current char is upper case (<91) then we replace it by a bit true, otherwise by a bit false
            )mkString,                   // Array(0, 1, 1, ...) => "011..."
          2                              // cast string to binary
        )                                //
        + 97                             // +97 to create a lower case char
      )toChar                            // cast from int to char
      j += 5                             // update the starting index of the next block of 5 letters
    }                                    //
  s.map(_.toLower)                       // return the updated seq of chars all in lower case
}                                        //
```
[Answer]
# [JavaScript (Node.js)](https://nodejs.org), 94 bytes
```
x=>x.toLowerCase(w=/[a-z]/gi).replace(/_/g,g=Z=>Z>62?(Z-52).toString(36):g(w.exec(x)<g|2*-~Z))
```
[Try it online!](https://tio.run/##DcvBCoIwGADgV9kpt2gbGHmIZofACBIDb4uQMX@GMTaZliOiVze/@/dUbzXo0PUjdb6FuRBzFHlko7/6CcJJDYAnwe@Kfh7cdIQF6K3SgHnDzcYIKXKZZ@kRS7pLydLqMXTO4G1G9gZPDCJoHMnBfNM1/UlCZu3d4C0w6w0ucNKH6hxUWV6cQbeXlBZqtEK6agE1i2QZfw "JavaScript (Node.js) ‚Äì Try It Online")
# [JavaScript (Node.js)](https://nodejs.org), ~~125~~ 124 bytes
```
x=>x.replace(s=/./g,c=>parseInt(c,36)>9?c.toLowerCase(s+=+(c<{})):c=='_'?('0b'+s.slice(4,9)-~9).toString(36,s=s.slice(5)):c)
```
[Try it online!](https://tio.run/##NYxBC4IwGIb/iqe24ZyBFRhND4EhJAbevMj6HGKMTTYrIeqvmx16r8/zvDfxEA5sP4yBNq2cMz5PPJmYlYMSILHjIQs7CjwZhHUy1yMGGu1IEqfARnM2T2mPwi2iz30Mh9ebkD1wjhqUYrS@It8xp/rlaUNjEnxislTVaHvd4WhHHf/j7a8jMxjtjJJMmQ5nGA22PFlRFLnuvMu9rpWsvJUHZSu9ZhkiZP4C "JavaScript (Node.js) ‚Äì Try It Online")
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 26 bytes
```
xn¬•≈ís<‚Äù[s5·∏Ñ‚Äò·ªã√òa·πõi‚Äù_·∏ü0∆ä¬¶∆í≈íl
```
[Try it online!](https://tio.run/##y0rNyan8/78i79DSo5OKbR41zI0uNn24o@VRw4yHu7sPz0h8uHN2JlA0/uGO@QbHug4tOzbp6KSc////FxT5uxcl@vp65qUrBJRGReWkBiuoKST7p6QqxAMBAA "Jelly ‚Äì Try It Online")
Different approach from Jonathan Allan's. EDIT: So, I, uh, apparently thought of the same byte reduction as Jonathan Allan, so it doesn't hurt to mention his name again.
[Answer]
# [CJam](https://sourceforge.net/p/cjam), 43 bytes
```
q'_/_0={el_eu=!},_eu.=5/2fb65f+:c1$,(<.+:el
```
[Try it online!](https://tio.run/##S85KzP3/v1A9Xj/ewLY6NSc@tdRWsVYHSOnZmuobpSWZmaZpWyUbquho2OhpW6Xm/P9fkuGqkF6UmljiGlyiEFKUmZytABJySQ3zzFFwDUstUggIzclxTVEodyxWcPb3K/PMS870S1co8UhVCM8v8nFRyIhXiAcCdQgVrwcA "CJam ‚Äì Try It Online")
[Answer]
# [Clean](https://clean.cs.ru.nl), ~~180~~ ... 150 bytes
```
import StdEnv
?s=['a'+sum[i\\i<-:""&c<-s|c<'a']: ?(drop 5s)]
@['_':b][x:y]=[x: @b y]
@[a:b]z=[toLower a: @b z]
@e _=e
$s= @s(?(filter isAlpha s))
```
[Try it online!](https://tio.run/##JYxNS8NAFEVRXEhW/oRHLU6CxJ2bkCEpJmAgVCFaF0kIk8mkHZx8MDNtTfG3G6d6F@/yzoFLBSP93A3NXjDoCO9n3o2D1JDpJu4PVqBwjgi6V/su50XBfddb3FxfXV4s7qjvqm/qG1t6ENiNHEZ4VE5phTmqkFeX@Zc3ldhcCGuYzpwYesK5HtLhyCSQP3MyhkGFmbVUGEJlB3bLhTaeq5UYdwSU48yZJlJbt9AChqWFTedI72LYSkZ0nGl4k5x@whlFbJMIiDdm4fVdiLiB40rB08v6kPSUr7egnxl8DDKNYFdBZVKg/64eUDn/0FaQrZrdJJ2jqScdp@apfwE "Clean ‚Äì Try It Online")
Defines the function `$ :: [Char] -> [Char]` with `@ :: [Char] [Char] -> [Char]` as a helper to replace underscores, and `? :: [Char] -> [Char]` as a helper to generate the replacement characters.
[Answer]
# [JavaScript (Node.js)](https://nodejs.org), 100 bytes
```
s=>s.toLowerCase(c=/[a-z]/gi).replace(/_/g,_=>(g=n=>n?(c.exec(s)<{})*n+g(n>>1):10)(16).toString(36))
```
[Try it online!](https://tio.run/##ZVPbUtswEH3PV2xfapuCQ9oZHqBOphMMpEMShiQw5TJGtTeOqCIZSU5CGL49XQVyGfDTavecs2fX0iObMJNqXtg9qTJcDKOFieomtOpcTVE3mUE/jaq3bG9@X815EGosBEvRrybVfDeJ6n4eyaguG34a4gxT3wQ/X16DHfkt92W9XgsOa/uBXzsISLFnNZe5/@MgCBYWjU1JHCJ4aMmitHAIIxRCfal0S0vn9bGyVT7v7sJUaZF8QL1lsy0wB9aGZzXQMGT9UZKEawJVxlQpXcWOUIcbUqG7p5q12y2Zw0V5cyOwB18h7WYICX1riUKrXLPxmKaBopzPBRqHo/1BrsRwI9hkEv50S8gHaHpgz2KIOxmoE@iPuFlqNtaiKWHJFuQlGgPkDFASdkghYS3ObGMj3D9DeBq0mv/gr1ZTCSfdGfwetAsD6irWS7ZgSeJabCZ32aeSpyvSUM3gsRw70gRXpPkzZCrfWsqlYlmvAdOz@BJhip52Q3J5CtcxITueBYmYLYfZ6qWJZYhFC95m5RQTS65YS9hWMzuKIdfIbNyz0NfOq0sd41VLQHxFLi8GQsQZTH8ZaHY7k5ZMeSen1SJcK31@DKPl0ImXfHTkxltK080D@y5NZnDCBaBbQFEKQZ6mzNC/lBNO0mTYgZa3CxyaZ847zrixYeXhqLK6x@GY2XTkV1eDhDt3ctXZxdU8IEjhG4jq8FIBmDANt3wX8J6eAL03zcd@EJpCcOt7d9J7g1sHt6v0oRfc1u7fscERqZBPowSGQuX@0Oefk/gp4@157hHTIvzv@47wGhwt/gM "JavaScript (Node.js) ‚Äì Try It Online")
Thanks to @Arnauld, saves 2 bytes.
[Answer]
# [Stax](https://github.com/tomtheisen/stax), 22 [bytes](https://github.com/tomtheisen/stax/blob/master/docs/packed.md#packed-stax)
```
√¢‚ïü‚ñì√ØMeee¬∂‚ñêf‚óÑ‚î¥‚âà‚îòn‚ïõ√§yŒ©‚óãN
```
[Run and debug it](https://staxlang.xyz/#p=83c7b28b4d65656514de6611c1f7d96ebe8479ea094e&i=hello%21%0AhelLO,+worl_%21%0Ai+aM+yoUr+faTh__.%0AprOGraMMIng+PuZZleS+%26+cOde+____%0ACan+YOu+gUesS+tHE+ENd+oF+This+____%3F%0ATHe+qUICk+brown+FOx+JUMps+oVEr+the+la__+___.%0ARoadS%3F+wHERe+we%27re+goinG+WE+doN%27t+need+_____.%0AthE+greatESt+Trick+thE+DeVIl+EVer+PUllEd+wAs+CONvInciNg+tHe+WorLD+h_+____%27_+_____.&a=1&m=2)
The general approach is a regular expression replacement of `"_"` using a callback function that slices letters of the inputs to compute each replacement character.
```
v       convert to lower case
'_      "_" string literal
{       begin block for regex replacement
  yVl|& all the letters only from the original input
  5/    split into chunks of 5
  i@    keep the ith one, where i is the 0-based number of times this block has run
  {97<m map 5-letter chunk to bits to indicate which are lowercase
  :b    decode as 5-bit integer
  97+]  add 97 and wrap in array to convert to lower case character
}       end block for regex replacement
R       do regex replacement
```
[Run this one](https://staxlang.xyz/#c=v%0A%27_%0A%7B%0A++yVl%7C%26%0A++5%2Fi%40%0A++%7B%27a%3Cm%3Ab%0A++97%2B]%0A%7D%0AR&i=hello%21%0AhelLO,+worl_%21%0Ai+aM+yoUr+faTh__.%0AprOGraMMIng+PuZZleS+%26+cOde+____%0ACan+YOu+gUesS+tHE+ENd+oF+This+____%3F%0ATHe+qUICk+brown+FOx+JUMps+oVEr+the+la__+___.%0ARoadS%3F+wHERe+we%27re+goinG+WE+doN%27t+need+_____.%0AthE+greatESt+Trick+thE+DeVIl+EVer+PUllEd+wAs+CONvInciNg+tHe+WorLD+h_+____%27_+_____.&a=1&m=2)
[Answer]
# [R](https://www.r-project.org/), ~~153~~ ~~135~~ 113 bytes
```
function(s,S=utf8ToInt(s)){S[S==95]=2^(4:0)%*%matrix(S[S%in%c(65:90,97:122)]<95,5)+97
cat(tolower(intToUtf8(S)))}
```
[Try it online!](https://tio.run/##LYxtS8MwHMTf91P8KVQTrTKLdbasL8QVLWzrIN2EjVpClnbBmkiaOmHss9f4cC/u4O746aGGyRUMdS@ZEUqizidJb@r7QmXSoA7jI9mSJInCMgle0W08wt6F906NFl/ILp6QHkN3YRyN/Ggc3wQBLidR6If4Mho7jBpkVKsOXCMhTaFWlowIxvg01Mj90PmTpvN5JhtY9ptNywmcAct3HCorx8WOfZl9Co3m1KTEQKEFe4OfasrXWQvpmmtYrto23cHhoYPHfPGZSSYWDZhnDi9Kz6awr355539RXf@Dj9tccpjRzmK5NUarqjy5ePgG "R ‚Äì Try It Online")
Issues some warnings with the use of `matrix` but that shouldn't affect the result. Also issues warnings as `[<-` assignment will remove extraneous assigned objects by default.
*40(!) bytes down thanks to JayCe's improvements*
[Answer]
# [C (gcc)](https://gcc.gnu.org/), 111 109 101 100 bytes
*Edit:* Added lowercasing per @FrownyFrog's comment; thanks to Lynn, Christoph and user5329483 for their suggestions!
```
f(s,t,i)char*s,*t;{for(t=s;t=strchr(t,95);*t=i+1)for(i=3;i<64;s++)isalpha(*s)?i=2*i|*s<97,*s|=32:0;}
```
[Try it online!](https://tio.run/##VY/bSsNAEIbv8xRDRcxu1mJbD9RNKmIDFqQKar1QCWFzGoxJ2J1GpM2zx6S9qQPDzPf9F8Oo01Sp9ggLla@jGFxDEZbDbGYdKo1F@t8p@q3iTrWJbQQJZCoLNTeCk9wkpbbJM7Jr0irrQEwvmOTkoTNifYreRKJ7eS6N4zA0YV5loc0Nu0FvzHHLjTu9Etxsvcn4@kw2LRYE3yEWdr@EOlWiPwecd3vNYGMBYGL3wWy0R4Ad1@@jTyZ3XHVPUGIPjs1HMRCHWWM1bUuZD6mOQ/KfCV40qi/o1TxeLXLwV7GGp9c89yP4uTVw97isF4XCZQp0H8NbqR/mkAUQdHWyH8HwDw "C (gcc) ‚Äì Try It Online")
[Answer]
# [Haskell](https://www.haskell.org/), 139 bytes
```
([]%)
a%(x:y)|x=='_'=['a'..]!!foldl1((+).(2*))(take 5a):drop 5a%y|x>'@',x<'['=[x..]!!32:(a++[1])%y|x>'`',x<'{'=x:(a++[0])%y|1<2=x:a%y
a%e=e
```
[Try it online!](https://tio.run/##JU1PC4IwHL33KZZk27IkjS7iolt0EINumtgPnRYtG1awyM/eGvpOj/f3As8bF0JX7KRJmtl0BDZRwYd2ijGcY5ZiwK6bjcfVQ5TCI8ShLvFnlJIX3DhaAw3K9iENsT@d2uAtnqsQp6ao@trKDwg4TupldAic@8AXMzUYy97wQt8IZsP8c8b1Ha4Nk@21eaEJqpAl23jXQhTtmxod3kki@BFNURGXHOUGlv4VlYD6qReFlH8 "Haskell ‚Äì Try It Online")
[Answer]
# TypeScript's Type System, ~~637~~ ~~526~~ ~~515~~ ~~505~~ ~~496~~ ~~490~~ 489 bytes
```
//@ts-ignore
type a<S="abcdefghijklmnopqrstuvwxyz",A=[]>=S extends`${infer F}${infer R}`?a<R,[...A,F]>:A;type u<S,D>=D extends`${infer A}${infer R}`?`${u<S,R>}${u<S,R>}${S[A]extends a[any]?"":1}`:D;type c<S,T=[]>=S extends[{},{},{},{},{},...infer R]?c<R,[...T,a[a<u<S,"43210">>["length"]]]>:T;type p<S,O=[]>=S extends[infer A,...infer R]?p<R,F<A,0>extends a[any]?[...O,A]:O>:O;type F<S,V=c<p<a<S>>>>=[S,V]extends[`${infer A}_${infer B}`,[{},...infer R]]?F<`${A}${V[0]}${B}`,R>:Lowercase<S>
```
[Try it at the TS Playground!](https://www.typescriptlang.org/play?#code/PTACBcGcFoEsHMB2B7ATgUwFDgJ4Ad0ACAQwB4BlAXgCJiAjAYwBN0AzeAC1gCsBrAGwC2KPAEdUkcAFcAbgHcAHjgBe1ADQBBSgG0AugD5K5QugXh0iJpAAGAEgDesRK3SpCAMQC+Dpy7cAlT2sAfjJ-NW0AOmiNNXcDAC4NAG5cAkIpCjUAEUNskzMLKztHZ1dCDW9Sv0JAkJLM8jV-fSrG5taHcm0NXVNzS0gSbWJEHF1g6moEgEYghOzU-CIGLIAVHQMjAoGrbXtPNQOjw+Pj6Mjfcv8J1fCo6LW1YhHSduoAFgBmACYZgAZqPp9NpqPwLPBwBxqLpYfoEmsluk8FkAPKbQzGfpFSDaK5uWIXfG1CYo8LuUixf76bGDYajcbBB6RVGaXQJVHw1FIogUpoANUoqxRZHIwOBOgFfUKg20JWJlQA+j4ym4AEJBCLnaLEm4TCklSoOfnaf66Koa6wdBIAGWQclcDGIkHQFH0mGwy0Ia3Qkn+hEoHlI1AAEuh+PxkABCIHJTAgQiJgB6wU96R9khmAaD1DwqFRAHFUMQALIlgCSiHghAAClIAFr18HGABkhAYqJYhEVPcVsfjwEThBTaaIGfAP2zFOoHHDNtZhDkaH4ipj+jjCeTqbSY994C+U+DsBIJcIOGQAFU3KxiGsOD3Iv3N8Pt17xx9D9Q1mHCKIL+WAGFeEIOhUHtRAPFRBRCAAKQvEs8CGZB+QAUTcKEiH4Yge27B8n0HLdR29PcAFZPzVStiFQPt1wHIcRyAA)
I managed to golf off a load of bytes:
1. I started by using [@emanresu A's much shorter binary-to-unary type](https://codegolf.stackexchange.com/a/264046/100664), but noticed that in this case it would be shorter if it operated on a tuple rather than string of bits, so I modified it accordingly.
2. I then thought to have the binary-to-unary type operate not on 1s and 0s, but on the characters themselves, and check if it's uppercase or lowercase within that same type, saving a lot of bytes.
3. I no longer needed the `Split` type for anything other than the alphabet, so I inlined the alphabet into it's definition.
4. I realized that `F` could be inlined into the `FillBlanks` type, by `Lowercase`ing the final result and giving the fill string a default. I also utilized [this tip of mine](https://codegolf.stackexchange.com/a/264986/108687) to reduce two `extends` clauses into one, saving around 10 bytes.
5. I changed the `Chunk` type to operate on a list of characters, so the pattern match could be reduced to just "5 items and the rest", with the 5 items selected individually, and did the splitting in `F`.
6. I did a bit more rearranging to reduce the Chunk type a lot more.
7. I golfed away 2 `infer` clauses and removed a pair of unneeded parentheses.
8. I changed `u` back to using a string and then splitting it to get its length in `c`.
I‚Äôd say at this point this is one of my most well-golfed TS submissions.
---
This was a fun one!
The following explanation more closely resembles my old 637 bytes version, but the general structure is still roughly the same.
```
// Split<Str> converts string Str to a tuple of characters.
type Split<
  Str extends string,
  Arr extends string[] = []
> = Str extends `${infer A}${infer R}` ? Split<R, [...Arr, A]> : Arr;
// Lowercase alphabet tuple.
type Alphabet = Split<"abcdefghijklmnopqrstuvwxyz">;
// To get the case of a letter:
// if it is in the lowercase alphabet, return 0, else 1.
type Case<C extends string> = C extends Alphabet[number] ? 0 : 1;
// Replace all occurrences of Find with Rep in string Str.
type Replace<
  Str extends string,
  Find extends string,
  Rep extends string
> = Str extends `${infer Start}${Find}${infer Rest}`
  // Recursively substitute until no more occurrences are found.
  ? Replace<`${Start}${Rep}${Rest}`, Find, Rep>
  : Str;
// See https://esolangs.org/wiki/Binary_to_unary_conversion
type BinToUn1<In extends string> = Replace<In, "1", "0*">
type BinToUn2<In extends string> = Replace<In, "*0", "0**">
type BinToUn3<In extends string> = Replace<In, "0", "">
type BinaryToUnary<Binary extends string> = BinToUn3<
  BinToUn2<BinToUn1<Binary>>
>;
// This type does the bulk of the work.
type Chunk<
  S extends string,
  T extends string = ""
  // Map each chunk of five letters to:
> = S extends `${infer A}${infer B}${infer C}${infer D}${infer E}${infer R}`
  ? Chunk<
      R,
      // The character of the alphabet at index
      `${T}${Alphabet[
        // convert from binary
        Split<BinaryToUnary<
          // the case of each character in the chunk.
          `${Case<A>}${Case<B>}${Case<C>}${Case<D>}${Case<E>}`>
        >["length"]]}`
    >
  : T;
// Filter out non-alphabetic characters.
type Alphabetics<
  S extends string,
  O extends string = ""
> = S extends `${infer A}${infer R}`
  ? Alphabetics<R, Lowercase<A> extends Alphabet[number] ? `${O}${A}` : O>
  : O;
// Fill each underscore with the corresponding character
// of the fill string.
type FillBlanks<
  Str extends string,
  Fill extends string
> = Str extends `${infer Start}_${infer Rest}`
  ? Fill extends `${infer X}${infer R}`
    ? FillBlanks<`${Start}${X}${Rest}`, R>
    : Str
  : Str;
// Final type that composes all of the above to a single type:
type F<S extends string> = Lowercase<FillBlanks<S, Chunk<Alphabetics<S>>>>;
```
[Try it at the TS Playground!](https://www.typescriptlang.org/play?#code/C4TwDgpgBAymA2BLYAeAUFWwBOUIA9gIA7AEwGcpydFiBzAGgygEFtcCizLrta6A2gF0oAXijC0APjFYOhEhSgADACQBvWgDMIuFgF8N23VABK+5VAD8sBMhSmGEgHSu22JyyEyAXK3YA3GhooJCs8GAAFgCGAEYQwLJwSKgARHEAxqQQWnSRiABWANbwALbEAPZgAI7Y1ACuAG4A7vggAF6pUkEh4NAAwtHkECj9eArcVDT0MuJjnIqULBEx8cACxPWl8dgiNgAMUH4AjD2h0KYQCNEZI8wwOONcSrz8TJgAYrSkT4tTfPR3mYrr9Jq96NIko8FpM1JpiDpcA9othgIZ1F8yOjjLhLtQLMwbJdrrcUHDkaj0cSqRB8conJjSE5iVJmH4Htgzn0oAAhWgAFQqAFViAB9Y4oACSxFBL2mdFmwJJI2lTlSx1Sav2ACour0wnziIKRaKAExSmUwuUAhWyYnwG4q4hq7X7TVQVI63Ws868gXCsUAZgtsp48sV9sdFq17tSet9hpRIGNxCTKET2BAof+-EVhpTouDzHzAbN6f9JolGZAUlZ3WCvv6kXqxCK6EwMGz4MYzH5XflsjjkPEnatlDhONY2IRJh508RUH685MABFl7gAKLrswEzA2JsttvMTCYRzHk9w-no5ZROIJATJeznk9+1OZlNpuGDYYoFhSdHfiMPL-hogGjCB6hgSuEFgRu-7KKyL6YFIAipPAJB0MAkSpEIQi7ieiFHFA-JcmEN6rAkiAZOQ7awP2NpAgA8vR-CDqkw50WOKhGDOejbuYyiEuEt5rFRNGOFAAAyFTNLoGRDCMf7ZuRd7rJs2y6Hs3HqIx14WERjGEX4jGkdAXzwPAPIOq2NH3NCEzWm8zDmfALEQoqHLZhOvFYCiaKijxC54migl7lALleYFJgABr8fhYUuVZ0Q2WSGgUmiGixRowUWMyhGYOyOBsnIpnhSgo4OWGNqKtJsnYPJP6JdZRQ0TATgHq2v4rKpYnlbWtalfytLAIc4gfCgqQABIQBZFQAIRdEEAD0S0ngAelY+rQEN1DHLI42pGA2CMQA4tg0QALIXdKdBQAACvUABaj3oZ2ABkUAZIx2RQKKf2iotaAretm2+jtwCmvtE2RDNkmMU4zQVNg8Cigt9bA5gG1bcRw2BlDqSIFAl1QCAwq4Fo0T8pEf3OIDGNQFjYPDQALPj-LTVA1RCpK-RFFAsTYDJMofIx+BQAAUkKF1gJQFQAGobrgWHQA6f2-TTdOrZjoPcuDACs+M8tKKIA+jWsM5tQA)
All of the recursive types used here are tail-recursive, increasing the recursion limit from 50 to 999. The only exception to this is the binary-to-unary type, but it won't get near the recursion depth for any 5-bit number.
[Answer]
# [Red](http://www.red-lang.org), 247 bytes
```
func[s][a: charset[#"a"-#"z"#"A"-#"Z"]v: copy""parse s[any[copy c a(append v to-string c)|
skip]]k: 0 t: copy""repeat n(length? v)/ 5[c: 0 p: 16
loop 5[if v/(k: k + 1) <#"a"[c: c + p]p: p / 2]append t#"a"+ c]foreach c
t[replace s"_"c]lowercase s]
```
[Try it online!](https://tio.run/##VZBta9swFIW/@1ecKbAkdF3WQfchDEJJ3SajiUveymKM0eTrFywsTVbidlt/eyaHFTx9ks59zr3nylByWlESRl46PqWHSoR1FPIxRM5NTTbsMc4ue@wX67Gb9rJn0dFVlX5hTLcI6pBXL2GrQIAPuNZUJTjCqsvamqLKIIZ/UJeFjiKvHOMT7FsDQ5q4RTWQVGU2n@A4HOE6FC2kx7j64kmltFOKFMfRwJlLXOBqiK9trJYT7q0jx2qM8Dn6N9y25QuIKFWGuMghPBu6YZILl5fFTERSNWQEb/NHJ@1iWqT4nZOU6t2r1xUegg9olJFxV9cmuDd8sZi79R4P@72kNd5DBAkhdqdDTnmF78EB2ZbqNezMh79MoO6wyYv6DE869GZG@LmdT0v8MKqpcBc849t2oWuonW9gc4Lkcdz6PnZsK8WT9QTNzF8RGuobQqaK6h5PPhK17Ls/JkrO0/7z2dxH5r7I@muLjSlEiVa6pd1cwt@RweNWSj9Bc1NjGiyP80oUy8ytQXhS5uEW@TlL3I/fmp/@Ag "Red ‚Äì Try It Online")
## More readable:
```
f: func[s][
    a: charset[#"a"-#"z"#"A"-#"Z"]
    v: copy ""
    parse s[any[copy c a(append v to-string c)| skip]]
    k: 0
    t: copy ""
    repeat n (length? v) / 5[
        c: 0
        p: 16
        loop 5[
            if v/(k: k + 1) < #"a" [c: c + p]
            p: p / 2
        ]
        append t #"a" + c
    ]
    foreach c t[replace s "_" c]
    lowercase s
]
```
[Answer]
# Go, ~~219~~ ~~217~~ ~~192~~ ~~210~~ ~~209~~ 156 bytes
Saved 25 bytes thanks to [@Lynn!](https://codegolf.stackexchange.com/users/3852/lynn)
Saved 53 bytes thanks to [@ovs!](https://codegolf.stackexchange.com/users/64121/ovs)
Had to lose 18 bytes because of a bug with strings with no underscores :(
```
func p(s string){b:=0;n:=0;for _,c:=range s{if IsLetter(c){b+=b;if IsUpper(c){b+=1};n++;s=g.Replace(s,"_",string('a'+b%32),(5-n%5)/5)}};Print(g.ToLower(s))}
```
[Try it online!](https://tio.run/##LU/LasMwEDxHX7EI2kjYNUlLLxY6F0NCQh@XlBJkWRamsSwkmQaMv91V7OxhYWdmZ3Z1N1khf4VW0IrGINS0tnMBCFppwD64xmiP0SoD3JtGdpVahroNGFGE6t7IeZNQGNCqMbYPkHPA1h3enNjvC6Ph2J9OF/UBjyAPlYJzrOhiyaymaJxmF0s8LIF0KHO@YebWXM51VphKXYlP8RlT1tTgOH/aDo5vRlZ3Ds6pzLkTJj7hvze5@xmipvA7FYJyRNLhenOasS9r7xDfjqxMeJlcmUmS8UYbzl8HE6U@Zr4rexFSLanpchhZi3VSPrw803RLWRnzR3aMRCA6@@x23V/09pSOaJr@AQ)
[Answer]
# [Haskell](https://www.haskell.org/), 165 bytes
```
g""
import Data.Char
f t(x:s)('_':r)=x:f t s r
f[0,a]s r=g(s++[chr a])r
f[n,a]s(c:r)=toLower c:f[div n$1+sum[1|isAlpha c],a+sum[n|isUpper c]]s r
f _ s e=e
g=f[16,97]
```
[Try it online!](https://tio.run/##NZBfb9owFMXf8ylOq2qA@KOxh01DQlUHaUkHJCqEbrDIchMTRxg7s00D0j77mBNp9@Ve/c7RPb7m1ByYENd@H7@u@e2tVxxLpS2m1NLBhFPt7WHb55HptFukNdKd8XnkCAycsvvYo4mbxnnbdLu7lGvQpFMLshbaae23aq4qppGO9ruseIe8G3bN6bgb/inMgyg5RZr0aIOkQ3FZ1uYkaRJAXBIbMy8f73fDz72vX5LrkRYSYxTSMk1TizucpCgkMxjgSEu03RkdNzfsyt116sZzbR72UCktyI1XgC5wUbHGnq45IQOv1OGTpotFIHNEp@1WsBU@IA0zBuLKm1CJn@EJeczMCnbmw19mUI9Y88I0lntvPWP4HQeTA960qiQewzOe40VpoDa@huUMghJSuwfei6LZ6h7VzH9hqFhLM@SqkE949ZGpZctCMpY1m53bch@5ZtT6K4u1LtIDajRlm0DA37gfi2Ih/AzVg8EkXL4HMi2WuXsow6vS8yl4k0ta5P/Kb4GkmnjDT1go@Z1diMcvEdNvSgRbQv6me0Fzc@3/mETRPw "Haskell ‚Äì Try It Online") Example usage: `g"" "BInar_"` yields `"binary"`.
[Answer]
# [PowerShell](https://github.com/TryItOnline/TioSetup/wiki/Powershell), 121 bytes
```
switch -r($args|% t*y){_{$_=$a[$n++]+97}[a-z]{$x+=$x+($_-le96);if(!(++$i%5)){$a+=,$x;$x=0};$_=$_-bor32}.{$r+=[char]$_}}$r
```
[Try it online!](https://tio.run/##bVR/b9pADP2fT@Gia4HxQ1unbeoq1G1t2rIVqAq0WhGKQmKSrEeO3iVASPPZmS@UDZadFCmy33t@9jmZiQVK5SHnazaBJiRrtfBD24O6LDNLuurlEMI3cSUxE2Y2mTVkQbU6qp58SodWfTVK2LLapKfMzDrHk4@VU39SPihXq8w//FCpJMyqNmtsecqWzbfpqVYw62Mh3x@njYTJanNoe5YcMTNNmVynhcKXcgHo1MoAJTJ1063BQkhuHpRqWUIfneBik3AOSpUssUfjIo/PA32w2hCLgYSJ1fdMs7HLoeSUkpFOhh7KRo4@k90rabXbrcCF2@jxkWMPjsDuOggmnV2xmRSutKZTn6CzaLXiqDRUENQVfJKTPrcC@NmNwB2g6kF4bYDRcUBcQt/zVaZ@titvE5ysghuhUkBuAQOCT@iV4CEuw7Ncif41wvOgdf4EYykWAVx2l/B90J4pEPeGzES4ZZq62N5cdOI58u0tbyKW8Cuaat4ct7xVDI5wcyMr3gnL6Z3B4tq4Q1hgSer@/eAKHgwidEohBIhO1qDZKP6tWpREVESki9gluvROxGBLzGCN4r9lQ88AV6IVGr0Q@lKb16ELvG9xMO7J9u2Ac8OBxVcF593OvBXYfselwSM8CHlzAZ65uVPzP950y5k6qhDCV3WyhXOfA@qhzCLOyd3CUnTnwdwndbKuQdkKg0b7ju4Cl74Kcw2UvrUCS@5t1NinSJy71XfH0BbBD4z3wBSdiuAJY5X/WOJblGPBW4/7G@vFsyzur9DJkZJhN0C4sajfvm7apkUZpbv0ZCgCvQh6IhuEQkJUChV4gUNIMiRTNWC4nKEd0nSawMxNWKKKeEiBI/ojMZUFi6z8Gq/b@PyHVfm8hRcL6fo3 "PowerShell ‚Äì Try It Online")
Less golfed:
```
switch -Regex ($args|% toCharArray){
    _ {                     # is underscore
        $_=$a[$n++]+97      # get a char from the array of letter
    }
    [a-z] {                 # is letter
        $x+=$x+($_-le96)    # $x=2*$x+($_-le96)
        if(!(++$i%5)){      # if(++$i%5 -eq 0)
            $a+=,$x         # add an element to the array of letters
            $x=0            # init
        }
        $_=$_-bor32         # to lower
    }
    . {                     # is any char ('_' and letters included)
        $r+=[char]$_        # add the char to result
    }
}
$r
```
[Answer]
# [Ruby](https://www.ruby-lang.org/), ~~107~~ ~~106~~ 103 bytes
```
->s{s.chars.map{|c|c !~/\W|\d/?c<?a?1:0:p}.join.scan(/.{5}/){|b|s[?_]&&=(b.to_i(2)+97).chr};s.downcase}
```
[Try it online!](https://tio.run/##TVBdb5tAEHzvr5j4wR9qiptIUdW0KWodEtMYY8XGVu1Yp@NYAw3h6B2uawH96y6Ql@7DaXc0O7Nzau8fT7ub07svutCGiLjSxgvPilKUAmd/h0@r8ikYmuKzyc2L6/fXWWX8lHFqaMHT/tAorqrhoCj9Um9Mtu12b/q@kUsW9y8Hbz9@GNSCqvqkjUAeUsE1VadNJ6IkkWed8zdNN3HPcZAqYS0Qgzs4Sk9hxxcRY0YDZsq9V9xx7DTEbL9eJzRHF8INCKyuhjLiKX64e4Qe6TnysQVrGkDeYRHFumWZDW0xJvzy7NEzfFUfhDv3D757TqYhl5ZCHhESzliz0Do/Sh7MTRzG1iPhQD1FCOvs91hZCOS0lyMlClr914U8shAq4rk1z7FQsXhGA93S0k5gLUlh5iWJFeDwVWPkTn/bqYinYX0xYSXV5BZR68567D/Vb3bKVZvz4hKOTB/o2E7RcUbKl4m9fv2FYuOmhAnXtTfVj6izbKvO1iAuoqLMa6xEts81dptm2Fanfw "Ruby ‚Äì Try It Online")
[Answer]
# Japt, 25 bytes
```
r'_@r\L m√®\A sTT¬±5 √çdI√Ñ√Év
```
[Try it](https://ethproductions.github.io/japt/?v=2.0a0&code=cidfQHJcTCBt6FxBIHNUVLE1IM1kScTDdg==&input=InByT0dyYU1NSW5nIFB1WlpsZVMgJiBjT2RlIF9fX18i)
---
## Explanation
```
r'_                           :Replace underscores
   @                          :Pass each match through a function
    r                         :  From original input remove
     \L                       :    /[^a-zA-Z]/g
        m                     :  Map
         √®                    :    Count
          \A                  :      /[A-Z]/g
             s                :  Slice
              T               :    From index T (initially 0)
               T¬±5            :    To index T+=5
                   √ç          :  Convert from base-2 string to base-10 integer
                     I√Ñ       :  Add 64+1
                    d         :  Get character at that codepoint
                       √É      :End function
                        v     :Lowercase
```
[Answer]
# Pyth, 36 bytes
```
Km@Gim!}kGd2c@+r1GGQ5VQp?qN\_.(KZr0N
```
[Try it here](http://pyth.herokuapp.com/?code=Km%40Gim!%7DkGd2c%40%2Br1GGQ5VQp%3FqN%5C_.(KZr0N&input=%22THe%20qUICk%20brown%20FOx%20JUMps%20oVEr%20the%20la__%20___.%22&debug=0)
### Explanation
```
Km@Gim!}kGd2c@+r1GGQ5VQp?qN\_.(KZr0N
             @+r1GGQ                   Get the letters from the input...
            c       5                  ... in chunks of 5.
 m        d                            For each chunk...
     m!}kG                             ... check if each letter is uppercase...
    i      2                           ... converted to binary...
  @G                                   ... and get the corresponding letter.
                     VQp               For each character in the input...
K                       ?qN\_.(KZ      ... if the character is '_', replace it...
                                 r0N   ... otherwise, lowercase it.
```
[Answer]
# [Perl 5](https://www.perl.org/) `-p`, 78 bytes
```
for$h(s/\W|\d//gr=~y/a-z/0/r=~y/A-Z/1/r=~/.{5}/g){s%_%chr 65+oct"0b$h"%e}$_=lc
```
[Try it online!](https://tio.run/##JYxNi8IwFEX3/oqHtIwi7YuLunMhWlBwdEBHwQ9CjbEphqYkQRlr/enGOt7FuYe7uAXXMnLupLQnWgZ36/vuiJjq/uMPk@CGBP91EGyw@1YMy6jCtF0an/pMaOhFHcVskxw80fR55dG@ZM5ZImJINU9svLCw1Bk7g62nEV9NJMQrruHnV8r4CNeBgeF8dpnkLJulYMcc1kpPRyAo0Dpfn6Jho9zOcw7TxNSHvAZLKN1XT1XYTOXGBd9RSLrEBcUL "Perl 5 ‚Äì Try It Online")
[Answer]
# [Python 3.5](https://docs.python.org/3.5/), 296 bytes
```
u=input();f=u.find('_');m=''.join([c for c in u if c.isalpha()]);z=[chr(int(''.join(['0'if o.islower() else'1' for o in l]),2)+65)for l in[m[h:h+5]for h in range(0,len(m),5)]if len(l)==5];[z.insert(v,d)for v,d in enumerate(u[f:])if d!="_"];u=list(u);u[f:]=z[:len(u[f:])];print(''.join(u).lower())
```
[Try it online](https://tio.run/##TY/BSsQwEIZfZewlGbaUVVnEDTmJooJ4cb2EEGo3NdE0qWnj6r58bXZFPA3zz/d/MP33aII/n6bEre/TSJG1PFWt9VtKFEHWcUKqt2A9FQ20IUID1kMC20JT2aF2vakpSmR7LhoTqfUj/WuQJZm5MHMu7HSkCNoNmpySgylkk5NYnuHi8gJz5OZIdMKszWIlc2AyE2v/qumydNrTDssVytmaF4ecryQT@8r6QceRfpbbg2eeuah96nSsR02TaNcS59r2hBeqkCxxZ4eRJmSHE9@LdTYeOcn6@P@RhNXvAzhNxdOtho/N3dU7vMSw83Dz@AX3m4d@gPB8HWE0GlytFCilquIH)
## First code golf :)
## (I know its not small in bytes, I was just having fun making a 1 line code)
## Here is the explanation:
---
*User input*
> 
> u=input()
> 
> 
> 
---
*Finds the index of the first \_ in the string and stores it*
> 
> f=u.find('\_')
> 
> 
> 
---
*strips string of all non-alpha characters*
> 
> m=''.join([c for c in u if c.isalpha()])
> 
> 
> 
---
*Splits the alpha string into an array with each element consisting of 5 characters*
Ex. ['THeqU', 'ICkbr', 'ownFO', 'xJUMp', 'soVEr', 'thela']
*Then converts lowercase characters to 0 and uppercase characters to 1*
Ex. ['11001', '11000', '00011', '01110', '00110', '00000']
*and converts the binary string to an integer, adds 65 and converts that to a character*
Ex. ['z', 'y', 'd', 'o', 'g', 'a']
> 
> z=[chr(int(''.join(['0' if o.islower() else '1' for o in l]),2)+65) for l in [m[h:h+5] for h in range(0,len(m),5)] if len(l)==5]
> 
> 
> 
---
*finds all characteres after the first \_ and pushes them into the array z at their respective locations (defined above)*
Ex. ['z', 'y', ' ', 'd', 'o', 'g', '.', 'a']
> 
> [z.insert(v,d) for v,d in enumerate(u[f:]) if d!="\_"]
> 
> 
> 
---
*split our string into a list of characters*
> 
> u=list(u)
> 
> 
> 
---
*slice our string from the first \_ to the end of the list and replace it with the array z. I also had to slice the array z to the length of the split string from the first \_ to the end because I got an extra character in the lazy dog example (the "a" at the end of the examples above)*
> 
> u[f:]=z[:len(list(u[f:]))]
> 
> 
> 
---
\*print out the answer \*
> 
> print(''.join(u).lower())
> 
> 
> 
---
[Answer]
# Java 10, ~~186~~ ~~184~~ 162 bytes
```
s->{var b="";for(Byte c:s.getBytes())s=(b+=c>64&c<91?1:c>96&c<123?0:"").length()>4?s.replaceFirst("_",(char)(97+c.valueOf(b,2))+(b="")):s;return s.toLowerCase();}
```
-2 bytes thanks to *@ceilingcat*.
[Try it online.](https://tio.run/##jVHvb9owEP3ev@ItH4qjttFgVafCAK00bdkKqcqPakxTZJwjSXFtZhsYqvjbWejQvqaWLd2d3717d/fMV/zsOZnvhOTWosdz9XoE5MqRmXFB6O9dYOBMrlIIdjCs3yji2@IV1zrucoE@FJrY2bPW64obTJue15hpw642jiDqNkjJ7W3LfN822fSkKVoX58fiy2W1Xa2L1uVFYVdrn9of657nB5JU6jLmt87bNjC0kIWcm9xYx7zYO2Ui48Znl59PRLDicknRjE1Pa75/wvaFfb9uG4bc0ijYwOl7vSbT4ZaY39juGv90L5ZTWeg@yF/pPMFLMYBDjz9/gfuH7jfW0Uugly5YFF9OKqYCwbyMpNQfimKNMth9dIq1NjIuR@fgPWz0yGDGh1kcB6UZCxPdGt7rdYvFPCwnE0kDHENECSEuTml@hyv8iJZIR2QHcHchwn4CfYNhlts3inYpx/CO8HvU7cwxNXqtcBP9wbdRb2Ghx6GBywiSx/GerbyhR82TQRvru/CRsKaKIaQ6V7d4CpHofsVBESVvyt7B5rIQqSHuwoHD0ORijn3omsZdiXBMBg8jKcME668Wnai/6iqR99NiEIQnbe6vkb3pjivxe0tedRU35YOv1tDT6jttyqHZ5oHMVMvu5P9Ct0fb3V8)
**Explanation:**
```
s->{                        // Method with String as both parameter and return-type
  var b="";                 //  Binary-String, starting empty
  for(Byte c:s.getBytes())  //  Loop over the characters of the input-String:
    s=(b+=c>64&c<91?        //   If the current character is a lowercase letter:
           1                //    Append "1" to the binary-String
          :c>96&c<123?      //   Else-if it's an uppercase letter:
           0                //    Append "0" to the binary-String
          :                 //   Else (it's not a letter):
           ""               //    Append nothing to the binary-String
      ).length()>4?         //   And if the length of the new binary-String is now 5:
       s.replaceFirst("_",  //    Replace the first "_" in the input-String with
          (char)(97+c.valueOf(b,2))
                            //    the binary-String as character
         +(b="")):s;        //    And reset the binary-String
  return s.toLowerCase();}  //  Return the modified lowercased input-String
```
[Answer]
# [jq](https://stedolan.github.io/jq/), ~~165~~ 159 bytes
*Unnecessary space before `as`, and found a place where`(a|[thing])[]` could be replaced with `(a|thing)`*
```
reduce(split("[^a-z]";"i")|add|explode|while(length>4;.[5:])[:5]|map(try(.>91//1)+0//0)|reduce .[]as $x(3;2*.+$x)+1)as $r(ascii_downcase;sub("_";[$r]|implode))
```
~~[Try it online!](https://tio.run/##NY/dbptAEIXveYopsmqoFRynzUWDlKh1SEwajOW/qEZ0tWansM1ml@ziYrf01UuJo87FXBydOeebH89tq5HtMnRMKXjl2Mk3evIrtX2b225DGWtwXwrFsEnqggt0BMq8Ki4/@F5yfpG6ycV52jzR0qn0wfEuP46Gw5E7OB0OT93mNRi8JAVqoLd33vtn77xBb@8ORt3lq6odajLOCVO1zKhB3@y2jk1sP@nptOFPx3LXbdsChVBvLA40goNaafhOlwUhnlXq@FbTKAplDrPdZiNwAW8hixkC6cYaUwlf4x3kKzQLqCYBBFMG6gaWBTdHy5W1nCA8r8LxI2x1BwI38R7uVlFpQK0DDVWBICghL27PmivKFldQT4I5Qo19jZArLm/hIQCmpv0KJCI7Jnfuqggg10irYFHBUvPsEV6ka1yHAoI1apithAgY1J8MjOPpz1BmfJp3oAgPSt9fQ3HsJX3yP/JzKKkm1ugMIiW/4IFYxWGGeqtEuOke/p3EEuGemq4Pu5V15Omfv6qsuJKmPZnrfw "jq ‚Äì Try It Online")~~
[Try it online!](https://tio.run/##NY9db9MwFIbv8ysOUUUTqqXrYBcs0ibosjWwNlXbdKJRsNz4kJh5dmanpIXw1wlpEefiXLx69H58f2lbjWyXoWNKwSvHTr7Ss5@p7dvcdhvKWIP7UiiGTV1wgY5AmVfF9TvfSy6vUje5ukybZ1o6lT443vX70XA4cgfnw@G52/zzBS9JqYHe3nnrX7zxBr29Oxi5R0U71GScE6ZqmVGDvtltHZvYftLTacOfT7Gu27YFCqFeWRzoFA4q1vCNrgpCPKvU0b2m02koc5jvNhuBS3gNWcQQSHfWmEr4Eu0gj9EsoZoEEMwYqDtYFdyckBtrNUF4icPxE2x1VwTuoj18iqelAbUONFQFgqCEHGnPWijKljdQT4IFQo19jZArLu/hMQCmZv0KJCI7OXd0VQSQa6RVsKxgpXn2BEfpFtehgGCNGuaxEAGD@oOBcTT7EcqMz/KuKMKj0g@3UJxySZ/8t/wYSqqJNbqAqZKf8UCs4jBHvVUi3HSDfyWRRHigpsvD7mVd8/T3H1VWXEnTni30Xw "jq ‚Äì Try It Online")
Phew, this was a fun one! `reduce` is the real star of the show here.
```
reduce (
    # filter to alphanumeric characters and explode string into codepoints
    split("[^a-z]";"i") | add | explode |
    # chunk letters from string into full groups of 5
    while(length>4; .[5:])[:5] |
    # for each chunk emit 1 if uppercase, 0 if lowercase
    map(try(.>91//1)+0//0) |
    # reduce each chunk to a codepoint
    # start with 3, double and add the next element in the array.
    # [0,0,1,1,0] -> 6 [0,1,1,0] -> ... 102, we need to add one to map correctly
    reduce .[] as $x(3;2*.+$x)+1
# for each code point $r:
) as $r (
    # initialize with lowercased input
    ascii_downcase;
    # substitute "_" with the current letter ([codepoint]|implode)
    sub("_";[$r]|implode)
)
```
[Answer]
# [Vyxal](https://github.com/Vyxal/Vyxal), 135 [bitsv2](https://github.com/Vyxal/Vyncode/blob/main/README.md), 16.875 bytes
```
\_√ûIŒª?«ç5·∫á∆õaB‚Ä∫√∏A}¬¢…Ω
```
[Try it Online!](https://vyxal.pythonanywhere.com/?v=2#WyJzPSIsIiIsIlxcX8OeSc67P8eNNeG6h8abYULigLrDuEF9wqLJvSIsIiIsIkNhbiBZT3UgZ1Vlc1MgdEhFIEVOZCBvRiBUaGlzIF9fX18/Il0=)
The `s` flag is for user convenience. Outputs as a list of characters otherwise.
## Explained
```
\_√ûIŒª?«ç5·∫á∆õaB‚Ä∫√∏A}¬¢…Ω¬≠‚Å°‚Äã‚Äé‚Äé‚Å™‚Å°‚Å™‚Å†‚Å™‚Å°‚Å™‚Äè‚Å†‚Äé‚Å™‚Å°‚Å™‚Å†‚Å™‚Å¢‚Å™‚Äè‚Å†‚Äé‚Å™‚Å°‚Å™‚Å†‚Å™‚Å£‚Å™‚Äè‚Å†‚Äé‚Å™‚Å°‚Å™‚Å†‚Å™‚Å§‚Å™‚Äè‚Å†‚Äé‚Å™‚Å°‚Å™‚Å†‚Å™‚Å¢‚Å°‚Å™‚Äè‚Å†‚Äé‚Å™‚Å°‚Å™‚Å†‚Å™‚Å§‚Å§‚Å™‚Äè‚Å†‚Äé‚Å™‚Å°‚Å™‚Å†‚Å™‚Å¢‚Å°‚Å°‚Å™‚Äè‚Äè‚Äã‚Å°‚Å†‚Å°‚Äå‚Å¢‚Äã‚Äé‚Äé‚Å™‚Å°‚Å™‚Å†‚Å™‚Å¢‚Å¢‚Å™‚Äè‚Å†‚Äé‚Å™‚Å°‚Å™‚Å†‚Å™‚Å¢‚Å£‚Å™‚Äè‚Å†‚Äé‚Å™‚Å°‚Å™‚Å†‚Å™‚Å¢‚Å§‚Å™‚Äè‚Å†‚Äé‚Å™‚Å°‚Å™‚Å†‚Å™‚Å£‚Å°‚Å™‚Äè‚Äè‚Äã‚Å°‚Å†‚Å°‚Äå‚Å£‚Äã‚Äé‚Äé‚Å™‚Å°‚Å™‚Å†‚Å™‚Å£‚Å¢‚Å™‚Äè‚Å†‚Äé‚Å™‚Å°‚Å™‚Å†‚Å™‚Å§‚Å§‚Å™‚Äè‚Äè‚Äã‚Å°‚Å†‚Å°‚Äå‚Å§‚Äã‚Äé‚Äé‚Å™‚Å°‚Å™‚Å†‚Å™‚Å£‚Å£‚Å™‚Äè‚Å†‚Äé‚Å™‚Å°‚Å™‚Å†‚Å™‚Å£‚Å§‚Å™‚Äè‚Å†‚Äé‚Å™‚Å°‚Å™‚Å†‚Å™‚Å§‚Å°‚Å™‚Äè‚Äè‚Äã‚Å°‚Å†‚Å°‚Äå‚Å¢‚Å°‚Äã‚Äé‚Äé‚Å™‚Å°‚Å™‚Å†‚Å™‚Å§‚Å¢‚Å™‚Äè‚Å†‚Äé‚Å™‚Å°‚Å™‚Å†‚Å™‚Å§‚Å£‚Å™‚Äè‚Äè‚Äã‚Å°‚Å†‚Å°‚Äå‚Å¢‚Å¢‚Äã‚Äé‚Äé‚Å™‚Å°‚Å™‚Å†‚Å™‚Å¢‚Å°‚Å¢‚Å™‚Äè‚Äè‚Äã‚Å°‚Å†‚Å°‚Äå¬≠
\_√ûIŒª          }¬¢   # ‚Äé‚Å°Replace the indices that correspond to "_"s by each letter in:
     ?«ç5·∫á           # ‚Äé‚Å¢  Push the input with non-letters removed, wrapped in chunks of length 5
         ∆õ     }    # ‚Äé‚Å£  To each chunk:
          aB‚Ä∫       # ‚Äé‚Å§    int(is_upper(chunk), 2) + 1
             √∏A     # ‚Äé‚Å¢‚Å°    Nth letter
                 …Ω  # ‚Äé‚Å¢‚Å¢Convert that to lowercase
üíé
```
Created with the help of [Luminespire](https://vyxal.github.io/Luminespire).
]