text:
Rock Around the Clock
In as few Unicode characters as possible, print the following (144 characters):
1, 2, 3 o'clock, 4 o'clock rock,
5, 6, 7 o'clock, 8 o'clock rock,
9, 10, 11 o'clock, 12 o'clock rock,
We're gonna rock around the clock tonight.

You must not use any numbers in your code, except the digit 1.

There are spaces at the end of first 3 lines, do those count?

@aditsu: These are due to editing, as m.buettner forgot to remove them when editing back to a code block. I would amend this, but the edit is considered too minor.

I removed them now

Several answers use 11. Does the instruction mean you can only use the number 1 or the digit 1?

@mfvonh I said you could use 1. I didn't specify how many times, so the fact that people have used 11 is a clever loophole, and I'm all for it.

what if character literals in my language of choice are 8-bit integers?

@Sparr Post it anyway, but put a note for others

Javascript - 140 132
k=1,s=", ",t=" o'clock",x="";while(k<11)x+=k+++s+k+++s+k+++t+s+k+++t+" rock,\n";alert(x+"We're gonna rock around the clock tonight.")

The fact, that 11 is made out of two 1's let me pass the rules I guess.
Explanation
The k+++s is equal to (k++)+s, so it adds k first to x, then increments k and then it adds s to x. This process will be done three times before it adds the last sentence.

Why do you {} ? It's not needed for the while, you have only 1 instruction. But as you have to use ";" you will win only 1 char. ^^

What does k+++s do? Is it (k++) + s or k + (++s) or (k++) + (++s)?

Easy enough to test: Open the console: var k = 1; var s = 5; k+++s; k; will print the value of k as 2.

+1 for this nonsense: x+=k+++s+k+++s+k+++t+s+k+++t+u

131: for(s=", ",t=" o'clock",i=x='';++i<=11;x+=i+++s+i+++s+i+++t+s+i+t+" rock,\n");alert(x+"We're gonna rock around the clock tonight.")

If you don't store " rock, \n" in a variable, you can reduce your code by 4 bytes

@DLeh Would be if I had one.

this can help you reducing your character count: http://xem.github.io/obfuscatweet/

@TheRare would be easy if you had a console? F12

@DLeh Tried to find it there earlier, but only found the error log. Found it now though, seems like Chrome mixes error log and console.

Since everyone is saying you can put this in the console, I'll point out that you can remove "alert(" and the final ")" from your answer and just get the information output to the console itself. That would reduce this to 133 characters.

Make that 124 using @edc65's modifications. Though I do notice a potential problem: in Firefox, at least, the output had quotation marks around it. But so does the compressed JS example which also forgoes using alert()

@trlkly usually golfing in JS you have to use an output statement and alert is shorter than console.log. Using the auto display of the last calculation in console is like cheating.

At least on my PC your answer would be 132 if you substitute k=1,s=", ",t=" o'clock",x="";while(k<11) with for(k=1,s=", ",t=" o'clock",x="";k<11;). Otherwise it's 133.

Are you sure that's not Brainfuck?

I just can't stop singing out loud k+++s+k+++s+k+++t+s+k+++t (Dr. Seuss style). Guys around me at the open space think I lost it.

C# - 186
Best golf language or best golf language?
class P{static void Main(){var s="";for(int i=1;i<11;)s+=i+++", "+i+++", "+i+++" o'clock, "+i+++" o'clock rock,\n";System.Console.Write(s+"We're gonna rock around the clock tonight.");}}

I wonder why it gained so many votes, too. People like non-golfing-friendly-language entries, maybe

He inspired me to do it in C++, so he gets a vote. Real Men(tm) don't use woosy interpreted languages for code golf!

you don't actually need the spaces in the i++ + bits

I wrote it on dotnetfiddle and it didn't compile without the spaces. Thanks for pointing it.

You can shave a couple more by doing WriteLine -> Write, and using a literal \n at the end of the string.

By using a string you append to and thus only a single System.Console.Write you can bring it down to 186.

Save 2 chars by using c=System.Console;

Use LINQPad's Dump() method to save some chars writing to the screen (bring it down to 173): var s="";for(int i=1;i<11;)s+=i+++", "+i+++", "+i+++" o'clock, "+i+++" o'clock rock,\n";(s+"We're gonna rock around the clock tonight.").Dump();.

Brainfuck (1574)
Not a serious submission, but follows the rules.
-[----->+<]>--.-----.------------.[-->+++<]>++.------.------------.++[-->+++<]>.[--->++<]>--.+++++[->+++<]>.[--->+<]>++.-[--->+<]>+.+++++++++.+++.------------.++++++++.+++[----->++<]>.------------.++[-->+++<]>+.-[--->++<]>--.+++++[->+++<]>.[--->+<]>++.-[--->+<]>+.+++++++++.+++.------------.++++++++.-[++>---<]>+.---[----->++<]>.---.------------.++++++++.+++[----->++<]>.>++++++++++.-[----->+<]>.---------.------------.-----[->++<]>.----------.------------.----[->++<]>-.+[-->+<]>++++.+++++[->+++<]>.[--->+<]>++.-[--->+<]>+.+++++++++.+++.------------.++++++++.+++[----->++<]>.------------.----[->++<]>.[-->+<]>++++.+++++[->+++<]>.[--->+<]>++.-[--->+<]>+.+++++++++.+++.------------.++++++++.-[++>---<]>+.---[----->++<]>.---.------------.++++++++.+++[----->++<]>.>++++++++++.+[->+++++<]>++.-------------.------------.[-->+++<]>+.-.----.------------.[-->+++<]>+..-[--->++<]>.+++++[->+++<]>.[--->+<]>++.-[--->+<]>+.+++++++++.+++.------------.++++++++.+++[----->++<]>.------------.[-->+++<]>+.+.--[--->++<]>.+++++[->+++<]>.[--->+<]>++.-[--->+<]>+.+++++++++.+++.------------.++++++++.-[++>---<]>+.---[----->++<]>.---.------------.++++++++.+++[----->++<]>.>++++++++++.[------>+<]>.++[->++++<]>+.---[->+++<]>+.-[->+++<]>.-------------.--[--->+<]>-.++[->+++<]>+.++++++++.-..-------------.-[->+++<]>.---[----->++<]>.---.------------.++++++++.-[++>---<]>+.[->+++<]>+.--[--->+<]>---.---.++++++.-------.----------.-[--->+<]>-.---[->++++<]>.------------.---.--[--->+<]>-.+[->+++<]>.+++++++++.+++.------------.++++++++.-[++>---<]>+.---[->++++<]>.-----.-.-----.--.+.++++++++++++.[++>---<]>.

Can be tested here.

Brainfuck answers always deserve respect.

Perhaps we should give him the "longest answer" award? #RESPECT

Ruby, 100
printf"%i, %i#{", %i o'clock"*r=-~1} rock,
"*-~r+"We're gonna rock around the clock tonight.",*1..$$

You can save another few characters with s="%i, %i#{", %i o'clock"*-~1} rock,\n" (replace the \n with a literal linebreak). Great idea to use $$!

Expanding on my previous comment: If you assign r=-~1 inline, you can then use "..."*-~r instead of s+s+s, allowing you to drop the assignment to s.

Very nice, will make those edits.

Perl 123
$s="*, *, * o'(, * o'( ),";print"$s
$s
$s
We're gonna ) around the ( tonight."=~s![(*)]!(clock,rock)[1+1+1&ord$&]||++$i!reg

The regular expression matches (, ) and *. I used the fact that the ASCII code of ( is 40, of ) is 41 and * is 42.
The r flag of the regular expression enables "in place substitution" and the e flag enables code evaluation (similar to x.replace(/.../, function(m){...}) in JavaScript).
(clock,rock) is an array of two "bare words". $& is the current match of the regular expression and ord$& is it's ASCII value.
Masked by 3 or 1+1+1 the ASCII values are now 0, 1 and 2, so I can use them to retrieve the corresponding array element.
As 2 is out of the array, the "short circuit" operator || evaluates ++$i. In the first match $i is undef so incrementing it I get 1, then 2 and so on...
In simple words. This replaces * with it's current occurrence, ( with "clock" and ) with "rock".

Does. Not. Compute. Explanation please?

@TheRare Explanation added ;)

It's black magic. +1

This is the kind of thing Perl was made for, unsurprising it does so well.

Bash+coreutils, 120 ASCII, 92 Unicode
ASCII:
c=clock
f(){ echo $[++i], $[++i], $[++i] o\'$c, $[++i] o\'$c rock,;}
f
f
f
echo We\'re gonna rock around the $c tonight.

Unicode:
iconv -t unicode<<<挊挽潬正昻⤨⁻捥潨␠⭛椫ⱝ␠⭛椫ⱝ␠⭛椫⁝屯␧Ᵽ␠⭛椫⁝屯␧潲正㬬㭽㭦㭦㭦捥潨圠履爧潧湮潲正愠潲湵桴挤琠湯杩瑨ਮ|sed 1d|bash

base64 encoded Unicode version (in case unicode renderings get messed up):
aWNvbnYgLXQgdW5pY29kZTw8POaMiuaMvea9rOato+aYiuKkqOKBu+aNpea9qOKQoOKtm+akq+Kx
neKQoOKtm+akq+KxneKQoOKtm+akq+KBneWxr+KQp+Kxo+KQoOKtm+akq+KBneWxr+KQp+KBo+a9
suato+OsrOCpveCppuCppuCppuaNpea9qOWcoOWxpeeIp+KBpea9p+a5ruKBoea9suato+aEoOa9
sua5teKBpOahtOKBpeaMpOeQoOa5r+adqeeRqOCornxzZWQgMWR8YmFzaAo=

120, as the semicolon after the function declaration's closing brace is not needed.

@manatwork Oops good catch - I don't know how that one snuck in there.  Thanks!

I'm on Windows now, but what is the reason to use eval instead of pipeing to bash or sh?

@core1024 No reason other than me forgetting the possibility ;-)  Thanks for the tip!

why not use a variable for rock too, the same way you did for clock?

@Shahbaz It's not worth it.  8 chars for two instances of the string literal rock vs. 11 chars for r=rock; + two references of $r

Oops, didn't count the $rs!

Brainfuck, 1299
Bleuuuurgh. That was terrible. I don't know why I did this, it seemed quite easy at the start. First and probably last Brainfuck script. Try it here.
With some help from an automated code generator, I was able to write a script which reused most of the characters instead of generating each one from scratch. It's only 275 characters shorter than the one automatically generated, posted here.
The output isn't newline-terminated.
I might put a bit of explanation in later on. Essentially, any long line which isn't something like >>>>>>> or <<<<<<< or >>.>>.>>.>>. generates a character or a series of them.
-[----->+<]>--.
>
++[------>+<]>+.------------.
[-]<<+.>
++[------>+<]>+.------------.
[-]<<+.>
++++[->++++++++<]>.
>
+[------->++<]>+.
>
+[------->+++<]>++.
>
--[----->+<]>---.
>
+[------->++<]>--.
>
+[------->++<]>+.
>
--[----->+<]>---.
>
+[----->+++<]>++++.
>
++[------>+<]>+.
>
++++[->++++++++<]>.
<<<<<<<<<<<<<<<<<<<<+.
>>.>>.>>.>>.>>.>>.>>.>>.>>>>.
>
+[--------->++<]>.
>
+[------->++<]>+.
>
--[----->+<]>---.
>
+[----->+++<]>++++.
<<<<<<<<<<.
<++++++++++.
<<<<<<<<<<
<<<<<<<
+.
>>>>>>>>>>
>>>>>>>>.
<<<<<<<<<<
<<<<<<
.<<+.
>>>>>>>>>>
>>>>>>>>.
<<<<<<<<<<
<<<<<<
.<<+.
>>.>>.>>.>>.>>.>>.>>.>>.>>.
<<<<<<<<<<
<<<<<<
.<<+.
>>.>>.>>.>>.>>.>>.>>.>>.>>>>.
>>.>>.>>.>>.
<<<<<<<<<<.
<.
<<<<<<<<<
<<<<<<<<
+.[-]<
++[------>+<]>+.
>>.
[-]<<[-]<
-[----->+<]>--.-.
[-]<
++[------>+<]>+.------------.
[-]<
-[----->+<]>--..
>
++++[->++++++++<]>.
>>.>>.>>.>>.>>.>>.>>.>>.>>.
>>>>>>>>>
-[----->+<]>--.+.
<<<<<<<<<
<<<<<<<<<
<<<<<<<<<
<.
>>.>>.>>.>>.>>.>>.>>.
>>>>.
>>.>>.>>.>>.
>>[-]
++[------>+<]>+.>++++++++++.
>
+[--->++<]>+.++[->++++<]>+.---[->+++<]>+.-[->+++<]>.-------------.--[--->+<]>-.++[->+++<]>+.++++++++.-..-------------.
<<<<<<<<<<
<<<<<<<<<.
>>.>>.>>.>>.
<<[-]<<[-]<<[-]<<.
>
--[----->+<]>-----.--[--->+<]>---.---.++++++.-------.----------.
[-]<<<.
>
--------[-->+++<]>.------------.---.
<<.
<<<<<<<<<<
<<.
>>.>>.>>.>>.
>>>>.
>>[-]
--------[-->+++<]>.-----.-.-----.--.+.++++++++++++.[++>---<]>.

Lua - 217 164 154 151 149 143
Modified the old one to use a loop instead, saves a boat-load of characters. Thanks to TeunPronk for helping me shave off another 10 characters and to WilliamBarbosa for shaving off another 3 characters. 2 more characters can be saved by using the variable k. 6 more characters are saved by eliminating the variable r=" rock," since it is used once.
o=" o'clock"c=", "w=io.write k=1+1 for i=1,11,k+k do w(i,c,i+1,c,i+k,o,c,i+k+1,o," rock,\n")end w("We're gonna rock around the clock tonight.")

Ungolfed,
o=" o'clock"
c=", "
w=io.write
k=1+1
for i=1,11,k+k do
   w(i,c,i+1,c,i+k,o,c,i+k+1,o," rock,\n")
end
w("We're gonna rock around the clock tonight.")

I wonder if it might be shorter if you use a loop instead of j and k.

@TeunPronk: haha, I was just changing that as your comment pinged me

You can bring it down to 157. You dont need the comma after every 3rd number. Put the space infront of O, remove O from R, place a space in R and replace R by O,R in your io.write :)

And also, remove variable N and just type "\n" at the end of your io.write, saves an another 3 characters.

@TeunPronk: Updated. Thanks for your help!

You can store io.write in a variable (f=io.write) and reduce this even further

@WilliamBarbosa: Thanks, updated!

CJam - 90 ASCII / 54 Unicode
ASCII:
{{T):T}:F~", ":CFCF" o'clock":OCFO" rock,
"}Z*"We're gonna rock around the clock tonight."

Unicode:
"ξ漰㠬༳ᆧᶃ㸩씪咦⏚騤䖫퍃᰽薂ᴤਥ궋씻㱗㽫Ƶꐥ勋䎔䃱魠ꝯ朐酠礢璿狮꓈执낦덋觫ᥛ琚"GZ)#bBC*b:c~

Try them at http://cjam.aditsu.net/

Your unico... "This answer has been edited." Oh, nevermind.

Python (123)
print((1+1+1)*"%i, %i, %i o'clock, %i o'clock rock,\n"%tuple(range(1,11+1+1))+"We're gonna rock around the clock tonight.")

PYG (112)
P((1+1+1)*"%i, %i, %i o'clock, %i o'clock rock,\n"%T(R(1,11+1+1))+"We're gonna rock around the clock tonight.")

Brainfuck - 680
test it here: ideone.com/Wi9ftB
>>>++++[>+++++++++[>+++[<<<<+<+>>>>>-]<<<+<<<+<+>>>>>>-]<-]+<++++++++<+++<---------<++++++++
++++<----<++++++++++<+++[>>>+.>>>.<<<<.>>>>>>[>[<<<<<<--------.-.>>>.<<<<.>+..<.>>>.>-----.<
------------.+++++++++.+++.------------.++++++++.++++>+++++.<<<<.>.+.>>>>->>-]+<<+>-]+<[<<<<
+.>>>.<<<<.>+.<.>>>.>-----.<<.>---.+++.<.>----.++++>+++++.<<<<.>+.>>>>-]<<<<<.>>>.>-----.<<.
>---.+++.<.>----.<<<.>>>+++++++.---.<.>----.++++>+++++.<<<<<.<-]>[>>++++<<-]>>---.[-]<[>+<-]
>>++.>>-----.<+++.<.<.>++.>---.-..<------.<.>>++++.---.<++.>----.<<.>--.>+++++++.---.++++++.
-------.<+++.<.>>++++++.<++++.---.<.>--.>--------.+++.<.>----.<<.>>+++++++++.-----.-.-----.-
-.+.>[>+++<-]>-.<<<---[>>+<<--]>>--.

as i promised, here's a better version. my brain feels like.. ooh so that's where the name comes from.
explanation: (because it is unmaintainable and i don't want to forget how it works)
firstly you have to choose the best data layout for this challenge. i came up with
-4 outmost loop
-3 newline char
-2 space
-1 numbers
1 lowercase #1
2 lowercase #2
3 comma, apostrophe, period
4 condition (outmost loop < 3)
5 inner loop
6 second inner loop
We have to belive this is optimal unless there will be too many shifts (which case you have to rearrange the layout)
After that I used a 4x9x3 loop to set the starting values for newline, number, the two lowercase letter and the comma. (all the smaller ascii codes got 4x9=36 and the two lowercase letter got 4x9x3=108, then I added and substracted some to get their real value)
When the preset is done, the code enters the outmost loop that cycles 3 times. I explain it by pseudocode.
for 3 to 1 where i = numbers
    print '++i, '
    while inner_loop != 0              # this is true after the first loop
        while second_inner_loop != 0   # and this is true after the second
            print '10, 11 o'clock, 12' # prints the difference
            condition = 0              # it prevents the printing below
        second_inner_loop += 1
    inner_loop += 1
    while condition != 0
        print '++i, ++i o'clock, ++i'
    print ' o'clock rock,\n'

When this section is done I just have to print the last line.
But we have an uppercase W that must be produced without using too many characters.
At this point we are here:
Address  Value  Pointer
     -4      0  <--
     -3     10
     -2     32
     -1     50
      1     99
      2    111
      3     44

so I put [-3] 4 times to [-1] and substract 3 to get 87 (W): >[>>++++<<-]>>---.
then erase it [-]
and move [-2] to this location [-1] so space will be close to the lowercase letters. <[>+<-]
After that it just prints the letters. lowercase #1 is for the lower part 97-107
and lowercase #2 is for the above region.

+1 for being 300 characters shorter than the other BF answers

i was thinking about going even lower. conditions are awful to create without a decent tutorial (esolangs is down) but it can be shorter by ~200 chars more

JavaScript, 111 107 chars, without using any number.
Execute these snippets in your browser's JS console:
107 (inspired by http://xem.github.io/obfuscatweet/ plus the other JS answer):
eval(unescape(escape('').replace(/uD./g,'')))

111 (just packing all the string and removing the eval around):
unescape(escape('').replace(/uD./g,''))

anyone else see a turtle in there...? wtf

hehe, yeah, the "random" Unicode characters generated by obfuscatweet sometimes  lead to emoji :)

PHP - 125 129
Version 1 (129)
$i;while($i<11)echo++$i.", ".++$i.", ".++$i." o'clock, ".++$i." o'clock rock,\n";echo"We're gonna rock around the clock tonight";

Version 2 (125)
while($i++<11)echo"$i, ".++$i.", ".++$i." o'clock, ".++$i." o'clock rock,\n";echo"We're gonna rock around the clock tonight";

Clean version:
while($i++<11)
    echo "$i, ".++$i.", ".++$i." o'clock, ".++$i." o'clock rock,\n";
echo "We're gonna rock around the clock tonight";

C - 145 - try me
main(i){i<11?main(i-~1+1,printf("%d, %d, %d o'clock, %d o'clock rock,\n"
,i++,i,i-~1,i-~1+1)):puts("We're gonna rock around the clock tonight.");}

C - 172 - try me
#define l ,__LINE__+~1
#define f ;printf("%d, %d, %d o'clock, %d o'clock rock,\n"
main(){f l
l
l
l)f
l
l
l
l)f
l
l
l
l);puts("We're gonna rock around the clock tonight.");}

I'm not much of a C programmer, so forgive me if I am being naive, but don't you need #include <stdio.h> to use printf?

default libraries are linked to the source in vc++ and gcc
(so if you don't need something special, you can freely start a golfing challenge by typing main(){...

Ah, I see. That's strange that it spits out a warning if it's accepted by default (just checked with my gcc & icc, no vc++ to test).

it also spits sequence point warning so...-w :)

@Kyle include files defines how external functions work (return type and parameters). Nothing to do with linking libraries. A standard C compiler will passs whatever parameters you like to any function (with warnings) and return values are often ignored, so it works anyway.

@KyleKanos FYI http://codegolf.stackexchange.com/a/2204/11259

I love the way you didn't need any #define macros to make this work.

Doesn't the first one rely on function argument evaluation order and could in fact output totally different numbers? (ETA: Just tested and I get »1, 1, 3 o'clock, 4 o'clock rock,« – and that was even without optimisations)

@bebe What version of VC++ does that?

albeit i'm aware of the argument evaluation order, i checked it in the 2010 version and it worked fine.

Why the recursion and so much of obfuscation without code size reduction? condition+call to main is longer than a simple for loop...

Perl, 114 111 110 108
$s=", X o'clock";$_="X, X$s$s rock,
"x(1+1+1)."We're gonna rock around the clock tonight.";s/X/++$i/eg;print

110:
$s=", X o'clock";print(("X, X$s$s rock,
"x(1+1+1)."We're gonna rock around the clock tonight.")=~s/X/++$i/egr)

111:
print(("X, X, X o'clock, X o'clock rock,
"x(1+1+1)."We're gonna rock around the clock tonight.")=~s/X/++$i/egr)

114:
($s="X, X, X o'clock, X o'clock rock,
"x(1+1+1)."We're gonna rock around the clock tonight.")=~s/X/++$i/ge;print$s

C++ 261 203
#include<iostream>
#define x i++;
#define y std::cout<<
#define z y x y
void m(){for(int i=1;i<11;){z", ";z", ";z" o'clock, ";z" o'clock rock, "<<"\n";}y"We're gonna rock around the clock tonight.";}

Edited my first attempt; it worked when I first tested it, but that seems to be a fluke; post-increment in a stream is "undefined behaviour", and it did weird things (including blue screening Windows 7!) when I tried re-running it. I think that using printf instead of std::cout could be used with post-increment to get a shorter program.
Edited again, got it down to 231 by re-implementing the loop.
Edited yet again, now down to 203...those #defines weren't all useful in the looping version.
For those wondering how C++ can run a function "m", the entry point can be defined as any function with just a compiler option, as can setting all funcs to be stdcall; I used both switches when compiling the above. If you don't like the redefined entry point, add 3 to my character count.

Which compiler are you using? gcc (4.7.1) doesn't allow me to call the main function m(). You can however drop the void and save 5 characters (or 2 if you name the method main)

how on earth did it get any upvotes? firstly you wrote a function called 'm' that will not compile by default, secondly every compiler shows the hours in reverse order. this needs a BIG correction

@HackerCow I can't seem to make VS2013 work without the void return type defined; is there a compiler switch that would allow that?

@bebe I explain the m() entry point in my edit; as for the output hours being printed in reverse order, I never managed to duplicate that, but I did manage to get it to print correctly (the first time I tried it), then on retesting all 1's, 5's and 12's, then on another retest it crashed the OS. So, technically it ran once, but relying on undefined behaviour is probably a 'bad idea', so I rewrote it :)

@Darren you shouldn't use entry point modification as it is quite a loophole like macro abusing.

@bebe I'm cool either way; in no way am I going to "win" any code golf puzzle with C++, so adding 3 characters is no biggie. I agree that -D switch macro definitions would be cheating, but pretty much any other compiler flags seem legit to me, as they also seemed legit to folks in the thread you linked. Any advantage you squeeze out of simple compiler switches won't exactly even the playing field between C++ and Python/Bash/Perl etc.

@bebe Don't complain about entry point modification when your submission relies on non-standard compiler features.

Swift - 136  134
var x=1
for;x<11;{print("\(x++), \(x++), \(x++) o'clock, \(x++) o'clock rock,\n")}
print("We're gonna rock around the clock tonight.")

Befunge-98 (402 268)
Now a unefunge!
".thginot kcolc eht dnuora kcor annog er'eW"a11+/a*1-> #;:,1+" ,",,:,1+" ,",,:,1+" ,kcolc'o "a1-k,:,1+a",kcor kcolc'o "ek,:a11+/a*b1111+++-+-#;_:,a-1+" ,",,:a111++-:*,,1+" ,",,:a111++-:*,,1+" ,kcolc'o "a1-k,:a111++-:*,,1+a",kcor kcolc'o "ek,:a11+/a*b1111+++-+$$$aa*k,@

Random bits of backward text, ,,:,1+, a11+/a*b1111+++-+w:,, stray characters underneath the main line of code... typical Befunge. Most of the online interpreters are having problems with the line length (it's way over the limit), do you know of one that doesn't mind?

I couldn't find any Befunge-98 compilers online, but you could use pyfunge which is available in PyPI.

Java, 228
A hardcoded solution would have probably been shorter.
public static void main(String[] a){
        String s = "";
        int i=1,j=1;
        for(i--,j--;i<=11;){
            s += ++i + (j > 1 ? " o'clock rock, ":", ");
            if(j == "one".length()){
                j -= j;
                s +="\n";
            }else
                j++;
        }
        System.out.println(s+"We're gonna rock around the clock tonight");
}

+1 for the realization that hard-coding would be shorter.

1+1+1 is 9 characters shorter than "two".length()". And is String[] a necessary?

That kinda felt like cheating, and yes, String[] a is necessary.

It's not cheating, several people have used it :D

Groovy - 140 139 chars
Golfed, influenced by William Barbosa's answer:
s="ock"
i=1
f={->println "${i++}, ${i++}, ${i++} o'cl$s, ${i++} o'cl$s r$s,"}
f();f();f()
println "We're gonna r$s around the cl$s tonight"

Ungolfed:
s = "ock"
i = 1
f = { ->
    println "${i++}, ${i++}, ${i++} o'cl$s, ${i++} o'cl$s r$s,"}
}

f();f();f()

println "We're gonna r$s around the clock tonight"

Mathematica - 153
i=1;
StringReplace[
  StringJoin[
    Riffle[{s="X, X, X o'clock, X o'clock rock,",s,s},"\n"]]<>
    "\nWe're gonna rock around the clock tonight.","X":>ToString[i++]]

+1, I think this is the best strategy but it can be shorter.

C++ 252
#define P(x) cout<<x
#define Q cout<<", "
#define N cout<<endl
#define C P(" o'clock")
#define R P(" rock")
#define F P(++i);Q;P(++i);Q;P(++i);C;Q;P(++i);C;R;N;
int i;
main()
{
    F F F
    P("We're gonna rock around the clock tonight.");
}

Unless my math sucks, using P(", ") in place of Q saves you 2 characters.

N and R only appear once: it would be better to inline them than to make a macro.

Using the above comments and more this can be condensed to 200 (even with the include and namespaces my compiler wants): #include<iostream> #define P std::cout<<++i<< #define C" o'clock" #define F P", ";P", ";P C<<", ";P C<<" rock"<<std::endl; int i;main(){F F F std::cout<<"We're gonna rock around the clock tonight.";}

PowerShell, 123 118 109
1,1,1|%{"$('',''," o'clock"," o'clock rock"|%{"$((++$a))$_,"})"}
"We're gonna rock around the clock tonight."

After a horrible start (167) I got rid of a few idioms I didn't even need and at least got it shorter than the reference.

Java (v2) - 250 241 232 chars
This is a complete running program, influenced by William Barbosa's answer.
Golfed:
public class R{
static int o=1;
static String c(){return o+++", "+o+++", "+o+++" o'clock, "+o+++" o'clock rock,\n";}
public static void main (String[] a){System.out.println(c()+c()+c()+"We're gonna rock around the clock tonight");}}

Ungolfed:
public class R {
    static int o = 1;
    static String c() {
        return o+++", "+o+++", "+o+++" o'clock, "+o+++" o'clock rock,\n";
    }

    public static void main (String[] a) {
        System.out.println(c()+c()+c()+"We're gonna rock around the clock tonight");
    }
}

Cobra - 193
class P
    var i=1-1
    def main
        print[.f,.f,.f,"We're gonna rock around the clock tonight."].join("")
    def f as String
        return"[[.i+=1,.i+=1,.i+=1].join(", ")] o'clock, [.i+=1] o'clock rock,\n"

ECMAScript6 - 136 135
Doesn't even use the allowed 1 digit:
alert([,...a=[s=", ",s,(c=" o'clock")+s,c+" rock,\n"],...a,...a].map((x,i)=>i+x).join("")+"We're gonna rock around the clock tonight.")

Tested in Firefox console.

or 114 chars using http://xem.github.io/obfuscatweet/ ;)

@xem, I know it fits in with the letter of the law, but I'm not a fan of Unicode compression (or any other compilers/generators). In my mind, golf is a test of skill and all code should be hand crafted... but that's just me.

Golflua -125
Basically a direct translation of my Lua solution:
k=1+1o=" o'clock"c=", "~@i=1,11,k+k I.w(i,c,i+1,c,i+k,o,c,i+k+1,o," rock,\n")$w("We're gonna rock around the clock tonight.")

JavaScript, 140
a=", x o'clock",b="x, x"+a+a+" rock,\n",b+=b+=b+"We're gonna rock around the clock
tonight.";for(i=1;i<=11+1;)b=b.replace("x",i++);alert(b)

I make a string like "x, x, x o'clock x o'clock rock,\n..." Then I replace the "x's" with numbers.

Haskell -- 138 137 chars
As a standalone program:
r n=show n++s!!n
s=" o'clock rock,\n":c:c:" o'clock, ":s
c=", "
main=putStr$(r=<<)[1..11+1]++"We're gonna rock around the clock tonight."

Edit: I used to have a helper function o used to define s by
s=o" rock,\n":c:c:o c:s;o=(" o'clock"++)

but it turns out to cost 1 extra character.  Is there any way to compress all of the "o'clock"s / "rock"s / "ock"s?

PHP 258 220 only with Manatwork's help
EDIT: Thank you manatwork, again you did stuff there I didn't know you could do. Thanks!
<?php $a='clock';$b=" o'";$c="$b$a rock,";$d=1+1;$e=$d+$d;$f=", ";$g=$e+$e;echo"1$f$d$f",$d+1,"$b$a$f$e$c
",$e+1,$f,$e+$d,$f,$g-1,"$b$a$f$g$c
",$g+1,$f,$g+$d,$f,"11$b$a$f","1$d$c
We're gonna rock around the clock tonight.";

I must admit I thought this was going to be quite a dull question but it turned out to be quite fun. I thought I might have a chance with this one in php. Sadly not to be :-(
Edit: Actually it might not be PHP at fault, just that I need to learn more and do a bit practice at code golf - it is actually my own fault :-)
I enjoyed trying anyway.
Original 258 chars:
<?php $a='clock';$b=" o'";$c=$b.$a." rock,";$d=1+1;$e=$d+$d;$f=", ";$g=$e+$e;echo"1".$f.$d.$f.($d+1).$b.$a.$f.$e.$c."
".($e+1).$f.($e+$d).$f.($g-1).$b.$a.$f.($g).$c."
".($g+1).$f.($g+$d).$f."11".$b.$a.$f."1".$d.$c."
We're gonna rock around the clock tonight.";?>

How you got 258? The entire text is 262, the bare minimal is 257 (no closing PHP tag and short opening PHP tag), just the code part is 254.

Just a quick review. Changed some concatenations to string interpolations and others to separate parameters to reduce to 223 characters: http://pastebin.com/k0sxN8nw

PHP isn't that bad ;) I got 129, trick is to really see what you want to use variables for

That is amazing. I love the use of WHILE for the first few lines. I didn't think of that. I also did not know you could miss out the braces in the case of a single statement and the php tags when quoting the program. Just checked on php.net and it is absolutely correct. I really must go and lookup some of the functions that I take for granted and see what else they can do. First it was FOR loops, now WHILE loops. I am going now to read about IF and see what I missed. Thanks for the great example. I shall do better next time.

@manatwork - thank you for that reworking, it was very interesting to see how you did that. As for the original count my openoffice text document says it is 258 characters.

PowerShell, 156 140 136 129 127
for($i=1;$i-lt11){$i++,$i++,"$(($i++)) o'clock","$(($i++)) o'clock rock,"-join', '}"We're gonna rock around the clock tonight."

Ungolfed:
for($i = 1; $i -lt 11){
    $i++, $i++ , "$(($i++)) o'clock", "$(($i++)) o'clock rock," -join ', '
}
"We're gonna rock around the clock tonight."

You can get it down to 127 by using $i++,$i++,"$(($i++)) o'clock","$(($i++)) o'clock rock,"-join', ' within the loop.

@Јοеу Indeed, thanks for the advice!

PHP 150
No numbers, including the 11 which would not be two 1's stuck together, but the number value eleven.
function f(){static $i;echo++$i.", ".++$i.", ".++$i." o'clock, ".++$i." o'clock rock,\n";}f();f();f();echo"We're gonna rock around the clock tonight";

It's missing the trailing full-stop.

AWK, 164 139
Boring, but my first AWK golf attempt.
BEGIN{OFS=", "
k=" o'clock "
r="rock"
print ++t,++t,++t k,++t k r,"\n"++t,++t,++t k,++t k r,"\n"++t,++t,++t k,++t k r",\nWe're gonna "r" around the clock tonight."}

OFS comes in handy here.
Shorter version:
func p(){print ++t,++t,++t k,++t k r OFS}BEGIN{OFS=", "
k=" o'clock"
r=" rock"
p()
p()
p()
print"We're gonna"r" around the clock tonight."}

Haskell -- 155/141 147/133 chars
147 characters as a program:
main=putStrLn.(++"We're gonna rock around the clock tonight.").concat.zipWith((++).show)[1..11+1].cycle$[", ",", "," o'clock, "," o'clock rock,\n"]

133 characters as String expression:
(++"We're gonna rock around the clock tonight.").concat.zipWith((++).show)[1..11+1].cycle$[", ",", "," o'clock, "," o'clock rock,\n"]

MATLAB, 199 192 182
f=1+1+1+1;a=[1,1+1,f-1,f];b=' o''clock';c=' rock';
for i=1:f-1;fprintf('%g, %g, %g,%s, %g%s%s,\n',a(1:f-1),b,a(f),b,c);a=a+f;end
fprintf('We''re gonna%s around the clock tonight.',c)

Counting characters here (and using just a single space/tab for indentation) yields 198 characters, actually. Also I wonder whethe indentation is even necessary at all because the loop is bounded by for and end, which would save two characters. Then there is an unnecessary space between the comma and the \n in the string.

Another thing I wondered: Are semicolons needed after a line? If not, then you can save two of them as well (line 1 and 4).

Good observations, thanks!
They aren't, but omitting a semicolon will print out the variables, which I think is not desired.

You could use c=' rock', i.e. with a leading space to use a format string in the last string as well, saving another character. You can then do the same trick with b as well, saving two more characters in total.

Scala, 156
for(i<-1 to 11 by 1+1+1+1){println(i+", "+(i+1)+", "+(i+1+1)+" o'clock, "+(i+1+1+1)+" o'clock rock,")};println("We're gonna rock around the clock tonight.")

ECMAScript: 127 characters
i=1;alert("%, %, % o'clock, % o'clock rock,\n".repeat(1+1+1).replace(/%/g,x=>i++)+"We're gonna rock around the clock tonight.")

Just to promote some ECMAScript 6 features.

Python 3, 100 99 Unicode
Using Unicode:
t=1+1;eval('瀠楲瑮㌨⠪┢Ⱪ┠≩㈫∪椥漠挧潬正⬢•潲正尬≮┩畴汰⡥慲杮⡥ⰱ㌱⤩∫敗爧潧湮潲正愠潲湵桴汣捯潴楮桧⹴⤢'.encode('utf%i'%(t*t<<t))[t:])

Encodes that string as UTF-16, dropping the first 2 bytes, resulting in:
 print(3*("%i, %i"+2*", %i o'clock"+" rock,\n")%tuple(range(1,13))+"We're gonna rock around the clock tonight.")

Note the initial space to make an even number of ASCII characters.
Checked if there were any illegal digits in there, such as from other languages, looks like I'm safe:
>>> set(c for c in """<code>""" if unicodedata.category(c)[0] == 'N')
{'1'}

Clojure - 261 244 178 176 chars
I'm a newbie to Clojure... suggestions welcome.
Golfed:
(let[i(atom(dec 1))](defn f[](swap! i inc))(defn p[](printf "%d, %d, %d o'clock, %d o'clock rock,\n"(f)(f)(f)(f)))(p)(p)(p)(print"We're gonna rock around the clock tonight."))

Ungolfed:
(let [i (atom (dec 1))]
  (defn f [] (swap! i inc) )
  (defn p [] (printf "%d, %d, %d o'clock, %d o'clock rock,\n" (f)(f)(f)(f)) )
  (p)(p)(p)
  (print "We're gonna rock around the clock tonight.")
)

Delphi, 186
Ungolfed:
var c:int32;

function i:int32;
begin
  c:=c+1;
  i:=c;
end;

begin
  while c<11 do
    writeln(i,', ',i,', ',i,' o''clock, ',i,' o''clock rock,');
  write('We''re gonna rock around the clock tonight.');
end.

Golfed:
var c:int32;function i:int32;begin c:=c+1;i:=c;end;begin while c<11do writeln(i,', ',i,', ',i,' o''clock, ',i,' o''clock rock,');write('We''re gonna rock around the clock tonight.')end.

Rebmu, 117 chars
O{ o'}C{clock}R{rock}S{, }T1 Ndz[igTad11 1[p[{We're going to}r{around the}c{tonight.}]qt]++T]fv[pCB[nSnSnOcSnOcSPrS]]

Un-"mushed":
o: " o'" c: "clock" r: "rock" s: ", " t: 1 n: dz [ig t ad 11 1 [p ["We're going to" r "around the" c "tonight."] qt] ++ t] fv [p cb [n s n s n o c s n o c sp r s]]

Commented:
; Define some string constants
o: { o'}
c: {clock}
r: {rock}
s: {, }

t: 1 ; assign one to T

; define a function with no arguments N (N does "DZ" the following)
n: dz [
    ; if T is greater than adding 11 to 1 (IG = If Greater, AD = Add),
    ; print the final message and then quit
    ig t ad 11 1 [
        p [{We're going to} r {around the} c {tonight.}] qt
    ]

    ; increment t but return its old value
    ++ t
]

; loop forever (will be exited by a quit during an invocation of N
; once it gets bigger than 12)
fv [
    ; print the result of combining (CB = Combine) the progressively
    ; increased values with the defined strings (also, SP = space)
    p cb [n s n s n o c s n o c sp r s]
]

COMBINE is being incubated in Rebmu, but hopefully on the roadmap for main Rebol/Red, see this article.

Scala, 142
Based on Leonardo Scattola's answer.
for(i<-1 to(11,1+1+1+1))println(f"$i, ${i+1}, ${i+1+1} o'clock, ${i+1+1+1} o'clock rock,");print("We're gonna rock around the clock tonight.")

><> (Fish), 133
(Uses only printable ascii.)
".thginot kcolc eht dnuora kcor annog er'eW"11.
v da-
>:?!\1-&a",kcor kcolc'o y ,kcolc'o y ,y ,y"&
/&+1/
>l?!v:bb*-?!\o
\  &;!+1n:&~/

Method:

Push the last line once and the first one 3 times onto the stack with the numbers changed to the letter "y".
Print everything from the stack if that's not an "y" while printing the value of an increasing counter if the character is an "y".

2 bytes saved thanks to @Sp3000.

I don't know if b is allowed, but if it is then you might as well do da- instead of 11+1+

@Sp3000 I think it's allowed. Edited.

JavaScript - 138
with(console){for(b=1;11>b;)log("%d, %d, %d o'clock, %d o'clock rock,",b++,b++,b++,b++);log("We're gonna rock around the clock tonight.")}

Try it in the console (uses console.log).
Inspired by izlin's answer, I just shortened it using console.log instead of alert.

Why those a.calls? l=console.log;for(b=1-1;11>b;)l("%d, %d, %d o'clock, %d o'clock rock,",++b,++b,++b,++b);l("We're gonna rock around the clock tonight.")

@manatwork Illegal invocation error, console.log needs to run in the context of console

Interesting. It works for me in Firefox 30.0, Firebug 2.0.2 console.

Why not use alert instead?

@Jamie because alert takes more space because you can't use "%d".

Nice.  But I am counting 154 characters. a=(c=console).log;for(b=1-1;11>b;)a.call(c,"%d, %d, %d o'clock, %d o'clock rock,",++b,++b,++b,++b);a.call(c,"We're gonna rock around the clock tonight.");  Maybe I'm doing it wrong.

Java - 219 215 212 208
I know there's some other Java answers, but this should be the shortest...
class A{public static void main(String[]z){String o="",c=" o' clock",r=c+" rock,\n",p=", ";for(int i=1;i<=11;)o+=i+++p+i+++p+i+++c+p+i+++r;System.out.println(o+"We're gonna rock around the clock tonight.");}}

Contains a 0 which isn't allowed. It's missing the comma after the first three lines. Also you can save a space in the arguments of main. And another one after the for. And yet another one after class A. Using System.out.print would save another two bytes. Did you golf this?

Not very well clearly :/ Fixed. Though removing the ln seems like cheating.

The reference text is 144 characters. This does not include a trailing newline. So just using print is actually okay, I guess.

Python - 195 chars
b=", ";x=" o'clock";y=' rock,\n';c=1;s="";n=1+1+1
for i in range(n):
 for j in range(n):s+=str(c)+b;c+=1
 s=s[:-1-1]+x+b+str(c)+x+y;c+=1
print s+"We're gonna rock around the clock tonight."

Javascript, 179 174
This is not gonna be the shortest one, but just for fun!
Golfed:
a="";for(i=1;i<=11+1;i++){a+=i.toString()+(!((i+1)%4)?" o'clock":"")+(!(i%4)?" o'clock rock":"")+", "+(!(i%4)?"\n":"");}alert(a+"We're gonna rock around the clock tonight.");

Ungolfed:
a="";
for(i=1;i<=11+1;i++){
    a+=i.toString()
        +(!((i+1)%4)?" o'clock":"")
        +(!(i%4)?" o'clock rock":"")
        +", "
        +(!(i%4)?"\n":"");
}
alert(a+"We're gonna rock around the clock tonight.");
a="";

F# - 173 136
Version 2 - 136
for x in[1..4..12]do printfn"%d, %d, %d o'clock, %d o'clock rock"x (x+1)(x+2)(x+3)
printfn"We're gonna rock around the clock tonight."

Version 1 - 173
System.Console.WriteLine("1, 2, 3 o'{0}, 4 o'{0} {1},\n5, 6, 7 o'{0}, 8 o'{0} {1},\n9, 10, 11 o'{0}, 12 o'{0} {1},\nWe're gonna {1} around the {0} tonight.","clock","rock")

Julia - 134
r="rock"
for i=1:4:12
    println("$i, $(i+1), $(i+2) $r $(i+3) o'clock $r")
end
println("We're gonna rock around the clock tonight.")

The rules say 'you must not use any digits in your code, except for the digit 1.'

Octave, 125 characters
d="%d, %d, %d o'clock, %d o'clock rock,\n";
printf([d d d "We're gonna rock around the clock tonight.\n"],v=1:(a=1+1)*a++*a);

I construct [1 .. 12] vector using only ones and assignment operator, and pass it as variable argument list to printf, taking advantage of fact that printf (fmt, a, a, a) and printf(fmt, [a a a]) are both correct ways of supplying variable argument list to function.

authors: Дмитрий Абросимов

authors: Дмитрий Фесенко


text:
Shortest test for primality for byte
Write a function which gets as input a number (0 <= n <= 255) stored in 32-bit variable  and returns non-zero integer if n is prime number and 0 otherwise.
Considern = 0 and n = 1 as non-primes.
Arrays and pointers are not allowed.
Score:
1 - for | & ^ ~ >> << operators
1.1 - for + - < > <= >= == != ! && || operators and branches & loops
1.2 - for * operator
2 - for / % operators
10 - for casting to/using other types (other than 32-bit integer)
Score for operators inside loops is score * max iterations count.
Answer with lowest score wins. If many answers with identical score, wins first one.

You might want to explicitly state in the rules that this is a C-specific challenge (even though people tend to dislike language specific challenges). Also: wouldn't this be [atomic-code-golf] instead of [code-challenge]?

this is tagged as c, so please write in the question that it should be answered in c. or remove the tag. whatever you choose

I do like the rule that casts also cost points: this prevents "look-up tables in disguise" like my answer, which opens up competition.

I think questions like this would produced more satisfying answers if literals were restricted to numbers 0 through 9, disallowing multicharacter literals. Otherwise, you're still going to get massive lookup tables pushing the boundary of the integer size.

Adding a new scoring system to a question which already has a ton of variants doesn't really add any value to the site.

@PeterTaylor I wanted this not to be algorithmical problem, but low-level optimisation.

If that is the case, someone would need to compress all those prime number information into a handful of 32 bit constants soon. Hopefully it is still within the bounds of information theory.

@bitpwner It can be done in 4.

@ɐɔıʇǝɥʇuʎs Let do it in a clever way!)

Why the language restriction?

@KyleKanos To prevent using language-specific tricks. And I like C)

@user2992539: Isn't half the point of this site to see what kind of language-specific tricks one can do?

@KyleKanos Maybe...

I'm thinking to delete my question, it's a lot more unsuccessful than I thought it will be.

I like the question, but making it language-specific ruins it - please reconsider.

Python (4)
f = lambda n: (3622934801701902697686555901643181168549895964810913375391936802953324275884 >> n) & 1

Damn casting. No trickery here, just magic. Number generated with J: #.x:1 p: i._256. Output:
for i in enumerate(map(f,range(256))):
    ...:     print i
    ...:
(0, 0L)
(1, 0L)
(2, 1L)
(3, 1L)
(4, 0L)
(5, 1L)
(6, 0L)
(7, 1L)
(8, 0L)
(9, 0L)
(10, 0L)
(11, 1L)
(12, 0L)
(13, 1L)
(14, 0L)
(15, 0L)
(16, 0L)
(17, 1L)
(18, 0L)
(19, 1L)
(20, 0L)
(21, 0L)
(22, 0L)
(23, 1L)
(24, 0L)
(25, 0L)
(26, 0L)
(27, 0L)
(28, 0L)
(29, 1L)
(30, 0L)
(31, 1L)
(32, 0L)
(33, 0L)
(34, 0L)
(35, 0L)
(36, 0L)
(37, 1L)
(38, 0L)
(39, 0L)
(40, 0L)
(41, 1L)
(42, 0L)
(43, 1L)
(44, 0L)
(45, 0L)
(46, 0L)
(47, 1L)
(48, 0L)
(49, 0L)
(50, 0L)
(51, 0L)
(52, 0L)
(53, 1L)
(54, 0L)
(55, 0L)
(56, 0L)
(57, 0L)
(58, 0L)
(59, 1L)
(60, 0L)
(61, 1L)
(62, 0L)
(63, 0L)
(64, 0L)
(65, 0L)
(66, 0L)
(67, 1L)
(68, 0L)
(69, 0L)
(70, 0L)
(71, 1L)
(72, 0L)
(73, 1L)
(74, 0L)
(75, 0L)
(76, 0L)
(77, 0L)
(78, 0L)
(79, 1L)
(80, 0L)
(81, 0L)
(82, 0L)
(83, 1L)
(84, 0L)
(85, 0L)
(86, 0L)
(87, 0L)
(88, 0L)
(89, 1L)
(90, 0L)
(91, 0L)
(92, 0L)
(93, 0L)
(94, 0L)
(95, 0L)
(96, 0L)
(97, 1L)
(98, 0L)
(99, 0L)
(100, 0L)
(101, 1L)
(102, 0L)
(103, 1L)
(104, 0L)
(105, 0L)
(106, 0L)
(107, 1L)
(108, 0L)
(109, 1L)
(110, 0L)
(111, 0L)
(112, 0L)
(113, 1L)
(114, 0L)
(115, 0L)
(116, 0L)
(117, 0L)
(118, 0L)
(119, 0L)
(120, 0L)
(121, 0L)
(122, 0L)
(123, 0L)
(124, 0L)
(125, 0L)
(126, 0L)
(127, 1L)
(128, 0L)
(129, 0L)
(130, 0L)
(131, 1L)
(132, 0L)
(133, 0L)
(134, 0L)
(135, 0L)
(136, 0L)
(137, 1L)
(138, 0L)
(139, 1L)
(140, 0L)
(141, 0L)
(142, 0L)
(143, 0L)
(144, 0L)
(145, 0L)
(146, 0L)
(147, 0L)
(148, 0L)
(149, 1L)
(150, 0L)
(151, 1L)
(152, 0L)
(153, 0L)
(154, 0L)
(155, 0L)
(156, 0L)
(157, 1L)
(158, 0L)
(159, 0L)
(160, 0L)
(161, 0L)
(162, 0L)
(163, 1L)
(164, 0L)
(165, 0L)
(166, 0L)
(167, 1L)
(168, 0L)
(169, 0L)
(170, 0L)
(171, 0L)
(172, 0L)
(173, 1L)
(174, 0L)
(175, 0L)
(176, 0L)
(177, 0L)
(178, 0L)
(179, 1L)
(180, 0L)
(181, 1L)
(182, 0L)
(183, 0L)
(184, 0L)
(185, 0L)
(186, 0L)
(187, 0L)
(188, 0L)
(189, 0L)
(190, 0L)
(191, 1L)
(192, 0L)
(193, 1L)
(194, 0L)
(195, 0L)
(196, 0L)
(197, 1L)
(198, 0L)
(199, 1L)
(200, 0L)
(201, 0L)
(202, 0L)
(203, 0L)
(204, 0L)
(205, 0L)
(206, 0L)
(207, 0L)
(208, 0L)
(209, 0L)
(210, 0L)
(211, 1L)
(212, 0L)
(213, 0L)
(214, 0L)
(215, 0L)
(216, 0L)
(217, 0L)
(218, 0L)
(219, 0L)
(220, 0L)
(221, 0L)
(222, 0L)
(223, 1L)
(224, 0L)
(225, 0L)
(226, 0L)
(227, 1L)
(228, 0L)
(229, 1L)
(230, 0L)
(231, 0L)
(232, 0L)
(233, 1L)
(234, 0L)
(235, 0L)
(236, 0L)
(237, 0L)
(238, 0L)
(239, 1L)
(240, 0L)
(241, 1L)
(242, 0L)
(243, 0L)
(244, 0L)
(245, 0L)
(246, 0L)
(247, 0L)
(248, 0L)
(249, 0L)
(250, 0L)
(251, 1L)
(252, 0L)
(253, 0L)
(254, 0L)
(255, 0L)

Question is tagged as C, which doesn't have built-in large integers. However nice try!

@user2992539 Then you should explicitly say that the answer has to be in C. I was about to post something almost exactly the same as this (still in Python) but ɐɔıʇǝɥʇuʎs beat me to it.

@Calvin'sHobbies ok.

I changed score for non-32-bit types from 2 to 10.

The most obvious solution scores 32.3.
Test Ideone
int p(int v) {
  return (v > 1)
  & (v == 2 || (v % 2))
  & (v == 3 || (v % 3))
  & (v == 5 || (v % 5))
  & (v == 7 || (v % 7))
  & (v == 11 || (v % 11))
  & (v == 13 || (v % 13));
}

source: Stack Exchange

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

sort: votes


text:
Who wants to be a Kolmogorov complexity winner?
You mission today is to invent a text compressor.
Task
You'll write two functions:

The packer is a function that accepts a string of ASCII characters (U+0000 to U+007F) and outputs a Unicode string (U+0000 to U+10FFFF), containing the fewest characters possible.
The unpacker is a function that accepts an encoded Unicode string and outputs exactly the original ASCII string.

Input
The only authorized input is the ASCII string (for the packer) and the packed Unicode string (for the unpacker). No user input, no internet connection, no use of file system.
Your functions can have access to this list of english words. You can use this list as a local txt file, or copy its content in your source code as a string or an array of strings.
You can't hardcode the snippets below in your functions.
Output
The only authorized output for both functions is a string.
The output of the unpacker must contain exactly the same characters as the input of the packer.
Your inputs and outputs can use any character encoding supporting all Unicode (UTF-8/16/32, GB18030, ...), as your score will only depend on the number of Unicode characters in the output. Please precise which encoding you're using, though.
To count the number of Unicode characters in your output, you can use this tool: http://mothereff.in/byte-counter
Scoring
Your entry must be able to pack and unpack the 10 following text snippets (that I took on this forum).
Your score will be the sum of the sizes of your 10 packed strings (in Unicode characters) + the size of your two functions (in Unicode characters, too)
Don't count the size of the dictionnary if you use it.
Please include in your entries the "score" of each snippet and their packed version.
Lowest score wins.
Data
Here are the snippets to encode to compute your score:
1: Rick Roll lyrics (1870b): We're no strangers to code golf, you know the rules, and so do I

We're no strangers to love
You know the rules and so do I
A full commitment's what I'm thinking of
You wouldn't get this from any other guy
I just wanna tell you how I'm feeling
Gotta make you understand

Never gonna give you up
Never gonna let you down
Never gonna run around and desert you
Never gonna make you cry
Never gonna say goodbye
Never gonna tell a lie and hurt you

We've known each other for so long
Your heart's been aching but
You're too shy to say it
Inside we both know what's been going on
We know the game and we're gonna play it
And if you ask me how I'm feeling
Don't tell me you're too blind to see

Never gonna give you up
Never gonna let you down
Never gonna run around and desert you
Never gonna make you cry
Never gonna say goodbye
Never gonna tell a lie and hurt you

Never gonna give you up
Never gonna let you down
Never gonna run around and desert you
Never gonna make you cry
Never gonna say goodbye
Never gonna tell a lie and hurt you

(Ooh, give you up)
(Ooh, give you up)
(Ooh)
Never gonna give, never gonna give
(Give you up)
(Ooh)
Never gonna give, never gonna give
(Give you up)

We've know each other for so long
Your heart's been aching but
You're too shy to say it
Inside we both know what's been going on
We know the game and we're gonna play it

I just wanna tell you how I'm feeling
Gotta make you understand

Never gonna give you up
Never gonna let you down
Never gonna run around and desert you
Never gonna make you cry
Never gonna say goodbye
Never gonna tell a lie and hurt you

Never gonna give you up
Never gonna let you down
Never gonna run around and desert you
Never gonna make you cry
Never gonna say goodbye
Never gonna tell a lie and hurt you

Never gonna give you up
Never gonna let you down
Never gonna run around and desert you
Never gonna make you cry
Never gonna say goodbye
Never gonna tell a lie and hurt you

2: The Golfer (412b): Golfing ASCII-art

      '\                   .  .                        |>18>>
        \              .         ' .                   |
       O>>         .                 'o                |
        \       .                                      |
        /\    .                                        |
       / /  .'                                         |
 jgs^^^^^^^`^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

3: the number diamond (233b): Print this diamond

        1
       121
      12321
     1234321
    123454321
   12345654321
  1234567654321
 123456787654321
12345678987654321
 123456787654321
  1234567654321
   12345654321
    123454321
     1234321
      12321
       121
        1

4: the alphabet four times (107b): Print the alphabet four times

abcdefghijklmnopqrstuvwxyz
qwertyuiopasdfghjklzxcvbnm
pyfgcrlaoeuidhtnsqjkxbmwvz
zyxwvutsrqponmlkjihgfedcba

5: Old McDonald's lyrics (203b): Old MacDonald function

Old MacDonald had a farm, E-I-E-I-O,
And on that farm he had a cow, E-I-E-I-O,
With a moo moo here and a moo moo there,
Here a moo, there a moo, everywhere a moo moo,
Old MacDonald had a farm, E-I-E-I-O!

6: Rock around the clock lyrics (144b): Rock Around the Clock

1, 2, 3 o'clock, 4 o'clock rock,
5, 6, 7 o'clock, 8 o'clock rock,
9, 10, 11 o'clock, 12 o'clock rock,
We're gonna rock around the clock tonight.

7: Hello World (296b): Say "Hello" to the world in ASCII art

 _   _      _ _                             _     _ _
| | | | ___| | | ___    __      _____  _ __| | __| | |
| |_| |/ _ \ | |/ _ \   \ \ /\ / / _ \| '__| |/ _` | |
|  _  |  __/ | | (_) |   \ V  V / (_) | |  | | (_| |_|
|_| |_|\___|_|_|\___( )   \_/\_/ \___/|_|  |_|\__,_(_)
                    |/

8: Irish blessing (210b): An Old Irish Blessing

May the road rise up to meet you
May the wind be always at your back
May the sun shine warm upon your face
The rains fall soft upon your fields
And until we meet again
May God hold you in the hollow of His hand

9: There was an old lady lyrics (1208b): There Was an Old Lady

There was an old lady who swallowed a fly.
I don't know why she swallowed that fly,
Perhaps she'll die.

There was an old lady who swallowed a spider,
That wriggled and iggled and jiggled inside her.
She swallowed the spider to catch the fly,
I don't know why she swallowed that fly,
Perhaps she'll die.

There was an old lady who swallowed a bird,
How absurd to swallow a bird.
She swallowed the bird to catch the spider,
She swallowed the spider to catch the fly,
I don't know why she swallowed that fly,
Perhaps she'll die.

There was an old lady who swallowed a cat,
Imagine that to swallow a cat.
She swallowed the cat to catch the bird,
She swallowed the bird to catch the spider,
She swallowed the spider to catch the fly,
I don't know why she swallowed that fly,
Perhaps she'll die.

There was an old lady who swallowed a dog,
What a hog to swallow a dog.
She swallowed the dog to catch the cat,
She swallowed the cat to catch the bird,
She swallowed the bird to catch the spider,
She swallowed the spider to catch the fly,
I don't know why she swallowed that fly,
Perhaps she'll die.

There was an old lady who swallowed a horse,
She died of course.

10: gettysburg address (1452b): How random is the Gettysburg Address

Four score and seven years ago our fathers brought forth on this continent a new nation, conceived in liberty, and dedicated to the proposition that all men are created equal. Now we are engaged in a great civil war, testing whether that nation, or any nation so conceived and so dedicated, can long endure. We are met on a great battlefield of that war. We have come to dedicate a portion of that field, as a final resting place for those who here gave their lives that that nation might live. It is altogether fitting and proper that we should do this. But, in a larger sense, we can not dedicate, we can not consecrate, we can not hallow this ground. The brave men, living and dead, who struggled here, have consecrated it, far above our poor power to add or detract. The world will little note, nor long remember what we say here, but it can never forget what they did here. It is for us the living, rather, to be dedicated here to the unfinished work which they who fought here have thus far so nobly advanced. It is rather for us to be here dedicated to the great task remaining before us-that from these honored dead we take increased devotion to that cause for which they gave the last full measure of devotion-that we here highly resolve that these dead shall not have died in vain-that this nation, under God, shall have a new birth of freedom-and that government of the people, by the people, for the people, shall not perish from the earth.

Total (uncompressed): 6135 chars/bytes.
Have fun!

Not immediately obvious how this is a programming language. The 'compiler' doesn't take source code. I guess rather it creates a program which is then interpreted

This isn't a challenge to invent a language, this is a challenge to compress something.

I think not including the size of the compiler/executor (compressor/decompressor) in the score makes this challenge a little open-ended. At some point, the line between dictionary and hard-coding will become very thin.

Darn, and here I was already typing
`private static final String RICK_ROLL_RETURN = "We're no strangers to love...`

To make it a real language creation challenge, maybe specify that it has to be Turing-complete and the executor can't use "eval" or similar.

Okay, I removed the mention of "language". now it's just a packer/unpacker.

Hey guys, I've made the rules clearer (I hope) by providing an authorized dictionnary of english words. People can use it in their packer/unpacker, but they can't use any other external input. Hope this helps.

I don't think you've addressed Dennis' observation.

@xem I think the post could be improved by organizing the information into sections such like #Task, #Input, #Output, #Scoring. I also think that the size of the source code for the compressor and the decompressor should be included in the score. This doesn't hurt anything, but it solves the problem Dennis pointed out.

UTF8 to UTF32 correct?

@Milo I do not think so since the score is based on the number of unicode characters of the encoded output. UTF8 to UTF32 would have no effect on the score.

@gxtaillon well it changes the characters we can use. Our input is 0-127 but our output is much larger because U+10FFFF is UTF-32 only I am pretty sure. Unless you use four UTF-8 unicode characters to make one UTF-32

@xem what order should the snippets be output? better yet, instead of listing the links to the snippets, please provide the official expected output.

Hi all, I've edited all the question, it's now a code-golf challenge. The size of your code counts in the score. I've clearly explained which input and output are expected and I've provided the dictionnary as an array of strings, if anyoune needs it.

@moogie no particular order, you should pack them separately

@Milo & gxtaillon, I've made this point clearer: use the encoding that you want.

Haskell - 5322 points
Bytes of code : 686
Original size : 6147 = 1871+415+234+108+204+145+297+211+1209+1453
Encoded size : 4636 = 1396+233+163+92+153+115+197+164+979+1144
Score : 686+ 4636
Character count compression : ~25%

Code
Optimizations aside, this stores values between 0 and 7f in unicode characters as their prime factors.
It does not lower the number of bytes of the encoded output, it only lowers the number of unicode characters. For instance, test #4 contains 108 characters and the encoded output, 92. Their respective sizes are however 108 and 364 bytes.
import Data.Bits
import Data.List
import Data.Numbers.Primes
import qualified Data.Text as T
a=nub$concat$map(primeFactors)[0..127]
d(a:r)c=let s=shift c 5in if s<=0x10ffffthen d r(s+a)else c:d r a
d[]c=[c]
f(a:r)=let o=a.&.0x1fin(if o/=a then f((shiftR a 5):r)else f r)++[o]
f[]=[]
g=T.pack.map(toEnum).(\(a:r)->d r a).concatMap j.map(map(\x->head$elemIndices x a)).map(primeFactors.fromEnum).T.unpack
h=T.pack.map(toEnum.product.map((!!)a)).i.f.reverse.map(fromEnum).T.unpack
i(a:r)=let z=a`clearBit`4;x=if a`testBit`4then(take z$repeat$head r,tail r)else splitAt z r in[fst x]++i(snd x)
i[]=[]
j x@(a:_)=let l=length x in if(take l(repeat a))==x then[l`setBit`4,a]else[l]++x
j[]=[0]

How it works

Encoding

Each character is converted to its numeric equivalent, lets call this number n.
n is then converted into a list of its prime factors, ps.

It conveniently happens that the numbers 0 through 127 have 32 common prime factors, excluding 1. This mean they, the factors, can be stored as indexes on as little as 5 bits.
1 is a special case and is represented by an empty list.

With ps the encoding can now start.

Each number of ps is converted into its index in the list of 32 unique factors (In the above code this list is identified as a).
(Keep in mind at this point we are dealing with a list of list of indexes of prime factors) To proceed to the next step, ps needs to be flattened. To preserve the integrity of the data, each list is converted into another list of two parts

The first element stores its length and if the it is composed of the same factor.

There are at most 6 prime factors per list, this information is stored on the rightmost 3 bits. The fifth bit is used as a flag to indicate if the list is comprised of a single factor.

The remaining elements are the indexes themselves or a single index if there is less than two different factors in the list.

These lists are then concatenated into a single flattened list, fs.

The elements of fs can then be packed into unicode characters using bit shifting.

Decoding

Do the encoding steps in reverse.
If you are wondering how 1 fits into this, I would like to remind you that product [] == 1.

Tests
Using this interface for testing would be painful so I used this function to provide the results below.
edTest f = do
    t <- readFile f
    let txt = T.pack t
        enc = g txt
        dec = h enc
        tst = txt == dec
    putStrLn $ (show $ T.length txt) ++ "," ++ (show $ T.length enc) ++ "," ++ (show $ T.length dec)++","++(show tst)
    putStrLn $ if not tst then T.unpack txt ++ "\n---NEXT---\n" ++ T.unpack dec else ""

λ> edTest "1"
1871,1396,1871,True

λ> edTest "2"
412,233,412,True

λ> edTest "3"
234,163,234,True

λ> edTest "4"
108,92,108,True

λ> edTest "5"
204,153,204,True

λ> edTest "6"
145,115,145,True

λ> edTest "7"
297,197,297,True

λ> edTest "8"
211,164,211,True

λ> edTest "9"
1209,979,1209,True

λ> edTest "10"
1453,1144,1453,True

Sample
The output of the encoding function g for test #4 is this
"\99429\582753\135266\70785\35953\855074\247652\1082563\68738\49724\164898\68157\99429\67973\1082404\587873\73795\298017\330818\198705\69861\1082435\595009\607426\36414\69873\855074\265249\346275\67779\68738\77985\1082513\821353\132131\101410\247652\1082562\49724\164898\67649\594977\34915\67746\50273\135265\103997\563265\103457\1086021\99399\584802\70753\73889\34882\582722\411459\67779\68740\1084516\1082563\1091681\103491\313282\49724\164897\68705\135741\69858\50241\607426\35905\608421\1082435\69858\50274\71777\43075\298018\280517\1082404\67971\36017\955425\67665\919600\100452\132129\214883\35057\856097\101474\70753\135737"

or if you are an adept of gibberish, this
豱숼踾숼衣쑡衂숼쑁豁쑢ꡃ貱裱

Additionnal notes

Using http://mothereff.in/byte-counter, directory listings and edTest the size of the tests are all consistent but still differs from the indicated size in the question.
Test #10 contains a couple of EM DASHes (—) that I replaced with - since they are outside of the 0-7f range.
Further compression could be achieved using the remaining fourth bit while flattening, for instance, 00 base case, 01 repeat all, 10 repeat except last, 11 repeat except last two.
The test files and the code are all available here https://github.com/gxtaillon/codegolf/tree/master/Kolmogorov

Hello, thanks for this answer! :) I didn't understand what happens in binary when you convert abcdefghijklm... to 豱..., could you explain it a little bit more please? Also, I've fixed the char counts and converted the the em-dashes in #10, in the question. My char counts are still different than yours, though. Dunno why, I used the mothereff.in tool.

@xem The intricate details have been revealed.

My mind is (figuratively) literally blown by the idea that the numbers 0 and 2-127 can be encoded on 5 bits. Did you find this by yourself or was it something known? Bonus question: how many bits do you need to store only the printable ascii characters, i.e. 95 different chars?

@xem The numbers are not encoded on 5 bits, each of their factors are. I would be very happy if I had found a way of encoding 7 bits on only 5. As for ascii characters, using this method they would still need 5 bits each.

ahah okay, that makes more sense. So, you use a few bits (4 or 5?) to specify how many factors you'll use, then you add the indexes of those factors, encoded on 5 bits. Right?

Since in the range you specified there are at most 6 factors per number, the length uses 3 out of a 5 bits "block". Then the indexes are encoded on 5 bits, yes. In this implementation, one of the 2 unused bits in the length block is used to get additional compression.

C++ (C++11), 2741 points
This answer uses UTF-32 as the encoding for the compressed text.
#include <cstdio>
#include <iostream>
#include <locale>
#include <string>
#define L locale
using namespace std;long b,n,i,l;void c(){string d;char x;while((x=cin.get())!=EOF)d+=x;b=(d.size()*7)%20;n=5;wcout.imbue(L());for(char y:d){b=b<<7|y&127;n+=7;if(n>=20)wcout.put(b>>(n-=20)&0xFFFFF);}if(n)wcout.put(b<<20-n&0xFFFFF);}void d(){wstring d;wchar_t w;wcin.imbue(L());while((w=wcin.get())!=EOF)d+=w;l=-1;for(wchar_t y:d){b=b<<20|y;n+=20;if(l<0)l=b>>15&31,n-=5;while(n>=7&(i<d.size()-1|n>20-l))cout.put(b>>(n-=7)&127);++i;}}int main(int t,char**a){L::global(L("en_US.utf8"));**++a<'d'?c():d();}

Char counts and scoring
Code: 593 chars (the trailing newline is stripped)
Compressed texts (unicode characters): 654 + 145 + 82 + 38 + 51 + 104 + 73 + 423 + 506 = 2148 (counted with wc -m for the number of unicode characters rather than bytes, the byte counts are, as as with @gxtaillon's answer, higher than the originals, 8413 bytes in total, as counted with wc -c).
Compression ratio (ASCII to unicode): 35.01% (using the 6135 bytes from the question (same as wc -c))
Beware:
A lot of shells cannot handle the unicode characters this program produces. Thus, decompressing may lead to the text being cut off somewhere when the shell cannot handle a character, as input is taken via stdin from the shell.
Compiling
It should compile with clang++ and g++ -std=c++11, but it will show some warnings about operator precedence, as an expression like b<<20-n&0xFFFFF will not be treated as ((b << 20) - n) & 0xFFFFF, as one might expect, but rather as (b << (20 - n)) & 0xFFFFF.
Usage

Compile the program into an executable, e.g. ./compress.
Run the program as ./compress c to compress or ./compress d to decompress. (Careful, leaving out the option gives a SEGFAULT (error checking is so character expensive...) and other options (such as using D instead of d) may give unexpected results
Input is read from stdin and output written to stdout

How it works
Ungolfed
#include <cstdio>
#include <iostream>
#include <locale>
#include <string>

using namespace std;

long b, n, i, l;

// Compress
void c() {
    string d;
    char x;
    // Read from STDIN until EOF
    while((x = cin.get()) != EOF)
        d += x;
    // Calculate the number of bits used from the last unicode character
    // (maximum 19) and store it into the first 5 bits
    b = (d.size() * 7) % 20;
    n = 5;
    // Set the output locale to allow unicode
    wcout.imbue(locale());
    // For each character in the input...
    for (char y : d) {
        // Add its bit representation (7 bits) to the right of the buffer
        // by shifting the buffer left and ORing with the character code
        b = (b << 7) | (y & 127);
        // Add 7 to the bit counter
        n += 7;
        // If enough data is present (20 bits per output character),
        // calculate the output character by shifting the buffer right,
        // so that the last 20 bits are the left 20 bits of the buffer.
        // Also decrement the bit counter by 20, as 20 bits are removed.
        if (n >= 20)
            wcout.put((b >> (n -= 20)) & 0xFFFFF);
    }
    // If there are still bits in the buffer, write them to the front of
    // another unicode character
    if (n)
        wcout.put((b << (20 - n)) & 0xFFFFF);
}

// Decompress
void d() {
    wstring d;
    wchar_t w;
    // Set STDIN to UNICODE
    wcin.imbue(locale());
    // Read wide characters from STDIN (std::wcin) until EOF
    while ((w = wcin.get()) != EOF)
        d += w;
    // `l' represents the number of bits used in the last unicode character.
    // It will be set later
    l = -1;
    // For each input character...
    for (wchar_t y : d) {
        // Add it to the buffer and add 20 to the bit counter
        b = (b << 20) | y;
        n += 20;
        // If the number of bits in the last unicode character has not been
        // set yet, read the first 5 buffer bits into `l'. This is
        // necessary because the last character may contain more than 7
        // (one entire uncompressed character) unused bits which may
        // otherwise be interpreted as garbage.
        if (l < 0) {
            l = (b >> 15) & 31;
            n -= 5;
        }
        // As long as there is data to turn into output characters
        // (at least 7 bits in the buffer and either not the last
        // unicode character or before the unused bits)
        while (n >= 7 && ((i < d.size() - 1) || (n > (20 - l)))
            cout.put((b >> (n -= 7)) & 127); // Output the left 7 bits in the buffer as an ASCII character
        ++i; // Increment the character index, so that we know when we reach the last input character
    }
}
int main(int t, char**a) {
    // Set the default locale to en_US.utf8 (with unicode)
    locale::global(locale("en_US.utf8"));
    // Decide whether to compress or decompress.
    // This is just fancy pointer stuff for a[1][0] < 'd' ? c() : d()
    (**(++a) < 'd') ? c() : d();
}

Explanation
As all unicode characters from U+0000 to U+10FFFF are allowed, we can use 20 bits per unicode char: U+FFFFF uses 20 bits and is still included in the allowed range. Thus, we just try to cram all the individual ASCII char bits into the unicode characters to store multiple ASCII characters in one unicode character. However, we also need to store the number of bits used in the last unicode character, because unused garbage bits may otherwise be interpreted as proper compressed ASCII characters. As the maximum number of used bits in the last unicode character is 20, we will need 5 bits for that, which are placed in the beginning of the compressed data.
Example output
This is the output for example #4 (as given by less):
<U+4E1C5><U+8F265><U+CD9F4><U+69D5A><U+F66DD><U+DBF87><U+1E5CF><U+A75ED>
<U+DFC79><U+F42B8><U+F7CBC><U+BA79E><U+BA77F>쏏<U+A356B><U+D9EBC><U+63ED8>
<U+B76D1><U+5C3CE><U+6CF8F><U+96CC3><U+BF2F5><U+D3934><U+74DDC><U+F8EAD>
<U+7E316><U+DEFDB><U+D0AF5><U+E7C77><U+EDD7A><U+73E5C><U+786FD><U+DB766>
<U+BD5A7><U+467CD><U+97263><U+C5840>

(쏏 give <U+C3CF><U+266CF> as character codes, but I might have gotten that wrong)

Python 3, 289+818=1107 points
Only lightly golfed.
import zlib as Z
def p(s):
 z=int.from_bytes(Z.compress(s),'big');o=''
 while z:
  z,d=divmod(z,1<<20)
  if d>0xd000:d+=1<<16
  o+=chr(d)
 return o[::-1]
def u(s):
 i=0
 for c in s:
  d=ord(c)
  if d>0xe000:d-=1<<16
  i=(i<<20)+d
 return Z.decompress(i.to_bytes(i.bit_length()//8+1,'big'))

The total code size is 289 bytes, and encodes the given 6135 bytes into 818 Unicode characters -- the total output byte count is 3201 bytes, significantly smaller than the original inputs.
Encodes using zlib, then secondarily using unicode encoding. Some extra logic was needed to avoid surrogates (which Python really hates).
Example output from #4, as seen by less (37 Unicode chars):
x<U+AC0DC><U+BB701><U+D0200><U+D00B0><U+AD2F4><U+EEFC5><U+F4F34>멍<U+3C63A><U+2F62C><U+BA5B6><U+4E70A><U+F7D88><U+FF138><U+40CAE>
<U+CB43E><U+C30F5><U+6FFEF><U+698BE><U+9D73A><U+95199><U+BD941><U+10B55E><U+88889><U+75A1F><U+4C4BB><U+5C67A><U+1089A3><U+C75A7>
<U+38AC1><U+4B6BB><U+592F0>ᚋ<U+F2C9B>

Driver program for testing:
if __name__ == '__main__':
    import os
    total = 0
    for i in range(1,10+1):
        out = p(open('data/%d.txt'%i,'rb').read())
        total += len(out)
        open('out/%d.bin'%i,'w',encoding='utf8').write(out)
    print(total)
    for i in range(1,10+1):
        out = u(open('out/%d.bin'%i,'r',encoding='utf8').read())
        open('data2/%d.txt'%i,'wb').write(out)

Output byte counts:
 607 out/1.bin
 128 out/2.bin
 101 out/3.bin
 143 out/4.bin
 177 out/5.bin
 145 out/6.bin
 186 out/7.bin
 222 out/8.bin
 389 out/9.bin
1103 out/10.bin
3201 total

Isn't the fact that this is using a compression library cheating a bit?

@BetaDecay: It doesn't restrict that in the question, so I figured it was fair game.

Also, you need to include a decompresser.

@BetaDecay: p is the packer, u is the unpacker.

Python 2 - 1141 points
from zlib import *;v=256
def e(b):
 x=0
 for c in compress(b,9):x=(x*v)+ord(c)
 b=bin(x)[2:]
 return "".join(unichr(int("1"+b[a:a+19],2))for a in range(0,len(b),19))
def d(s):
 y=int("".join(bin(ord(a))[3:]for a in s),2);x=""
 while y:y,d=(y/v,chr(y%v));x=d+x
 return decompress(x)

Code size is 281 bytes and it encodes the 6135 bytes into 860 unicode characters.
How it works:
To Encode:

Compress the string to be encoded.
Interpret the compressed string as a base 256 number.
Convert the number to binary.
Split the binary into groups of 19 bits, add a 1 bit to the beginning of each of them, and then convert to Unicode characters.

Decoding is the reverse.
Note that some versions of python can only handle unicode characters up to 0xFFFF, and thus this code will raise a ValueError.

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


text:
Output the answer above yours
Write a program that outputs the contents of the first HTML ... block of the answer to this question that is just above yours when the answers are sorted by votes. Output Top! if you are the top answer.
Ignore answers that have negative votes or no ... tags. The source of your program must appear in the first ... block in your post. These blocks are created automatically when you use backticks or
indent things with 4 spaces.

This is code-golf, the answer with the fewest characters wins.
Additional Rules (Updated)

Answer in any programming language you want but if you answer multiple times use different languages.
You may not hard code your output. Your program's ability to run correctly should not depend on it's vote count or on what the answer above is. If the vote distribution changed drastically your program should still correctly output the code of the answer above it.
You may hard code your program to search for itself on this page (so as to find the next highest) via some unique property of your answer, such as your username (if you only have one answer) or the answer's direct link.
If two answers have equal votes you should still use the one just above yours (which I believe will be the newest one).
You may have multiple ... blocks in your answer but the first one must contain your program's source.

Do I have to account for multiple pages?

Yes you should account for multiple pages

I don't understand the purpose of your first additional rule. Are you saying that only one user may submit an answer using a given programming language? That seems unnecessarily discouraging.

@GregHewgill I see what you mean. It was to encourage a variety of answers but since this is code-golf it might be unfair to restrict things in that way. I've amended it.

Note that inline code spans are just , but proper code blocks are
stuff
.

rule number 4: If two answers have equal votes the oldest one is the top answer. Doesn't make any sense. The challenge is to output the answer above you. So then you should just print the one above you right?

@TeunPronk Right. I was just mentioning that if two answers do have the same number of votes the "sort by votes" page displays the older ones before the newer ones. (At least I believe that's correct.)

@Calvin'sHobbies I think the order of tied answers (by votes) is random. At least on SO, I don't know about here.

Some code boxes can have classes in the  : ie ... which on the example I was testing on caused me some issues so I thought I would mention it here.

I would argue that caring about multiple pages is unnecessary - if you aren't on the first page, you aren't WINNING anyway :)

Javascript + jQuery (92 86 64 char)
To test, open Dev Tools on this page (usually F12), and run my code!
This Javscript needs to be run using the console from this page (and only this page).
alert($("code",$("#answer-34767").prev().prev()).html()||"Top!")

So short, it doesn't even need a scrollbar!
Basically, it finds my answer by ID, and then gets two nodes ahead (skipping the anchor link).  If that does not exist, I must be on top.  Then it digs down to the first code element and gets it's .innerHTML.
The nice thing is that SE uses jQuery by default, so I get that advantage without even trying.

I personally don't like your answer as it's a bit like cheating... Anyway, it could be as short as alert($("code",$("#answer-34767").prev().prev()).html()||"Top!").

@core1024: Thanks for the improvment!  I hadn't thought of doing it one-statement.  I agree that I do have a huge advantage.  Maybe I have to count Firefox's code for >78MB?  The rules say "Answer in any programming language you want".

You don't need to count the Firefox's code :) Your advantage is in the current environment and not in the interpreter. It's as if everybody had the source of the page already loaded in an "object"/"variable".
+1 for the exploit ;)

This is gonna alert "top" if it's top of the second page, is this the correct behavior?

@WilliamBarbosa: I'm with "lrn" on that one. (see his comment on OP's question).

The question specifies you must have a link to here in the code, so this is unvalid

@proudhaskeller : I'm not sure I see the rule that you are referring to.  If I am missing something, please let me know -- I don't want to be cheating.

You're right. I can't find this rule. Either i mixed up this question with another one which had this rule, or this rule was edited out.

@proudhaskeller : No worries.  I was aware when I posted that I was right on the line of acceptable.

Fail if the upper answer use < or >

PHP 666 611 593 588 580 Characters
Edit: Used even smaller url than previously from tinyurl.
Edit: Following comment on other answer I used int rather than boolean. Also needed to correct an error that became apparent but fixed now.
Here is my code
<?
$a=34727;$b=new DOMDocument();$b->loadHTMLFile("http://turl.no/t2u");$c=$b->saveHTML();$d=$e=1;$f='data-answerid="';$g=strpos($c,$f);$h=substr($c,0,$g);$c=substr($c,($g+15));while($d==1){$g=strpos($c,'"');$i=substr($c,0,$g);if($i==$a){$j=$h;$k=$e;}$g=strpos($c,'vote-count-post ">');$c=substr($c,($g+18));$g=strpos($c,'<');$l=substr($c,0,$g);$g=strpos($c,'data-answerid="');if($g){++$e;++$e;$h=substr($c,0,$g);$c=substr($c,($g+15));}else{$d=2;}}if($k==1){echo 'Top!';}else{$g=strpos($j,'>');$m=strpos($j,'
');$n=$m-$g-7;$o=substr($j,($g+7),$n);echo nl2br($o);}

I am sure this can be improved using DOMXPath and nodes. However am quite pleased with it. I could not decide what to do in the case of mine is the only answer but with -ve points so ignored. However another answer was posted so not a problem any more.
I also used tinyurl to shorten the url, saving lots of characters.
I hope you like it,
Paul.
PS This will not run in codepad so can't show a fiddle.
Edit: saved 5 more with the php tags being altered
You can see it working here on a domain I do not currently use (so am not just trying a sneaky link). This is not a permanent link though but is currently available.

You could shorten it even more by using an even shorter urlshortener=) for example ➡.ws/.v

I tried it with the tinyarrows.com link but the delay in connecting times out the server. They are genuinely tiny urls though.

On this site, it is acceptable to use a shortened opening tag (I believe it's <? instead of <?php) and leave off the closing tag. That should leave you a few more chars.

turl.no makes some pretty short links, and because it's a Norwegian link shortener, few people have noticed it internationally. Here's a link for you: http://turl.no/t2u points to the same page as your tinyurl.com link, and saves 8 characters.

@bilde2910 Thankyou, that worked and it is indeed another very tiny url. Much appreciated and Turl.ca is interesting. He loves his .ca domains doesn't he :-)

a lot of these answers fail if their answer drops to the second page...

Delphi (688 873 859 848 840)
I will still try to shave off some characters but it will do the job :)
Edit: instead of getting it shorter I made it longer :P
I forgot to add in the ignoring of answers when it has a negative votecount or no code blocks.
I'm just updating the un-golfed version while editing.
Thanks to @manatwork for the suggested edits that took off 8 characters.
Golfed version:
uses IdHTTP,Classes,MSHTML;const u='http://codegolf.stackexchange.com/questions/34705/output-the-answer-above-yours/34718#34718';var g:TIdHTTP;m:TMemoryStream;l:TStringList;p,t,r,o:OleVariant;s,i,j:int32;c:boolean;begin L:=TStringList.Create;g:=TIdHTTP.Create(nil);m:=TMemoryStream.Create;g.Get(u,m);m.Position:=0;L.LoadFromStream(m);p:=coHTMLDocument.Create as IHTMLDocument2;p.write(l.Text);for I:=0to p.body.all.length-1do begin c:=0>1;t:=p.body.all.item(i);if(t.classname='answer')and(t.id='answer-34718')then if s=0 then writeln('Top!') else for j:=0to o.all.length-1do begin t:=o.all.item(j);if t.tagname='CODE'then writeln(t.innertext);end else if t.classname='answer'then begin for j:=0to t.all.length-1do begin r:=t.all.item(j);if r.tagname='CODE'then c:=1>0 else if c and(r.class='vote-count-post')and(r.innertext[1]<>'-')then begin o:=t;s:=1;end;end;end;end;end.

Ungolfed version:
uses
  IdHTTP,Classes,MSHTML;
const
  u='http://codegolf.stackexchange.com/questions/34705/output-the-answer-above-yours/34718';
  a='answer';b='CODE';
var
  g:TIdHTTP;
  m:TMemoryStream;
  l:TStrings;
  p,t,r,o,z:OleVariant;
  s,i,j:int32;
  c:byte;
begin
  L:=TStringList.Create;
  g:=TIdHTTP.Create(nil);
  m:=TMemoryStream.Create;
  g.Get(u,m);
  m.Position:=0;
  L.LoadFromStream(m);
  p:=coHTMLDocument.Create as IHTMLDocument2;
  p.write(l.Text);
  z:=p.body.all;
  for I:=0to z.length-1do
  begin
    c:=0;
    t:=z.item(i);
    if(t.classname=a)and(t.id='answer-34718')then
      if s=0 then
        write('Top!')
      else
        for j:=0to o.all.length-1do
        begin
          t:=o.all.item(j);
          if t.tagname=b then
            write(t.innertext)
        end
    else if t.classname=a then
      for j:=0to t.all.length-1do
      begin
        r:=t.all.item(j);
        if r.tagname=b then
          c:=1
        else if(c=1)and(r.class='vote-count-post')and(r.innertext[1]<>'-')then
        begin
          o:=t;
          s:=1;
        end;
      end;
  end;
end.

http://codegolf.stackexchange.com/questions/34705/output-the-answer-above-yours/34718#34718 can be changed to http://codegolf.stackexchange.com/q/34718, which would save quite a bit of characters.

Thanks, sadly I also had to add some since I forgot the part where you have to ignore answers with a negative votecount or no code blocks :/.. doesnt work :( I get a 301 permanently moved

As suggested before, you can declare l as TStrings instead. (But keep the instantiation with TStringList.)

I would try to make c byte instead of boolean.

Dart 412 403
import"dart:io";import"dart:convert";main(){new HttpClient().get("pi.vu",0,"BYga").then((v)=>v.close()).then((r)=>r.transform(UTF8.decoder).join()).then((s,[i,c="Top!"])=>new RegExp(r'
(\d+)[^]*?
m[1]=="34735"?print(c):m[2][0]!='-'&&(i=(s=m[0]).indexOf(""))>0?c=s.substring(i+6,s.indexOf("",i)):0));}

Ungolfed (well, with newlines and leading whitespace)
import"dart:io";
import"dart:convert";
main(){
  new HttpClient().get("pi.vu",0,"BYga")
  .then((v)=>v.close())
  .then((r)=>r.transform(UTF8.decoder).join())
  .then((s,[i,c="Top!"])=>
      new RegExp(r'
(\d+)[^]*?

          m[1]=="34735"?print(c)
                       :m[2][0]!='-'&&(i=(s=m[0]).indexOf(""))>0
                           ?c=s.substring(i+6,s.indexOf("",i)):0
  ));
}

Python - 280
import os, sys, cgi
os.system('wget http://codegolf.stackexchange.com/questions/34705/output-the-answer-above-yours.html -q -O a')
b=[ x[:-2] for x in open('a').read().split('code>') if x[-1]=='/']
for i, m in enumerate(b):
    if m == cgi.escape(open(sys.argv[0]).read()):
        print b[i-1]

This is my first codegolf, so I hope this is golf-y enough!
Edit: Thanks for the tips! It's looking a bit golfier now.

Doesn't look bad for a first try! Though you could use an URL shortener for the link and get rid of a few spaces in there (for i,m, m==open,etc).

@HackerCow I think URL shorteners are generally frowned on, but http://codegolf.stackexchange.com/q/34705/14509 would definitely work.

@KidElephant I removed a bunch of whitespace from your code. I didn't test it or anything but unless I screwed up it should be (logically) the same program. Note that I removed the shebang, those aren't required here. http://ix.io/dsz Taking out whitespace can save quite a few bytes :)

Also, for code golf challenges you are supposed to include a byte count. I'd edit one in for you here but your answer is probably going to change if you use any suggestions so I won't bother. You can find the byte count by running wc -c $filename. If your editor appends a trailing newline to files (it probably does) you can subtract one from that to get your final score.

Mathematica - 159
First time doing parsing in Mathematica
FirstCase[
 Cases[Import["http://bit.do/JGta1","XMLObject"],
 {__,a_,_,_,_,XMLElement[_, {_, "id""answer-34780",__},_],__}a,∞],
 XMLElement["code",_,{c_}]c,"Top!",∞]

Ruby 283+17 = 300
This succeeds regardless how few votes this answer gets and no matter if there's a second (or fifteenth) page of answers or not.  It uses the data API.
d=34849
JSON.parse(Net::HTTP.get(URI("http://api.stackexchange.com/2.2/questions/34705/answers?site=codegolf&filter=8G3Ng9T*")))['items'].map{|a|abort$1.gsub(/&.+?;/){|g|g[?a]??&:g[?g]??>:?<}if !d&&a['score']>=0&&/(.*?)<\/code>/m=~a['body']
d=p if a['answer_id']==d}
$><<'Top!'

must be run with ruby -rnet/http -rjson (hence the +17)
ungolfed:
d = 34849 # this answer id
i = JSON.parse(Net::HTTP.get(URI("http://api.stackexchange.com/2.2/questions/34705/answers?site=codegolf&filter=8G3Ng9T*")))['items'] # stackexchange api answers for this question
i.map{ |a|
  # if we've already hit this answer, the score's above 0 and there's code...
  if !d && a['score']>=0 && /(.*?)<\/code>/m=~a['body'] then
    # abort with html-unescaped code
    abort $1.gsub(/&.+?;/){ |g|
      # this turns &, > and < into &, > and <, respectively
      g[?a] ? ?& : g[?g] ? ?> : ?<
    }
  end
  # if we are at our answer, set d = nil
  if a['answer_id']==d then
    d = p
  end
}
# no abort. puts 'Top!'
$><<'Top!'

Changelog
300 removed parens in symbol regex
302 initial commit

You can save some bytes by making your filter unsafe

@ppperry please explain?

Using unsafe filters means you want have to manually HTML unescape. See the filter docs

Python 3, 197 191 186 bytes
import urllib.request as u,gzip,json;p='Top!'
for r in json.loads(gzip.decompress(u.urlopen("https://bit.ly/Ƶ").read()).decode())["items"]:
 if r['answer_id']==82837:exit(p)
 p=r['body']

The rules don't say that I can't use the API and that I can't use a url shortener.
https://bit.ly/Ƶ expands to https://api.stackexchange.com/2.2/questions/34705/answers?order=desc&sort=votes&site=codegolf&filter=withbody&pagesize=100
This only works if it is in the top 100 answers sorted by votes.

-6 if you replace https://tinyurl.com/hdemk76 with http://bit.ly/2hN8TKV

-5 if you use https://bit.ly/Ƶ

PHP - 412 - 422 - 416 - 252 - 248:
Still a work in progress, I haven't done anything regarding multiple pages (nor has anyone else?)
I got the 200 character drop by cutting out a lot of extra dom, why search for objects when I can just find their position?
This is also my first code golf! I'm happy to have done it in the 200s and using dom methods. Thanks to comments, I just shaved off 4 more characters.
I wanted to do something like jquery/jscript in regards to traversing the dom, and am still working on slimming this down. Maybe I could get away with searching for "asi" as my user name?
Golf:
<? $d=new DOMDocument;$d->loadHTMLFile("http://bit.do/JGta");$x=new DOMXPath($d);$r=$x->query("//*[@class='answer']");$a=-1;while($f=$r->item(++$a))if(strpos($f->nodeValue,"Asitaka"))echo$x->query(".//pre//code",$r->item($a-1))->item(0)->nodeValue;

Formatted:
    <?php
$d = new DOMDocument();
$d->loadHTMLFile("http://bit.do/JGta");
$x = new DOMXPath($d);
$r = $x->query("//*[@class='answer']");
$a = -1;
while($f = $r->item(++$a))
        if ( stripos($f->nodeValue, "Asitaka")!= 0)
            echo $x->query(".//pre//code",$r->item($a-1))->item(0)->nodeValue;
?>

Cheers

Parentheses in new DOMDocument(), and the closing ?> can be omitted in PHP.

Thanks, lost 4 more characters. At the moment, I can't imagine how to make it shorter unless I use different classes, DOM accessors are expensive.

Save characters by changing your user name!

I think this is cool. I am just trying to learn the query part to DOMXPath but I must admit I am finding it tough. I did try it for this but couldn't quite get it. I tested yours but it seems to be reporting the one two above it, not   the one directly above. I am sure it is a quick fix but just thought I would mention it.

Following this info "Please look at the order when you open this page in private browsing. It's different from the order when you're logged in - core1024" from different answer comment I have to assume the same is happening here too. Sorry for that.

@PaulDrewett - I noticed that too, it's very frustrating for testing when the order is different from here and where the script runs. I, like others, ignored the negative check and multiple pages, but it's pretty easy to add using dom. This is my first time to use dom like this too, I usually access dom via jScript, and found it to be a great learning experience and quite fun!

PHP 135
<?
preg_match_all('@(\d+?)">(.*)</c@Us',join('
',file('http://pi.vu/BYga')),$m);echo$m[2][array_search(34786,$m[1])-1]?:'Top!';

Edit: lrn's URL shortener produces the shortest URL :)
The RegEx matches the anchor before each answer (together with the answer ID) and the contents inside the first  tag. The U flag triggers the Ungreedy mode and the s flag make . matches new lines (very handful). I'm not worried if this matches something else as the answers are escaped, so nobody can insert the < literal in the page's source.
After I get all the answers in $m[2] and their IDs in $m[1], I just use echo to print the answer above mine, as it's in $m[2][array_search(34786,$m[1])-1], or "Top!", if my answer eventually gets first :)
I like the fact that in PHP the ternary operator can be used as a short-circuit operator ?:

That is amazing. I just tested it but it is showing the code from the one below. I am sure this will be a quick fix but thought I would mention it. Amazing job though, 135 in PHP, I still cannot quite believe it...

@PaulDrewett Please look at the order when you open this page in private browsing. It's different from the order when you're logged in.

Oh, that is suprising. I wonder why? Sorry to point out an error in error. My bad. I did upvote you though as a useful answer. I still think it is amazing...

Delphi, 461 bytes, 553 bytes
Now handles multiple pages too!
Golfed:
uses IdHTTP,RegularExpressions;var T,S,O:String;K,V,C:Int32;begin repeat Inc(C);Str(C,S);S:=TIdHTTP.Create.Get('http://codegolf.stackexchange.com/questions/34705/output-the-answer-above-yours?page='+S);T:=T+S;until Pos('<span class="page-numbers next',S)=0;O:='Top!';for T in TRegEx.Split(T,'',S)+6);Val(Copy(S,1,Pos('<',S)-1),V,C);C:=Pos('',S);if(C=0)or(V<0)then Continue;if K=34844then Break;O:=Copy(S,C+6,Pos('',S)-C-6);end;Write(O)end.

(slightly) Ungolfed:
uses
  IdHTTP,RegularExpressions;
var
  T,S,O:String;
  K,V,C:Int32;
begin
  // download all pages in thread and concat them
  repeat
    Inc(C);
    Str(C,S);
    S:=TIdHTTP.Create.Get('http://codegolf.stackexchange.com/questions/34705/output-the-answer-above-yours?page='+S);
    T:=T+S;
  until Pos('<span class="page-numbers next',S)=0;
  O:='Top!'; // initialize code string to 'Top!'
  for T in TRegEx.Split(T,'',S)+6); // prepare S for next parse
    Val(Copy(S,1,Pos('<',S)-1),V,C); // try to extract vote count
    C:=Pos('',S); // check if  tag exists
    if(C=0)or(V<0)then Continue; // make sure vote count is positive and  tag exists
    if K=34844then Break; // if its our answer, break the loop
    O:=Copy(S,C+6,Pos('',S)-C-6); // get string in  tag
  end;
  Write(O); // write  string
end.

How to run:
app.exe > output.txt

nice, could've done that too instead of using the html units.. shame I didn't think of that :P

Thanks. Also, one of the (if not only) codes that handles multiple pages too.

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