[Question]
  [
[Cubically](//git.io/Cubically) is too tedious to manually write any code in. Your challenge is to translate ASCII text into Cubically source code.
# Cubically
This is just a quick run-down of Cubically; the [repository](//git.io/Cubically) has a more complete guide and details.
Cubically is an esolang I wrote a while ago, designed to be painful to use. It contains two pieces of memory, a 3x3x3 Rubik's Cube and a register called the "notepad".
### Memory
The internal Rubik's Cube is initialized like this:
```
   000
   000          top face
   000
111222333444    left, front, right, and back faces, respectively
111222333444
111222333444
   555
   555          down face
   555
```
After performing a clockwise 90° turn on the right face, the memory cube would look like this:
```
   002
   002
   002
111225333044
111225333044
111225333044
   554
   554
   554
```
### Commands
A non-integer character sets the default command. For each integer before the default command is set once again, the command is performed with that integer. For example, `x524y312` would perform command `x` with 5, then with 2, then with 4, then perform command `y` with 3, then with 1, then with 2.
The integers that commands use represent face indexes. So `x0` would perform `x` on the UP (0-indexed) face. `x1` would perform `x` on the LEFT (1-indexed) face, and so on.
Performing any command with `6` will perform that command on the notepad value. Performing any command with any integer over 6 will result in an error.
Here are some example commands:
* `R1` - turn the RIGHT face clockwise 90° so the internal cube will look like the second example above
* `R11` - turn the RIGHT face clockwise 90° twice, identical to `R2`
* `+0` - add all values of the UP face to the notepad
* `+000` - add all values of the UP face to the notepad three times
* `@6` - print the nonexistent 6th-indexed face (memory) as a character
* `%4` - print the sum of all values on the BACK face as an integer
A complete list of commands and syntax is available at the [repository](//git.io/Cubically).
# Challenge
You will take ASCII text as input and print a Cubically program as output.
Examples (stolen from [here](https://codegolf.stackexchange.com/a/126522/61563) and [here](https://codegolf.stackexchange.com/a/126679/61563)):
```
Input -> Output
Hello, World! -> +53@6+1F2L2+0@6L2F2U3R3F1L1+2@66L3F3R1U1B3+0@6:4U1R1+00@6-000@6*0-4+000@6-00@6+2-000000@6-5+4000@6-00@6/0+00@6:0+0/0+00@6
1$2$3$4$5$6$7$8$9$10$ -> B1+2/2%6@4+00/0%6@4+00/1%6@4+21/1%6@4+30/0%6@4+22/1%6@4+22/1%6@4+40/1%6@4+52/1%6@4+42/1%6@4
```
# Rules
* Your program may not contain a dictionary containing the translations for the 100 testcases.
* Your program must finish in less than 180 seconds (no brute-force programs that take weeks).
* Your program must output valid Cubically code that finishes in less than 180 seconds.
* Your program will take input via standard input, unless you want to mess with the test driver.
* Your program must output Cubically code that produces nothing but your program's input when run. [ಠ\_ಠ](https://chat.stackexchange.com/transcript/message/38913238#38913238)
# Scoring
You will test your program with 100 pseudorandom strings of pseudorandom length. (A bash script is provided that will do this for you.) Here is how you will score:
* Let the length of the output program be **o**.
* Let the length of the input string be **l**.
* Let a variable **r** be the result of **o/l**.
* Find the average of all **r**: **(r1 + r2 + r... + r100) / 100**.
[Test with this script.](https://tio.run/##lVXtf9o2EP7uv@IKZNiFGNI2ewkhG2tplo0mWZruLUkzYR@2NlvyJDkvTdm/np1sA6bNfr9WH0DcPbp77rmTmDId3983H/WmXPSm9MNxmp@xnCbcylxBpmSkWAqRRA1cgIkRZlxpA0xFeYrC@GDBn7ws2MRK5lEsc1PE04HimelaMyJkMhchaB4JXYC5CHnADJKbGUsK0pzSpzLks1vQMkUTcxEVND6nQMdIw5Jh36HgsAeKidAPnCgIqi1symJX6AYvj05gNJnAZHS4/2a0P369U5gB@KwUKpBpxhNUPS4MqkwhfYJADDUwCFAZRurNCAF4Y1BoLkUXWBgCJxEktK3QbZhiIq99x8EgltBobTWImfWsSDw/enV8MBm/@JiJDUYsUuKsbUg6F@YBlvTwBoPcsCnlj1EhpWgC@qQa2IptirLiMtlMKtBG2Ya3XL9nZfCcUDqLJpLvUvN3OGzdNWk/XzoK3psCobWAQPvctNf91kd10advbsyqtIPD0/HJ8cn49KHqFGYJo2raNX0rveCam7gss@b0q9bQScFSDCuJuxDETERodS9PGyn9T5D3IQJQ61qNRU1sSyBCgYomOARkKuFEzVkKQndg2HI/DAm7C3W8NehSdNo/JPoCsi66Qk05ypHSAUtw@GRQw/ZWzWrAe5gG3gftovNLS3lpPo5W2KFTgBdRQilwMcqjK5IgsnddKtxpwP9F6MFWv18FoOeLiyDJQ4RdbUIu/XjPWTMlfLpuMzxFa3GuJA@t8Jd2dmXqUtMVPNbUfSno9SDBIUHhwZ1TzjMzPKh8BZQlGY1Jnp5dwHBZfKO/9eTps@0vv/r6m8bK@O@j75qtjbdfPHa9y86fm8Ozi/PzQbvr9@7m73fOG7t739bAo@@fvxi/3P/h4MefJq8Oj45/Pnl9@uaXX3/7/Y8aiE2DEGdRzP/6O0mFzP6h9za/ur65fdcYlPNgL6idGuAwhP6AvnZtPQPodPiqffqME/1VLVYL14MNcG2z5cxdeDzYhC3vogquzyjURRHYmTuOTZPS6@VaTT2nVKzIPSi2lbSET1mSyMB91vcGNZYrhtRa2nQ6C9ntqvVId92S4cbTba@zXQWxK8uNdnVlmDvz@7W/Jfug/Qc) You'll have to modify it as instructed. Note that the program does not check whether the output is valid Cubically code.
If you can't get the script working, I can help. Ping me in the [Cubically chat room](https://chat.stackexchange.com/rooms/62883/cubically).
  
[Answer]
# Lua, [Score](https://tio.run/##lVZZQ9tGEH7Xr5jaUCR8G0gCxjQ0ISQtOUpIL0PTtbS2N5W0rrTiCKF/PZ3Z1YkNSfRgr3Znv5n55tKYxbPPn@vfdcYi7IzxxbLq3/BYdbiSSQTzSE4jFsBU8hhECGrGYSKiWAGLpknAQ9UGEv7qh4TVLJLJdCYTpfFiNxJz1aRtzmEuk9CDWEzDWAuL0BMuUxyPmSKjIEhQfSA9MbmCWAZczUQ41WZ8i4OWkor5w66F4LAHEQu9tmtNXTddQkvqleYNnr0@hv2jIzjaf3X4bv/w4O2O3gYQE0OUK4O58HnUEaHi0Tzi@Ash514MDFweKYbsTVAC@KXiYSxk2ATmeSCQBAlrRPQajLkvL9qWxd2ZhNpKr4aW0UlhxJPXL9@8ODp4umgJgaEVAdocEyTe8xKXG/P4JXcTxcaof8YjjirqwNvIGpDHpMJ4bJRNZASxiijgK3a7QzQ4lietLIh49j4WH/lw5bqO65v8QNvdCjmsZCKwdqrWqud0hn7hb1tdqsK1F69ODo7f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Ov@JnFL/EK1gSmWasHpXFflA8K6CoaafGzXOJiRl82ZaeMYBnlbttaWrYkWPFOqypGU258saK07lZS5VbsWXilPxJ1PS6JtHEQP8wipiO2WmSA2bwVI0Q@ia7oI0vOcfTQNEUsAvZIC@E26TIWoNZUxL2SUAFTs/bElzKy831Kakoro/eevOj0iqBnraJgKXWluyx3TLAKxyoxMlSEMMwFtrStWyAjs2XleZP6ZLRj76yau2jyTq1yuGB13j4yxN6XEBtLEbtlxDxLFm6XgTPCzH@rdFYG@OoILJSYm3YCWyeXkyfrXYm6JEnvr9Iv1agJurusMO8L4T0BXEy6LwTvntAtBK7MesZdpUnc2SKymzm7S2dKaZK7fSu7ZeWW9C3ameOoVDZedf4H): ~~85.91~~ ~~13.50~~ ~~13.20~~ ~~12.70~~ ~~9.41~~ ~~9.32~~ ~~9.83~~ ~~9.66~~ ~~9.12~~ ~~9.06~~ 8.03 (Average)
```
-- Get input
local inp = io.read("*a")
local out = ""
local faces = { [5] = 45, [4] = 36, [3] = 27, [2] = 18, [1] = 9 }
local lastChar = nil
-- Mode the program is in
-- 2 = not set (needs :), 1 = just set (needs +), 0 = normal
local mode = 1;
for i = 1, inp:len() do
  -- Character value at current position
  local c = string.byte(inp, i)
  if c == lastChar then
    -- Repeat character
    out = out .. "6"
  elseif c % 9 == 0 and c <= 45 then
    if #out == 0 then
      out = out .. "@"
    end
    out = out .. (c / 9)
  else
    local c2 = c
    -- Handle if difference from lastChar is divisible by 9
    if lastChar and (c - lastChar) % 9 == 0 then
      local difference = c - lastChar
      if difference > 0 then
        out = out .. "+"
      else
        out = out .. "-"
        difference = difference * -1
      end
      for index = 5, 1, -1 do
        local face = faces[index]
        while difference >= face do
          difference = difference - face
          out = out .. index
        end
      end
      c = 0
    end
    -- Handle anything not divisible by 9
    local extra = c % 9
    if extra > 0 then
      -- Try to optimize by dividing by 9, if possible
      if lastChar and math.floor(lastChar / 9) == extra then
        out = out .. "/1"
        mode = 1
        extra = 0
      else
        while extra > 0 do
          local n = extra > 5 and 5 or extra
          if mode == 2 then
            out = out .. ":"
            mode = 1
          elseif mode == 1 then
            out = out .. "+"
            mode = 0
          end
          out = out .. n
          extra = extra - n
        end
        out = out .. "/1"
        mode = 1
      end
      c = c - (c % 9)
    end
    -- Handle anything divisible by 9
    for index = 5, 1, -1 do
      local face = faces[index]
      while c >= face do
        if mode == 2 then
          out = out .. ":"
          mode = 1
        elseif mode == 1 then
          out = out .. "+"
          mode = 0
        end
        c = c - face
        out = out .. index
      end
    end
    out = out .. "@6"
    lastChar = c2
  end
  mode = 2
end
print(out)
```
[Try it online!](https://tio.run/##jVVNb9swDL37V3AeCthtnMZps63dOgzYYb3sMuxW9KDaSqNBsQJZaZsN@@0ZKdmyXLvpgCCmSerx61GWW7bfZxl84wZEtdmaSKqCSZLhCoSaas7KJD5mcRo1JrU1aIrj5nXJCl6j4g/cLG7xeb6YwM05SWfvUDojaf4epTlJ@QeUcpIu4G@DIFltvq6YRmUlZBRhOt9VycGsOGy0utdsDaLGlMgyJy9loMaEk4rzsobLdAI5qn9t657@BPUz667XTDbB1oSMeXyMlkqDIHFC1V5KXiUplCoCwDCUDysM1/DA5JYDM1BsteaVgY2qhRGqQkcHWSBIbbSo7qd3O8MTREPIFO34E0uyX3VFYlV01Eb5wTeckNtgVu/6S//TKcRfYlRyWXMLdIRtQ7AZsKrE10/U7g4RXd7a0@ThtaOIiFmVw3BJAadwkTYhrb2pkfpeuJJs6teYgeQUshTLJcfOFByWWq27SnFmpXgQtbhDx7sdXLRJeg@qAkNmXpN2FQb5uxSCOJhKcKjx6qfyuQ/xvAkncWPwdQ59stgberGDl2PI8hao6WfTIgDLr6rkT3gEdwJpluWOX2FVtD7oYLfoxrrfeo/HlcDOhUU5xxDl5dwy6xs49qqzobyxS76TiNazHlWezZ5VO7NC1tt9HJm0K5A/Gc3sxI46Bjjlsxkh8k@9A6NAbYxYi98Wi4BLikK4EzqMC2gjdXPvEWrNzGq6lErpxOuJ1EQrF/cAL07zbujtVdF1qSllNsYdN6yusN6MXCsquPIOC5vrApAkVhV53jQ1ueh4d/bTHaZ8GfeMg6z99dEi5q8hnowizkJEz5LB6RC4bZh7ZoEtBPjvCQxWrGhugsSSK/VkfYmoIyQ9vKWv7agbejG2mIdGeGCAQ9K9MrwDoxsMLux627veJfHiFdGe9N0d/aYEX/JiHrWnIp/JPCLNBj@VJsGj6X5/zaVUE3hUWpZv/gE)
Okay, I don't think I can optimize this anymore.
This version iterates through each character, adding c % 9 (where c is the character's decimal value) by doing `:5+2/1`, then adds the parts divisible by 9 by adding that face's value. For example: `:2/1+551@` to print "e", where `:2/1` adds 2, `+551` adds 99 (9 \* (5 + 5 + 1), or 9 \* 11), and `@` prints the output. Input is read with `io.read()`.
Optimizations include directly adding/subtracting after printing if the difference between characters is a multiple of 9, dividing the current value if possible rather than setting c % 9 from scratch, and repeating characters by printing the current value again rather than recalculating it. Additionally, I've implemented Kamil's method of instantly printing any face that already contains the target value, and MD XF's suggestion to not use `:` at the beginning, but instead just start with a `+`.
[Answer]
# [Cubically](//git.io/cubically), [Score](https://tio.run/##lVRbW9tGEH3Xr5j4UkuRb4rBaW1McYIhpA5QB3oDSmVpLW0j7aq7Ky4hzl@ns5IvckO/L9GDPJ6ZnTlzzqymrgwfH8vPWlPKWlP8Yxjlb3iMMtzzVEAieCDcGAJOJFAGKiQwo0IqcEWQxoSpJujkr350sgoFT4OQpyqrJz1BE1XXbkIg4SnzQdKAySyZMp96riIYdpUGBXGK7WPu09k9SB4TFVIWZDC@ZUBDceVGg7aBxWEXhMv8pmcEnrcwocEzK@MNDk4mMByPYTw8PjwfHo7e9zI3AJ3lRHk8TmhERIsyRUQiCL6BEeJLcMEjQrnI3gwzgNwpwiTlrA6u7wNFEjjUNNE1mJKI3zYNg3ghh1LFKSEyHVmDeH3y7vRoPNr/EokuhihixCx1STznpx7J4ZE74qXKnWL/kAiCLcpAmsga6Il1i3zivNmMC5BKaMErZrOlabAMnxtLETF2LelHMqg8lNGerwIZ7gYjUFmmQO1S1TbjOoZz4bup7tR6tKPjs9HkdDI6e2o6QZLIxWlqBX4XfMEtVWE@ZiHYXEiDJ5kbE39BcR280GUB0bznpxXnza@g9ykAUFCtgKJAtgYQEEYEbrAPxBURRWjGihC8A4OK2eKJannpFBc9iu5bAq0PsqForgfsLLmyNg6uJED7KQmWKZsSCCKxY75gEvuRwYt@Ibe1lq4En2DqWf8RD8@vPPkV@rJa5gc7S15W8Tkjy8Ue3iAhgb75XJBeCf6vQgucdntRAD9mlHlR6hPYkcqnvBnuGhuuiE43fYrGRHuMG059LcO13mQem7gCAp5L3AXO8FuCikJEmAUPRr7drqLeIpalulGCS5PGF1cwWA1fajsvOlvb3Zff/1BaOz8/2ytXqn9@99y0ru2/GoOLq8vLfq3ebD3MP/UuSzu7PxaSh69e748ODt8cvf1p/O745PTnyfuz819@/e33PwpJ7tTzySwI6d8fopjx5B/8@qY3t3f3H0v9fB/0dTX1EBQG0O7jz46epw@2TdfyyQuK8NezaC5MC6pgarH5zFxGLGiAY10tissLLHWVFTbmhqHbxPgtMzWnlpEzlvXuZ@aCWsyPcZe5Z261rX4B5RohSouGbS9p109BI1k3c4TVzrZlby@K6CdJlTTlwjE35o/nnX1n0hk7B51Xzrmz3/nce2k7ZsPZ6@Cr6ljdnmN3HMfZ61adhjYcu93e2tNu/cepamtrWzswv5sdt7r/Ag): 86.98
```
U3D1R3L1F3B1U1D3~:7+1(-1@3(-1%1)6:1+3111@6%1-31111+004@6:1+11111%6:1+45@6:1-1%6~:7+1)6 
```
[Try it online!](https://tio.run/##Sy5NykxOzMmp/P8/1NjFMMjYx9DN2Mkw1NDFuM7KXNtQQ9fQwRhIqBpqmlkZahsbGho6mKka6oIYhtoGBiYOIGEQx1AVxDIxBQkA1ZuBtWuaKfz/75Gak5OvoxCeX5SToggA "Cubically – Try It Online")
Turns out, all you need is conditional loops, a face equal to 1, and consistent End-Of-Input behavior.
```
U3D1R3L1F3B1U1D3     set LEFT face sum to 1
~:7                  read input, set notepad to input
+1                   add 1 to notepad
(                    open loop that can always be jumped to
 -1                   subtract 1 from notepad
 @3                   print RIGHT face (ASCII 43 '+')
            ##   the following mechanism gets the output program's   ##
            ##   notepad to the current inputted ASCII value:        ##
 (                    open loop that can always be jumped to
  -1                   subtract 1 from notepad
  %1                   print '1'
 )6                   jump back to loop while notepad is nonzero
            ##   the following mechanism prints "/1@6:1"             ##
 :1+3111@6            set notepad to 47,    print (ASCII 47 '/')
 %1                   print LEFT face       print (integer '1')
 -31111+004@6         set notepad to 64,    print (ASCII 64 '@')
 :1+11111%6           set notepad to 6,     print (integer 6)
 :1+45@6              set notepad to 58,    print (ASCII 58 ':')
 :1-1%6               set notepad to 0,     print (integer 1)
 ~                    read input
 :7+1                 set notepad to input plus 1, so EOF changes to zero
)6                    loop if notepad is truthy
```
The adding/subtracting of the LEFT face is to get the loop to end when EOF is read.
[Answer]
# [C# (.NET Core)](https://www.microsoft.com/net/core/platform), Score: ~~129.98~~ ~~11.73~~ ~~10.82~~ ~~9.62~~ ~~10.33~~ ~~10.32~~ 10.20
-1.2 point from MD XF's suggestion to use `@6666...` instead of `@6@6@6@6...` for repeating character, and superior initialization sequence
```
static void Main()
{
	List<byte> input = new List<byte>();
            int inChar = Console.Read();
            while (inChar != -1)
            {
                input.Add((byte)inChar);
                inChar = Console.Read();
            }
            Console.Write("U3D1R3L1F3B1U1D3");
            byte[] sides = new byte[] { 20, 1, 14, 43, 24, 33 };
            byte currentChar = 0;
   	    if(currentChar == input[0] || sides.Contains(input[0])) Console.Write("@");
            foreach (byte character in input)
            {
		if (currentChar == character)
		{
			Console.Write("6");
			continue;
		}
		
		if (sides.Contains(character))
		{
			Console.Write(Array.IndexOf(sides, character));
			continue;
		}
                if (currentChar < character)
                {
                    Console.Write("+");
                    while (currentChar < character)
                    {
                        byte nextAdd = sides.Where(s => s + currentChar <= character).Max();
                        currentChar = (byte)(currentChar + nextAdd);
                        Console.Write(Array.IndexOf(sides, nextAdd));
                    }
                }
                if (currentChar > character)
                {
                    Console.Write("-");
                    while (currentChar > character)
                    {
                        byte nextSub = sides.Where(v => currentChar - v >= character).Max();
                        currentChar = (byte)(currentChar - nextSub);
                        Console.Write(Array.IndexOf(sides, nextSub));
                    }
                }
                Console.Write("@6");
            }
}
```
[Try it online!](https://tio.run/##rVRdb9owFH3Gv@KWJ0dARJqqL3xoHdU@JKpJrSoeqj4Y5zIspU5nOxRE@e3MmaFNDGxMNIoVXfv6nOOck3Dd4pnCda6F/Al3C23wqUPKVTgU8pc3NcjSFLkRmdThV5SoBO8QItkT6mfGEQb5WEwWZEl4yrR2pUBFlmttmBEcZplI4IYJSQPbVRsKbbrjhcE@CPmcG@iBxBd4n6ZBh0DpEtLYMZgyZVsHVkaWYniLLPEbX6YiRaCb3rMetKKg0rCsVA7bKgivkoTSgjtwez1c13iEgBUhlXrbO1LCIK3fx9fRbTyMvsSfo/voOq572wsFD4@gRYJ681Y2U0s4bzchsvdFEy7iJpzbZxzDqkN2EIDnSqE0G71t11L7c4gJrSz23Pkf2o/w@up4rd3SWK803S4FgX@OT4XwCu/ExorxKVAnwIIzblBZeMfg21CriQn4Wt62BXa96Kl5vJcFr53mVqKQORbFyo4NnKf/He4A3pVSbBF@lwnOf0zc7mZJxD6unVR4p@iWD@E376ZvT0Ya9T3hK4X7aLbDjG9BkTg3Nvo2JO7VjaaokNro9UFDo5Kjbtme8IbN6QGZxVUNoPuwKsIbW@q/gBzh1RbkAMquXSvyTwf7JzvY@g8H@x/g4F0@9hycFQ6WaVowg/6HOtjaUp/uYAFyioP@z@myvvNXXq2L8Q3TNGsCGWUqTc5@Aw "C# (.NET Core) – Try It Online")
My newest version actually does some manipulation of the cube! Yay!
That first `Console.Write` up there is a fixed manipulation MD XF worked out that creates this cube:
```
   242
   202
   242
000131555313
010121535343
000131555313
   424
   454
   424
```
The significance of this cube is that one of its sides has a sum of 1, allowing manipulations of the Notepad on a smaller scale than multiples of nine, and in particular it simplifies relative movement rather than needing to start from zero each character; in this algorithm both addition and subtraction are used to take the shortest path between characters.
MD XF's version of the initialization causes side 2 to have a sum of 14, which saves many bytes of output for ASCII distances between 14 and 20.
Now can handle inputs with internal newlines, Console.Read() gets individual characters until End of File; see the TIO link which should have the input
```
Hello, 
World!
```
Shaved a couple fractions of a point by immediately outputting a character if its ASCII value just happens to already exist on a side.
[Test Script](https://tio.run/##rVZ9X9s2EP4bfYproMNuEichtNsakjUFythC6aCs24AyxVZibbaUWjIvDdlX7062kzgObPTXGpLY0unuuec5ndynyv/0afVRrc9FrY8PhKx@xkVW4UbGEYwiOYxoCEPJFHAB2mcw4JHSQKNhHDKhHTDGD76MsfYjGQ99GevEn3IjPtIVM8wYjGQsPFB8KFRizIXHXaoZTlNtQEEYY/hQenxwA0qGTPtcDBMYn5Mg0VLToF0n6Bw6EFHhOS4Zum52C1WZ3CW8wavDI@j2etDrvt476e7tHj9PhgH4ICXKleGIByyqcaFZNIoYfoNgzFNAwWWRpsjeAC2AXWsmFJeiAtTzgCMJEtYN0evQZ4G8cghhri@htNYoITIz47hqjmP78ODNfm93ZxmM8YdAQoStjFdc6sUuSxGya@bGmvYRgs8ihlFCV829D2QESkdG5DXLqZnUbeJJMhUO5y4U/8jaa@NVvJ/MJhKsVcFgbWoC62d6fXHezGEu@O3oaz3PZf/1292jN0e7b@9KJ2KjgCL89RynGUdwxbWf5pWbdDI5cKWgIfMyWivg@lQMmeE6Xa2ldB7A510AIKdUDkWOXQNgyASLsGo9YDQKOEIjM0Kw7ttrViiFTNnHpbA1pcZesJsxjvd3MT41WWQ8YgoDpDWkXBqw9kYrZ1ubK1WCW@i7dkErXD8bSXfJsrdkHMqJ8dSLJwWb1m73EvMfms0tI/a8BPd5qEGjXs8cYL/iwg1iD/lQ2uPS8TtkYSjg/cUxzUNmRsil5J5h/cIUrgwtVDyCJwqllwLbBQoIARM2jElazFRzN5tLTGkwwhqJw9NzaM@SL9UbG83Np8@@/e770nzwn0cvVtcev//miWVflP@stk/Pz85a6xWnNp7cPj8rbXV@yBl3X27v7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L1C99SiRo15v1SKvvhjzaJb4qF1g2JmSpPM@KWgKb0ryOjf7/4reXaabX/TC@d/Q@PphTTL5e/QA "C# (.NET Core) – Try It Online") and explanation:
This is kinda boring, but as far as I can tell it works. Admittedly I only tried `Hello, World!` but I ran the output in the TIO Cubically interpreter and it output "Hello, World!" so I assumed it works.
Rather than actually manipulating the cube at all, the notepad is simply incremented by the sum of the 1 face (9) repeatedly until it has the right value for each character, then prints it.
[Answer]
# C++11, [Score](https://tio.run/##lVdpe9NGEP6uXzE4AcuRz4QEsC2XFAKlDYEG0isxqSytrW0kraojB8H963Rmda0Sh0PPg7zZud95d1bMrNj9/HntXm/Gg94M/9C0te94tDW4EmkEYSQWkeXDQrAYeACJy2DOozgBK1qkPguSLpDyNz@knLiRSBeuSBPpL7YjHiZt2mYMQpEGDsR8EcRSmQcOt62EodhKKCnwUwzvC4fPryAWPktcHixkGt9ToJaIxPLMvobOYQKRFThdW1vYdr6EjpAriRu8eHMIu/v7sL978PJo9@Xeu6HcBuDzDChb@CH3WNTjQcKiMGL4hoAxJwYLbBYlFqI3Rw1glwkLYi6CNliOAxxBENAkoJswY5646Goas10BjfVBAzMjSdcOwyqRZ29ev321v/f8djbkEDPxMe@Y3KKtk9osS5FdMjtNrBnm4LKIYZiFYUAnThzTNozBoIxEpdNa0@YigjiJqPPrerdHeLQ0R2hFN1F2GvOPzFy/XsP1shTIAjoBg/VCBZonSbMuJxkWiO9ucplU9b06eL93@PZw7/2qEiMWehaW1FSAzoGDC564Wa2KsJv3CC0Dy2dOjnUbbNcKFowakFknQnS/AeNVCYDSPiULBXFKYMECFiGVHWBW5HFMTSsBwcNgEsTkCMYFJq2aQgk1rldBXajUoY5YjJ4zRsW25TFzc6To9qoWNeATzOzWjSahfbmTnZnb3uQ@GFK58OKIgBVM3j3Hwhd01EXEhg24y0MPBv1@7gCnFw9sL3UYjJGjXHTdiVbb8visvpdwn9GOdi64Q3CfEmOFr2OrI9iIseciwOGBnQOPBS241jIWWwm3c5l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q0k6xamSBMyzLaxyj54IFtkrTv2s5ZlgxYGvNVyO0ExVDh20Nsz6ZB@pcnXgcXrRdzD91i@DXKCaFjdW605/zZOgtFjib76sD9nTLz8nwUlQfAmb0CATqqkHesFExLDbqsJRkMMj2Oo@eTzYGmjVRWq7o/I7zMb/aJTnKL/p1fltu7VTgxZO9q2C47ND1upFJ2EguXLJ1Gt8utOoRBQbW@LIhmGyWS62W11LvQ1NqWCjp/0P): 6.37
```
#include <iostream>
#include <vector>
#include <array>
#include <limits>
#include <algorithm>
const int inf = std::numeric_limits<int>::max(),
maxDiff = 128, nFace = 6;
std::array<int, maxDiff+1> plusvalue, totalvalue, plustrace, totaltrace;
std::array<int, nFace> input;
void prtrace(int value) {
    while (value) {
        std::cout << plustrace[value];
        value -= input[plustrace[value]];
    }
}
void prexpr(int i) {
    char xorwt = 0;
    if (i < 0) {
        xorwt = '+' ^ '-';
        i = -i;
    }
    if (totalvalue[i] != 0 && totalvalue[i] != inf) {
        std::cout << (char)('+' xor xorwt);
        prtrace(totaltrace[i]);
        if (totaltrace[i] != i) {
            std::cout << (char)('-' xor xorwt);
            prtrace(totaltrace[i] - i);
        }
    }
}
int main() {
    std::cout << "RU";
    input = {6, 15, 27, 26, 19, 42};
    std::cin >> std::noskipws;
    std::fill(plusvalue.begin(), plusvalue.end(), inf);
    plusvalue[0] = 1; // '+'
    for (int i = 0; i < nFace; ++i) { // knapsack, each value repeated inf times
        int val = input[i];
        if (val == 0) continue;
        for (int p = 0; p <= maxDiff - val; ++p) {
            if (plusvalue[p] != inf && plusvalue[p + val] > plusvalue[p] + 1) {
                plusvalue[p + val] = plusvalue[p] + 1;
                plustrace[p + val] = i;
            }
        }
    }
    for (int p = 0; p <= maxDiff; ++p) totalvalue[p] = plusvalue[p], totaltrace[p] = p;
    totalvalue[0] = 0;
    for (int sub = 1; sub <= maxDiff; ++sub) {
        if (plusvalue[sub] == inf) continue;
        for (int p = 0; p <= maxDiff - sub; ++p) {
            if (plusvalue[p+sub] != inf && totalvalue[p] > plusvalue[p+sub] + plusvalue[sub]) { // include '+'s
                totalvalue[p] = plusvalue[p+sub] + plusvalue[sub];
                totaltrace[p] = p+sub;
            }
        }
    }
//    // Note: plustrace[x] = i<=nFace : plustrace[x-input[i]] + 1 = plustrace[x]
//    long long sum = 0;
//    for (int i = 0; i <= maxDiff; ++i) {
//        sum += totalvalue[i];
//        std::cout << i << '\t' << totalvalue[i] << '\t';
//        prexpr(i);
//        std::cout << '\n';
//    }
//
//    std::cout << "_______________________________\n\nAverage = " << sum / (maxDiff + 1.) << '\n';
// RU 3.98131
    char ch;
    int cur = 0;
    while (std::cin >> ch) {
        int diff = ch - cur;
        prexpr(diff);
        std::cout << "@6";
        cur += diff; // cur = ch
    }
}
/*
RU 3.98131
*/
```
Try it online! [(generate Cubically code from ASCII)](https://tio.run/##lVZZb9s4EH7Xr5hNu7Ec@U6bwxdatN3HfSi2T45bMDRtEZElQaJyoPBfrztD6iBjp90KsCRzjm848w1HPE27G873@1cy5lGxEjCVSa4ywbZzr1m7F1wlmb3Csow92QuR3EqVOyrRJsmkCtGTx5M4VyBj@q1hBrlajcdxsRWZ5N@M6RSl8/F4yx79dsfDx0e5JtXh6KoD8T@MC/xzMfG0qYYniw6UmsFwDmlU5PcsKkQHVKJYVL7TssrQQbms3w8daYw5BpgWauJ594lcQZppZZ8i197a8N0DvB5CGQnwnTW6tFOeFAqm0wZ4ofWWk1pN/4fuzKAtniuWmjtvV8chHtNMhyErOB6yDB6T7EFhYgbGQq7BlzCFgR1TpdMKWvAVWt1WE4fE5a6s0CoPTfIWcgl/oXc4PYWDVSzli1v3Kbq2T5AIb0JoN7hVXpt6oE9LXkdRyTSejfYiYvc44ouo0EXHjd6uyTxle8tk7Fe4Dt7J5y8nZdKphpjI7xcdGL7twOgSf/R@3YE3o93EspUxzOcl@5P8TqYPOVKtlq9lFPk1i3u3YkPonYbYPRGvaIFSb/zWosVgSd0ygX6fKq2Fa0yEIY2mCBA1NM0nEASUTlK@i1maM37XAcF4WFIzE6lgSqx0vyq5FXlTG9MLUJFXLt26admMKIhdr2RciEZeB5SagFKYzqoOxkKgKUWWPi80uW02mlbsI1ZayxCQgyXMwdENYPjcn5u42nB2YDg5amaoY5lJV293wKbf7b3ctdVi6fNw7MOrlBpUy0hToDwKari8uDXEoBcXElfs1LhpRuGSCqnb/I9Lidb/p5SBRmnK6WbAqaRRDcCNsCRxNXWQ@flBzX6R1uNOJ8dd2Lknw99V3cPA8ML7v4kSY4s7j5o105mZa46kW3WVJmAZbWVVeoySeGNuebE1JTeCIw3vFFwfoUZVHzpoHczck31iy@0DT9KtdaNa9HSHQSmwTauJ1X7RX@smri12@Cxf3UP226@vm/gmfn8vMrahr4MTMqE99cGvmIg57LUbOAL5/AXOe9dXw/Oh1wxSHlaHuQJeZE0flZPePr956HQNWqzMtwoen12ytgedTgPJrSHj7vHdxUkjImwsyUoXDIM1sfCwGUv9M8/awVnf2@//CwWgNxpDyRo@FLeSsyh6QvRkk7Et5GFSRCu4FUAqochED97HT3rnjCuR4SYgYzFmcTEa9HqXn5Ygc2CcixSHQA/evXr999fTM789HJ2/eXtxeXU98H7wdcQ2@b6Lu5nxIBgOfwI) and [(run Cubically code)](https://tio.run/##jVK7DsIwDPwgq5IdO537DUh8AHRC6srA15f4nBewsDjq5c6@c7o/74/9dhyv87xcKedtJV14Wxch9iMnR9SrfybSUo0EPBlQKJ3nSueYskPi3cgM3QyyUmMEUwClm3MAZhXoko8UBrl6SYO@KMNDdFWMKkq/qN6sOhbq0tK7gCm5iIqvkQ/DfvNYy8PdnkU4AVXjJuFau7cWQactaXjn2Xyka6D0GUWIj9mVqkbLSV/ZiBa7bHGAy4DjiNTxwozlxQqsDzNuAfBm4wkmt9VotVzX5eq2DkXTeNu0aK8Z1mWSf3K@@X/U/q9t63m@AQ)
Explanation:
* First the program prints "RU", which make the face sum from `{0,9,18,27,36,45}` to `{6, 15, 27, 26, 19, 42}`. What makes that face sum set useful is that the gcd is 1, so by Bézout's identity there exist a way to construct any number `d` from a sum (or difference) of those numbers.
* Therefore, if the next char is `ch` and the current notepad value is `n`, then let `d = ch - n`, we can execute Cubically commands in the form `+{digits from 0 to 5}-{digits from 0 to 5}` such that the notepad value becomes `ch`. Then just execute `%6` to print notepad value.
* To find the most efficient way to express `d` as a sum/difference of numbers in the face sum set, I use Knapsack algorithm for all numbers from 0 to 128. E.g., for `d=1`, the program gets `27 - 26 = 1`, so it prints `+2-3`, which is `27 - 26 = 1`. Which can be seen when run the program with input `abc`, the program output 
> 
> RU+4333@6**+2-3**@6**+2-3**@6
> 
> 
>
[Answer]
# C++, score: ~~4.026~~ 3.998
improvement: added M, E and S rotations; now eats even more RAM  
Fortunately, there is no memory limit here! This program can use over 10 GB of RAM, if you are unlucky enough.
Uses a heavily modified A\*-like algorithm that doesn't find even nearly optimal solutions.
It takes at least 2 bytes to cause any change to the notepad, and another byte to print it, so getting a score below 3 is almost certainly impossible.
Uses a shamelessly stolen large part of the <https://codegolf.stackexchange.com/a/104881> answer to "Simulate a Rubik's cube" (by user "cmaster - reinstate monica") (for some reason I remember golfing that answer, but I can't find any related comments).
```
//#define _GLIBCXX_DEBUG
#include <x86intrin.h>
#include <cstring>
#include <iostream>
#include <streambuf>
#include <bitset>
#include <cstdio>
#include <atomic>
#include <vector>
#include <algorithm>
#include <cmath>
#include <climits>
#include <random>
#include <set>
#include <list>
#include <map>
#include <unordered_map>
#include <deque>
#include <stack>
#include <queue>
#include <string>
#include <iomanip>
#include <unordered_set>
#include <thread>
#define faceMove(offset) {offset,offset+1,offset+2,offset+15,offset+28,offset+27,offset+26,offset+13}
int faceMoves[9][8] = {
    faceMove(3),    //Up
    faceMove(39),   //Left
    faceMove(42),   //Front
    faceMove(45),   //Right
    faceMove(48),   //Back
    faceMove(81),    //Down
    {0,0,0,0, 0,0,0,0}, //M
    {0,0,0,0, 0,0,0,0}, //E
    {0,0,0,0, 0,0,0,0}, //S (these 3 move the centers in Cubically)
}, lineMoves[9][12] = {
    {50,49,48,47,46,45,44,43,42,41,40,39},    //Up
    {3,16,29,42,55,68,81,94,107,76,63,50},    //Left
    {29,30,31,45,58,71,83,82,81,67,54,41},    //Front
    {109,96,83,70,57,44,31,18,5,48,61,74},    //Right
    {39,52,65,107,108,109,73,60,47,5,4,3},    //Back
    {65,66,67,68,69,70,71,72,73,74,75,76}, //Down
    {0*13 + 4, 1*13 + 4, 2*13 + 4, 3*13 + 4, 4*13 + 4, 5*13 + 4, 6*13 + 4, 7*13 + 4, 8*13 + 4, 5*13 + 10, 4*13 + 10, 3*13 + 10}, //M
    {4*13 + 0, 4*13 + 1, 4*13 + 2, 4*13 + 3, 4*13 + 4, 4*13 + 5, 4*13 + 6, 4*13 + 7, 4*13 + 8, 4*13 + 9, 4*13 + 10, 4*13 + 11}, //E
    {1*13 + 3, 1*13 + 4, 1*13 + 5, 3*13 + 7, 4*13 + 7, 5*13 + 7, 7*13 + 5, 7*13 + 4, 7*13 + 3, 5*13 + 1, 4*13 + 1, 3*13 + 1} //S
};
#undef faceMove
void cubeRotate(std::string& cube, int* move, int rotation)
{
    int sign = rotation < 0 ? -1 : 1;
    for(int* submove = move; submove != move + rotation; submove += sign)
    {
        char takeout = cube[submove[3*rotation]];
        for(int j = 3; j --> 0;) cube[submove[j * rotation + rotation]] = cube[submove[j*rotation]];
        cube[*submove] = takeout;
    }
}
std::string cubeMove(std::string cube, int move, int inverted)
{
    cubeRotate(cube, faceMoves[move + inverted] - inverted, inverted ? -2 : 2);
    cubeRotate(cube, lineMoves[move + inverted] - inverted, inverted ? -3 : 3);
    return cube;
}
std::string cubeStart = 1+R"(
   000      
   000      
   000      
111222333444
111222333444
111222333444
   555      
   555      
   555      )";
std::array<char, 6> faceVals(const std::string& s)
{
    std::array<char, 6> fvs {};
    int xs[6] { 3, 0, 3, 6, 9, 3};
    int ys[6] { 0, 3, 3, 3, 3, 6};
    for(int i = 0; i < 6; i++)
    {
        char ts = 0;
        for(int y = ys[i]; y < ys[i] + 3; y++)
        for(int x = xs[i]; x < xs[i] + 3; x++)
            ts += s[y * 13 + x] - '0';
        fvs[i] = ts;
    }
    return fvs;
}
std::string target;
struct sstate
{
    int i;
    std::string cube;
    int notepad;
    char prevCmd;
    int movesSincePrint = 0;
    bool operator < (const sstate& rhs) const
    {
        return std::tie(i, notepad, cube, prevCmd) < std::tie(rhs.i, rhs.notepad, rhs.cube, rhs.prevCmd);
    }
    int heur() const
    {
        return 3 * (target.size() - i);
    }
};
std::vector<std::pair<sstate, char>> neighbours(sstate of)
{
    std::array<char, 6> fvs = faceVals(of.cube);
    std::vector<std::pair<sstate, char>> ans;
    if(target[of.i] == of.notepad) return {{{of.i+1, of.cube, of.notepad, '@', 0}, '@'}};
    for(char c : "+-*/X&|:_")
        ans.push_back({{of.i, of.cube, of.notepad, c}, c});
    if(of.prevCmd == '+' && of.notepad < 512)
        for(int i = 0; i < 6; i++)
        {
            if(of.notepad + fvs[i] > 512) continue;
            auto next = of; next.notepad += fvs[i]; ans.push_back({next, i+'0'});
        }
    if(of.prevCmd == '-' && of.notepad < 512)
        for(int i = 0; i < 6; i++)
        {
            if(of.notepad - fvs[i] > 512) continue;
            auto next = of; next.notepad -= fvs[i]; ans.push_back({next, i+'0'});
        }
    if(of.prevCmd == '*' && of.notepad < 512)
        for(int i = 0; i < 6; i++)
        {
            if(fvs[i] * of.notepad > 65536) continue;
            auto next = of; next.notepad *= fvs[i]; ans.push_back({next, i+'0'});
        }
    if(of.prevCmd == '/')
        for(int i = 0; i < 6; i++)
        {
            if(fvs[i] == 0) continue;
            auto next = of; next.notepad /= fvs[i]; ans.push_back({next, i+'0'});
        }
    if(of.prevCmd == 'X' && of.notepad < 512)
        for(int i = 0; i < 6; i++)
        {
            if((of.notepad ^ fvs[i]) > 512) continue;
            auto next = of; next.notepad ^= fvs[i]; ans.push_back({next, i+'0'});
        }
    if(of.prevCmd == '&')
        for(int i = 0; i < 6; i++)
        {
            auto next = of; next.notepad &= fvs[i]; ans.push_back({next, i+'0'});
        }
    if(of.prevCmd == '|' && of.notepad < 512)
        for(int i = 0; i < 6; i++)
        {
            if((of.notepad | fvs[i]) > 512) continue;
            if(fvs[i] == 0) continue;
            auto next = of; next.notepad |= fvs[i]; ans.push_back({next, i+'0'});
        }
    if(of.prevCmd == '_')
        for(int i = 0; i < 6; i++)
        {
            if(fvs[i] == 0) continue;
            auto next = of; next.notepad %= fvs[i]; ans.push_back({next, i+'0'});
        }
    if(of.prevCmd == ':')
        for(int i = 0; i < 6; i++)
        {
            auto next = of; next.notepad = fvs[i]; ans.push_back({next, i+'0'});
        }
    if(of.cube != cubeStart) { auto next = of; next.prevCmd = '~'; next.cube = cubeStart; ans.push_back({next, '#'}); }
    std::string moves = "ULFRBDMES";
    for(int i = 0; i < 9; i++)
    if(of.prevCmd == moves[i])
    {
        auto next = of;
        next.cube = cubeMove(next.cube, i, false);
        next.cube = cubeMove(next.cube, i, false);
        next.prevCmd = '~';
        ans.push_back({next, '\''});
    }
    if(of.movesSincePrint < 1 || (of.movesSincePrint == 1 && 'A' <= of.prevCmd && of.prevCmd <= 'Z'))
    for(int i = 0; i < 9; i++)
    {
        auto next = of;
        next.cube = cubeMove(next.cube, i, false);
        next.prevCmd = moves[i];
        next.movesSincePrint++;
        ans.push_back({next, moves[i]});
    }
    return ans;
}
struct astate
{
    sstate ss;
    int f;
    bool operator < (const astate& rhs) const
    {
        if(f != rhs.f) return f < rhs.f;
        if(ss.heur() != rhs.ss.heur()) return ss.heur() < rhs.ss.heur();
        return ss < rhs.ss;
    }
};
std::string metagolf(std::string target)
{
    ::target = target;
    std::map<sstate, std::pair<sstate, std::string>> prev;
    astate start = {{0, cubeStart, 0, '~'}, 0};
    std::map<sstate, int> dists; dists[start.ss] = 0;
    std::set<astate> openset; openset.insert(start);
    int nodes = 0;
    std::vector<int> ics(target.size() + 3);
    sstate best; int bestdist = INT_MAX; bool done = false;
    std::vector<std::set<std::string>> cubes(target.size() + 1);
    int itsleft = 10000;
    int curI = 0;
    int lastChange = 0;
    while(!openset.empty() && (!done || itsleft --> 0))
    {
        auto it = openset.begin();
        auto[cs, cf] = *it; openset.erase(it);
        int cd = dists[cs];
        if(cs.i == target.size()) { if(cd < bestdist) bestdist = cd, best = cs; done = true; continue; }
        if(cs.i < curI) continue;
        if(cs.i > curI) cubes[cs.i].insert(cs.cube);
        if((cubes[cs.i].size() > 1000 && cs.i > curI) || (cubes[cs.i].size() > 0 && cs.i > curI && nodes - lastChange > 5e4)) curI = cs.i, lastChange = nodes;
        if(nodes % 128 == 0) printf("n=%d, cf=%d, i=%d, notepad=%d, tc=%d\r", nodes, cf, cs.i, cs.notepad, target[cs.i]);
        nodes++;
        for(auto[next, cmd] : neighbours(cs))
        {
            if(dists.count(next) && dists[next] <= cd + 1) continue;
            dists[next] = cd + 1;
            prev[next] = {cs, std::string(1, cmd)};
            openset.insert((astate){next, cd + 1 + next.heur()});
        }
    }
    std::string ans = "";
    while(prev.count(best))
    {
        auto[pr, cmd] = prev[best];
        best = pr;
        ans += cmd;
    }
    std::reverse(ans.begin(), ans.end());
    return ans;
}
std::string gen_random(int len)
{
    static const char alphanum[] = "0123456789"
            "~!@#$%^&*()_+`-=[]\\;',./{}|:\"<>?" //this is obviously not alphanumeric
            "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
            "abcdefghijklmnopqrstuvwxyz";
    std::string s;
    while(len --> 0) s += alphanum[rand() % (sizeof(alphanum) - 1)];
    return s;
}
int main()
{
    //auto cube = cubeStart;
    //for(int i = 0; i < 9; i++) cube = cubeMove(cube, i, 0);
    //for(int i = 0; i < 9; i++) cube = cubeMove(cube, i, 1);
    //printf("%s\n", cube.data());
    double ans = 0;
    for(int i = 0; i < 100; i++)
    {
        std::string s = gen_random(rand() % 35 + 5);
        std::string code = metagolf(s);
        printf("%s: %s\n", s.data(), code.data());
        ans += code.size() * 1.0 / s.size();
    }
    printf("%lf\n", ans * 1.0 / 100);
    //std::string ts = "Hello, World!";
    //int n = ts.size();
    //printf("%s\n", metagolf(ts).data());
}
```
To avoid Unicode handling, this program performs certain character substitutions: `X` corresponds to `⊕`, `&` to `·`, and `#` to `▦`.
I used this to create an answer to "Hello, World!": <https://codegolf.stackexchange.com/a/206322>
]