[Question]
  [
Write the smallest program that maps strings injectively to outputs and maps itself to 2020.
To be clear, your program \$p\$ must have the following properties:
1. every possible input string \$s\$ has a well-defined output \$p(s)\$,
2. for every pair of strings \$s\$ and \$t\$ with \$s\neq t\$, it holds that \$p(s)\neq p(t)\$, and
3. \$p(p)=2020\$.
Be sure to explain why your submission satisfies properties 1 and 2. For property 3, the output can be a string or any type of number.
**Edit 1:** Programs need to be proper quine variants. Reading the source code is not allowed.
**Edit 2:** Note that as a consequence of property 2, it holds that \$p(s)\neq p(p)\$ for every \$s\neq p\$.
  
[Answer]
# awk, 4 bytes
The structure of an awk program is *`pattern { action }`*. If *pattern* evaluates to true, *{ action }* is performed. If *{ action }* is omitted, the default is to output the current input record.
Code:
```
2020
```
As `2020` always evaluates to true, the program always prints it's input, therefore satisfying properties 1. and 2. When the input is the program itself it satisfies property 3. \$p(p)=2020\$ — even \$p(p)=p\$.
Some test cases:
```
$ echo 2020 | awk '2020'
2020
$ echo 0 | awk '2020'
0
$ echo "" | awk '2020'
$ echo foo | awk '2020'
foo
```
Would've been more glorious back in the good old days:
```
$ echo 1 | awk '1'
1
```
[Answer]
# JavaScript (ES6), 23 bytes
Returns either the input string with a leading \$0\$, or \$2020\$ if the input is the program.
```
f=s=>s=='f='+f?2020:0+s
```
[Try it online!](https://tio.run/##y0osSyxOLsosKNHNy09J/f8/zbbY1q7Y1lY9zVZdO83eyMDIwMpAu/h/cn5ecX5Oql5OfrpGmoaSR2pOTr6OQnh@UU6KopKmJheaPEgfFmEcpgNV/gcA "JavaScript (Node.js) – Try It Online")
---
# [JavaScript (Node.js)](https://nodejs.org), 76 bytes
Generates a unique BigInt by using each byte of the input string, then applies a XOR to the result in such a way that \$f(f)=2020\$.
```
f=s=>(g=s=>Buffer(s).every(b=>t=t<<8n|BigInt(b),t=1n)&&t)(s)^g('f='+f)^2020n
```
[Try it online!](https://tio.run/##y0osSyxOLsosKNHNy09J/f8/zbbY1k4jHUQ6laalpRZpFGvqpZalFlVqJNnaldiW2NhY5NU4ZaZ75pVoJGnqlNga5mmqqZVoAtXFpWuop9mqa6dpxhkZGBnk/U/OzyvOz0nVy8lP10jTUPJIzcnJ11EIzy/KSVFU0tTkQpOnpt1A4/8DAA "JavaScript (Node.js) – Try It Online")
[Answer]
# [Ruby](https://www.ruby-lang.org/) `-n`, 45 bytes
Based on one of the classic Ruby quines, `_="_=%p;puts _%%_";puts _%_`. Prints `2020` if the input is the source, otherwise prints the Ruby representation of the input (encapsulated in quotes, various characters like `"` and `\` are escaped, etc.)
```
_="_=%p;p$_==_%%_ ?2020:$_";p$_==_%_ ?2020:$_
```
[Try it online!](https://tio.run/##KypNqvz/P95WKd5WtcC6QCXe1jZeVTVewd7IwMjASiVeCSaGECJR@b/8gpLM/Lzi/7p5AA "Ruby – Try It Online")
[Answer]
# [Python 3.8 (pre-release)](https://docs.python.org/3.8/), ~~81~~ ~~60~~ ~~59~~ ~~57~~ 56 bytes
-21 Thanks to Jo King
Outputs 2020 if the input matches the program, otherwise the input concatenated to itself 5 time (eg. `abc` becomes `abcabcabcabcabc`)
```
exec(a:='print(5*[i:=input(),404][i=="exec(a:=%r)"%a])')
```
[Try it online!](https://tio.run/##K6gsycjPM7YoKPr/P7UiNVkj0cpWvaAoM69Ew1QrOtPKNjOvoLREQ1PHxMAkNjrT1lYJpkq1SFNJNTFWU12TfJ0A "Python 3.8 (pre-release) – Try It Online")
---
# [Python 2](https://docs.python.org/2/), 56 bytes
Outputs 2020 if the input matches the program, otherwise the input concatenated to itself 5 time (eg. `abc` becomes `abcabcabcabcabc`)
```
a='i=input();print 5*[i,404][i=="a=%r;exec a"%a]';exec a
```
[Try it online!](https://tio.run/##K6gsycjPM/r/P9FWPdM2M6@gtERD07qgKDOvRMFUKzpTx8TAJDY609ZWKdFWtcg6tSI1WSFRSTUxVh3K/v9fSUmJXM1ArQA "Python 2 – Try It Online")
---
# [Python 3.8 (pre-release)](https://docs.python.org/3.8/), ~~77~~ ~~67~~ 65 bytes
-10 Thanks to Jo King
Outputs 2020 if the input matches the program, otherwise the input concatenated to itself 5 time (eg. `abc` becomes `abcabcabcabcabc`) 
```
lambda s:5*[s,404][s==(a:='lambda s:5*[s,404][s==(a:=%r)%%a]')%a]
```
[Try it online!](https://tio.run/##K6gsycjPM7YoKPqfpmCrEPM/JzE3KSVRodjKVCu6WMfEwCQ2utjWViPRylYdt5RqkaaqamKsuiaQ@F9QlJlXopGmkZlXUFqioamp@d/IAAA "Python 3.8 (pre-release) – Try It Online")
[Answer]
# [GolfScript](http://www.golfscript.com/golfscript/), 2 bytes
```
20
```
This is a refined solution to James Brown's solutions.
If the input is 20 [source code], prints 2020 - otherwise prints [string]+20, which is unique and easily reversible.
[Try it online!](https://tio.run/##S8/PSStOLsosKPn/38gAhAE "GolfScript – Try It Online")
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 16 bytes
```
“Ṿ;⁾v`³⁽¥ŒṾ⁼?”v`
```
[Try it online!](https://tio.run/##y0rNyan8//9Rw5yHO/dZP2rcV5ZwaPOjxr2Hlh6dBBR51LjH/lHD3LKE/0SoAQA "Jelly – Try It Online")
A full program that takes a string as its input. It outputs an unevaluated Jelly version of the input unless provided with itself, in which case it outputs 2020. 
Thanks to @JonathanAllan for pointing out a flaw in my original version!
## Explanation
```
 “Ṿ;⁾v`³⁽¥ŒṾ⁼?”v` | Evaluate as Jelly code the following, using itself as the argument:
  Ṿ               | - Unevaluate (effectively wraps string back into “”
   ;⁾v`           | - Append "v`"
       ³    ⁼?    | - If equal to the program’s argument:
        ⁽¥Œ       | - Then: 2020 (compressed integer)
           Ṿ      | - Else: Unevaluated version of the program’s original argument
```
[Answer]
# [Raku](https://github.com/nxadm/rakudo-pkg), 47 bytes
```
<say "<$_>~~.EVAL"eq($!=get)??2020!!@$!>~~.EVAL
```
[Try it online!](https://tio.run/##K0gtyjH7/9@mOLFSQclGJd6urk7PNczRRym1UENF0TY9tUTT3t7IwMhAUdFBRREmS7IGAA "Perl 6 – Try It Online")
Outputs `2020` if the input matches the program, otherwise the input surrounded in brackets.
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E/wiki/Commands), 28 [bytes](https://github.com/Adriandmen/05AB1E/wiki/Codepage)
```
"34çìD«QiŽ7ìëû"34çìD«QiŽ7ìëû
```
[Try it online](https://tio.run/##yy9OTMpM/f9fydjk8PLDa1wOrQ7MPLrX/PCaw6sP78YqSIpaAA) or [verify a few more test cases](https://tio.run/##yy9OTMpM/V9TVnl4gr2SwqO2SQpK9v@VjE0OLz@8xuXQ6sDMo3vND685vPrwbqyC/2t1SFDNRaxSrpLU4hIuIwMjA67EpGSuRK5EEEoEAA).
**Explanation:**
```
"34çìD«QiŽ7ìëû"            # Push this string
               34ç         # Push 34, and convert it to a character: '"'
                  ì        # Prepend it in front of the string
                   D«      # Append a copy of the string to itself
                     Qi    # If it's equal to the (implicit) input:
                       Ž7ì #  Push compressed integer 2020
                      ë    # Else:
                       û   #  Palindromize the (implicit) input
                           # (after which the result is output implicitly)
```
[See this 05AB1E tip of mine (section *How to compress large integers?*)](https://codegolf.stackexchange.com/a/166851/52210) to understand why `Ž7ì` is `2020`.
[Answer]
# [C (gcc)](https://gcc.gnu.org/), ~~190~~ ~~196~~ ~~194~~ ~~192~~ ~~180~~ 176 bytes
Thanks to [Jo King](https://codegolf.stackexchange.com/users/76162/jo-king) for pointing out a bug.
Trailing newline seems accepted in some other answers, so will use that to fix a bug pointed out by [NieDzejkob](https://codegolf.stackexchange.com/users/55934/niedzejkob). (Also -12 bytes thanks to the same.)
-4 bytes thanks to @ceilingcat.
Assumes little-endian, ASCII, `sizeof(int) >= 4`, all the good stuff.
Outputs the input string preceded by a dollar sign, unless given its own source code, in which case it outputs `2020`.
```
*s="*s=%c%s%1$c,u[99]={'0202'};f(int*t){puts(bcmp(u+2,t,sprintf(u+2,s,34,s))?putchar(36),t:u);}",u[99]={'0202'};f(int*t){puts(bcmp(u+2,t,sprintf(u+2,s,34,s))?putchar(36),t:u);}
```
[Try it online!](https://tio.run/##S9ZNT07@/1@r2FYJiFWTVYtVDVWSdUqjLS1jbavVDYwMjNRrrdM0MvNKtEo0qwtKS4o1kpJzCzRKtY10SnSKC4qAMmlgXrGOsYlOsaamPVBRckZikYaxmaZOiVWppnWtErUN/A9UpJCbmJmnoclVzcWZpqGUkZqlpGkNZgKtMICxYTTQczG09GEM1b0IcnntfwA "C (gcc) – Try It Online")
[Answer]
# Java 10, 128 bytes
```
s->{var t="s->{var t=%c%s%1$c;t=t.format(t,34,t);return t.equals(s)?2020:0+s;}";t=t.format(t,34,t);return t.equals(s)?2020:0+s;}
```
[Try it online.](https://tio.run/##rZDPSsNAEIfveYohNLDBdonVk0v0CayHHq2HyXYrmyabujMJSMmzx40G9CKh0Msyf76B77cldrgq98dBV0gEz2jdOQKwjo0/oDawGVuAl6I0mkGLLXvr3oFSFeZ9FB5iZKthAw5yGGj1eO7QA@fxb5nohJLbhVacszw0vkYWvLy7X3KqvOHWO2BpPlqsSFD6tM7W2UN2Q6qPL74Y1Oh0aosqOE1qXWP3UIdok/3rG2D6k2v7SWxq2bQsT2HFlRNOavHHfXeNHLvLg8Tp9xf/rziisxAb4lkICz3LTEAf9cMX)
**Explanation:**
[quine](/questions/tagged/quine "show questions tagged 'quine'") part of the explanation:
* `var t` contains the unformatted source code
* `%s` is used to input this String into itself with `t.format(...)`
* `%c`, `%1$c`, and the `34` are used to format the double quotes
* `t.format(t,34,t)` puts it all together
Challenge part of the explanation:
* `t.equals(s)` checks if the input-String is equal to the source code
* `?2020`: if it is, return `2020` as result
* `:0+s`: if not, return the input-String with a prepended 0 as result instead
[Answer]
# [Pyth](https://github.com/isaacg1/pyth), ~~26~~ 23 bytes
Outputs 2020 if the input matches the program, otherwise the input concatenated to itself 2020 time (eg. ab becomes ababab...ababab)
```
*2020|qjN B"*2020|qjN B
```
[Try it online!](https://tio.run/##K6gsyfj/X8vIwMigpjDLT8FJCYn9/7@SkhIOOaDMv/yCksz8vOL/uikA "Pyth – Try It Online")
## Explanation
```
*2020|qjN B"*2020|qjN B
          B"*2020|qjN B : Evaluates to ("*2020|qjN B", "*2020|qjN B")
       jN               : join with '"' as seperator (will be source code)
     |q                 : True if source is equal to input else input
*2020                   : Multiply by 2020 (i.e. True -> 2020, input -> 2020 * input)
```
---
# [Pyth](https://github.com/isaacg1/pyth), 21 bytes
Not sure if the following solution is valid, it will only work if the year is 2020. 
```
*.d3|qjN B"*.d3|qjN B
```
[Try it online!](https://tio.run/##K6gsyfj/X0svxbimMMtPwUkJwfz/X0lJCasMUPxffkFJZn5e8X/dFAA "Pyth – Try It Online")
[Answer]
# [J](http://jsoftware.com/), 56 bytes
```
".a=.}:0 :0
echo@>2020[^:(]-:'".a=.}:0 :0',LF,a&[)1!:1[3
```
[Try it online!](https://tio.run/##y/r/X0kv0Vav1spAwcqAKzU5I9/BzsjAyCA6zkojVtdKHUlWXcfHTSdRLVrTUNHKMNqYfJ0A "J – Try It Online")
A full program. Unless provided with itself prints each character on a separate line.
[Answer]
# [Japt](https://github.com/ETHproductions/japt), 24 bytes
```
OvA="¶`OvA=`+Q+A?2020:U³
```
[Try it online!](https://tio.run/##y0osKPn/37/M0Vbp0LYEEJ2gHajtaG9kYGRgFXpo8///6rgl1QE "Japt – Try It Online")
## Explanation
Outputs 2020 if the input matches the program, otherwise the input 3 times (eg. ab becomes ababab)
```
OvA="¶`OvA=`+Q+A?2020:U³
  A="¶`OvA=`+Q+A?2020:U³  // Set value of A to "¶`OvA=`+Q+A?2020:U³"
Ov                        // Evaluate A as japt code
      `OvA=`+Q+A          // Concatenate "OvA=", '"' and A (Q = '"')
     ¶          ?2020:U³  // If equal to input then 2020 else input concatenated to itself 3 times
```
]