text:
Deletion of a blank line in source code which causes unexpected functionality
Write a script that works fine when a blank line is present in the flow of program logic, but breaks or causes unexpected behaviour when that line is removed.
Avoid standard loopholes and stupid answers. Your program should do something "useful," even if all it does is add a few integers.
Removing an empty line from a multiline string doesn't count, unless the expected output from that multiline string shouldn't technically change (ie: if you're removing all blank lines matching ^$).
Whitespace foolery isn't allowed either; don't do weird things with carriage returns, tabs, spaces, etc.

Are empty lines inside multiline strings counted?

I think you should exclude Whitespace.

I think that Whitespace is a "standard loophole"

Updated the question with qualifications.

nneonneo is talking about Whitespace, which is a language that uses only spaces as its syntax.

Is there any blank line that doesn't match ^$ ?!

@aditsu No there is not.

@TheRare so that means removing an empty line from a multiline string doesn't count... unless it's a blank line? o_O

@aditsu My thought exactly.

"unexpected functionality" is a very good phrase.

"Whitespace foolery isn't allowed either; don't do weird things with carriage returns, tabs, spaces, etc."  What's a blank line except but a newline character following another (or other character(s), depending on platform)?

Acme::Bleach, anyone?

@JoshuaTaylor, if you remove a line in your program that matches ^$ and observe different functionality, that's what we're looking for. A blank line is NOT ^\s+$.

@NaftuliTzviKay It was tongue in cheek response, but the point was that a blank line is something that has to two with whitespace.  If removing a blank line makes a difference, then just about by definition it's "whitespace foolery".  The \<newline> behavior in C, for instance only works when \ is followed by a newline (which is a whitespace) character.  It's whitespace foolery. :)

I'm voting to close this question as off-topic because underhanded challenges are no longer on-topic on this site. http://meta.codegolf.stackexchange.com/a/8326/20469

Javascript
Opens an alert popup with "Hello, World!" if the blank line exists, otherwise alerts "0".
(function(){
    alert(~(arguments.callee+[]).indexOf('\n\n') && "Hello, World!");

})();

Demo
Explanation:
arguments.callee is a reference to the self-executing anonymous function.
Appending a blank array ([]) casts the function to a string, which gives you its source code.
indexOf returns -1 if the string is not found.
Performing a bitwise not operation (~) results in -1 being turned into 0, which is a falsey value.

What trickery is this?!

arguments.callee contains the source of the function.

@Kroltan I've added an explanation to the answer :)

@Matthew is that in the spec, or just something that most browsers happen to implement?

@Michael looks like it, according to the publicly accessible documentation: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions_and_function_scope/arguments/callee

Note that this no longer works in strict mode (which most modern code would be using). Strict mode forbids the use of arguments.callee.

@Michael: No, spec says nothing about the exact format. In fact, there are engines running around that do not preserve whitespace.

@DanielLoNigro You can just give the function expression a name and use that instead of arguments.callee. Even makes it shorter.

C
This magic 8-ball program will still work without the blank line, but it will be a bit more decisive — none of the neutral answers will ever appear in the output.
#include <stdio.h>
#include <time.h>
#include <stdlib.h>
int main() {
  int x, t;
  char *quotes[] = {
        // Positive :-)
        "It is certain", "It is decidedly so", "Without a doubt", "Yes definitely", "You may rely on it",
        "As I see it, yes", "Most likely", "Outlook good", "Yes", "Signs point to yes",
        // Indifferent :-\

        "Reply hazy try again", "Ask again later", "Better not tell you now", "Cannot predict now", "Concentrate and ask again",
        // Negative :-(
        "Don't count on it", "My reply is no", "My sources say no", "Outlook not so good", "Very doubtful" };
  srandom(time(NULL)); // Initialize random number generator
  x = random() % (sizeof(quotes) / sizeof(char*)); // Choose a random outcome
  printf("The Magic Eight Ball says...\n%s\n",quotes[x]);
  return 0;
}

Explanation

 When the C parser sees a backslash followed by a newline character, it ignores both and treats the second line as a continuation of the first. Without the empty line, the "indifferent" answers will all be treated as part of the previous comment.

I +1'd, but seeing C comments ending with a backslash is starting to become a standard loophole, IMO.

@TimS. Common I can see, but how on earth is it a loophole?

It was a reference to this "standard loopholes" post, so maybe not literally a "loophole".

Maybe add line breaks after Positive, before Indifferent, and before and after Negative to make it less obvious?

@TimS. if you are bored with this "solution", why did you upvote?

The backslash-the-next-line-into-a-comment answers (trigraph or no trigraph) are making me wish I had 125 reputation. I keep seeing them and they're starting to be awfully repetitive, totally see-through, and no longer clever or funny. (Which is unfortunate for those using them, like squeamish here, because they in no way deserve the ire and are sometimes totally unaware of this - but the trick is earning it.)

Sorry everybody. I didn't expect this to get many votes. Please vote for nderscore and aditsu instead.

@Jan starting to become standard is not the same as long-standard/overdone...its use is fairly clever here, it doesn't look out of place (unlike some I've seen, which inexplicably have character(s) at the end of a comment, or end their comments with the comment-start character(s) in order to do something unusual). So: I upvote the solution, not the continued use of its trick.

Related: Unicode escapes in Java outside of string literals.

Befunge-93
v
&
&
+
#

.
@

My first befunge program :)
It reads two numbers from the input and prints their sum. If you delete the empty line, it doesn't print anything.
Explanation:
v sets a downward direction for executing the code
& reads an integer
+ adds the numbers together
# skips the next command
. prints an integer from the stack
@ ends the program
As written, # skips over the empty line and contines with .. Buy when you delete the empty line, . is skipped.
There seems to be a nice interpreter at http://befunge.aurlien.net/

Ah, clever one.

Befunge 98 also does this. Good thinking. And this interpreter has some benefits (I haven't used yours much, so I don't know its benefits).

Ruby/Shell

#!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
#!   The Amazing Integer Adder             !
#! Adds 1 and 1, and displays the result   !
#!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

p 1+1

Works fine if a newline is at the top, otherwise the first comment line is interpreted by the shell as a malformed shebang.

Wouldn't this either always work or always not work? For example, if you ran it as ruby youranswer.rb, it wouldn't look for a shebang because it's being run in the ruby interpreter already, but if you ran it as ./youranswer.rb it wouldn't run at all because there's no shebang..

At least with my ruby, the shebang is honored even if you run it as ruby youranswer.rb, which can be useful to set necessary command-line switches in the file. So without the newline I get ruby: no Ruby script found in input (LoadError)

Scala
case class IntWrapper(i: Int)

{
  val answer = (IntWrapper(0) /: (1 to 100)){(x, y) => IntWrapper(x.i + y)} // Add up ints
  println(s"Sum of wrapped integers is $answer")
}

If you remove the blank line, no output will be printed. Which is for the best, as your stack would overflow if you actually called IntWrapper.

This is a corner case of Scala's semicolon inference. Normally newlines get a semicolon whenever the resulting code would be valid. However, the Scala devs didn't want to force people to use Egyptian brackets, so it's valid to put the brackets for a class definition on the line immediately after - no semicolon is added, even though one could be. However, a blank line divorces the brackets from the class definition. With the blank line removed, the code changes from being a class definition and a block, to a class definition with a constructor - and a recursive constructor at that!

Very nice of them not to force Egyptian Brackets. But semicolon inferrence is a bad idea, in my opinion.

Semicolon inference gets a bad name, largely due to JavaScript. It's a bit less painful if you design the language with it in mind (no one complains about it in Python, for example). Unfortunately Scala included a couple of features that don't play nice with semicolon inference. There's this, and postfix operators (which I was tempted to use in my answer, but it's a bit passé).

@James_pic: AFAIK no one complains about it in Python because it doesn't exist in Python.  In JS, semicolons are a necessary part of the syntax, and can be inserted (inferred) at certain points.  In Python, semicolons are not a necessary part of the syntax, but can be used optionally.  That's a big difference.

It may seem like a big difference, but if Scala removed a few features, which currently make statement boundaries ambiguous, it would move from JavaScript's side of the fence to Python's.

@James_pic: What makes python different is that there newline terminates the statement unless escaped or inside any kind of bracket. That is there is no complete/incomplete rule.

@Jan Hydec I suppose that's true. I'd never really thought of it like that, as I always wrap multiline expressions in brackets, in both languages, but you're right.

GolfScript
~{.@\%:

}do;

Calculates the GCD of two non-zero integers. Removing the blank line breaks the program.
Try it online.
How it works
This is a GolfScript implementation of the Euclidean algorithm:
      # STACK: "15 24"
~     # Interpret the input string.
{     # STACK: 15 24
  .@  # Duplicate the topmost integer and rotate the other on top of both copies.
      # STACK: 24 24 15
  \   # Swap the topmost integers.
      # STACK: 24 15 24
  %   # Calculate the modulus.
      # STACK: 24 15
}do   # If the modulus is non-zero, repeat the loop.
;     # Discard the last modulus.

There's just one tiny problem:

 {}do pops the modulus from the stack to check if it's truthy, so it has to get duplicated at the end of the loop. This is normally accomplished by ., but :\n\n has the same effect: It stores the topmost stack item in the variable LF (:\n), then pushes the contents of that variable.

Wow, even that's a variable? :O

@aditsu: Only #, { and } cannot be used as variable names, as they're part of the syntax. Every other token is fine, including strings.

@Dennis wow. TIL even strings can be used as variables. Is that useful for anything?

@JanDvorak: Aside from some edges cases (palindromic code, underhanded code, probably not. I think this is just a (documented) side effect of how the GolfScript interpreter splits the code into tokens.

@Dennis does that mean that .:-1 stores the input into -1, not the minus sign itself? Hmm...

@JanDvorak: It does. (Addendum to my first comment, : is also part of the syntax.)

MediaWiki Template Syntax
Define Template:Foo as
{{{a

b|Uh-oh!}}}

In another page,
{{Foo|a

b=Works!}}  <!-- outputs "Works!" -->

{{Foo|a

b=Works!}}  <!-- outputs "Uh-oh!" -->

{{Foo|a
b=Works!}}  <!-- outputs "Uh-oh!" -->

 In MediaWiki, parameter names can contain newlines.

Nice, this is along the lines of what I was looking for, weird edge cases like this.

LaTeX (backref)
The following LaTeX code uses a citation and the citation contains a list of pages, where the entry is citated. Here it is the first page. Package hyperref also adds PDF links, the page back reference is red, the citation link is green.
\documentclass{article}
\usepackage[colorlinks,pagebackref]{hyperref}
\begin{document}
Donald E. Knuth is the inventor of \TeX~\cite{knuth}.
\begin{thebibliography}{9}
\bibitem{knuth}
Donald E. Knuth: \textit{The \TeX book}; Addison Wesley, 1984.

\end{thebibliography}
\end{document}

But LaTeX does not require the empty line, the empty line looks superfluous and the example will still work without hyperref and the empty line:
\documentclass{article}
\begin{document}
Donald E. Knuth is the inventor of \TeX~\cite{knuth}.
\begin{thebibliography}{9}
\bibitem{knuth}
Donald E. Knuth: \textit{The \TeX book}; Addison Wesley, 1984.
\end{thebibliography}
\end{document}

But the links and back reference are gone, thus we reinsert them:
\documentclass{article}
\usepackage[colorlinks,pagebackref]{hyperref}
\begin{document}
Donald E. Knuth is the inventor of \TeX~\cite{knuth}.
\begin{thebibliography}{9}
\bibitem{knuth}
Donald E. Knuth: \textit{The \TeX book}; Addison Wesley, 1984.
\end{thebibliography}
\end{document}

But now the example is broken and will not compile anymore:
Runaway argument?
 Donald E. Knuth: \textit {The \TeX book}; Addison Wesley, 1984. \end \ETC.
! File ended while scanning use of \BR@@bibitem.
<inserted text>
                \par
<*> knuth

?

What happened? Package hyperref (or more precise package backref, which is loaded by hyperref) wants to get at the end of the bibliography entry to add the back reference list. But the syntax in LaTeX only provides the beginning of the entry by \bibitem, the end can be anywhere. In this emergency package backref has added a restriction that \bibitem has to end the entry with an empty line. Then the package can redefine \bibitem to put the back references at the end of the entry.
Since the empty line is missing, TeX keeps looking for it, but found the end of file instead and issues the error message.

C (semi-obfuscated)
This little program takes a number on the command line and computes its factorial.  However, it also contains cutting-edge AI functionality for runtime verification that the company's coding standards, including the correct use of whitespace and blank lines, are being followed.  Removing a blank line will trigger the algorithm to reject the insufficiently maintainable program.
No line continuations or trigraphs anywhere.  I believe it is valid ANSI C99.
Due to the advanced mathematics involved, if you compile with gcc, remember to use -lm.
#include <setjmp.h>
#include <stdio.h>
#define max(x,y) ((x<y?y:x))
#define swap(x,y) ((x^=y,y^=x,x^=y))
#include <stdlib.h>
#include <math.h>
#define vfry(x,p,z,y,i) (!!y&((z##z##L##I##p##x##z##z)))
#define NDEBUG

/*
 * Proper use of whitespace is essential!
 * Please do not remove any blank lines.
 */

const double E = 2.71828182845904523536;

int vrfy(double epsilon, int magic, const char *key, long int L) {
  /* You are not expected to understand this */
  double x=284.2891,u=2.34e56;
  while (rand()+magic*pow(epsilon,sin(x-E))!=log(u*L))
    x*=vrfy(1.0/epsilon,(int)u,&key[swap(L,magic)],L++);
  return u/lgamma(x);
}

int main(int argc, char *argv[]) {
  int N_=831293812; /* do not change, see Knuth 1987 */
  if (!vfry(E, N,_, "M=&;VT=I!9", 0xfe86ddcaL)) {
    fprintf(stderr, "Code standards violation detected!\n");
    abort();
  }
  if (argc < 2) {
    fprintf(stderr, "Usage: %s n\nComputes n!\n", argv[0]);
    exit(1);
  }
  int m=1, n=atoi(argv[1]), i;
  for (i=1; i <= n; i++)
    m *= i;
  printf("%d! = %d\n", n, m);
  return 0;
}

Spoiler

 The complicated vrfy function is never called, but rather the funny-looking vfry macro.  The use of the preprocessor's string concatenation feature disguises the fact that we are really just checking the parity of __LINE__.

Also works with tcc -run

This is really neat. That vfry isn't expanded in the function definition really stumped me.

C
This program works as expected (as described in the comments) unless the blank line before foo = 5; is removed.
Sadly, I encountered an error almost exactly like this in production code once.
#include <stdio.h>

int main()
{
    int foo = 0;

    #define FROB(x) do {                                            \
        x++;                                                        \
        printf("%d\n", x);                                          \
    } while (0);                                                    \

    foo = 5;
    FROB(foo); /* prints 6 */
    FROB(foo); /* prints 7 */
    FROB(foo); /* prints 8 */

    return 0;
}

This example uses the do { ... } while (0) idiom for creating a multiline statement in a macro (see https://stackoverflow.com/questions/257418/do-while-0-what-is-it-good-for). It also uses the backslash character to spread a #define over multiple lines, conveniently lined up well out of sight. However, it also does two things kind of wrong:

There is a semicolon after while (0), while the idiom usually omits this
There is a backslash after the final line of the #define

With this in place, removing the blank line before foo = 5; causes that assignment to be executed after the printf, but also after every invocation of the FROB macro. As a result, the output after removing the blank line is:
1
6
6

Basically a duplicate of http://codegolf.stackexchange.com/a/31662/20356

@TheRare But it's less obvious.

It's only less obvious if you don't look at those backslashes floating very conspicuously over to the right. (But since they're floating there very conspicuously over to the right, they're going to get looked at.)

However, all but one of them are justified

@QuadmasterXLII, technically speaking, they're all justified -- right-justified, to be precise.

C/C++
int main(){

    return __LINE__ - 3;
}

Returns success and can be used as an implementation for true. If the empty line is removed you can use it as an implementation for false instead.

PowerShell
This function will add two numbers.
function add ($a, $b) {
    $numbers = @($a `

            $b)
        $numbers| measure -sum| select -expand sum
}

Removing the blank line will cause the function to fail with: Unexpected token '$b' in expression or statement.
Explanation

Array elements can be separated by newlines and/or commas. Placing the line continuation character (`) after $a requires an extra newline to separate $a and $b. Otherwise, the interpreter views the code as $numbers = @($a $b) (no element separator).

TeX
\noindent\everypar{$\bullet$ hello }

world
\bye

Without the empty line, "hello" is not printed.
Explanation
TeX treats the empty line as a paragraph break, and \everypar is executed at the start of a new paragraph.

Java
import java.util.Scanner;

public class BlankLine
{
    public static void main( String[] args )
    {
        //This calculates 2^ given number
        //if you remove blank line after the next line it will always print 1
        int x = new Throwable().getStackTrace()[0].getLineNumber();

        int y = new Throwable().getStackTrace()[0].getLineNumber() - x;
        System.out.println("Number:");
        Scanner scanner = new Scanner(System.in);
        int r = 1;
        int n = scanner.nextInt();

        for(int i = 0; i < n; i++){
            r *= y;
        }
        System.out.println("2^number: "+r);
    }
}

 x is current line number, y is current line number - x. If there is blank line between them the result is 2. So the code calculates 2 ^ number.

+1 simply because it's Java, although as a frequent visitor of Code Review I wonder why you're not using Math.pow?

Because my code has to do something. Adding 2 numbers is a bit too simple.

Using Math.pow and print out the result is also doing something is it not?

And now I realized I really could use .Math.pow
I don't know why I thought I need to do it that way... Matbe I wanted to do it in mor "sneaky" way.

You've been golfing too much. You should visit Code Review instead where we do things right!

Perl 5
print(<<""
Hello, World!

);

This code prints Hello, World!.  Removing the blank line gives a syntax error instead.
Explanation:

 Perl's here-doc syntax for multi-line strings allows an empty terminator string.  It's even explicitly documented.  Removing the blank line causes the closing parenthesis (and everything else up to the next blank line, if there is one) to be interpreted as part of the string, causing a syntax error.

 The error messages you get are actually pretty decent, for such an oddball syntax feature.  If there are no blank lines at all in the program after the print(<<"" line, Perl simply says:

 Can't find string terminator "" anywhere before EOF at foo.pl line 1.
If there is an empty line at the end of the program, you get something like this instead:

 syntax error at foo.pl line 4, at EOF
  (Might be a runaway multi-line << string starting on line 1)
Execution of foo.pl aborted due to compilation errors.

Batch
@echo off
setLocal enableDelayedExpansion
set NL=^

echo Hello!NL!World

This code will output Hello and on the next line World. When either or both of the blank lines are removed, it outputs nothing at all.
There is an explanation here.

Python
Don't know if this falls under the standard loopholes, I looked at the list and didn't see this.
src = open(__file__, 'r')
code = src.readlines()
src.close()

if code[3] == '\n':
    print 'Hello World!'

Running this regularly returns
Hello World!

Running it without the blank line on line 4, ie like below:
src = open(
__file__, 'r')
code = src.readlines()
src.close()
if code[3] == '\n':
    print 'Hello World!'

returns nothing.

Ruby
Deletion of the first line will cause error:

line = IO.readlines($0).first.chomp
if line.empty?
puts 34+4
else
raise "Please add a newline at the beginning of the program."
end

I love the error message. Would like to see the reaction of someone that tries to run the program and gets that response.

Technically not a "code" issue, but a server one. If this is sent to Apache from a CGI script (which can be generated with any language you please), it will send an HTTP response to the client:
HTTP/1.x 200 OK
Content-Type: text/html; charset=UTF-8

Hello world!

On the other hand, this will fail as it is missing the blank space after the header.
HTTP/1.x 200 OK
Content-Type: text/html; charset=UTF-8
Hello world!

Tcl
A function that adds two numbers (and checks if the newline have been deleted):
proc add {a b} {
    if {[llength [split [info body add] \n]] < 5} {error "function has been modified"}

    return [expr $a+$b]
}

There's nothing to hide here, it does what it says, so I'm not spoilerizing the explanation. The function info is a swiss army knife of introspection (what other languages call reflection). info body returns the source code of a function (if not written in C or assembly).
I have to admit that this had me stumped until I saw the javascript solution.

C
#include <stdio.h>

int main() {
    const char* a = "You love blank lines.";
    #define print_out(a) \

    printf("%s\n", a);
    a = "You don't seem to love blank lines";
    print_out(a);
    return 0;
}

With the blank line, a is the local variable a and without it's the macro parameter...

Python 2.x
This program outputs the fifth character of the inputted string.
import inspect

text = raw_input()
print 'Fifth character of the string:', text[inspect.getlineno(inspect.currentframe())]

This isn't in any way hidden. If you remove the empty line, it gives the fourth character and the sixth if you add one.

Perl
#!/usr/bin/perl

use strict;
use warnings;

open IN, "<".$0 or die "Did not find input files!";
while (<IN>) {
        m/blabla/ && ((<IN> =~ /\}/ && print "tra-la-la...\n") || print "ti-ri-li\n");

}
close IN;

 This perl script will read the script file and check if after the line containing "blabla" there is a closing bracket.

JavaScript
The function whereami responds with the position of the calling line, relative to its own position in the source code.
console.log (whereami ()) //3 line(s)  before me

function whereami () {
    var a=function a(e){try{to}catch(c){for(var d=c.stack.split("\n"),b=0;b<d.length&&!~d[b].indexOf("a");b++);return c.stack.split("\n")[b+~~e].match(/:(\d+)/)[1]-~~window.hasOwnProperty("__commandLineAPI")}},a1=a(1),i

    i= a(2)>a(1)+4?a(1):a(1)>a1+2?a1-1:a/a1

    return ((i=(a(2)<i?i-1:a(1)>i+3?a(2)-a(1)-1:a/1)) + " line(s) "   ) + (i<a(2)?" after":(i>=a(2)?" before":"confusing")) + " me";
}

console.log (whereami ()) //3 line(s)  after me

If any blank line in the whereami function is removed. The output is NaN line(s) confusing me. (Adding lines doesn't break it)

 It actually only counts how many lines are between i and the first and last line respectively. If they fall under a given value. The reference line is set to NaN which neither satisfies NaN<callingLine nor NaN>=callingLine. I tried to hide it a bit in unreadable ternary expressions.

Cool. I hadn't thought of using the exceptions stack like that.

Escript
Due to bug in escript implementation valid escript has to be at least three lines long and first line hast to be shebang line or empty line. So following script hast to have two empty lines where first one has to be first one:
main(_) -> io:format("Hello world!~n", []), halt().

Or it hast to be broken in two lines but still has to have first empty line.
main(_) ->
    io:format("Hello world!~n", []), halt().

Otherwise you will get
escript: Premature end of file reached

Ruby
print %q
2+2=

p(2+2)

Prints 2+2=4, but gives a syntax error without the blank third line. %q allows any non-word character to serve as a string delimiter, even the newline character. So the first three lines of code are actually equivalent to print %q"2+2=", or just print "2+2=". Since the newline after 2+2= is being used as a quote delimiter, it's not also parsed as a line delimiter, so you need another one immediately after.

Insomnia (both versions)!
Þyoo

â

This code prints a ~ (don't ask why, insomnia is weird). If you remove the blank line, it prints a ÿ instead.
By the way that first letter is a thorn.

Hooray, thorns! Haven't seen that character in ages, +1.

C++
This is a classic and rather dumb trick. You will know what it is when you see it, this is just here for completion's sake. As such, I'm marking this as a community wiki answer.
int main() {
    //This program won't work without the next line, why??/

    return 1;
}

Why this works

This is actually one of the loopholes.

@Mhmd I wasn't aware. Either way, I know people always use this in these kinds of question, and I just wanted to leave this here just so someone doesn't find it clever to do this.

This answer is wrong for two reasons. The first is that ??/ means \, so ??// means \/, and as the line doesn't end in \, there is no line continuation. The second is that the behaviour is exactly the same regardless of whether return 0; is executed, because that is the standard behaviour when the execution of main reaches the closing }.

@hvd There. I fixed it.

@cra I know people always use this in these kinds of question that's why we made it a standard loophole

@undergroundmonorail I wasn't aware of that, like I said. I made it a community wiki answer for a reason.

Paste this into a html file, and open it in your browser.  It's pretty simple, but a little tricky because it takes the number of blank lines in the document and indexes an array to call a function which shows an alert.
<body>
<script>
[null, function(){alert("GIVE ME MY LINE BACK")}, function(){alert("2 + 2 = " + (2+2))}][document.body.innerHTML.split("\n\n").length]()

</script>
</body>

This one is borderline rule breaking.  Technically JavaScript doesn't have multiline strings, which is the only reason this works.
Because you can have a syntax error in one script tag without interfering with the other script tags this shows a positive result only if there's an error on the page.  The error prevents the second alert from firing because it's in the same script tag.
<body>
<script>
window.onerror=function(){
  alert("2 + 2 = " + (2+2));
}
</script>
<script>
var a = "\

";
alert("GIVE ME MY LINE BACK!");
</script>
</body>

Ruby
puts (% #{ARGV[0].to_i + ARGV[1].to_i}

)

The secret is that the newline, is really a tab, then a new line. I don't know if this counts but I thought it was cleaver. The character after the % is also a tab, but for some reason it doesn't show up like one. I'm using Ruby's percent notation to make a string, that adds the first 2 arguments passed to the script. There's more on that here:
http://teohm.com/blog/2012/10/15/start-using-ruby-percent-notation/

It actually doesn't count, read the instructions: "No whitespace foolery." Exactly one \n should be present and should be crucial to having the program work as expected.

Ah ok :( well I tried

I think you can fix this, though: a newline can itself be a percent delimiter.

AppleScript
say¬

quit
This code is absolutely meant to throw an error, as it matches (in compiler speak) to this:
¬
   say
quit
Which throws the error "Can’t make current application into type text."
However, if you delete the second line, you get the equivalent of this code:
say ¬
   (quit)
Which says nothing and attempts to close the current application (Script Editor or Terminal).

><>
This program
02.

v"?"o
;"!"o

outputs
?

and exits.
Removing the blank line cause it to output
!


text:
Build a pair of spies that will throw stones into a river
Recently at the newly released Puzzling.SE, there was a problem about spies throwing stones into a river that was actually quite challenging:

Two spies must pass each other two secret numbers (one number per spy), unnoticed by their enemies. They have agreed on a method for doing this using only 26 indistinguishable stones in advance.
They meet at a river, where there is a pile of 26 stones. Starting with the first spy, they take turns throwing a group of stones into the river: the first spy throws some number of stones, then the second one, then the first one again...
Each spy must throw at least one stone on his turn, until all the stones are gone.
They observe all throws and diverge when there are no more stones. They keep silence all the time and no information is exchanged except number of stones thrown at each turn.
How can they exchange the numbers successfully if the numbers can be from 1 to M?

Your task is to build a pair of programs, spy1 and spy2, that can solve this problem for the highest possible M.
Your programs will each take a number from 1 to your chosen M as input. Then, spy1 will output a number representing the number of stones it throws into the river, which will be input to spy2 which will also output a number to be input to spy1, and so on until the numbers output add up to 26. At the end of throwing, each program will output the number it believes the other program had, which must match the number that was actually input to the other program.
Your program must work for all possible ordered pairs of numbers (i, j) where both i and j can vary from 1 to M.
The program that works for the largest M will be the winner, with the first answer to be posted breaking a tie. Additionally, I will award a +100 reputation bounty to the first solution that is proven to work for M >= 2286, and +300 to the first solution that is proven to work for M >= 2535.

Solution means algorithm, or a program, which generates set of dissisions for each (i,j)?

Not one program, but two. They must communicate independently, as in your problem.

Since the programs are going to need to share their decision tree, can we make it one program which takes an argument to say which spy it is?

As long as you can guarantee that each spy communicates independently and there is no extra information exchanged between them.

Independently I have verified that 2535 is the information-theoretic max for this problem. I quite strongly believe now that no program can do better.

C#, M = 2535
This implements* the system which I described mathematically on the thread which provoked this contest. I claim the 300 rep bonus. The program self-tests if you run it either without command-line arguments or with --test as a command-line argument; for spy 1, run with --spy1, and for spy 2 with --spy2. In each case it takes the number which I should communicate from stdin, and then does the throws via stdin and stdout.
* Actually, I've found an optimisation which makes a massive difference (from several minutes to generate the decision tree, to less than a second); the tree which it generates is fundamentally the same, but I'm still working on a proof of that. If you want a direct implementation of the system which I described elsewhere, see revision 2, although you might want to backport the extra logging from Main and the better inter-thread comms from TestSpyIO.
If you want a test case which completes in less than a minute, change N to 16 and M to 87.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;

namespace CodeGolf
{
    internal class Puzzle625
    {
        public static void Main(string[] args)
        {
            const int N = 26;
            const int M = 2535;

            var root = BuildDecisionTree(N);

            if (args.Length == 0 || args[0] == "--test")
            {
                DateTime startUtc = DateTime.UtcNow;
                Console.WriteLine("Built decision tree in {0}", DateTime.UtcNow - startUtc);
                startUtc = DateTime.UtcNow;

                int ok = 0;
                int fail = 0;
                for (int i = 1; i <= M; i++)
                {
                    for (int j = 1; j <= M; j++)
                    {
                        if (Test(i, j, root)) ok++;
                        else fail++;
                    }
                    double projectedTimeMillis = (DateTime.UtcNow - startUtc).TotalMilliseconds * M / i;
                    Console.WriteLine("Interim result: ok = {0}, fail = {1}, projected test time {2}", ok, fail, TimeSpan.FromMilliseconds(projectedTimeMillis));
                }
                Console.WriteLine("All tested: ok = {0}, fail = {1}, in {2}", ok, fail, DateTime.UtcNow - startUtc);
                Console.ReadKey();
            }
            else if (args[0] == "--spy1")
            {
                new Spy(new ConsoleIO(), root, true).Run();
            }
            else if (args[0] == "--spy2")
            {
                new Spy(new ConsoleIO(), root, false).Run();
            }
            else
            {
                Console.WriteLine("Usage: Puzzle625.exe [--test|--spy1|--spy2]");
            }
        }

        private static bool Test(int i, int j, Node root)
        {
            TestSpyIO io1 = new TestSpyIO("Spy 1");
            TestSpyIO io2 = new TestSpyIO("Spy 2");
            io1.Partner = io2;
            io2.Partner = io1;

            // HACK! Prime the input
            io2.Output(i);
            io1.Output(j);

            Spy spy1 = new Spy(io1, root, true);
            Spy spy2 = new Spy(io2, root, false);

            Thread th1 = new Thread(spy1.Run);
            Thread th2 = new Thread(spy2.Run);
            th1.Start();
            th2.Start();

            th1.Join();
            th2.Join();

            // Check buffer contents. Spy 2 should output spy 1's value, so it's lurking in io1, and vice versa.
            return io1.Input() == i && io2.Input() == j;
        }

        private static Node BuildDecisionTree(int numStones)
        {
            NodeValue[] trees = new NodeValue[] { NodeValue.Trivial };
            for (int k = 2; k <= numStones; k++)
            {
                int[] prev = trees.Select(nv => nv.Y).ToArray();
                List<int> row = new List<int>(prev);
                int cap = prev.Length;
                for (int i = 1; i <= prev[0]; i++)
                {
                    while (prev[cap - 1] < i) cap--;
                    row.Add(cap);
                }

                int[] next = row.OrderByDescending(x => x).ToArray();
                NodeValue[] nextTrees = new NodeValue[next.Length];
                nextTrees[0] = trees.Last().Reverse();
                for (int i = 1; i < next.Length; i++)
                {
                    int cp = next[i] - 1;
                    nextTrees[i] = trees[cp].Combine(trees[i - prev[cp]]);
                }

                trees = nextTrees;
            }

            NodeValue best = trees.MaxElement(v => Math.Min(v.X, v.Y));
            return BuildDecisionTree(numStones, best, new Dictionary<Pair<int, NodeValue>, Node>());
        }

        private static Node BuildDecisionTree(int numStones, NodeValue val, IDictionary<Pair<int, NodeValue>, Node> cache)
        {
            // Base cases
            // NB We might get passed val null with 0 stones, so we hack around that
            if (numStones == 0) return new Node(NodeValue.Trivial, new Node[0]);

            // Cache
            Pair<int, NodeValue> key = new Pair<int, NodeValue>(numStones, val);
            Node node;
            if (cache.TryGetValue(key, out node)) return node;

            // The pair-of-nodes construction is based on a bijection between
            //     $\prod_{i<k} T_i \cup \{(\infty, 0)\}$
            // and
            //     $(T_{k-1} \cup \{(\infty, 0)\}) \times \prod_{i<k-1} T_i \cup \{(\infty, 0)\}$

            // val.Left represents the element of $T_{k-1} \cup \{(\infty, 0)\}$ (using null for the $(\infty, 0)$)
            // and val.Right represents $\prod_{i<k-1} T_i \cup \{(\infty, 0)\}$ by bijection with $T_{k-1} \cup \{(\infty, 0)\}$.
            // so val.Right.Left represents the element of $T_{k-2}$ and so on.
            // The element of $T_{k-i}$ corresponds to throwing $i$ stones.
            Node[] children = new Node[numStones];
            NodeValue current = val;
            for (int i = 0; i < numStones && current != null; i++)
            {
                children[i] = BuildDecisionTree(numStones - (i + 1), current.Left, cache);
                current = current.Right;
            }
            node = new Node(val, children);

            // Cache
            cache[key] = node;
            return node;
        }

        class Pair<TFirst, TSecond>
        {
            public readonly TFirst X;
            public readonly TSecond Y;

            public Pair(TFirst x, TSecond y)
            {
                this.X = x;
                this.Y = y;
            }

            public override string ToString()
            {
                return string.Format("({0}, {1})", X, Y);
            }

            public override bool Equals(object obj)
            {
                Pair<TFirst, TSecond> other = obj as Pair<TFirst, TSecond>;
                return other != null && object.Equals(other.X, this.X) && object.Equals(other.Y, this.Y);
            }

            public override int GetHashCode()
            {
                return X.GetHashCode() + 37 * Y.GetHashCode();
            }
        }

        class NodeValue : Pair<int, int>
        {
            public readonly NodeValue Left;
            public readonly NodeValue Right;

            public static NodeValue Trivial = new NodeValue(1, 1, null, null);

            private NodeValue(int x, int y, NodeValue left, NodeValue right) : base(x, y)
            {
                this.Left = left;
                this.Right = right;
            }

            public NodeValue Reverse()
            {
                return new NodeValue(Y, X, this, null);
            }

            public NodeValue Combine(NodeValue other)
            {
                return new NodeValue(other.X + Y, Math.Min(other.Y, X), this, other);
            }
        }

        class Node
        {
            public readonly NodeValue Value;
            private readonly Node[] _Children;

            public Node this[int n]
            {
                get { return _Children[n]; }
            }

            public int RemainingStones
            {
                get { return _Children.Length; }
            }

            public Node(NodeValue value, IEnumerable<Node> children)
            {
                this.Value = value;
                this._Children = children.ToArray();
            }
        }

        interface SpyIO
        {
            int Input();
            void Output(int i);
        }

        // TODO The inter-thread communication here can almost certainly be much better
        class TestSpyIO : SpyIO
        {
            private object _Lock = new object();
            private int? _Buffer;
            public TestSpyIO Partner;
            public readonly string Name;

            internal TestSpyIO(string name)
            {
                this.Name = name;
            }

            public int Input()
            {
                lock (_Lock)
                {
                    while (!_Buffer.HasValue) Monitor.Wait(_Lock);

                    int rv = _Buffer.Value;
                    _Buffer = null;
                    Monitor.PulseAll(_Lock);
                    return rv;
                }
            }

            public void Output(int i)
            {
                lock (Partner._Lock)
                {
                    while (Partner._Buffer.HasValue) Monitor.Wait(Partner._Lock);
                    Partner._Buffer = i;
                    Monitor.PulseAll(Partner._Lock);
                }
            }
        }

        class ConsoleIO : SpyIO
        {
            public int Input()
            {
                return Convert.ToInt32(Console.ReadLine());
            }

            public void Output(int i)
            {
                Console.WriteLine("{0}", i);
            }
        }

        class Spy
        {
            private readonly SpyIO _IO;
            private Node _Node;
            private bool _MyTurn;

            internal Spy(SpyIO io, Node root, bool isSpy1)
            {
                this._IO = io;
                this._Node = root;
                this._MyTurn = isSpy1;
            }

            internal void Run()
            {
                int myValue = _IO.Input() - 1;
                int hisValue = 1;

                bool myTurn = _MyTurn;
                Node n = _Node;
                while (n.RemainingStones > 0)
                {
                    if (myTurn)
                    {
                        if (myValue >= n.Value.X) throw new Exception("Internal error");
                        for (int i = 0; i < n.RemainingStones; i++)
                        {
                            // n[i] allows me to represent n[i].Y values: 0 to n[i].Y - 1
                            if (myValue < n[i].Value.Y)
                            {
                                _IO.Output(i + 1);
                                n = n[i];
                                break;
                            }
                            else myValue -= n[i].Value.Y;
                        }
                    }
                    else
                    {
                        int thrown = _IO.Input();
                        for (int i = 0; i < thrown - 1; i++)
                        {
                            hisValue += n[i].Value.Y;
                        }
                        n = n[thrown - 1];
                    }

                    myTurn = !myTurn;
                }

                _IO.Output(hisValue);
            }
        }
    }

    static class LinqExt
    {
        // I'm not sure why this isn't built into Linq.
        public static TElement MaxElement<TElement>(this IEnumerable<TElement> e, Func<TElement, int> f)
        {
            int bestValue = int.MinValue;
            TElement best = default(TElement);
            foreach (var elt in e)
            {
                int value = f(elt);
                if (value > bestValue)
                {
                    bestValue = value;
                    best = elt;
                }
            }
            return best;
        }
    }
}

Instructions for Linux users
You'll need mono-csc to compile (on Debian-based systems, it's in the mono-devel package) and mono to run (mono-runtime package). Then the incantations are
mono-csc -out:codegolf31673.exe codegolf31673.cs
mono codegolf31673.exe --test

etc.

Is that C#? I don't know how to run that on Linux.

All this time I thought I was doing something wrong. As it turns out, building the decision tree simply takes 30 minutes... For the record, this works on Fedora 20: 1. yum install mono-core (as root). 2. dmcs  Puzzle625.cs 3. mono Puzzle625.exe --test

@Dennis, I think that Mono's JIT isn't quite as good as Microsoft's. I have some ideas for optimisation, but I haven't finished testing them.

Fedora's repositories provide version 2.10.8, which is over two years old. Maybe newer versions are faster. I'm curious: How long does it take with Microsoft?

@Dennis, I've heavily optimised the decision tree generation.

From 30 minutes to 39 microseconds. That's what I call an optimization!

Python Tester Program
I figure it would be useful to have a test program which can verify that your implementation is working. Both scripts below work with either Python 2 or Python 3.
Tester program (tester.py):
import sys
import shlex
from subprocess import Popen, PIPE

def writen(p, n):
    p.stdin.write(str(n)+'\n')
    p.stdin.flush()

def readn(p):
    return int(p.stdout.readline().strip())

MAXSTONES = 26

def test_one(spy1cmd, spy2cmd, n1, n2):
    p1 = Popen(spy1cmd, stdout=PIPE, stdin=PIPE, universal_newlines=True)
    p2 = Popen(spy2cmd, stdout=PIPE, stdin=PIPE, universal_newlines=True)

    nstones = MAXSTONES

    writen(p1, n1)
    writen(p2, n2)

    p1turn = True
    while nstones > 0:
        if p1turn:
            s = readn(p1)
            writen(p2, s)
        else:
            s = readn(p2)
            writen(p1, s)
        if s <= 0 or s > nstones:
            print("Spy %d output an illegal number of stones: %d" % ([2,1][p1turn], s))
            return False
        p1turn = not p1turn
        nstones -= s

    n1guess = readn(p2)
    n2guess = readn(p1)

    if n1guess != n1:
        print("Spy 2 output wrong answer: expected %d, got %d" % (n1, n1guess))
        return False
    elif n2guess != n2:
        print("Spy 1 output wrong answer: expected %d, got %d" % (n2, n2guess))
        return False

    p1.kill()
    p2.kill()

    return True

def testrand(spy1, spy2, M):
    import random
    spy1cmd = shlex.split(spy1)
    spy2cmd = shlex.split(spy2)

    n = 0
    while 1:
        i = random.randrange(1, M+1)
        j = random.randrange(1, M+1)
        test_one(spy1cmd, spy2cmd, i, j)
        n += 1
        if n % 100 == 0:
            print("Ran %d tests" % n)

def test(spy1, spy2, M):
    spy1cmd = shlex.split(spy1)
    spy2cmd = shlex.split(spy2)
    for i in range(1, M+1):
        print("Testing %d..." % i)
        for j in range(1, M+1):
            if not test_one(spy1cmd, spy2cmd, i, j):
                print("Spies failed the test.")
                return
    print("Spies passed the test.")

if __name__ == '__main__':
    if len(sys.argv) != 4:
        print("Usage: %s <M> <spy1> <spy2>: test programs <spy1> and <spy2> with limit M" % sys.argv[0])
        exit()

    M = int(sys.argv[1])
    test(sys.argv[2], sys.argv[3], M)

Protocol: The two spy programs specified on the command-line will be executed. They are expected to interact solely though stdin/stdout. Each program will receive its assigned number as the first line of input. In each turn, spy 1 outputs the number of stones to throw, spy 2 reads a number from stdin (representing spy 1's throw), and then they repeat (with positions reversed). When either spy determines that 26 stones have been thrown, they stop and output their guess for the other spy's number.
Example session with a compatible spy1 (> denotes input to the spy)
> 42
7
> 5
6
> 3
5
27
<program quits>

If you choose a very large M, and it takes too long to run, you can switch test( for testrand( in the last line to run random tests. In the latter case, leave the program running for at least a few thousand trials to build up confidence.
Example program (spy.py), for M=42:
import sys

# Carry out the simple strategy for M=42

def writen(n):
    sys.stdout.write(str(n)+"\n")
    sys.stdout.flush()

def readn():
    return int(sys.stdin.readline().strip())

def spy1(n):
    m1,m2 = divmod(n-1, 6)
    writen(m1+1)
    o1 = readn() # read spy2's number

    writen(m2+1)
    o2 = readn()

    rest = 26 - (m1+m2+o1+o2+2)
    if rest > 0:
        writen(rest)
    writen((o1-1)*6 + (o2-1) + 1)

def spy2(n):
    m1,m2 = divmod(n-1, 6)
    o1 = readn() # read spy1's number
    writen(m1+1)

    o2 = readn()
    writen(m2+1)

    rest = 26 - (m1+m2+o1+o2+2)
    if rest > 0:
        readn()

    writen((o1-1)*6 + (o2-1) + 1)

if __name__ == '__main__':
    if len(sys.argv) != 2:
        print("Usage: %s [spy1|spy2]" % (sys.argv[0]))
        exit()

    n = int(input())
    if sys.argv[1] == 'spy1':
        spy1(n)
    elif sys.argv[1] == 'spy2':
        spy2(n)
    else:
        raise Exception("Must give spy1 or spy2 as an argument.")

Example usage:
python tester.py 42 'python spy.py spy1' 'python spy.py spy2'

Java, M = 2535
OK, here is my implementation.  At each step one spy makes a move.  Each possible move represents a range of codes.  The spy chooses the move matching his secret code.  As they throw more stones, the range of possible codes reduces until, at the end, for both spies, only one code remains possible according to the moves they did.
To recover the secret codes, you can replay all the moves and compute the corresponding code ranges.  At the end, only one code remains for each spy, that is the secret code he wanted to transmit.
Unfortunately, the algorithm relies on a large precomputed table with hundred of thousands of integers.  The method couldn't be applied mentally with more than 8-10 stones maybe.
The first file implements the Spy's algorithm.  The static part precomputes a codeCount table that is later used to compute each move.  The second part implements 2 procedures, one to select how many stones to throw, the other to replay a moves to help reconstruct the secret codes.
The second file tests the Spy class extensively.  The method simulate simulates the process.  It uses the Spy class to generate a sequence of throws from the secret codes and then reconstructs the codes from the sequence.
Spy.java
package stackexchange;

import java.util.Arrays;

public class Spy
{
    // STATIC MEMBERS

    /** Size of code range for a number of stones left to the other and the other spy's range */
    static int[][] codeCount;

    // STATIC METHODS

    /** Transpose an array of code counts */
    public static int[] transpose(int[] counts){
        int[] transposed = new int[counts[1]+1];
        int s = 0;
        for( int i=counts.length ; i-->0 ; ){
            while( s<counts[i] ){
                transposed[++s] = i;
            }
        }
        return transposed;
    }

    /** Add two integer arrays by element.  Assume the first is longer. */
    public static int[] add(int[] a, int[] b){
        int[] sum = a.clone();
        for( int i=0 ; i<b.length ; i++ ){
            sum[i] += b[i];
        }
        return sum;
    }

    /** Compute the code range for every response */
    public static void initCodeCounts(int maxStones){
        codeCount = new int[maxStones+1][];
        codeCount[0] = new int[] {0,1};
        int[] sum = codeCount[0];
        for( int stones=1 ; stones<=maxStones ; stones++ ){
            codeCount[stones] = transpose(sum);
            sum = add(codeCount[stones], sum);
        }
    }

    /** display the code counts */
    public static void dispCodeCounts(int maxStones){
        for( int stones=1 ; stones<=maxStones ; stones++ ){
            if( stones<=8 ){
                System.out.println(stones + ": " + Arrays.toString(codeCount[stones]));
            }
        }
        for( int s=1 ; s<=maxStones ; s++ ){
            int[] row = codeCount[s];
            int best = 0;
            for( int r=1 ; r<row.length ; r++ ){
                int min = r<row[r] ? r : row[r];
                if( min>=best ){
                    best = min;
                }
            }
            System.out.println(s + ": " + row.length + " " + best);
        }
    }

    /** Find the maximum symmetrical code count M for a number of stones */
    public static int getMaxValue(int stones){
        int[] row = codeCount[stones];
        int maxValue = 0;
        for( int r=1 ; r<row.length ; r++ ){
            int min = r<row[r] ? r : row[r];
            if( min>=maxValue ){
                maxValue = min;
            }
        }
        return maxValue;
    }

    // MEMBERS

    /** low end of range, smallest code still possible */
    int min;

    /** range size, number of codes still possible */
    int range;

    /** Create a spy for a certain number of stones */
    Spy(int stones){
        min = 1;
        range = getMaxValue(stones);
    }

    /** Choose how many stones to throw */
    public int throwStones(int stonesLeft, int otherRange, int secret){
        for( int move=1 ; ; move++ ){
            // see how many codes this move covers
            int moveRange = codeCount[stonesLeft-move][otherRange];
            if( secret < this.min+moveRange ){
                // secret code is in move range
                this.range = moveRange;
                return move;
            }
            // skip to next move
            this.min += moveRange;
            this.range -= moveRange;
        }
    }

    /* Replay the state changes for a given move */
    public void replayThrow(int stonesLeft, int otherRange, int stonesThrown){
        for( int move=1 ; move<stonesThrown ; move++ ){
            int moveRange = codeCount[stonesLeft-move][otherRange];
            this.min += moveRange;
            this.range -= moveRange;
        }
        this.range = codeCount[stonesLeft-stonesThrown][otherRange];
    }
}

ThrowingStones.java
package stackexchange;

public class ThrowingStones
{
    public boolean simulation(int stones, int secret0, int secret1){

        // ENCODING

        Spy spy0 = new Spy(stones);
        Spy spy1 = new Spy(stones);

        int[] throwSequence = new int[stones+1];
        int turn = 0;
        int stonesLeft = stones;

        while( true ){
            // spy 0 throws
            if( stonesLeft==0 ) break;
            throwSequence[turn] = spy0.throwStones(stonesLeft, spy1.range, secret0);
            stonesLeft -= throwSequence[turn++];
            // spy 1 throws
            if( stonesLeft==0 ) break;
            throwSequence[turn] = spy1.throwStones(stonesLeft, spy0.range, secret1);
            stonesLeft -= throwSequence[turn++];
        }

        assert (spy0.min==secret0 && spy0.range==1 );
        assert (spy1.min==secret1 && spy1.range==1 );

//      System.out.println(Arrays.toString(throwSequence));

        // DECODING

        spy0 = new Spy(stones);
        spy1 = new Spy(stones);

        stonesLeft = stones;
        turn = 0;
        while( true ){
            // spy 0 throws
            if( throwSequence[turn]==0 ) break;
            spy0.replayThrow(stonesLeft, spy1.range, throwSequence[turn]);
            stonesLeft -= throwSequence[turn++];
            // spy 1 throws
            if( throwSequence[turn]==0 ) break;
            spy1.replayThrow(stonesLeft, spy0.range, throwSequence[turn]);
            stonesLeft -= throwSequence[turn++];
        }
        int recovered0 = spy0.min;
        int recovered1 = spy1.min;

        // check the result
        if( recovered0 != secret0 || recovered1 != secret1 ){
            System.out.println("error recovering (" + secret0 + "," + secret1 + ")"
                    + ", returns (" + recovered0 + "," + recovered1 + ")");
            return false;
        }
        return true;
    }

    /** verify all possible values */
    public void verifyAll(int stones){
        int count = 0;
        int countOK = 0;
        int maxValue = Spy.getMaxValue(stones);
        for( int a=1 ; a<=maxValue ; a++ ){
            for( int b=1 ; b<=maxValue ; b++ ){
                count++;
                if( simulation(stones, a, b) ) countOK++;
            }
        }
        System.out.println("verified: " + countOK + "/" + count);
    }

    public static void main(String[] args) {
        ThrowingStones app = new ThrowingStones();
        Spy.initCodeCounts(26);
        Spy.dispCodeCounts(26);
        app.verifyAll(20);
//      app.verifyAll(26); // never managed to complete this one...
    }

}

For reference, the precomputed codeCount array contains the following values:
1: [0, 1]
2: [0, 1, 1]
3: [0, 2, 1, 1]
4: [0, 3, 2, 1, 1, 1]
5: [0, 5, 3, 2, 2, 1, 1, 1, 1]
6: [0, 8, 5, 4, 3, 2, 2, 2, 1, 1, 1, 1, 1, 1]

This related directly to Peter Taylor's Tk sets.  We have:
(x,y) in Tk  <=>  y <= codeCount[x]

I don't think this quite meets spec without a way to run the two spies in separate processes and communicate the throws without sharing access to their range fields. But I'm very intrigued by your method of calculating the table. Do you have a proof of correctness? And are you interested in collaborating on a paper which discusses the problem and calculating its solution?

The other spy's range is a function of the past moves, as it is computed in the "replay" method.  I believe it is correct.  The table I compute is exactly the same as you sets Tk.  Transposing the table exchanges x and y, the sum is the sum of all possible children from a node.  I haven't proven it correct, except that I have tested it up to 22 stones.  I tried to write a proper answer for puzzling.stackexchange, but I haven't managed to explain it in a clear an convincing way.  And mostly, it is what you did already.

Ok. I probably don't have time this week, but when I'm less busy I'll try to find a proof that your generation method produces the same table as mine, because I think it would be a good addition to the stuff I've written up already.

Actually it's quite simple: its equivalence to my calculation method comes down to the lemma that the conjugate of the multiset-union of two partitions is equal to the pointwise sum of their conjugates.

(slaping my head) But of course!  Why didn't I think of that earlier?  :-)

Preprint which explains it a bit better. Comments welcome.

Ok. I've updated the .tex but I need to run: will update the PDF later.

ksh/zsh, M = 126
In this simple system, each spy throws binary digits to the other spy. In each throw, the first stone is ignored, the next stones are each bit 0, and the last stone is bit 1. For example, to throw 20, a spy would throw 4 stones (ignore, 0, 2, add 4), then throw 3 stones (ignore, 8, add 16), because 4 + 16 = 20.
The set of numbers is not contiguous. 0 to 126 are in, but 127 is out. (If both spies have 127, they need 28 stones, but they have 26 stones.) Then 128 to 158 are in, 159 is out, 160 to 174 are in, 175 is out, 176 to 182 are in, 183 is out, 184 to 186 is in, 187 is out, and so on.
Run an automatic swap with ksh spy.sh 125 126, or run individual spies with ksh spy.sh spy1 125 and ksh spy.sh spy2 126. Here, ksh can be ksh93, pdksh or zsh.
EDIT 14 Jun 2014: Fix a problem with some co-processes in zsh. They would idle forever and fail to exit, until the user killed them.
(( stones = 26 ))

# Initialize each spy.
spy_init() {
    (( wnum = $1 ))  # my number
    (( rnum = 0 ))   # number from other spy
    (( rlog = -1 ))  # exponent from other spy
}

# Read stone count from other spy.
spy_read() {
    read count || exit
    (( stones -= count ))

    # Ignore 1 stone.
    (( count > 1 )) && {
        # Increment exponent.  Add bit to number.
        (( rlog += count - 1 ))
        (( rnum += 1 << rlog ))
    }
}

# Write stone count to other spy.
spy_write() {
    if (( wnum ))
    then
        # Find next set bit.  Prepare at least 2 stones.
        (( count = 2 ))
        until (( wnum & 1 ))
        do
            (( wnum >>= 1 ))
            (( count += 1 ))
        done

        (( wnum >>= 1 ))  # Remove this bit.
        (( stones -= count ))
        print $count      # Throw stones.
    else
        # Throw 1 stone for other spy to ignore.
        (( stones -= 1 ))
        print 1
    fi
}

# spy1 writes first.
spy1() {
    spy_init "$1"
    while (( stones ))
    do
        spy_write
        (( stones )) || break
        spy_read
    done
    print $rnum
}

# spy2 reads first.
spy2() {
    spy_init "$1"
    while (( stones ))
    do
        spy_read
        (( stones )) || break
        spy_write
    done
    print $rnum
}

(( $# == 2 )) || {
    name=${0##*/}
    print -u2 "usage: $name number1 number2"
    print -u2 "   or: $name spy[12] number"
    exit 1
}

case "$1" in
    spy1)
        spy1 "$2"
        exit;;
    spy2)
        spy2 "$2"
        exit;;
esac

(( number1 = $1 ))
(( number2 = $2 ))

if [[ -n $KSH_VERSION ]]
then
    eval 'cofork() { "$@" |& }'
elif [[ -n $ZSH_VERSION ]]
then
    # In zsh, a co-process stupidly inherits its own >&p, so it never
    # reads end of file.  Use 'coproc :' to close <&p and >&p.
    eval 'cofork() {
        coproc {
            coproc :
            "$@"
        }
    }'
fi

# Fork spies in co-processes.
[[ -n $KSH_VERSION ]] && eval 'coproc() { "$@" |& }'
cofork spy1 number1
exec 3<&p 4>&p
cofork spy2 number2
exec 5<&p 6>&p

check_stones() {
    (( stones -= count ))
    if (( stones < 0 ))
    then
        print -u2 "$1 is in trouble! " \
            "Needs $count stones, only had $((stones + count))."
        exit 1
    else
        print "$1 threw $count stones.  Pile has $stones stones."
    fi
}

# Relay stone counts while spies throw stones.
while (( stones ))
do
    # First, spy1 writes to spy2.
    read -u3 count report1 || mia spy1
    check_stones spy1
    print -u6 $count

    (( stones )) || break

    # Next, spy2 writes to spy1.
    read -u5 count report2 || mia spy2
    check_stones spy2
    print -u4 $count
done

mia() {
    print -u2 "$1 is missing in action!"
    exit 1
}

# Read numbers from spies.
read -u3 report1 || mia spy1
read -u5 report2 || mia spy2

pass=true
(( number1 != report2 )) && {
    print -u2 "FAILURE: spy1 put $number1, but spy2 got $report2."
    pass=false
}
(( number2 != report1 )) && {
    print -u2 "FAILURE: spy2 put $number2, but spy1 got $report1."
    pass=false
}

if $pass
then
    print "SUCCESS: spy1 got $report1, spy2 got $report2."
    exit 0
else
    exit 1
fi

source: Stack Exchange

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

sort: votes


text:
Negate a number
You are to accept, on standard input, one number. You will then output the negation of that number. Your code will do nothing else. You may accept various formats if you wish (like "one" or ("uno+2.4e10i"). You may also output it how ever you wish. Note that these formats mush have existed somewhere on the internet before this question. The thing you can't do is use the same 6 character sequence twice in your code. Also, if any set of characters can be removed, and your code still functions the same, they must be removed (no making huge useless strings, since they could just be removed.)
This is code bowling, so the answer with the most characters wins!
Note: In case you were wondering, negation means "multiply by negative one." The representation of the numbers is up to you, but the meaning of negation is not.

Do you mean negation as in 8 -> -8 or negation as in 0100 -> 1011?

This SO Q&A suggests that, in general, ~x = -x - 1, which is not the same thing as what you state. You need to clarify this, what exactly do you mean by negation.

I thought the bit complement was negation. Apparently not.

About the "if any set of characters can be removed": does that only apply to consecutive characters or really any set of characters?

To build on @m.buettner's question, how are long variable names counted?

This is a completely objective criteria if you read the question.

Objective or not, I don't get it. Either way, it's not a good question. 1. If it refers to any arbitrary set of characters, every GolfScript answer containing a ~, a ) and a ~ after that will have a score of 3, no matter what those characters do (if anything) at the moment. 2. If it refers to consecutive characters, you can still use arbitrarily large strings, as long you check their lengths.

@Dennis There is an upper bound on length. Also,  if your golf script works on many different formats, reducing it to~(~ changes it's function, so wouldn't occur.

@PyRulez: The upper bound is 1592 TB if we restrict ourselves to 1 byte characters. You got me convinced about removing the characters, but this will be extremely difficult to test. Even for a 256 byte program, there are over 10**77 different programs that can be formed just by removing characters.

I retract my previous comment. This is actually a nice challenge; it's just very difficult to figure out whether a given solution is valid or not. All ideas I had to trivialize it were doomed to failure.

I think as of Dennis's code this has gotten out of hand. There was a question recently where code had to be pointlessly contrived, but ever part had to have some semi-plausible software good practice justification. here it is

@NathanCooper This question was sort of an experiment with restricted source and code bowling anyway. They were talking about nuking the tag on meta.

CJam, 278,548 characters
Stack Exchange has a 30,000 character limit, so I've uploaded my code to Google Drive.
The online interpreter chokes when decoding the lookup tables (Maximum call stack size exceeded), so I suggest using the standard interpreter (requires Java).
I/O
Input should be an integer (in whatever format CJam understands). Output is in British English.
$ cjam negate.cjam <<< 9990001
negative nine million nine hundred and ninety thousand and one
$ cjam negate.cjam <<< -1001000000
one milliard and one million
$ cjam negate.cjam <<< 0
zero

Validity
All code is functional, so removing parts should not be possible. Note that all linefeeds are part of strings and cannot be removed.
There are no repeated sequences of six characters:
$ tr \\n \\t <negate.cjam | grep -P '(.{6}).*\1' | wc -c
0

How it works
I've started with a list of the first one thousand natural numbers and a list of the first three thousand three hundred and thirty-four powers of one thousand.
Sadly, both lists repeat the same 6 character sequences over and over again, so I had to encode them in a way that would avoid those repeated sequences. The following CJam code accomplishes that task:
q
2G#b
94b
{32+}%
{c}%
" !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}"
"}|{zyxwvutsrqponmlkjihgfedcba`_^]~[ZYXWVUTSRQPONMLKJIHGFEDCBA@?>=<;:9876543210/.-,+*)('&%$#
! "
er

It reads the list from STDIN (q), converts the resulting string into a base 65536 number (2G#b), converts the resulting integer into an array by considering it a base 94 number (94b), adds 32 to each integer in the array ({32+}%) to avoid unprintable characters, converts the array into a string ({c}%) and performs a character transliteration ("…""…"er) to get rid of characters that require escaping. This required a little trial-and-error; the natural choice (95b) resulted in repeated sequences.
The final code does the following:
{                             " Define a decoding function for the lists.               ";
  "…""…"er{32-}%94b2G#b{c}%   " Perform the steps from above in reverse order.          ";
  "
  "/                          " Split the result by linefeeds.                          ";
}:D;

"…":H;"…":P;                  " Store the encoded lists in variables.                   ";

q~                            " Interpret the input from STDIN.                         ";
__                            " Duplicate twice.                                        ";
0<!{}{-1*}?                   " If the input is negative, multiply the last copy by -1. ";
`_                            " Stringify and duplicate the last copy.                  ";
,3%3\-"0"*\+                  " Prepend 0's to make the string length a multiple of 3.  ";
3/-1%                         " Split into string of three characters and reverse.      ";
-1:C;                         " Initialize variable C to -1. ";
{                             " For each substring:                                     ";
  ~                           " Interpret it (i.e., cast to integer).                   ";
  H=_                         " Retrieve the correspond English number from H.          ";
  'z'e'r"o"+++=               " Push 1 if the number is zero.                           ";
  C):C;                       " Increment C.                                            ";
  {;}{" "+CP=+}?              " Remove 0 or append the corresponding modifier from P.   ";
 }%
-1%_                          " Reverse the array and duplicate it.                     ";
,1>                           " If the array has more than one element…                 ";
{
  )_"and"/,1=                 " …and the last element doesn't contain the string 'and'… ";
  'a'n'd" "+++*\+a+           " …prepend the  string 'and ' to it.                      ";
}{_,0={H0=a+}*}?              " If the array is empty, replace it with [ 'zero' ].      ";
\0>                           " If the input was positive,                              ";
{
  'n'e'g'a't'i'v"e"+++++++a\+ " prepend the string 'negative'.                          ";
}{}?
" "*                          " Join the array of strings with spaces.                  ";
"
"                             " Append a linefeed.                                      ";

Do you think you could explain how you made this?

@PyRulez: I've edited my answer.

Tcl, 1073741823 (1G-1 bytes, cheating)
This is (obviously) cheating. It can be even larger in some languages like Bash, which doesn't load the whole program when it starts. Tcl runs very slow at starting, and finally refuses to run the program if the file size is about 2147483647 bytes or more.
set b binary
$b scan [$b format i [expr {[gets stdin]-1^3+[file size $argv0]*4}]] i a
puts $a
exit
#!!!!!#"!!!!#%!!!!#&!!!!#'!!!!#(!!!!#)!!!!#*!!!!#+!!!!#,!!!!#-!!!!#.!!!!#/!!!!#0!!!!#1!!!!#2!!!!#3!!!!#4!!!!#5!!!!#6!!!!#7!!!!#8!!!!#9!!!!#:!!!!#<!!!!#=!!!!#>!!!!#?!!!!#@!!!!#A!!!!#B!!!!#C!!!!#D!!!!#E!!!!#F!!!!#G!!!!#H!!!!#I!!!!#J!!!!#K!!!!#L!!!!#M!!!!#N!!!!#O!!!!#P!!!!#Q!!!!#R!!!!#S!!!!#T!!!!#U!!!!#V!!!!#W!!!!#X!!!!#Y!!!!#Z!!!!#[!!!!#^!!!!#_!!!!#`!!!!#a!!!!#b!!!!#c!!!!#d!!!!#e!!!!#f!!!!#g!!!!#h!!!!#i!!!!#j!!!!#k!!!!#l!!!!#m!!!!#n!!!!#o!!!!#p!!!!#q!!!!#r!!!!#s!!!!#t!!!!#u!!!!#v!!!!#w!!!!#x!!!!#y!!!!#z!!!!#{!!!!#|!!!!#~!!!!#!"!!!#""!!!#%"!!!#&"!!!#'"!!!#("!!!#)"!!!#*"!!!#+"!!!#,"!!!#-"!!!#."!!!#/"!!!#0"!!!#1"!!!#2"!!!#3"!!!#4"!!!#5"!!!#6"!!!#7"!!!#8"!!!#9"!!!#:"!!!#<"!!!#="!!!#>"!!!#?"!!!#@"!!!#A"!!!#B"!!!#C"!!!#D"!!!#E"!!!#F"!!!#G"!!!#H"!!!#I"!!!#J"!!!#K"!!!#L"!!!#M"!!!#N"!!!#O"!!!#P"!!!#Q"!!!#R"!!!#S"!!!#T"!!!#U"!!!#V"!!!#W"!!!#X"!!!#Y"!!!#Z"!!!#["!!!#^"!!!#_"!!!#`"!!!#a"!!!#b"!!!#c"!!!#
(...1073740323 more bytes...)
|%#m+Y|%#n+Y|%#o+Y|%#p+Y|%#q+Y|%#r+Y|%#s+Y|%#t+Y|%#u+Y|%#v+Y|%#w+Y|%#x+Y|%#y+Y|%#z+Y|%#{+Y|%#|+Y|%#~+Y|%#!,Y|%#",Y|%#%,Y|%#&,Y|%#',Y|%#(,Y|%#),Y|%#*,Y|%#+,Y|%#,,Y|%#-,Y|%#.,Y|%#/,Y|%#0,Y|%#1,Y|%#2,Y|%#3,Y|%#4,Y|%#5,Y|%#6,Y|%#7,Y|%#8,Y|%#9,Y|%#:,Y|%#<,Y|%#=,Y|%#>,Y|%#?,Y|%#@,Y|%#A,Y|%#B,Y|%#C,Y|%#D,Y|%#E,Y|%#F,Y|%#G,Y|%#H,Y|%#I,Y|%#J,Y|%#K,Y|%#L,Y|%#M,Y|%#N,Y|%#O,Y|%#P,Y|%#Q,Y|%#R,Y|%#S,Y|%#T,Y|%#U,Y|%#V,Y|%#W,Y|%#X,Y|%#Y,Y|%#Z,Y|%#[,Y|%#^,Y|%#_,Y|%#`,Y|%#a,Y|%#b,Y|%#c,Y|%#d,Y|%#e,Y|%#f,Y|%#g,Y|%

It computes the result with its own file size. So deleting anything will change the behavior.
The above program is generated by the C++ program below.
#include<fstream>
#include<string>
#include<cstring>

std::ofstream f("a.tcl");
const long long size = 0x3fffffffLL;

const std::string init = "set b binary\n"
             "$b scan [$b format i [expr {[gets stdin]-1^3+[file size $argv0]*4}]] i a\n"
             "puts $a\n"
             "exit\n";
const std::string charset = "!\"%&'()*+,-./0123456789:<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[^_`abcdefghijklmnopqrstuvwxyz{|~";
const int ncharset = 88;

int main() {
    f<<init;
    long long p = init.length();

    int b[5] = {};
    char ch[6] = "!!!!!";

    while(p < size) {
        f<<"#";
        p++;
        if(size-p > 5) {
            f.write(ch, 5);
            p += 5;
        }
        else {
            f.write(ch, size-p);
            break;
        }
        int i=0;
        while(b[i] == ncharset-1) {
            ch[i] = charset[b[i]=0];
            i++;
        }
        ch[i] = charset[++b[i]];
    }
    f<<std::flush;
    return 0;
}

The 7-zipped version of the complete program has only 18MB. Maybe I can upload it somewhere if someone request for it.
I chose Tcl because it has only a small number of special characters. So I could be sure one cannot implement the same functionality by selecting some characters not to delete. I guess Lisp is better on this.

(new to code bowling) Why is this cheating?

Wolfram Mathematica 10↑↑3.1955 characters
Bowling-ed:
ToExpression[FromCharacterCode[StringLength["¡¢£¤¥¦§..."]~IntegerDigits~Nest[Hyperfactorial, 10, 2]]]

This is closely based on my answer to Biggest Irreducible Hello World
Where the string is the length-6 DeBruijn Sequence of every unicode character over 128. This guarantees that it never repeats any set of 6 in itself, or outside the code since 6 never show up. Since there are only points over 128, even if there are valid symbols, none of them can read user input.
Golfed / decoded:
Print[-Input[]]

Which is converted to it's character code (80, 114, 105...) and read back as a base-Nest[Hyperfactorial, 10, 2] number. This cannot be broken down to any number besides 109, which is not at least 117 for 'u'.
This means the string length is (k!)^k^(n-1)/k^n, where k is the number of unique characters, and n is the length of each non-repeating group (6).
Oddly enough, I think this is the hard limit to this question. If it wasn't for the 6-character restriction, or unicode only have 1 million characters, then the answer would have been a tad over
80 * Nest[Hyperfactorial, 10, 9]]^15

or
10↑↑11.289

C# 865
Uses DateTime parsing since a negative will throw an exception. Since Console was already used the answer is output to a Form. Also C# has string and String object.
Edit: removed some duplicate char sequences.
using System;
using System.ComponentModel;
using System.Windows.Forms;
using System.Diagnostics;
using System.Globalization;
namespace Golf
{
    class Code
    {
        String num;
        bool isPos;
        Code() { }
        void In()
        {
            num = Console.ReadLine();
        }

        void Out()
        {
            try
            {
                DateTime.Parse(this.num);
                isPos = true;
            }
            catch (Exception)//if negative throw exception
            {
                isPos = false;
            }
            int res;
            double pi = Math.PI;
            if(Int32.TryParse(num, out res))
            {
                res = (int)((isPos) ? Math.Cos(pi) * res : Math.Sin(3 * pi / 2) * res);
            }

            Form f = new Form();
            Label l = new Label();
            l.Text = res.ToString();
            f.Controls.Add(l);
            f.ShowDialog();
        }

        public static void Main(string[] args)
        {
            Code code = new Code();
            code.In();
            code.Out();
        }

    }
}

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

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