text:
Create output twice the length of the code
The Challenge
Write a complete program that writes twice as many bytes to standard output as the length of the program.
Rules

The program must write ASCII characters to the standard output.
The contents of the output doesn't matter.
The output, measured in bytes, must be exactly twice the length of the program, also measured in bytes, unless you fulfill the bonus.
Any trailing newline is included in the output's byte count.

Bonus
Your program can optionally take a number, n, as input. If so, the output must be exactly n * program length bytes. You can assume that n will always be a positive integer. If no input is provided, n must default to 2.
If you do this,  you can subtract 25 bytes from your score.
Shortest program wins.
Restrictions

No standard loopholes.
The program must be at least 1 byte long.
No adding unnecessary whitespace to the source code to change its length. Similarly, comments don't count.
Unless you fulfill the bonus, the program must accept no input. If you do fulfill the bonus, the integer must be the only input.

Lowest score (program length in bytes - bonus) wins.
The shortest answer for each language wins for that language.
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=59436,OVERRIDE_USER=41505;function answersUrl(e){return"https://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"https://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

For the bonus, does the output have to be exactly n * program length bytes, or is that a minimum?

It has to be exact

Looks like the code snippet has to be modified to handle negative scores.

A bonus of -25 is basically mandatory for some languages, since it lets them achieve a negative score. In the future, I'd suggest using a percent bonus, or just making the bonus the question if you really want answers to go for it. Or, just don't have a bonus.

For "no input is provided", do we assume the empty string is passed in? I can't see how one would deal with the user never typing in an input and the program just waiting.

@El'endiaStarman I'm not really a javascript expert, so I used the leaderboard snippet. I think I found the regex that controls which number gets used, so I changed that to accept a dash. How long does it take for the snippets to update?

@xnor If the program waits for user input, then it is an empty string. For "no input", I was thinking along the lines of command-line args.

@DanielM. So you mean that if we accept input, we have to account for empty input and in that case use 2?

@AlexA. That is correct.
On another note, I found the regex that it actually uses, and when that was changed, it updated immediately.

@DanielM.: Excellent! :)

Since there are so many answers, I'm just changing it to "shortest answer in each language" instead of "shortest answer overall".

ASCII or printable ASCII? (Dunno if that would change anything, but worth clarifying.)

Any 8-byte ASCII (for 2 reasons).

I just chose ASCII as it is a standard format, and it's clearer to say to "write ASCII" than "write bytes". Additionally, it avoids the 16/32 bit nonsense of unicode (seriously, 8 extra bits?).

There are already submissions with unprintable characters that I don't want to invalidate.

Should the "Done\n" in this answer count as output?

Can someone fix the snippet? Hyperlinked language names are sorted incorrectly.

at least 1 byte Why.

@BlockCoder1392 in some languages, an empty program is a Quine, but that's no fun

No, I was like "WHY MUST YOU DO THIS" because anything*empty=empty, so you could get a really easy -25 polyglot.

Does CRLF count as one character?

@dorukayhan I'd count bytes for this

Would "\n" count as two characters?

Why [tag:quine]?

It seems there's some disagreement about what a "complete program" is here. Some answers are just functions; others are more what I would think of as complete programs that take input from stdin or the command line. Can you clarify?

I was gonna do the empty programme :(

Do I include the trailing newline in the output byte count? Python includes it by default.

HQ9+, 2 bytes
QQ

outputs
QQQQ

I think it is not forbidden here.

It may not be forbidden, but it's not very inter... wait, how did it get eight upvotes?

@JanDvorak Much as I dislike HQ9+, this to me is a creative use.  This usage most likely wasn't envisioned when HQ9+ was created, which is more than can be said of most other Hq9+ programs.  +1 from me.

I didn’t even know that Q prints “the program’s source code”. I thought it just printed a Q. Well done for spotting the crucial difference!

Sadly, HQ9+ isn't considered a programming language.

@LegionMammal978 Technically this is a constant output challenge, which means non-programming languages are allowed.

This has 120 votes. 1,200 rep for typing QQ into an interpreter.

Shakespeare, 768
Yeah, Shakespeare's not much of a golfing language. Outputs 1,536 spaces.
Rosencrantz and Guildenstern: A Series of Tedious Events.

Rosencrantz, a count of extraordinary determination.
Guildenstern, a spacy character.

Act I: The Long Conversation

Scene I: A Tortured Friendship

[Enter Rosencrantz and Guildenstern]

Rosencrantz:
 You are a gentle, noble, valiant, loyal, loving companion.

Guildenstern:
 You are nothing!

Scene II: Asking the Hard Questions

Rosencrantz:
 Speak your mind.

Guildenstern:
 You are as fair as the sum of yourself and a daisy. Are you as
 daring as the sum of a big, bold, fiery, feisty, rough, rowdy,
 ham-fisted, hawk-eyed, broad-shouldered, bright-eyed lad and a
 large, yellow, vicious, hairy, wild, scary, long-tailed,
 sharp-clawed, small-eared lion?

Rosencrantz:
 If not, let us return to scene II.

Edit: 256
Okay, I'll actually golf it. Note that the above does not compile in any existing Shakespeare implementation because I wrote it painstakingly by hand (but am prepared to defend its correctness.)
The below translates to C with one warning in spl-1.2.1, and outputs 512 spaces:
Ummm.Ajax,1.Puck,2.Act I:I.Scene I:A.[Enter Ajax and Puck]Ajax:You old old old old old cow.Puck:You are zero!Scene II:B.Ajax:Speak thy mind.Puck:You are the sum of you and a red cat.Are you as big as the square of me?Ajax:If not, let us return to scene II.

I'll +1 if you actually golf this.

What manner of whitchcraft is this? I didn't even know such thing existed...

@Malavos don't you mean which manner of whitchcraft?

@sysreq probably. shrugs My english is bad and I feel bad. Not really, because it's not my native language. Sorry about that.

woah, you golfed it. Holy havens.

@Malavos I was just joking about the way you misspelled witchcraft, sorry -- both what and which are probably ok

No, I ask for your forgiviness if I sounded offensive or defensive. I was just making a reference to Futurama! :)
On a serious note, I'm still surprised by this answer. We need more of those on the site.

I think you can use “you is”.

"You old old old old old cow!" +1. In all seriousness, would it be possible to golf that even further?

Recall, 17 bytes
................!

16 NOOPs. Then the debugger ! is invoked and dumps the memory to the console. The memory is empty, but the header is 34 bytes long:
-- STATE DUMP --
----------------

Try it here.

This is one of the cooler answers IMO.

Creative answer. These are my reasons to visit codegolf.

Mathematica REPL, 1 byte
#

Prints #1.

The question says to "write a complete program"; this is just a REPL snippet.

CJam, -17 bytes
r2e|i8,*

The source code is 8 bytes long and qualifies for the -25 bytes bonus.
Try it online in the CJam interpreter.
How it works
r         e# Read a token from STDIN.
 2        e# Push 2.
  e|      e# Logical OR; keep the token if it's not empty, 2 otherwise.
    i     e# Cast to integer.
     8,   e# Push [0 1 2 3 4 5 6 7].
       *  e# Repeat the array the corresponding number of times.

Crap. Well done.

How is it negative bytes?

@NickT 8 bytes (source code) - 25 bytes (bonus).

You can save several million copies of it if you're running out of disk space.

No, I think metadata would make it positive

Cjam is reeeeeally nice for golfing!

Python 2.6, 10
print`-.1`

Prints -0.10000000000000001, which is 20 chars.
Note that the string repr shows more precision. print-.1 just gives -.1, and print.1/3 gives 0.0333333333333 for only 13 digits of accuracy.

This no longer works in Python 2.7 or 3.1.

@AndersKaseorg So repl.it is wrong, then?

@mbomb007 Apparently. GitHub suggests that’s hardly the only thing it’s wrong about. Ideone agrees with CPython.

Same comment as for your other answer: doesn't this print a trailing newline, giving 21 bytes of output?

@MartinBüttner Here, changing it to \print`+.1` would compensate for the trailing newline.

You mean print\+.1``?

@wizzwizz4 I can't figure out how to show you in a comment. Try looking here: https://meta.stackexchange.com/a/70679/285610
I think it was triple backticks, the code, then a space, then triple backticks, but I can't be certain. Sometimes escaping with backslashes is necessary

Seed, 10 bytes
4 56111240

This compiles to the Befunge program (found by brute force)
9k.@

which produces the following 20 bytes when run (tested in CCBI, note the trailing space):
0 0 0 0 0 0 0 0 0 0

Being unfamiliar with Befunge 98, I had to double check the spec a few times for this one:

k seems pretty broken to me, executing one more time than intended due to the IP moving into the repeated instruction
Befunge 98's stacks have infinite zeroes at the bottom
. outputs as a number, followed by a space

.... I....just....can't.

R, 3 2 bytes
Code
!0           # NOT FALSE

Outputs
TRUE

Wow, finally R, finally.
It seems that {} work too, it outputs NULL
Bonus 33 16 bytes:
Code
rep(1,number*16)

Outputs
# if number is not defined
> rep(1,number*16)
> Error: object 'number' not found     # output is 32 (or 2*16) bytes long error

# if number is defined
> number = 3
> rep(1,number*16)                     # output is 16*number bytes long
> 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1

I hope using the name "number" for the variable is not equivalent to " adding unnecessary whitespace to the source code"

JavaScript, 2 bytes!
Even shorter than the 3 bytes solution:
!0

Returns true after running.

You should note that this only works in a REPL environment

If the \n following the print counts as a byte, one could simply use 0 or any other single number.

I did 3E5 on my first one, but thought repl was cheating.

Matlab, 8 bytes
1234;'5'

Output:

The output contains newline, ans =, newline twice, space four times, '5', newline, so 16 bytes.

Let's hope nobody has format compact as default :)

@sanchises :-) Yes, that depends on how Matlab's preferences have been set. But format loose is the default preference

How about 123;4? Is three bytes shorter=)

@flawr Good idea! Post it yourself!

Nope, way too much inspired by your answer=)

@flawr Edited then!

There are 5 spaces before number "3" in output - shouldn't they count as well?

@elementiro You're right, how didn't I notice? Thanks!

Python 2, 11
print`id`*1

Print the string representation of the built-in id, which is 22 chars:
<built-in function id>

The *1 is to get the code to 11 chars. You could also do print id;00.
More boring alternative 11's are:
print'1'*22
print 9**21

I've been playing around with complex numbers, but unfortunately print.8/-9j is one char short

Don't these print a trailing newline, bringing the output's byte count to 23?

@MartinBüttner That rule was edited in later, but changing it to print id,;1 suffices to suppress the trailing newline. It doesn't add a trailing space either.

@xnor print 9**21 doesn't work. It's 21 characters. print 9**23 works though

dc, 10 - 25 = -15
2?A*Ar^1-n

Takes a blank line for "no input".
Calculates 10 ^ (10 * n) - 1, where n is the input, or 2 if input is empty.  Prints a string of 9s of the required length.

2 push 2 to the stack in case input is empty
? push input to the stack
A push 10 to the stack (dc has shortcuts A-F for 10 - 15)
* pop twice and multiply (multiply input by 10)
A push 10 to the stack
r reverse top two stack elements
^ exponentiate 10 ^ (10 * input)
1- subtract 1 from the top of stack
n print with no newline.

dang, that is so clever. And lucky with the code length there :)  But maybe you should add a small explanation for the uninitiated. And I think newline counts, so you should probably use n instead of p.

Brainfuck, 14 bytes
+++++++[....-]

This is a little mathematical exercise. Let's denote the number of + characters in the code by a, and the number of . characters by b.
The code outputs a*b bytes, with values from a down to 1 (these are non-ASCII bytes, but it seems OK according to the spec). The code's length is a+b+3. So we have
a*b = 2 * (a+b+3)

Trying different values for a and b, we see that the minimum for a+b+3 is achieved for
a = 4       or       a = 7
b = 7                b = 4

A veteran brainfuck programmer will spot the +[[>....]-<<+] option.

@orthoplex When I read your comment I immediately portmanteau'd brainfuck and programmer: brainfucker

TI-Basic, 3 bytes
1ᴇ5

Prints 100000.

Actually, I think the newline would count, so you can just do 0 for 1 byte.

How about ᴇ3? And @lirtosiast, since TI-Basic doesn't have newlines I'm skeptical about that.

gs2, -18 bytes
CP437: W↕0!↨.2
Hex dump: 57 12 30 21 17 2e 32
W reads numbers from STDIN into a list. ↕0 appends a 2 to the list, and ! extracts the first element. Then ↨. (the list [0,1,2,3,4,5,6]) is repeated (2) this many times.
This is very similar to Dennis's CJam answer -- gs2 just combines r and i into one byte.
Note: I had to fix a bug in the gs2 implementation for this to work: previously, each program had a hidden newline appended to its output, which was entirely unintentional. It only surfaced after I tried to solve this program (the language was designed for anarchy golf, which ignores trailing newlines in all problems), and I only pushed a fix to master just now, so feel free to take this answer with a grain of salt.

First GS2 answer I've seen that doesn't have any card suit characters!

Pyth, 10 9 - 25 = -16
-1 by Dennis
**N9?zvz2

Prints [input]*9 quote characters, or 2*9 if the input is empty.
isaacg has a shorter answer here
Pyth, 1 byte
T

Prints 10. It's a built in variable that initializes to 10.

It would be useful if .x worked with errors. Is there a justification for why it doesn't?

My best guess is that Q causes Pyth to eval the input before the actual code is executed. **N9.xvz2 works as expected, but it's not shorter than **N9?zvz2.

Any trailing newline is included in the output's byte count. T outputs 10 and a newline. Use d, it's a space which gets a newline appended

Perl 5, 16 bytes - 25 = -9
$_ =$]x($_*2||4)

This is an oddball approach to the problem.
Run with the -p command line argument.
I saw a Perl answer below that used a special variable to print more text - and thus shorten their byte count. So I used a much more verbose special variable. It prints 8 characters with a 2 character variable name. Thus, with a byte count of 16 (padded with one whitespace character to make it 16), it prints 2 * $], where $] is the Perl version printed as 5.xxxxxx, dependent upon your Perl version. Without input it prints it four times, equaling 8*4 or 32, which is double the byte count of the code.
I love Perl.

I think this fails for empty input. Per the rules, if no input is provided, the multiple should default to 2.

@AlexA. Damn, I missed that. New to code golf. Edit incoming, but my answer has a lot of characters now because I have no idea how to do this more creatively in perl :(

Hey there, a few more tips that might help you here, by default in a program script, pop and shift work on @ARGV (in a sub they work on @_) so you could do something like $n=pop||2 to get the first code block down, and you have ;} at the end, which can almost always be just } to save another. Something that might help you save more chars is the string repetition operator x, consider print 1x20 or something along those lines... :) Hope that helps!

@DomHastings Man, thanks! I got it down to 2 bytes total because of your help :) Thank you very much for your suggestions.

I think you can shorten it to this print"n"x(21*pop||42). Run on the command line with perl -e'print"n"x(21*pop||42)' 3 | wc -c

@chilemagic Right you are! although no command line arguments are needed, you can run this straight from a .pl script file. That also saves some bytes, as one must count the bytes from special command line arguments if used. You've saved me 6 bytes however :) Thank you very much.

Updated the answer to use -p instead of taking command line arguments.

JavaScript, 4 bytes
+1/0

Prints Infinity
I think this is the shortest possible JS solution without ES6 :P

What version of NodeJS do you have? This doesn't work with mine.

This also works on Firefox console.

The trailing newline should be included in the output length.

Node.js v0.10.40 doesn't print anything at all because there's no print command. Do you have a different version of Node.js or does this only work in a shell that prints the evaluation of a line? (in which case I don't think this answer would be valid).

4 bytes? Please make this actually like, the correct size.

You could do math ones like 1e5 without ES6

Im assuming that the file the code is stored in is main.js and the source is +1/0 — 4 bytes

You should mark this as Node.js

What about !0?

C, 27 25
main(){printf("%50f",0);}

•Thanks @Titus for knocking off 2 bytes

And for my non-competing 16 byte solution in C, go here: https://codegolf.stackexchange.com/a/111330/16513
^I say non-competing because the error code could possibly depend on your compiler, Also note I'm using GCC in that solution. Also I'm not certain if it breaks rule 1 or not, I think it probably does so I went ahead and labeled it non-competing

I do not think that counts as a valid C program but main(){printf("%0.XXf",0);} works.

But you have to #include <stdio.h>, right?

@Zereges No, C has the "implicit declaration" rule that usually lets you use stuff without the proper #include. The compiler will emit a warning, and it will sometimes crash, but it will usually work.

@ryvnf  Thanks, good point! Got it in. :)

@anatolyg Thanks for the reference :D

@anatolyg From what you've posted, it seems, that it is undefined behaviour. So I would recommend adding at least one compiler, which handles this correctly as well as explanation, that this is UB. See this link.

@AlbertRenshaw Also, I do not think it works here.

Note that 27*2 != 38.

@Zereges.  This code does not exhibit undefined behaviour.  The "implicit declaration" and "implicit return type" features are deprecated in recent standards, but their usage is still permitted and results are well defined.  There are circumstances in using such features causes undefined behaviour, but this code does not involve those.

@Peter The undefined behavior here is not because of an implicit declaration - it's because of trying to extract double from a va_list which contains an int.

Well that's easily fixed.  Change the 6 to a 7 and add a . after the 0.

This compiles for me in Visual Studio Community 2013 using a C++ project and adding the above code to source.c with no other files, and runs from the Windows command prompt. As mbomb007 points out, 272!=38. However, 272=54, which can be achieved by changing the '%0.36' to '%0.52' with no change in code length.

@MichaelS Ah sorry haha, they suggested I add "Main(){}" and I did and forgot to adjust that number as well to fit the new length, rookie mistake lol — fixed it now!

Can´t You use %50d?

@Titus creates nonsense on my IDE, but said nonsense is indeed 50 bytes. Editing now, thanks

Couldn't you have less letters in title style? GRRRRRR...

Macaroni 0.0.2, 23 chars
print tobase pow 32 9 2

Prints 329 in binary, which happens to conveniently turn out to be 46 characters long (it's 1000000000000000000000000000000000000000000000), without a trailing newline.

V, 2 Bytes
4é

This outputs
ÿÿÿÿ

Try it online!
Explanation
This is a really hacky answer, and it works by abusing the internals of V. Essentially how it works is that ÿ is a command in V that signals the program is over, and any pending commands must complete. Otherwise, some implicit endings would not work, and the interpret would hang more often. This command is automatically sent several times at the end of the program, and most of the time has no effect on the output.
é is a command that inserts a single character. However, it does it by grabbing a raw byte, so it doesn't interpret ÿ as "end", it interprets it as "this is the character you need to insert." 4é makes it insert this character 4 times instead of one.

JavaScript ES6, 33 - 25 = 8
(a=2)=>Array(a*33).fill(0).join``

Try it online!

I can't seem to make this code run on console. Is it right? "Uncaught SyntaxError: Unexpected token =>"

@Malavos you need an es6 compliant browser such as the latest Firefox. Chrome doesn't support default args afaik

I'm using UCBrowser, but that's right! It's based on chromium and gecko anyway. Tried it on nightly, got "000000000000000000000000000000000000000000000000000000000000000000". Nice! Could you explain your code for me? I'm a newbie.

@Malavos The hardcoded 33 is actually the length of the code. It creates a new array with length 33*a where a is the input parameter defaulting to 2 as per the OP, fills it, and returns a joined string.

By creating your array with one extra element you can fill with the join
Arrary(1+a*<length>) and join\0``

bash, 11 bytes
Here's a pleasingly ironic usage of a data compression tool :) ...
gzip -f<<<2
Here's a hex dump of the output (22 bytes)...
0000000: 1f 8b 08 00 e3 ce 32 59 00 03 33 e2 02 00 90 af  ......2Y..3.....
0000010: 7c 4c 02 00 00 00                                |L....

This outputs 22 bytes of "extended ASCII" (eg. 8 bits per character).  This seems to meet the OP's definition of ASCII if you read the comments on the Question post.

On TIO I got 16, but on my linux machine, I got 34

@StanStrum, I don't know what TIO is, but that 34 under linux is odd.  Perhaps you have gzip aliased to use different switches to normal?

I don't know if that's the case, but that does seem odd. I'll try it on some LiveCDs to see if I messed it up with one of my programs @Wossname

I think I originally used a stock Centos 7 install to create this answer.  It worked at the time +shrug+.

On my fresh LiveCD, I got 16

Beats me then.  GIve it a downvote, since it's not universal.  No worries. :)

I'm not that guy, and I won't take advantage of my newly earned 129 rep tyvm. I'll see if I can make a version that works on my Linux installation

CJam, -9
q_,{i}{;2}?G*'X*

Explanation

q_,

Reads the entire input and pushes it, then pushes the length.

{i}{;2}?

If the length of the input is over zero, convert it to an integer. Otherwise, pop the input and push 2.

G*

Pushes 16 (the program length), then multiplies it by 2 if there is no input, or by the input.

'X*

Pushes X and multiplies it by the top of the stack.

@ThomasKwa Whoops. Updating in a sec.

The comma is not necessary, however you can avoid the "if" altogether if you do a logical "or": q2e|i will give you the number you want

Also you could use S instead of 'X, the only issue is that the output will not be visible until you select it (well, if you run it offline and redirect to a file, it's not a problem)

Uh.. nevermind, I just saw Dennis's answer now :p

Even with the conditional, you can shorten this. You don't need to calculate the length, since an empty string is already falsey. You also don't need to pop the empty string off the stack, since it does not contribute to the output. Which also allows yo to avoid the braces for the else branch. I came up with this before I looked at any of the answers: r_{i}2?SB**.

><>, 19 + 2 (-v flag) - 25 = -4 bytes
l?!2f4+*v
-1o;!?::<

test it here!
Thanks Cole and Sp3000
First checks the stack length, if it's 0 put 2 on the stack. Multiplies it by 21 (code length), then outputs the unicode representation of that number and decrements it by 1, loops until 0. (you'll have to inspect the output to see the characters, since the browser won't display them)

Yeah, sorry to ruin your answer (but it is shorter than mine, if that makes you feel better). Edit: whoops hit enter too soon, your entry as it stands right now is not valid per the rule "You can assume that n will always be a positive integer. If no input is provided, n must default to 2." I also think it might print one too many characters (It goes from 14 to 0 which is 15 characters by my count, not 14). If I'm correct, l0=?2f6+*v as the first line and 1-::0=?;o> as the second should make it right.

Hm, not sure what you mean. It shouldn't print 0 in any case. Putting a 2 as the initial stack outputs (EDIT: stuff i can't paste) which, at least using this char counter, is 28 chars.

I understand what you're saying now. I interpreted "Your program can optionally take a number, n, as input" meaning that if the input would be 2. I'll edit the answer, thanks! (also i can save some by using a string instead of numbers)

Happy to help, especially if it's ><>.

?! is usually better than 0=?

@Sp3000 oh man i can't believe i didn't realize this. Edited, thanks!

Out-golfed

dc, 19 - 25 = -6
2?19*[1n1-d0<l]dslx

Takes a number (2 is pushed to the stack as backup) and multiplies it by 19. Prints a 1 (no newline) and decrements the number. Loops while the number is greater than 0.

C++, 80 bytes
#include<iostream>
int main(){int i=0;while(i<20){std::cout<<&i;i++;}return 0;}

note the newline character is two characters. (if you don't want it to be, change i<20 to i<=19 to get back to the same byte count.)
Sample output (will change every time)
0088FA0C0088FA0C0088FA0C0088FA0C0088FA0C0088FA0C0088FA0C0088FA0C0088FA0C0088FA0C0088FA0C0088FA0C0088FA0C0088FA0C0088FA0C0088FA0C0088FA0C0088FA0C0088FA0C0088FA0C

same 8 character memory address 20 times.

Some golfing hints: a for loop is shorter than a while loop and lets you drop the braces, it's slightly cheaper to use cstdio and just printf a string, and you don't need to return anything.

You can strip your approach to 63 bytes: #include<iostream> int main(){for(int i=10;--i;)std::cout<<&i;}
But there is already a shorter answer with a slightly different approach.

JavaScript (ES5), 68 bytes - 25 bonus = 43

alert(Array(1+(+prompt()||2)).join(document.scripts[0].textContent))

(in case your browser won't allow for the snippet to run for security reasons, try this fiddle http://jsfiddle.net/thePivottt/c3v20c9g/ )
This script only works in a browser following at least DOM3 (with Node.textContent) and ECMAScript 5 (or perhaps an older version). I tried to make is as standard conforming and compatible as possible. It also assumes that the script is in the first script element of the document.
It actually concatenates multiple copies of the script itself, which is pretty awesome. Note that the snippet tool on SE puts extra whitespace around the script. We could ignore that whitespace with .trim() but I don't find it necessary considering the program is perfect without SE's meddling. Just save this HTML5 file if you want to see it run perfectly.
<!DOCTYPE html>

    <title>Minimalist HTML5 page</title>

This script uses prompt and alert because console.log is not part of any standard, even if most modern browsers use it. If the number of repetitions passed is not a valid number or is empty, it defaults to 2. If the input is a decimal number, the program crashes due the the invalid array length.
The code uses a few interesting features of JavaScript:

Array(1+(+prompt()||2))

Array(INT) creates an Array of INT cells.
+prompt() takes an input and turns it into a number. If we passed the input as a string, the Array function would simply wrap it in a one-element array.
+prompt()||2 returns the input if it is truthy, else it returns 2.
This whole code creates an array of N empty elements, where N is one more than the amount of repetitions asked.

.join(document.scripts[0].textContent)

The array's join(STRING) method creates a string by concatenating all the cells, putting the provided STRING between values. In this program, there are N+1 empty elements in the array, or exactly N in-between spots. The result will be a string containing N times the provided STRING.
document.scripts[o] is the first

source: Stack Exchange

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

authors: n̴̖̋h̷͉̃a̷̭̿h̸̡̅ẗ̵̨́d̷̰̀ĥ̷̳

sort: votes


text:
PRINT like THIS
Write a program that takes an input to STDIN and makes all of the lowercase letters (including accented letters) in the 2k-1th word uppercase and all the uppercase letters (also including accented letters) in the 2kth word lowercase (k is a positive integer). The program should not affect any other characters in any word. For example, if the string is Ook! O0k!, then the output should be OOK! o0k!.
A new word is formed when there is a nonzero amount of whitespace after a non-whitespace character. Whitespace at the beginning of an input should be ignored. If a word does not contain any changed characters, the program should still consider it as a word and continue.
Sample inputs (Different inputs are separated by a blank newline). Please note the third example, which should have leading spaces, and have the first be capitalised.
Nineteen Eighty-Four (1984)

Programming Puzzles & Code Golf   -
Hooray for Code Golf Stack Exchange!

     2be or not 2be, that is the ~~~QuEsTiOn~~~

++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---.+++++++..+++.>>.<-.<.+++.------.--------.>>+.>++.

Sample outputs
NINETEEN eighty-four (1984)

PROGRAMMING puzzles & code GOLF   -
HOORAY for CODE golf STACK exchange!

     2BE or NOT 2be, THAT is THE ~~~question~~~

++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---.+++++++..+++.>>.<-.<.+++.------.--------.>>+.>++.

This is code golf, fellas. Standard CG rules apply. Shortest program in bytes wins.

I'm pretty sure I covered all the loopholes regarding whitespace and non-letter characters, but if I've missed any, please tell me.

Thanks to @Optimizer for creating the following code snippet. To use, click "Show code snippet", scroll to the bottom and click "► Run code snippet".

/* Configuration */

var QUESTION_ID = 59464; // Obtain this from the url
// It will be like http://XYZ.stackexchange.com/questions/QUESTION_ID/... on any question page
var ANSWER_FILTER = "!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe";
var COMMENT_FILTER = "!)Q2B_A2kjfAiU78X(md6BoYk";
var OVERRIDE_USER = 43444; // This should be the user ID of the challenge author.

/* App */

var answers = [], answers_hash, answer_ids, answer_page = 1, more_answers = true, comment_page;

function answersUrl(index) {
  return "http://api.stackexchange.com/2.2/questions/" +  QUESTION_ID + "/answers?page=" + index + "&pagesize=100&order=desc&sort=creation&site=codegolf&filter=" + ANSWER_FILTER;
}

function commentUrl(index, answers) {
  return "http://api.stackexchange.com/2.2/answers/" + answers.join(';') + "/comments?page=" + index + "&pagesize=100&order=desc&sort=creation&site=codegolf&filter=" + COMMENT_FILTER;
}

function getAnswers() {
  jQuery.ajax({
    url: answersUrl(answer_page++),
    method: "get",
    dataType: "jsonp",
    crossDomain: true,
    success: function (data) {
      answers.push.apply(answers, data.items);
      answers_hash = [];
      answer_ids = [];
      data.items.forEach(function(a) {
        a.comments = [];
        var id = +a.share_link.match(/\d+/);
        answer_ids.push(id);
        answers_hash[id] = a;
      });
      if (!data.has_more) more_answers = false;
      comment_page = 1;
      getComments();
    }
  });
}

function getComments() {
  jQuery.ajax({
    url: commentUrl(comment_page++, answer_ids),
    method: "get",
    dataType: "jsonp",
    crossDomain: true,
    success: function (data) {
      data.items.forEach(function(c) {
        if (c.owner.user_id === OVERRIDE_USER)
          answers_hash[c.post_id].comments.push(c);
      });
      if (data.has_more) getComments();
      else if (more_answers) getAnswers();
      else process();
    }
  });
}

getAnswers();

var SCORE_REG = /<h\d>\s*([^\n,<]*(?:<(?:[^\n>]*>[^\n<]*<\/[^\n>]*>)[^\n,<]*)*),.*?(\d+)(?=[^\n\d<>]*(?:<(?:s>[^\n<>]*<\/s>|[^\n<>]+>)[^\n\d<>]*)*<\/h\d>)/;

var OVERRIDE_REG = /^Override\s*header:\s*/i;

function getAuthorName(a) {
  return a.owner.display_name;
}

function process() {
  var valid = [];

  answers.forEach(function(a) {
    var body = a.body;
    a.comments.forEach(function(c) {
      if(OVERRIDE_REG.test(c.body))
        body = '
' + c.body.replace(OVERRIDE_REG, '') + '
';
    });

    var match = body.match(SCORE_REG);
    if (match)
      valid.push({
        user: getAuthorName(a),
        size: +match[2],
        language: match[1],
        link: a.share_link,
      });
    else console.log(body);
  });

  valid.sort(function (a, b) {
    var aB = a.size,
        bB = b.size;
    return aB - bB
  });

  var languages = {};
  var place = 1;
  var lastSize = null;
  var lastPlace = 1;
  valid.forEach(function (a) {
    if (a.size != lastSize)
      lastPlace = place;
    lastSize = a.size;
    ++place;

    var answer = jQuery("#answer-template").html();
    answer = answer.replace("{{PLACE}}", lastPlace + ".")
                   .replace("{{NAME}}", a.user)
                   .replace("{{LANGUAGE}}", a.language)
                   .replace("{{SIZE}}", a.size)
                   .replace("{{LINK}}", a.link);
    answer = jQuery(answer);
    jQuery("#answers").append(answer);

    var lang = a.language;
    lang = jQuery(''+lang+'').text();

    languages[lang] = languages[lang] || {lang: a.language, lang_raw: lang, user: a.user, size: a.size, link: a.link};
  });

  var langs = [];
  for (var lang in languages)
    if (languages.hasOwnProperty(lang))
      langs.push(languages[lang]);

  langs.sort(function (a, b) {
    if (a.lang_raw.toLowerCase() > b.lang_raw.toLowerCase()) return 1;
    if (a.lang_raw.toLowerCase() < b.lang_raw.toLowerCase()) return -1;
    return 0;
  });

  for (var i = 0; i < langs.length; ++i)
  {
    var language = jQuery("#language-template").html();
    var lang = langs[i];
    language = language.replace("{{LANGUAGE}}", lang.lang)
                       .replace("{{NAME}}", lang.user)
                       .replace("{{SIZE}}", lang.size)
                       .replace("{{LINK}}", lang.link);
    language = jQuery(language);
    jQuery("#languages").append(language);
  }

}
body { text-align: left !important}

#answer-list {
  padding: 10px;
  width: 290px;
  float: left;
}

#language-list {
  padding: 10px;
  width: 290px;
  float: left;
}

table thead {
  font-weight: bold;
}

table td {
  padding: 5px;
}

<link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/codegolf/all.css?v=83c949450c8b">

Shortest Solution by Language

Language	User	Score

Leaderboard

	Author	Language	Size

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

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

What about accented characters? Do we have to ignore those? Are functions allowed?

I didn't have accente characters in mind when I wrote the question, but I suppose they would count. Functions are allowed.

Which whitespace characters do we have to account for? Can we assume that non-whitespace characters will be printable?

All whitespace characters, and yes.

If you require accented characters, you should add a test case for them.

Vim script, 22 21 bytes
nm Q vEUWvEuWQ|norm Q

Explanation:
The first command maps Q to:
vEU make word uppercase
W go to next word
vEu make word lowercase
W go to next word
Q repeat recursive mapping
and |norm Q executes the mapping
Usage of the program
This is how you get Vim to read from stdin:
$ vim - -c 'nm Q vEUWvEuWQ|norm Q'
Vim: Reading from stdin
This is the first line!
This is the second line!
This is the third and last line I type to check if this works!
^D

This will open up Vim displaying this:
THIS is THE first LINE.
this IS the SECOND line.
THIS is THE third AND last LINE i TYPE to CHECK if THIS works!
~
~
~

GNU sed, 28
Score includes +2 for -rz passed to GNU sed.
s/(\S+\s*)(\S*)/\U\1\L\2/g

Test output
$ for t in 'Nineteen Eighty-Four (1984)' \
> 'Programming Puzzles & Code Golf   -
> Hooray for Code Golf Stack Exchange!' \
> '     2be or not 2be, that is the ~~~QuEsTiOn~~~' \
> '++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---.+++++++..+++.>>.<-.<.+++.------.--------.>>+.>++.'; do
> echo "$t" | sed -zrf PRINTlikeTHIS.sed
> done
NINETEEN eighty-four (1984)
PROGRAMMING puzzles & code GOLF   -
HOORAY for CODE golf STACK exchange!
     2BE or NOT 2be, THAT is THE ~~~question~~~
++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---.+++++++..+++.>>.<-.<.+++.------.--------.>>+.>++.
$

Perl, 26 bytes
25 bytes code + 1 byte command line
s/\S+/++$i%2?uc$&:lc$&/eg

Thanks to ThisSuitIsBlackNot for fixing a couple of bugs!
Usage:
perl -p entry.pl

Pyth, 23
jdmjbmrk=xZ!!kcdbcjb.zd

Try it online or run the test suite
Alternates between pyth's lower and upper functions, which are r...0 or r...1. This will probably affect unicode characters, waiting on OP clarification to change.
I feel like something must be golfable. Particularly the XOR to change the switch on which of upper/lower should be used.

If I interpreted the question correctly, input A\nB should print A\nb.

That is not a correct interpretation of the question. A new word is formed when there is a nonzero amount of whitespace after a non-whitespace character. The output for A\nB is A\NB. But it seems like your CJAM answer got it right.

@Dennis thanks, should be fixed now.

JavaScript ES6, 74 71 bytes
.toUpperCase() and .toLowerCase() absolutely slaughter the byte count (adds 32 bytes 0.o). Most work-arounds end up with more bytes though
s=>s.replace(/(\S+\s*)(\S*)/g,(_,a,b)=>a.toUpperCase()+b.toLowerCase())

Perl, 87 bytes
After screwing with both regular expressions and map for a while, I could not come up with an elegant solution, so this is the result:
@a=split(" ",lc(<>));while($i<=$#a/2){@a[$i*2]=uc(@a[$i*2]);$i++;}print(join(" ", @a));

Nice solution.  Could  be replaced with <> to save a few bytes?  Also,  could the $i=0 be skipped?

@steve Thanks; and yes, that along with a minor fix (tested it with a different input, and it had a small error,) are now included. Thanks for the ideas! I'm very used to verbose, explicit coding :P

@Codefun64 Welcome to PPCG! You can skip most of your parentheses to save more bytes as they're optional in Perl, eg. lc(<>), could be lc<> and using a statement modifier for your while allows you to skip the parenthesis too eg. print$i++while$i<10 vs. while($i<10){print$i++}. There's a useful page that helped me a lot Tip for Golfing in Perl

Ruby, 56 bytes
$><<gets.gsub(/\S+/){($.+=1)%2>0?$&.downcase: $&.upcase}

Delphi, 290 bytes
program P;uses SysUtils;var s:string;i:word;w:byte;f:boolean;begin repeat readln(s);w:=0;f:=false; for I:=1 to length(s) do begin if s[i]>' ' then begin if w=0 then f:=not f;w:=1;if f then s[i]:=uppercase(s[i])[1] else s[i]:=lowercase(s[i])[1] end else w:=0 end;writeln(s)until false;end.

Not really a good language to golf with ...

Welcome to Programming Puzzles & Code Golf!

Groovy, 108 125 120
System.in.eachLine{def b;it.split(" ").any{if(!it.empty)b=!b;print "${b?it.toUpperCase():it.toLowerCase()} "};println()}

Not as clean as I was hoping it would be, which seems to be a theme with my Groovy answers.

+17 to fix behavior with leading whitespace
-5 for removing trailing newline and switching from .isEmpty() to .empty

$ cat tests.txt
Nineteen Eighty-Four (1984)

Programming Puzzles & Code Golf   -
Hooray for Code Golf Stack Exchange!

     2be or not 2be, that is the ~~~QuEsTiOn~~~

++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---.+++++++..+++.>>.<-.<.+++.------.--------.>>+.>++.
$ groovy PRINTlikeTHIS.groovy < tests.txt
NINETEEN eighty-four (1984)

PROGRAMMING puzzles & code GOLF   -
HOORAY for CODE golf STACK exchange!

     2BE or NOT 2be, THAT is THE ~~~question~~~

++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---.+++++++..+++.>>.<-.<.+++.------.--------.>>+.>++.

Lua, 96 bytes
i=0 print(io.read'*l':gsub('%S+',function(x)i=i+1 return i%2==1 and x:upper() or x:lower()end))

This prints out a number after the output.

Pyth, 17 22 bytes
FGcwd=+YrG=Z%+1Z2;jdY

Try it here

Leading space case fails but still nice.

This also does not handle input on more than one line, and prints a trailing space.

I'll refactor when I can, thanks :D

Python 3, 103 95 bytes
print(' '.join(b.lower()if a%2 else b.upper()for a,b in enumerate(input().strip().split(' '))))

You can replace the conditional with [b.upper(),b.lower()][a%2] to save 4 bytes (assuming I counted correctly on mobile).

STATA, 252 bytes
insheet using a.b
g b=word(v,1)
gl c=0
forv x=1/`=_N'{
loc d=1
while b[`x']!=""{
if !$c replace v=subinword(v,b,upper(b),1) if `x'==_n
if $c replace v=subinword(v,b,lower(b),1) if `x'==_n
loc ++d
replace b=word(v,`d') if `x'==_n
gl c=1-$c
}
di v[`x']
}

Expects input as a csv file (one column) called a.b.
Explanation:
Read data in (default variable name is v1, shortenable to v). Make a new variable b equal to the first word (space separated token) of v for each line. For each line, while the next word is not empty (only occurs if no more characters on that line), replace the word in v with the upper or lower case version of that word in the current line, depending on how many (mod 2) words have already been found. Then get the next word and repeat. Print out the whole line when finished with it.

Lua, 88 bytes
a=io.read():gsub("%g+",function(s)m=not m return m and s:upper()or s:lower()end)print(a)

CJam, 28 bytes
q{C' >Sc'!<*X^:XCelCeu?:S}fC

I'm currently considering the first 33 ASCII/Unicode characters (and only those) whitespace. I'm awaiting clarification to know whether this is valid or not.
Try it online in the CJam interpreter.

C#, 104 100 99 bytes
static void Main(){string.Join(" ","".Split(' ').Select((o,i)=>i++%2==0?o.ToUpper():o.ToLower()));}

It's 79 bytes with
string.Join(" ","".Split(' ').Select((o,i)=>i++%2==0?o.ToUpper():o.ToLower()));

Perl 5 + -040plF/^ +$/, 17 bytes
$_=($|-=@F)?uc:lc

Try it online!

This fails for the third test case (should be 2BE at the start)

Thanks @cairdcoinheringaahing, I think I've sorted it!

Husk, 12 bytes
z?a_mȯ%2Lwḣ¹

Try it online!
Preserves whitespace in the input, in agreement with the test cases.
z?a_mȯ%2Lwḣ¹
z             # zip two lists together,
              # using this function on each pair of elements:
 ?            # if element from list1 is truthy
  a           # uppercase the element from list2
   _          # otherwise lowercase the element from list2
    mȯ%2Lwḣ¹  # list1:
    mȯ        # map this function on each element of
          ḣ¹  # all the prefixes of the input string:
        Lw    # number of elements after splitting on whitespace
      %2      # modulo 2
              # list2: the input string

A different program which uppercases & lowercases in words, and does "not affect any other characters in any word" (which I wrote  after reading the instructions, but before realising that the third "Sample output" should also be considered as part of the specification), could be only 10 bytes:
wzom?a_İ¬w

Try it online!

This fails for the third example (not the lack of leading spaces)

@cairdcoinheringaahing Fixed now (I hope) for +2 bytes...

PowerShell, 106 bytes
$k=@();$i=0;$args[0].trim().split(' ')|%{if($i%2){$k+=$_.tolower()}else{$k+=$_.toupper()};$i++};$k-join" "

Try it online!
Shameless port of python 3 solution, Just horrible attempt to golf ;-(

This fails for the third test case

@cairdcoinheringaahing edited, added .trim() python .strip()

The program should maintain leading spaces unfortunately

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

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


text:
Measuring Rectangles
Challenge
Your goal is to write a program which will output the 8 measurements of a rectangle, with only some measurements in the input. Your program should throw an error if it cant be done.
Here is what each measurement means:
|          left
|          |      centerX
|          |      |      right
|          |      |      |
|          v      v      v
|           _____________
|       ^  |             |  <---top
|       |  |             |
|       |  |             |
|height |  |             |  <---centerY
|       |  |             |
|       |  |             |
|       v  |_____________|  <---bottom
|
|          <----width---->
|________________________________________

Input/Output Formats:
Input is in the form of some measurements of a box, one on each line. Output should be all 8 measurements of the corresponding box (or an error if the given measurements can not be used to find the other measurements).
For example, an input of
left 6
centerX 10
top 40
height 20

should print out
left 6
right 14
top 40
bottom 20
centerX 10
centerY 30
width 8
height 20

This is code-golf, so the shortest code wins.

It's unclear what the input should be.

I don't get it. Generally, you will need 4 values (two of the horizontal, two of the vertical) to define the rectangle. Is the goal to get 4 values as input, and produce all of the values in the list? Just guessing, because it seems quite unclear.

The first sentence is a bit unclear as well—does only two pairs mean 4? This seems to conflict with the second sentence, given any pair of coordinates.

i added some edits,  sorry for the phrasing!

Is my attempt as a function valid? MFC: https://pastebin.com/raw/Pbi68pLj

Python 2 with SWI Prolog ('typical' install), on Windows, 595 565 bytes.
import sys,subprocess as w;o='left right top bottom centerX centerY width height'
g={k:v for k,v in [l.strip().split() for l in sys.stdin.readlines()]};s='L,R,T,B,C,D,W,H';
open('t','w').write(
":-use_module(library(clpfd)).\nr(%s):-L#=R-2*(R-C),L#=R-W,L#=C-W//2,B#=T-2*(T-D),B#=T-H,B#=D-H//2,%s."%
(s,','.join('writeln(%s)'%x for x in s.split(','))));r='\n'.join([a+' '+b for (
a,b) in zip(o.split(),w.check_output("swipl -q -f t -t r(%s)."%(','.join(g.get(
x,x[0].replace('centerY','d').upper()) for x in o.split()))).split('\r\n'))])
print '!' if '_' in r else r

e.g. with a text file for input, containing:
right 14
centerX 10
top 40
height 20

it does this:
D:\>type rectin.txt|c:\python27\python.exe d:\rect.py
left 6
right 14
top 40
bottom 20
centerX 10
centerY 30
width 8
height 20

And in the error condition if the contents of the stdin file are not enough to calculate the other values, it does this:
D:\>type rectin.txt|c:\python27\python.exe d:\rect.py
!

NB. It relies on swipl.exe being in the PATH
Explanation
I started writing in Python, got bored of expressing all the possible combinations of relationship (each one can be derived from three different combinations). I thought "must be a job for Prolog". So I installed a Prolog, headed for a tutorial, and got something that just about works. It's this:
:-use_module(library(clpfd)).

r(L,R,T,B,C,D,W,H):-
    L#=R-2*(R-C),
    L#=R-W,
    L#=C-W//2,
    B#=T-2*(T-D),
    B#=T-H,
    B#=D-H//2,

    writeln(L),
    writeln(R),
    writeln(T),
    writeln(B),
    writeln(C),
    writeln(D),
    writeln(W),
    writeln(H).

It uses the clpfd library (part of the 'typical install' requirement), which provides 'declarative integer arithmetic'. This gives the big advantage that I only need to define Left in terms of (Right and CenterX), (Right and Width), (CenterX and Width). From that, it can derive Right, Center and Width. (Same with the vertical set Top/Bottom/CenterY/Height).
This also means I don't have to check which specific values are provided; I give all the available values and placeholders for the rest, and it either calculates the answers, or outputs some unknown variable placeholders.
Being extremely novice at Prolog, handling STDIN was too much for me right now, so I wrapped it with Python. I don't have an ungolfed version of the Python, but it's not doing anything too amazing; it reads STDIN into a dictionary of {measurement:value} pairs, then puts them in the preset order the Prolog code is expecting, merged with the uppercase first letter of the unknowns.
(There's an annoyance where all the measurements are unique by first letter, except centerX and centerY, so it replaces centerY with D).
Then it writes the Prolog script out to a file, shells out to Prolog to run it and read the result, parses the number output and pairs them up with the measurements in order.
Then checks if any of the outputs were uncomputable and throws an error (!), otherwise prints the result.

Awesome use of Prolog and CLP(FD) constraints! You can combine all these writeln/1 calls into a single call of format/2. For example, try: ?- format("~w~n~w~n~w~n", [a,b,c]). to see what I mean. To read from standard input, I recommend you use a DCG and then apply the DCG to user_input with SWI-Prolog's library(pio) and phrase_from_stream/2. See library(dcg/basics) for some useful definitions. I hope that this will allow you to shorten your code significantly.

@mat Thanks for the suggestions! (But they look too intimidating. I think I lucked out with how easy CLP(FD) is to use, after that I couldn't even make a recursive list-is-sorted-if predicate. I'm nowhere near applying a DCG to an io stream). (All my writeln/1 calls are generated from a Python list comprehension, they're already shorter than a basic format("~w~n~w~n~... call would be, even if I had known it existed).

MFC, 212
void P(int l,int t,int r,int b){CRect R(l,t,r,b);POINT c=R.CenterPoint();TRACE("Left:%d Top:%d Right:%d Bottom:%d CenterX:%d CenterY:%d Width:%d H:%d",R.left,R.top,R.right,R.bottom,c.x,c.y,R.Width(),R.Height());}

MFC, 213
void P(int l,int t,int r,int b){CRect R(l,t,r,b);CPoint c=R.CenterPoint();TRACE("Left:%d Top:%d Right:%d Bottom:%d CenterX:%d CenterY:%d Width:%d H:%d",R.left,R.top,R.right,R.bottom,c.x,c.y,R.Width(),R.Height());}

Outputs the result to Visual Studio's Debug Output Window.
Example:
P(12,7,23,30);

outputs
Left:12 Top:7 Right:23 Bottom:30 CenterX:17 CenterY:18 Width:11

Uncondensed format:
void P(int l, int t, int r, int b)
{
    CRect R(l, t, r, b);
    CPoint c= R.CenterPoint();
    TRACE("Left %d Top:%d Right:%d Bottom:%d CenterX:%d CenterY:%d Width:%d H:%d", R.left, R.top, R.right, R.bottom, c.x, c.y, R.Width(), R.Height());
}


text:
Python Golfing Suggestions
I have read: Tips for golfing in Python
I would like to golf this code further. Any more tips?
x,y,q,w=[int(i) for i in raw_input().split()]
while 1:
 a=int(input())
 s=d=""
 if q>x:
  s="W"
  q-=1
 elif q<x:
  s="E"
  q+=1
 if w>y:
  d="N"
  w-=1
 elif w<y:
  d="S"
  w+=1
 print d+s

The program:
You move on a map which is 40 wide by 18 high. Thor is initially placed on a random spot on the map and must reach the light of power as quickly as possible. You need to have the shortest code possible.
During each turn, you must specify in which direction to move, from one of the following:
N (North)
NE (North-East)
E (East)
SE (South-East)
S (South)
SW (South-West)
W (West)
NW (North-West)
YOU WIN WHEN THOR REACHES THE LIGHT OF POWER.
YOU LOSE:
if Thor moves off the map.
if Thor doesn't have enough energy left to reach the light of power.
EXAMPLE: THOR STARTS ON THE MAP ON THE SQUARE (3, 6). THE LIGHT OF POWER IS ON SQUARE (3, 8).
TURN 1
THOR MOVES SOUTHWARDS. NEW POSITION = (3, 7). THOR HAS ENOUGH ENERGY LEFT FOR 10 MOVES
TURN 2
THOR MOVES SOUTHWARDS. NEW POSITION = (3, 8). THOR HAS ENOUGH ENERGY LEFT FOR 9 MOVES
The program must first read the initialization data from standard input. Then, within an infinite loop, read the data from the standard input related to Thor's current state and provide to the standard output Thor's movement instructions.
INITIALIZATION INPUT:
Line 1: 4 integers indicate the position of the light of power. 2 indicate Thor’s starting position.
INPUT FOR ONE GAME TURN:
Line 1: The level of Thor’s remaining energy. This represents the number of moves he can still make.
OUTPUT FOR ONE GAME TURN:
A single line providing the move to be made: N NE E SE S SW W or NW
Edit : it's a code golf on codingame.com

To give you golfing tips, we need to know what your code is supposed to achieve. For example, a=int(input()) strikes me as odd, since you don't use a anywhere.

It is the remaining energy to see if I can move or not, I guess I never run out of energy in the simple test.

The description hardly matches the code.

x,y,q,w=map(int,raw_input().split()) saves 9 characters

N.B.: This may not be entirely correct as I don't know what your code is supposed to do
The first thing to do is remove unnecessary whitespace, especially that after the if statements:
x,y,q,w=[int(i) for i in raw_input().split()]
while 1:
 a=int(input())
 s=d=""
 if q>x:s="W";q-=1
 elif q<x:s="E";q+=1
 if w>y:d="N";w-=1
 elif w<y:d="S";w+=1
 print d+s

This golfs your code down by 4 bytes.
What would be ideal for this challenge is a switch case  which, unfortunaley, does not exist in Python. Instead we can be clever with an array's index:
x,y,q,w=[int(i) for i in raw_input().split()]
while 1:
 a=int(input())
 s=d=""
 exec(['s="W";q-=1','s="E";q+=1'][q<x])
 exec(['d="N";w-=1','d="S";w+=1'][w<y])
 print d+s

Saving you x bytes.
Finally  you can get rid of all whitespace now:
x,y,q,w=[int(i) for i in raw_input().split()]
while 1:a=int(input());s=d="";exec(['s="W";q-=1','s="E";q+=1'][q<x]);exec(['d="N";w-=1','d="S";w+=1'][w<y]);print d+s

I think you have a bug where you don't allow q==x or w==y to do nothing; you always move Thor in a diagonal, never in a horizontal or vertical.

if q>x:s="W";q-=1, I though I tried this? Doesnt it need a tab character?

@TessellatingHeckler Yeah, that's a major glaw :P

You did not get rid of the space in int(i) for...

@Jonathan I can't remember exactly, but I think removing that space breaks the code for some reason

@BetaDecay Well, seems odd. But in that case I get why it stood.

Umm… switch case does exist in python, it’s just match case.


text:
Palindrome Hello, World
Your task is to create a program that prints "Greetings, Planet!" exactly to the console. Seems simple enough, right? Well, here's the trick. The code must be a palindrome, meaning it reads from right to left the same as in left to right.
Standard loopholes are NOT allowed.

This does not seem to be "hello world".

@ΈρικΚωνσταντόπουλος It's the same as Hello World for all intents and purposes. The goal is to print a short string consisting of two words with the punctuation common in Hello World programs as well. Apart from built-ins that print Hello World, solutions will be absolutely identical (apart from the actual string) regardless of the actual string being printed. (And I assume the phrase "Greetings, Planet!" was chosen specifically to make built-ins useless.)

@MartinBüttner I think that Hello, world! and Hello World! are the only outputs allowed for a [tag:hello-world] program.

///, 37 bytes
Greetings, Planet!/!tenalP ,sgniteerG

This is gonna be tough to beat.

TI-BASIC, 67 bytes
"!tenalP ,sgniteerG"
"Greetings, Planet!"

This works because the last line of a program is displayed on the screen, while the first string is essentially treated as a comment.
Each lowercase letter is stored as 2 bytes, and the remaining characters are 1 byte. If I were to bend the rules and print in all caps, it would be 41 bytes:
"!TENALP ,SGNITEERG"
"GREETINGS, PLANET!"

Can you use e and i (the numbers) to reduce byte count further?

@VTCAKAVSMoACE I considered that, but they italicized, so they look,slightly different.

To be clear the first line isn't a comment, it gets stored to the answer variable.

I know this is a bit late (and a bit finicky), but...
><> (Fish), 47 45 47 Bytes (really 43 45, if I wasn't using the randomized direction)
x"!tenalP ,sgniteerG"!|o|!"Greetings, Planet!"x

These answers are a bit different to every other; there is a chance for either direction of code to be executed.
So, by "printing to console", I assumed you meant printing to stdout. This throws an error; the error is thrown to stderr AFTER the string is printed to stdout.
To prove that this worked both ways, I used the "random direction" director, "x". Fish is a two-dimensional language, so, no matter which way the director points, the code will still (eventually) be executed.
Assuming that the first director points to the right, the characters are loaded to the "stack" in reverse order, then the reverse of the reverse (or the normal text) is printed.
Assuming that both directors point to the left, the characters are, once again, loaded to the "stack" in reverse order (because the code loads it in backwards here, direction is to the left), then the reverse of the reverse (or the normal text) is printed.
If the randomized director points up or down, this won't matter - fish knows to loop to the underside or overside of the code, pointing back to the randomizer. In this way, it will continue to loop with the randomizers until it points inward, towards the code to execute.
The !|o|! bit does the following, from both sides:

! skips the next instruction (will always skip |)
| is a reflector; it points inward back towards o.
o outputs the current item of the stack to console as a character and removes it from the stack.

So, essentially, this is the "two mirrors in a bathroom pressed up together" trick, where I output until I can't anymore.
Now using a cat emoji. >o< redirects the output inward infinitely, still throwing the error, but I can get away with not using a skip into reflection.
Turns out I was right the first time - the second attempt was not palindromic, but it was reflective.
Fish (without printing to stderr), 64 Bytes (ew)
x"!tenalP ,sgniteerG"!;oooooooooooooooooo;!"Greetings, Planet!"x

This dude's a little longer.
It has the same randomized arrow function (to prove it works both ways) and does not print to stderr.
The difference here is obvious; I literally print out every item in the stack, then end execution with ;.
The !; does not end execution immediately, as ! skips the next item (end exec, in this case) and continues until it hits the other side, which acts as ;!, wherein it ends execution before it skips anything.
It follows the same randomized direction pattern as the shorter answer.

I think you should call the language ><> to distinguish it from the Fish shell

@Aaron It is generally assumed that Fish here means ><>, but I've encountered that problem before - I'll add it. Thanks!

as i guess , it's unpridictable wheather the full code will be excuted or not . What if program counter is stuck between two random direction instructions , or just stuck at one of the random direction instructions , for example  , it turns down , reachs the bottom , comes back to that instruction and start all over ?

@GLASSIC The program will only output once, and the entire code will never be executed.

Bubblegum, 38 bytes
0000000: 73 2f 4a 4d 2d c9 cc 4b 2f d6 51 08 c8 49 cc 4b 2d 51 04  s/JM-..K/.Q..I.K-Q.
0000013: 04 51 2d 4b cc 49 c8 08 51 d6 2f 4b cc c9 2d 4d 4a 2f 73  .Q-K.I..Q./K..-MJ/s

Macaroni 0.0.2, 52 bytes
print "Greetings, Planet!""!tenalP ,sgniteerG" tnirp

A solution that doesn't use comments. (Mostly because Macaroni doesn't have comments...)

Macaroni doesn't have comments? ಠ_ಠ

CJam, 41 bytes
Thanks to Dennis for the three bytes off.
"!tenalP ,sgniteerG";"Greetings, Planet!"

You need to flip the strings. Right now you're popping the right output and printing the reversed one.

@NinjaBearMonkey Whoops. Fixing.

Also works in GolfScript.

Foo, 39 bytes
"Greetings, Planet!"!tenalP ,sgniteerG"

Try it online.

!tenalP ,sgniteerG"Greetings, Planet! saves a few bytes.

JavaScript, 56 bytes
This can run in any browser.
alert("Greetings, Planet!")//)"!tenalP ,sgniteerG"(trela

Replacing print/tnirp with alert/trela, it works in other engines, too.

@ETHproductions can't believe I didn't think of that, thanks!

Template Strings? demo

@jrich your're right, alert\Greetings, Planet!`//`!tenalP ,sgniteerG`trela` is 52 bytes

C++, 129 bytes
Trying to do this without comments led me into a deep, dark preprocessor nightmare with no way out that I could see. Instead I've just aimed to get it as short as possible.
/**/
#include<cstdio>
int main(){puts("Greetings Planet!");}//*/
/*//};)"!tenalP sgniteerG"(stup{)(niam tni
>oidtsc<edulcni#
/**/

Jelly
25 bytes
»1ị“RsẈḄ,#ʠU“Uʠ#,ḄẈsR“ị1»

Look 'ma, no comments! Try it online!
How it works
»1ị“RsẈḄ,#ʠU“Uʠ#,ḄẈsR“ị1»  Main link. No arguments.

   “        “        “  »  Decompress all three strings; yield a list of strings.
    RsẈḄ,#ʠU               (decompresses to 'Greetings, Planet!')
             Uʠ#,ḄẈsR      (decompresses to ' WafdkmC Posited,')
                      ị1   (decompresses to 'Taarhus')

»1                         Take the maximum of the default argument (0) and 1.
  ị                        Select the string at the index to the left.

GolfScript, 41 bytes
"Greetings, Planet!":"!tenalP ,sgniteerG"

Look ma, no no-ops! Try it online in Web GolfScript.
The second half of the source code stores the string in the second string.
"Greetings, Planet!":"!tenalP ,sgniteerG"
"!tenalP ,sgniteerG"

would print
Greetings, Planet!Greetings, Planet!

Python 3, 57 bytes
print('Greetings, Planet!')#)'!tenalP ,sgniteerG'(tnirp

I fixed the issue with parenthesis.
Python 2, 53 bytes
print'Greetings, Planet!'#'!tenalP ,sgniteerG'tnirp

I used advantage of the lack of required parenthesis and spaces in Python 2, but there wasn't that big of a difference.

Stuck, 41 Bytes
"Greetings, Planet!"p"!tenalP ,sgniteerG"

Fairly similar to the CJam answer, except in Stuck if a print command is issued, automatic stack printing is suppressed.

05AB1E, 16 bytes
Code:
”!º¥,ÁÙ””ÙÁ,¥º!”

Explanation:
”!º¥,ÁÙ”          # Compressed string which results in "! Crm, Everywhere".
        ”ÙÁ,¥º!”  # Compressed string which results in "Greetings, Planet!".
                  # Top of stack is implicitly outputted.

Try it online!

Mathematica, 52 bytes
Print@"Greetings, Planet!""!tenalP ,sgniteerG"@tnirP

Also generates a Null "!tenalP ,sgniteerG"[tnirP] which doesn't get printed.

FYI, a lot of your answers (this one included) have been getting tossed in the Low Quality queue because they're solely a title/score and code. Though there's nothing wrong with that, you may consider adding more text (such as an explanation) so they don't get auto-flagged.

@Mego Okay, thought they were pretty self-explanatory.

I'm not saying the lack of an explanation is a bad thing (though answers with explanations tend to get more upvotes), I'm just letting you know that your (valid) answers were getting auto-flagged because of their length. :)

you can save 2 bytes with Echo in v10.3.

Fission, 45 43 bytes
Thanks to jimmy23013 for saving 2 bytes.
;"!tenalP ,sgniteerG"R"Greetings, Planet!";

Try it online!
R initialises an atom which moves to the right. " toggles string mode which simply prints the desired string to STDOUT before hitting ;, which destroys the atom and terminates the program. The first half is simply never executed.

STATA, 52 bytes
di "Greetings, Planet!"//"!tenalP ,sgniteerG" id
A slightly longer (53 byte) version that doesn't use comments is:
#d
di "Greetings, Planet!";"!tenalP ,sgniteerG" id
d#

#d [something] changes the delimiter (initially a carriage return) to ; unless [something] is cr, so the first command changes the delimiter to ;, the second prints the string, and the third (which continues until the end) is apparently a nop, though I have no idea why. I would have guessed that this would throw an error (unrecognized command "!tenalP ,sgniteerG" or something), but apparently not.

Japt, 29 bytes
This programming language was made after the question was posted, but was not made for this question.
`!t?ÓP ,?Ä>ÎG`;`GÎ>Ä?, PÓ?t!`

Try it online!
Each ? is an unprintable Unicode char: U+0082, U+000F, U+000F, and U+0082, respectively.
Fun fact: If Japt had been published a month sooner, it would have legitimately won this challenge.

APL, 41 bytes
'Greetings, Planet!'⍝'!tenalP ,sgniteerG'

In APL, the last value is printed and the lamp character (⍝) start a comment.

Hello, and welcome to PPCG! Great answer!

GolfScript, 41 bytes
"Greetings, Planet!"#"!tenalP ,sgniteerG"

Try it online !

@muddyfish Edited. Now it is a palindrome . Sorry.

TCL, 80 Bytes
proc unknown args {puts "Hello World!"}
}"!dlroW olleH" stup{ sgra nwonknu corp

explanation:  TCL executes a global proc unknown when it encounters a call to an undefined command, the first line redefines that proc to a simple "hello world" program.
TCL's quoting rules are quite subtle, an open brace starts a quoted word that extends to the next matching close brace, allowing nested, quoted words.  Braces are otherwise treated as normal characters.  five words: }"!dlroW olleH", stup{, sgra, nwonknu and corp.  No command named }"!dlroW olleH" has been defined, so the undefined proc from the first line is invoked instead.
A similar question was posted on the StackOverflow of antiquity; which has since been closed and deleted.  I used my solution as a tongue in cheek TCL sample in this answer, and am now getting comments asking for an explanation, so I recreate my answer here.

Keg, 41 bytes
Greetings\, Planet\!#!\tenalP ,\sgniteerG

Try it online!

Try it online!

Ruby, 43 bytes
p"Greetings, Planet!"#"!tenalP ,sgniteerG"p

Lua, 52 Bytes
print"Greetings, Planet!"--"!tenalP ,sgniteerG"tnirp

In Lua terminal, it is only 44 bytes with
="Greetings, Planet!"--"!tenalP ,sgniteerG"=

My bad. Thanks for the alert!

Remove all parentheses. For functions with a single string parameter they are optional.

Lua 5.3 do not require = in terminal, so it is 2 bytes off there. I think it existed in 2015, not sure tho.

Unefunge 98 - 49 bytes
"!tenalP ,sgniteerG<DC1>"k,@,k"<DC1>Greetings, Planet!"

The code above contains two unprintable characters with code 17 (device control 1) represented by <DC1>.

Vitsy, 41 Bytes
This programming language was made after the question was posted, but was not made for this question.
"!tenalP ,sgniteerG"Z"Greetings, Planet!"
The Z character outputs everything in the stack to STDOUT.
Try it online!

MSM, 73 bytes
GGreetings, Planet!.................,.................!tenalP ,sgniteerGG

The first half just before the middle , builds a reverse greeting string including the additional G on the very right. The middle , drops it and the rest is a canonical "Hello/Greeting/whatever" program. The additional characters on both ends are needed, because the message contains a ,. The left one is executed and drops the s. Both , and s need a replacement for the left concatenation dots, hence the Gs. The , on the right isn't executed, but build into the final string.

Bash, 52 48 bytes
echo Greetings, Planet!||!tenalP ,sgniteerG ohce

Also works in ksh, zsh, yash, dash.  But not tcsh.
$ cat x.sh
echo Greetings, Planet!||!tenalP ,sgniteerG ohce
$ bash x.sh
Greetings, Planet!
$ ksh x.sh
Greetings, Planet!
$ zsh x.sh
Greetings, Planet!
$ yash x.sh
Greetings, Planet!
$ dash x.sh
Greetings, Planet!
$ tcsh x.sh
tenalP: Event not found.
$

Remove all quotes.

Oh dear, a bash answer was shorter than python =/. Back to the drawing board!

CoffeeScript, 53 bytes
Similar to Ruby and Lua and pretty much all the variants here.
alert 'Greetings, Planet!'#'!tenalP ,sgniteerG' trela

Milky Way 1.5.10, 43 41 39 bytes
"Greetings, Planet!"!tenalP ,sgniteerG"

Explanation
"Greetings, Planet!"                       # push the string to the stack
                    !                      # output the TOS
                     tenalP ,sgniteerG"    # throws an error and exits

Usage
python3 milkyway.py <path-to-code>

Did you really need a comment? If this is stack based (without implicit output), then just outputting the stack should work.

You're right! Thanks. @FlagAsSpam

jq, 44 characters
(42 charactes code + 2 character command line option.)
"Greetings, Planet!"//"!tenalP ,sgniteerG"

(Not a big deal, posted just for the sake of that operator. Yes, // is not comment, is the alternative operator: if its left operand is null or false, the right operand is returned, otherwise the left operand.)
Sample run:
bash-4.3$ jq -nr '"Greetings, Planet!"//"!tenalP ,sgniteerG"'
Greetings, Planet!

On-line test (Passing -r through URL is not supported – check Raw Output yourself.)

Emacs Lisp, 60 bytes
(message"Greetings, planet!");)"!tenalp , sgniteerG"egassem(

As you might have already guessed ; denotes a comment.

There you have some characters images reversed instead of character orders. For example if the first character is (, the last one must also be (. (See Downgoat's JavaScript answer as example.)

Fishing, Dock length 41
v+CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
  `Greetings, Planet!`P`!tenalp ,sgniteerG`

For a palindrome that also includes the dock and is measured in total bytes, this has 132 bytes.
v+CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
  `Greetings, Planet!`P`!tenalp ,sgniteerG`  CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC+v

Fishing prints the stack with P. Because the dock ends at the end of the first line, no other fish are caught or executed.

Golfscript, 41 bytes
"!tenalP ,sgniteerG";"Greetings, Planet!"
Pushes "!tenalP ,sgniteerG" to stack, removes top of stack (;), and pushes "Greetings, Planet!". Stack is printed at end of execution in GolfScript.

Self-Modifying Brainf*ck, 67 bytes
+[<[<]<[.<]-][0Greetings, Planet!0!tenalP ,sgniteerG0][-[>.]>[>]>]+

Where the 0's denote null characters.
The first <[<] moves the pointer to the beginning of the message (the last null character) And the following <[,<] reads and outputs the message until the terminating null character. This is a pretty long answer, so it probably won't stand a chance, but hey, it's pretty cool.

Fuzzy Octo Guacamole, 52 bytes
'Greetings, Planet!'X@X'!tenalP ,sgniteerG'

Pushes "Greetings, Planet!" to the stack, pop, print, and end.  ('' pushes the string, _; pops and prints, and @ terminates immediately.
Without the @, it would then print 0 after the string.

C, 72 bytes
main(){puts("Greetings, Planet!");}//};)"!tenalP ,sgniteerG"(stup{)(niam

Self-modifying Brainfuck, 47 bytes
Greetings, Planet!<[.<]<.[<!tenalP ,sgniteerG

The code contains two null-bytes, shown here as 0:
Greetings, Planet0!<[.<]<.[<!0tenalP ,sgniteerG

Try it online!
Explanation
Like the other SMBF answers, this includes the required string in the source code, along with a null-byte as an end-of-string marker. Note that SMBF is like regular BF, except that the source is copied to the front of the tape and the tape head starts at the cell just after the source code.
We can save some bytes over the other answers by putting the actual string at the end, so that we don't have to skip past the actual source code. Finally, we can save one more byte by putting the ! on the other side of the null-byte which conveniently lets us reuse the <. in the mirror image to print the last character (otherwise we'd have to double the ] to avoid that <. is executed). Here is the code:
,     Read a character, which is a no-op with no input.
<     Move tape head onto the 'G'.
[.<]  In a loop, print character, move tape head left. This prints the desired
      string except for the '!'. The loop terminates when the tape head reaches
      the null byte.
<     Move the tape head left another cell onto the '!'.
.     Print it.
[     Unmatched square bracket, terminates the program.

Hoon, 41 bytes
"Greetings, Planet!":"!tenalP ,sgniteerG"

In Hoon, a:b means "compute a in the context of b". To include a library, for example, you stick a rune that evaluates the rest of your program in the context of the core containing the library. This is possible because cores also contain the entire kernel and stdlib, so you can nest them and still compute.
Because a string literal is just a constant expression that doesn't depend on the context it is being evaluated in at all, we can replace the entire stdlib with just another constant expression and it will evaluate to the same thing.

Brachylog, 41 bytes
"Greetings, Planet!"w"!tenalP ,sgniteerG"

This will call w - write with "Greetings, Planet!" as input and "!tenalP ,sgniteerG" as output. w writes its input to STDOUT and does nothing with its output.

Pyth, 41 bytes
"Greetings, Planet!"K"!tenalP ,sgniteerG"

Prints "Greetings, Planet!", then assigns "!tenalP ,sgniteerG" to K

PowerShell, 41 bytes
"Greetings, Planet!"#"!tenalP ,sgniteerG"

Output is implied is PowerShell and anything after # is a comment.

R, 51 bytes
cat("Greetings, Planet!")#("!tenalP ,sgniteerG")tac

No really original, # indicates a commentary in R

The reversed version is )"!tenalP ,sgniteerG"(tac, not ("!tenalP ,sgniteerG")tac

Hy, 58 bytes
(print "Greetings, Planet!");;("!tenalP ,sgniteerG" tnirp)

I'm not competing.

Vyxal, 41 19 18 bytes
`!±∵ ,∴İ``İ∴, ∵±!`

Try it Online!
We can achieve this via string compression. By entering
`Greetings, Planet!`øD

We get:
`İ∴, ∵±!`

We therefore just reverse it to get:
`!±∵ ,∴İ`

The reason why I had to enter !±∵ ,∴İ is to fulfill the palindrome requirement.
Vyxal prints the last string outputted to stack, in this case ignoring the first one.

Dyalog APL, 43 bytes
'!tenalP ,sgniteerG'∘⊢∘'Greetings, Planet!'

or
'Greetings, Planet!'∘⊣∘'!tenalP ,sgniteerG'

Really cute ones, but I am afraid those with braces are not palindromes as their first and last characters are different.

@Oh, right. I'll take those away.

Mouse-2002, 47 bytes
"Greetings, Planet"33!'$'!33"tenalP ,sgniteerG"

I hate that I have to print !'s charcode because using it in a string just prints \n.
things_to_fix_in_my_mouse_reboot.append("EXCLAMATION POINTS ARE THEMSELVES, NOT NEWLINES.")

PlatyPar, 40 bytes
"!tenalp ,sgniteerG""Greetings, planet!"

Pushes the two strings to the stack. At the end of the program, the last item of the stack is printed, so the first inverted one is ignored. I see a lot of other answers like this, except mine doesn't have something between the two strings.
Try it online!

Microscript, 43 bytes
"!tenalP ,sgniteerG"aha"Greetings, Planet!"

Microscript II, 40 bytes
Noncompeting, language postdates the question.
"!tenalP ,sgniteerG""Greetings, Planet!"

Pylongolf, 43 bytes
."Greetings, Planet!"~"!tenalP ,sgniteerG".

~ prints the stack nicely, . resets the stack.
"Greetings, Planet!" pushes the sentence into the stack, ~ prints it.
The rest is a blur.
EDIT: I saved 2 bytes by removing the ~ symbols on both sides.

Java, 170 164 bytes
interface e{static void main(String[]s){System.out.print("Greetings, Planet!");}}//}};)"!tenalP ,sgniteerG"(trinp.tuo.metsyS{)s][gnirtS(niam diov citats{e ecafretni

PHP, 48 52 bytes
echo"Greetings, Planet!";//;"!tenalP ,sgniteerG"ohce

// comments out the rest of the line, leaving echo"Greetings, Planet!";.
No space is needed between echo and ", meaning this is this the shortest possible response for PHP.
Would have loved a clever excuse to use /* */, but couldn't think of one.

surely you need to add ohce to the end?

Right you are, no idea how I missed that.

Haystack, 43 bytes
"Greetings, Planet!"o|o"!tenalP, sgniteerG"

Here's how this two-dimensional program works:

"Greetings, Planet!" pushes a string whose content is Greetings, Planet! to the stack.
o prints everything in the stack.
| is the needle. The program ends because it found the needle in the haystack!
o"!tenalP, sgniteerG" isn't executed as the needle is found before reaching there.

Hello World example(s) from shebang

INXW63CTMNZGS4DU, 42 bytes
"Greetings, Planet!"#"!tenalP, sgniteerG"

A trailing newline is needed at the end
The # character start a comment, and the last value is printed, so this program print "Greetings, Planet!"

Nim, 49 bytes
echo"Greetings, Planet!"#"!tenalP ,sgniteerG"ohce

Pretty self-explanatory. Uses Nim's short echo syntax and a comment to create the palindrome.

Straw, 41 bytes
(Greetings, Planet!)>)!tenalP ,sgniteerG(

Try it online
(Greetings, Planet!) push a string on the stack, > print it. The rest of the program simply fill the stack with junk.

AWK, 66 bytes
BEGIN{print"Greetings, Planet!"#"!tenalP, sgniteerG"tnirp{NIGEB

Could save some bytes if input were allowed, but I assume it isn't.
The input required code would save 15 bytes and be run like this:
awk '{$0="Greetings, Planet!"}1#1{"!tenalP, sgniteerG"{' <<< "arbitrary string here"

q/kdb+ 41 bytes
Solution:
"!tenalP ,sgniteerG";"Greetings, Planet!"

Example:
q)"!tenalP ,sgniteerG";"Greetings, Planet!"
"Greetings, Planet!"

Explanation:
This is really just two statements separated by a semicolon, "!tenalP ,sgniteerG" and "Greetings, Planet!", due to the ;, the first statement does not get printed to the console.

Java, 192 Bytes
public class C{public static void main(String[] args){System.out.print("Greetings, Planet!");}}//}};)"!tenalP ,sgniteerG"(tnirp.tuo.metsyS{)sgra ][gnirtS(niam diov citats cilbup{C ssalc cilbup

For the online compiler i had to change the class name from C to Main
Try it online!

In what Java compiler does this work as-is, without changing C to Main?

this is necessary for the online compiler but i dont know why

Does it work in an offline compiler?

yeah of cause it does

T-SQL, 52 bytes
PRINT'Greetings, Planet!'--'!tenalP ,sgniteerG'TNIRP

Not much different from other answers, but didn't see another SQL-based solution.
-- is an in-line comment in T-SQL, PRINT is one byte shorter than SELECT.

Underload, 48 bytes
)(Greetings, Planet!)S())(S)!tenalP ,sgniteerG()

Uses the fact that non-matching closing brackets don't error on the interpreter that TIO uses.
How it works
) Used to make a matching pair of brackets at the end, so it doesn't error
(Greetings, Planet!)S   Outputs 'Greetings, Planet!'
()   Used to make it so the output command doesn't run a second time, since it gets enclosed in bracket. Also, adds an element to the stack so the 'a' in the '!tenalP, sgniteerG', doesn't error, since 'a' is a command in Underload
)(S)   Pushes S to the stack
!tenalP ,sgniteerG   Reversed 'Greetings, Planet'. Every character is a no-op apart from 'a'
()   Matching pair of brackets I mentioned on the first line

Try it Online!

Pip, 42 40 bytes
"!tenalP ,sgniteerG""Greetings, Planet!"

Try it online!
Pip prints the last expression in a file

Julia (1.2), 41 bytes
"!tenalP ,sgniteerG";"Greetings, Planet!"

Example
julia> print("!tenalP ,sgniteerG";"Greetings, Planet!")
"Greetings, Planet!"

Explanation
Putting a semicolon on the end of an expression makes the expression not output anything.

ink, 38 bytes
Greetings, Planet!//!tenalP ,sgniteerG

Try it online!

Fig, \$29\log_{256}(96)\approx\$ 23.87 bytes
"H>YB_@Pm*xnJD"DJnx*mP@_BY>H"

Try it online!
"H>YB_@Pm*xnJD"DJnx*mP@_BY>H"
"H>YB_@Pm*xnJD"               # The string "H>YB_@Pm*xnJD"
               DJnx*mP@_BY>H" # Compressed string "Greetings, Planet!"

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


text:
Make a (software) modem!
Objective
Design a modulator/demodulator pair to accurately transmit data as quickly as possible over simulated plain old telephone service (POTS).
Steps

Generate some random (/dev/random or the like) data that will take 3-4 seconds to transmit
Modulate the data with your modulator to produce an audio file
Pass the audio file through the POTS simulator. If you don't have Python/Scipy you can upload a file with the form, or do a JSON API request.
Demodulate the audio file back to binary data
Validate that the input and output are equal-ish* (limit 1 out of every 1000 bits can be corrupted)
Score is number of bits transmitted divided by the length of the audio file (bits/second)

Rules

Input file must be 3-4 seconds, 44.1 kHz, mono.
Run the simulator with an SNR of 30 dB (it's default)
The demodulator must reconstruct the transmitted data with a bit error rate of no more than 10-3 (1 per thousand bits).
No digital compression is allowed (i.e. zipping the data. It's outside the scope of the challenge.)
No attempting to shove data into frequencies above 4 kHz. (My filters aren't perfect, but they're reasonably POTS-like with a relatively small number of taps.)
If your modem protocol requires a short preamble (no more than 1 second) to synchronize/calibrate the receiver, it isn't penalized.
If possible, please host the audio file somewhere accessible so we can listen to a cacophony of beeps and boops.

Example
Here's an example notebook that demonstrates the modulation/demodulation with simple "on-off keying" (audio samples included!).

It would score 100 (bits/second). Note that it's transmitting with a much worse 5 dB SNR.

Is this different than an ordinary "compress this binary data" challenge? If so, could you clarify how precisely it differs?

Here you're modulating data (turning it into something analog) then the reverse. One could maybe call it "analog compression"

Sorry, I'm not sure I understand how this challenge works. The word "modulate" doesn't even appear in the Wikipedia article you linked. Could you include more background information, or clarify the spec?

wget wikipedia.org/Special:Random | grep title | texttospeech audio.wav speechtotext POTSaudio.wav | wget wikipedia/wiki/$text

This is an awesome challenge, I will try to find the time to submit an answer!

MATLAB, 1960 bps
Here is my updated attempt:
fs = 44100; %44.1kHz audio rate
fc = 2450;  %2.45kHz carrier - nice fraction of fs!
fsym = fc/5; %symbol rate

tmax = 4; %about 4 seconds worth

preamblesyms = 6;

t = 1/fs:1/fs:(tmax+preamblesyms/fsym);

symbols = preamblesyms+fsym*tmax;
symbollength = length(t)/symbols;
bits = symbols*3;
bitstream = [zeros(1,preamblesyms*3),rand(1,bits-preamblesyms*3)>0.5]; %Add a little preamble of 18 bits
data = bin2dec(char(reshape(bitstream,3,symbols)'+'0'))';

greycode = [0 1 3 2 6 7 5 4];

%Encode the symbols using QAM8 - we use effectively grey code so that
%adjacent symbols in the constellation have only one bit difference
%(minimises error rate)
encoded = zeros(2,symbols);
encoded(1,data==1) = 1/sqrt(2);
encoded(1,data==3) = 1;
encoded(1,data==2) = 1/sqrt(2);
encoded(1,data==7) = -1/sqrt(2);
encoded(1,data==5) = -1;
encoded(1,data==4) = -1/sqrt(2);
encoded(2,data==0) = 1;
encoded(2,data==1) = 1/sqrt(2);
encoded(2,data==2) = -1/sqrt(2);
encoded(2,data==6) = -1;
encoded(2,data==7) = -1/sqrt(2);
encoded(2,data==4) = 1/sqrt(2);

%Modulate onto carrier
carrier = [sin(2*pi*fc*t);cos(2*pi*fc*t)];
signal = reshape(repmat(encoded(1,:)',1,symbollength)',1,[]);
signal(2,:) = reshape(repmat(encoded(2,:)',1,symbollength)',1,[]);
modulated = sum(signal.*carrier)';

%Write out an audio file
audiowrite('audio.wav',modulated,fs);

%Wait for the user to run through the POTS simulator
input('');

%Read in the filtered data
filtered=audioread('audio.pots-filtered.wav')';

%Recover the two carrier signals
preamblecos = filtered(symbollength+1:symbollength*2);
preamblesin = filtered(symbollength+1+round(symbollength*3/4):symbollength*2+round(symbollength*3/4));

%Replicated the recovered carriers for all symbols
carrierfiltered = [repmat(preamblesin,1,symbols);repmat(preamblecos,1,symbols)];

%Generate a demodulation filter (pass up to 0.66*fc, stop at 1.33*fc
%(really we just need to kill everything around 2*fc where the alias ends up)
d=fdesign.lowpass('Fp,Fst,Ap,Ast',0.05,0.1,0.5,60);
Hd = design(d,'equiripple');

%Demodulate the incoming stream
demodulated = carrierfiltered .* [filtered;filtered];
demodulated(1,:)=filtfilt(Hd.Numerator,1,demodulated(1,:));
demodulated(2,:)=filtfilt(Hd.Numerator,1,demodulated(2,:));

%Split signal up into bit periods
recovereddemodulated=[];
recovereddemodulated(1,:,:) = reshape(demodulated(1,:),symbollength,symbols);
recovereddemodulated(2,:,:) = reshape(demodulated(2,:),symbollength,symbols);

%Extract the average level for each bit period. Only look at the second
%half to account for slow rise times in the signal due to filtering
recoveredsignal=mean(recovereddemodulated(1,round(symbollength/2):symbollength,:));
recoveredsignal(2,:)=mean(recovereddemodulated(2,round(symbollength/2):symbollength,:));

%Convert the recovered signal into a complex number.
recoveredsignal=recoveredsignal(2,:) + 1j*recoveredsignal(1,:);

%Determine the magnitude and angle of the symbol. The phase is normalised
%to pi/4 as that is the angle between the symbols. Rounding this to the
%nearest integer will tell us which of the 8 phases it is closest to
recoveredphase = round(angle(recoveredsignal)/(pi/4));
recoveredphase = mod(recoveredphase+8,8)+1; %Remap to an index in the grey code vector.

%Determine the symbol in the QAM8 constellation
recoveredencoded=greycode(recoveredphase);
recoveredencoded(1:preamblesyms)=0; %Assume the preamble is correct for comparison

%Turn it back in to a bit stream
bitstreamRecovered = reshape(dec2bin(recoveredencoded)'-'0',1,[]);

%And check if they are all correct...
if(all(bitstream==bitstreamRecovered))
    disp(['Woop, ' num2str(fsym*4) 'bps']);
else
    error('Its corrupt Jim.');
end

Since my first attempt, I have played around a bit. There is now a small preamble at the beginning (18 bit periods, but could be shorter) which contains just a cosine wave. I extract this and replicated it to create correctly phased sine and cosine carriers for demodulation - as it is a very short preamble, I haven't counted it in the bit rate as per your instructions.
Also since the first attempt I am now using a QAM8 constellation to achieve 3 bits per symbol instead of 2. This effectively doubles the transfer rate. So with a ~2.4kHz carrier I am now achieving 1960bps.
I've also improved the symbol detection so that the averaging doesn't get affected by slow rise times caused by the filtering - basically only the second half of each bit period is averaged to remove the impact of rise times.
Still nowhere near the 40kbps theoretical channel bandwidth from the Shannon-Hartley theory (assuming the 30dB SNR)
Just for those that like horrible sounds, this is the new entry:

And in case anyone is interested, this is the previous 960bps entry

Scoring is just the transfer rate, so keep your code clear. I added a suggestion to host your audio file somewhere if it's easy for funsies :D

I'll upload the audio to my site. It sounds rather eery!

@NickT audio file uploaded - see the link at the bottom of the post.

If you have a SoundCloud account you can upload your audio and post a link and it will be playable in your post. (Example)

@NickT thanks. I've created a soundcloud account and uploaded it. I've also made an updated version with double the data rate :)


text:
Golfing Strings
I have always failed to give an answer for kolmogorov-complexity challenges which require string compression, the main reason being that I don't know to use string compression tools as effectively as I should.
For this reason, I have posted this question. Unlike my other tips questions, this is not language  specific meaning that if you can think of any tips in your own language, then you may post it (providing that you specify the language). General tips are also appreciated.
So, how can I use string compression tools to their maximum effectiveness?

Base conversion (CJam)
An easy way to encode ASCII strings that do not start with a null byte is to convert from base 128 to integer, then to base 256:
128b256b:c              e# Prints encoded string.
128b256b:c`"256b128b:c" e# Prints encoded string with decoder.

This uses 7 bits to encode each ASCII character.
If the original string consists only of, e.g., lowercase letters, and does no start with an a, we can start by mapping "a...z" to [0 ... 25], then proceed as above:
'afm26b256b:c               e# Prints encoded string.
'afm26b256b:c`"256b26b'af+" e# Prints encoded string with decoder.

Finally, if the original string has only a few unique characters (common in ASCII art), it is usually better to specify the alphabet explicitly.
For example:
" +-/\|"f#6b256b:c                       e# Prints encoded string.
" +-/\|"f#6b256b:c`"256b6b"" +-/\|"`"f=" e# Prints encoded string with decoder.

As a rule of thumb, you want the first character of the original string to be the second character of the alphabet, the next distinct character of the original string to be the first character of the alphabet, the next distinct character of the original string to be the third character of the alphabet, the next distinct character of the original string to be the fourth character of the alphabet, etc.
The encoder of last example works as follows:
" +-/\|"f# e# Replace each character by its index in that string.
6b256b     e# Convert from base 6 (length of the alphabet) to base 256.
:c         e# Cast each digit to character.

The decoder of last example works as follows:
256b6b     e# Convert from base 256 to base 6.
" +-/\|"f= e# Replace each digit by the corresponding character of the alphabet.

I would be more specific: as a rule of thumb you want the first character of the original string to be the second character of the alphabet, the next distinct character of the original string to be the first character of the alphabet, ...

@PeterTaylor Added. Thanks!

Larger Kolmogorov complexity questions with some structure but no simple formula (e.g. song lyrics) will typically benefit from a grammar-based approach. In essence, you extract repeated substrings and encode them somehow. This is what Lempel-Ziv does, using a fairly restricted class of grammars; if you use more general grammars then you have to figure out how to encode the rules. E.g. one approach here is "offset encoding", where you offset each source byte by the  number of rules (n), assign bytes 1 to n to the rules, use the 0 byte to separate rules, and repeatedly replace byte i with the evaluated rule i. Finally you undo the offset by subtracting n from each byte.
I have actually written a Java program which implements various approaches:

Most of the approaches follow a two-phase process. In the first phase the string is converted into a grammar which generates it; in the second phase, the grammar is converted into a GolfScript program. The first phase implementations are largely based on Charikar, Lehman, Liu, Panigrahy, Prabhakaran, Sahai, & Shelat (2005) The smallest grammar problem, Information Theory, IEEE Transactions on, 51(7), 2554-2576.

It also includes a Lempel-Ziv approach, a base encoding approach, and a runlength-encoding approach, and identifies the one which gives the shortest program.

Stax
In the Stax code golfing language, there's a helpful little tool called the string literal compressor. I don't know how it works, exactly, but there is another where I do know how it works. It converts strings into numbers, then into Base 256. It's CP437, with 0x00 and 0xFF converted for copying. It's PackedStax. You could convert your strings with the string literal compressor then Pack it, for some good compression.
Using this process the string "This string is thirty-two bytes" can be converted to v*"A]-|W4]}3"% (the compressed string is usually surrounded by backticks to tell the difference between a normal string in Stax) and finally to üvìë![┴╩qJu←▓α for a compression / reduction of 18 bytes, more than half.

The string compressor does an extremely optimized Huffman coding.