[Question]
  [
Program A outputs program B's code when run, and B outputs A's source.
Requirements:
* Only one language across both programs
* Programs are different. One program that outputs itself does not qualify.
* Both programs are non-empty, or at least 1 byte in length. Trailing newlines in both source and output are ignored
* ~~stdin is closed.~~ Do not read anything (so **you can't read the source** and manipulate it). Output goes to stdout.  
**Edit:** stdin is connected to `/dev/null`. You can order it be closed if clarified.
* Do not use `random` functions.
Additional:
* Give explanations if possible
Score is **total length**. Trailing newline does not count if it doesn't affect the program.
  
[Answer]
## [CJam](https://sourceforge.net/p/cjam), 13 + 13 = 26 bytes
```
{sYZe\"_~"}_~
```
[Try it online!](https://tio.run/##S85KzP3/v7o4Mio1Rim@Tqk2vu7/fwA "CJam – Try It Online")
Outputs
```
{sZYe\"_~"}_~
```
### Explanation
```
{       e# Standard quine framework, leaves a copy of the block on the stack
        e# for the block itself to process.
  s     e# Stringify the block.
  YZe\  e# Swap the characters at indices 2 and 3, which are Y and Z themselves.
  "_~"  e# Push the "_~" to complete the quine.
}_~
```
Since `e\` is commutative in its second and third operand, the other program does exactly the same, swapping `Z` and `Y` back into their original order.
[Answer]
# [CJam](https://sourceforge.net/p/cjam), ~~11 + 13 = 24~~ 11 + 12 = 23 bytes
```
"N^_p"
N^_p
```
[Try it online!](https://tio.run/##S85KzP3/X8kvLr5AiQtE/v8PAA "CJam – Try It Online")
Outputs:
```
"N^_p
"
N^_p
```
The output has 13 bytes, but:
> 
> Trailing newline does not count if it doesn't affect the program.
> 
> 
> 
So I changed the space to a newline to take advantage of that.
It is based on the shortest CJam proper quine:
```
"_p"
_p
```
And `N^` is to xor the string with a newline, which adds a newline if there isn't a newline, and remove it if there is, for a string that each character is unique.
I think I have seen that quine in the quine question, but I couldn't find it.
[Answer]
# [RProgN 2](https://github.com/TehFlaminTaco/RProgN-2), 3 + 3 = 6 bytes
First program:
```
0
1
```
[Try it online!](https://tio.run/##Kyooyk/P0zX6/9@Ay/D/fwA "RProgN 2 – Try It Online")
Second program:
```
1
0
```
[Try it online!](https://tio.run/##Kyooyk/P0zX6/9@Qy@D/fwA "RProgN 2 – Try It Online")
-2 thanks to [Martin Ender](https://codegolf.stackexchange.com/users/8478/martin-ender).
[Answer]
# C, 95 + 95 = 190 bytes
*Thanks to @immibis for saving 16\*2 bytes!*
```
char*s="char*s=%c%s%c;main(i){i=%d^1;printf(s,34,s,34,i);}";main(i){i=1^1;printf(s,34,s,34,i);}
```
[Try it online!](https://tio.run/##S9ZNT07@/z85I7FIq9hWCUqrJqsWqyZb5yZm5mlkalZn2qqmxBlaFxRl5pWkaRTrGJvogIlMTetaJSRVhrgU/f8PAA)
Outputs:
```
char*s="char*s=%c%s%c;main(i){i=%d^1;printf(s,34,s,34,i);}";main(i){i=0^1;printf(s,34,s,34,i);}
```
[Try it online!](https://tio.run/##S9ZNT07@/z85I7FIq9hWCUqrJqsWqyZb5yZm5mlkalZn2qqmxBlaFxRl5pWkaRTrGJvogIlMTetaJSRVBrgU/f8PAA)
Which outputs:
```
char*s="char*s=%c%s%c;main(i){i=%d^1;printf(s,34,s,34,i);}";main(i){i=1^1;printf(s,34,s,34,i);}
```
[Answer]
# Javascript, 67+67=134 bytes
1st program:
```
alert(eval(c="`alert(eval(c=${JSON.stringify(c)},n=${+!n}))`",n=0))
```
2nd program:
```
alert(eval(c="`alert(eval(c=${JSON.stringify(c)},n=${+!n}))`",n=1))
```
This is based on [Herman Lauenstein's answer to Tri-interquine](https://codegolf.stackexchange.com/a/130317/70761)
# Javascript (Invalid - reads source code), ~~75+75=150~~ ~~61+61=122~~ ~~58+58=116~~ 50+50=100 bytes
*saved 20 bytes thanks to Tushar, 6 bytes thanks to Craig Ayre, and saved 16 bytes thanks to kamoroso94*
1st program:
```
f=_=>alert(("f="+f).replace(0,a=>+!+a)+";f()");f()
```
2nd program:
```
f=_=>alert(("f="+f).replace(1,a=>+!+a)+";f()");f()
```
Swaps the 1s with the 0s and vice versa. They both do the same thing, just producing different output because of their source code.
[Answer]
## Python 2, 63+63 = 126 bytes
[Try it online](https://tio.run/##K6gsycjPM/r/39FW3dFWtci6oCgzr0TBMdrKyDhWVdVR2zHayNLK2DTWyNjKyDJWHVUeIc1Fvn6wxP//AA)
First program:
```
A='A=%r;print A[:23]%%A+A[29:35]23:29]';print A[:23]%A+A[23:29]
```
outputs:
```
A='A=%r;print A[:23]%%A+A[29:35]23:29]';print A[:23]%A+A[29:35]
```
Second program:
```
A='A=%r;print A[:23]%%A+A[29:35]23:29]';print A[:23]%A+A[29:35]
```
Outputs:
```
A='A=%r;print A[:23]%%A+A[29:35]23:29]';print A[:23]%A+A[23:29]
```
[Answer]
# JavaScript ([JsShell](https://developer.mozilla.org/en-US/docs/Mozilla/Projects/SpiderMonkey/Introduction_to_the_JavaScript_shell)), 35 + 34 = 69 bytes
1:
```
(f=x=>print(`(f=${f})(${-x})`))(-1)
```
2:
```
(f=x=>print(`(f=${f})(${-x})`))(1)
```
[Answer]
# [Underload](https://esolangs.org/wiki/Underload), 32+32=64 bytes
```
(a~a*(:^)*S)(~(a)~a*^a(:^)**S):^
```
[Try it online!](https://tio.run/##K81LSS3KyU9M@f9fI7EuUUvDKk5TK1hTo04jURPIjUsECwBFrOL@/wcA "Underload – Try It Online")
```
(~(a)~a*^a(:^)**S)(a~a*(:^)*S):^
```
[Try it online!](https://tio.run/##K81LSS3KyU9M@f9fo04jUbMuUSsuUcMqTlNLK1hTIxHIBXOCNa3i/v8HAA "Underload – Try It Online")
[Answer]
# Mathematica, 43 + 44 = 87 bytes
```
(Print[#1[#0[#1, -#2]]] & )[HoldForm, -1 1]
```
and
```
(Print[#1[#0[#1, -#2]]] & )[HoldForm, -(-1)]
```
[Answer]
# asmutils sh, 16+16 bytes, abusing the "stdin is closed" rule.
```
#!/bin/sh
tr x y
```
Since stdin is closed and sh will open its script to the first available handle (rather than move it to a high numbered handle like modern shells do), tr ends up reading from a copy of the script without having ever opened it.
This interquine is payload capable but inserting a payload is tricky.
In addition, this original version abuses some crazy bug in the ancient kernel I used in those days. (I don't know what's up with that kernel--I found out later on it had different major and minor numbers for devices too.) If you fix the ABI changes that broke asmutils the interquine still won't work. I forget if asmutils sh has exec or not, but if it does, this is a modern version:
```
exec dd skip=0 | tr x y
```
This abuses a deliberate bug in asmutils dd; it has a performance optimization it calls llseek for skip if it can, but to save a byte it passes SEEK\_SET rather than SEEK\_CUR. This results in garbage on stderr but the interquine on stdout. Asmutils dd doesn't have an option to suppress the stderr spam.
[Answer]
# [><>](https://esolangs.org/wiki/Fish), 16 + 16 = 32 bytes
```
":1-}80.r   !#o#
```
and 
```
#o#!   r.08}-1:"
```
[Try it online!](https://tio.run/##S8sszvj/X8nKULfWwkCvSEFBQVE5X/n/fwA "><> – Try It Online")
This works by using a jump in the program, the first programs jump will skip the reverse of the stack (if it reversed the stack it would be a quine).
The second program doesn't skip the reverse but was it's already reversed by the flow of the program then it'll create the originial.
This code will end in an error.
[Answer]
## Common Lisp, 58 characters
```
#1=(let((*print-circle* t))(print'(write '#1# :circle t)))
```
... or 24 characters if you don't mind assuming `*print-circle*` is globally set to `T` :
```
#1=(print '(write '#1#))
```
The printed representation of the code is read as a cyclic structure, where `#1#` points back to the cons cell following `#1=`. We quote programs so that they are not executed. Since `*print-circle*` is T, the REPL takes care to emit such reader variables during printing; this is what the above code prints, and returns:
```
#1=(write '(print '#1#)) 
```
When we evaluate the above code, it prints:
```
#1=(print '(write '#1#))
```
If you want to stick with the default value for `*print-circle*`, which is NIL in a conforming implementation, then you'll have to rebind the variable temporarily:
```
#1=(let((*print-circle* t))(print'(write '#1# :circle t)))
```
Inside the body of the LET, we print things with `*print-circle*` being T. So we obtain:
```
#1=(write
    '(let ((*print-circle* t))
       (print '#1#))
    :circle t) 
```
As you can see, the new program doesn't rebind `*print-circle*`, but since we are using `write`, which is the low-level function called by `print`, we can pass additional arguments such as `:circle`. The code then works as expected:
```
#1=(let ((*print-circle* t))
     (print '(write '#1# :circle t)))
```
However, you need to execute the above programs as a script, not inside a REPL, because even though you print things while taking care of circular structures, both `write` and `print` also returns the value being printed; and in a default REPL, the value is also being printed, but outside of the dynamic context where `*print-circle*` is T.
[Answer]
# [RProgN 2](https://github.com/TehFlaminTaco/RProgN-2), 7 + 7 = 14 bytes
I wanted to try to show off a better usage of RProgN, rather than just abusing print orders...
```
1
«\1\-
```
and...
```
0
«\1\-
```
## Explained
```
1   # Push the constant, 1. (Or 0, depending on the program)
«\1\-
«       # Define a function from this to the matching », in this case there isn't any, so define it from this to the end of the program, then continue processing.
 \      # Flip the defined function under the constant.
  1\-   # Get 1 - Constant.
```
Because this prints the stack upside down, the new constant is printed first, then the stringifed version of the function is printed.
[Try it online!](https://tio.run/##Kyooyk/P0zX6/9@Q69DqGMMY3f//AQ "RProgN 2 – Try It Online")
[Answer]
## [LOGO](https://sourceforge.net/projects/fmslogo/), 65 + 66 = 131 bytes
```
apply [(pr ? ` [[,? ,-?2]] )] [[apply [(pr ? ` [[,? ,-?2]] )]] 1]
```
and
```
apply [(pr ? ` [[,? ,-?2]] )] [[apply [(pr ? ` [[,? ,-?2]] )]] -1]
```
[Answer]
# Python 3, 74+74=148 bytes
```
a='a=%r;b=%r;print(b%%(b,a))';b='b=%r;a=%r;print(a%%(a,b))';print(b%(b,a))
```
and
```
b='b=%r;a=%r;print(a%%(a,b))';a='a=%r;b=%r;print(b%%(b,a))';print(a%(a,b))
```
~~i don't understand it either~~
[Answer]
# [><>](https://esolangs.org/wiki/Fish), 12 + 12 = 24 bytes
```
'3d*!|o|!-c:
```
and
```
':c-!|o|!*d3
```
[Try it online!](https://tio.run/##S8sszvj/X904RUuxJr9GUTfZiisxL4VL3SpZFyyglWL8/z8A "><> – Try It Online")
Both programs use a wrapping string literal to add the code to the stack, then produce the `'` command through different methods. When printing the stack it pushes the code backwards, however the `'` stays at the front. There are several variations that produce the `'`; `3d*`, `d3*`, `00g`, `:c-` when paired with `3d*` and `:9-` when paired with `00g`.
A too [similar solution](https://tio.run/##S0pNK81LT9W1tNAtqAQz//9XMtJOztZRcNDJTtY2@v8fAA) to post, in Befunge-98 for 13\*2 bytes
```
"2+ck, @,kc+2
```
[Answer]
# [Stax](https://github.com/tomtheisen/stax), 18+20=38 bytes
```
"Vn|^34bL"Vn|^34bL
```
[Run and debug online!](https://staxlang.xyz/#c=%22Vn%7C%5E34bL%22Vn%7C%5E34bL&a=1)
```
"Vn|^34bL
"Vn|^34bL
```
[Run and debug online!](https://staxlang.xyz/#c=%22Vn%7C%5E34bL%0A%22Vn%7C%5E34bL%0A&a=1)
## Explanation
Added for completeness. Port of @jimmy23013's CJam answer. Toggles the newlines using set xor.
[Answer]
# Javascript (ES6), 36 + 36 = 72 bytes
Program 1:
```
f=n=>('f='+f).replace(/4|5/g,n=>n^1)
```
Program 2:
```
f=n=>('f='+f).replace(/5|4/g,n=>n^1)
```
These programs work by cloning themselves and replace `5` with `4` and `4` with `5`
```
console.log((
    f=n=>('f='+f).replace(/4|5/g,n=>n^1)
)())
console.log((
    f=n=>('f='+f).replace(/5|4/g,n=>n^1)
)())
```
[Answer]
# [Klein](https://github.com/Wheatwizard/Klein), ~~26~~ 24 bytes
```
<:3+@+3<:"
```
[Try it online!](https://tio.run/##y85Jzcz7/1/eysZY20Hb2MpGXun///8GBgb/dR0B "Klein – Try It Online")
## Explanation
This works the same as [my Klein Quine](https://codegolf.stackexchange.com/a/121406/56656), where it prints the source backwards followed by a `"`, the last one got away with this by being palindromic, so all we need to do is make it non-palindromic without damaging its functionality. By switching `<` and `:` we were able to do this without interfering with functionality.
[Answer]
# [Pari/GP](http://pari.math.u-bordeaux.fr/), 36 + 36 = 72 bytes
```
(f=(x)->print1("(f="f")("1-x")"))(1)
```
[Try it online!](https://tio.run/##K0gsytRNL/j/XyPNVqNCU9euoCgzr8RQQwnIV0pT0tRQMtStUNJU0tTUMNT8/x8A "Pari/GP – Try It Online")
```
(f=(x)->print1("(f="f")("1-x")"))(0)
```
[Try it online!](https://tio.run/##K0gsytRNL/j/XyPNVqNCU9euoCgzr8RQQwnIV0pT0tRQMtStUNJU0tTUMND8/x8A "Pari/GP – Try It Online")
[Answer]
# [Python 2](https://docs.python.org/2/), 42 + 43 = 85 bytes,
# [Python 3](https://docs.python.org/3/), 44 + 45 = 89 bytes
## Python 2 (85 bytes):
```
a='a=%r,-%d;print a[0]%%a',-1;print a[0]%a    # Program 1: 42 bytes
a='a=%r,-%d;print a[0]%%a',--1;print a[0]%a   # Program 2: 43 bytes
```
[Try it online!](https://tio.run/##K6gsycjPM/r/P9FWPdFWtUhHVzXFuqAoM69EITHaIFZVNVFdR9cQWSTx/38A "Python 2 – Try It Online")
## Python 3 (89 bytes):
```
a='a=%r,-%d;print(a[0]%%a)',-1;print(a[0]%a)    # Program 1: 44 bytes 
a='a=%r,-%d;print(a[0]%%a)',--1;print(a[0]%a)   # Program 2: 45 bytes
```
[Try it online!](https://tio.run/##K6gsycjPM/7/P9FWPdFWtUhHVzXFuqAoM69EIzHaIFZVNVFTXUfXEFkoUfP/fwA "Python 3 – Try It Online")
## How it works? :
I started from the standard `a='a=%r;print(a%%a)';print(a%a)` quine. But instead of having `a` equal only to a string, I have `a` equal to a tuple regrouping a sting and an integer.
I add the char `-` in front of my integer:
* if it is equal to `-1`, `-%d` will be equal to `--1`
* if it is equal to `--1`, `%d` will evaluate it as 1 so `-%d` will be equal to `-1`
## Edits:
I found aferwards this pretty elegant solution. Not better, just elegant. (58 + 58 = 116 bytes):
```
a="print'a=%r;exec a.lower()'%a.swapcase()";exec a.lower() # 58 char each
a="PRINT'A=%R;EXEC A.LOWER()'%A.SWAPCASE()";exec a.lower() # 116 bytes in total
```
[Try it online!](https://tio.run/##bczBCsIgGADge0/xsyFuF2FBEQwPMjwEUcMF6/ongoOh4oS1p7e6RucPvrAl690@Z@RFiJNLFDmJrXkZDchmv5pY1ZQgW1YMGhdT1cWPQgmHE2iLEQxqu/tMvTpf71Rwolr5kB0IdrmNUn0nwYZR9J0Y5N@paY7w3JJZYHKQfMI55zc "Python 2 – Try It Online")
]