The Challenge

Write a complete program that writes twice as many bytes to standard output as the length of the program.

Rules

• The program must write ASCII characters to the standard output.

• The contents of the output doesn't matter.

• The output, measured in bytes, must be exactly twice the length of the program, also measured in bytes, unless you fulfill the bonus.

• Any trailing newline is included in the output's byte count.

Bonus

Your program can optionally take a number, n, as input. If so, the output must be exactly n * program length bytes. You can assume that n will always be a positive integer. If no input is provided, n must default to 2.

If you do this, you can subtract 25 bytes from your score.

Shortest program wins.

Restrictions

• No standard loopholes.

• The program must be at least 1 byte long.

• No adding unnecessary whitespace to the source code to change its length. Similarly, comments don't count.

• Unless you fulfill the bonus, the program must accept no input. If you do fulfill the bonus, the integer must be the only input.

Lowest score (program length in bytes - bonus) wins.

The shortest answer for each language wins for that language.

Here is a Stack Snippet to generate both a regular leaderboard and an overview of winners by language.

# Language Name, N bytes

where N is the size of your submission. If you improve your score, you can keep old scores in the headline, by striking them through. For instance:

# Ruby, <s>104</s> <s>101</s> 96 bytes

If there you want to include multiple numbers in your header (e.g. because your score is the sum of two files or you want to list interpreter flag penalties separately), make sure that the actual score is the last number in the header:

# Perl, 43 + 2 (-p flag) = 45 bytes

You can also make the language name a link which will then show up in the leaderboard snippet:

# [><>](http://esolangs.org/wiki/Fish), 121 bytes

• For the bonus, does the output have to be exactly n * program length bytes, or is that a minimum? – xnor Oct 2 '15 at 23:19
• It has to be exact – Daniel M. Oct 2 '15 at 23:20
• Looks like the code snippet has to be modified to handle negative scores. – El'endia Starman Oct 2 '15 at 23:49
• A bonus of -25 is basically mandatory for some languages, since it lets them achieve a negative score. In the future, I'd suggest using a percent bonus, or just making the bonus the question if you really want answers to go for it. Or, just don't have a bonus. – xnor Oct 2 '15 at 23:58
• For "no input is provided", do we assume the empty string is passed in? I can't see how one would deal with the user never typing in an input and the program just waiting. – xnor Oct 2 '15 at 23:59

TI-BASIC, 1 byte

0

Output:

0    ;there is a newline; counts as char

Thanks to Thomas Kwa for his spectacular observation. The i/o looks as thus:

0
0   ;right-aligned, but newline is part of output.
• I think the newline counts as part of the output. – lirtosiast Oct 4 '15 at 17:53
• @ThomasKwa What newline? You mean the "enter" key? – Conor O'Brien Oct 4 '15 at 18:18
• No, the newline printed automatically after every program is executed. – lirtosiast Oct 4 '15 at 18:32
• Oh. So change it to ᴇ3? – Conor O'Brien Oct 4 '15 at 18:36
• Yes, but it can just be 0 as I commented on the other TI-BASIC answer by Deusovi. – lirtosiast Oct 4 '15 at 18:39

Shakespeare Programming Language, 216 192 191 bytes

Twice the source.Ajax,.Puck,.Act I:.Scene I:.[Exeunt][Enter Ajax and Puck]Ajax:Open heart!You big big big big big big big cat!Puck:You is the sum ofyou a cat!Be you worse I?If solet us Act I!

Try it online!

Prints a 0 followed by 128 128s.

$bubblegum double.bg !# • That's two or three bytes, one character (depends on encoding). Do bytes == characters here? – Nateowami Oct 5 '15 at 10:23 • I/O is raw in Bubblegum. It only knows bytes, not characters. – Dennis Oct 5 '15 at 13:33 • Yeah, that's what I was thinking, but... how is Ä one byte in any sense? After all, if input is raw, that's two bytes, that just happen to be one character. Am I missing something? How can Ä possibly be "1 byte"? – Nateowami Oct 6 '15 at 9:12 • @Nateowami in ISO-8859-1, for example, Ä is a single byte, 0xC4. – primo Oct 6 '15 at 11:34 • @primo Thanks, I wouldn't have guessed. Perhaps the encoding should be specified though, because using the reference implementation I get -M?). Likely the encoding got changed when the post was submitted (or else when I used echo Ä > file.txt and gedit). – Nateowami Oct 6 '15 at 11:57 Python 2.7, 26 24 - 25 = -1 byte def s(c=2):print'A'*24*c 24 characters long, prints twice its length on no input: >>> s() AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA prints n*length for any other input: >>> s(1) AAAAAAAAAAAAAAAAAAAAAAAA >>> s(3) AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA Java 8, 82 Bytes interface A{static void main(String[]s){for(A a:new A[164])System.out.println();}} Prints out 164 empty lines. C, 36 bytes main(a){for(a=4;a--;)puts(puts);}//! Really hacky stuff here. The implementation of puts on my machine (gcc 6.3) has 16 bytes before it hits a null, and adds a newline and SOH (18 bytes total). Run four times, and it's 72 (or 0x48) chars. I padded mine with a 3-char comment to fit that. Most of the chars are unreadable, so here's a hexdump of the output. 0000000 5541 5441 8949 55fc 4853 ec83 e808 76ae 0000010 0a01 5541 5441 8949 55fc 4853 ec83 e808 0000020 76ae 0a01 5541 5441 8949 55fc 4853 ec83 0000030 e808 76ae 0a01 5541 5441 8949 55fc 4853 0000040 ec83 e808 76ae 0a01 0000048 Mouse, 21 bytes 1I:(I.43<^9!1I.+I:)$

Ungolfed:

1 I:                  ~ Begin a loop index at 1
( I. 43 < ^           ~ While I < 43...
9 !                 ~ Print 9 to STDOUT
1 I. + I:           ~ Increment I
)$• I didn't know others knew Mouse! you csn shave bytes by not initialisingI, because its value will start at zero, and making it 42 instead. – cat Dec 16 '15 at 12:17 • eg. (i.31<^9!i.1+i:) is 16 bytes – cat Dec 16 '15 at 13:34 q, 10 3 bytes 3#0 Outputs 6 bytes: "0 0 0\n". • If I understand the challenge correctly, an 8-byte long program should produce 16 bytes of output... – undergroundmonorail Oct 3 '15 at 5:46 • Right. I should have read past the title. I've updated my answer. – Alexander Belopolsky Oct 3 '15 at 6:19 JavaScript (ES6), 24 30 - 25 = 5 bytes alert('s'.repeat(30*prompt())) • The question requires a full program. Your code will only work inside a REPL environment. – Dennis Oct 4 '15 at 13:32 • @Dennis, there is no other way for JavaScript to receive input, and using prompt is standard practice in other golfing challenges where input is required. – Patrick Roberts Oct 4 '15 at 14:19 • @PatrickRoberts If you use prompt to input, then you should use something like alert to output. – Doorknob Oct 4 '15 at 14:27 • prompt isn't the issue. This will produce no output outside a REPL environment. – Dennis Oct 4 '15 at 14:59 • I updated the answer to alert the value, also removing the unnecessary unary plus operator since the multiplication will coerce the value to a number. – Patrick Roberts Oct 4 '15 at 16:22 C, 23 (without bonus) main(){printf("%46d");} Outputs an uninitialized value, padded by spaces to 46 bytes. Trying to do it with a bonus, I arrived to a tie. I don't know whether it's unfortunate or cool. C, 23 (with bonus) main(x){printf("%*d",(~scanf("%d",&x)?x:2)*48);} The code has 48 bytes. I use bit-complement ~ to check whether scanf returned -1. Python 2, 11 bytes print 9**21 displays 109418989131512359209\n (22 chars) Funciton, 78 bytes Not very advanced. Just output 156 As. Of course you can change 65 to any two-digit ASCII code. If non-printable characters are allowed as well, you could shorten it by 6 bytes by outputting character #1 144 times. ╔═══╗┌─╖╔══╗ ║156╟┤…╟╢65║ ╚═══╝╘╤╝╚══╝ • You could use the TAB character, 9. – Titus Jan 27 '17 at 6:36 Vitsy, 14 11 - 25 = -14 Bytes Note: This language was made after this question was asked, but it was not created for this task. 2a{b*\[DO]; I'm pretty sure this can be golfed down a little more, but here you go: 2a{b*\[DO]; 2 Push 2 to the stack as the backup value - if input is pushed, then it will already exist in the stack. a Push "\n" (the literal) to the stack as an integer - this will be our output. { Rotate the stack to the left b* Multiply the top value (used to be the back-most (2 or input) value) by 11. \[..] Repeat as many times as the top item of the stack specifies for all instructions within [] DO Duplicate the top value, then output it. ; End execution. Common Lisp REPL, 9 (write -) - is a variable that holds the currently evaluating expression in the REPL, while write returns whatever it writes. So it writes (write -) then returns "(write -)" which is printed by the REPL without the quotes. (If this was done in an REL instead of an REPL, then it'd be a quine instead.) Python, 15 bytes print 'aaaaa'*6 Prints: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa Which is 30 bytes. • There are already two shorter Python 2 answers. – lirtosiast Oct 27 '15 at 14:50 • @ThomasKwa well I'm sorry I didn't read through all 110 answers </sarcasm> – TheDoctor Oct 27 '15 at 14:52 • There's a stack snippet at the top. All you need to do is click two buttons and scroll down to Python. Both of those answers were on the first page anyway. – lirtosiast Oct 27 '15 at 14:58 • You could use print'a'*11 to save 4 bytes. – ASCIIThenANSI Dec 17 '15 at 16:00 • @ASCIIThenANSI print'a'*22. The output needs to be twice the length of your code. – Erik the Outgolfer Sep 22 '16 at 14:27 J, 653 2 bytes (bonus: -11 bytes) (try it online) Program: %4 Output: 0.25 Explanation: The reciprocal of 4. Bonus: 10,1$~_1+7*]/2

Testcases:

10,1$~_1+7*]/2 :10 1 1 1 1 1 1 1 1 1 1 1 1 1 10,1$~_1+7*]/2 2  :10 1 1 1 1 1 1 1 1 1 1 1 1 1
10,1$~_1+7*]/2 3 :10 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Explanation: 10, NB. prepend 10 to 1$~            NB. the "~" reverses the arguments.
NB.    e.g. 1 $~ 5 becomes 5$ 1.
NB.    5 $1 means create an array of size 5, NB. using the number 1. The number is NB. recycled because there is not enough number. NB. For example, 5$1 2 3 would produce 1 2 3 1 2.
_1+         NB. add negative one to
7*       NB. seven multiplied by
]/2    NB. if the input is 5, then this part
NB.    becomes 2]5, which evaluates to 5.
NB.    if there is no input, then this
NB.    part is only 2.

3-byte attempt:

7^7

Output:

823543

Explanation: 7 raised to the power 7.

Notes: Looks like I am not the first one to discover this.

5-byte attempt:

Program:

*:i.5

Output:

0 1 4 9 16

Explanation: *: means square. i.5 means generate a list from 0 to 4

6-byte attempt:

Program:

10,5$5 Output: 10 5 5 5 5 5 Explanation: 5$5 means create an array of size 5 (on the left of $), using the number 5 (on the right of$). The number is recycled because there is not enough number.

For example, 5$1 2 3 would produce 1 2 3 1 2. • Looks like I am not the first one to discover <code>7^7</code>... never mind, I still discovered it myself. – Leaky Nun Mar 30 '16 at 2:15 Desmos, 3 bytes 9^6 Equals 531441 • I'm not sure desmos is considered a language, though it is pretty awesome. – Daniel M. Jul 3 '16 at 22:54 • Desmos is technically a programming language since you can program things with it. – weatherman115 Jul 4 '16 at 1:22 • – Mego Jul 4 '16 at 5:21 05AB1E, 6 - 25 = -19 bytes (noncompeting) VžOY×? Try it online! VžMY×? Argument n V Assign n to Y, if n is empty Y defaults to 2 žO Push 'aeiouy' to stack (has same length as program) Y× Repeat the string Y times ? Print top of stack without newline • You have been outgolfed. – Oliver Ni Jun 3 '17 at 16:05 • @OliverNi Does the input default to 2 if not given? – kalsowerus Jun 3 '17 at 16:09 • Oh. I'll fix that. – Oliver Ni Jun 3 '17 at 16:18 Bash, 5 bytes seq 5 Output (with a newline char on the end of each gives 10 bytes)... 1 2 3 4 5 Whitespace, 38 36 bytes SSTTTSTTNNSSNSNSTNSTSSSTNTSSSSNSNTTN Try it online! Prints "-27-26-25-24-23-22-21-20-19-18-17-16-15-14-13-12-11-10-9-8-7-6-5-4-3-2-1". Whitespace doesn't have optional input so I can't go for the bonus. • Could you print -1 to shorten it? – Jo King May 21 '18 at 22:50 • @JoKing managed to save off 2 bytes with an idea I got from your suggestion. – CensoredUsername May 21 '18 at 23:02 PowerShell, 3 bytes 1e4 Try it online! PowerShell, 1 byte Thanks to @mazzy for pointing this one out! 1 Try it online! Both programs' outputs includes a trailing newline! • You could to try 1. Output includes a trailing newline! – mazzy Dec 9 '18 at 7:03 Perl 6, 17 - 25 = -8 points print e x(get||2) Try it online! Prints the builtin constant e ($$\2.718281828459045\$$) either input or 2 times. Luckily, the precision of the constant is 17 bytes long, exactly the same as my code length. Explanation: print # Print without newline e # The constant e (2.718281828459045) x( ) # String multiplied by get # The input ||2 # Or two if the input does not exist Deadfish~, 5 bytes You expected a worthwhile submission, but it was ME: {dio} Try it online! Prints the number "1" ten times. Ruby, 6 bytes p ?a*9 Prints "aaaaaaaaa" (including the quotes) and a newline. JavaScript (ES6), 23 bytes - 25 = -2 (n=2)=>'x'.repeat(23*n) Just for fun here's a quine version with a score of 27 bytes -25 =2 a=(n=2)=>a=${a}.repeat(n)
• Does this really write to standard output? – user253751 Oct 3 '15 at 0:26
• It's a function return, using fat arrow notation. – MayorMonty Oct 3 '15 at 2:25
• The spec requires a full program... – John Dvorak Oct 3 '15 at 16:39
• Running this program just gives me a function. Its output is a function that the length isn't double, nor does it take standard input. – Unihedron Oct 4 '15 at 12:57
• Writing functions that return the required result, as well as taking input from function arguments, is allowed. – ivzem May 24 '17 at 12:50

PHP 7, 9 Bytes

<?=str_repeat(1,($argv[1]??2)*34); Uses the short opening tag with echo <?= and the null coalesce operator ?? which falls back to 2 if$argv[1] is not set, without throwing an error.

Element, 16 bytes - 25 bonus = -9

_2:1<[2]16*'[X]

Explanation:

_2:1<[2]16*'[X]
_                  take input
2:                duplicate it
1<              test "if less than one" (like an empty input)
[2]           FOR/IF push 2 if true
16*        multiply by 16
'       move result to control stack
[  ]   FOR
X    output the letter X

Element, 6 bytes

9 12^

prints 282429536481

Explanation:

9       push 9
12^   to the twelfth power
`  output