text:
A "cheating" quine
Long-time lurker, first-time poster. So here goes.
In the Wikipedia page for quine, it says that "a quine is considered to be 'cheating' if it looks at its own source code." Your task is to make one of these "cheating quines" that reads its own source code.
This is code-golf, so the shortest code in bytes - in each language - wins. This means that a 5-byte Pyth script would not beat a 21-byte Python script - but a 15-byte Python script would.
You must use file I/O to read the source code, so the following JavaScript code, taken from the official Wikipedia page, is invalid:
function a() {
    document.write(a, "a()");
}
a()

It must access the source code of the file on disk.
You are not allowed to specify the file name. You must make it detect the filename itself.
Everyone clear? Go!

Is it allowed to specify the name of the file that the program is run in? How should that be scored?

Is a trailing newlines not present in the original file allowed?

@isaacg IMHO That's not a quine, since it is not the source code.

You should state a requirement that it determine the actual filename instead of assuming a hard-coded string for the source location.

I agree with @feersum though, that requiring a specific file name makes this challenge way to trivial.

@isaacg No, it isn't. I'll add that to the OP

Can we assume that (for compiled languages) the source code is in the same folder (i.e. we can just add ".cpp" or ".hs" to arg[0] to get the source).

@HEGX64 Sure, that makes sense.

APL uses a workspace to store and execute code. May I read the program code from the workspace? The program will not contain its own name.

@Adám I'm not sure how this workspace thing works, but what I'm going for is reading the program code from the filesystem. If it does that, great.

@TheInitializer The workspace is already fully loaded into memory before the command is given to a program to run. In that sense, the workspace is APL's virtual "file" system.

@Adám It seems fine I guess.

The challenge could have attracted by far more creative solutions without this restriction to source file reading from disk. All languages without disk access are excluded, for example. And all clever tricks on how to break some interpreter restriction ...

@Philippos Probably true, but to be fair I did write this problem when I was 13

For a 13 year old, this is quite a nice challenge, I admit. (-:

Zsh, 4 bytes
<$0

The Z shell has feline functionalities built in. The fourth character is a linefeed.
Try it online!
The code does not depend in any way on the file name; it works even if the file name contains special character, such as spaces or newlines.
Test run
$ cat "my quine.sh"
<$0
$ zsh "my quine.sh"
<$0
$ diff -s <(zsh "my quine.sh") <(cat "my quine.sh")
Files /dev/fd/63 and /dev/fd/62 are identical

feline functionalities :)

Bash, 6 bytes
cat $0

Basically.

Why was this down voted? It does exactly what the program asked for.

Doesn't cat append a trailing newline? So this is 7 bytes?

It does not print a newline.

cat does not append a newline (at least on my system).

@isaacg cat prints the content of the supplied file byte per byte.

Note that #!cat in a file also works for a cheating quine. But not when the file is called with bash.

@LukStorms That's a good point. I wonder if that is valid...

Not sure. It does feel like a bigger cheat.

@LukStorms it would mean that I could beat Pyth though (mwahahaha). I'll ask chat what they think

@LukStorms But wouldn't this be a cat solution then, instead of a bash solution? And cat does not really qualify as programming language

@fschmengler I'd say it's a sh solution, and cat is just one of many possible standard system commands in a sh shebang.

@Sparr: On my system, #! works even if sh doesn't exist (but you have to use the full path).

@Joshua sure, because #! also exists in whatever shell you're using to run the script. It's not just a sh directive.

@Sparr: I discovered it's in the kernel on my system.

Will this work if the file is named -e ?

@fschmengler & Joshua.  Now that I readup on the shebang. It seems when it's in a script on a unix-like system it's called by the program loader of the system. So if you run a script with only a she-banged line then you can't call it a bash script.

@MarkPlotnick I have no idea how you would run a shell script named this from the command line. You can't escape the dash with a backslash.

If the file name starts with a dash, you'd have to call the script as bash ./-e, which will still work, since this is the argument that gets passed to Bash. (Without quotes, $0 won't handles whitespace in the file name though.)

@LukStorms #!cat only works if your current directory is /bin. I wonder whether a solution is allowed to make such requirements.

@MarkPlotnick If the file is named -e and executed like this execl("-e", "-e", NULL);, then bash will in fact think -e is an option rather than a file name. But if the script is invoked from a bash shell, I am not sure you can get bash to invoke the script without passing a path to the file.

@kasperd Also depends on your $PATH variable? PATH normally has /usr/bin, which includes cat.

@LukStorms Scanning the PATH is done by user mode library code, but #! is handled by the kernel and doesn't take PATH into account. If you want a #! line to use PATH it is usually done by taking advantage of an intermediate program like for example #!/usr/bin/env python, but that's not very useful for code golf.

@kasperd Ok. I had only tested it in cygwin, which doesn't have a problem with it. But on a linux it's indeed a problem. Not that it matters, it was already discussed that it wouldn't count as a bash script.

@MarkPlotnick Naming the file "-e" works fine on bash, zsh and sh for me.

Not pure bash, it needs some other executable, namely cat, present and findable in the $PATH. However, bash does the interpretation logic, and if cat is present, it can be assumed as a command available to bash.

@GolarRamblar Most bash submissions assume coreutils are available.

naming the file -e works for me on msys2

tried to name the file -e and execute it using (bash|sh|zsh) -- -e and it failed with all of them

UNIX executable loader, 10 bytes
#!/bin/cat

If you don't care about spam on standard error, you can make it one byte shorter:
#!/bin/dd

I like this.  Not sure if it qualifies as a "language," though.

Perhaps cheating a bit, but couldn't you rename your bin folder and the cat program to shorten the path?

I'm not suggesting you do btw. I'm suggesting you could

@Kevin The "language" (that is, interpreter) is cat. And I guess if you want to be very specific, a cat program simply prints itself, and is compatible with every file format in existence :)

@JamesWebster sudo install /bin/cat /c. Y'know, just in case /bin isn't on the root filesystem. Gotta have that cat in singleuser…

@l0b0: The "language" here is not cat. The interpreter we play with here is within the kernel (e.g., Linux), which reads the first two bytes (magic bytes) of a file given to it in order to execute it, and if it finds them to be #!, it continues to read the line to get a path of another executable which it will then execute, passing the file's path as an argument to it. The interpreter here is not cat, but part of the kernel. cat is just invoked after the kernel interpreted the first line, and then just does the file I/O. Here it is the same as with the bash-answer (cat $0) above.

*BSD needs a newline.

C, 52
s[99];main(){read(open(__FILE__,0),s,99);printf(s);}

Of course, this reads the source code and not the compiled program - I assume that's within spec.

You could use printf instead of puts to avoid a trailing newline.

@feersum yes, good catch

@downvoter ... you know ... just curious...

@DigitalTrauma It's because of your avatar, of course

Actually, puts can be used, you just need to read fewer characters.

You are assuming s is initialized with NUL characters. Is that guaranteed to be the case?

@kasperd Yes, guaranteed by C89

Save two bytes: s[50];main(){read(open(__FILE__,0),s,50);puts(s);} by reading only 50 characters you skip the possible newline and can use puts instead of printf.

If you don't want to edit that in, can I post it as a new answer?

@MDXF Normally such a trivial difference doesn't warrant a new answer, so I wouldn't encourage it.  I can't stop you though ;-).  FWIW, if you use puts() then the extra newline will mean your source must also end in a newline, making it 51 bytes.

@DigitalTrauma Still a byte less... :D

Vyxal 2.4.0, 50 bytes
`\");VY_print(chr(96)+code.split('\n')[3][15:-4])#

Vyxal doesn't have a way to read files, but in v2.4.0 and prior, there was an ACE exploit that allowed for arbitrary python to be executed.

The ACE:
Vyxal is a transpiled language, meaning that every command in a program is converted to some python code, and then all of the python code is combined together and executed.
When pushing a string, all that was done to the string in transpilation was changing " to \\\", then appending it to the stack. This meant that a string \"); # would become \\");#. On its own, this means nothing, but when considered in the transpiled code, it is much more useful.
When viewing the transpiled code (which you can do for any Vyxal program using the c flag), you can see that the snippet `\\"); # is transpiled to the following python code:
stack.append("\\"); #\n")

Instead of pushing the string that we told it to, it simply pushed \, followed by a comment. In theory, we could put any python code between the ; and the #, which is what we do in this program.

The program:
In this program, the payload (the python code that we actually care about) is the following:
VY_print(chr(96)+code.split('\n')[3][15:-4])

This has several parts to it, so lets pick it apart bit by bit.
VY_print is the printing function that is defined internally in Vyxal. I used this function instead of print because it disables the implicit output that Vyxal normally has. This prints the final string, which will hopefully be the same as the program.
When the program is transpiled, the transpiled code is saved in the code variable. This variable is used in the program to read the source code, which makes this a cheating quine.
However, the code variable also contains a header that initializes a few variables, such as the stack. To combat this, we split the code on newlines and get only the fourth line, which is where our code is.
Unfortunately, this line also has the stack.append..., and the comment at the end, neither of which are part of our quine. Because of this, we need to take only the 16th through 5th-to-last characters in the string, which we do with [15:-4].
Finally, our code has a backtick at the beginning to start the string, so we add one to the beginning of the output with chr(96), since the ASCII value of ` is 96.

Wooooo crappy programming ftw!

Perl, 15 bytes
open 0;print<0>

Saved 3 bytes thanks to @ThisSuitIsBlackNot!

You can save 3 bytes with open 0;print<0>

@ThisSuitIsBlackNot I was sure there was a shorter way to do it, but I couldn't for the life of my work it out... Using 0 assumes $0 then?

Yep. See perldoc -f open: "As a shortcut a one-argument call takes the filename from the global scalar variable of the same name as the filehandle: $ARTICLE = 100; open(ARTICLE) or die "Can't find article $ARTICLE: $!\n";"

Perl 6, 20 bytes
print slurp $?FILE

I haven't worked with Perl 6 very long so I'm not sure if there are any tricks to make this shorter.

can you remove the second space?

@Eevee nope, it gets angry

PHP, 21 Bytes
<?=file(__FILE__)[0];

file reads a file line by line into an array and the file only has one line. This saves a byte in comparison to readfile(__FILE__).

Notice that this only works from PHP5.4 and up, which was the first version to support array de-referentiation. But other than that, quite a nice answer!

readfile is also 21: <?readfile(__FILE__);.

Right, it doesn't need <?=

Python 2, 32 bytes
There's a newline at the end of the file.
print open(__file__).readline()

Python 3, 33 bytes
There's a newline at the end of the file.
print(open(__file__).readline())

Thanks to feersum for catching a problem and supplying __file__, Loovjo for a new approach to the Python 2 solution that saved 17 bytes, and Skyler for a solution that saved yet another byte and worked in both Python 2 and 3 (pending print being a function in Python 3)!
Doc link for readline

This would also save 2 bytes in python3 because you could discard the end parameter.

@Skyler You're absolutely correct.

How does this work in Python 3, which needs parens for print?

Python 3 should be print(open(__file__).readline()) followed by a newline.

Your Python 3 example says Python 2 rather than Python 3

@TheInitializer fixed, thanks

You can use print(open(__file__).read(30)) to save 3 Bytes

@nTerior only two; readline becomes read, and 30 gets added. That is the same idea as xsot's answer, but applied to 3.x where it works just as well. The number used is one less than the file length (assuming single-character newlines) because the last character (the newline) will come from print's default formatting.

osascript (AppleScript from the command line), 40 33 32 bytes
(read path to me)'s paragraph 1

Executing on a file called a with osascript a.
Gets the first paragraph (line) of the file and prints it to STDOUT with a trailing newline, therefore the newline in the code.

See my edit to the OP

Working on getting it to work.

read path to me seems to work for me.  El Cap.

Didn't see this, but this is the way I ended up doing it. :P Thanks, @DigitalTrauma. EDIT: trailing newlines must be considered, so you add the newline and use paragraphs 1.

Python 2.7, 30 bytes
print open(__file__).read(29)

Edit: Just to be clear, the code above is supposed to have a newline at the end as the 30th byte. I'm not familiar with markdown enough to figure out how to display it in the code block.
I'm using the same trick here as the one in my C submission. This reads the whole source file excluding the trailing newline to account for the additional newline which print will append to the output.

Does this run into the same problem with the trailing newline that the other submission did?

No. There's supposed to be a trailing newline that makes the 30th byte in the source code but I can't get it to display in the code block. My submission works because it reads the first 29 bytes of the source code so that the newline from print won't be extraneous.

That's not what the comma does. It appends a space instead of a newline.

could use ␤ to indicate a semantically-important newline

Batch, 9 8 Bytes
@type %0

Saved a byte thanks to @Joshua

You can save a byte by eliminating the trailing %.

AutoIt, 34 bytes
Outputs itself to the clipboard:
ClipPut(FileRead(@ScriptFullPath))

Ruby, 14
$>.<<IO.read$0

Nice use of . to avoid parentheses

Go, 111 105 bytes
package main
import("io"
."os"
."runtime")
func main(){_,p,_,_:=Caller(0)
f,_:=Open(p)
io.Copy(Stdout,f)}

My first code-golf in Go – just a few tricks you can use here I guess.

There is already an answer in Go - does this use the same method?

@VoteToClose: I realise it, I was inspired by the other one indeed, but used package renaming here (cheap trick) as well as different technique for opening and piping file to stdout. Saved me a massive 22 bytes ;-)

The method is actually a bit different, good one!

C, 31 bytes
main(){system("cat "__FILE__);}

The bash solution is so short, so why not base a C solution on it?

C, 49 bytes
s[];main(){read(open(__FILE__,0),s,48);puts(s);}

Edit: To clarify, the 49th byte is a newline.
This reads the source code minus the newline at the end to account for the newline which puts will append to the end of the output.

This code invokes undefined behavior twice.

Well, this is code golf. My code produces the desired output so it's a valid submission.

@xsot In that case, you should probably list the compiler version + options; otherwise this might not be verifiable.

It should work for most versions of gcc without any  compilation option.

You'll also have to specify the filesystem it's on in this case. Some filesystems may not ensure the first read() call returns all 48 bytes (a successful read will read between 1 byte and the number of bytes passed).

If having undefined behavior is permitted as long as you can have some compiler that produces the desired output on some machine during some phase of the moon, then I propose int main(void) { *0; } as a solution.  After all, the standard would permit an implementation that compiles that into a program that solves the problem.  I'd be fine with using implementation-dependent behavior as long as you specify the compiler, but with undefined behavior, you can't even guarantee that you wouldn't get ten different answers if you ran that ten times in a row on the same machine.

@Ray Sure, you could write a compiler that makes int main(void) { *0; } as a solution, but 1 you'd have to mark solutions using it as noncompeting 'cause it'd be newer than the challenge; 2 you'd be downvoted into oblivion; 3 it's really boring.

@MDXF I wasn't seriously suggesting that we write that solution.  I was arguing against allowing undefined behavior. int main() {*0;} might work even on existing compilers, since it contains undefined behavior. Similarly, xsot's solution might work on existing compilers, since it contains undefined behavior. Neither one is guaranteed to solve the problem. (Although xsot's is admittedly more likely to do so, it might just as easily crash). My actual argument is that we should permit solutions that depend on implementation-dependent or unspecified behavior, but not undefined behavior.

@Ray So it would've been better practice if he'd included in the header (gcc) or (clang) or (tcc), but the truth is, most smart compilers these days will perform the same for some types of undefined behavior. This is one.

@MDXF That would be useful if it was implementation-dependent or unspecified behavior.  But if it's undefined, it might work one run and crash the next, even with the same compiler.  He's writing to an array with no memory allocated to it.  This isn't a purely theoretical situation; that might very well crash depending on what lives in that memory.  (Though the fact that it's declared in file scope makes it a bit less likely.)

PowerShell, 39 36 31 25 Bytes
About as tight as I can get it:
gc $MyInvocation.MyCommand.Path | oh
Backed by popular demand this has been changed to:
gc $PSCommandPath|echo -n

prints to host shell current standard output.

gc $MyInvocation.MyCommand.Path is enough. It will automatically print it out.

its not guaranteed to especially if the script is running silently

Haha yea I don't care. I was going to post if no one else had a PowerShell answer. But I forgot that gc was an alias and was just going to use cat, so you had a byte on me there anyway.

Uh, I wouldn't be that strict about it. Otherwise every PS answer would explicitly have to pipe to the host shell, but that's up to you...

You could instead use gc $PSCommandPath for 17 bytes. The problem I see is that this spits out a newline (which doesn't exist in the source). It's ambiguous now if trailing newline is OK or not ... depending upon how that rules, we may need to do something tricksy like gc $PSCommandPath|write-host -n for 31 bytes.

Also, welcome to PPCG!

hahaha yes not sure on the ruling on that, hopefully OP will answer that...thanks team!

Mathematica, 16 bytes
FilePrint@$Input

Run it in script mode.

I've been using Mathematica for many years and had never even heard of script mode.

Haskell, 63 bytes
For science!
import System.Environment
main=getProgName>>=readFile>>=putStr

Only works with the runhaskell command. Very cool though

><>, 13 Bytes
0:0go:c=?;1+!

Tested both on the online and offline interpreters. The g command is the closest to being able to read from the source file and if it doesn't count for the purpose of this challenge I'll mark my entry non-competing; I do believe it normally considered "cheating" for quines.
Try it online.

Ruby, 15 bytes
$><<IO.read($0)

Source: https://stackoverflow.com/questions/2474861/shortest-ruby-quine

I've converted this to a community wiki because it isn't your own work.

Pyth, 25 bytes
$import sys$h'e$sys.argv

This reads its file name. Essentially, it looks up argv, opens the file corresponding to its last argument, and prints its first line.

Can't you just do h'$__file__$?

@kirbyfan64sos That gives me the error NameError: name '__file__' is not defined. Pyth is compiled to Python, and then the resultant string is executed. So I wouldn't expect that to work.

Haskell, 49 bytes
{-#LANGUAGE CPP#-}main=putStr=<<readFile __FILE__

Try it online!
(GHC) Haskell has an extension to use the C preprocessor (commonly used for portability between versions and architectures.) Hopefully self-explanatory.

Rust, 45 bytes
fn main(){print!("{}",include_str!(file!()))}

Try it online!
The file macro expands to the file it's invoked in's file path, the include_str macro expands to a string literal containing the contents of the file at the specified path, and the print macro prints.

HTML with JavaScript, 115 bytes (doesn't really count)
<!DOCTYPE html><html><title>x</title><script>alert(new XMLSerializer().serializeToString(document))</script></html>

Does this count? I don't mind, it was fun :)
Technically it doesn't open a file. It's also a well-formed HTML5 document. The XMLSerializer was the only tool which also returned the DOCTYPE portion, but is non-standard. Still, it works on chrome and firefox, and I bet other browsers.
And as a bonus:
JavaScript, 41 bytes
alert(document.currentScript.textContent)

Remove ";" at the end, save 1 byte :)

@ЕвгенийНовиков You're right, not sure why I left that in back then. It seems like I didn't count it though.

You don't need the <title>x</title>

@VFDan A well-formed standalone HTML document needs a title of at least one character, even if browsers will make do without it. I thought it was a nice bit of trivia to display in this silly answer.

Are <head> and <body> not needed for well-formed HTML?

@Somebody Nope. The head element implicitly begins when a tag that should be inside the head is encountered, and the body implicitly begins when a tag that is only allowed in the body and not the head is encountered. Even the html tags are optional, I guess I didn't know that in 2015. Though you should probably always put the opening html tag so you can specify a lang attribute.

Java 8, 133 125 Bytes (or 150 142 slightly cleaner)
Based on @VoteToClose's answer but choosing Files.copy and thus avoiding the intermediate String creation needed to call System.out:
import java.nio.file.*;interface A{static void main(String[]a) throws Exception{Files.copy(Paths.get(A.class.getName()+".java"),System.out);}}

or hard-coding the class-name even more:
import java.nio.file.*;interface A{static void main(String[] a)throws Exception{Files.copy(Paths.get("A.java"),System.out);}}

Cleaned up:
import java.nio.file.*;

class A {
    public static void main(String[] a) throws Exception {
        Files.copy(Paths.get("A.java"), System.out);
    }
}

Welcome to PPCG! (Programming Puzzles and Code Golf). Nice first answer!

This is almost invalid, as we were told to not hardcode a filename.

You are not allowed to assume the file extension is .java.

Node.js, 66 63 bytes
p=process;p.stdout.write(require('fs').readFileSync(p.argv[1]))

Doesn't use console.log, which appends a newline.

You can save a few bytes by using the synchronous api: p=process;p.stdout.write(require('fs').readFileSync(p.argv[1]))

Why not console.log(require('fs').readFileSync(process.argv[1]))\n for 57 bytes?

This doesn't always work. Say the file is named test.js. It is valid to invoke it by running node test, which will cause this to throw an error.

Go, 133 Bytes

Everyone clear? Go!

package main
import("fmt"
"io/ioutil"
"runtime")
func main(){_,f,_,_:=runtime.Caller(0)
s,_:=ioutil.ReadFile(f)
fmt.Print(string(s))}

This inspired me to write my own (and the very first) code-golf solution in Go. Looking for some general tricks, you can easily go down to 123 characters here by applying single-letter names for packages, for example r"runtime".

, 2 chars / 6 bytes
ℹ⬮

Try it here (Firefox only).
The ℹ function both returns and pushes to the stack the source code. There is automatic outputting, so the contents of the stack will be outputted. Therefore, the source code will be outputted.

Does this read the source file, or a copy of the source code?

Here's the line in the interpreter source with the function. It's not really a file-based interpreter, but it reads the textarea value (aka the code).

You made this change an hour ago. Would your code have worked with the previous version?

@Dennis I actually made that change before seeing this challenge. It was because I didn't like the original output format.

@molarmanful Nevertheless, according to site policy, this is a noncompeting answer due to the fact that it uses a version of your language created after the challenge was posted.

Alright, added disclaimer.

F#, 54 Bytes
printf"%s"(System.IO.File.ReadAllText __SOURCE_FILE__)

Usage:
fsi --exec a.fsx

Perl 5, 15 13 bytes
Credit to the Bash solution for inspiring this:
print`cat $0`

EDIT: Don't need the semi-colon or first space.

Not pure perl, it needs some other executable, namely cat, present and findable in the $PATH. But if it is present, it can be assumed as just a command available to perl, so why not.

Scala(2.10), 101 bytes
import scala.reflect.io.File;object A extends App{print(File(getClass.getName.head+".scala").slurp)}

Similar to the Java and C# answers.  The only "interesting" parts here are the .head to drop the $ from the class name and the slurp method (which I'd never seen before) to read the file in as a String.

Cool, I didn't know that method existed in scala. Mine is slightly longer using groovy.

You are not allowed to assume the file extension is .scala.

Python 2, 27 bytes
print next(open(__file__))

Python 3, 28 bytes
print(next(open(__file__)))

Byte count includes new line.

My first contribution: harsh criticism welcomed.

Sad to see this one this far down while worse-scoring Python attempts are higher. As a historical note, this requires Python 2.6 and up; even 2.6 was past EOL at the time, but still.

Raku, 17 bytes
$?LANG.orig.print

Try it online!
This relies on some compiler internals.

Java - 214 194
import java.io.*;class Q{Q(){try{System.out.print(new BufferedReader(new FileReader(getClass().getName()+".java")).readLine());}catch(Exception e){}}public static void main(String[]a){new Q();}}

Reduced a lot with using @VoteToClose method of finding the filename for java.
Readable version:
import java.io.*;

class Q {
        Q() {
                try {
                        System.out.print(new BufferedReader(new FileReader(getClass().getName()+".java")).readLine());
                } catch(Exception e) {}
        }
        public static void main(String[] a) {
                new Q();
        }
}

NOTE: The readable version doesn't actually work, it just reads the first line. Just to show what the code is doing

I posted a Java answer as one of the first answers. :P But, just in case you want to narrow this down more, you can remove public from the class declaration. Also, I might steal your method of getting a class name for my answer. ;)

You are not allowed to assume the file extension is .java.

@Makonede Are you sure? I get an error trying to compile anything that isn't .java

@Cruncher It doesn't matter, it's still specifying part of the file name.

C#, 153 bytes
class A{static void Main(){new A();}A([System.Runtime.CompilerServices.CallerFilePath]string s=""){System.Console.Write(System.IO.File.ReadAllText(s));}}
Readable version:
class A
{
    static void Main()
    {
        new A();
    }

    A([System.Runtime.CompilerServices.CallerFilePath] string s = "")
    {
        System.Console.Write(System.IO.File.ReadAllText(s));
    }
}

Thanks to @Johnbot for the idea to use CallerFilePathAttribute, which avoids any kind of name hardcoding!

I do smell elements of my answer in this! Well done! +1 And welcome to the community!

It's possible to get the source file name using the CallerFilePathAttribute.

You save 26 characters with string s instead of string sourceFilePath.

I think you can save another 8 bytes if you add using System; at the top and omit System. in all namespace qualifiers (at least I think it worked that way, it's been some years since I've worked with C#)

@Comintern - good catch, thanks. That's what I get for doing it in a hurry.

@hoffmale - that doesn't actually work. The using clause doesn't import sub-namespaces, just classes. So it would let me replace System.Console with just Console, but not System.IO with just IO. I could use an alias, using S = System; and shorten the uses of it, but that ends up being a wash.

ah, so that was only for classes... thanks for clarifying ^^

JavaScript (node.js), 65
with(process)require('fs').createReadStream(argv[1]).pipe(stdout)

Perl, 9 bytes
#!/bin/dd

Perl allows you to change the parser while the file's being read. One thing you can do is to change the program that parses the file entirely via the use of #! on the first line; this feature was intended to allow the use of Perl to fix a system on which shebangs didn't work correctly. dd with no parameters copies standard input to standard output (followed by some statistics on standard error which shouldn't matter), thus is a suitable program to use for a cheating-quine (because Perl reloads the file from disk to give to dd.)

That is not perl. The kernel reads the first two bytes and interprets them, finds #!' and thus continues to read the line, finds /bin/ddand thus launches/bin/dd, given the file as argument to dd`. NO PERL INVOLVED AT ALL.

@GolarRamblar: It is Perl. You can run perl followed by the filename, and perl itself will do the #! translation. It uses slightly different rules from the kernel for interpreting #! lines, in fact. (Perl originally added this feature so that if you were using an operating system, like Windows or DOS, that does not support #! lines, you could nonetheless use #! scripts by setting Perl as the interpreter for their file type.)

Python 3, 28 35 32 29 21 bytes
lambda:open(__file__)

Try it online! File objects are iterable, and output in a singleton iterable is allowed.
lambda:open(__file__)  # full program
lambda:                # define function taking no arguments which returns...
       open(        )  # file at path...
            __file__   # current script path

This doesn't work unfortunately as print will output a trailing newline not present in the original code.

You can suppress the newline by passing end='' parameter to print: Try it online!

Oh, I actually knew that but didn't know trailing newlines weren't allowed. I'll fix that.

This doesn't work. In order for the file I/O to be meaningful, the code has to be run from a file; while a function could be run at the interpreter prompt and its output would be displayed, a) it would display as a string representation and not formatted output; b) __file__ would not be defined at the REPL and even if it were it couldn't name a file that doesn't exist.

The previous version, print(*open(__file__),end='') works fine and, unlike the competitors, doesn't require a trailing newline. However, that still doesn't beat Oddthinking's 28-byte (27 in 2.x) solution.

Javascript (Babel Node), 74 72 bytes
Thanks to Kyle Slattery for posting his answer about __filename.
Also, thanks to Makonede for saving 2 bytes and making my answer correct.
require('fs').readFile(__filename,'utf8',(e,d)=>process.stdout.write(d))

Welcome to CG&CC! As noted previously, we require solutions to attempt to optimize for a challenge's scoring criterion; this is a [tag:code-golf] challenge so your code should be as short as you can make it. Some steps you could take might be to remove unnecessary whitespace (and semicolons? I do not actually know JS) and use shorter variable names. Also consider posting the score of your solution, and a link to an online interpreter (such as Try It Online).

You should also check out our Welcome Page to get a better idea of what we recommend and expect for answers.

thats what im going to do thank you

-2 by removing whitespace, removing braces, and renaming variables: require('fs').readfile(__filename,'utf8',(e,d)=>process.stdout.write(d)). Also, your answer is currently invalid, as it prints a trailing newline.

i missed that point, also thanks for your help man

Python, 22 bytes
input(*open(__file__))
Attempt This Online!

This requires the user to terminate the program (by hitting Enter and having the output discarded, or otherwise aborting it), but I tried it with shell redirection and it does get the right output, without adding an extra newline or anything.

Shell + xargs, 27 bytes
xargs -0a/proc/self/cmdline
Attempt This Online!
On Linux, the file /proc/self/cmdline contains the arguments provided to the current command, including the command's name itself, separated by null bytes. In this case, the command is xargs, and the argument is -0a/proc/self/cmdline.
xargs -0 splits its input on null bytes, and passes them to another command. When a second command isn't specified, it defaults to echo. The -a option makes xargs read from a file instead of STDIN.
I'm not 100% sure if this is valid, because strictly speaking the source code of the shell script itself isn't in /proc/self/cmdline, but it certainly isn't a proper quine, so I think it morally ought to be allowed.

*nix interpreter directive, 10 bytes
#!/bin/cat

Shebang (#!) abuse. The shebang causes the "code" to be "interpreted" using cat, which prints out the content of the file.
EDIT: Someone else came up with it before me.

Some systems require a line terminator, eg. OpenBSD.

JavaScript (Node.js), 56 bytes
with(require('fs'))writeSync(1,readFileSync(__filename))

Try it online!

C (Win32), 36 bytes
main(){CopyFileA(__FILE__,"CON",0);}

CopyFile makes the challenge easier in Win32 than in POSIX or ISO C, that's for sure. You however need to call the compiler with stdcall as its default calling convention.

VBScript, 67 bytes
CreateObject("WScript.Shell").Run "cmd /K type "&Wscript.ScriptName

Aubergine,  22 bytes,  noncompeting
The tab character at the end signals end of file, and the interpreters all crash without it. It's cool that this challenge showed up on my radar this week since I just finished golfing this for the wiki.
-a1+a1=oA=Bi-BA:bB=ia

I'll explain how it works later.  It does not use file I/O but it very much does read its listing, and it is definitely cheating.

Groovy 92 bytes
Shorter than the other groovy answer, in addition to being filename agnostic.
print new Error().stackTrace*.fileName.collect{it?new File(it):null}.find{it?.exists()}.text

No newline at end of file.

Vitsy, 4 bytes
This language feature is newer than this question, but not made for this question.
iG`Z

i     Grab input. Since there is no input, it pushes -1 to the stack.
 G    Get the class name of the referenced class. -1 refers to the current class.
  `   Read the file under the name of the stack's contents and push all of it to the stack.
   Z  Output everything in the stack.
As of November 24, class commands allow for referencing other programs accessible by disk, or 'classes'. Normally, it'd be used something like this:
00k

;u someothervitsyfile
Where I execute the 0th line (the first line) of the 0th index of the uses list ('someothervitsyfile'). I can get its name with G like so:
0GZ

;u someothervitsyfile
And, if I have the name, I can get its contents like so:
0G`Z

;u someothervitsyfile
But the special cases of this are -2 and -1, where -2 references the superclass (as defined by ;e) and -1 references the current class.
So, to get the name of the current class, I use -1, get its name, and, with its name being the only thing in the stack, I pull its contents with `.
Very fancy.
You cannot try this online, as it has been disabled to prevent reading server files.

Mouse-2002, 8 bytes
Expects to be put in a file called MOUSE.001. (Files with the names MOUSE.nnn are the only files Mouse knows how to perform I/O on. I didn't write the interpreter.)
If the EOF char at the end of the file, which is printed to the terminal, crashes your terminal, it's not my fault and I consider this a feature, not a bug.
(1 &F!')

Additionally, technically this is undefined behaviour (though most of Mouse is undefined except in practice) because it promises that the file's length is at least as long as the while(true). If this hangs your system because it's a loop, save your work, run git commit && git push, and don't say I didn't warn you.

Lua, 31 Bytes
print(io.open(arg[1]):read'*a')

The Arg table contains the following in lua.
{Filename, Command Line Argument1, Command Line Argument 2, ...}

That seems to be more like {[-1]="Interpreter", [0]="Filename", [1]="Command Line Argument1, [2]="Command Line Argument 2"}. So you should read arg[0] instead.

SmileBASIC, 69 68 bytes
LOAD"PRG1:"+PRGNAME$(0),FALSE
PRGEDIT 1
FOR I=0 TO 3?PRGGET$();
NEXT

Load the program into slot 0 (the default slot), and run!
Explanation
LOAD"PRG1:"+PRGNAME$(0),FALSE  load the source code into program slot 1
PRGEDIT 1                      open program slot 1 for editing
FOR I=0 TO 3                   loop 3 times { (no newline here)
?PRGGET$();                      print line, supressing extra newline
NEXT                           }

The ,FALSE on LOAD is required to supress a confirmation dialogue. I wasn't sure if this was required so I threw it in anyways (seems like it should be).
The extra setup of loading the source code into the neighbouring slot is required as SmileBASIC can't read or write from the currently loaded source code for some reason (it clearly reads it to load it into the other slot, but whatever).
As the output format isn't specified, you might be able to get away with just using the first line and claiming the output is found on slot one (which is one tap away) for 29 bytes.

FALSE in SB just means 0, because SB doesn't have a boolean type. Conditionals (== != < > <= >= || &&) evaluate to 0 when false and 1 when true (with the exception of || and && which evaluate to 3 when the left term is a string; nobody knows why.) Any nonzero number is truthy, as well as all strings, even empty ones. NaN is always falsy and never equals itself. Arrays can't be compared though. Anyway, my point is, turn FALSE into 0 and save 4 characters. You could probably get away with allowing the loading screen but idk.

Thanks @snail'! That's exactly the kind of information I needed to get assimilated in golfing with SmileBASIC! I'll update my answer soon.

SmileBASIC, 26 bytes (newline at end)
Saw @redstarcoder 's answer and wanted to out-golf it. I'm not sorry.
?LOAD("TXT:"+PRGNAME$());

This exploits the fact that PRG is just a resource subtype of TXT (it's literally the same file format with a different icon) and loads the source file into a string. It's then simply printed.
I removed unneeded whitespace wherever the parser would let me, and put it all on one line for show. ? is just a shorthand for PRINT. The ; at the end ensures the PRINT doesn't add an extra newline. This one also doesn't disable the load dialog popup, but whatever.
If you remove the newline using a program that deletes the last character (since SB automatically adds a LF whenever you save through the editor) you can also remove the semicolon, bringing the answer down to 24 bytes. I didn't do this though, because I consider it kinda underhanded.

Being "kinda underhanded" is probably ok in a challenge called "A 'cheating' quine"

Node.js, 63 bytes
Uses the __filename global to obtain its file path as opposed to process.argv[1], which can be flawed:
require('fs').createReadStream(__filename).pipe(process.stdout)

GW-BASIC / Applesoft BASIC / IBM BASIC / Commodore BASIC,  6 bytes
1 LIST

Pretty simple. No matter where you loaded the program from or how much is in it, it will always print everything in the program buffer, including itself.

R, 44 bytes
cat(scan(sub(".*=","",commandArgs()[4]),""))

Prints to stderr as well. If that's not allowed this works for 46 bytes:
cat(readLines(sub(".*=","",commandArgs()[4])))

Run these from the command line using Rscript.

Burlesque - 25 bytes
With-IO
,%____FILE?rfQ

Disclaimer: I've just added ____FILE because I/O support is still very rudimentary and there was no way of detecting the name of the file. Otherwise this would have been impossible. I/O built-ins aren't available in default builds but can be activated by using ghc ... -DHAVE_IO_UNSAFE ....
Without-IO:
,#Q2 SH ~- ",#Q" \/ .+ sh

Explanation: Burlesque is nasty.
Actual explanation: #Q looks at its own source code and pushes the code that is left in the "execution pipeline" onto the stack. In otherwords: #Q pushes all the code that is to the right to the stack. However, #Q does not look at ALL the source code just what is left in the "execution pipeline of the current execution context":
blsq ) 2ro{#Qj}m[
{1 {j} 2 {j}}

The #Q here is only able to see the j due to the execution context.
On a side-note: Burlesque has other modifiers that allow you to modify code such as for example #q which allows you to overwrite the remaining code in the execution pipeline of the current execution context:
blsq ) 3 4 {?*}#q?+
12

{?*}#q overwrites the ?+ with ?*. With #J we can inject/delay a piece of code by appending it to the execution pipeline:
blsq ) 3 4 {J?*}#J?+
49

The #J here appends J?* to the ?+.

Hm, I'm not sure this satisfies "You must use file I/O to read the source code".

Oh, right. I should stop stopping prematurely while reading.

Meh. If it's allowed for APL to read code from "in-memory" then I can do that too ;)

Racket, 63 bytes
#lang racket
(display(file->string(find-system-path'run-file)))

Try it online!
Pretty straightforward - just finds the current file, reads it, and prints it back out.

Knight (C/AST, *nix), 50 49 bytes
\t represents a raw tab.
O`"cat `tr '\0' '\t'</proc/$PPID/cmdline|cut -f3`"
Doesn't work in the golfed interpreter for some reason, so no TIO.
Abuses the shell command built-in <backtick> and the standardized command line args for Knight, which is knight -f file.kn
/proc/$PPID/cmdline obtains the \0-separated command line arguments of the parent process (which is the knight interpreter itself), tr '\0' '\t' replaces \0 with \t, and cut -f3 takes the third tab-delimited argument. Then, we just cat the file and output the result.
A similar result can be done using the -e flag, but that doesn't read the source file from the disk (unless you count the cmdline file)
-1 byte using a raw tab over \t

PARI/GP, 18 bytes
print1(readstr[1])
Attempt This Online!
The function readstr reads every lines as strings form a file. When readstr takes no input, it reads the source file.

C (clang), 47 (46?) bytes
main(s){write(!!read(open(__FILE__,0),&s,47));}

Try it online!
This will corrupt the stack and segfault, but not before printing the correct output.
If executing in a terminal we can do 46 bytes printing to stdin:
main(s){write(!read(open(__FILE__,0),&s,46));}

Bash, 18 Bytes
history|tail -c18

Note: Technically this is not allowed because it gets history from memory, and not from disk.
 Bytes:
echo 'history|tail -c18' > quine
wc -c quine
18 quine

18 bytes (including the newline)
Explanation:
history gets the bash history from memory and tail grabs the last 18 characters. This is a more proper quine than cat $0 and #!/bin/cat because it includes the newline.
echo "$BASH_COMMAND" can be used to do the same thing for an extra 1 character.

I like that one, but it fails to obey the rule to read it's source from disk.

Tcl, 37 bytes
chan copy [open [info script]] stdout

The older, more self explanatory version (43 bytes):
puts -nonewline [read [open [info script]]]

Lua, 59 characters
print(io.open(debug.getinfo(1,'S').source:sub(2)):read'*a')

Sample run:
bash-4.3$ lua quine.lua
print(io.open(debug.getinfo(1,'S').source:sub(2)):read'*a')

C++, 93 bytes
#include <iostream>
#include <fstream>
main(){std::fstream f(__FILE__);std::cout<<f.rdbuf();}

I wanted to do a “pure” C++ version…and I have to say that it doesn't do too badly: it's down to 54 bytes if I can do without including the headers.

78

74

A Groovy 103 100 bytes!
Yes I know I'm evil
I stay in line with the other JVM answers (Java, Scala) to make this answer.
class X{static def main(String[]a){new X()}
def X(){print new File(getClass().name+'.groovy').text}}

Emacs Lisp (93 Bytes)
:; emacs -Q -script $0; exit
(find-file (nth 2 command-line-args))
(message (buffer-string))

The first line calls the program in your normal shell and exits (to prevent the rest also being evaluated). command-line-args will be a list of three strings, "emacs", "-scriptload" and the name of your file. find-file will open that file and make it the current buffer, so that (message (buffer-string)) will write it to stdout as -script redirects messages there.
It should be noted, that -Q may not be necessary if your Emacs doesn't print other messages during startup, so that the first line could be shortened to #!emacs -script, shortening this to 81 bytes, but as it is highly unlikely that init and site-lisp files produce 0 messages at all, this cannot be assumed.

APL, 8 bytes (non-competing)
APL does not use source files for single functions, rather a whole workspace (a machine-readable collection of token-representations) is saved and loaded, so I guess this is not allowed:
f
⎕CR'f'

(⎕CR is Character Representation) as the program reads its current definition in memory (the loaded workspace), which may have been modified from the source in the file.

Matlab, 32 bytes
disp(fileread([mfilename,'.m']))

You are not allowed to assume the file extension is .m.

@Makonede MATLAB files have have the ending .m, so it would make sense doing anything other than that. The challenge specifically says we have to read the file name, not the ending, and OP actually confirmed that we can use the file ending.

stacked, 11 bytes
program put

Try it here!
Outputs the program stored in the program variable. Simple!

HTML and Javascript, 88 Bytes
<head></head><body><svg onload="alert(document.documentElement.innerHTML)"></svg></body>

Had to add <head></head><body></svg></body> because that's what the browser outputs regardless of the original file.

#HTML and Javascript, 109 Bytes#
@Masterzagh, Actually browsers add html tag too. Sorry, Couldn't add a comment as I don't have enough reputation.

I tested it on firefox and chrome and neither added the html (at least on the alert which is what we're interested in).  @prathapareddy

Lua, 32 29 bytes
3 bytes saved thanks to Jonathan Frech
print(io.open(arg[0]):read())

Try it online!
How?
Lua uses the arg table to store it's arguments, the script name is always stored at index 0 of this table despite the fact there are no further arguments. After using this table to get the name of the file, printing it was as easy as opening the file and reading its content.

I think you can toss your variable and save three bytes.

It is interesting, how your script's file name is stored at 'index' zero, even though LUA is 1-indexed ... And it goes on: arg[-1] contains the language name ...

Perl 6 / POSIX shell, 16 bytes
run 'cat',$?FILE

Try it online!

CopyPasta Language, 32 bytes
But I think this is interesting enough to compete here.
CopyFile
TheFuckingCode
Pasta!

Copy the source code, display the clipboard, and stop the program.

Worthy of note: This language did not have an interpreter when you posted this, so it would have been invalid. As of rn, I have implemented an interpreter for the language, since the linked interpreter on the esolang is a dead link

Jelly u, 26 bytes
“open(sys.argv[2])”ŒV

Try it online!
Not encoded in Jelly's SBCS, because 1. by meta consensus on flags Jelly u is a different language from Jelly (so it's not like I'm handicapping myself or anything), 2. I'm having some difficulties deciding on what form of output would be valid for an SBCS Jelly cheating quine, and 3. I'm having some difficulties actually executing on the methods I've considered (note that that's not even shorter than this).
“open(sys.argv[2])”ŒV    Evaluate "open(sys.argv[2])" as Python, within Jelly's interpreter.py.

      sys.argv           Get the arguments with which this was invoked on the command line.
                         (jelly fu [whatever the file's called])
              [2]        Take the third argument,
 open(           )       and open the file at that location.

                   ŒV    Iterate through the file object, obtaining a Jelly string of its contents.

This can be encoded in the SBCS and be perfectly valid at the same time.

@Makonede It still presents the difficulty of taking SBCS-encoded file contents and outputting either the corresponding UTF-8 or the same bytes.

How about this: The output should look identical to the program. So the corresponding UTF-8.

...I was about to say "well guess what I already tried", but it turns out the apparent failure is an issue with TIO's bash rather than the solution itself. Glad I tried that again

05AB1E (legacy), 43 39 30 27 bytes
’ƒÛ(__£Ø__('Ë‚').Òœv[1])’.E

Try it online! I would've used the rewrite, if only I knew Elixir… Output doesn't contain the program, however it is the program in a singleton iterable object (a file). This is allowed.
’ƒÛ(__£Ø__('Ë‚').Òœv[1])’.E  # full program
’ƒÛ(__£Ø__('Ë‚').Òœv[1])’    # push "open(__import__('sys').argv[1])"...
                         .E  # evaluated as Python code
                             # implicit output

============================================================================

open(__import__('sys').argv[1])  # full Python program
open(                         )  # return file at path...
                           [1]   # second...
     __import__('sys').argv      # command-line argument

Note: This program assumes no command-line flags or extra arguments are passed. If this assumption is not allowed, it can be fixed at a cost of 1 byte by adding a - before the 1.

Julia 1.0, 29 26 bytes
print(readline(@__FILE__))

Try it online!

Processing, 48 bytes
print(loadStrings(getClass().getName()+".pde"));

I don't know Processing, but this looks like it wouldn't work if the file name didn't end in .pde.

The java answer sais , getClass().getName()+".java"
Also I don't know if there is a way of getting the extension,
you can get a list of filenames in a folder but it's not bulletproof either

Nim, 43 bytes
import os
echo readFile(paramStr(0)&".nim")

See my comment on the above answer. You are not allowed to assume the filename ends in .nim.

@Makonede The Nim compiler won’t compile a file that does not end in .nim.

JavaScript (Deno), 49 47 bytes
console.log(Deno.readFileSync(import.meta.url))

C, 31 bytes
main(){system("cat "__FILE__);}

Works perfectly...

Duplicate

Whoops — didn't see that one or the Bash solution it was based on. First attempt was to use exec(3) but that didn't link properly. Great minds think alike, I guess?

Nim, 39 bytes
stdout.write currentSourcePath.readFile

Attempt This Online!

authors: Евгений Новиков


text:
Who has the most stars in The Nineteenth Byte?
Note: this challenge involves downloading and sifting through HTML webpages. If your language cannot handle this you might not want to participate in this challenge.
Introduction
There are always discussions over in The Nineteenth Byte Chat about who leads the starboard. So, lets help everyone out and count the total amount of stars per user in the chat.
Challenge
Given an positive integer N which is greater than zero, calculate the leader(s) of the starboard of the last N starred messages in the chat. These messages can be viewed here. Hint: each page has 50 starred messages. Output will be a list of the top 5 users by amount of starred messages. A bonus of -15% off your byte count will be granted if you can display the usernames of those users, but no penalty will be given if you simply display the user id numbers. Please note that there is profanity in some of the starred messages. If you are sensitive to this type of language, view the page with caution.
Examples (Image is current starboard as of writing this challenge):

(RED) Input: 5 Output (With bonus): [Geobits Sp3000 PhiNotPi Seadrus]
(BLUE) Input: 10 Output (Without bonus): [51024 17335 24697 116494 129255]
(GREEN) Input: 14 Output (Without bonus): [51024 116494 141697 17335 24697]

Extra stuff:
Ties in the top 5 will be sorted by lowest to highest user id number. If there is less than five users, just output the leaderboard with empty slots at the end. Input and output can be in any format. Output does not need to be capitalized. If input is greater than 50, you must still count the messages on page 2, page 3, etc. You may assume that input will always be under 2^31, and will also not be so large that it 1) is larger than the amount of starred messages that there is and 2) will not crash the program (by making arrays to big, running out of memory, etc.).
This is code-golf, shortest code in bytes wins!

Leaderboards
Here is a Stack Snippet to generate both a regular leaderboard and an overview of winners by language.
To make sure that your answer shows up, please start your answer with a headline, using the following Markdown template:
## Language Name, N bytes

where N is the size of your submission. If you improve your score, you can keep old scores in the headline, by striking them through. For instance:
## Ruby, <s>104</s> <s>101</s> 96 bytes

If there you want to include multiple numbers in your header (e.g. because your score is the sum of two files or you want to list interpreter flag penalties separately), make sure that the actual score is the last number in the header:
## Perl, 43 + 2 (-p flag) = 45 bytes

You can also make the language name a link which will then show up in the leaderboard snippet:
## [><>](http://esolangs.org/wiki/Fish), 121 bytes

var QUESTION_ID=62182,OVERRIDE_USER=36670;function answersUrl(e){return"http://api.stackexchange.com/2.2/questions/"+QUESTION_ID+"/answers?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+ANSWER_FILTER}function commentUrl(e,s){return"http://api.stackexchange.com/2.2/answers/"+s.join(";")+"/comments?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+COMMENT_FILTER}function getAnswers(){jQuery.ajax({url:answersUrl(answer_page++),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){answers.push.apply(answers,e.items),answers_hash=[],answer_ids=[],e.items.forEach(function(e){e.comments=[];var s=+e.share_link.match(/\d+/);answer_ids.push(s),answers_hash[s]=e}),e.has_more||(more_answers=!1),comment_page=1,getComments()}})}function getComments(){jQuery.ajax({url:commentUrl(comment_page++,answer_ids),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){e.items.forEach(function(e){e.owner.user_id===OVERRIDE_USER&&answers_hash[e.post_id].comments.push(e)}),e.has_more?getComments():more_answers?getAnswers():process()}})}function getAuthorName(e){return e.owner.display_name}function process(){var e=[];answers.forEach(function(s){var r=s.body;s.comments.forEach(function(e){OVERRIDE_REG.test(e.body)&&(r="
"+e.body.replace(OVERRIDE_REG,"")+"
")});var a=r.match(SCORE_REG);a&&e.push({user:getAuthorName(s),size:+a[2],language:a[1],link:s.share_link})}),e.sort(function(e,s){var r=e.size,a=s.size;return r-a});var s={},r=1,a=null,n=1;e.forEach(function(e){e.size!=a&&(n=r),a=e.size,++r;var t=jQuery("#answer-template").html();t=t.replace("{{PLACE}}",n+".").replace("{{NAME}}",e.user).replace("{{LANGUAGE}}",e.language).replace("{{SIZE}}",e.size).replace("{{LINK}}",e.link),t=jQuery(t),jQuery("#answers").append(t);var o=e.language;/s.lang?1:e.lang<s.lang?-1:0});for(var c=0;c<t.length;++c){var i=jQuery("#language-template").html(),o=t[c];i=i.replace("{{LANGUAGE}}",o.lang).replace("{{NAME}}",o.user).replace("{{SIZE}}",o.size).replace("{{LINK}}",o.link),i=jQuery(i),jQuery("#languages").append(i)}}var ANSWER_FILTER="!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe",COMMENT_FILTER="!)Q2B_A2kjfAiU78X(md6BoYk",answers=[],answers_hash,answer_ids,answer_page=1,more_answers=!0,comment_page;getAnswers();var SCORE_REG=/<h\d>\s*([^\n,]*[^\s,]),.*?(\d+)(?=[^\n\d<>]*(?:<(?:s>[^\n<>]*<\/s>|[^\n<>]+>)[^\n\d<>]*)*<\/h\d>)/,OVERRIDE_REG=/^Override\s*header:\s*/i;
body{text-align:left!important}#answer-list,#language-list{padding:10px;width:290px;float:left}table thead{font-weight:700}table td{padding:5px}
 <link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/codegolf/all.css?v=83c949450c8b">

Leaderboard

	Author	Language	Size

Winners by Language

Language	User	Score

{{PLACE}}	{{NAME}}	{{LANGUAGE}}	{{SIZE}}	Link

{{LANGUAGE}}	{{NAME}}	{{SIZE}}	Link

Thanks. I've been idly curious about this for a while now, and didn't want to bother writing something to find out. Now others will do it for me :)

Before anyone asks, chat does not have an official API.

Does the URL have to count in the byte count? Just noticed that TeaScript / JavaScript will have issues with Cross-origin resource sharing

@Vɪʜᴀɴ It would be hard to judge which characters to remove that are part of the url, do you think allowing everyone to remove 70 characters (roughly the length of the url) would help this problem?

Off-topic but I find it a bit ridiculous that you have to warn people about "profane language".

I have been immortalized in this past :D

The starboard side of a ship named The Nineteenth Byte. Hmm...
Also, can someone run this for a really large number? I want to know who is the winner over all starred messages for the entire history of the room.

I' m so sorry for being slow but reading starred messages while coding was so hilarious and dilatory, this could have kept my mood up for a month.

Edit: Yes, I found it, the tie and duplicate ids issues are both fixed up harmonically. The trick is that the old code sorts the user-ids by descending number of stars, so I twisted some lines of my program in a way that it sorts users according to 99-n°_stars; since 99 is way bigger than the top hit star-cap (hopefully - I assumed), sorting the result by increasing number of stars kills both birds with one stone, descending stars with ascendant user-ids.

BrownRecluse, without bonus = 536 with bonus = 551-15% = 468 b
U=New(URL);P=New(Parser);L=New(Stack);t=New(Stack);v='http://chat.stackexchange.com/rooms/info/240/the-nineteenth-byte?tab=stars&page=';j=input();a=0;for i=1to j\50+1do begin U.Location=v+i;U.get;P.Parse(U.Data);x=New(RegEx);x.Data=U.Data;x.Mask='users/(\d*)/(\S*)".*?"times">(\d*?)<';while(x.Match)and(a<j)do begin L.Push(Format('%3d%9s%s',[99-x.Value[3],x.Value[1],x.Value[2]]));a=a+1;end;end;L.sort;i=0;for each L as y do if(not y.empty)and(not t.find(y.right(y.Length-12)))and(i<5)then begin y.delete(1,12);i=i+1;t.push(y);end;output(t.join(' '));

Input
60

Output
mego rainbolt alex-a lembik v

Input
90

Output
aditsu mego rainbolt alex-a lembik

NOTES

This program (including bonus) doesnt support unicode characters -  I'm sorry Vɪʜᴀɴ!
This program works based on the standard feature that each page contains almost 50 starred messages by default.
See clearly that 60 and 90 messages are contained within the first two pages, whilst the outputs differ.
This is the download page of this programming language in case it is not in your possession
In case needed, this is the bonusless program of 485 b
U=New(URL);P=New(Parser);L=New(Stack);t=New(Stack);v='http://chat.stackexchange.com/rooms/info/240/the-nineteenth-byte?tab=stars&page=';j=input();a=0;for i=1to j\50+1do begin U.Location=v+i;U.get;P.Parse(U.Data);x=New(RegEx);x.Data=U.Data;x.Mask='users/(\d*)/(\S*)".*?"times">(\d*?)<';while(x.Match)and(a<j)do begin L.Push(Format('%3d%9s',[99-x.Value[3],x.Value[1]]));a=a+1;end;end;L.sort;i=0;for each L as y do if(not y.empty)and(not t.find(y.right(y.Length-3)))and(i<5)then begin y.delete(1,3);i=i+1;t.push(y);end;output(t.join(' '));

Input
60

Output
169713    107051    141888     94625    116494

Input
90

Output
50454    169713    107051    141888     94625

If there was incoherence between results my code isn't taking the blame!

Why are there two alex-as in the output?

@feersum fixed.

source: Stack Exchange

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/

sort: votes


text:
Will it ambigram?
First challenge!
What is an ambigram?
Ambigrams are word(s) that read the same word(s) or another word given a certain transformation and possibly stylistic alterations.
Example:

That's an example of a rotational ambigram; it reads the same word, even when flipped around.
The Challenge
You are to create a function, program, etc. that can detect whether a given input (consisting of only a-zA-Z chars) is a natural symmetric ambigram (an ambigram that reads the same word without significant artistic alteration given a transformation). You can compete in one or more of the following categories:
Rotational
Examples: I, O, ae, AV, pod
Transformation table (both ways)
a  e/D
b  q
d  p/P
h  y
l  l
m  w
n  u/U
o  o/O/G/Q
s  s/S
t  t
x  x/X
z  z/Z
A  v/V
B  E
D  G
H  H
I  I
M  W
N  N

Output truesy or falsy value.
Reflectional (Vertical Line)
Examples: wow, mom, HOH
Chars to match
b/d i j l m n o p/q s/z t u v w x y A B/E G/D H I M O Q S/Z T U V W X Y

Output truthy or falsy value.
Reflectional (Horizontal Line)
Examples: XOD, KEK, BED
Chars to match
a l o t x B C D E H I K O X

Output truthy or falsy value.
Totem
Examples:
x  n  O
o  u  H
x  M  I
      O

Chars to match
A H I M O T U V W X Y i l m n o t u v w x y

Output truthy or falsy value.
Any (bonus of -50%)
This code should either output the type(s) of ambigram(s) that the input could possibly be (if the input is an ambigram) or a falsy value (if the input is not an ambigram).
Code rules

Standard loopholes are disallowed.
Input is case-sensitive. This means that AV would count, but aV would not count as a rotational ambigram.
An input of zero length is considered to be a natural symmetric ambigram.
Make sure to write your header as: # Division, Language, Byte-Count.
This is code-golf! You know what that means.

Consolas is a Microsoft font and not present on all devices. Please include a list of all rotational and reflectional characters in your specification.

I would include a table of characters and their horizontal and vertical reflections.

@ThomasKwa Correction: "ambigram," not "anagram." To everyone: I've corrected some stuff. Should be good?

To qualify for the bonus, what exactly does the submission have to return?

What is "totem"?

I still don't get the totem. I think what it means is that if written vertically it will have a vertical line of symmetry, but it certainly isn't made clear. It needs to be clarified in the spec before I will cast a reopen vote.

Clarified totem. Also clarified bonus.

Why are D and G in multiple groups in the rotational symmetry?
Shouldn't they just be in one?

@TFeld 'D' can become an 'a' or 'g' when rotated. 'G' can become a 'D' or 'O' when rotated. It takes minimal modification to do so.

@molarmanful I get it now :)
Shouldn't T be included in the Totem though?

Nice challenge. Could plese explain the rotion a D? (in any font they seems different enough)

Does bod match the requirements for vertical reflection?

What is that example image supposed to say?

@ThePopMatchine Molarmanful. It's one of my earliest/not-the-best ambigram. Of course, I have a gallery here with better ones (probably).

@TFeld Nice catch! Edited.

Python 2, 258 bytes (622 567 543 516-50%)
Here's my attempt at an answer.
R=dict(zip(list('abdhlmnostxzABDHIMN'),'eD q pP y l w uU oOGQ sS t xX zZ vV E G H I W N'.split()))
V='ijlmnotuvwxyAHIMOQTUVWXY'
W=dict(b='d',p='q',s='z',B='E',G='D',S='Z')
H='lotxBCDEHIKOX'
T='AHIMOTUVWXYilmnotuvwxy'
s=raw_input()
r=v=h=t=1
for i,j in R.items():
 for c in j:R[c]=R.get(c,'')+i
for i,j in W.items():
 for c in j:W[c]=W.get(c,'')+i
for i in range(len(s)):
 c,l=s[i],s[-i-1]
 r&=(c in R and l in R[c])
 v&=c in V or(c in W and l in W[c])
 h&=(c in H)+(l in H)>1
 t&=c in T
print 'R'*r+'V'*v+'H'*h+'T'*t

Prints the possible types of ambigrams, or 0 if no ambigrams are possible.
RVHT for rotational, vertical, horizontal and totem respectively.

Should be able to do not (x and y) -> (x)+(y)>1 where x and y are boolean statements. You should also be able to define dictionaries like: R=dict(a='ed',b='q'...). I believe the empty string should count as a falsy value so you can drop the or 0.

@FryAmTheEggman Thanks!
Though it seems should be (x)+(y)<2 or else it's just an and

You're right, and I did some more golfing, but I've just noticed that I think your calculation for vertical reflection is incorrect. I think you need to use a dictionary again, and for example it should match bod I think (I will ask OP though)

save 34 chars: R=dict(zip(list('abdhlmnostxzABDHIMN'),'eD q pP y l w uU oOGQ sS t xX zZ vV E G H I W N'.split()))

You can save 6 bytes by removing the spaces in H = 'lotxBCDEHIKOX' and the next two lines, and 4 more by removing spaces between if and (.

@FryAmTheEggman Thanks, I fixed the vertical reflection

All, Ruby, 289 - 50% = 144.5 bytes
i=gets.chop;s=i.tr('ijlmnotuvwxyAHIMOQTUVWXY','').tr'bpsBGS','dqzEDZ';t=i.tr'eDqpPylwuUOGQStXZvVEGHIWN','aabddhlmnnooostxzAABDHIMN';o=(i.tr('alotxBCDEHIKOX','')=='' ? 'V':'')+(s==s.reverse ? 'H':'')+(i.tr('AHIMOUVWXYilmnotuvwxy','')=='' ? 'T':'')+(t==t.reverse ? 'R':'');puts o=='' ? 1<0:o

This seems too long...

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/


text:
Carrots. So. Many. Carrots

 Damn, that's a lot of carrots.

The Inspiration

The Task
You must create a program, that, in as many languages as possible, replaces every instance of ^ with a markdown formatted link (meaning that if I was to post it in an answer, it would automatically read it as an image and place the image instead of the words) of this upward facing carrot.

How to Use Said Formatting:
First, anywhere in the file, put in the link like so (this is what I did for this question):
[1]: https://i.stack.imgur.com/mecHl.png
And then, wherever you want it:
[![][1]][1]
Rules

Standard Loopholes apply.
Input will be through STDIN or equivalent.
Output will be through STDOUT or equivalent.
Your code must be a fully operating program in all languages that you use.
The URL that you use for your carrot does not have to be the one in this answer. This was just an example. You may use any URL, provided that SE's Markdown shows this specific carrot with it.
This is a polyglot challenge, so the answer with the greatest amount of carrots languages wins!

In the case of a tie, the shortest code size of the entries with the largest number of languages wins.

EDIT:

Also, do NOT use trivial derivatives of languages! This means using a substitution language (Brainfuck vs. ShadyAsFuck) and different language versions (Python 2 vs. Python 3).

There's a lot trivial esolangs to fit... (including 9001 BF variants)

Don't be that guy.
Note: Yes, this program will be slightly trivial in languages with regex support. However, the competition is to see how many languages the competitors can use.

I don't understand the replacement (this part: [![http://i.stack.imgur.com/mecHl.png][1]][1])

@Zereges What don't you understand about it? If you want another example of this, click on "Add an Answer" and then hit the image button. It'll auto construct the image markdown for you, just as shown in this question.

Oh, I see, I didn't realized, that imagelinks are that complex.

Can't you just use ![](//i.stack.imgur.com/mecHl.png)?

For the purpose of this contest, I'm restricting it to the way described. Note that this is also the default formatting for inserting a picture into a post.

Can we choose any method for I/O? Are functions allowed?

It should be a full program in whatever languages you choose, and input is through STDIN. I'll add that in for clarification. @fschmengler

Carrots forever! ^^^

First, anywhere in the , I'm not sure which word is missing there.

@trichoplax It was supposed to say "file". Put it in, sorry for the ambiguity lack of word.

@FryAmTheEggman, it makes no sense for a question to be tagged both [tag:polyglot] and [tag:rosetta-stone].

@FryAmTheEggman That would mean writing separate programs that do the same thing. A polyglot is something that does it in as many languages as possible with one program.

@VoteToClose ok I can't read. My bad :S

@VoteToClose Is just [![][1]][1] allowed once the [1]: http://i.stack.imgur.com/mecHl.png is placed? Why have the extra link in the alt text?

And does the [1] have to contain a 1? Any alphanumeric string in the brackets works.

It can be any number, but to simplify the problem, I used 1. For the purpose of this challenge, it's not necessary. I will remove the link in the second item, though, thanks for pointing that out. @Calvin'sHobbies

@KritixiLithos I answered in Carrot just for you! Although it is only one language it shouldn't be hard to extend to more than one.

Python, Befunge 98, Lisp, and Javascript - 829 827 +2 (-x flag in python) =  831  829 bytes
"^\
";/*";
""""(defun q (string part replacement &key (test #'char=))(with-output-to-string (out) (loop with part-length = (length part) for old-pos = 0 then (+ pos part-length) for pos = (search part string :start2 old-pos :test test) do (write-string string out :start old-pos :end (or pos (length string))) when pos do (write-string replacement out) while pos)))(princ "[1]:http://tinyurl.com/qczsjtl
")(ignore-errors (loop (princ (q (read-line) "^" "[![][1]][1]"))))""";import sys;i=sys.stdin.read();print '[1]:http://tinyurl.com/qczsjtl\n'+i.replace('^','[![][1]][1]');"""" """
1;'''
;#<v"[1]:http://tinyurl.com/qczsjtl"$$$
;X v,<
;X >:|XXXXX>v
;vXXX>a,#
;>#@~>:10g-|>,#
;^ XXXXXXXX>$"]1[]]1[][![">:# ,# _#
;X */alert("[1]:http://tinyurl.com/qczsjtl\n"+prompt().split("^").join("[![][1]][1]"));/*
;>^"'''#*/

Requires the -x command line flag when run with python. the Xs can be replaced with any character. The end-of-line number signs (and the number sign at the beginning of the first line that starts with a semicolon) are present to avoid befunge trying to execute the invalid instruction ; (which starts a comment in lisp). There is no trailing space on any of the lines.
Saved two bytes by replacing 55+ with a to print a newline.

So fancy, so clean. I like. +1 Well done on completing with more than 3 languages. :D

Minkolang 0.10, Befunge-93, ><>; 3 2D languages, 321 bytes
v[1]: https://i.stack.imgur.com/mecHl.png
v[![][1]][1]
>\$$>~:1+!#v_:"^"-#v_1>:34*`#v_v
//  ^             ,<0        <    >:0g,1+v
v#   ,,:*52<          ^+1  ,g1:<@_^#`*85:<1
>!v#(od"^"=,34*&34*[i1+1qO]!O$I)lO58*[i1+0qO].
  >i:0(?v:"^"-?v1>:34*)?vv
  ^           o<0       < > :0go1+v
  oo:*52<        ^+1og1: <^;?)*85:<1

Interpreters: Minkolang, Befunge-93, ><>.
I'll go into detail on each component if anyone wants, but what's important is that all of them read the first and second lines of the codebox and output the characters at the appropriate times. Also, I decide between Befunge and Minkolang/><> by the use of \, which swaps the top two values of the stack in the first and is a mirror in the other two. To separate Minkolang and ><>, I use !v#. ! is an unconditional trampoline in both languages, but # is an omni-directional mirror in ><> and a no-op in Minkolang. From then on, each language executes code in its own component.

Carrot, 60 58 bytes
#^A^S"[![][1]][1]"^[1]: https://i.stack.imgur.com/mecHl.png

I know it is only one language at the moment but I thought we can't really have a challenge about carrots that isn't answered in Carrot.
Saved 2 bytes thanks to @KritixiLithos.
Explanation:
#                                          // Set the stack to the input
^                                          // Change to operations mode
A^                                         // Convert to array mode by splitting on ^
S"[![][1]][1]"                             // Convert to string mode by joining on
                                           // the literal string supplied
^[1]: https://i.stack.imgur.com/mecHl.png   // Switch back to stack mode and
                                           // append the string literal

I'm not familiar with any languages with # comments but you could easily make a polyglot with one of those just add that code at the start then substring in the carrot code to leave only the # in the input.

I did not even know why this code worked (the A^ part, partly because I had long forgotten about its implementation), but then I realised it was because of my terribly-written interpreter that lacks a proper parser. Here, have a +1 for confusing the creator of the language.

@KritixiLithos To be honest I was trying to get it working with a regex and failed miserably and was surprised myself when A^ ended up working! I'm guessing when you split, you leave empty elements so ^^ gives [ "", "", "" ].

You can remove the +" at the end and change it to ^ while dropping the ending " like so, #^A^S"[![][1]][1]"^[1]: http://i.stack.imgur.com/mecHl.png. Essentially, + with a string argument prepends the string to the stack, but ^ does the same thing for a shorter bytecount.

@KritixiLithos Of course thanks!


text:
Fix the Meeesesessessesseesseessedessed upp teeexexextext
This is inspired by Monday Mini-Golf #6: Meeesesessess upp teeexexextext
Background
ETHproductions have difficulty entering text on his usual webpage. Whenever he use digits or letters, the text will be meeesesessessesseesseessedessed up. Your task is to help him type so the normal behavior is achieved.
The transform
The transform affects runs of alphanumeric ([0-9A-Za-z]) characters delimited by any nonalphanumeric characters. In the following example, the first line would be transformed into the second (the other lines show the breakdown of the transform)
An12num:
Annn1n12n12nn12nn12nun12nun12numn12num
A
 nn
   n1
     n12
        n12nn12n
                n12nun12nu
                          n12numn12num

In particular, any alphanumeric character after the first in a run will be transformed into the entire run so far except for the first character. Furthermore, if the character is a letter (as opposed to a digit), the character will be turned into twice the run.
Thankfully, backspace will delete last character and also resets the beginning of the run.
Task
This time your task is not to perform the transformation. Instead, given an input string, you must return an encoded text that, if transformed, will result in the input. The output must be as short as possible, where \<char> counted as a single character.
Text is encoded as follows:
\                   -> \\
backspace character -> \b
linefeed            -> \n

You may write a program or function, taking input via STDIN (or closest alternative), command-line argument or function argument and outputting the result via STDOUT (or closest alternative), function return value or function (out) parameter.
Test cases
Each test case is two lines, the first being input, the second output.
Heeeeeelp me. It shouldn't be messed up.
Hee \blp\b me\b. It\b sh\bou\bld\bn't be\b me\bss\bed\b up\b.

alert("Hello, world!");
al\ber\bt("He\bll\bo, wo\brl\bd!");

1223234234523456
123456

It's well defined, but why there's no answer?

Somehow I missed this; nice spin-off! Perhaps I'll try to write an answer later.

This reminds me of the time a friend of mine sent text through UDP

I think your final test case needs a fix. You include the first character (1every time) in the runs.

I honestly do not understand what I'm supposed to do... Sorry. Could you add some inputs and outputs and add some examples with the explaination? Sorry.

This is too hard! If only I knew Regex...

CJam, 207
{_,1>{:E1<_0{:I2$,+E=:C+:R1>C'9>)*+:P,E,<{EP#{L0}{PRI)1}?}{PE#L{R8cP,E,-*+}?0}?}g}&}:U;LqS+'a+{_'[,_el^A,s+&,V={+}{s\V!:V{L{:BU_aL?B,,1>Bf{_2$<U_{_W=8>S8c+*+\@>j+}{?;}?}+{,}$0=}j}|\}?}%s'\8cN++'\"\bn"f+er-2<

Try it online
Explanation:
Almost forgot to write this :p
The problem is solved in several steps:

the text is separated into runs of alphanumeric characters (let's call them words) and runs of non-alphanumeric characters (non-words)
non-words are printed as they are, and words are fixed
fixing a word is done recursively (with memoization): split the word into 2 chunks in every possible way (including empty 2nd chunk), try to unmess the first chunk (see below), fix the 2nd chunk and join the results with a space-backspace if needed; take the shortest sub-solution
unmessing a chunk means finding a minimal string of alphanumeric characters possibly followed by some backspaces (but with no backspaces in the middle) that when messed up, result in the given chunk; it is done with a simple greedy algorithm, going from left to right, building the unmessed string and its messed version in parallel, and determining the next needed character at each step; some chunks can not be unmessed

Holy cow... that's one heck of a CJam program! Nice work.


text:
Quine / Reverse Quine
Write a complete program that takes a boolean or non-negative integer input. It must:

Output its own source code if the input value is falsy
Output its own source code in reverse if the input value is truthy

Your program cannot be palindromic, nor can it read its own source code by any means.
This is code golf - shortest code in bytes wins.

So... if my language doesn't have booleans. But 0 is falsy and positive integers are truthy. Can I assume that the input will be only 0 or 1 (as stand-ins for booleans - the language will in fact always yield one of those two as the result of a conditional operator)? Or do I have to support any integers, since I can't use "actual" booleans?

Gol><>, 9 bytes
'rd3*I?rH

I feel a little awkward posting this, since we already have ><>, Vitsy and Minkolang answers. The only additions to the standard quine are I (read integer input), ? (execute next if truthy) and r (reverse stack).
Try it online.

Join the club! :D You're winning anyways. +1

8 bytes: sP#Hr?I"

CJam, 17 16 bytes
{`"_~"+Wq~g#%}_~

Test it here.
A fairly straight-forward modification of the standard quine. Other solutions for 17 bytes:
{`"_~"+q~{W%}&}_~
{`"_~"+q~!2*(%}_~

If I can assume that the input is only 0 or 1 (as a stand-in for a boolean, which there is no dedicated type for in CJam), I get 15 by omitting the g:
{`"_~"+Wq~#%}_~

Explanation
{`"_~"+  e# Standard generalised quine framework. Leaves the source code on the stack.
  W      e# Push a -1.
  q~     e# Read and evaluate input.
  g      e# signum, turning truthy values into 1 (leaving 0 unchanged).
  #      e# Power. -1^0 == 1, -1^1 == -1.
  %      e# Select every Nth element: a no-op for 1 and reverses the string for -1.
}_~

Since 0 and 1 are CJam's Booleans, I don't think you need the g.

@Dennis Yeah I wasn't really sure about that.

Surprisingly, I somehow beat this. o-o I won't be surprised if you golf it down more though. :D

Pyth, 17 bytes
_WQjN*2]"_WQjN*2]

A straightforward modification of the standard Pyth quine.

Damn, I'd been waiting to post this since an hour after it was sandboxed.

><>, 17 Bytes
Requires the -v flag (+1 byte) for pushing input onto the stack (or for you to put input on the stack beforehand on the online interpreter).
'rd3*$?rol?!;70.

You could do the below for the same amount of bytes (without the flag) if integer inputs only were allowed (i.e. 0 for falsy, 1 for truthy).
'rd3*ic%?rol?!;80.

Try it online
Truthy/falsy for ><> are anything not 0 and 0, respectively.

Vitsy, 15 Bytes
...I'm... I'm beating CJam! (shouts over) Mom! Look, ma, I deed it!
'rd3*i86*-)rl\O
Explanation:
'rd3*i86*-(rl\O
Standard quine, but with a twist:

'               Capture the source code as a string
 rd3*           Create the ' character in ASCII
     i86*-      Get the input character as ASCII then subtract 48 from it.
                    If it's zero, it'll the if statement will skip the next instruction.
          (r    If the top item of the stack is zero, do not do the next item.
                    The next item here is reverse.
            l\O Print out the stack.

Newer Version of Vitsy, 11 Bytes
v'rd3*}v)rZ
v            Capture the input as a variable.
 '           Capture the source until encountering another '
  r          Reverse the stack.
   d3*       Push ' to the stack.
      }      Rotate the stack to the right one.
       v)    Push the variable (input) to the stack and test if it is not zero.
         r   If so, reverse the stack.
          Z  Output everything in the stack.

Python 2, 51 bytes
s="print('s=%r;exec s'%s)[::1-2*0**input()]";exec s

Javascript (ES6), 42 bytes
$=_=>'$='+(_?$:[...''+$].reverse().join``)

This is a modification of my Bling Quine. It's twice as long, too.

Does this actually output anything? Answers that only work in a REPL are not allowed.

@ETHproductions That would call the function, but it still wouldn't print anything. Also, it wouldn't be a quine anymore.

@Dennis Right. Well, I guess that means prompt() is necessary, unless we switch to Node.JS. I believe $=_=>(A=`$=${$};$(prompt())`,alert(_?A:[...A].reverse().join``));$(prompt()) works properly, although maybe it could be golfed down more.

"Your program cannot [...] read its own source code by any means." Does this solution fall into this category?

Haskell, 126 118 108 bytes
main=readLn>>=putStr.([t,reverse t]!!);t=s++show s;s="main=readLn>>=putStr.([t,reverse t]!!);t=s++show s;s="

Expects 0 or 1 as input.

Burlesque, 40 bytes
ri#Q2 SH ~- "ri#Q" \/ .+ j "<-" ps if sh

Explanation:
Burlesque has advanced stack and code manipulation built-ins. In fact, you can't access the source code of the program but you can access the remaining
code that is to be executed in the future. This means #Q will return all the code that follows it which is why we have to add everything up to #Q to that code which is what we're doing with ri#Q.
blsq ) #Q1 2++
12 -- this is the result of 1 2++
{1 2 ++} -- this is the result of #Q

++1 2 is technically illegal code since it's stack based. But we can manipulate the code to make it execute as 1 2++:
blsq ) #Q<-#q++1 2
12

Working with these built-ins is incredibly tricky and nobody has yet used them for anything productive except for quine related things. If you reverse ++1 2 you get 2 1++ which would produce 21 and not 12. The reason the code above produces 12 is because #Q also includes the <- so in the end we end up executing a lot more than just 2 1++ :p. We end up executing 2 1++#q<- which produces 12.
We can actually replace things in our code for example this code replaces all occurences of ?+ in itself with ?*
blsq ) #Q(?+)(?*)r~5.-#q5 5?+
25

Usage:
$ echo "1" | blsq --stdin 'ri#Q2 SH ~- "ri#Q" \/ .+ j "<-" ps if sh'
hs fi sp "-<" j +. /\ "Q#ir" -~ HS 2Q#ir
$ echo "0" | blsq --stdin 'ri#Q2 SH ~- "ri#Q" \/ .+ j "<-" ps if sh'
ri#Q2 SH ~- "ri#Q" \/ .+ j "<-" ps if sh

Minkolang 0.10, 13 bytes
"66*2-n,?r$O.

Try it here.
This is exactly like the standard quine except for these four characters: n,?r. n takes an integer from input, , inverts it, so ? skips r if the input is truthy. Otherwise, r reverses the stack so that it is output in reverse order.

My thunder is gone. :c

Java 10 (full program), 282 bytes
interface N{static void main(String[]a){var s="interface N{static void main(String[]a){var s=%c%s%1$c;s=s.format(s,34,s);System.out.print(new Boolean(a[0])?new StringBuffer(s).reverse():s);}}";s=s.format(s,34,s);System.out.print(new Boolean(a[0])?new StringBuffer(s).reverse():s);}}

Try it online.
Java 10 (as lambda function), 154 bytes
b->{var s="b->{var s=%c%s%1$c;s=s.format(s,34,s);return b?new StringBuffer(s).reverse():s;}";s=s.format(s,34,s);return b?new StringBuffer(s).reverse():s;}

Try it online.
Explanation:
interface N{                          // Class
  static void main(String[]a){        //  Mandatory main-method
    var s="interface N{static void main(String[]a){var s=%c%s%1$c;s=s.format(s,34,s);System.out.print(new Boolean(a[0])?new StringBuffer(s).reverse():s);}}";
                                      //   Unformatted source code
    s=s.format(s,34,s);               //   Format the source code (the quine-String)
    System.out.print(                 //   Print:
      new Boolean(a[0])?              //    If the input is true:
       new StringBuffer(s).reverse()  //     Print the quine-String reversed
      :                               //    Else:
       s);}}                          //     Print the quine-String as is

quine explanation:

The var s contains the unformatted source code
%s is used to put this String into itself with s.format(...)
%c, %1$c, and 34 are used to format the double-quotes
s.format(s,34,s) puts it all together

And then new StringBuffer(s).reverse() is used to reverse the quine-String if necessary based on the input-boolean.

05AB1E, 21 bytes
0"D34çýÂ‚sè"D34çýÂ‚sè

Try it online.
Modification of the default quine 0"D34çý"D34çý by adding Â‚sè.
Explanation:
0                        # Push 0 to the stack
                         #  STACK: [0]
 "D34çýÂ‚sè"             # Push the string 'D34çýÂ‚sè' to the stack
                         #  STACK: [0, 'D34çýÂ‚sè']
            D            # Duplicate this string
                         #  STACK: [0, 'D34çýÂ‚sè', 'D34çýÂ‚sè']
             34ç         # Push '"' to the stack
                         #  STACK: [0, 'D34çýÂ‚sè', 'D34çýÂ‚sè', '"']
                ý        # Join the stack with '"' delimiter
                         #  STACK: ['0"D34çýÂ‚sè"D34çýÂ‚sè']
                 Â       # Bifurcate (short for Duplicate & Reverse)
                         #  STACK: ['0"D34çýÂ‚sè"D34çýÂ‚sè', 'ès‚Âýç43D"ès‚Âýç43D"0']
                  ‚      # Pair them up:
                         #  STACK: [['0"D34çýÂ‚sè"D34çýÂ‚sè','ès‚Âýç43D"ès‚Âýç43D"0']]
                   s     # Swap to get the boolean input (0 or 1)
                         #  STACK: [['0"D34çýÂ‚sè"D34çýÂ‚sè','ès‚Âýç43D"ès‚Âýç43D"0'], 1]
                    è    # Index the input into the list
                         #  STACK: ['ès‚Âýç43D"ès‚Âýç43D"0']
                         # (Output the top of the stack implicitly)

PS: Automatically prints a trailing newline. If this should be reversed as well, it's 23 bytes instead:
0"D34çýÂ‚sè?"D34çýÂ‚sè?

Try it online. (? is an explicit Print without new-line)

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/