[Question]
  [
Write a cat program, a quine, and a Hello World in the same language such that when two specific programs of the three are concatenated in a certain order, you get the third program. It does not matter which program is the first, second, and third are as long as all three types are represented once each.
e.g. if \$A\$ is a cat and \$B\$ is a quine then \$AB\$ is Hello World. Alternatively, if \$A\$ is Hello World and \$B\$ is a cat then \$AB\$ is a quine. You only need to make *one permutation* of the possible 6 work.
For completeness of explanation:
* A cat program outputs the input exactly
* A quine is a program that outputs its own source code
* A hello world program outputs the string "Hello World!"
## Rules, Scoring, Formatting
* Shortest code wins. Scoring goes by the length of the concatenated program, i.e. the longest of the three.
* Standard rules and loopholes apply.
* The hello world program and quine might possibly receive input. You must output the appropriate text regardless of what is given as input.
* Programs may output a trailing newline.
* You can treat all three programs as if they are surrounded by your language's function closure (please specify the name of your implicit argument in this case) or `main` function boilerplate if that is required for your solution to work. Use the same convention for all three programs. The quine should not contain the boilerplate in this case.
Format the header of your answer like this:
> 
> <first type> + <second type> = <third type>, <language>, <score>
> 
> 
> 
or
> 
> <language>, <first type> + <second type> = <third type>, <score>
> 
> 
> 
  
[Answer]
# [Python 3](https://docs.python.org/3.8/), Hello World + Quine = Cat, 129 bytes
### [Hello World](https://tio.run/##HczBCsIwDADQe74i7pTAGAMvInj3DzyOwqIGahvSDPTrq@7@ePaJZy3Hk3nv@rLqgbWNKeStgalhAruYawlIk8tDW4iTjcNVcq54q57Xw8Cwyh13RgufAY202BbEDL9uWv4bzdz7Fw "Python 3.8 (pre-release) – Try It Online"):
```
import os,atexit as a
p=print
a.register(p,"Hello World!")
def print(_):
 p(input())
 os._exit(0)
```
### [Quine:](https://tio.run/##K6gsycjPM7YoKPr/v9hWvdhWtci6oCgzr0SjWFW1WFMdzinW/P8fAA "Python 3.8 (pre-release) – Try It Online")
```
s='s=%r;print(s%%s)';print(s%s)
```
### [Cat](https://tio.run/##PcxNCsIwEEDh/ZxiLIRmoBTBjSjZewOXJdCogdgMM1PQ08c/cPng4/HTbnXZ7Vlay3euYlh1iJYe2TAqRuDAkheDOEq6ZrUknofulEqpeK5S5k1HMKcLfpmf6ADIPi@8mieC926cPje/JdDQa3By/FF1Tqn/h1JrltRe "Python 3.8 (pre-release) – Try It Online"):
```
import os,atexit as a
p=print
a.register(p,"Hello World!")
def print(_):
 p(input())
 os._exit(0)
s='s=%r;print(s%%s)';print(s%s)
```
`atexit` lets you define cleanup steps that will run when your program exits "normally". In this case, I register the `print` function (renamed `p`) with the argument `"Hello World!"`, so it will print that string when the program ends.
I then redefine `print` to become a `cat` function. Normally, this would cause the program to print its input *and* "Hello World!", but `os._exit()` is an "abnormal" exit that bypasses the cleanup steps.
Now that `print` has been redefined, the Quine simply calls this `cat` function and the program abruptly exits. If the Quine doesn't exist, then the program exits normally, printing "Hello World!" in the process.
The final program doesn't work on TIO, but it works for me running Python 3.7.3 on MacOS.
[Answer]
# Bash, Quine + Cat = Hello World, 110 bytes
## [Quine](https://tio.run/##S0oszvj/v9BWPbUsMUehoCgzryRNQUmlWAlMqFsX26oX2saYmGOVBooDFQBJ1WIQU6VQHYj//wcA)
```
q='eval printf "$s" "$s"';s='q=\47eval printf "$s" "$s"\47;s=\47%s\47;$q';$q
```
## [Cat](https://tio.run/##S0oszvj/v6SoNFUhLTGnOFVNLTmxpKYmNTkjX8EjNScnXyE8vygnRfH//4zE4pQ0CE6DMQE)
```
true false&&cat||echo Hello World!
```
## [Hello World](https://tio.run/##S0oszvj/v9BWPbUsMUehoCgzryRNQUmlWAlMqFsX26oX2saYmGOVBooDFQBJ1WIQU6VQHYhLikpTFdISc4pT1dSSE0tqalKTM/IVPFJzcvIVwvOLclIU///PSCxOSYPgNBgTAA)
```
q='eval printf "$s" "$s"';s='q=\47eval printf "$s" "$s"\47;s=\47%s\47;$q';$qtrue false&&cat||echo Hello World!
```
This takes advantage of the fact that undefined variables expand to the empty string and that `true` is a command that can take arguments.
You can trivially swap the cat and the hello world by swapping `true` and `false`
[Answer]
# [R](https://www.r-project.org/), Quine + hello, world = cat; ~~48 + 49~~ ... 43 + 44 = 87 bytes
Or **[75 bytes](https://tio.run/##lY9BC4IwGIbv@xVrFzeY0V0UQogOXqQdAzVbMRhbuFlK2F9fUy8JQXT8no/3eb@vcULdhREnyfGhN2vDrdR15ae6svyqmx7GEGVpsc0yROG8G1GKCAEgrWx8aVVthVa4I08XhAmLfBSbvNWWY0YoIwH8Rl@7MOmjUlxKzJINRXsupYYP3cjzCtGOuAHkrVB8UQD@KAADmJzF5FxqfpX77PgcRkLdWovIfAomYCxBR@XJh9tz9wY)** as internal code of functions and not including `function(){}` wrappers.
*Edit: -14 bytes thanks to Robin Ryder!*
Nontrivial quine:
```
'->T;cat(sQuote(T),T)' ->T;cat(sQuote(T),T)
```
[Try it online!](https://tio.run/##K/qfmVeWWZyZlJOqEVxZrFecWpKTn5wI5CUnlqSm5xdVKtgqKPk4xzv6@CjpKEDkQELOSpqa/9V17UKsgQo1igNL80tSNUI0dUI01RWwif7n@g8A "R – Try It Online")
Hello,world:
```
~F->y;cat(`if`(T>0,"Hello world!",scan(,T)))
```
[Try it online!](https://tio.run/##K/qfmVeWWZyZlJOqEVxZrFecWpKTn5wI5CUnlqSm5xdVKtgqKPk4xzv6@CjpKEDkQELOSpqa/@vcdO0qrYEqNRIy0xI0QuwMdJQ8UnNy8hXK84tyUhSVdIqTE/M0dEI0gYq5/gMA "R – Try It Online")
Cat:
```
'->T;cat(sQuote(T),T)' ->T;cat(sQuote(T),T)~F->y;cat(`if`(T>0,"Hello world!",scan(,T)))
```
[Try it online!](https://tio.run/##K/qfmVeWWZyZlJOqEVxZrFecWpKTn5wI5CUnlqSm5xdVKtgqKPk4xzv6@CjpKEDkQELOSpqa/9V17UKsgQo1igNL80tSNUI0dUI01RWwida56dpVgkUTMtMSNELsDHSUPFJzcvIVyvOLclIUlXSKkxPzNIAqgeZm5hWUlnD9BwA "R – Try It Online")
A 'trivial quine' version could be Quine = `~1`, and Hello, world = `+F->y;cat(`if`(y<0,scan(,''),'Hello world!'))`, for **2+45=47 bytes**.
**How? (nontrivial & trivial versions)**
The default behaviour of [R](https://www.r-project.org/) is to output any unassigned values (such as variables or expressions). So, to print a quine, we simply need to generate an expression containing the program code, and it is output by default (this applies both to the nontrivial quine, which is contructed using `cat` to join the various text elements together, as well as the trivial quine `~1` consisting simply of a formula which is outputted)
If a value is assigned to a variable, it is not output. So to stop the quines from printing, we incorporate them into an expression and assign this to the variable `y`.
To do this, we need to use a binary operator, but since this operator will also appear at the start of the 'Hello, world' program, it must also function as a unary operator. Both the `~` (formula) and `+` (positive/sum) operators have this property.
Conveniently, [R](https://www.r-project.org/) also includes a (little used outside coding challenges) left-to-right assignment operator, `->`, which - together with a unary/binary operator - lets us package the quine into the variable `y` & forget about it. Then all we need to do is to determine whether this has happened or not, and use this to switch between 'Hello, world' and 'cat' behaviour.
[Answer]
# Quine + Cat = Hello World, [Jelly](https://github.com/DennisMitchell/jelly), 25 bytes
*-2 bytes thanks to @Jonathan Allan*
### Quine (12 bytes)
```
“Ṿṭ⁷;⁾v`”v`
```
(starts with a newline)
[Try it online!](https://tio.run/##y0rNyan8/5/rUcOchzv3Pdy59lHjdutHjfvKEh41zC1L@P//v5KSkqGRsYlOYlIykAkA)
### Cat (13 bytes)
```
Ṇ
“,ḷṅḳȦ»³ÑƑ?
```
[Try it online!](https://tio.run/##ATIAzf9qZWxsef//4bmGCuKAnCzhuLfhuYXhuLPIpsK7wrPDkcaRP////yIxMjM0LCdhYmMnIg) (argument quoted to avoid casting to a Python object from string as per @Jonathan Allan's suggestion)
### Hello World (25 bytes)
```
“Ṿṭ⁷;⁾v`”v`Ṇ
“,ḷṅḳȦ»³ÑƑ?
```
(starts with a newline)
[Try it online!](https://tio.run/##AUoAtf9qZWxsef//CuKAnOG5vuG5reKBtzvigb52YOKAnXZg4bmGCuKAnCzhuLfhuYXhuLPIpsK7wrPDkcaRP////yIxMjM0LCdhYmMnIg)
## How it Works
In Jelly, the last link (last line) is always executed as the main link. The Cat and Hello World have the same last link, so they are differentiated by the value of the first link (blank (identity) or `Ṇ` (logical not)).
```
“,ḷṅḳȦ»³ÑƑ?
          ?  # If
        ÑƑ   # The first link is the identity
“,ḷṅḳȦ»        # Return "Hello World!" (String Compressor: https://codegolf.stackexchange.com/a/151721/68261)
             # Else
       ³       # Return the input
```
The quine is slightly difficult because it needs to prepend a blank line.
```
“Ṿṭ⁷;⁾v`”v` 
“Ṿṭ⁷;⁾v`”     # Set the string "Ṿṭ⁷;⁾v`"
         v`   # Eval it on itself:
 Ṿṭ⁷;⁾v`
 Ṿ              # Uneval: "“Ṿṭ⁷;⁾v`”"
  ṭ⁷            # Prepend a newline "¶“Ṿṭ⁷;⁾v`”"
    ;⁾v`        # Concatenate "v`" to get "¶“Ṿṭ⁷;⁾v`”v`"
```
[Answer]
# [Wolfram Language (Mathematica)](https://www.wolfram.com/wolframscript/), Quine + Cat = Hello World, ~~15+28=43~~ 15 + 22 = 37 bytes
3 functions.
### Quine
```
ToString[#0] & 
```
[Try it online!](https://tio.run/##y00syUjNTSzJTE78n2b7PyQ/uKQoMy89WtkgVkFN4X8AkFPikOagVFiamZeq9B8A "Wolfram Language (Mathematica) – Try It Online")
### Cat
```
#/.#_:>"Hello World!"&
```
[Try it online!](https://tio.run/##y00syUjNTSzJTE78n2b7X1lfTzneyk7JIzUnJ18hPL8oJ0VRSe1/QFFmXolDmoNScmKJ0n8A "Wolfram Language (Mathematica) – Try It Online")
### Hello World
```
ToString[#0] & #/.#_:>"Hello World!"&
```
[Try it online!](https://tio.run/##y00syUjNTSzJTE78n2b7PyQ/uKQoMy89WtkgVkFNQVlfTzneyk7JIzUnJ18hPL8oJ0VRSe1/AFBJiUOag1IGWLwcJK70HwA "Wolfram Language (Mathematica) – Try It Online")
---
### ~~HW+Q=C,46+58=104 Q+C=HW,43+48=91~~ Cat + Quine = Hello World, 49 + 37 = 86 bytes
**Cat**
```
Print[#/._@_->"Hello World!"]&@$ScriptInputString
```
[Try it online!](https://tio.run/##y00syUjNTSzJTE78/z@gKDOvJFpZXy/eIV7XTskjNScnXyE8vygnRVEpVs1BJTi5KLOgxDOvoLQkuASoNv3//@TEEgA "Wolfram Language (Mathematica) – Try It Online")
**Quine**
```
Print[ToString[#0, InputForm][]] & []
```
[Try it online!](https://tio.run/##y00syUjNTSzJTE78/z@gKDOvJDokP7gEyEiPVjbQUfDMKygtccsvyo2Njo1VUFOIjv3/v7A0My8VAA "Wolfram Language (Mathematica) – Try It Online")
**Hello World**
```
Print[#/._@_->"Hello World!"]&@$ScriptInputStringPrint[ToString[#0, InputForm][]] & []
```
[Try it online!](https://tio.run/##y00syUjNTSzJTE78/z@gKDOvJFpZXy/eIV7XTskjNScnXyE8vygnRVEpVs1BJTi5KLOgxDOvoLQkuASoNh2iISQfwotWNtBRAMu65RflxkbHxiqoKUTH/v@fATaoHGQQAA "Wolfram Language (Mathematica) – Try It Online")
[Answer]
# [Rust](https://www.rust-lang.org/), Quine + Cat = Hello, world! (106 + 2 = 108 bytes)
### Quine (~~108~~ 106 bytes):
-2 bytes: removed ',' from "Hello world!"
```
let s=format!("Hello world!");format!("{},{0:?})","let s=format!(\"Hello world!\");format!(\"{},{0:?})\"")
```
`.into()` instead of `format!` saves a few bytes but is context-dependent.
### Cat (2 bytes):
```
;s
```
### Quine + Cat = Hello, world! (~~110~~ 108 bytes):
```
let s=format!("Hello world!");format!("{},{0:?})","let s=format!(\"Hello world!\");format!(\"{},{0:?})\"");s
```
[Try it!](https://tio.run/##xZHBTsMwDIbveQrPB0ikwDi3MG4VRySuvYQt3SKlyUhcTajrs5e0Qy1jHLjNp9@OP@uPHZpIfV85qJVxXEDLIAXpSHxUQ@BaEcopPcZjasvjVOhGJfK/0I/GOH0BW00QnyofakULji/aWg8HH@xmgSKf6m0n24fsuRMo8Rwpz5jyB1TOVIko/mVyN8@6otXLjbKOsXSawe1jseJO1TqDm9tIiswaIgUJVQaFYIedDnpkipQ7/kbBuK2AuxWcJDvddZ80WZf8vga/DarOoO1QwjD5ezVzy/hScTRu3xDep7LnQvxuEzksl5C@BEGrjXo31tBnMt73Xw)
Updated to not use `include_str!`. Hopefully this doesn't break any rules anymore.
This relies on it being in a closure/function that implements `Fn(String) -> String` with argument `s`.
---
Old answer, uses `include_str!`:
### Quine (67 bytes):
```
match include_str!("f"){p@_ if p.len()==67=>p,_=>"Hello, world!"}//
```
(Not very creative, unfortunately)
### Cat (1 byte):
```
s
```
### Quine + Cat = Hello, world! (68 bytes):
```
match include_str!("f"){p@_ if p.len()==67=>p,_=>"Hello, world!"}//s
```
~~Try it! (Repl.it link due to multiple files)~~
This depends on the code being in its own file named "f" and being `include!`'d into main.rs before being executed. The Repl.it link has the programs in separate files with different names, which means that the quine and hello world programs are different by one character so that they include the correct string.
~~This challenge was especially difficult in Rust (without using a comment at the end of one of the programs) because of the syntax of the language. Functions and multi-statement closures have braces surrounding them, so you can't just concat two closures to get a third, unfortunately.~~
[Answer]
# [Python 2](https://docs.python.org/2/), Hello World + Cat = Quine, 200 198 189 bytes
## Hello World
```
id=0;a="Hello World!";a0='id=0;a="%s";a0=%r;print a0%%((a,a0)if id<1else 1)\nimport sys\nif id:print sys.stdin.read()';print a
```
## Cat
```
0%((a,a0)if id<1else 1)
import sys
if id:print sys.stdin.read()
```
My previous answer was actually wrong. `raw_input` only reads one line. This reads the entire input.
## Quine
```
id=0;a="Hello World!";a0='id=0;a="%s";a0=%r;print a0%%((a,a0)if id<1else 1)\nimport sys\nif id:print sys.stdin.read()';print a0%((a,a0)if id<1else 1)
import sys
if id:print sys.stdin.read()
```
[Try it online!](https://tio.run/##fc7BCsIwDAbge58iDspakNF5dPbuG3jxEmjFQE1LW5E9/ayK7CLekvz8H0lzvUbeLQs5aya03dGHEOEUc3CbbkJj@28iy3uXeUqZuAIaKZXCLRpNFyB3GH0oHkZ9ZrqlmCuUubT5le0/lXYYSnXEQ/bolO5X6qckVkj8c9r7nO7NKfDIVKtnwSkyiyc "Python 2 – Try It Online")
---
*2020-08-05: -42 bytes thanks to Jonathan Allen, +33 to fix a bug*
[Answer]
# [Keg](https://github.com/JonoCode9374/Keg), Hello World + Quine = Cat, 26 bytes
```
«H%c¡|,!«``:[④|᠀,]`:[④|᠀,]
```
[Try it online!](https://tio.run/##y05N////0GoP1eRDC2t0FA@tTkiwin40cXHNwwUNOrHI7P//iwE "Keg – Try It Online")
## How it Works
### Hello World
```
«H%c¡|,!«`
```
[Try it online!](https://tio.run/##y05N////0GoP1eRDC2t0FA@tTvj/HwA "Keg – Try It Online")
This is my answer to the HW challenge with some additional string closing syntax. Why? Because a) the main string needs closing to be concatenated and b) the end ``` is needed to "ignore" the quine part
### Quine (non-trivial)
```
`:[④|᠀,]`:[④|᠀,]
```
[Try it online!](https://tio.run/##y05N//8/wSr60cTFNQ8XNOjEIrP//wcA "Keg – Try It Online")
```
`:[④|᠀,]`           
```
Push the string `:[④|᠀,]` to the stack
```
:[④|᠀,]
```
Duplicate the string and start an if-block. The if block uses the truthiness of the t.o.s to determine which branch is to be executed. In this case, the string is truthy, so the `④` is executed (printing the string raw). Implicit output then prints the string nicely.
### Concatenation
```
«H%c¡|,!«``
```
Push the string `Hello, World!` followed by an empty string onto the stack.
```
:[④|᠀,]
```
Duplicate the top of the stack (an empty string) and start the if block. Empty strings are considered falsey, so the `᠀,` branch is executed. This takes input and prints it.
```
`:[④|᠀,]
```
Push the string `:[④|᠀,]` and don't do anything with it.
[Answer]
# [Python 3.8](https://docs.python.org/3.8/), Cat + Quine = Hello, ~~101 91~~ 89 bytes
## Cat (32 bytes)
```
a=id=""
while 1:a=input(a)+"\n";
```
[Try it online!](https://tio.run/##DcexDkAwEADQ3VdcOhGTWIQY/IeloWi0d5dzTePry9sev3oR9gNLKXb2@2xMlS8fHHTjf@SktW1as6KZSlnkTNGhPnCQwGYVWOgUG6uYgvrg0T2QSW5QIhj5Aw "Python 3.8 (pre-release) – Try It Online")
## Quine (57 bytes)
```
exec(s:='+input(id and"exec(s:=%r)"%s or"Hello World!")')
```
[Try it online!](https://tio.run/##NcgxDsIwDADAnVeYSFUbdWRBlRjY@EHnqDElwrEjxxHw@nTixis/ewlfrkV7xy9uU11u45y4NJtShMDR/XtQ74YKou6BRAKrKMWz86Pv/a57y8hW4SkKWzAoKruGfMqNLFFirPARfYOJwFIO "Python 3.8 (pre-release) – Try It Online")
## Hello World (89 bytes)
```
a=id=""
while 1:a=input(a)+"\n";exec(s:='+input(id and"exec(s:=%r)"%s or"Hello World!")')
```
[Try it online!](https://tio.run/##NcixDsIgEADQvV9xXtK0pJNxMRiGbv6Biwsp2BKBIwek@vVoYhzfS@@yUTydE7emlTMKsds35y0c5dcx1TJqMeE94sW@7DJmqYbp986Ajgb/3bPAPgMxXq33BDdibw4oBtHazGsNNpYMD2JYdIHEtLIOXai@OO@izbATP6EQgUwf "Python 3.8 (pre-release) – Try It Online")
## How it works:
For the cat program:
* `a=id=0` we assign `a` and `id` to the empty string. `id` is now evaluated as `False` (remember it for later)
* At the first loop of `while 1`: `a=input(a)+"\n"` will display `a` without a new line (so the empty string) and store in `a` the first line of the input plus a newline
* Then we loop again, displaying the input of the previous iteration until the program has written all the lines of the input and crash (`EOFError`)
For the quine program:
* The main structure of the quine is `exec(s:='print("exec(s:=%r)"%s)')`, a well known quine in python.
* We uses `input()` instead of `print()` to avoid the trailing new line
* the `+` at the start is here to make the program crash as soon as it finished printing to make sure the program ends.
* `id` is a python built-in. Because of that it is evaluated as `True` so `id and <code 1> or <code2>` will be equal to `<code 1>` (which contains the code for our quine to work).
For the hello world program:
* remember the cat program where we assigned `id` to the empty string?
* `id and <code 1> or <code2>` will now execute `<code2>` since `id` is now evaluated as `False`, resulting the printing of `Hello World!`
* The `+` crashes the program avoiding looping in the cat code again
## Old solution: cat (37) + quine (64) = hello (101 bytes)
Here is my old solution using triple quoted string and comments to "squeeze" the quine part and directly printing `"Hello World!"`. It uses some cool tricks with comments:
```
while p:=print:id or p(input());id=""									# cat (37 bytes)
                                     "";exec(s:='input(\'"";exec(s:=%r)\'%s)#"""-p("Hello World!")#')	# quine (64 bytes)
while p:=print:id or p(input());id="""";exec(s:='input(\'"";exec(s:=%r)\'%s)#"""-p("Hello World!")#')	# hello (101 bytes)
```
[Try it online!](https://tio.run/##TYwxDsIwDEV3TmFaVUkGJhYU1IGNG7B0qdrQWqSx5bgqnD5UYuGP7z19/uhM6XxhKWWbMQZg37JgUo8jkABbTLyqde6KY1vtu4Z3GGz2rfmZzvyxRlxnmuzqPTyxre4hRoIHSRyPlauNK@Um07qEpBme@//QK7DQJP1yWNaoGDGFDBvJC5QIPH8B "Python 3.8 (pre-release) – Try It Online")
Who said that comments were not usefull in codegolfing?
[Answer]
# [R](https://www.r-project.org/), Quine (~~74~~ 51 bytes) + Cat (~~77~~ 74 bytes) = [Hello world](https://tio.run/##dY2xCsIwFEV3vyJmaR68ip1LC1IoDlnE7LbGVAIhkSQqXfz1GK2r4z3nwPVJ24cO@mwUO85hE1Q0To55yTGqq/MzaQjl3WnHOUWyuA/qKEAqyravRbOtc8zC4e6iYj1gDwX5Z15V2c5fOuhpYKKtMNy8tnFiAn@hAMDFYpCjZUgpIN0rYxx5Om8u63wOaZXe) ~~151~~ 125 bytes
# [R](https://www.r-project.org/), Hello world (~~173~~ 174 bytes) + Cat (~~77~~ 74 bytes) = [Quine](https://tio.run/##K/qfmVeWWZyZlJOqEVxZrFecWpKTn5wI5CUnlqSm5xdVKtgqKPk4xzv6@CjpKEDkQELOSpqa/@sMde0qrUNs1WEM1WJroD6NhMy0BA03GwOd4uTEPA0dJSVNHSWP1JycfIXy/KKcFEWgXogOuOIQO0Od4oKizLySNI0QneLA0vySVI0QTU0diCwegzTV6W/lf67/AA) ~~250~~ 248 bytes
# [R](https://www.r-project.org/), Quine (~~74~~ 51 bytes) + Hello world (~~173~~ 174 bytes) = [Cat](https://tio.run/##jZCxCsIwEIZ3nyIGJDlIpZ21BSkEhy5idltrKoHQlCRVuvjqNVp1U9zu7vvufjg7qvainDpqSfeDWzrptamr0NWVl2djB5QiXOSHTVFghib2GOUYYCRRxlcijVdBpm7XGy8pB8aBoG/klkTZEAh5Fwv3dErVlJSvY@bqqqUMY2B4K7U26GqsPs1D3LTxkUWWMNdZ1fqGCvbKEABsoj8OAfk3Mnyn6/1svAM) ~~247~~ 225 bytes
**A set of Quine, Cat & Hello world from which any 2 can be combined to form the third.**
Not the shortest answer, but pleasingly symmetric.
**Quine (~~74~~ 51 bytes)**
```
'->F;T=0;cat(sQuote(F),F)' ->F;T=0;cat(sQuote(F),F)
```
[Try it online!](https://tio.run/##K/qfmVeWWZyZlJOqEVxZrFecWpKTn5wI5CUnlqSm5xdVKtgqKPk4xzv6@CjpKEDkQELOSpqa/9V17dysQ2wNrIGKNYoDS/NLUjXcNHXcNNUVcMn8/w8A "R – Try It Online")
**Cat (~~77~~ 74 bytes)**
```
~1->y;cat(`if`(T>1,sprintf(T,sQuote(T)),`if`(T,scan(,""),"Hello world!")))
```
[Try it online!](https://tio.run/##JY7BCsIwEER/Jea0C6vQs1iQXjzkIuZuY0wlEJqSTZVc/PUY6XHmPYZJ1c9vz/4RHNwKH9jlEK1pyZrsXjEVcRJSDfezUpLExv7VIBHrt9v35dhMGP00gu474iX5OU@gia9rzA40Im2U2JoZSEokeXEhRPGJKTx3bQnbjWXN9Qc "R – Try It Online")
**Hello world (~~173~~ 174 bytes)**
```
~1->y;T='~1->y;T=%s;cat(`if`(F<0,scan(,""),"Hello world!"))~1->y;cat(`if`(T>1,sprintf(T,sQuote(T)),`if`(T,scan(,""),"Hello world!")))';cat(`if`(F<0,scan(,""),"Hello world!"))
```
[Try it online!](https://tio.run/##K/qfmVeWWZyZlJOqEVxZrFecWpKTn5wI5CUnlqSm5xdVKtgqKPk4xzv6@CjpKEDkQELOSpqa/@sMde0qrUNs1WEM1WJroD6NhMy0BA03GwOd4uTEPA0dJSVNHSWP1JycfIXy/KKcFEWgXogOuOIQO0Od4oKizLySNI0QneLA0vySVI0QTU0diCwegzTVibXy/38A "R – Try It Online")
[Answer]
# [Aceto](https://github.com/aceto/aceto), quine (67) + cat (33) = Hello World (100 bytes\*)
(\*I counted one file including a final newline so that catting them together works as expected)
### [quine](https://codegolf.stackexchange.com/a/209076/21173) (made it for this challenge):
```
£"24«cs%55«3+cp24«2+cdpsdpsppn"24«cs%55«3+cp24«2+cdpsdpsppn
```
### cat:
```
X
n
p el
r"HlX
^^ oldnp
 ^Wor!"
```
---
The quine itself was the hardest part, due to the nature of having code on a Hilbert curve (The "Hello World", and cat programs are trivial compared to it). The solution of having the concatenated program do something else than the parts is simple in Aceto: Because the (longer-line) quine enforces a square size of an even power of two (64 = 2^6), and the cat program has, on its own, a square of size 8x8 (8 = 2^3, an odd power of two), the instruction pointer starts moving in a different direction.
[Answer]
# [Alice](https://github.com/m-ender/alice), Cat + Quine = Hello World, 51 bytes
**Cat:** (With trailing newline)
```
\ >  "!dlroW olleH"d&O@
  ^/ v
  # < i
```
[Try it online.](https://tio.run/##S8zJTE79/z9GwU5BQUkxJacoP1whPycn1UMpRc3fgUtBIU5foQxIKSvYKGRy/f@flp@flFgEAA)
Uses # to skip the redirect west and instead hit the redirect south into the i, which pushes the input as a string to the top of the stack. The instruction pointer then reflects off the top and bottom boundaries of the grid, hitting the o and @ from the Hello World program, causing it to output the top of the stack as a string and then terminate. The code requires a trailing newline, which I couldn't get to display here in the code block.
**Quine:**
```
"!<@O&9h.
```
[Try it online.](https://tio.run/##S8zJTE79/19J0cbBX80yQ@///7T8/KTEIgA)
Just a standard Alice quine.
**Hello World:**
```
\ >  "!dlroW olleH"d&O@
  ^/ v
  # < i
"!<@O&9h.
```
[Try it online.](https://tio.run/##S8zJTE79/z9GwU4hQUkxJacoP1whPycn1UMpJUHN34FLQSFOX6EMSCkr2Chkcikp2jj4q1lm6P3/n5afn5RYBAA)
The # is now used to skip the @ from the quine program, causing the instruction pointer to instead hit the redirect west, which passes through a mirror and hits two more redirects to hit a standard Alice Hello World program.
[Answer]
# Hello World + Quine = Cat, C (GCC), 149 (81 + 68)
### Hello World
```
a;main(s){a?read(0,&s,1)&&main(putchar(s)):puts("Hello World!");}
#define main m
```
[Try it online!](https://tio.run/##S9ZNT07@/z/ROjcxM0@jWLM60b4oNTFFw0BHrVjHUFNNDSxeUFqSnJFYBJTXtAKyizWUPFJzcvIVwvOLclIUlTSta7mUU1LTMvNSFUDqFXL//w/JyCxWAKKSjFSFzDygJgA "C (gcc) – Try It Online")
### Quine
```
a=1;main(s){printf(s="a=1;main(s){printf(s=%c%s%1$c,34,s);}",34,s);}
```
[Try it online!](https://tio.run/##S9ZNT07@/z/R1tA6NzEzT6NYs7qgKDOvJE2j2FYJq6hqsmqxqqFKso6xiU6xpnWtEozx/z8A "C (gcc) – Try It Online")
### Cat (Hello World + Quine)
```
a;main(s){a?read(0,&s,1)&&main(putchar(s)):puts("Hello World!");}
#define main m
a=1;main(s){printf(s="a=1;main(s){printf(s=%c%s%1$c,34,s);}",34,s);}
```
[Try it online!](https://tio.run/##S9ZNT07@/z/ROjcxM0@jWLM60b4oNTFFw0BHrVjHUFNNDSxeUFqSnJFYBJTXtAKyizWUPFJzcvIVwvOLclIUlTSta7mUU1LTMvNSFUDqFXK5Em0N4UYWFGXmlaRpFNsqYRVVTVYtVjVUSdYxNtEpBhqlBGP8/x@SkVmsAEQlGakKmXlAmwE "C (gcc) – Try It Online")
[Answer]
# [><>](http://esolangs.org/wiki/Fish), Quine + Cat = Hello World!, 48 bytes
**[Quine](https://tio.run/##S8sszvj/X6nIwCA9P8de0drEQO//fwA)**
`"r00gol?!;40.`
The classic ><> quine
**[Cat](https://tio.run/##S8sszvj/Xym2TCnTykDD3jqfyy7HXhFIxSl5pObk5CuE5xflpCgq2fz/X5JaXAIA)**
```
"]v"i:0(?;o
>l?!;o
^"Hello World!"<
```
A simple cat program, loaded with some other code that isn't being run.
**[Hello World!](https://tio.run/##S8sszvj/X6nIwCA9P8de0drEQE8ptkwp08pAw946n8sOJJbPFafkkZqTk68Qnl@Uk6KoZPP/PwA)**
```
"r00gol?!;40."]v"i:0(?;o
>l?!;o
^"Hello World!"<
```
The quine part makes the instruction pointer stop interpreting "]v" as text, instead clearing the stack and moving down to the "Hello World!" printer.
---
Equivalently, the program can be written as
```
'rd3*ol?!;40.']v'i:0(?;o
>l?!;o
^"Hello World!"<
```
Which, as Jo King points out, avoids using the `g` code reflection instruction, arguably making the quine more genuine.
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E/wiki/Commands), Quine + Hello World = Cat, 23 [bytes](https://github.com/Adriandmen/05AB1E/wiki/Codepage)
**Quine:**
```
2096239D20BJ
```
[Try it online (with input)](https://tio.run/##yy9OTMpM/f/fyMDSzMjY0sXIwMnr//@S1OISAA) or [try it online (without input)](https://tio.run/##yy9OTMpM/f/fyMDSzMjY0sXIwMnr/38A).
**Hello World:**
```
I.gi”Ÿ™‚ï!
```
[Try it online (with input)](https://tio.run/##yy9OTMpM/f/fUy8981HD3KM7HrUsetQw6/B6xf//S1KLSwA) or [try it online (without input)](https://tio.run/##yy9OTMpM/f/fUy8981HD3KM7HrUsetQw6/B6xf//AQ).
**Cat:**
```
2096239D20BJI.gi”Ÿ™‚ï!
```
[Try it online (with input)](https://tio.run/##yy9OTMpM/f/fyMDSzMjY0sXIwMnLUy8981HD3KM7HrUsetQw6/B6xf//S1KLSwA) or [try it online (without input)](https://tio.run/##yy9OTMpM/f/fyMDSzMjY0sXIwMnLUy8981HD3KM7HrUsetQw6/B6xf//AQ).
(All three output with trailing newline.)
**Explanation:**
```
2096239       # Push integer 2096239
       D      # Duplicate it
        20B   # Convert it to base-20 as list: "D20BJ"
           J  # Join stack together: "2096239D20BJ"
              # (after which it is output implicitly as result)
I             # Push the input (or an empty string if none is given)
 .g           # Get the amount of items on the stack (which will be 1)
   i          # If this amount is 1 (which it always is):
    ”Ÿ™‚ï!    #  Push dictionary string "Hello World!"
              #  (after which it is output implicitly as result)
2096239D20BJ  # Same as above
I             # Push the input (or an empty string if none is given)
 .g           # Get the amount of items on the stack: 2
   i          # If this amount is 1 (which it isn't):
    ”Ÿ™‚ï!    #  Push dictionary string "Hello World!"
              # (implicit else:)
              #  (implicitly output the input we pushed earlier as result)
```
[See this 05AB1E tip of mine (section *How to use the dictionary?*)](https://codegolf.stackexchange.com/a/166851/52210) to understand why `”Ÿ™‚ï!` is `"Hello World!"`.  
Credit of the quine goes to [*@Grimmy*'s answer here](https://codegolf.stackexchange.com/a/186809/52210).
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), Quine + Cat = Hello World! 17 [bytes](https://github.com/DennisMitchell/jelly/wiki/Code-page)
Note that using a formatted input has been deemed valid and this entry takes input as a command-line argument formatted as a Python string. To have a pure-Cat program we'd need to use STDIN in Jelly, since it first attempts to evaluate any command-line argument as Python. This is achievable in 21 bytes with `”ṘṘ` + `”1$0¡ƈȮ¤L¿“,ḷṅḳȦ»Ṇ?` [TIO](https://tio.run/##AT4Awf9qZWxsef//4oCd4bmY4bmYMSQwwqHGiMiuwqRMwr/igJws4bi34bmF4bizyKbCu@G5hj///1NvbWUKdGV4dA).
```
”ṘṘ
```
**[Quine](https://tio.run/##y0rNyan8//9Rw9yHO2cA0f///5WC83NTFUpSK0qUAA "Jelly – Try It Online")**
```
1$0¡³“,ḷṅḳȦ»⁼?
```
**[Cat](https://tio.run/##ATEAzv9qZWxsef//MSQwwqHCs@KAnCzhuLfhuYXhuLPIpsK74oG8P////yJTb21lIHRleHQi "Jelly – Try It Online")**
```
”ṘṘ1$0¡³“,ḷṅḳȦ»⁼?0
```
**[Hello World!](https://tio.run/##AToAxf9qZWxsef//4oCd4bmY4bmYMSQwwqHCs@KAnCzhuLfhuYXhuLPIpsK74oG8P////yJTb21lIHRleHQi "Jelly – Try It Online")**
### How?
The shortest proper quine in Jelly is:
```
”ṘṘ - Main Link: any arguments
”Ṙ  - an 'Ṙ' character
  Ṙ - print Jelly representation of x (i.e. ”Ṙ) and yield x ('Ṙ')
    - implicit print (i.e. Ṙ)
```
To use it we need to not let the `Ṙ` execute in the largest program.
One way to not execute a link is to follow it with `0¡` - repeat zero times, but `¡` needs a link to repeat, like `X0¡`, so we make `X` equal `1$`.
`$` composes the preceding two links into a single monadic link and (slightly surprisingly) `1$` can start a full program, as a monad which yields \$1\$ but when repeated zero times it just yields whatever its left argument is.
As such starting a program which has one command-line argument with `1$0¡` applies `1$` zero times to that argument, i.e. is a no-op, giving the rest of the program that same left argument.
But when `1$0¡` is prefixed with `”ṘṘ` we have the `X` (described earlier) equal to `Ṙ1` which when applied zero times to `”Ṙ` yields the character `'Ṙ'`.
Since the character, `'Ṙ'`, is not equal to the right argument of the Main Link (which, when given a single command-line argument is that argument) since that is a *list* of characters, we can use equality, `⁼`, to test, `?`, (effectively) whether the prefix `”ṘṘ` is present and either...
...Cat\* (if not):
```
³ - yield the programs 1st command-line argument
```
...or Hello World!:
```
“,ḷṅḳȦ» - compressed string = "Hello World!"
```
---
\* The Cat code for the 21 byte STDIN version is:
```
ƈȮ¤L¿ - niladic link (no arguments)
    ¿ - do...
  ¤   - ...instruction: nilad followed by link(s) as a nilad
ƈ     -   read a character from STDIN
 Ȯ    -   print & yield
   L  - ...while?: length (0 at EOF)
```
and we use the monad logical-NOT, `Ṇ`, as our test since we get an implicit left argument of `0` with no command-line arguments and by this point `Ṇ` gets an argument of `0` (`0Ṇ` = \$1\$ -> Cat) or `'Ṙ'` (`”ṘṆ` = \$0\$ -> Hello World!).
[Answer]
# [Ruby](https://www.ruby-lang.org/), Cat + Quine = *Hello World!*, ~~100~~ ~~97~~ 96 bytes
Reading the source code is prohibited for quines but there is no such rule for *Hello World!* programs. We exploit this fact using Ruby's `DATA`/`__END__` mechanism. If `__END__` appears alone on any line in the code, execution terminates there. However, any further code is accessible via the constant `DATA`, which is initialised to a `File` object containing all of this non-executable 'data'.
### Cat
```
$><<(DATA||=$<).read;a
```
[Try it online!](https://tio.run/##KypNqvz/X8XOxkbDxTHEsabGVsVGU68oNTHFOvH//5CMVIXkxBKFYiDOz1MoAXJzE0sA "Ruby – Try It Online")
The idiomatic `||=` operator sets the value of the variable `DATA` only if it is not already defined. In this case, `DATA` is not defined because the program does not contain `__END__`. In effect, the first part of the code therefore reduces to `$><<$<.read`, where `$<` and `$>` point to STDIN and STDOUT, respectively. For later use, the final `a` (which is an undefined variable) throws an error, which is inconsequential here.
### Quine
```
eval$s=%q($><<"eval$s=%q(#$s)
__END__
Hello World!")
__END__
Hello World!
```
[Try it online!](https://tio.run/##KypNqvz/P7UsMUel2Fa1UEPFzsZGCcFVVinW5IqPd/VziY/n8kjNyclXCM8vyklRVMIu/P9/SEaqQnJiiUIxEOfnKZQAubmJJQA "Ruby – Try It Online") or [verify quine](https://tio.run/##S0oszvj/vzxZQTdZQS8zr6C0RK8kM9@aKzfFtLg0F0WoqDSpEklAoUYBoghDxvr//9SyxByVYlvVQg0VOxsbJQRXWaVYkys@3tXPJT6eyyM1JydfITy/KCdFUQm7MAA "Bash – Try It Online").
All of the real work is done in the first line, which is a basic Ruby quine template. With `__END__` now making an appearance, it shouldn't be too hard to see where this is going.
### *Hello World!*
```
$><<(DATA||=$<).read;a
eval$s=%q($><<"eval$s=%q(#$s)
__END__
Hello World!")
__END__
Hello World!
```
[Try it online!](https://tio.run/##KypNqvz/X8XOxkbDxTHEsabGVsVGU68oNTHFOpErtSwxR6XYVrVQA6RACcFVVinW5IqPd/VziY/n8kjNyclXCM8vyklRVMIu/P9/SEaqQnJiiUIxEOfnKZQAubmJJQA "Ruby – Try It Online")
Finally we have `DATA` and `__END__` together. Unlike in the *cat* program, `DATA` is defined this time: it's a `File` object containing `Hello World!`. Once this has been printed, there is no further output because of the error thrown by the final `a` (undefined) in the first line.
[Answer]
# Python 3, Cat + Quine = Hello World, 121 bytes
* -2 bytes thanks to @Jo King
**Cat**:
Actual `cat` part is taken from the top comment of [this SO answer](https://stackoverflow.com/a/40462515/4608364).
If the file is long enough, switch to a Hello World program.
```
len(open(__file__).read())<99or~print('Hello World!')
import sys
print(sys.stdin.read())
```
The `~print` exits the program after printing: `print` returns `None` and `~None` throws. (Crashing to exit was allowed by OP in a comment.)
**Quine**:
Pretty standard. Originally wanted to use Python 3.8 `:=` to do `print((s:='print((s:=%r)%%s)')%s)`, but that was longer. Stole the use of `;` instead of `\n` from [one of the other Python answers](https://codegolf.stackexchange.com/a/209043/43266).
```
s='s=%r;print(s%%s)';print(s%s)
```
**[Combined](https://tio.run/##PU27CsMwDNz9Fe5gbC2BtlNos@cPMpqCXSpwJSN5yZJfT01fyz24O66u7cF03veSKXDtEOMdS44RBsm3FACu48iyVUFqwc@5FLYLS0kHDwaflaVZXdV8Cl0N2hLSb2108jo5uXxz5xT83yiYfo2U7dG86fQC)**:
```
len(open(__file__).read())<99or~print('Hello World!')
import sys
print(sys.stdin.read())
s='s=%r;print(s%%s)';print(s%s)
```
[Answer]
# [Haskell](https://www.haskell.org/), Cat + Quine = Hello World, 127 bytes
## Cat, 27 bytes
```
o=interact id
main=o where 
```
[Try it online!](https://tio.run/##DcnRDcAgCAXA/07BAo7gMERJfBGhVZuOT/29a7y6qEZKhTc9L0yoHXD6fGoNz7Atk8sm1GswLJ9qMoUiuOuq43LADeb3Dw "Haskell – Try It Online")
## Quine, 100 bytes
```
o=putStr"Hello, world!";main=putStr$(++)<*>show$"o=putStr\"Hello, world!\";main=putStr$(++)<*>show$"
```
[Try it online!](https://tio.run/##y0gszk7Nyfmvq5ucWKJQWJqZl6qQARTIVyjPL8pJ@Z9vW1BaElxSpOQBEtSBiCoqWecmZuZBpVQ0tLU1bbTsijPyy1WUYBpiUHXE4NHy/39idk5xSi5XfmZmfl5mXn4BAA "Haskell – Try It Online")
## Hello World
```
o=interact id
main=o where o=putStr"Hello, world!";main=putStr$(++)<*>show$"o=putStr\"Hello, world!\";main=putStr$(++)<*>show$"
```
[Try it online!](https://tio.run/##fcsxEoIwEIXhnlOsGQoVOYHGmt6WZofsTHYIWUyW4fgRZSxsbN//Po95pBBK2w6o8Fw4EvhtEFglBVfEclRKOCiwqybkaLfkKRGInRd9aDLd@3/ZwcFcP6c91cemOd3O9@xlrc0X9L@i/0NKwTFkN1XCLJGjzC8 "Haskell – Try It Online")
## Explanation
The main trick in this answer is scoping. In the cat we have a simple program. We have a `main` which is just defined to be `o`, which is a cat program. At the end of the program there is a `where` which opens a new scope. This will make our entire quine program attached to the scope of the main program. Two things are solved by doing this.
* Since the quine program's `main` is not defined in the global scope we avoid the duplicate main declaration error.
* We can declare a version of `o` that overrides the one in the global scope. Our quine program declares `o` to be a hello world program.
The overall technique is very similar to [Silvio Mayolo's answer](https://codegolf.stackexchange.com/a/209120/56656), however improves upon it in two ways.
* Silvio Mayolo's answer declares a variable `c=1`, which is never used (I am not sure why this is done. Removing it doesn't break anything). This does not have this.
* I used a shorter quine technique. I took a glance at Silvio Mayolo's quine and I don't know how it works, but it is longer than mine.
[Answer]
# [Python 2](https://docs.python.org/2/), Quine + Cat = Hello World, 86 bytes
### [Quine](https://tio.run/##K6gsycjPM/r/PzPFVh2IVYusC4oy80oUMlNUVTNT1BG8zJT//wtLM/NSAQ "Python 2 – Try It Online") (35 bytes)
```
id='id=%r;print id%%id';print id%id
```
### [Cat](https://tio.run/##K6gsycjPM/r/X9tAS109MS9F3SM1JydfITy/KCdFUZ2rPCMzJ1Vd3S4zxaqgKDOvRKEosTw@M6@gtERD8///5MQSLiAqAQA "Python 2 – Try It Online") (51 bytes)
```
+0*''and'Hello World!'
while''>id:print raw_input()
```
### [Hello World](https://tio.run/##K6gsycjPM/r/PzPFVh2IVYusC4oy80oUMlNUVTNT1BG8zBRtAy119cS8FHWP1JycfIXw/KKcFEV1rvKMzJxUdXW7zBQriOKixPL4zLyC0hINzf//AQ "Python 2 – Try It Online") (86 bytes)
```
id='id=%r;print id%%id';print id%id+0*''and'Hello World!'
while''>id:print raw_input()
```
[Answer]
# [Pxem](https://esolangs.org/wiki/Pxem) ([esolang-box notation](https://github.com/hakatashi/esolang-box#pxem)), Hello World: 48 bytes + Quine: 110 bytes = Cat: 158 bytes.
Unprintables are escaped.
## Hello World
```
.f!.zHello World.p.d.a.w.c.z.w.o.i.c\001.+.a.d.a.a
```
## Quine
```
!Be!?BzBc!!B+BzXXFBaBcFBz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5W3d0tlJMSmZPDa7KR5nL41TLgScRv/d/1Tq2l26IODAsALn2Migdfgcgo/HAqT8mBu0@cKvCYK04kZPEEOGhOUVm6CNn79Fw "ksh – Try It Online")
Use variable `mode` to switch programs.
## How it works
The Hello World program consists of several parts, as in:
```
# branch if content begins with '!' or not
.f!.z
  # Hello World program
  # Note that '!' is recycled here
  Hello World.p.d
.a
.w.c.z
  # Cat program
  # Note that content of stack is cleared before entrying here
  .w.o.i.c\001.+.a.d
.a.a\n
```
Quine is [recycled from here](https://codegolf.stackexchange.com/a/221399/100411).
Cat program uses this specification:
> 
> The first line is the file name of the pxem code.
> 
> 
> The rest is the content of the pxem code.
> 
> 
> 
[Answer]
# [AWK](https://www.gnu.org/software/gawk/manual/gawk.html), Cat + HW = Quine, 156 bytes
```
BEGIN{k=1}1;BEGIN{if(k){printf a="BEGIN{k=1}1;BEGIN{if(k){printf a=%c%s%c,34,a,34,34,34;exit}print%cHello World!%c}",34,a,34,34,34;exit}print"Hello World!"}
```
[Try it online!](https://tio.run/##SyzP/v/fydXd068629aw1tAaws5M08jWrC4oyswrSVNItFUiqEI1WbVYNVnH2EQnEUSAkXVqRWZJLViJarJHak5OvkJ4flFOiqJqcq0STqVKyCqVav//d04sAQA "AWK – Try It Online")
This is the overall algorithm:
```
BEGIN{k=1}1;
BEGIN{if(k){
    print"Quine";exit
    }
print"Hello, World!"
}
```
## Cat
```
BEGIN{k=1}1;
```
## Hello World
```
BEGIN{if(k){printf a="BEGIN{k=1}1;BEGIN{if(k){printf a=%c%s%c,34,a,34,34,34;exit}print%cHello World!%c}",34,a,34,34,34;exit}print"Hello World!"}
```
[Answer]
# [V (vim)](https://github.com/DJMcMayhem/V), Quine + Hello World = Cat, 32 bytes
## Quine
```
dG2idG2i
```
Explanation:
* `dG`: Delete the buffer (saving it to the unnamed register)
* `2idG2i`: Insert `dG2i` twice.
## Hello World
```
"_dG4iHello World!
␛pH3D
```
With trailing newline. TryItOnline also shows a trailing space after that, but this appears to be an artifact of it's V runner.
Explanation:
* `"_dG`: Delete the buffer (without saving it to a register)
* `4iHello World!␊␛`: Write "Hello World!" 4 times
* `p`: Paste from the (empty) unnamed register
* `H3D`: Delete the first 3 lines of the buffer
## Cat
```
dG2idG2i"_dG4iHello World!
␛pH3D
```
Since all no-ops in V are automatically cat programs, the trick here is to make the combined program cancel out itself.
Explanation:
* `dG`: Delete the buffer (saving it to the unnamed register)
* `2idG2i"_dG4iHello World!␊␛`: Write `dG2i"_dG4iHello World!` twice (trailing newline)
* `p`: Paste from the unnamed register.
	+ Since the motion used to delete was `G`, this pastes it onto the following line.
	+ Therefore, the first two lines of the buffer are that crazy string, the third is an empty line, and the rest is the original buffer
* `H3D`: Delete the first 3 lines of the buffer
[Try it online!](https://tio.run/##K/v/P8XdKBOEleJT3E0yPVJzcvIVwvOLclIUuWxSi5PtCjxSjFP@/w/JSFUoLM1MzlZIKsovz1NIy6/gyirNLShWyC9LLVIoAUrnJFZVKqTkp//XLQMA "V (vim) – Try It Online")
[Answer]
# PHP, Hello World + Quine = Cat, 117 bytes
Because of the input method this only works using the command line.
## Hello world
the double die is because the php code has to get interupted earlier in order to prevent errors being printed (missing function a)
```
<?php if(!function_exists('a')){die('Hello world!');}die(a($argv));
```
## Quine
without opening tag, php just outputs whatever it contains
```
function a($b){unset($b[0]);echo implode(' ',$b);}
```
## Cat
Because function declations are passed first, the die() isn't called yet and therefor a() exists, and is called in order to print its arguments. The unset avoids the scriptname from being printed (which is not an input)
```
<?php if(!function_exists('a')){die('Hello world!');}die(a($argv));function a($b){unset($b[0]);echo implode(' ',$b);}
```
If only the first argument has to be printed, a shortcut can be used (101 bytes):
```
<?php if(!function_exists('a')){die('Hello world!');}die(a($argv));function a($b){unset($b[0]);echo implode(' ',$b);}
```
This however is not the full input and i consider this invalid
[Answer]
# Java 10+, Cat + Quine = Hello World, 384 (135 + 249) bytes
## [Cat](https://tio.run/##LcyxDoIwEIDh2bdonGCwEHFAHUw0Jg5OonEwDhd6mEK5ajlAQnh2ZHD9k@/PoYFFropx1MToMkhRHPqKgXUqGquVKEGTl7DT9Ho8we@TrmIspa1ZvqfIhry9tQaB5PVyO@4IW5FPV1mzNjJJgQid91eafEn45bMm9PzN/ITGWHG3zqi5vx2GIBhHyKtCZXE4W3aRcFG8Dj9du/oB), 135 bytes
```
interface C{static void main(String[]a){System.out.println(Boolean.TRUE?new java.util.Scanner(System.in).nextLine():"Hello World");}}//
```
## [Quine](https://tio.run/##y0osS9TNSsn@/z8zryS1KC0xOVXBNzEzr7q4JLEkM1mhLD8zRSEXKKARXFKUmZceHZuoWV2WWKRQbKuE0BFIhHLVZNVi1WTr4MriktRcvfzSEr0CoIqSNI1iHWMTHTBhaKBpXVurmoww2Ck/Pyc1Ma86CUIrhASFutqmJeYUp1rXKhFhFhdxRv3/DwA), 249 bytes
(note: TIO doesn't let me run the code unless I rename my interface from `Q` to `Main`, but just know that it's supposed to be named the former)
```
interface Q{static void main(String[]a){var s="interface Q{static void main(String[]a){var s=%c%s%c;System.out.printf(s,34,s,34,10);}}%cinterface Boolean{boolean TRUE=false;}";System.out.printf(s,34,s,34,10);}}
interface Boolean{boolean TRUE=false;}
```
## [Hello World](https://tio.run/##lY/BasJAEIbvfYolENiAXSt6apBCodBDe9AoHqSHcTMpm66zZXeMSsizx2gFwYPYywz8zHx8fwkVPJb5T9saYvQFaBSfYKgODGy0qJzJxboLZMbe0PfyC5I62wfGtXIbVr9dyJbkq3MWgdRsOn97IdyKsgOrDRurMg1E6OX5y1CiCHf8YQhl8hy9o7VOLJy3eZSkTdPvX0wmNzUq8CKMo/@dxzoOsU6vKxQy9Iaj3mkMno4esb6Az@3q1d8Wx5bjAmzAtInuYD3ch2rbAw), 384 bytes
```
interface C{static void main(String[]a){System.out.println(Boolean.TRUE?new java.util.Scanner(System.in).nextLine():"Hello World");}}//interface Q{static void main(String[]a){var s="interface Q{static void main(String[]a){var s=%c%s%c;System.out.printf(s,34,s,34,10);}}%cinterface Boolean{boolean TRUE=false;}";System.out.printf(s,34,s,34,10);}}
interface Boolean{boolean TRUE=false;}
```
Again, the TIO link contains an interface called `Main`, but it's actually `C`, the cat program.
It redefines `Boolean.TRUE` to be `false` when the quine is concatenated to the cat.
[Answer]
# Haskell, Cat + Quine = Hello World, 140 bytes
## Cat
```
b=interact id
main=b where c=1;
```
## Quine
```
main=putStr a>>print a;b=putStrLn "Hello world!";a="main=putStrLn a>>print a;b=putStrLn \"Hello world!\";a="
```
## Hello World!
```
b=interact id
main=b where c=1;main=putStr a>>print a;b=putStrLn "Hello world!";a="main=putStrLn a>>print a;b=putStrLn \"Hello world!\";a="
```
We exploit the rules of variable shadowing. The cat program simply calls the global `b`, defined as `interact id` (a standard cat in Haskell). We declare a variable `c` that's never used, simply so we can concatenate later. The quine is pretty standard; we define a variable `b` that we never use, but otherwise it simply prints its payload and exits.
Here's a version of "Hello world" with better spacing.
```
b = interact id
main = b
  where c=1
        main=putStr a>>print a
        b=putStrLn "Hello world!"
        a="main=putStrLn a>>print a;b=putStrLn \"Hello world!\";a="
```
`main` simply calls `b`, but this time is calls the locally-declared `b`, which prints "Hello world!". All of the other variables are unused.
[Answer]
# [Klein](https://github.com/Wheatwizard/Klein) 001, Quine + Cat = Hello World, 28 bytes
## Quine, 11 bytes
*This is Martin Ender's quine from [here](https://codegolf.stackexchange.com/a/121511/56656)*
```
:?\:2+@> "
```
[Try it online!](https://tio.run/##y85Jzcz7/9/KPsbKSNvBTkGJ6////wYGhv91HQE "Klein – Try It Online")
## Cat, 17 bytes
```
@ >"Hello world!"
```
[Try it online!](https://tio.run/##y85Jzcz7/99BwU7JIzUnJ1@hPL8oJ0VR6f///7rJ/w0MDP8n5uTkFAMA "Klein – Try It Online")
## Hello World, 28 bytes
```
:?\:2+@> "
@ >"Hello world!"
```
[Try it online!](https://tio.run/##y85Jzcz7/9/KPsbKSNvBTkGJy0HBTskjNScnX6E8vygnRVHp////BgaG/3UdAQ "Klein – Try It Online")
[Answer]
# [Japt](https://github.com/ETHproductions/japt), Quine + Cat = Hello World, 43 bytes
All of the complexity is jammed into making a quine that includes a variable that holds `Hello World!`. Cat simply outputs the default input and the Hello World merger reuses the variable from the quine.
## [Quine, 41 bytes](https://ethproductions.github.io/japt/?v=1.4.6&code=IkhlbGxvIFdvcmxkISIKImlRILJpUmlRaVVpUSJpUSCyaVJpUWlVaVE=&input=)
```
"Hello World!"             // U = "Hello World!"
"iQ ²iRiQiUiQ"iQ ²iRiQiUiQ // A bunch of messy string manipulations to make this a quine
```
## [Cat, 2 bytes](https://ethproductions.github.io/japt/?v=1.4.6&code=ClU=&input=ImZvb2JhciI=)
```
U // Output the default first input
```
## [Hello World, 43 bytes](https://ethproductions.github.io/japt/?v=1.4.6&code=IkhlbGxvIFdvcmxkISIKImlRILJpUmlRaVVpUSJpUSCyaVJpUWlVaVEKVQ==&input=)
```
"Hello World!"             // U = "Hello World!"
"iQ ²iRiQiUiQ"iQ ²iRiQiUiQ // Throwaway line
U                          // Output U
```
[Answer]
# [Vyxal](https://github.com/Vyxal/Vyxal), Cat + Quine = Hello, 16 bytes
## Hello world, 13 bytes
```
kh\!+□⁋`I^`I^
```
[Try it Online!](https://vyxal.pythonanywhere.com/#WyIiLCIiLCJraFxcISvilqHigYtgSV5gSV4iLCIiLCJhXG5iXG5jXG5kXG4iXQ==)
## Cat, 7 bytes
```
kh\!+□⁋
```
[Try it Online!](https://vyxal.pythonanywhere.com/#WyIiLCIiLCJraFxcISvilqHigYsiLCIiLCJhXG5iXG5jXG5kXG4iXQ==)qwhYOKWoeKBiyIsIiIsImFcbmJcbmNcbmRcbiJd)
## Quine, 6 bytes
```
`I^`I^
```
[Try it Online!](https://vyxal.pythonanywhere.com/#WyIiLCIiLCJgSV5gSV4iLCIiLCJhXG5iXG5jXG5kXG4iXQ==)
## Explanation :
```
## Cat (10)
kh       # push 'Hello World' onto the stack
  \!+    # add '!' to the string
     □   # push the list of the inputs onto the stack
      ⁋  # join the element on top of the stack, with '\n' as separator
         # implicit output
## Quine (6)
`I^`     # push 'I^' on the stack
    I    # string -> `string`string 
     ^   # reverse the stack
         # implicit output
## Hello (16)
kh\!+          # push `Hello World!` onto the stack
     □         #  | do
      ⁋        #  | many
       `I^`    #  | useless
           I   #  | things
             ^ # reverse the stack
               # implicit output
```
]